[compiler-rt] [compiler-rt] Implement __extendxftf2 for x86_64 (PR #66918)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 22 16:48:19 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff e5026f0179f2871ba9fefc489972643324a4ba4f 85a64d3becc1fc25da45defd5fa61dd0a9788a26 -- compiler-rt/lib/builtins/extendxftf2.c compiler-rt/test/builtins/Unit/extendxftf2_test.c compiler-rt/lib/builtins/fp_extend.h compiler-rt/test/builtins/Unit/addtf3_test.c compiler-rt/test/builtins/Unit/divtf3_test.c compiler-rt/test/builtins/Unit/extenddftf2_test.c compiler-rt/test/builtins/Unit/extendhftf2_test.c compiler-rt/test/builtins/Unit/extendsftf2_test.c compiler-rt/test/builtins/Unit/floatditf_test.c compiler-rt/test/builtins/Unit/floatsitf_test.c compiler-rt/test/builtins/Unit/floatunditf_test.c compiler-rt/test/builtins/Unit/floatunsitf_test.c compiler-rt/test/builtins/Unit/fp_test.h compiler-rt/test/builtins/Unit/multf3_test.c compiler-rt/test/builtins/Unit/subtf3_test.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/compiler-rt/lib/builtins/extendxftf2.c b/compiler-rt/lib/builtins/extendxftf2.c
index aa5355e94..20911fe7c 100644
--- a/compiler-rt/lib/builtins/extendxftf2.c
+++ b/compiler-rt/lib/builtins/extendxftf2.c
@@ -10,8 +10,8 @@
// bits.
// TODO: use fp_lib.h once QUAD_PRECISION is available on x86_64.
-#if __LDBL_MANT_DIG__ == 64 && defined(__x86_64__) \
- && (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
+#if __LDBL_MANT_DIG__ == 64 && defined(__x86_64__) && \
+ (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
#define SRC_80
#define DST_QUAD
#include "fp_extend_impl.inc"
diff --git a/compiler-rt/lib/builtins/fp_extend.h b/compiler-rt/lib/builtins/fp_extend.h
index fc23c1c2d..ad73a49c5 100644
--- a/compiler-rt/lib/builtins/fp_extend.h
+++ b/compiler-rt/lib/builtins/fp_extend.h
@@ -88,7 +88,8 @@ static const int dstSigFracBits = 52;
// TODO: use fp_lib.h once QUAD_PRECISION is available on x86_64.
#if __LDBL_MANT_DIG__ == 113
typedef long double dst_t;
-#elif defined(__x86_64__) && (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
+#elif defined(__x86_64__) && \
+ (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
typedef __float128 dst_t;
#endif
typedef __uint128_t dst_rep_t;
diff --git a/compiler-rt/test/builtins/Unit/extendxftf2_test.c b/compiler-rt/test/builtins/Unit/extendxftf2_test.c
index c4b561a42..de950fc54 100644
--- a/compiler-rt/test/builtins/Unit/extendxftf2_test.c
+++ b/compiler-rt/test/builtins/Unit/extendxftf2_test.c
@@ -4,10 +4,10 @@
#include "int_lib.h"
#include <stdio.h>
-#if __LDBL_MANT_DIG__ == 64 && \
- defined(__x86_64__) && (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
+#if __LDBL_MANT_DIG__ == 64 && defined(__x86_64__) && \
+ (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
-#include "fp_test.h"
+# include "fp_test.h"
COMPILER_RT_ABI __float128 __extendxftf2(long double a);
@@ -28,8 +28,8 @@ char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
#endif
int main() {
-#if __LDBL_MANT_DIG__ == 64 && \
- defined(__x86_64__) && (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
+#if __LDBL_MANT_DIG__ == 64 && defined(__x86_64__) && \
+ (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
// qNaN
if (test__extendxftf2(makeQNaN80(), UINT64_C(0x7fff800000000000),
UINT64_C(0x0)))
diff --git a/compiler-rt/test/builtins/Unit/fp_test.h b/compiler-rt/test/builtins/Unit/fp_test.h
index e11eacf4a..9d9208afc 100644
--- a/compiler-rt/test/builtins/Unit/fp_test.h
+++ b/compiler-rt/test/builtins/Unit/fp_test.h
@@ -10,15 +10,15 @@
#endif
// TODO: Switch to using fp_lib.h once QUAD_PRECISION is available on x86_64.
-#if __LDBL_MANT_DIG__ == 113 || \
- ((__LDBL_MANT_DIG__ == 64) && defined(__x86_64__) && \
+#if __LDBL_MANT_DIG__ == 113 || \
+ ((__LDBL_MANT_DIG__ == 64) && defined(__x86_64__) && \
(defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)))
-#if __LDBL_MANT_DIG__ == 113
-#define TYPE_FP128 long double
-#else
-#define TYPE_FP128 __float128
-#endif
-#define TEST_COMPILER_RT_HAS_FLOAT128
+# if __LDBL_MANT_DIG__ == 113
+# define TYPE_FP128 long double
+# else
+# define TYPE_FP128 __float128
+# endif
+# define TEST_COMPILER_RT_HAS_FLOAT128
#endif
enum EXPECTED_RESULT {
@@ -51,8 +51,7 @@ static inline double fromRep64(uint64_t x)
}
#ifdef TEST_COMPILER_RT_HAS_FLOAT128
-static inline TYPE_FP128 fromRep128(uint64_t hi, uint64_t lo)
-{
+static inline TYPE_FP128 fromRep128(uint64_t hi, uint64_t lo) {
__uint128_t x = ((__uint128_t)hi << 64) + lo;
TYPE_FP128 ret;
memcpy(&ret, &x, 16);
@@ -86,8 +85,7 @@ static inline uint64_t toRep64(double x)
}
#ifdef TEST_COMPILER_RT_HAS_FLOAT128
-static inline __uint128_t toRep128(TYPE_FP128 x)
-{
+static inline __uint128_t toRep128(TYPE_FP128 x) {
__uint128_t ret;
memcpy(&ret, &x, 16);
return ret;
@@ -152,10 +150,8 @@ static inline int compareResultD(double result,
// return 0 if equal
// use two 64-bit integers instead of one 128-bit integer
// because 128-bit integer constant can't be assigned directly
-static inline int compareResultF128(TYPE_FP128 result,
- uint64_t expectedHi,
- uint64_t expectedLo)
-{
+static inline int compareResultF128(TYPE_FP128 result, uint64_t expectedHi,
+ uint64_t expectedLo) {
__uint128_t rep = toRep128(result);
uint64_t hi = rep >> 64;
uint64_t lo = rep;
@@ -245,26 +241,23 @@ static inline double makeQNaN64(void)
}
#if __LDBL_MANT_DIG__ == 64 && defined(__x86_64__)
-static inline long double LDFromRep128(uint64_t hi, uint64_t lo)
-{
+static inline long double LDFromRep128(uint64_t hi, uint64_t lo) {
__uint128_t x = ((__uint128_t)hi << 64) + lo;
long double ret;
memcpy(&ret, &x, 16);
return ret;
}
-static inline long double makeQNaN80(void)
-{
+static inline long double makeQNaN80(void) {
return LDFromRep128(0x7fffUL, 0xc000000000000000UL);
}
-static inline long double makeNaN80(uint64_t rand)
-{
- return LDFromRep128(0x7fffUL, 0x8000000000000000 | (rand & 0x3fffffffffffffff));
+static inline long double makeNaN80(uint64_t rand) {
+ return LDFromRep128(0x7fffUL,
+ 0x8000000000000000 | (rand & 0x3fffffffffffffff));
}
-static inline long double makeInf80(void)
-{
+static inline long double makeInf80(void) {
return LDFromRep128(0x7fffUL, 0x8000000000000000UL);
}
#endif
``````````
</details>
https://github.com/llvm/llvm-project/pull/66918
More information about the llvm-commits
mailing list