[PATCH] D53608: [builtins] Build float128 soft float builtins for x86_64.

Siddhartha Bagaria via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 9 17:06:16 PST 2021


starsid updated this revision to Diff 393340.
starsid added a comment.

fix commit author name and email


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53608/new/

https://reviews.llvm.org/D53608

Files:
  compiler-rt/lib/builtins/extendhftf2.c
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/powitf2.c
  compiler-rt/lib/builtins/trunctfdf2.c
  compiler-rt/lib/builtins/trunctfhf2.c
  compiler-rt/lib/builtins/trunctfsf2.c


Index: compiler-rt/lib/builtins/trunctfsf2.c
===================================================================
--- compiler-rt/lib/builtins/trunctfsf2.c
+++ compiler-rt/lib/builtins/trunctfsf2.c
@@ -14,6 +14,6 @@
 #define DST_SINGLE
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI float __trunctfsf2(long double a) { return __truncXfYf2__(a); }
+COMPILER_RT_ABI float __trunctfsf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/trunctfhf2.c
===================================================================
--- compiler-rt/lib/builtins/trunctfhf2.c
+++ compiler-rt/lib/builtins/trunctfhf2.c
@@ -16,8 +16,6 @@
 #define DST_HALF
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI _Float16 __trunctfhf2(long double a) {
-  return __truncXfYf2__(a);
-}
+COMPILER_RT_ABI _Float16 __trunctfhf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/trunctfdf2.c
===================================================================
--- compiler-rt/lib/builtins/trunctfdf2.c
+++ compiler-rt/lib/builtins/trunctfdf2.c
@@ -14,6 +14,6 @@
 #define DST_DOUBLE
 #include "fp_trunc_impl.inc"
 
-COMPILER_RT_ABI double __trunctfdf2(long double a) { return __truncXfYf2__(a); }
+COMPILER_RT_ABI double __trunctfdf2(fp_t a) { return __truncXfYf2__(a); }
 
 #endif
Index: compiler-rt/lib/builtins/powitf2.c
===================================================================
--- compiler-rt/lib/builtins/powitf2.c
+++ compiler-rt/lib/builtins/powitf2.c
@@ -17,9 +17,9 @@
 
 // Returns: a ^ b
 
-COMPILER_RT_ABI long double __powitf2(long double a, int b) {
+COMPILER_RT_ABI fp_t __powitf2(fp_t a, int b) {
   const int recip = b < 0;
-  long double r = 1;
+  fp_t r = 1;
   while (1) {
     if (b & 1)
       r *= a;
Index: compiler-rt/lib/builtins/fp_lib.h
===================================================================
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -105,12 +105,17 @@
 COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b);
 
 #elif defined QUAD_PRECISION
-#if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)
+#if (__LDBL_MANT_DIG__ == 113 || defined(__x86_64__)) &&                       \
+    defined(__SIZEOF_INT128__)
 #define CRT_LDBL_128BIT
 typedef uint64_t half_rep_t;
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;
+#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+typedef __float128 fp_t;
+#else
 typedef long double fp_t;
+#endif
 #define HALF_REP_C UINT64_C
 #define REP_C (__uint128_t)
 // Note: Since there is no explicit way to tell compiler the constant is a
Index: compiler-rt/lib/builtins/extendhftf2.c
===================================================================
--- compiler-rt/lib/builtins/extendhftf2.c
+++ compiler-rt/lib/builtins/extendhftf2.c
@@ -16,8 +16,6 @@
 #define DST_QUAD
 #include "fp_extend_impl.inc"
 
-COMPILER_RT_ABI long double __extendhftf2(_Float16 a) {
-  return __extendXfYf2__(a);
-}
+COMPILER_RT_ABI fp_t __extendhftf2(_Float16 a) { return __extendXfYf2__(a); }
 
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53608.393340.patch
Type: text/x-patch
Size: 3039 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211210/065d0c8a/attachment.bin>


More information about the llvm-commits mailing list