public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work105y)] PR target/107299: Update IEEE 128-bit types for PowerPC libgcc
@ 2023-01-12 18:25 Michael Meissner
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Meissner @ 2023-01-12 18:25 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:22aa4c6073d8c553cfcd85cd072463cc3a404762

commit 22aa4c6073d8c553cfcd85cd072463cc3a404762
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Thu Jan 12 13:24:48 2023 -0500

    PR target/107299: Update IEEE 128-bit types for PowerPC libgcc
    
    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.
    
    I changed the libgcc build so that the IEEE 128-bit support is now compiled
    with -mabi=ieeelongdouble.  For the _mulkc3 and _divkc3, I explicitly use long
    double and long double _Complex to avoid type mismatch errors.
    
    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.
    
    2023-01-12   Michael Meissner  <meissner@linux.ibm.com>
    
            PR target/107299
            * config/rs6000/_divkc3.c (toplevel): Add assertion for building with
            -mabi=ieeelongdouble.  Remove code supporting -mabi=ibmlongdouble.
            (COPYSIGN): Use the long double built-in.
            (INFINITY): Likewise.
            (FABS): Likewise.
            (_divkc3): Use long double and _Complex long double types.
            * config/rs6000/_mulkc3.c (toplevel): Add assertion for building with
            -mabi=ieeelongdouble.
            (COPYSIGN): Use the long double built-in.
            (INFINITY): Likewise.
            (_mulkc3): Use long double and _Complex long double types.
            * config/rs6000/quad-float128.h (TF): Delete definition.
            (TFtype): Define to be _Float128 or long double.
            (TCtype): Define to be _Complex _Float128 or _Complex long double.
            (__mulkc3_sw): Only declare function if -mabi=ieeelongdouble.
            (__divkc3_sw): Likewise.
            (__mulkc3_hw): Likewise.
            (__divkc3_hw): Likewise.
            (__mulkc3): Likewise.
            (__divkc3): Likewise.
            * config/rs6000/t-float128 (FP128_CFLAGS_SW): Use -mabi=ieeelongdouble.
            * config/rs6000/t-float128-hw (FP128_CFLAGS_HW): Likewise.
            * libgcc2.h (TFtype): Allow MD code to override definition.
            (TCtype): Likewise.
            * soft-fp/quad.h (TFtype): Likewise.

Diff:
---
 libgcc/config/rs6000/_divkc3.c        | 26 +++++++++-------------
 libgcc/config/rs6000/_mulkc3.c        | 16 ++++++++-----
 libgcc/config/rs6000/float128-ifunc.c | 10 +++++++--
 libgcc/config/rs6000/quad-float128.h  | 42 ++++++++++++++++-------------------
 libgcc/config/rs6000/t-float128       |  1 +
 libgcc/config/rs6000/t-float128-hw    |  1 +
 libgcc/libgcc2.h                      |  5 +++++
 libgcc/soft-fp/quad.h                 |  2 ++
 8 files changed, 57 insertions(+), 46 deletions(-)

diff --git a/libgcc/config/rs6000/_divkc3.c b/libgcc/config/rs6000/_divkc3.c
index 59ab2137d1d..255886fae12 100644
--- a/libgcc/config/rs6000/_divkc3.c
+++ b/libgcc/config/rs6000/_divkc3.c
@@ -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 must be compiled with -mabi=ieeelongdouble"
+#endif
+
+#define COPYSIGN(x,y) __builtin_copysignl (x, y)
+#define INFINITY __builtin_infl ()
+#define FABS(x) __builtin_fabsl (x)
 #define isnan __builtin_isnan
 #define isinf __builtin_isinf
 #define isfinite __builtin_isfinite
