]> gcc.gnu.org Git - gcc.git/commitdiff
PR target/107299: Update IEEE 128-bit types in PowerPC libgcc.
authorMichael Meissner <meissner@linux.ibm.com>
Wed, 18 Jan 2023 02:37:15 +0000 (21:37 -0500)
committerMichael Meissner <meissner@linux.ibm.com>
Wed, 18 Jan 2023 02:37:15 +0000 (21:37 -0500)
This patch updates the IEEE 128-bit types in libgcc.

At the moment, we cannot build GCC when the target uses IEEE 128-bit long
doubles, such as building the compiler for a native Fedora 36 system.  The
build dies when it is trying to build the _mulkc3.c and _divkc3 modules.

This patch changes the IEEE 128-bit type (TFtype) in the IEEE 128-bit support
to use either _Float128 or long double.  Previously we would use the __float128
type.  In addition, the TCtype will use the same type along with _Complex.

While it is desirable to ultimately have __float128 and _Float128 use the same
internal type and mode within GCC, at present if you use the option
-mabi=ieeelongdouble, the __float128 type will use the long double type.  We
get an internal compiler error if we combine the signbitf128 built-in with a
long double type.

I've gone through several iterations of trying to fix this within GCC, and
there are various problems that have come up.  I developed this alternative
patch that changes libgcc so that it does not tickle the issue.  I hope we can
fix the compiler at some point, but right now, this is preventing people on
Fedora 36 systems from building compilers where the default long double is IEEE
128-bit.

I changed the three functions that deal with complex multiply and complex divide
support (_mulkc3, _divkc3, and float128-ifunc) to always be compiled with IEEE
128-bit long double.  This is to be type correct, and avoid mismatch declaration
errors from the compiler.

2023-01-17   Michael Meissner  <meissner@linux.ibm.com>

PR target/107299
* config/rs6000/_divkc3.c (top level): Require that long double is IEEE
128-bit.
(COPYSIGN): Use long double built-in.
(INFINITY): Likewise.
(FABS): Likewise.
(RBIG): Use TFmode constants, not KFmode.
(RMIN): Likewise.
(RMIN2): Likewise.
(RMINSCAL): Likewise.
(RMAX2): Likewise.
* config/rs6000/_mulkc3.c (top level): Require that long double is IEEE
128-bit.
(COPYSIGN): Use long double built-in.
(INFINITY): Likewise.
* config/rs6000/quad-float128.h (TF): Remove definition.
(TFtype): New macro, use _Float128 or long double.
(TCtype): Change to macro, use _Complex _Float128 or _Complex long
double.
(__mulkc3_sw): Only declare if long double is IEEE 128-bit.
(__divkc3_sw): Likewise.
(__mulkc3_hw): Likewise.
(__divkc3_hw): Likewise.
(__mulkc3): Likewise.
(__divkc3): Likewise.
* libgcc2.h (TFtype): Allow md files to override this.
(TCtype): Likewise.
* soft-fp/quad.h (TFtype): Likewise.

libgcc/config/rs6000/_divkc3.c
libgcc/config/rs6000/_mulkc3.c
libgcc/config/rs6000/quad-float128.h
libgcc/libgcc2.h
libgcc/soft-fp/quad.h

index 59ab2137d1d05d3ca763b3f751c364df2214bfca..cfbc7b7651620abcd5de80f16695a2f642d6b896 100644 (file)
@@ -26,9 +26,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #include "soft-fp.h"
 #include "quad-float128.h"
 
-#define COPYSIGN(x,y) __builtin_copysignf128 (x, y)
-#define INFINITY __builtin_inff128 ()
-#define FABS __builtin_fabsf128
+#ifndef __LONG_DOUBLE_IEEE128__
+#error "_divkc3.c needs to be compiled with -mabi=ieeelongdouble."
+#endif
+
+#define COPYSIGN(x,y) __builtin_copysignl (x, y)
+#define INFINITY __builtin_infl ()
+#define FABS __builtin_fabsl
 #define isnan __builtin_isnan
 #define isinf __builtin_isinf
 #define isfinite __builtin_isfinite
@@ -37,19 +41,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define __divkc3 __divkc3_sw
 #endif
 
-#ifndef __LONG_DOUBLE_IEEE128__
-#define RBIG   (__LIBGCC_KF_MAX__ / 2)
-#define RMIN   (__LIBGCC_KF_MIN__)
-#define RMIN2  (__LIBGCC_KF_EPSILON__)
-#define RMINSCAL (1 / __LIBGCC_KF_EPSILON__)
-#define RMAX2  (RBIG * RMIN2)
-#else
 #define RBIG   (__LIBGCC_TF_MAX__ / 2)
 #define RMIN   (__LIBGCC_TF_MIN__)
 #define RMIN2  (__LIBGCC_TF_EPSILON__)
 #define RMINSCAL (1 / __LIBGCC_TF_EPSILON__)
 #define RMAX2  (RBIG * RMIN2)
-#endif
 
 TCtype
 __divkc3 (TFtype a, TFtype b, TFtype c, TFtype d)
