diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake index b24ea353df48..921057706c5e 100644 --- a/libc/cmake/modules/LLVMLibCArchitectures.cmake +++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake @@ -184,6 +184,8 @@ elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "nvptx") set(LIBC_TARGET_ARCHITECTURE_IS_NVPTX TRUE) elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "spirv") set(LIBC_TARGET_ARCHITECTURE_IS_SPIRV TRUE) +elseif(LIBC_TARGET_ARCHITECTURE STREQUAL "power") + set(LIBC_TARGET_ARCHITECTURE_IS_POWERPC TRUE) else() message(FATAL_ERROR "Unsupported libc target architecture ${LIBC_TARGET_ARCHITECTURE}") diff --git a/libc/config/linux/power/config.json b/libc/config/linux/power/config.json new file mode 100644 index 000000000000..22e47df31bb6 --- /dev/null +++ b/libc/config/linux/power/config.json @@ -0,0 +1,7 @@ +{ + "string": { + "LIBC_CONF_STRING_LENGTH_IMPL": { + "value": "element" + } + } +} diff --git a/libc/config/linux/power/entrypoints.txt b/libc/config/linux/power/entrypoints.txt new file mode 100644 index 000000000000..f133d4f0d20c --- /dev/null +++ b/libc/config/linux/power/entrypoints.txt @@ -0,0 +1,14 @@ + +set(TARGET_LIBC_ENTRYPOINTS + libc.src.errno.errno +) + +set(TARGET_LIBM_ENTRYPOINTS) + +set(TARGET_LIBMVEC_ENTRYPOINTS) + +set(TARGET_LLVMLIBC_ENTRYPOINTS + ${TARGET_LIBC_ENTRYPOINTS} + ${TARGET_LIBM_ENTRYPOINTS} + ${TARGET_LIBMVEC_ENTRYPOINTS} +) diff --git a/libc/config/linux/power/headers.txt b/libc/config/linux/power/headers.txt new file mode 100644 index 000000000000..8b96869309bf --- /dev/null +++ b/libc/config/linux/power/headers.txt @@ -0,0 +1 @@ +set(TARGET_PUBLIC_HEADERS) diff --git a/libc/src/__support/FPUtil/generic/sqrt.h b/libc/src/__support/FPUtil/generic/sqrt.h index 2295fdf85a11..4e452a87050b 100644 --- a/libc/src/__support/FPUtil/generic/sqrt.h +++ b/libc/src/__support/FPUtil/generic/sqrt.h @@ -9,7 +9,6 @@ #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_GENERIC_SQRT_H #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_GENERIC_SQRT_H -#include "sqrt_80_bit_long_double.h" #include "src/__support/CPP/bit.h" // countl_zero #include "src/__support/CPP/type_traits.h" #include "src/__support/FPUtil/FEnvImpl.h" @@ -22,6 +21,10 @@ #include "hdr/fenv_macros.h" +#ifdef LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80 +#include "sqrt_80_bit_long_double.h" +#endif // !LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80 + namespace LIBC_NAMESPACE_DECL { namespace fputil { @@ -52,7 +55,7 @@ template <> LIBC_INLINE void normalize(int &exponent, uint64_t &mantissa) { normalize(exponent, mantissa); } -#elif !defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80) +#elif defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128) template <> LIBC_INLINE void normalize(int &exponent, UInt128 &mantissa) { const uint64_t hi_bits = static_cast(mantissa >> 64); @@ -76,8 +79,10 @@ LIBC_INLINE static constexpr cpp::enable_if_t< sqrt(InType x) { if constexpr (internal::SpecialLongDouble::VALUE && internal::SpecialLongDouble::VALUE) { +#ifdef LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80 // Special 80-bit long double. return x86::sqrt(x); +#endif // !LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80 } else { // IEEE floating points formats. using OutFPBits = FPBits;