@@ -37,25 +41,17 @@ 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)
+_Complex long double
+__divkc3 (long double a, long double b, long double c, long double d)
 {
-  TFtype denom, ratio, x, y;
-  TCtype res;
+  long double denom, ratio, x, y;
+  _Complex long double res;
 
   /* long double has significant potential underflow/overflow errors that
      can be greatly reduced with a limited number of tests and adjustments.
diff --git a/libgcc/config/rs6000/_mulkc3.c b/libgcc/config/rs6000/_mulkc3.c
index cfae81f8b5f..52b2aea2459 100644
--- a/libgcc/config/rs6000/_mulkc3.c
+++ b/libgcc/config/rs6000/_mulkc3.c
@@ -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 must 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
 
@@ -35,11 +39,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define __mulkc3 __mulkc3_sw
 #endif
 
-TCtype
-__mulkc3 (TFtype a, TFtype b, TFtype c, TFtype d)
+_Complex long double
+__mulkc3 (long double a, long double b, long double c, long double d)
 {
-  TFtype ac, bd, ad, bc, x, y;
-  TCtype res;
+  long double ac, bd, ad, bc, x, y;
+  _Complex long double res;
 
   ac = a * c;
   bd = b * d;
diff --git a/libgcc/config/rs6000/float128-ifunc.c b/libgcc/config/rs6000/float128-ifunc.c
index 73cbca2fc9a..6a680a85baf 100644
--- a/libgcc/config/rs6000/float128-ifunc.c
+++ b/libgcc/config/rs6000/float128-ifunc.c
@@ -45,6 +45,10 @@
 #error "This module must not be compiled with IEEE 128-bit hardware support"
 #endif
 
+#ifndef __LONG_DOUBLE_IEEE128__
+#error "float128-ifunc must be compiled with -mabi=ieeelongdouble"
+#endif
+
 #define SW_OR_HW(SW, HW) (__builtin_cpu_supports ("ieee128") ? HW : SW)
 #ifdef FLOAT128_HW_INSNS_ISA3_1
 #define SW_OR_HW_ISA3_1(SW, HW) (__builtin_cpu_supports ("arch_3_1") ? HW : SW)
@@ -354,8 +358,10 @@ IBM128_TYPE __extendkftf2 (TFtype)
 TFtype __trunctfkf2 (IBM128_TYPE)
   __attribute__ ((__ifunc__ ("__trunctfkf2_resolve")));
 
-TCtype __mulkc3 (TFtype, TFtype, TFtype, TFtype)
+_Complex long double __mulkc3 (long double, long double,
+			       long double, long double)
   __attribute__ ((__ifunc__ ("__mulkc3_resolve")));
 
-TCtype __divkc3 (TFtype, TFtype, TFtype, TFtype)
+_Complex long double __divkc3 (long double, long double,
+			       long double, long double)
   __attribute__ ((__ifunc__ ("__divkc3_resolve")));
diff --git a/libgcc/config/rs6000/quad-float128.h b/libgcc/config/rs6000/quad-float128.h
index ae0622c744c..ce6df3f219d 100644
--- a/libgcc/config/rs6000/quad-float128.h
+++ b/libgcc/config/rs6000/quad-float128.h
@@ -27,22 +27,9 @@
    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.  */
-#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)));
-
-#else
-typedef __complex float TCtype __attribute__ ((mode (TC)));
-#endif
+/* Override quad.h's definitions for 128-bit floating point type.  */
+#define TFtype _Float128
+#define TCtype _Complex _Float128
 
 /* Force the use of the VSX instruction set.  */
 #if defined(_ARCH_PPC) && (!defined(__VSX__) || !defined(__FLOAT128__))
@@ -100,8 +87,6 @@ extern UTItype_ppc __fixunskfti_sw (TFtype);
 #endif
 extern IBM128_TYPE __extendkftf2_sw (TFtype);
 extern TFtype __trunctfkf2_sw (IBM128_TYPE);
-extern TCtype __mulkc3_sw (TFtype, TFtype, TFtype, TFtype);
-extern TCtype __divkc3_sw (TFtype, TFtype, TFtype, TFtype);
 
 #ifdef _ARCH_PPC64
 extern TItype_ppc __fixkfti (TFtype);
@@ -146,8 +131,6 @@ extern UTItype_ppc __fixunskfti_hw (TFtype);
 #endif
 extern IBM128_TYPE __extendkftf2_hw (TFtype);
 extern TFtype __trunctfkf2_hw (IBM128_TYPE);
-extern TCtype __mulkc3_hw (TFtype, TFtype, TFtype, TFtype);
-extern TCtype __divkc3_hw (TFtype, TFtype, TFtype, TFtype);
 
 /* Ifunc function declarations, to automatically switch between software
    emulation and hardware support.  */
@@ -187,9 +170,22 @@ extern UTItype_ppc __fixunskfti (TFtype);
 extern IBM128_TYPE __extendkftf2 (TFtype);
 extern TFtype __trunctfkf2 (IBM128_TYPE);
 
-/* Complex __float128 built on __float128 interfaces.  */
-extern TCtype __mulkc3 (TFtype, TFtype, TFtype, TFtype);
-extern TCtype __divkc3 (TFtype, TFtype, TFtype, TFtype);
+#ifdef __LONG_DOUBLE_IEEE128__
+/* Only declare complex multiply/divide support functions if long double is
+   IEEE 128-bit.  Otherwise the compiler will issue type mismatch warnings.  */
+extern _Complex long double __mulkc3_sw (long double, long double,
+					 long double, long double);
+extern _Complex long double __divkc3_sw (long double, long double,
+					 long double, long double);
+extern _Complex long double __mulkc3_hw (long double, long double,
+					 long double, long double);
+extern _Complex long double __divkc3_hw (long double, long double,
+					 long double, long double);
+extern _Complex long double __mulkc3 (long double, long double,
+				      long double, long double);
+extern _Complex long double __divkc3 (long double, long double,
+				      long double, long double);
+#endif
 
 /* Convert IEEE 128-bit floating point to/from string.  We explicitly use
    _Float128 instead of TFmode because _strtokf and _strfromkf must be compiled
diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128
index b09b5664af0..f46961dbc82 100644
--- a/libgcc/config/rs6000/t-float128
+++ b/libgcc/config/rs6000/t-float128
@@ -76,6 +76,7 @@ fp128_includes		= $(srcdir)/soft-fp/double.h \
 # Build the emulator without ISA 3.0 hardware support.
 FP128_CFLAGS_SW		 = -Wno-type-limits -mvsx -mfloat128 \
 			   -mno-float128-hardware -mno-gnu-attribute \
+			   -mabi=ieeelongdouble \
 			   -I$(srcdir)/soft-fp \
 			   -I$(srcdir)/config/rs6000 \
 			   $(FLOAT128_HW_INSNS)
diff --git a/libgcc/config/rs6000/t-float128-hw b/libgcc/config/rs6000/t-float128-hw
index d64ca4dd694..3450e0dfa39 100644
--- a/libgcc/config/rs6000/t-float128-hw
+++ b/libgcc/config/rs6000/t-float128-hw
@@ -26,6 +26,7 @@ fp128_sed_hw		= -hw
 FP128_CFLAGS_HW		 = -Wno-type-limits -mvsx -mfloat128 \
 			   -mpower8-vector -mpower9-vector \
 			   -mfloat128-hardware -mno-gnu-attribute \
+			   -mabi=ieeelongdouble -Wno-psabi \
 			   -I$(srcdir)/soft-fp \
 			   -I$(srcdir)/config/rs6000 \
 			   $(FLOAT128_HW_INSNS)
diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h
index fc24ac34502..a39c365d904 100644
--- a/libgcc/libgcc2.h
+++ b/libgcc/libgcc2.h
@@ -156,9 +156,14 @@ typedef		float XFtype	__attribute__ ((mode (XF)));
 typedef _Complex float XCtype	__attribute__ ((mode (XC)));
 #endif
 #if LIBGCC2_HAS_TF_MODE
+/* PowerPC would like to override this to be _Float128.  */
+#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__)));
diff --git a/libgcc/soft-fp/quad.h b/libgcc/soft-fp/quad.h
index 3889bb44f1f..71f87d36ba9 100644
--- a/libgcc/soft-fp/quad.h
+++ b/libgcc/soft-fp/quad.h
@@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/meissner/heads/work105y)] PR target/107299: Update IEEE 128-bit types for PowerPC libgcc
@ 2023-01-12 18:42 Michael Meissner
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Meissner @ 2023-01-12 18:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:66c1bf485041e18014ba85ebde082d6cf2b83b36

