From a2569a76e034d98b067805d3c577d46eb6766506 Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Tue, 7 Feb 2023 20:41:30 +0000 Subject: [PATCH] [libc][NFC] Rename macros --- libc/cmake/modules/cpu_features/check_AVX2.cpp | 2 +- libc/cmake/modules/cpu_features/check_AVX512BW.cpp | 2 +- libc/cmake/modules/cpu_features/check_AVX512F.cpp | 2 +- libc/cmake/modules/cpu_features/check_FMA.cpp | 2 +- libc/cmake/modules/cpu_features/check_SSE2.cpp | 2 +- libc/cmake/modules/cpu_features/check_SSE4_2.cpp | 2 +- libc/config/linux/app.h | 2 +- libc/docs/code_style.rst | 4 +-- libc/src/__support/FPUtil/FEnvImpl.h | 4 +-- libc/src/__support/FPUtil/FMA.h | 6 ++-- libc/src/__support/FPUtil/PlatformDefs.h | 2 +- libc/src/__support/FPUtil/aarch64/FEnvImpl.h | 2 +- libc/src/__support/FPUtil/aarch64/FMA.h | 4 +-- .../__support/FPUtil/aarch64/fenv_darwin_impl.h | 2 +- .../src/__support/FPUtil/aarch64/nearest_integer.h | 2 +- libc/src/__support/FPUtil/aarch64/sqrt.h | 2 +- libc/src/__support/FPUtil/multiply_add.h | 4 +-- libc/src/__support/FPUtil/nearest_integer.h | 5 ++-- libc/src/__support/FPUtil/sqrt.h | 4 +-- libc/src/__support/FPUtil/x86_64/FEnvImpl.h | 2 +- libc/src/__support/FPUtil/x86_64/FMA.h | 4 +-- libc/src/__support/FPUtil/x86_64/LongDoubleBits.h | 2 +- .../__support/FPUtil/x86_64/NextAfterLongDouble.h | 2 +- libc/src/__support/FPUtil/x86_64/PolyEval.h | 2 +- libc/src/__support/FPUtil/x86_64/nearest_integer.h | 2 +- libc/src/__support/FPUtil/x86_64/sqrt.h | 2 +- libc/src/__support/OSUtil/linux/syscall.h | 6 ++-- libc/src/__support/common.h | 2 +- libc/src/__support/macros/architectures.h | 32 +++++++++++----------- libc/src/__support/macros/cpu_features.h | 14 +++++----- libc/src/__support/threads/linux/thread.cpp | 12 ++++---- libc/src/__support/threads/thread.h | 3 +- libc/src/math/generic/asinf.cpp | 4 +-- libc/src/math/generic/cosf.cpp | 4 +-- libc/src/math/generic/expm1f.cpp | 8 +++--- libc/src/math/generic/sincosf.cpp | 4 +-- libc/src/math/generic/sincosf_utils.h | 4 +-- libc/src/math/generic/sinf.cpp | 6 ++-- libc/src/math/generic/tanf.cpp | 4 +-- libc/src/math/generic/tanhf.cpp | 4 +-- libc/src/setjmp/longjmp.cpp | 4 +-- libc/src/setjmp/setjmp.cpp | 4 +-- .../src/string/memory_utils/bcmp_implementations.h | 21 +++++++------- .../string/memory_utils/memcmp_implementations.h | 23 ++++++++-------- .../string/memory_utils/memcpy_implementations.h | 16 +++++------ .../string/memory_utils/memmove_implementations.h | 10 +++---- .../string/memory_utils/memset_implementations.h | 16 +++++------ libc/src/string/memory_utils/op_aarch64.h | 4 +-- libc/src/string/memory_utils/op_generic.h | 2 +- libc/src/string/memory_utils/op_x86.h | 4 +-- libc/src/threads/linux/Futex.h | 3 +- libc/test/src/fenv/enabled_exceptions_test.cpp | 4 +-- libc/test/src/fenv/feenableexcept_test.cpp | 4 +-- libc/test/src/fenv/feholdexcept_test.cpp | 4 +-- libc/test/src/string/memory_utils/op_tests.cpp | 4 +-- libc/test/src/sys/utsname/uname_test.cpp | 4 +-- 56 files changed, 155 insertions(+), 150 deletions(-) diff --git a/libc/cmake/modules/cpu_features/check_AVX2.cpp b/libc/cmake/modules/cpu_features/check_AVX2.cpp index 024dd40..5fde894 100644 --- a/libc/cmake/modules/cpu_features/check_AVX2.cpp +++ b/libc/cmake/modules/cpu_features/check_AVX2.cpp @@ -1,5 +1,5 @@ #include "src/__support/macros/cpu_features.h" -#ifndef LIBC_TARGET_HAS_AVX2 +#ifndef LIBC_TARGET_CPU_HAS_AVX2 #error unsupported #endif diff --git a/libc/cmake/modules/cpu_features/check_AVX512BW.cpp b/libc/cmake/modules/cpu_features/check_AVX512BW.cpp index 5010612..084a215 100644 --- a/libc/cmake/modules/cpu_features/check_AVX512BW.cpp +++ b/libc/cmake/modules/cpu_features/check_AVX512BW.cpp @@ -1,5 +1,5 @@ #include "src/__support/macros/cpu_features.h" -#ifndef LIBC_TARGET_HAS_AVX512BW +#ifndef LIBC_TARGET_CPU_HAS_AVX512BW #error unsupported #endif diff --git a/libc/cmake/modules/cpu_features/check_AVX512F.cpp b/libc/cmake/modules/cpu_features/check_AVX512F.cpp index 2bab186..2d3f171 100644 --- a/libc/cmake/modules/cpu_features/check_AVX512F.cpp +++ b/libc/cmake/modules/cpu_features/check_AVX512F.cpp @@ -1,5 +1,5 @@ #include "src/__support/macros/cpu_features.h" -#ifndef LIBC_TARGET_HAS_AVX512F +#ifndef LIBC_TARGET_CPU_HAS_AVX512F #error unsupported #endif diff --git a/libc/cmake/modules/cpu_features/check_FMA.cpp b/libc/cmake/modules/cpu_features/check_FMA.cpp index b524476..69e979c 100644 --- a/libc/cmake/modules/cpu_features/check_FMA.cpp +++ b/libc/cmake/modules/cpu_features/check_FMA.cpp @@ -1,5 +1,5 @@ #include "src/__support/macros/cpu_features.h" -#ifndef LIBC_TARGET_HAS_FMA +#ifndef LIBC_TARGET_CPU_HAS_FMA #error unsupported #endif diff --git a/libc/cmake/modules/cpu_features/check_SSE2.cpp b/libc/cmake/modules/cpu_features/check_SSE2.cpp index d1c01ee..cbc9813 100644 --- a/libc/cmake/modules/cpu_features/check_SSE2.cpp +++ b/libc/cmake/modules/cpu_features/check_SSE2.cpp @@ -1,5 +1,5 @@ #include "src/__support/macros/cpu_features.h" -#ifndef LIBC_TARGET_HAS_SSE2 +#ifndef LIBC_TARGET_CPU_HAS_SSE2 #error unsupported #endif diff --git a/libc/cmake/modules/cpu_features/check_SSE4_2.cpp b/libc/cmake/modules/cpu_features/check_SSE4_2.cpp index 5280430..3c0bae8 100644 --- a/libc/cmake/modules/cpu_features/check_SSE4_2.cpp +++ b/libc/cmake/modules/cpu_features/check_SSE4_2.cpp @@ -1,5 +1,5 @@ #include "src/__support/macros/cpu_features.h" -#ifndef LIBC_TARGET_HAS_SSE4_2 +#ifndef LIBC_TARGET_CPU_HAS_SSE4_2 #error unsupported #endif diff --git a/libc/config/linux/app.h b/libc/config/linux/app.h index 67a3624..08d7f2a 100644 --- a/libc/config/linux/app.h +++ b/libc/config/linux/app.h @@ -35,7 +35,7 @@ struct TLSImage { uintptr_t align; }; -#if defined(LIBC_TARGET_IS_X86_64) || defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_X86_64) || defined(LIBC_TARGET_ARCH_IS_AARCH64) // 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/docs/code_style.rst b/libc/docs/code_style.rst index b9c71a6..74fe8de 100644 --- a/libc/docs/code_style.rst +++ b/libc/docs/code_style.rst @@ -39,8 +39,8 @@ We define two kinds of macros: **code defined** and **build defined** macros. * **Properties** - Build related properties like used compiler, target architecture or enabled CPU features defined by introspecting compiler - defined preprocessor defininitions. e.g., ``LIBC_TARGET_IS_ARM``, - ``LIBC_TARGET_HAS_AVX2``, ``LIBC_COMPILER_IS_CLANG``, ... + defined preprocessor defininitions. e.g., ``LIBC_TARGET_ARCH_IS_ARM``, + ``LIBC_TARGET_CPU_HAS_AVX2``, ``LIBC_COMPILER_IS_CLANG``, ... * **Attributes** - Compiler agnostic attributes or functions to handle specific operations. e.g., ``LIBC_INLINE``, ``LIBC_NO_LOOP_UNROLL``, ``LIBC_LIKELY``, ``LIBC_INLINE_ASM``. diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h index 6d060b8..115ed39 100644 --- a/libc/src/__support/FPUtil/FEnvImpl.h +++ b/libc/src/__support/FPUtil/FEnvImpl.h @@ -12,13 +12,13 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" -#if defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) #if defined(__APPLE__) #include "aarch64/fenv_darwin_impl.h" #else #include "aarch64/FEnvImpl.h" #endif -#elif defined(LIBC_TARGET_IS_X86) +#elif defined(LIBC_TARGET_ARCH_IS_X86) #include "x86_64/FEnvImpl.h" #else #include diff --git a/libc/src/__support/FPUtil/FMA.h b/libc/src/__support/FPUtil/FMA.h index b78577a..8de0be8 100644 --- a/libc/src/__support/FPUtil/FMA.h +++ b/libc/src/__support/FPUtil/FMA.h @@ -13,11 +13,11 @@ #include "src/__support/macros/architectures.h" #include "src/__support/macros/cpu_features.h" -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) -#if defined(LIBC_TARGET_IS_X86_64) +#if defined(LIBC_TARGET_ARCH_IS_X86_64) #include "x86_64/FMA.h" -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) #include "aarch64/FMA.h" #endif diff --git a/libc/src/__support/FPUtil/PlatformDefs.h b/libc/src/__support/FPUtil/PlatformDefs.h index 3d97b10..ca500bc 100644 --- a/libc/src/__support/FPUtil/PlatformDefs.h +++ b/libc/src/__support/FPUtil/PlatformDefs.h @@ -11,7 +11,7 @@ #include "src/__support/macros/architectures.h" -#if defined(LIBC_TARGET_IS_X86) +#if defined(LIBC_TARGET_ARCH_IS_X86) #define X87_FPU #endif diff --git a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h index 03730dd..b7a1056 100644 --- a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h +++ b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h @@ -12,7 +12,7 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" -#if !defined(LIBC_TARGET_IS_AARCH64) || defined(__APPLE__) +#if !defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(__APPLE__) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/aarch64/FMA.h b/libc/src/__support/FPUtil/aarch64/FMA.h index 8318193..b8b4f6c 100644 --- a/libc/src/__support/FPUtil/aarch64/FMA.h +++ b/libc/src/__support/FPUtil/aarch64/FMA.h @@ -12,11 +12,11 @@ #include "src/__support/macros/architectures.h" #include "src/__support/macros/cpu_features.h" -#if !defined(LIBC_TARGET_IS_AARCH64) +#if !defined(LIBC_TARGET_ARCH_IS_AARCH64) #error "Invalid include" #endif -#if !defined(LIBC_TARGET_HAS_FMA) +#if !defined(LIBC_TARGET_CPU_HAS_FMA) #error "FMA instructions are not supported" #endif diff --git a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h index da7b44d..314fc3d 100644 --- a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h +++ b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h @@ -12,7 +12,7 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" -#if !defined(LIBC_TARGET_IS_AARCH64) || !defined(__APPLE__) +#if !defined(LIBC_TARGET_ARCH_IS_AARCH64) || !defined(__APPLE__) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/aarch64/nearest_integer.h b/libc/src/__support/FPUtil/aarch64/nearest_integer.h index 351e147..f7d3890 100644 --- a/libc/src/__support/FPUtil/aarch64/nearest_integer.h +++ b/libc/src/__support/FPUtil/aarch64/nearest_integer.h @@ -12,7 +12,7 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" -#if !defined(LIBC_TARGET_IS_AARCH64) +#if !defined(LIBC_TARGET_ARCH_IS_AARCH64) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/aarch64/sqrt.h b/libc/src/__support/FPUtil/aarch64/sqrt.h index b6e3f68..c710711 100644 --- a/libc/src/__support/FPUtil/aarch64/sqrt.h +++ b/libc/src/__support/FPUtil/aarch64/sqrt.h @@ -12,7 +12,7 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" -#if !defined(LIBC_TARGET_IS_AARCH64) +#if !defined(LIBC_TARGET_ARCH_IS_AARCH64) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/multiply_add.h b/libc/src/__support/FPUtil/multiply_add.h index e5df0f5..fd990f7 100644 --- a/libc/src/__support/FPUtil/multiply_add.h +++ b/libc/src/__support/FPUtil/multiply_add.h @@ -27,7 +27,7 @@ template LIBC_INLINE T multiply_add(T x, T y, T z) { } // namespace fputil } // namespace __llvm_libc -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) // FMA instructions are available. #include "FMA.h" @@ -47,6 +47,6 @@ LIBC_INLINE double multiply_add(double x, double y, double z) { } // namespace fputil } // namespace __llvm_libc -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA #endif // LLVM_LIBC_SRC_SUPPORT_FPUTIL_MULTIPLY_ADD_H diff --git a/libc/src/__support/FPUtil/nearest_integer.h b/libc/src/__support/FPUtil/nearest_integer.h index 7fa5a41..70dcc2a 100644 --- a/libc/src/__support/FPUtil/nearest_integer.h +++ b/libc/src/__support/FPUtil/nearest_integer.h @@ -11,10 +11,11 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" +#include "src/__support/macros/cpu_features.h" -#if (defined(LIBC_TARGET_IS_X86_64) && defined(__SSE4_2__)) +#if (defined(LIBC_TARGET_ARCH_IS_X86_64) && defined(LIBC_TARGET_CPU_HAS_SSE4_2)) #include "x86_64/nearest_integer.h" -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) #include "aarch64/nearest_integer.h" #else diff --git a/libc/src/__support/FPUtil/sqrt.h b/libc/src/__support/FPUtil/sqrt.h index 5c48967..e6c3324 100644 --- a/libc/src/__support/FPUtil/sqrt.h +++ b/libc/src/__support/FPUtil/sqrt.h @@ -11,9 +11,9 @@ #include "src/__support/macros/architectures.h" -#if defined(LIBC_TARGET_IS_X86_64) +#if defined(LIBC_TARGET_ARCH_IS_X86_64) #include "x86_64/sqrt.h" -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) #include "aarch64/sqrt.h" #else #include "generic/sqrt.h" diff --git a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h index dcb48d0..64b3986 100644 --- a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h +++ b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h @@ -11,7 +11,7 @@ #include "src/__support/macros/architectures.h" -#if !defined(LIBC_TARGET_IS_X86) +#if !defined(LIBC_TARGET_ARCH_IS_X86) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/x86_64/FMA.h b/libc/src/__support/FPUtil/x86_64/FMA.h index 48e7d08..fec9852 100644 --- a/libc/src/__support/FPUtil/x86_64/FMA.h +++ b/libc/src/__support/FPUtil/x86_64/FMA.h @@ -13,11 +13,11 @@ #include "src/__support/macros/architectures.h" #include "src/__support/macros/cpu_features.h" -#if !defined(LIBC_TARGET_IS_X86_64) +#if !defined(LIBC_TARGET_ARCH_IS_X86_64) #error "Invalid include" #endif -#if !defined(LIBC_TARGET_HAS_FMA) +#if !defined(LIBC_TARGET_CPU_HAS_FMA) #error "FMA instructions are not supported" #endif diff --git a/libc/src/__support/FPUtil/x86_64/LongDoubleBits.h b/libc/src/__support/FPUtil/x86_64/LongDoubleBits.h index 1833091..7fa1a4b 100644 --- a/libc/src/__support/FPUtil/x86_64/LongDoubleBits.h +++ b/libc/src/__support/FPUtil/x86_64/LongDoubleBits.h @@ -14,7 +14,7 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" -#if !defined(LIBC_TARGET_IS_X86) +#if !defined(LIBC_TARGET_ARCH_IS_X86) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/x86_64/NextAfterLongDouble.h b/libc/src/__support/FPUtil/x86_64/NextAfterLongDouble.h index 1b8d95d..ec898c2 100644 --- a/libc/src/__support/FPUtil/x86_64/NextAfterLongDouble.h +++ b/libc/src/__support/FPUtil/x86_64/NextAfterLongDouble.h @@ -11,7 +11,7 @@ #include "src/__support/macros/architectures.h" -#if !defined(LIBC_TARGET_IS_X86) +#if !defined(LIBC_TARGET_ARCH_IS_X86) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/x86_64/PolyEval.h b/libc/src/__support/FPUtil/x86_64/PolyEval.h index d38af43..473c158 100644 --- a/libc/src/__support/FPUtil/x86_64/PolyEval.h +++ b/libc/src/__support/FPUtil/x86_64/PolyEval.h @@ -12,7 +12,7 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" -#if !defined(LIBC_TARGET_IS_X86_64) +#if !defined(LIBC_TARGET_ARCH_IS_X86_64) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/x86_64/nearest_integer.h b/libc/src/__support/FPUtil/x86_64/nearest_integer.h index 12fe62e..ee21310 100644 --- a/libc/src/__support/FPUtil/x86_64/nearest_integer.h +++ b/libc/src/__support/FPUtil/x86_64/nearest_integer.h @@ -12,7 +12,7 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" -#if !defined(LIBC_TARGET_IS_X86_64) +#if !defined(LIBC_TARGET_ARCH_IS_X86_64) #error "Invalid include" #endif diff --git a/libc/src/__support/FPUtil/x86_64/sqrt.h b/libc/src/__support/FPUtil/x86_64/sqrt.h index 0ee57b0..7f5a38f 100644 --- a/libc/src/__support/FPUtil/x86_64/sqrt.h +++ b/libc/src/__support/FPUtil/x86_64/sqrt.h @@ -12,7 +12,7 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" -#if !defined(LIBC_TARGET_IS_X86) +#if !defined(LIBC_TARGET_ARCH_IS_X86) #error "Invalid include" #endif diff --git a/libc/src/__support/OSUtil/linux/syscall.h b/libc/src/__support/OSUtil/linux/syscall.h index ff9810e..c18d144 100644 --- a/libc/src/__support/OSUtil/linux/syscall.h +++ b/libc/src/__support/OSUtil/linux/syscall.h @@ -12,11 +12,11 @@ #include "src/__support/common.h" #include "src/__support/macros/architectures.h" -#ifdef LIBC_TARGET_IS_X86_64 +#ifdef LIBC_TARGET_ARCH_IS_X86_64 #include "x86_64/syscall.h" -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) #include "aarch64/syscall.h" -#elif defined(LIBC_TARGET_IS_ARM) +#elif defined(LIBC_TARGET_ARCH_IS_ARM) #include "arm/syscall.h" #endif diff --git a/libc/src/__support/common.h b/libc/src/__support/common.h index c7ccaea..7f8ed3f 100644 --- a/libc/src/__support/common.h +++ b/libc/src/__support/common.h @@ -17,7 +17,7 @@ #endif // GPU targets do not support aliasing. -#if defined(LLVM_LIBC_PUBLIC_PACKAGING) && defined(LIBC_TARGET_IS_GPU) +#if defined(LLVM_LIBC_PUBLIC_PACKAGING) && defined(LIBC_TARGET_ARCH_IS_GPU) #define LLVM_LIBC_FUNCTION(type, name, arglist) \ LLVM_LIBC_FUNCTION_ATTR decltype(__llvm_libc::name) \ __##name##_impl__ __asm__(#name); \ diff --git a/libc/src/__support/macros/architectures.h b/libc/src/__support/macros/architectures.h index 234ed3e..ffd2ee7 100644 --- a/libc/src/__support/macros/architectures.h +++ b/libc/src/__support/macros/architectures.h @@ -10,43 +10,43 @@ #define LLVM_LIBC_SUPPORT_MACROS_ARCHITECTURES_H #if defined(__AMDGPU__) -#define LIBC_TARGET_IS_AMDGPU +#define LIBC_TARGET_ARCH_IS_AMDGPU #endif #if defined(__NVPTX__) -#define LIBC_TARGET_IS_NVPTX +#define LIBC_TARGET_ARCH_IS_NVPTX #endif -#if defined(LIBC_TARGET_IS_NVPTX) || defined(LIBC_TARGET_IS_AMDGPU) -#define LIBC_TARGET_IS_GPU +#if defined(LIBC_TARGET_ARCH_IS_NVPTX) || defined(LIBC_TARGET_ARCH_IS_AMDGPU) +#define LIBC_TARGET_ARCH_IS_GPU #endif -#if defined(__pnacl__) || defined(__CLR_VER) || defined(LIBC_TARGET_IS_GPU) -#define LIBC_TARGET_IS_VM +#if defined(__pnacl__) || defined(__CLR_VER) || defined(LIBC_TARGET_ARCH_IS_GPU) +#define LIBC_TARGET_ARCH_IS_VM #endif -#if (defined(_M_IX86) || defined(__i386__)) && !defined(LIBC_TARGET_IS_VM) -#define LIBC_TARGET_IS_X86_32 +#if (defined(_M_IX86) || defined(__i386__)) && !defined(LIBC_TARGET_ARCH_IS_VM) +#define LIBC_TARGET_ARCH_IS_X86_32 #endif -#if (defined(_M_X64) || defined(__x86_64__)) && !defined(LIBC_TARGET_IS_VM) -#define LIBC_TARGET_IS_X86_64 +#if (defined(_M_X64) || defined(__x86_64__)) && !defined(LIBC_TARGET_ARCH_IS_VM) +#define LIBC_TARGET_ARCH_IS_X86_64 #endif -#if defined(LIBC_TARGET_IS_X86_32) || defined(LIBC_TARGET_IS_X86_64) -#define LIBC_TARGET_IS_X86 +#if defined(LIBC_TARGET_ARCH_IS_X86_32) || defined(LIBC_TARGET_ARCH_IS_X86_64) +#define LIBC_TARGET_ARCH_IS_X86 #endif #if (defined(__arm__) || defined(_M_ARM)) -#define LIBC_TARGET_IS_ARM +#define LIBC_TARGET_ARCH_IS_ARM #endif #if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) -#define LIBC_TARGET_IS_AARCH64 +#define LIBC_TARGET_ARCH_IS_AARCH64 #endif -#if (defined(LIBC_TARGET_IS_AARCH64) || defined(LIBC_TARGET_IS_ARM)) -#define LIBC_TARGET_IS_ANY_ARM +#if (defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_ARM)) +#define LIBC_TARGET_ARCH_IS_ANY_ARM #endif #endif // LLVM_LIBC_SUPPORT_MACROS_ARCHITECTURES_H diff --git a/libc/src/__support/macros/cpu_features.h b/libc/src/__support/macros/cpu_features.h index 34c46f5..bc7ba10 100644 --- a/libc/src/__support/macros/cpu_features.h +++ b/libc/src/__support/macros/cpu_features.h @@ -13,31 +13,31 @@ #define LLVM_LIBC_SRC_SUPPORT_MACROS_CPU_FEATURES_H #if defined(__SSE2__) -#define LIBC_TARGET_HAS_SSE2 +#define LIBC_TARGET_CPU_HAS_SSE2 #endif #if defined(__SSE4_2__) -#define LIBC_TARGET_HAS_SSE4_2 +#define LIBC_TARGET_CPU_HAS_SSE4_2 #endif #if defined(__AVX__) -#define LIBC_TARGET_HAS_AVX +#define LIBC_TARGET_CPU_HAS_AVX #endif #if defined(__AVX2__) -#define LIBC_TARGET_HAS_AVX2 +#define LIBC_TARGET_CPU_HAS_AVX2 #endif #if defined(__AVX512F__) -#define LIBC_TARGET_HAS_AVX512F +#define LIBC_TARGET_CPU_HAS_AVX512F #endif #if defined(__AVX512BW__) -#define LIBC_TARGET_HAS_AVX512BW +#define LIBC_TARGET_CPU_HAS_AVX512BW #endif #if defined(__ARM_FEATURE_FMA) || defined(__AVX2__) || defined(__FMA__) -#define LIBC_TARGET_HAS_FMA +#define LIBC_TARGET_CPU_HAS_FMA #endif #endif // LLVM_LIBC_SRC_SUPPORT_MACROS_CPU_FEATURES_H diff --git a/libc/src/__support/threads/linux/thread.cpp b/libc/src/__support/threads/linux/thread.cpp index 599082a..a084a00 100644 --- a/libc/src/__support/threads/linux/thread.cpp +++ b/libc/src/__support/threads/linux/thread.cpp @@ -16,7 +16,7 @@ #include "src/__support/error_or.h" #include "src/__support/threads/linux/futex_word.h" // For FutexWordType -#ifdef LIBC_TARGET_IS_AARCH64 +#ifdef LIBC_TARGET_ARCH_IS_AARCH64 #include #endif @@ -99,14 +99,14 @@ __attribute__((always_inline)) inline uintptr_t get_start_args_addr() { // NOTE: For __builtin_frame_address to work reliably across compilers, // architectures and various optimization levels, the TU including this file // should be compiled with -fno-omit-frame-pointer. -#ifdef LIBC_TARGET_IS_X86_64 +#ifdef LIBC_TARGET_ARCH_IS_X86_64 return reinterpret_cast(__builtin_frame_address(0)) // The x86_64 call instruction pushes resume address on to the stack. // Next, The x86_64 SysV ABI requires that the frame pointer be pushed // on to the stack. So, we have to step past two 64-bit values to get // to the start args. + sizeof(uintptr_t) * 2; -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) // The frame pointer after cloning the new thread in the Thread::run method // is set to the stack pointer where start args are stored. So, we fetch // from there. @@ -190,7 +190,7 @@ int Thread::run(ThreadStyle style, ThreadRunner runner, void *arg, void *stack, // Also, we want the result of the syscall to be in a register as the child // thread gets a completely different stack after it is created. The stack // variables from this function will not be availalbe to the child thread. -#ifdef LIBC_TARGET_IS_X86_64 +#ifdef LIBC_TARGET_ARCH_IS_X86_64 long register clone_result asm("rax"); clone_result = __llvm_libc::syscall_impl( SYS_clone, CLONE_SYSCALL_FLAGS, adjusted_stack, @@ -198,7 +198,7 @@ int Thread::run(ThreadStyle style, ThreadRunner runner, void *arg, void *stack, &clear_tid->val, // The futex where the child thread status is signalled tls.tp // The thread pointer value for the new thread. ); -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) long register clone_result asm("x0"); clone_result = __llvm_libc::syscall_impl( SYS_clone, CLONE_SYSCALL_FLAGS, adjusted_stack, @@ -211,7 +211,7 @@ int Thread::run(ThreadStyle style, ThreadRunner runner, void *arg, void *stack, #endif if (clone_result == 0) { -#ifdef LIBC_TARGET_IS_AARCH64 +#ifdef LIBC_TARGET_ARCH_IS_AARCH64 // We set the frame pointer to be the same as the "sp" so that start args // can be sniffed out from start_thread. __arm_wsr64("x29", __arm_rsr64("sp")); diff --git a/libc/src/__support/threads/thread.h b/libc/src/__support/threads/thread.h index fe95d8f..839737e 100644 --- a/libc/src/__support/threads/thread.h +++ b/libc/src/__support/threads/thread.h @@ -36,7 +36,8 @@ union ThreadReturnValue { constexpr ThreadReturnValue(void *r) : posix_retval(r) {} }; -#if (defined(LIBC_TARGET_IS_AARCH64) || defined(LIBC_TARGET_IS_X86_64)) +#if (defined(LIBC_TARGET_ARCH_IS_AARCH64) || \ + defined(LIBC_TARGET_ARCH_IS_X86_64)) constexpr unsigned int STACK_ALIGNMENT = 16; #endif // TODO: Provide stack alignment requirements for other architectures. diff --git a/libc/src/math/generic/asinf.cpp b/libc/src/math/generic/asinf.cpp index e86c164..b50c2cb 100644 --- a/libc/src/math/generic/asinf.cpp +++ b/libc/src/math/generic/asinf.cpp @@ -73,12 +73,12 @@ LLVM_LIBC_FUNCTION(float, asinf, (float x)) { // |x| < 2^-125. For targets without FMA instructions, we simply use // double for intermediate results as it is more efficient than using an // emulated version of FMA. -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) return fputil::multiply_add(x, 0x1.0p-25f, x); #else double xd = static_cast(x); return static_cast(fputil::multiply_add(xd, 0x1.0p-25, xd)); -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA } // Check for exceptional values diff --git a/libc/src/math/generic/cosf.cpp b/libc/src/math/generic/cosf.cpp index ffce4b1..c84d4fb 100644 --- a/libc/src/math/generic/cosf.cpp +++ b/libc/src/math/generic/cosf.cpp @@ -100,11 +100,11 @@ LLVM_LIBC_FUNCTION(float, cosf, (float x)) { // |x| < 2^-125. For targets without FMA instructions, we simply use // double for intermediate results as it is more efficient than using an // emulated version of FMA. -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) return fputil::multiply_add(xbits.get_val(), -0x1.0p-25f, 1.0f); #else return static_cast(fputil::multiply_add(xd, -0x1.0p-25, 1.0)); -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA } if (auto r = COSF_EXCEPTS.lookup(x_abs); LIBC_UNLIKELY(r.has_value())) diff --git a/libc/src/math/generic/expm1f.cpp b/libc/src/math/generic/expm1f.cpp index 4a8a301..43e7d2d 100644 --- a/libc/src/math/generic/expm1f.cpp +++ b/libc/src/math/generic/expm1f.cpp @@ -37,14 +37,14 @@ LLVM_LIBC_FUNCTION(float, expm1f, (float x)) { return 0x1.8dbe62p-3f; } -#if !defined(LIBC_TARGET_HAS_FMA) +#if !defined(LIBC_TARGET_CPU_HAS_FMA) if (LIBC_UNLIKELY(x_u == 0xbdc1'c6cbU)) { // x = -0x1.838d96p-4f int round_mode = fputil::get_round(); if (round_mode == FE_TONEAREST || round_mode == FE_DOWNWARD) return -0x1.71c884p-4f; return -0x1.71c882p-4f; } -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA // When |x| > 25*log(2), or nan if (LIBC_UNLIKELY(x_abs >= 0x418a'a123U)) { @@ -100,12 +100,12 @@ LLVM_LIBC_FUNCTION(float, expm1f, (float x)) { // 2^-76. For targets without FMA instructions, we simply use double for // intermediate results as it is more efficient than using an emulated // version of FMA. -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) return fputil::fma(x, x, x); #else double xd = x; return static_cast(fputil::multiply_add(xd, xd, xd)); -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA } // 2^-25 <= |x| < 2^-4 diff --git a/libc/src/math/generic/sincosf.cpp b/libc/src/math/generic/sincosf.cpp index 19e5d2b..82ddaa8 100644 --- a/libc/src/math/generic/sincosf.cpp +++ b/libc/src/math/generic/sincosf.cpp @@ -129,14 +129,14 @@ LLVM_LIBC_FUNCTION(void, sincosf, (float x, float *sinp, float *cosp)) { // |x| < 2^-125. For targets without FMA instructions, we simply use // double for intermediate results as it is more efficient than using an // emulated version of FMA. -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) *sinp = fputil::multiply_add(x, -0x1.0p-25f, x); *cosp = fputil::multiply_add(FPBits(x_abs).get_val(), -0x1.0p-25f, 1.0f); #else *sinp = static_cast(fputil::multiply_add(xd, -0x1.0p-25, xd)); *cosp = static_cast(fputil::multiply_add( static_cast(FPBits(x_abs).get_val()), -0x1.0p-25, 1.0)); -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA return; } diff --git a/libc/src/math/generic/sincosf_utils.h b/libc/src/math/generic/sincosf_utils.h index 78a06dc..3fd713e 100644 --- a/libc/src/math/generic/sincosf_utils.h +++ b/libc/src/math/generic/sincosf_utils.h @@ -14,7 +14,7 @@ #include "src/__support/common.h" #include "src/__support/macros/cpu_features.h" -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) #include "range_reduction_fma.h" // using namespace __llvm_libc::fma; using __llvm_libc::fma::FAST_PASS_BOUND; @@ -26,7 +26,7 @@ using __llvm_libc::fma::small_range_reduction; using __llvm_libc::generic::FAST_PASS_BOUND; using __llvm_libc::generic::large_range_reduction; using __llvm_libc::generic::small_range_reduction; -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA namespace __llvm_libc { diff --git a/libc/src/math/generic/sinf.cpp b/libc/src/math/generic/sinf.cpp index bea221b..511f548 100644 --- a/libc/src/math/generic/sinf.cpp +++ b/libc/src/math/generic/sinf.cpp @@ -18,7 +18,7 @@ #include -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) #include "range_reduction_fma.h" #else #include "range_reduction.h" @@ -100,11 +100,11 @@ LLVM_LIBC_FUNCTION(float, sinf, (float x)) { // |x| < 2^-125. For targets without FMA instructions, we simply use // double for intermediate results as it is more efficient than using an // emulated version of FMA. -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) return fputil::multiply_add(x, -0x1.0p-25f, x); #else return static_cast(fputil::multiply_add(xd, -0x1.0p-25, xd)); -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA } // |x| < pi/16. diff --git a/libc/src/math/generic/tanf.cpp b/libc/src/math/generic/tanf.cpp index ddc76fd..9c2f685 100644 --- a/libc/src/math/generic/tanf.cpp +++ b/libc/src/math/generic/tanf.cpp @@ -74,11 +74,11 @@ LLVM_LIBC_FUNCTION(float, tanf, (float x)) { // |x| < 2^-125. For targets without FMA instructions, we simply use // double for intermediate results as it is more efficient than using an // emulated version of FMA. -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) return fputil::multiply_add(x, 0x1.0p-25f, x); #else return static_cast(fputil::multiply_add(xd, 0x1.0p-25, xd)); -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA } // |x| < pi/32 diff --git a/libc/src/math/generic/tanhf.cpp b/libc/src/math/generic/tanhf.cpp index 7959f59..b0de6f9 100644 --- a/libc/src/math/generic/tanhf.cpp +++ b/libc/src/math/generic/tanhf.cpp @@ -59,13 +59,13 @@ LLVM_LIBC_FUNCTION(float, tanhf, (float x)) { auto ep = exp_b_range_reduc(2.0f * x); // exp(2 * x) double r = ExpBase::powb_lo(ep.lo); // tanh(x) = (exp(2x) - 1) / (exp(2x) + 1) -#if defined(LIBC_TARGET_HAS_FMA) +#if defined(LIBC_TARGET_CPU_HAS_FMA) return fputil::multiply_add(ep.mh, r, -1.0) / fputil::multiply_add(ep.mh, r, 1.0); #else double exp_x = ep.mh * r; return (exp_x - 1.0) / (exp_x + 1.0); -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA } } // namespace __llvm_libc diff --git a/libc/src/setjmp/longjmp.cpp b/libc/src/setjmp/longjmp.cpp index da323dd..9e75711 100644 --- a/libc/src/setjmp/longjmp.cpp +++ b/libc/src/setjmp/longjmp.cpp @@ -15,7 +15,7 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(void, longjmp, (__jmp_buf * buf, int val)) { -#ifdef LIBC_TARGET_IS_X86_64 +#ifdef LIBC_TARGET_ARCH_IS_X86_64 register __UINT64_TYPE__ rbx __asm__("rbx"); register __UINT64_TYPE__ rbp __asm__("rbp"); register __UINT64_TYPE__ r12 __asm__("r12"); @@ -38,7 +38,7 @@ LLVM_LIBC_FUNCTION(void, longjmp, (__jmp_buf * buf, int val)) { LIBC_INLINE_ASM("mov %1, %0\n\t" : "=r"(r15) : "m"(buf->r15) :); LIBC_INLINE_ASM("mov %1, %0\n\t" : "=r"(rsp) : "m"(buf->rsp) :); LIBC_INLINE_ASM("jmp *%0\n\t" : : "m"(buf->rip)); -#else // LIBC_TARGET_IS_X86_64 +#else // LIBC_TARGET_ARCH_IS_X86_64 #error "longjmp implementation not available for the target architecture." #endif } diff --git a/libc/src/setjmp/setjmp.cpp b/libc/src/setjmp/setjmp.cpp index 9506eda..d4f2fae 100644 --- a/libc/src/setjmp/setjmp.cpp +++ b/libc/src/setjmp/setjmp.cpp @@ -15,7 +15,7 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(int, setjmp, (__jmp_buf * buf)) { -#ifdef LIBC_TARGET_IS_X86_64 +#ifdef LIBC_TARGET_ARCH_IS_X86_64 register __UINT64_TYPE__ rbx __asm__("rbx"); register __UINT64_TYPE__ r12 __asm__("r12"); register __UINT64_TYPE__ r13 __asm__("r13"); @@ -50,7 +50,7 @@ LLVM_LIBC_FUNCTION(int, setjmp, (__jmp_buf * buf)) { buf->rsp = reinterpret_cast<__UINTPTR_TYPE__>(__builtin_frame_address(0)) + sizeof(__UINTPTR_TYPE__) * 2; buf->rip = reinterpret_cast<__UINTPTR_TYPE__>(__builtin_return_address(0)); -#else // LIBC_TARGET_IS_X86_64 +#else // LIBC_TARGET_ARCH_IS_X86_64 #error "setjmp implementation not available for the target architecture." #endif diff --git a/libc/src/string/memory_utils/bcmp_implementations.h b/libc/src/string/memory_utils/bcmp_implementations.h index 22bbd90..195a932 100644 --- a/libc/src/string/memory_utils/bcmp_implementations.h +++ b/libc/src/string/memory_utils/bcmp_implementations.h @@ -29,7 +29,7 @@ inline_bcmp_embedded_tiny(CPtr p1, CPtr p2, size_t count) { return BcmpReturnType::ZERO(); } -#if defined(LIBC_TARGET_IS_X86) || defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_X86) || defined(LIBC_TARGET_ARCH_IS_AARCH64) [[maybe_unused]] LIBC_INLINE BcmpReturnType inline_bcmp_generic_gt16(CPtr p1, CPtr p2, size_t count) { if (count < 256) @@ -39,9 +39,10 @@ inline_bcmp_generic_gt16(CPtr p1, CPtr p2, size_t count) { align_to_next_boundary<64, Arg::P1>(p1, p2, count); return generic::Bcmp<64>::loop_and_tail(p1, p2, count); } -#endif // defined(LIBC_TARGET_IS_X86) || defined(LIBC_TARGET_IS_AARCH64) +#endif // defined(LIBC_TARGET_ARCH_IS_X86) || + // defined(LIBC_TARGET_ARCH_IS_AARCH64) -#if defined(LIBC_TARGET_IS_X86) +#if defined(LIBC_TARGET_ARCH_IS_X86) [[maybe_unused]] LIBC_INLINE BcmpReturnType inline_bcmp_x86_sse2_gt16(CPtr p1, CPtr p2, size_t count) { if (count <= 32) @@ -109,9 +110,9 @@ inline_bcmp_x86_avx512bw_gt16(CPtr p1, CPtr p2, size_t count) { else return inline_bcmp_generic_gt16(p1, p2, count); } -#endif // defined(LIBC_TARGET_IS_X86) +#endif // defined(LIBC_TARGET_ARCH_IS_X86) -#if defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) [[maybe_unused]] LIBC_INLINE BcmpReturnType inline_bcmp_aarch64(CPtr p1, CPtr p2, size_t count) { @@ -158,16 +159,16 @@ inline_bcmp_x86_avx512bw_gt16(CPtr p1, CPtr p2, size_t count) { } return aarch64::Bcmp<32>::loop_and_tail(p1, p2, count); } -#endif // defined(LIBC_TARGET_IS_AARCH64) +#endif // defined(LIBC_TARGET_ARCH_IS_AARCH64) LIBC_INLINE BcmpReturnType inline_bcmp(CPtr p1, CPtr p2, size_t count) { -#if defined(LIBC_TARGET_IS_X86) +#if defined(LIBC_TARGET_ARCH_IS_X86) return inline_bcmp_x86(p1, p2, count); -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) return inline_bcmp_aarch64(p1, p2, count); -#elif defined(LIBC_TARGET_IS_ARM) +#elif defined(LIBC_TARGET_ARCH_IS_ARM) return inline_bcmp_embedded_tiny(p1, p2, count); -#elif defined(LIBC_TARGET_IS_GPU) +#elif defined(LIBC_TARGET_ARCH_IS_GPU) return inline_bcmp_embedded_tiny(p1, p2, count); #else #error "Unsupported platform" diff --git a/libc/src/string/memory_utils/memcmp_implementations.h b/libc/src/string/memory_utils/memcmp_implementations.h index 713be78..0499f01 100644 --- a/libc/src/string/memory_utils/memcmp_implementations.h +++ b/libc/src/string/memory_utils/memcmp_implementations.h @@ -29,7 +29,7 @@ inline_memcmp_embedded_tiny(CPtr p1, CPtr p2, size_t count) { return MemcmpReturnType::ZERO(); } -#if defined(LIBC_TARGET_IS_X86) || defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_X86) || defined(LIBC_TARGET_ARCH_IS_AARCH64) [[maybe_unused]] LIBC_INLINE MemcmpReturnType inline_memcmp_generic_gt16(CPtr p1, CPtr p2, size_t count) { if (LIBC_UNLIKELY(count >= 384)) { @@ -39,9 +39,10 @@ inline_memcmp_generic_gt16(CPtr p1, CPtr p2, size_t count) { } return generic::Memcmp<16>::loop_and_tail(p1, p2, count); } -#endif // defined(LIBC_TARGET_IS_X86) || defined(LIBC_TARGET_IS_AARCH64) +#endif // defined(LIBC_TARGET_ARCH_IS_X86) || + // defined(LIBC_TARGET_ARCH_IS_AARCH64) -#if defined(LIBC_TARGET_IS_X86) +#if defined(LIBC_TARGET_ARCH_IS_X86) [[maybe_unused]] LIBC_INLINE MemcmpReturnType inline_memcmp_x86_sse2_gt16(CPtr p1, CPtr p2, size_t count) { if (LIBC_UNLIKELY(count >= 384)) { @@ -84,9 +85,9 @@ inline_memcmp_x86_avx512bw_gt16(CPtr p1, CPtr p2, size_t count) { return x86::avx512bw::Memcmp<64>::loop_and_tail(p1, p2, count); } -#endif // defined(LIBC_TARGET_IS_X86) +#endif // defined(LIBC_TARGET_ARCH_IS_X86) -#if defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) [[maybe_unused]] LIBC_INLINE MemcmpReturnType inline_memcmp_aarch64_neon_gt16(CPtr p1, CPtr p2, size_t count) { if (LIBC_UNLIKELY(count >= 128)) { // [128, ∞] @@ -106,10 +107,10 @@ inline_memcmp_aarch64_neon_gt16(CPtr p1, CPtr p2, size_t count) { // [64, 127] return generic::Memcmp<16>::loop_and_tail(p1 + 32, p2 + 32, count - 32); } -#endif // defined(LIBC_TARGET_IS_AARCH64) +#endif // defined(LIBC_TARGET_ARCH_IS_AARCH64) LIBC_INLINE MemcmpReturnType inline_memcmp(CPtr p1, CPtr p2, size_t count) { -#if defined(LIBC_TARGET_IS_X86) || defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_X86) || defined(LIBC_TARGET_ARCH_IS_AARCH64) if (count == 0) return MemcmpReturnType::ZERO(); if (count == 1) @@ -122,7 +123,7 @@ LIBC_INLINE MemcmpReturnType inline_memcmp(CPtr p1, CPtr p2, size_t count) { return generic::Memcmp<4>::head_tail(p1, p2, count); if (count <= 16) return generic::Memcmp<8>::head_tail(p1, p2, count); -#if defined(LIBC_TARGET_IS_X86) +#if defined(LIBC_TARGET_ARCH_IS_X86) if constexpr (x86::kAvx512BW) return inline_memcmp_x86_avx512bw_gt16(p1, p2, count); else if constexpr (x86::kAvx2) @@ -131,15 +132,15 @@ LIBC_INLINE MemcmpReturnType inline_memcmp(CPtr p1, CPtr p2, size_t count) { return inline_memcmp_x86_sse2_gt16(p1, p2, count); else return inline_memcmp_generic_gt16(p1, p2, count); -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) if constexpr (aarch64::kNeon) return inline_memcmp_aarch64_neon_gt16(p1, p2, count); else return inline_memcmp_generic_gt16(p1, p2, count); #endif -#elif defined(LIBC_TARGET_IS_ARM) +#elif defined(LIBC_TARGET_ARCH_IS_ARM) return inline_memcmp_embedded_tiny(p1, p2, count); -#elif defined(LIBC_TARGET_IS_GPU) +#elif defined(LIBC_TARGET_ARCH_IS_GPU) return inline_memcmp_embedded_tiny(p1, p2, count); #else #error "Unsupported platform" diff --git a/libc/src/string/memory_utils/memcpy_implementations.h b/libc/src/string/memory_utils/memcpy_implementations.h index bd576d1..595585fc3 100644 --- a/libc/src/string/memory_utils/memcpy_implementations.h +++ b/libc/src/string/memory_utils/memcpy_implementations.h @@ -29,7 +29,7 @@ inline_memcpy_embedded_tiny(Ptr __restrict dst, CPtr __restrict src, builtin::Memcpy<1>::block(dst + offset, src + offset); } -#if defined(LIBC_TARGET_IS_X86) +#if defined(LIBC_TARGET_ARCH_IS_X86) [[maybe_unused]] LIBC_INLINE void inline_memcpy_x86(Ptr __restrict dst, CPtr __restrict src, size_t count) { if (count == 0) @@ -86,9 +86,9 @@ inline_memcpy_x86_maybe_interpose_repmovsb(Ptr __restrict dst, return inline_memcpy_x86(dst, src, count); } } -#endif // defined(LIBC_TARGET_IS_X86) +#endif // defined(LIBC_TARGET_ARCH_IS_X86) -#if defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) [[maybe_unused]] LIBC_INLINE void inline_memcpy_aarch64(Ptr __restrict dst, CPtr __restrict src, size_t count) { if (count == 0) @@ -115,18 +115,18 @@ inline_memcpy_aarch64(Ptr __restrict dst, CPtr __restrict src, size_t count) { align_to_next_boundary<16, Arg::Src>(dst, src, count); return builtin::Memcpy<64>::loop_and_tail(dst, src, count); } -#endif // defined(LIBC_TARGET_IS_AARCH64) +#endif // defined(LIBC_TARGET_ARCH_IS_AARCH64) LIBC_INLINE void inline_memcpy(Ptr __restrict dst, CPtr __restrict src, size_t count) { using namespace __llvm_libc::builtin; -#if defined(LIBC_TARGET_IS_X86) +#if defined(LIBC_TARGET_ARCH_IS_X86) return inline_memcpy_x86_maybe_interpose_repmovsb(dst, src, count); -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) return inline_memcpy_aarch64(dst, src, count); -#elif defined(LIBC_TARGET_IS_ARM) +#elif defined(LIBC_TARGET_ARCH_IS_ARM) return inline_memcpy_embedded_tiny(dst, src, count); -#elif defined(LIBC_TARGET_IS_GPU) +#elif defined(LIBC_TARGET_ARCH_IS_GPU) return inline_memcpy_embedded_tiny(dst, src, count); #else #error "Unsupported platform" diff --git a/libc/src/string/memory_utils/memmove_implementations.h b/libc/src/string/memory_utils/memmove_implementations.h index ea068c1..12b7623 100644 --- a/libc/src/string/memory_utils/memmove_implementations.h +++ b/libc/src/string/memory_utils/memmove_implementations.h @@ -66,13 +66,13 @@ template } LIBC_INLINE void inline_memmove(Ptr dst, CPtr src, size_t count) { -#if defined(LIBC_TARGET_IS_X86) || defined(LIBC_TARGET_IS_AARCH64) -#if defined(LIBC_TARGET_IS_X86) +#if defined(LIBC_TARGET_ARCH_IS_X86) || defined(LIBC_TARGET_ARCH_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_X86) static constexpr size_t kMaxSize = x86::kAvx512F ? 64 : x86::kAvx ? 32 : x86::kSse2 ? 16 : 8; -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) static constexpr size_t kMaxSize = aarch64::kNeon ? 16 : 8; #endif // return inline_memmove_generic(dst, src, count); @@ -101,9 +101,9 @@ LIBC_INLINE void inline_memmove(Ptr dst, CPtr src, size_t count) { return generic::Memmove<64, kMaxSize>::loop_and_tail_backward(dst, src, count); } -#elif defined(LIBC_TARGET_IS_ARM) +#elif defined(LIBC_TARGET_ARCH_IS_ARM) return inline_memmove_embedded_tiny(dst, src, count); -#elif defined(LIBC_TARGET_IS_GPU) +#elif defined(LIBC_TARGET_ARCH_IS_GPU) return inline_memmove_embedded_tiny(dst, src, count); #else #error "Unsupported platform" diff --git a/libc/src/string/memory_utils/memset_implementations.h b/libc/src/string/memory_utils/memset_implementations.h index b318efd..854552c 100644 --- a/libc/src/string/memory_utils/memset_implementations.h +++ b/libc/src/string/memory_utils/memset_implementations.h @@ -28,7 +28,7 @@ inline_memset_embedded_tiny(Ptr dst, uint8_t value, size_t count) { generic::Memset<1, 1>::block(dst + offset, value); } -#if defined(LIBC_TARGET_IS_X86) +#if defined(LIBC_TARGET_ARCH_IS_X86) template [[maybe_unused]] LIBC_INLINE static void inline_memset_x86(Ptr dst, uint8_t value, size_t count) { @@ -55,9 +55,9 @@ inline_memset_x86(Ptr dst, uint8_t value, size_t count) { align_to_next_boundary<32>(dst, count); return generic::Memset<32, MaxSize>::loop_and_tail(dst, value, count); } -#endif // defined(LIBC_TARGET_IS_X86) +#endif // defined(LIBC_TARGET_ARCH_IS_X86) -#if defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) template [[maybe_unused]] LIBC_INLINE static void inline_memset_aarch64(Ptr dst, uint8_t value, size_t count) { @@ -93,21 +93,21 @@ inline_memset_aarch64(Ptr dst, uint8_t value, size_t count) { return generic::Memset<64, MaxSize>::loop_and_tail(dst, value, count); } } -#endif // defined(LIBC_TARGET_IS_AARCH64) +#endif // defined(LIBC_TARGET_ARCH_IS_AARCH64) LIBC_INLINE static void inline_memset(Ptr dst, uint8_t value, size_t count) { -#if defined(LIBC_TARGET_IS_X86) +#if defined(LIBC_TARGET_ARCH_IS_X86) static constexpr size_t kMaxSize = x86::kAvx512F ? 64 : x86::kAvx ? 32 : x86::kSse2 ? 16 : 8; return inline_memset_x86(dst, value, count); -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) static constexpr size_t kMaxSize = aarch64::kNeon ? 16 : 8; return inline_memset_aarch64(dst, value, count); -#elif defined(LIBC_TARGET_IS_ARM) +#elif defined(LIBC_TARGET_ARCH_IS_ARM) return inline_memset_embedded_tiny(dst, value, count); -#elif defined(LIBC_TARGET_IS_GPU) +#elif defined(LIBC_TARGET_ARCH_IS_GPU) return inline_memset_embedded_tiny(dst, value, count); #else #error "Unsupported platform" diff --git a/libc/src/string/memory_utils/op_aarch64.h b/libc/src/string/memory_utils/op_aarch64.h index ac0d956..f725e8d 100644 --- a/libc/src/string/memory_utils/op_aarch64.h +++ b/libc/src/string/memory_utils/op_aarch64.h @@ -15,7 +15,7 @@ #include "src/__support/macros/architectures.h" -#if defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) #include "src/__support/common.h" #include "src/string/memory_utils/op_generic.h" @@ -174,6 +174,6 @@ template struct Bcmp { } // namespace __llvm_libc::aarch64 -#endif // LIBC_TARGET_IS_AARCH64 +#endif // LIBC_TARGET_ARCH_IS_AARCH64 #endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_AARCH64_H diff --git a/libc/src/string/memory_utils/op_generic.h b/libc/src/string/memory_utils/op_generic.h index 20cba82..cda68f2 100644 --- a/libc/src/string/memory_utils/op_generic.h +++ b/libc/src/string/memory_utils/op_generic.h @@ -123,7 +123,7 @@ static_assert((UINTPTR_MAX == 4294967295U) || (UINTPTR_MAX == 18446744073709551615UL), "We currently only support 32- or 64-bit platforms"); -#if defined(LIBC_TARGET_IS_X86_64) || defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_X86_64) || defined(LIBC_TARGET_ARCH_IS_AARCH64) #define LLVM_LIBC_HAS_UINT64 #endif diff --git a/libc/src/string/memory_utils/op_x86.h b/libc/src/string/memory_utils/op_x86.h index 5310255..8cfb99a 100644 --- a/libc/src/string/memory_utils/op_x86.h +++ b/libc/src/string/memory_utils/op_x86.h @@ -14,7 +14,7 @@ #include "src/__support/macros/architectures.h" -#if defined(LIBC_TARGET_IS_X86_64) +#if defined(LIBC_TARGET_ARCH_IS_X86_64) #include "src/__support/common.h" #include "src/string/memory_utils/op_builtin.h" @@ -269,6 +269,6 @@ template using Memcmp = MemcmpImpl; } // namespace __llvm_libc::x86 -#endif // LIBC_TARGET_IS_X86_64 +#endif // LIBC_TARGET_ARCH_IS_X86_64 #endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_OP_X86_H diff --git a/libc/src/threads/linux/Futex.h b/libc/src/threads/linux/Futex.h index 8030092..b96713a 100644 --- a/libc/src/threads/linux/Futex.h +++ b/libc/src/threads/linux/Futex.h @@ -13,7 +13,8 @@ namespace __llvm_libc { -#if (defined(LIBC_TARGET_IS_AARCH64) || defined(LIBC_TARGET_IS_X86_64)) +#if (defined(LIBC_TARGET_ARCH_IS_AARCH64) || \ + defined(LIBC_TARGET_ARCH_IS_X86_64)) // The futex data has to be exactly 4 bytes long. However, we use a uint type // here as we do not want to use `uint32_t` type to match the public definitions // of types which include a field for a futex word. With public definitions, we diff --git a/libc/test/src/fenv/enabled_exceptions_test.cpp b/libc/test/src/fenv/enabled_exceptions_test.cpp index 904b406..4a28f78 100644 --- a/libc/test/src/fenv/enabled_exceptions_test.cpp +++ b/libc/test/src/fenv/enabled_exceptions_test.cpp @@ -21,7 +21,7 @@ // This test enables an exception and verifies that raising that exception // triggers SIGFPE. TEST(LlvmLibcExceptionStatusTest, RaiseAndCrash) { -#if defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) // Few aarch64 HW implementations do not trap exceptions. We skip this test // completely on such HW. // @@ -33,7 +33,7 @@ TEST(LlvmLibcExceptionStatusTest, RaiseAndCrash) { __llvm_libc::fputil::enable_except(FE_DIVBYZERO); if (__llvm_libc::fputil::get_except() == 0) return; -#endif // defined(LIBC_TARGET_IS_AARCH64) +#endif // defined(LIBC_TARGET_ARCH_IS_AARCH64) // TODO: Install a floating point exception handler and verify that the // the expected exception was raised. One will have to longjmp back from diff --git a/libc/test/src/fenv/feenableexcept_test.cpp b/libc/test/src/fenv/feenableexcept_test.cpp index cc4285e..e8703c7 100644 --- a/libc/test/src/fenv/feenableexcept_test.cpp +++ b/libc/test/src/fenv/feenableexcept_test.cpp @@ -16,7 +16,7 @@ #include TEST(LlvmLibcFEnvTest, EnableTest) { -#if defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) // Few aarch64 HW implementations do not trap exceptions. We skip this test // completely on such HW. // @@ -28,7 +28,7 @@ TEST(LlvmLibcFEnvTest, EnableTest) { __llvm_libc::feenableexcept(FE_DIVBYZERO); if (__llvm_libc::fegetexcept() == 0) return; -#endif // defined(LIBC_TARGET_IS_AARCH64) +#endif // defined(LIBC_TARGET_ARCH_IS_AARCH64) int excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW, FE_UNDERFLOW}; diff --git a/libc/test/src/fenv/feholdexcept_test.cpp b/libc/test/src/fenv/feholdexcept_test.cpp index d0bb4db..6b871cf 100644 --- a/libc/test/src/fenv/feholdexcept_test.cpp +++ b/libc/test/src/fenv/feholdexcept_test.cpp @@ -16,7 +16,7 @@ #include TEST(LlvmLibcFEnvTest, RaiseAndCrash) { -#if defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) // Few aarch64 HW implementations do not trap exceptions. We skip this test // completely on such HW. // @@ -28,7 +28,7 @@ TEST(LlvmLibcFEnvTest, RaiseAndCrash) { __llvm_libc::fputil::enable_except(FE_DIVBYZERO); if (__llvm_libc::fputil::get_except() == 0) return; -#endif // defined(LIBC_TARGET_IS_AARCH64) +#endif // defined(LIBC_TARGET_ARCH_IS_AARCH64) int excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW, FE_UNDERFLOW}; diff --git a/libc/test/src/string/memory_utils/op_tests.cpp b/libc/test/src/string/memory_utils/op_tests.cpp index 5676956..7f5d4d4 100644 --- a/libc/test/src/string/memory_utils/op_tests.cpp +++ b/libc/test/src/string/memory_utils/op_tests.cpp @@ -15,7 +15,7 @@ #include -#if defined(LIBC_TARGET_IS_X86_64) || defined(LIBC_TARGET_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_X86_64) || defined(LIBC_TARGET_ARCH_IS_AARCH64) #define LLVM_LIBC_HAS_UINT64 #endif @@ -200,7 +200,7 @@ using BcmpImplementations = testing::TypeList< x86::avx512bw::Bcmp<64>, // x86::avx512bw::Bcmp<128>, // #endif -#ifdef LIBC_TARGET_IS_AARCH64 +#ifdef LIBC_TARGET_ARCH_IS_AARCH64 aarch64::Bcmp<16>, // aarch64::Bcmp<32>, // #endif diff --git a/libc/test/src/sys/utsname/uname_test.cpp b/libc/test/src/sys/utsname/uname_test.cpp index 013f940..3c66814 100644 --- a/libc/test/src/sys/utsname/uname_test.cpp +++ b/libc/test/src/sys/utsname/uname_test.cpp @@ -18,9 +18,9 @@ TEST(LlvmLibcUnameTest, GetMachineName) { struct utsname names; ASSERT_GE(__llvm_libc::uname(&names), 0); -#ifdef LIBC_TARGET_IS_X86_64 +#ifdef LIBC_TARGET_ARCH_IS_X86_64 ASSERT_STREQ(names.machine, "x86_64"); -#elif defined(LIBC_TARGET_IS_AARCH64) +#elif defined(LIBC_TARGET_ARCH_IS_AARCH64) ASSERT_STREQ(names.machine, "aarch64"); #endif } -- 2.7.4