diff options
author | Alex Richardson <alexrichardson@google.com> | 2023-07-24 16:41:44 -0700 |
---|---|---|
committer | Alex Richardson <alexrichardson@google.com> | 2023-07-24 17:19:11 -0700 |
commit | e3374c8c31fb54a2c8df6c906884e14f1c8a2209 (patch) | |
tree | 1e9f811d00689ac63af09759e2ab2f25107333d5 /compiler-rt | |
parent | b1149400122be1a9c713f3c31674a4f9b765c2d4 (diff) | |
download | llvm-e3374c8c31fb54a2c8df6c906884e14f1c8a2209.zip llvm-e3374c8c31fb54a2c8df6c906884e14f1c8a2209.tar.gz llvm-e3374c8c31fb54a2c8df6c906884e14f1c8a2209.tar.bz2 |
[builtins] Avoid using CRT_LDBL_128BIT in implementation. NFC
Currently the *tf builtin functions can only be built if long double is an
IEEE float, which prevents them from being available e.g. for x86 targets
(unlike libgcc which has them). This non-functional change prepares the
builtins library *tf functions for being able to target x86 by decoupling
their presence from CRT_LDBL_128BIT and instead checking for a
CRT_HAS_TF_MODE macro. This change is NFC since the CRT_HAS_TF_MODE is
currently only set if long double is an IEEE 128-bit float.
Reviewed By: compnerd
Differential Revision: https://reviews.llvm.org/D153812
Diffstat (limited to 'compiler-rt')
25 files changed, 29 insertions, 26 deletions
diff --git a/compiler-rt/lib/builtins/addtf3.c b/compiler-rt/lib/builtins/addtf3.c index 86e4f4cf..2cb3a4d 100644 --- a/compiler-rt/lib/builtins/addtf3.c +++ b/compiler-rt/lib/builtins/addtf3.c @@ -13,7 +13,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) #include "fp_add_impl.inc" COMPILER_RT_ABI fp_t __addtf3(fp_t a, fp_t b) { diff --git a/compiler-rt/lib/builtins/comparetf2.c b/compiler-rt/lib/builtins/comparetf2.c index f159245..be5e9e5 100644 --- a/compiler-rt/lib/builtins/comparetf2.c +++ b/compiler-rt/lib/builtins/comparetf2.c @@ -39,7 +39,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) #include "fp_compare_impl.inc" COMPILER_RT_ABI CMP_RESULT __letf2(fp_t a, fp_t b) { return __leXf2__(a, b); } diff --git a/compiler-rt/lib/builtins/divtf3.c b/compiler-rt/lib/builtins/divtf3.c index 5bcc9a8..bd76763 100644 --- a/compiler-rt/lib/builtins/divtf3.c +++ b/compiler-rt/lib/builtins/divtf3.c @@ -14,7 +14,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) #define NUMBER_OF_HALF_ITERATIONS 4 #define NUMBER_OF_FULL_ITERATIONS 1 diff --git a/compiler-rt/lib/builtins/extenddftf2.c b/compiler-rt/lib/builtins/extenddftf2.c index ddf470e..835076b 100644 --- a/compiler-rt/lib/builtins/extenddftf2.c +++ b/compiler-rt/lib/builtins/extenddftf2.c @@ -9,7 +9,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) #define SRC_DOUBLE #define DST_QUAD #include "fp_extend_impl.inc" diff --git a/compiler-rt/lib/builtins/extendhftf2.c b/compiler-rt/lib/builtins/extendhftf2.c index aefe973..a2cb0f7 100644 --- a/compiler-rt/lib/builtins/extendhftf2.c +++ b/compiler-rt/lib/builtins/extendhftf2.c @@ -10,8 +10,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) && \ - defined(COMPILER_RT_HAS_FLOAT16) +#if defined(CRT_HAS_TF_MODE) && defined(COMPILER_RT_HAS_FLOAT16) #define SRC_HALF #define DST_QUAD #include "fp_extend_impl.inc" diff --git a/compiler-rt/lib/builtins/extendsftf2.c b/compiler-rt/lib/builtins/extendsftf2.c index cf1fd2f..0739859 100644 --- a/compiler-rt/lib/builtins/extendsftf2.c +++ b/compiler-rt/lib/builtins/extendsftf2.c @@ -9,7 +9,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) #define SRC_SINGLE #define DST_QUAD #include "fp_extend_impl.inc" diff --git a/compiler-rt/lib/builtins/fixtfdi.c b/compiler-rt/lib/builtins/fixtfdi.c index fe570e6..d27a99b 100644 --- a/compiler-rt/lib/builtins/fixtfdi.c +++ b/compiler-rt/lib/builtins/fixtfdi.c @@ -9,7 +9,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) typedef di_int fixint_t; typedef du_int fixuint_t; #include "fp_fixint_impl.inc" diff --git a/compiler-rt/lib/builtins/fixtfsi.c b/compiler-rt/lib/builtins/fixtfsi.c index a32bd96..01e352a 100644 --- a/compiler-rt/lib/builtins/fixtfsi.c +++ b/compiler-rt/lib/builtins/fixtfsi.c @@ -9,7 +9,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) typedef si_int fixint_t; typedef su_int fixuint_t; #include "fp_fixint_impl.inc" diff --git a/compiler-rt/lib/builtins/fixtfti.c b/compiler-rt/lib/builtins/fixtfti.c index 19f84ce..491fca5 100644 --- a/compiler-rt/lib/builtins/fixtfti.c +++ b/compiler-rt/lib/builtins/fixtfti.c @@ -9,7 +9,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) typedef ti_int fixint_t; typedef tu_int fixuint_t; #include "fp_fixint_impl.inc" diff --git a/compiler-rt/lib/builtins/fixunstfdi.c b/compiler-rt/lib/builtins/fixunstfdi.c index a0805e6..febdb8f 100644 --- a/compiler-rt/lib/builtins/fixunstfdi.c +++ b/compiler-rt/lib/builtins/fixunstfdi.c @@ -9,7 +9,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) typedef du_int fixuint_t; #include "fp_fixuint_impl.inc" diff --git a/compiler-rt/lib/builtins/fixunstfsi.c b/compiler-rt/lib/builtins/fixunstfsi.c index 3a1320e..4efc387 100644 --- a/compiler-rt/lib/builtins/fixunstfsi.c +++ b/compiler-rt/lib/builtins/fixunstfsi.c @@ -9,7 +9,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) typedef su_int fixuint_t; #include "fp_fixuint_impl.inc" diff --git a/compiler-rt/lib/builtins/fixunstfti.c b/compiler-rt/lib/builtins/fixunstfti.c index 23cd1ab..fa9e7aa 100644 --- a/compiler-rt/lib/builtins/fixunstfti.c +++ b/compiler-rt/lib/builtins/fixunstfti.c @@ -9,7 +9,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) typedef tu_int fixuint_t; #include "fp_fixuint_impl.inc" diff --git a/compiler-rt/lib/builtins/floatditf.c b/compiler-rt/lib/builtins/floatditf.c index 9b07b65..c6e326a 100644 --- a/compiler-rt/lib/builtins/floatditf.c +++ b/compiler-rt/lib/builtins/floatditf.c @@ -15,7 +15,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) COMPILER_RT_ABI fp_t __floatditf(di_int a) { const int aWidth = sizeof a * CHAR_BIT; diff --git a/compiler-rt/lib/builtins/floatsitf.c b/compiler-rt/lib/builtins/floatsitf.c index 80a4ef0..4d5b52f 100644 --- a/compiler-rt/lib/builtins/floatsitf.c +++ b/compiler-rt/lib/builtins/floatsitf.c @@ -15,7 +15,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) COMPILER_RT_ABI fp_t __floatsitf(si_int a) { const int aWidth = sizeof a * CHAR_BIT; diff --git a/compiler-rt/lib/builtins/floattitf.c b/compiler-rt/lib/builtins/floattitf.c index 8e27373..fff0755 100644 --- a/compiler-rt/lib/builtins/floattitf.c +++ b/compiler-rt/lib/builtins/floattitf.c @@ -25,7 +25,7 @@ // mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm // mmmm mmmm mmmm -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) COMPILER_RT_ABI fp_t __floattitf(ti_int a) { if (a == 0) return 0.0; diff --git a/compiler-rt/lib/builtins/floatunditf.c b/compiler-rt/lib/builtins/floatunditf.c index 8d31085..abe0ca9 100644 --- a/compiler-rt/lib/builtins/floatunditf.c +++ b/compiler-rt/lib/builtins/floatunditf.c @@ -15,7 +15,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) COMPILER_RT_ABI fp_t __floatunditf(du_int a) { const int aWidth = sizeof a * CHAR_BIT; diff --git a/compiler-rt/lib/builtins/floatunsitf.c b/compiler-rt/lib/builtins/floatunsitf.c index 7ba1fb6..3f0a524 100644 --- a/compiler-rt/lib/builtins/floatunsitf.c +++ b/compiler-rt/lib/builtins/floatunsitf.c @@ -15,7 +15,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) COMPILER_RT_ABI fp_t __floatunsitf(su_int a) { const int aWidth = sizeof a * CHAR_BIT; diff --git a/compiler-rt/lib/builtins/floatuntitf.c b/compiler-rt/lib/builtins/floatuntitf.c index a8b3b48..33a81b3 100644 --- a/compiler-rt/lib/builtins/floatuntitf.c +++ b/compiler-rt/lib/builtins/floatuntitf.c @@ -25,7 +25,7 @@ // mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm // mmmm mmmm mmmm -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) COMPILER_RT_ABI fp_t __floatuntitf(tu_int a) { if (a == 0) return 0.0; diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h index 0e7e93c..58eb45f 100644 --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -106,7 +106,12 @@ COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b); #elif defined QUAD_PRECISION #if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__) +// TODO: Availability of the *tf functions should not depend on long double +// being IEEE 128, but instead on being able to use a 128-bit floating-point +// type, which includes __float128. +// Right now this (incorrectly) stops the builtins from being used for x86. #define CRT_LDBL_128BIT +#define CRT_HAS_TF_MODE #define TF_C(c) c##L typedef uint64_t half_rep_t; typedef __uint128_t rep_t; diff --git a/compiler-rt/lib/builtins/multf3.c b/compiler-rt/lib/builtins/multf3.c index 0626fb8..8fd7368 100644 --- a/compiler-rt/lib/builtins/multf3.c +++ b/compiler-rt/lib/builtins/multf3.c @@ -14,7 +14,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) #include "fp_mul_impl.inc" COMPILER_RT_ABI fp_t __multf3(fp_t a, fp_t b) { return __mulXf3__(a, b); } diff --git a/compiler-rt/lib/builtins/powitf2.c b/compiler-rt/lib/builtins/powitf2.c index 8e639a0..74fe707 100644 --- a/compiler-rt/lib/builtins/powitf2.c +++ b/compiler-rt/lib/builtins/powitf2.c @@ -13,7 +13,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) // Returns: a ^ b diff --git a/compiler-rt/lib/builtins/subtf3.c b/compiler-rt/lib/builtins/subtf3.c index 3364c28..e1b1022 100644 --- a/compiler-rt/lib/builtins/subtf3.c +++ b/compiler-rt/lib/builtins/subtf3.c @@ -13,7 +13,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) COMPILER_RT_ABI fp_t __addtf3(fp_t a, fp_t b); // Subtraction; flip the sign bit of b and add. diff --git a/compiler-rt/lib/builtins/trunctfdf2.c b/compiler-rt/lib/builtins/trunctfdf2.c index 6857ea5..f0d2e41 100644 --- a/compiler-rt/lib/builtins/trunctfdf2.c +++ b/compiler-rt/lib/builtins/trunctfdf2.c @@ -9,7 +9,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) #define SRC_QUAD #define DST_DOUBLE #include "fp_trunc_impl.inc" diff --git a/compiler-rt/lib/builtins/trunctfhf2.c b/compiler-rt/lib/builtins/trunctfhf2.c index e3a2309..f777632 100644 --- a/compiler-rt/lib/builtins/trunctfhf2.c +++ b/compiler-rt/lib/builtins/trunctfhf2.c @@ -10,8 +10,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) && \ - defined(COMPILER_RT_HAS_FLOAT16) +#if defined(CRT_HAS_TF_MODE) && defined(COMPILER_RT_HAS_FLOAT16) #define SRC_QUAD #define DST_HALF #include "fp_trunc_impl.inc" diff --git a/compiler-rt/lib/builtins/trunctfsf2.c b/compiler-rt/lib/builtins/trunctfsf2.c index 0261b1e..242735f 100644 --- a/compiler-rt/lib/builtins/trunctfsf2.c +++ b/compiler-rt/lib/builtins/trunctfsf2.c @@ -9,7 +9,7 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) #define SRC_QUAD #define DST_SINGLE #include "fp_trunc_impl.inc" |