commit 66c1bf485041e18014ba85ebde082d6cf2b83b36
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Thu Jan 12 13:42:18 2023 -0500

    PR target/107299: Update IEEE 128-bit types for PowerPC libgcc
    
    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.
    
    I changed the libgcc build so that the IEEE 128-bit support is now compiled
    with -mabi=ieeelongdouble.  For the _mulkc3 and _divkc3, I explicitly use long
    double and long double _Complex to avoid type mismatch errors.
    
    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.
    
    2023-01-12   Michael Meissner  <meissner@linux.ibm.com>
    
            PR target/107299
            * config/rs6000/_divkc3.c (toplevel): Add assertion for building with
            -mabi=ieeelongdouble.  Remove code supporting -mabi=ibmlongdouble.
            (COPYSIGN): Use the long double built-in.
            (INFINITY): Likewise.
            (FABS): Likewise.
            * config/rs6000/_mulkc3.c (toplevel): Add assertion for building with
            -mabi=ieeelongdouble.
            (COPYSIGN): Use the long double built-in.
            (INFINITY): Likewise.
            * config/rs6000/float128-ifunc.c (toplevel): Add assertion for building
            with -mabi=ieeelongdouble.
            * config/rs6000/quad-float128.h (TF): Delete definition.
            (TFtype): Define to be _Float128 or long double.
            (TCtype): Define to be _Complex _Float128 or _Complex long double.
            (__mulkc3_sw): Only declare function if -mabi=ieeelongdouble.
            (__divkc3_sw): Likewise.
            (__mulkc3_hw): Likewise.
            (__divkc3_hw): Likewise.
            (__mulkc3): Likewise.
            (__divkc3): Likewise.
            * config/rs6000/t-float128 (FP128_CFLAGS_SW): Add -mabi=ieeelongdouble.
            * config/rs6000/t-float128-hw (FP128_CFLAGS_HW): Likewise.
            * libgcc2.h (TFtype): Allow MD code to override definition.
            (TCtype): Likewise.
            * soft-fp/quad.h (TFtype): Likewise.

