[PATCH, V2] Define KFmode constants for libgcc.

This patch defines the constants needed for libgcc for the PowerPC
specific IEEE 128-bit floating point types (KFmode).  The 4/28 changes to
libgcc need these constants defined.

We only define the KFmode constants if IEEE 128-bit floating point is
supported, but long double does not use the IEEE 128-bit format.  If long
double uses the IEEE 128-bit format, it will use TFmode and not KFmode.

With this patch, we don't have to modify _divkc3.c to use the FLT128
constants.  Instead, the -fbuilting-libgcc option will build the appropriate
__LIBGCC_KF_* macros.

I have built a bootstrap compiler on a little endian power9 system and it
finished.  Previously it had crashed in building libgcc.  I also build a
non-bootstrap compiler where the default long double format is IEEE 128-bit and
it built ok

Can I check this into the trunk for GCC 12?

gcc/
2021-04-29  Michael Meissner  <meiss...@linux.ibm.com>

        PR bootstrap/100327
        * config/rs6000/rs6000.c
        (TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P): Define.
        (rs6000_iibgcc_floating_mode_supported_p): New target hook.
---
 gcc/config/rs6000/rs6000.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index cdeb049986f..23485027d85 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -1569,6 +1569,10 @@ static const struct attribute_spec 
rs6000_attribute_table[] =
 #undef TARGET_SCALAR_MODE_SUPPORTED_P
 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
 
+#undef TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P
+#define TARGET_LIBGCC_FLOATING_MODE_SUPPORTED_P \
+  rs6000_libgccc_floating_mode_supported_p
+
 #undef TARGET_VECTOR_MODE_SUPPORTED_P
 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
 
@@ -24089,6 +24093,31 @@ rs6000_scalar_mode_supported_p (scalar_mode mode)
     return default_scalar_mode_supported_p (mode);
 }
 
+/* Target hook for libgcc_floating_mode_supported_p.  */
+
+static bool
+rs6000_libgccc_floating_mode_supported_p (scalar_float_mode mode)
+{
+  switch (mode)
+    {
+    case E_SFmode:
+    case E_DFmode:
+    case E_TFmode:
+      return true;
+
+      /* We only return true for KFmode if IEEE 128-bit types are supported, 
and
+        if long double does not use the IEEE 128-bit format.  If long double
+        uses the IEEE 128-bit format, it will use TFmode and not KFmode.
+        Because the code will not use KFmode in that case, there will be aborts
+        because it can't find KFmode in the Floatn types.  */
+    case E_KFmode:
+      return TARGET_FLOAT128_TYPE && !TARGET_IEEEQUAD;
+
+    default:
+      return false;
+    }
+}
+
 /* Target hook for vector_mode_supported_p.  */
 static bool
 rs6000_vector_mode_supported_p (machine_mode mode)
-- 
2.22.0


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797

Reply via email to