diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake --- a/libc/cmake/modules/LLVMLibCArchitectures.cmake +++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake @@ -150,10 +150,12 @@ set(LIBC_TARGET_ARCHITECTURE_IS_AARCH64 TRUE) elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "x86_64") set(LIBC_TARGET_ARCHITECTURE_IS_X86 TRUE) -elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "riscv32") - set(LIBC_TARGET_ARCHITECTURE_IS_RISCV32 TRUE) elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "riscv64") set(LIBC_TARGET_ARCHITECTURE_IS_RISCV64 TRUE) + set(LIBC_TARGET_ARCHITECTURE "riscv") +elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "riscv32") + set(LIBC_TARGET_ARCHITECTURE_IS_RISCV32 TRUE) + set(LIBC_TARGET_ARCHITECTURE "riscv") else() message(FATAL_ERROR "Unsupported libc target architecture ${LIBC_TARGET_ARCHITECTURE}") diff --git a/libc/config/linux/app.h b/libc/config/linux/app.h --- a/libc/config/linux/app.h +++ b/libc/config/linux/app.h @@ -37,7 +37,7 @@ #if defined(LIBC_TARGET_ARCH_IS_X86_64) || \ defined(LIBC_TARGET_ARCH_IS_AARCH64) || \ - defined(LIBC_TARGET_ARCH_IS_RISCV64) + defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) // At the language level, argc is an int. But we use uint64_t as the x86_64 // ABI specifies it as an 8 byte value. Likewise, in the ARM64 ABI, arguments // are usually passed in registers. x0 is a doubleword register, so this is diff --git a/libc/config/linux/riscv64/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt rename from libc/config/linux/riscv64/entrypoints.txt rename to libc/config/linux/riscv/entrypoints.txt diff --git a/libc/config/linux/riscv64/headers.txt b/libc/config/linux/riscv/headers.txt rename from libc/config/linux/riscv64/headers.txt rename to libc/config/linux/riscv/headers.txt diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h --- a/libc/src/__support/FPUtil/FEnvImpl.h +++ b/libc/src/__support/FPUtil/FEnvImpl.h @@ -30,10 +30,8 @@ #include "x86_64/FEnvImpl.h" #elif defined(LIBC_TARGET_ARCH_IS_ARM) #include "arm/FEnvImpl.h" -#elif defined(LIBC_TARGET_ARCH_IS_RISCV32) -#include "riscv32/FEnvImpl.h" -#elif defined(LIBC_TARGET_ARCH_IS_RISCV64) -#include "riscv64/FEnvImpl.h" +#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) +#include "riscv/FEnvImpl.h" #else namespace __llvm_libc::fputil { diff --git a/libc/src/__support/FPUtil/FMA.h b/libc/src/__support/FPUtil/FMA.h --- a/libc/src/__support/FPUtil/FMA.h +++ b/libc/src/__support/FPUtil/FMA.h @@ -18,8 +18,8 @@ #include "x86_64/FMA.h" #elif defined(LIBC_TARGET_ARCH_IS_AARCH64) #include "aarch64/FMA.h" -#elif defined(LIBC_TARGET_ARCH_IS_RISCV64) -#include "riscv64/FMA.h" +#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) +#include "riscv/FMA.h" #elif defined(LIBC_TARGET_ARCH_IS_GPU) #include "gpu/FMA.h" #endif diff --git a/libc/src/__support/FPUtil/riscv64/FEnvImpl.h b/libc/src/__support/FPUtil/riscv/FEnvImpl.h rename from libc/src/__support/FPUtil/riscv64/FEnvImpl.h rename to libc/src/__support/FPUtil/riscv/FEnvImpl.h diff --git a/libc/src/__support/FPUtil/riscv64/FMA.h b/libc/src/__support/FPUtil/riscv/FMA.h rename from libc/src/__support/FPUtil/riscv64/FMA.h rename to libc/src/__support/FPUtil/riscv/FMA.h --- a/libc/src/__support/FPUtil/riscv64/FMA.h +++ b/libc/src/__support/FPUtil/riscv/FMA.h @@ -13,7 +13,7 @@ #include "src/__support/macros/properties/architectures.h" #include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA -#if !defined(LIBC_TARGET_ARCH_IS_RISCV64) +#if !defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/riscv64/sqrt.h b/libc/src/__support/FPUtil/riscv/sqrt.h rename from libc/src/__support/FPUtil/riscv64/sqrt.h rename to libc/src/__support/FPUtil/riscv/sqrt.h --- a/libc/src/__support/FPUtil/riscv64/sqrt.h +++ b/libc/src/__support/FPUtil/riscv/sqrt.h @@ -12,7 +12,7 @@ #include "src/__support/common.h" #include "src/__support/macros/properties/architectures.h" -#if !defined(LIBC_TARGET_ARCH_IS_RISCV64) +#if !defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/sqrt.h b/libc/src/__support/FPUtil/sqrt.h --- a/libc/src/__support/FPUtil/sqrt.h +++ b/libc/src/__support/FPUtil/sqrt.h @@ -15,8 +15,8 @@ #include "x86_64/sqrt.h" #elif defined(LIBC_TARGET_ARCH_IS_AARCH64) #include "aarch64/sqrt.h" -#elif defined(LIBC_TARGET_ARCH_IS_RISCV64) -#include "riscv64/sqrt.h" +#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) +#include "riscv/sqrt.h" #else #include "generic/sqrt.h" diff --git a/libc/src/__support/OSUtil/linux/riscv64/CMakeLists.txt b/libc/src/__support/OSUtil/linux/riscv/CMakeLists.txt rename from libc/src/__support/OSUtil/linux/riscv64/CMakeLists.txt rename to libc/src/__support/OSUtil/linux/riscv/CMakeLists.txt --- a/libc/src/__support/OSUtil/linux/riscv64/CMakeLists.txt +++ b/libc/src/__support/OSUtil/linux/riscv/CMakeLists.txt @@ -1,5 +1,5 @@ add_header_library( - linux_riscv64_util + linux_riscv_util HDRS syscall.h DEPENDS diff --git a/libc/src/__support/OSUtil/linux/riscv64/syscall.h b/libc/src/__support/OSUtil/linux/riscv/syscall.h rename from libc/src/__support/OSUtil/linux/riscv64/syscall.h rename to libc/src/__support/OSUtil/linux/riscv/syscall.h diff --git a/libc/src/__support/OSUtil/linux/syscall.h b/libc/src/__support/OSUtil/linux/syscall.h --- a/libc/src/__support/OSUtil/linux/syscall.h +++ b/libc/src/__support/OSUtil/linux/syscall.h @@ -19,8 +19,8 @@ #include "aarch64/syscall.h" #elif defined(LIBC_TARGET_ARCH_IS_ARM) #include "arm/syscall.h" -#elif defined(LIBC_TARGET_ARCH_IS_RISCV64) -#include "riscv64/syscall.h" +#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) +#include "riscv/syscall.h" #endif namespace __llvm_libc { diff --git a/libc/src/__support/macros/properties/architectures.h b/libc/src/__support/macros/properties/architectures.h --- a/libc/src/__support/macros/properties/architectures.h +++ b/libc/src/__support/macros/properties/architectures.h @@ -45,7 +45,7 @@ #define LIBC_TARGET_ARCH_IS_AARCH64 #endif -#if (defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_ARM)) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_ARM) #define LIBC_TARGET_ARCH_IS_ANY_ARM #endif @@ -57,8 +57,7 @@ #define LIBC_TARGET_ARCH_IS_RISCV32 #endif -#if (defined(LIBC_TARGET_ARCH_IS_RISCV64) || \ - defined(LIBC_TARGET_ARCH_IS_RISCV32)) +#if defined(LIBC_TARGET_ARCH_IS_RISCV64) || defined(LIBC_TARGET_ARCH_IS_RISCV32) #define LIBC_TARGET_ARCH_IS_ANY_RISCV #endif diff --git a/libc/src/__support/threads/linux/thread.cpp b/libc/src/__support/threads/linux/thread.cpp --- a/libc/src/__support/threads/linux/thread.cpp +++ b/libc/src/__support/threads/linux/thread.cpp @@ -57,7 +57,7 @@ #ifdef LIBC_TARGET_ARCH_IS_AARCH64 #define CLONE_RESULT_REGISTER "x0" -#elif defined(LIBC_TARGET_ARCH_IS_RISCV64) +#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) #define CLONE_RESULT_REGISTER "t0" #elif defined(LIBC_TARGET_ARCH_IS_X86_64) #define CLONE_RESULT_REGISTER "rax" @@ -169,7 +169,7 @@ // is set to the stack pointer where start args are stored. So, we fetch // from there. return reinterpret_cast(__builtin_frame_address(1)); -#elif defined(LIBC_TARGET_ARCH_IS_RISCV64) +#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) // The current frame pointer is the previous stack pointer where the start // args are stored. return reinterpret_cast(__builtin_frame_address(0)); @@ -306,7 +306,7 @@ tls.tp // The thread pointer value for the new thread. ); #elif defined(LIBC_TARGET_ARCH_IS_AARCH64) || \ - defined(LIBC_TARGET_ARCH_IS_RISCV64) + defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) long register clone_result asm(CLONE_RESULT_REGISTER); clone_result = __llvm_libc::syscall_impl( SYS_clone, CLONE_SYSCALL_FLAGS, adjusted_stack, diff --git a/libc/src/__support/threads/thread.h b/libc/src/__support/threads/thread.h --- a/libc/src/__support/threads/thread.h +++ b/libc/src/__support/threads/thread.h @@ -41,7 +41,7 @@ #if (defined(LIBC_TARGET_ARCH_IS_AARCH64) || \ defined(LIBC_TARGET_ARCH_IS_X86_64) || \ - defined(LIBC_TARGET_ARCH_IS_RISCV64)) + defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)) constexpr unsigned int STACK_ALIGNMENT = 16; #endif // TODO: Provide stack alignment requirements for other architectures. diff --git a/libc/src/setjmp/riscv64/CMakeLists.txt b/libc/src/setjmp/riscv/CMakeLists.txt rename from libc/src/setjmp/riscv64/CMakeLists.txt rename to libc/src/setjmp/riscv/CMakeLists.txt diff --git a/libc/src/setjmp/riscv64/longjmp.cpp b/libc/src/setjmp/riscv/longjmp.cpp rename from libc/src/setjmp/riscv64/longjmp.cpp rename to libc/src/setjmp/riscv/longjmp.cpp --- a/libc/src/setjmp/riscv64/longjmp.cpp +++ b/libc/src/setjmp/riscv/longjmp.cpp @@ -12,7 +12,7 @@ #include -#if !defined(LIBC_TARGET_ARCH_IS_RISCV64) +#if !defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) #error "Invalid file include" #endif diff --git a/libc/src/setjmp/riscv64/setjmp.cpp b/libc/src/setjmp/riscv/setjmp.cpp rename from libc/src/setjmp/riscv64/setjmp.cpp rename to libc/src/setjmp/riscv/setjmp.cpp --- a/libc/src/setjmp/riscv64/setjmp.cpp +++ b/libc/src/setjmp/riscv/setjmp.cpp @@ -11,7 +11,7 @@ #include -#if !defined(LIBC_TARGET_ARCH_IS_RISCV64) +#if !defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) #error "Invalid file include" #endif diff --git a/libc/startup/linux/riscv64/CMakeLists.txt b/libc/startup/linux/riscv/CMakeLists.txt rename from libc/startup/linux/riscv64/CMakeLists.txt rename to libc/startup/linux/riscv/CMakeLists.txt diff --git a/libc/startup/linux/riscv64/start.cpp b/libc/startup/linux/riscv/start.cpp rename from libc/startup/linux/riscv64/start.cpp rename to libc/startup/linux/riscv/start.cpp diff --git a/libc/test/src/fenv/enabled_exceptions_test.cpp b/libc/test/src/fenv/enabled_exceptions_test.cpp --- a/libc/test/src/fenv/enabled_exceptions_test.cpp +++ b/libc/test/src/fenv/enabled_exceptions_test.cpp @@ -21,7 +21,8 @@ // This test enables an exception and verifies that raising that exception // triggers SIGFPE. TEST(LlvmLibcExceptionStatusTest, RaiseAndCrash) { -#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || defined(LIBC_TARGET_ARCH_IS_RISCV64) +#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || \ + defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) // Few Arm HW implementations do not trap exceptions. We skip this test // completely on such HW. // diff --git a/libc/test/src/fenv/feenableexcept_test.cpp b/libc/test/src/fenv/feenableexcept_test.cpp --- a/libc/test/src/fenv/feenableexcept_test.cpp +++ b/libc/test/src/fenv/feenableexcept_test.cpp @@ -16,7 +16,8 @@ #include TEST(LlvmLibcFEnvTest, EnableTest) { -#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || defined(LIBC_TARGET_ARCH_IS_RISCV64) +#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || \ + defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) // Few Arm HW implementations do not trap exceptions. We skip this test // completely on such HW. // diff --git a/libc/test/src/fenv/feholdexcept_test.cpp b/libc/test/src/fenv/feholdexcept_test.cpp --- a/libc/test/src/fenv/feholdexcept_test.cpp +++ b/libc/test/src/fenv/feholdexcept_test.cpp @@ -16,7 +16,8 @@ #include TEST(LlvmLibcFEnvTest, RaiseAndCrash) { -#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || defined(LIBC_TARGET_ARCH_IS_RISCV64) +#if defined(LIBC_TARGET_ARCH_IS_ANY_ARM) || \ + defined(LIBC_TARGET_ARCH_IS_ANY_RISCV) // Few Arm HW implementations do not trap exceptions. We skip this test // completely on such HW. // diff --git a/libc/test/src/math/exhaustive/CMakeLists.txt b/libc/test/src/math/exhaustive/CMakeLists.txt --- a/libc/test/src/math/exhaustive/CMakeLists.txt +++ b/libc/test/src/math/exhaustive/CMakeLists.txt @@ -21,6 +21,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -38,6 +39,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -55,6 +57,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -72,6 +75,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -89,6 +93,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -106,6 +111,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -123,6 +129,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -140,6 +147,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -157,6 +165,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -174,6 +183,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -191,6 +201,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -208,6 +219,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -225,6 +237,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -242,6 +255,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -261,6 +275,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -291,6 +306,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -308,6 +324,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -325,6 +342,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -342,6 +360,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -359,6 +378,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -376,6 +396,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -393,6 +414,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -410,6 +432,7 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic ) add_fp_unittest( @@ -427,4 +450,5 @@ libc.src.__support.FPUtil.fp_bits LINK_LIBRARIES -lpthread + -latomic )