Diff:
---
 libgcc/config/rs6000/_divkc3.c        | 18 +++++++-----------
 libgcc/config/rs6000/_mulkc3.c        |  8 ++++++--
 libgcc/config/rs6000/float128-ifunc.c |  4 ++++
 libgcc/config/rs6000/quad-float128.h  | 30 +++++++++++++-----------------
 libgcc/config/rs6000/t-float128       |  1 +
 libgcc/config/rs6000/t-float128-hw    |  1 +
 libgcc/libgcc2.h                      |  5 +++++
 libgcc/soft-fp/quad.h                 |  2 ++
 8 files changed, 39 insertions(+), 30 deletions(-)

diff --git a/libgcc/config/rs6000/_divkc3.c b/libgcc/config/rs6000/_divkc3.c
index 59ab2137d1d..b721543ebef 100644
--- a/libgcc/config/rs6000/_divkc3.c
+++ b/libgcc/config/rs6000/_divkc3.c
@@ -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 must be compiled with -mabi=ieeelongdouble"
+#endif
+
+#define COPYSIGN(x,y) __builtin_copysignl (x, y)
+#define INFINITY __builtin_infl ()
+#define FABS(x) __builtin_fabsl (x)
 #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)
diff --git a/libgcc/config/rs6000/_mulkc3.c b/libgcc/config/rs6000/_mulkc3.c
index cfae81f8b5f..d5fb649888e 100644
--- a/libgcc/config/rs6000/_mulkc3.c
+++ b/libgcc/config/rs6000/_mulkc3.c
@@ -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 must 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
 
diff --git a/libgcc/config/rs6000/float128-ifunc.c b/libgcc/config/rs6000/float128-ifunc.c
index 73cbca2fc9a..1466c733039 100644
--- a/libgcc/config/rs6000/float128-ifunc.c
+++ b/libgcc/config/rs6000/float128-ifunc.c
@@ -45,6 +45,10 @@
 #error "This module must not be compiled with IEEE 128-bit hardware support"
 #endif
 
+#ifndef __LONG_DOUBLE_IEEE128__
+#error "float128-ifunc.c needs to be compiled with -mabi=ieeelongdouble."
+#endif
+
 #define SW_OR_HW(SW, HW) (__builtin_cpu_supports ("ieee128") ? HW : SW)
 #ifdef FLOAT128_HW_INSNS_ISA3_1
 #define SW_OR_HW_ISA3_1(SW, HW) (__builtin_cpu_supports ("arch_3_1") ? HW : SW)
diff --git a/libgcc/config/rs6000/quad-float128.h b/libgcc/config/rs6000/quad-float128.h
index ae0622c744c..c98c445d16b 100644
--- a/libgcc/config/rs6000/quad-float128.h
+++ b/libgcc/config/rs6000/quad-float128.h
@@ -27,21 +27,14 @@
    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
+#define TCtype _Complex _Float128
 
 #else
-typedef __complex float TCtype __attribute__ ((mode (TC)));
+#define TFtype long double
+#define TCtype _Complex long double
 #endif
 
 /* Force the use of the VSX instruction set.  */
