From 66989a1d5937d2eadcf7658a16a8fd8eced23a00 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 23 Feb 2024 10:32:52 -0600 Subject: [PATCH 1/5] fix build for z/os --- compiler-rt/lib/builtins/fp_lib.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h index c4f0a5b9587f7..48adea3619cf4 100644 --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -383,10 +383,10 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { #endif } -#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE) +#elif defined(QUAD_PRECISION) +#if defined(CRT_HAS_TF_MODE) && defined(CRT_HAS_IEEE_TF) // The generic implementation only works for ieee754 floating point. For other // floating point types, continue to rely on the libm implementation for now. -#if defined(CRT_HAS_IEEE_TF) static __inline tf_float __compiler_rt_logbtf(tf_float x) { return __compiler_rt_logbX(x); } From 6c45d601a845035f297973a7bc928be21dfe16cc Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 09:14:04 -0500 Subject: [PATCH 2/5] Fix files so div & mult are included for z/OS and excluded for 32-bit sparc --- compiler-rt/lib/builtins/CMakeLists.txt | 11 +++++++++-- compiler-rt/lib/builtins/divtc3.c | 2 +- compiler-rt/lib/builtins/multc3.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 2c3b0fa84a478..0b3ed34c37c05 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -755,8 +755,15 @@ set(riscv64_SOURCES ${riscv_SOURCES} ) -set(sparc_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES}) -set(sparcv9_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES}) +# Exclude the FT sources for 32-bit SPARC. Clang doesn't +# support 128-bit long double on 32-bit SPARC. +if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "sparc") + set(sparc_SOURCES ${GENERIC_SOURCES}) + set(sparcv9_SOURCES ${GENERIC_SOURCES}) +else() + set(sparc_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES}) + set(sparcv9_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES}) +endif() set(wasm32_SOURCES ${GENERIC_TF_SOURCES} diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c index c393de815337e..099de5802daf0 100644 --- a/compiler-rt/lib/builtins/divtc3.c +++ b/compiler-rt/lib/builtins/divtc3.c @@ -13,7 +13,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128) +#if defined(CRT_HAS_F128) // Returns: the quotient of (a + ib) / (c + id) diff --git a/compiler-rt/lib/builtins/multc3.c b/compiler-rt/lib/builtins/multc3.c index a89832f0e883e..61a3f45e47279 100644 --- a/compiler-rt/lib/builtins/multc3.c +++ b/compiler-rt/lib/builtins/multc3.c @@ -15,7 +15,7 @@ #include "int_lib.h" #include "int_math.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128) +#if defined(CRT_HAS_F128) // Returns: the product of a + ib and c + id From b151da0745fb409ab542161af77b3bbeb0471426 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 25 Sep 2024 10:15:26 -0500 Subject: [PATCH 3/5] reorg some more so sparc doesn't get error when CRT_HAS_TF_MODE isn't defined --- compiler-rt/lib/builtins/fp_lib.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h index d0e1c2637fa00..e4a330d84ecf9 100644 --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -369,7 +369,8 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { } #elif defined(QUAD_PRECISION) -#if defined(CRT_HAS_TF_MODE) && defined(CRT_HAS_IEEE_TF) +#if defined(CRT_HAS_TF_MODE) +#if defined(CRT_HAS_IEEE_TF) // The generic implementation only works for ieee754 floating point. For other // floating point types, continue to rely on the libm implementation for now. static __inline tf_float __compiler_rt_logbtf(tf_float x) { @@ -386,6 +387,9 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { #define __compiler_rt_fmaxl __compiler_rt_fmaxtf #define crt_fabstf crt_fabsf128 #define crt_copysigntf crt_copysignf128 +#else +#error Unsupported TF mode type +#endif #elif defined(CRT_LDBL_128BIT) static __inline tf_float __compiler_rt_logbtf(tf_float x) { return crt_logbl(x); @@ -401,8 +405,6 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { #define __compiler_rt_fmaxl crt_fmaxl #define crt_fabstf crt_fabsl #define crt_copysigntf crt_copysignl -#else -#error Unsupported TF mode type #endif #endif // *_PRECISION From fef5e08d576b360dd735646124e40d34ef049878 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 21 Jan 2025 10:53:50 -0500 Subject: [PATCH 4/5] simplify conditional code for QUAD --- compiler-rt/lib/builtins/fp_lib.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h index e4a330d84ecf9..ff269c77be9cc 100644 --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -369,8 +369,7 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { } #elif defined(QUAD_PRECISION) -#if defined(CRT_HAS_TF_MODE) -#if defined(CRT_HAS_IEEE_TF) +#if defined(CRT_HAS_IEEE_TF) && defined(CRT_HAS_INT128) // The generic implementation only works for ieee754 floating point. For other // floating point types, continue to rely on the libm implementation for now. static __inline tf_float __compiler_rt_logbtf(tf_float x) { @@ -387,9 +386,6 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { #define __compiler_rt_fmaxl __compiler_rt_fmaxtf #define crt_fabstf crt_fabsf128 #define crt_copysigntf crt_copysignf128 -#else -#error Unsupported TF mode type -#endif #elif defined(CRT_LDBL_128BIT) static __inline tf_float __compiler_rt_logbtf(tf_float x) { return crt_logbl(x); @@ -405,6 +401,8 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { #define __compiler_rt_fmaxl crt_fmaxl #define crt_fabstf crt_fabsl #define crt_copysigntf crt_copysignl +#else +#error Unsupported QUAD_PRECISION mode #endif #endif // *_PRECISION From 5e87718b5a62d092a7a6ebaba9c1511941c64c7c Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 21 Jan 2025 14:30:33 -0500 Subject: [PATCH 5/5] Revert "simplify conditional code for QUAD" This reverts commit fef5e08d576b360dd735646124e40d34ef049878. --- compiler-rt/lib/builtins/fp_lib.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h index ff269c77be9cc..e4a330d84ecf9 100644 --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -369,7 +369,8 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { } #elif defined(QUAD_PRECISION) -#if defined(CRT_HAS_IEEE_TF) && defined(CRT_HAS_INT128) +#if defined(CRT_HAS_TF_MODE) +#if defined(CRT_HAS_IEEE_TF) // The generic implementation only works for ieee754 floating point. For other // floating point types, continue to rely on the libm implementation for now. static __inline tf_float __compiler_rt_logbtf(tf_float x) { @@ -386,6 +387,9 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { #define __compiler_rt_fmaxl __compiler_rt_fmaxtf #define crt_fabstf crt_fabsf128 #define crt_copysigntf crt_copysignf128 +#else +#error Unsupported TF mode type +#endif #elif defined(CRT_LDBL_128BIT) static __inline tf_float __compiler_rt_logbtf(tf_float x) { return crt_logbl(x); @@ -401,8 +405,6 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { #define __compiler_rt_fmaxl crt_fmaxl #define crt_fabstf crt_fabsl #define crt_copysigntf crt_copysignl -#else -#error Unsupported QUAD_PRECISION mode #endif #endif // *_PRECISION