[libc-commits] [clang-tools-extra] [compiler-rt] [flang] [libcxxabi] [llvm] [lldb] [libunwind] [libclc] [lld] [libc] [clang] [libcxx] [builtins] Generate __multc3 for z/OS (PR #77554)
Sean Perry via libc-commits
libc-commits at lists.llvm.org
Thu Jan 11 11:21:48 PST 2024
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/77554
>From 7ba4d61bd2beda03ba0fcefc9ca5c1ff08ffd48e Mon Sep 17 00:00:00 2001
From: Sean Perry <perry at ca.ibm.com>
Date: Tue, 9 Jan 2024 20:59:28 -0600
Subject: [PATCH 1/5] Generate __multc3 for z/OS
---
compiler-rt/lib/builtins/divtc3.c | 3 ---
compiler-rt/lib/builtins/fp_lib.h | 8 ++++++--
compiler-rt/lib/builtins/int_types.h | 6 ++++--
compiler-rt/lib/builtins/multc3.c | 4 ----
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c
index e970cef574b21d..6ec9c5f17d4b68 100644
--- a/compiler-rt/lib/builtins/divtc3.c
+++ b/compiler-rt/lib/builtins/divtc3.c
@@ -13,7 +13,6 @@
#define QUAD_PRECISION
#include "fp_lib.h"
-#if defined(CRT_HAS_TF_MODE)
// Returns: the quotient of (a + ib) / (c + id)
@@ -52,5 +51,3 @@ COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) {
}
return z;
}
-
-#endif
diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h
index af406e760497a4..a293788fc68f56 100644
--- a/compiler-rt/lib/builtins/fp_lib.h
+++ b/compiler-rt/lib/builtins/fp_lib.h
@@ -188,6 +188,8 @@ static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
#undef Word_HiMask
#undef Word_LoMask
#undef Word_FullMask
+#else
+typedef long double fp_t;
#endif // defined(CRT_HAS_TF_MODE)
#else
#error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined.
@@ -374,10 +376,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)
// 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)
+#if defined(CRT_HAS_TF_MODE) && defined(CRT_HAS_IEEE_TF)
static __inline tf_float __compiler_rt_logbtf(tf_float x) {
return __compiler_rt_logbX(x);
}
@@ -405,6 +407,8 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) {
#define __compiler_rt_logbl crt_logbl
#define __compiler_rt_scalbnl crt_scalbnl
#define __compiler_rt_fmaxl crt_fmaxl
+#define crt_fabstf crt_fabsl
+#define crt_copysigntf crt_copysignl
#else
#error Unsupported TF mode type
#endif
diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h
index 7624c728061518..ebbc63af598b76 100644
--- a/compiler-rt/lib/builtins/int_types.h
+++ b/compiler-rt/lib/builtins/int_types.h
@@ -189,8 +189,10 @@ typedef long double tf_float;
#define CRT_LDBL_IEEE_F128
#endif
#define TF_C(x) x##L
-#elif __LDBL_MANT_DIG__ == 113
-// Use long double instead of __float128 if it matches the IEEE 128-bit format.
+#elif __LDBL_MANT_DIG__ == 113 || \
+ (__FLT_RADIX__ == 16 && __LDBL_MANT_DIG__ == 28)
+// Use long double instead of __float128 if it matches the IEEE 128-bit format
+// or the IBM hexadecimal format.
#define CRT_LDBL_128BIT
#define CRT_HAS_F128
#define CRT_HAS_IEEE_TF
diff --git a/compiler-rt/lib/builtins/multc3.c b/compiler-rt/lib/builtins/multc3.c
index f20e53ccbf233b..21c522d0330b7f 100644
--- a/compiler-rt/lib/builtins/multc3.c
+++ b/compiler-rt/lib/builtins/multc3.c
@@ -15,8 +15,6 @@
#include "int_lib.h"
#include "int_math.h"
-#if defined(CRT_HAS_TF_MODE)
-
// Returns: the product of a + ib and c + id
COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) {
@@ -66,5 +64,3 @@ COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) {
}
return z;
}
-
-#endif
>From 81b814ccc0b216eb9464c9fa5d4d28b0511c2338 Mon Sep 17 00:00:00 2001
From: Sean Perry <39927768+perry-ca at users.noreply.github.com>
Date: Tue, 9 Jan 2024 23:49:29 -0500
Subject: [PATCH 2/5] formatting update
---
compiler-rt/lib/builtins/divtc3.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c
index 6ec9c5f17d4b68..7d3185c9d71fbb 100644
--- a/compiler-rt/lib/builtins/divtc3.c
+++ b/compiler-rt/lib/builtins/divtc3.c
@@ -13,7 +13,6 @@
#define QUAD_PRECISION
#include "fp_lib.h"
-
// Returns: the quotient of (a + ib) / (c + id)
COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) {
>From 2cb932ab37caf472aa296f5d7c811feada8464f0 Mon Sep 17 00:00:00 2001
From: Sean Perry <perry at ca.ibm.com>
Date: Wed, 10 Jan 2024 16:03:48 -0600
Subject: [PATCH 3/5] only define CRT_HAS_F128 & CRT_HAS_IEEE_TF for IEEE
---
compiler-rt/lib/builtins/int_types.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h
index ebbc63af598b76..9ceced37a997f4 100644
--- a/compiler-rt/lib/builtins/int_types.h
+++ b/compiler-rt/lib/builtins/int_types.h
@@ -194,8 +194,10 @@ typedef long double tf_float;
// Use long double instead of __float128 if it matches the IEEE 128-bit format
// or the IBM hexadecimal format.
#define CRT_LDBL_128BIT
+#if __LDBL_MANT_DIG__ == 113
#define CRT_HAS_F128
#define CRT_HAS_IEEE_TF
+#endif
#define CRT_LDBL_IEEE_F128
typedef long double tf_float;
#define TF_C(x) x##L
>From bb5c0c36c1fc9883593599457825b91631e4f1af Mon Sep 17 00:00:00 2001
From: Sean Perry <39927768+perry-ca at users.noreply.github.com>
Date: Thu, 11 Jan 2024 14:21:27 -0500
Subject: [PATCH 4/5] Update compiler-rt/lib/builtins/int_types.h
Co-authored-by: Alexander Richardson <mail at alexrichardson.me>
---
compiler-rt/lib/builtins/int_types.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h
index 9ceced37a997f4..ca97391fc28466 100644
--- a/compiler-rt/lib/builtins/int_types.h
+++ b/compiler-rt/lib/builtins/int_types.h
@@ -194,11 +194,11 @@ typedef long double tf_float;
// Use long double instead of __float128 if it matches the IEEE 128-bit format
// or the IBM hexadecimal format.
#define CRT_LDBL_128BIT
-#if __LDBL_MANT_DIG__ == 113
#define CRT_HAS_F128
+#if __LDBL_MANT_DIG__ == 113
#define CRT_HAS_IEEE_TF
-#endif
#define CRT_LDBL_IEEE_F128
+#endif
typedef long double tf_float;
#define TF_C(x) x##L
#elif defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
>From 4a24da7e340d9b9699ea6af955392a9e301f1f05 Mon Sep 17 00:00:00 2001
From: Sean Perry <39927768+perry-ca at users.noreply.github.com>
Date: Thu, 11 Jan 2024 14:21:39 -0500
Subject: [PATCH 5/5] Update compiler-rt/lib/builtins/fp_lib.h
Co-authored-by: Alexander Richardson <mail at alexrichardson.me>
---
compiler-rt/lib/builtins/fp_lib.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h
index a293788fc68f56..ec71b662a72f15 100644
--- a/compiler-rt/lib/builtins/fp_lib.h
+++ b/compiler-rt/lib/builtins/fp_lib.h
@@ -379,7 +379,7 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) {
#elif defined(QUAD_PRECISION)
// 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_TF_MODE) && defined(CRT_HAS_IEEE_TF)
+#if defined(CRT_HAS_IEEE_TF) && defined(CRT_HAS_128BIT)
static __inline tf_float __compiler_rt_logbtf(tf_float x) {
return __compiler_rt_logbX(x);
}
More information about the libc-commits
mailing list