Skip to content

Commit cc0065a

Browse files
[builtins] Generate __multc3 for z/OS (#77554)
#68132 ended up removing __multc3 & __divtc3 from compiler-rt library builds that have QUAD_PRECISION but not TF_MODE due to missing int128 support. I added support for QUAD_PRECISION to use the native hex float long double representation. --------- Co-authored-by: Alexander Richardson <mail@alexrichardson.me>
1 parent 3baedb4 commit cc0065a

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

compiler-rt/lib/builtins/divtc3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define QUAD_PRECISION
1414
#include "fp_lib.h"
1515

16-
#if defined(CRT_HAS_TF_MODE)
16+
#if defined(CRT_HAS_F128)
1717

1818
// Returns: the quotient of (a + ib) / (c + id)
1919

compiler-rt/lib/builtins/fp_lib.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
188188
#undef Word_HiMask
189189
#undef Word_LoMask
190190
#undef Word_FullMask
191+
#else
192+
typedef long double fp_t;
191193
#endif // defined(CRT_HAS_TF_MODE)
192194
#else
193195
#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) {
374376
#endif
375377
}
376378

377-
#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE)
379+
#elif defined(QUAD_PRECISION)
378380
// The generic implementation only works for ieee754 floating point. For other
379381
// floating point types, continue to rely on the libm implementation for now.
380-
#if defined(CRT_HAS_IEEE_TF)
382+
#if defined(CRT_HAS_IEEE_TF) && defined(CRT_HAS_128BIT)
381383
static __inline tf_float __compiler_rt_logbtf(tf_float x) {
382384
return __compiler_rt_logbX(x);
383385
}
@@ -405,6 +407,8 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) {
405407
#define __compiler_rt_logbl crt_logbl
406408
#define __compiler_rt_scalbnl crt_scalbnl
407409
#define __compiler_rt_fmaxl crt_fmaxl
410+
#define crt_fabstf crt_fabsl
411+
#define crt_copysigntf crt_copysignl
408412
#else
409413
#error Unsupported TF mode type
410414
#endif

compiler-rt/lib/builtins/int_types.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,16 @@ typedef long double tf_float;
189189
#define CRT_LDBL_IEEE_F128
190190
#endif
191191
#define TF_C(x) x##L
192-
#elif __LDBL_MANT_DIG__ == 113
193-
// Use long double instead of __float128 if it matches the IEEE 128-bit format.
192+
#elif __LDBL_MANT_DIG__ == 113 || \
193+
(__FLT_RADIX__ == 16 && __LDBL_MANT_DIG__ == 28)
194+
// Use long double instead of __float128 if it matches the IEEE 128-bit format
195+
// or the IBM hexadecimal format.
194196
#define CRT_LDBL_128BIT
195197
#define CRT_HAS_F128
198+
#if __LDBL_MANT_DIG__ == 113
196199
#define CRT_HAS_IEEE_TF
197200
#define CRT_LDBL_IEEE_F128
201+
#endif
198202
typedef long double tf_float;
199203
#define TF_C(x) x##L
200204
#elif defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)

compiler-rt/lib/builtins/multc3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "int_lib.h"
1616
#include "int_math.h"
1717

18-
#if defined(CRT_HAS_TF_MODE)
18+
#if defined(CRT_HAS_F128)
1919

2020
// Returns: the product of a + ib and c + id
2121

0 commit comments

Comments
 (0)