@@ -100,8 +93,6 @@ extern UTItype_ppc __fixunskfti_sw (TFtype);
 #endif
 extern IBM128_TYPE __extendkftf2_sw (TFtype);
 extern TFtype __trunctfkf2_sw (IBM128_TYPE);
-extern TCtype __mulkc3_sw (TFtype, TFtype, TFtype, TFtype);
-extern TCtype __divkc3_sw (TFtype, TFtype, TFtype, TFtype);
 
 #ifdef _ARCH_PPC64
 extern TItype_ppc __fixkfti (TFtype);
@@ -146,8 +137,6 @@ extern UTItype_ppc __fixunskfti_hw (TFtype);
 #endif
 extern IBM128_TYPE __extendkftf2_hw (TFtype);
 extern TFtype __trunctfkf2_hw (IBM128_TYPE);
-extern TCtype __mulkc3_hw (TFtype, TFtype, TFtype, TFtype);
-extern TCtype __divkc3_hw (TFtype, TFtype, TFtype, TFtype);
 
 /* Ifunc function declarations, to automatically switch between software
    emulation and hardware support.  */
@@ -187,9 +176,16 @@ extern UTItype_ppc __fixunskfti (TFtype);
 extern IBM128_TYPE __extendkftf2 (TFtype);
 extern TFtype __trunctfkf2 (IBM128_TYPE);
 
-/* Complex __float128 built on __float128 interfaces.  */
+#ifdef __LONG_DOUBLE_IEEE128__
+/* Only declare complex multiply/divide support functions if long double is
+   IEEE 128-bit.  Otherwise the compiler will issue type mismatch warnings.  */
+extern TCtype __mulkc3_sw (TFtype, TFtype, TFtype, TFtype);
+extern TCtype __divkc3_sw (TFtype, TFtype, TFtype, TFtype);
+extern TCtype __mulkc3_hw (TFtype, TFtype, TFtype, TFtype);
+extern TCtype __divkc3_hw (TFtype, TFtype, TFtype, TFtype);
 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
diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128
index b09b5664af0..f46961dbc82 100644
--- a/libgcc/config/rs6000/t-float128
+++ b/libgcc/config/rs6000/t-float128
@@ -76,6 +76,7 @@ fp128_includes		= $(srcdir)/soft-fp/double.h \
 # Build the emulator without ISA 3.0 hardware support.
 FP128_CFLAGS_SW		 = -Wno-type-limits -mvsx -mfloat128 \
 			   -mno-float128-hardware -mno-gnu-attribute \
+			   -mabi=ieeelongdouble \
 			   -I$(srcdir)/soft-fp \
 			   -I$(srcdir)/config/rs6000 \
 			   $(FLOAT128_HW_INSNS)
diff --git a/libgcc/config/rs6000/t-float128-hw b/libgcc/config/rs6000/t-float128-hw
index d64ca4dd694..3450e0dfa39 100644
--- a/libgcc/config/rs6000/t-float128-hw
+++ b/libgcc/config/rs6000/t-float128-hw
@@ -26,6 +26,7 @@ fp128_sed_hw		= -hw
 FP128_CFLAGS_HW		 = -Wno-type-limits -mvsx -mfloat128 \
 			   -mpower8-vector -mpower9-vector \
 			   -mfloat128-hardware -mno-gnu-attribute \
+			   -mabi=ieeelongdouble -Wno-psabi \
 			   -I$(srcdir)/soft-fp \
 			   -I$(srcdir)/config/rs6000 \
 			   $(FLOAT128_HW_INSNS)
diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h
index fc24ac34502..a39c365d904 100644
--- a/libgcc/libgcc2.h
+++ b/libgcc/libgcc2.h
@@ -156,9 +156,14 @@ typedef		float XFtype	__attribute__ ((mode (XF)));
 typedef _Complex float XCtype	__attribute__ ((mode (XC)));
 #endif
 #if LIBGCC2_HAS_TF_MODE
+/* PowerPC would like to override this to be _Float128.  */
+#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__)));
diff --git a/libgcc/soft-fp/quad.h b/libgcc/soft-fp/quad.h
index 3889bb44f1f..71f87d36ba9 100644
--- a/libgcc/soft-fp/quad.h
+++ b/libgcc/soft-fp/quad.h
@@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-12 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-12 18:25 [gcc(refs/users/meissner/heads/work105y)] PR target/107299: Update IEEE 128-bit types for PowerPC libgcc Michael Meissner
2023-01-12 18:42 Michael Meissner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).