index cfae81f8b5fcdbdd544eb9ecc1ea7db53f576581..345d6300b4cbb316f6d7e11c30aa0813c16123dd 100644 (file)
@@ -26,8 +26,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #include "soft-fp.h"
 #include "quad-float128.h"
 
-#define COPYSIGN(x,y) __builtin_copysignf128 (x, y)
-#define INFINITY __builtin_inff128 ()
+#ifndef __LONG_DOUBLE_IEEE128__
+#error "_mulkc3.c needs to be compiled with -mabi=ieeelongdouble."
+#endif
+
+#define COPYSIGN(x,y) __builtin_copysignl (x, y)
+#define INFINITY __builtin_infl ()
 #define isnan __builtin_isnan
 #define isinf __builtin_isinf
 
index ae0622c744c1ab2f1cec4d0220d238a234278b83..35eeccfa952e22912a6177dc181a35e10f367866 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* quad.h defines the TFtype type by:
-   typedef float TFtype __attribute__ ((mode (TF)));
-
-   This define forces it to use KFmode (aka, ieee 128-bit floating point).
-   However, when the compiler's default is changed so that long double is IEEE
-   128-bit floating point, we need to go back to using TFmode and TCmode.  */
+/* Override quad.h's definitions for 128-bit floating point type.  */
 #ifndef __LONG_DOUBLE_IEEE128__
-#define TF KF
-
-/* We also need TCtype to represent complex ieee 128-bit float for
-   __mulkc3 and __divkc3.  */
-typedef __complex float TCtype __attribute__ ((mode (KC)));
+#define TFtype _Float128               /* long double is IBM.  */
+#define TCtype _Complex _Float128
 
 #else
-typedef __complex float TCtype __attribute__ ((mode (TC)));
+#define TFtype long double             /* long double is IEEE.  */
+#define TCtype _Complex long double
 #endif
 
 /* Force the use of the VSX instruction set.  */
@@ -100,8 +93,11 @@ extern UTItype_ppc __fixunskfti_sw (TFtype);
 #endif
 extern IBM128_TYPE __extendkftf2_sw (TFtype);
 extern TFtype __trunctfkf2_sw (IBM128_TYPE);
+
+#ifdef __LONG_DOUBLE_IEEE128__
 extern TCtype __mulkc3_sw (TFtype, TFtype, TFtype, TFtype);
 extern TCtype __divkc3_sw (TFtype, TFtype, TFtype, TFtype);
+#endif
 
 #ifdef _ARCH_PPC64
 extern TItype_ppc __fixkfti (TFtype);
@@ -146,8 +142,11 @@ extern UTItype_ppc __fixunskfti_hw (TFtype);
 #endif
 extern IBM128_TYPE __extendkftf2_hw (TFtype);
 extern TFtype __trunctfkf2_hw (IBM128_TYPE);
+
+#ifdef __LONG_DOUBLE_IEEE128__
 extern TCtype __mulkc3_hw (TFtype, TFtype, TFtype, TFtype);
 extern TCtype __divkc3_hw (TFtype, TFtype, TFtype, TFtype);
+#endif
 
 /* Ifunc function declarations, to automatically switch between software
    emulation and hardware support.  */
@@ -188,8 +187,10 @@ extern IBM128_TYPE __extendkftf2 (TFtype);
 extern TFtype __trunctfkf2 (IBM128_TYPE);
 
 /* Complex __float128 built on __float128 interfaces.  */
+#ifdef __LONG_DOUBLE_IEEE128__
 extern TCtype __mulkc3 (TFtype, TFtype, TFtype, TFtype);
 extern TCtype __divkc3 (TFtype, TFtype, TFtype, TFtype);
+#endif
 
 /* Convert IEEE 128-bit floating point to/from string.  We explicitly use
    _Float128 instead of TFmode because _strtokf and _strfromkf must be compiled
index fc24ac34502bc0fd6024c4f03614bccae650e979..6a249877c7ae046421c3eff72aa288592632310c 100644 (file)
@@ -156,9 +156,13 @@ typedef            float XFtype    __attribute__ ((mode (XF)));
 typedef _Complex float XCtype  __attribute__ ((mode (XC)));
 #endif
 #if LIBGCC2_HAS_TF_MODE
+#ifndef TFtype
 typedef                float TFtype    __attribute__ ((mode (TF)));
+#endif
+#ifndef TCtype
 typedef _Complex float TCtype  __attribute__ ((mode (TC)));
 #endif
+#endif
 
 typedef int cmp_return_type __attribute__((mode (__libgcc_cmp_return__)));
 typedef int shift_count_type __attribute__((mode (__libgcc_shift_count__)));
index 3889bb44f1fdc17fa122fc827144c8a0027ca9b7..71f87d36ba9801ac0aabc1d87cb947a413b5a9fc 100644 (file)
@@ -65,7 +65,9 @@
 #define _FP_HIGHBIT_DW_Q       \
   ((_FP_W_TYPE) 1 << (_FP_WFRACBITS_DW_Q - 1) % _FP_W_TYPE_SIZE)
 
+#ifndef TFtype
 typedef float TFtype __attribute__ ((mode (TF)));
+#endif
 
 #if _FP_W_TYPE_SIZE < 64
 
This page took 0.069124 seconds and 5 git commands to generate.