[gcc(refs/users/meissner/heads/work097)] Revert patch.

Michael Meissner meissner@gcc.gnu.org
Wed Aug 10 05:33:58 GMT 2022


https://gcc.gnu.org/g:5ea487122f4f86eda46e67fa738bb359039ac11c

commit 5ea487122f4f86eda46e67fa738bb359039ac11c
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Wed Aug 10 01:32:00 2022 -0400

    Revert patch.
    
    2022-08-09   Michael Meissner  <meissner@linux.ibm.com>
    
    gcc/
    
            Revert patch.
            * config/rs6000/rs6000-builtin.cc (rs6000_type_string): Use
            float128_type_node, not ieee128_float_type_mode.
            (rs6000_init_builtins): Always use the _Float128 type for the __float128
            keyword.  Do not use the long double type.
            * config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Use
            float128_type_node, not ieee128_float_type_mode.  Simplify if
            statements.
            (rs6000_cpu_cpp_builtins): Delete ieee128_float_type_mode.
            * config/rs6000/rs6000.cc (rs6000_libgcc_floating_mode_supported_p):
            Always use KFmode for _Float128 and __float128.
            (rs6000_floatn_mode): Likewise.
            (rs6000_c_mode_for_suffix): Always use KFmode for _Float128 and
            __float128.  Add 'w' and 'W' suffix for __ibm128 constants.
            * config/rs6000/rs6000.h (RS6000_BTI_ieee128_float): Delete.
            (ieee128_float_type_node): Likewise.
            * ChangeLog.meissner: Update.

Diff:
---
 gcc/ChangeLog.meissner              | 35 -----------------------------------
 gcc/config/rs6000/rs6000-builtin.cc | 12 +++++++++---
 gcc/config/rs6000/rs6000-c.cc       | 16 +++++++---------
 gcc/config/rs6000/rs6000.cc         | 36 ++++++++++++++++++++++++------------
 gcc/config/rs6000/rs6000.h          |  2 ++
 5 files changed, 42 insertions(+), 59 deletions(-)

diff --git a/gcc/ChangeLog.meissner b/gcc/ChangeLog.meissner
index d660cbf6974..4bc6bdb00a9 100644
--- a/gcc/ChangeLog.meissner
+++ b/gcc/ChangeLog.meissner
@@ -1,38 +1,3 @@
-==================== work097, patch003
-
-Use _Float128 type for __float128.
-
-In the past if the long double type was IEEE 128-bit, the __float128 type would
-use the long double type, and TFmode would be used for the mode for both
-_Float128 and long double types.
-
-This patch always uses the _Float128 type for __float128, and it always uses
-KFmode for the mode.  Right now, a similar change for __ibm128 has not been
-made.
-
-In making these changes, I noticed that there was an internal tree for holding
-the __float128 type.  This code removes that internal tree variable.
-
-2022-08-09   Michael Meissner  <meissner@linux.ibm.com>
-
-gcc/
-
-	* config/rs6000/rs6000-builtin.cc (rs6000_type_string): Use
-	float128_type_node, not ieee128_float_type_mode.
-	(rs6000_init_builtins): Always use the _Float128 type for the __float128
-	keyword.  Do not use the long double type.
-	* config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Use
-	float128_type_node, not ieee128_float_type_mode.  Simplify if
-	statements.
-	(rs6000_cpu_cpp_builtins): Delete ieee128_float_type_mode.
-	* config/rs6000/rs6000.cc (rs6000_libgcc_floating_mode_supported_p):
-	Always use KFmode for _Float128 and __float128.
-	(rs6000_floatn_mode): Likewise.
-	(rs6000_c_mode_for_suffix): Always use KFmode for _Float128 and
-	__float128.  Add 'w' and 'W' suffix for __ibm128 constants.
-	* config/rs6000/rs6000.h (RS6000_BTI_ieee128_float): Delete.
-	(ieee128_float_type_node): Likewise.
-
 ==================== work097, patch002
 
 Rework 128-bit complex multiply and divide.
diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc
index c53a2d32a6f..755a6b95db0 100644
--- a/gcc/config/rs6000/rs6000-builtin.cc
+++ b/gcc/config/rs6000/rs6000-builtin.cc
@@ -434,7 +434,7 @@ const char *rs6000_type_string (tree type_node)
     return "ss";
   else if (type_node == ibm128_float_type_node)
     return "__ibm128";
-  else if (type_node == float128_type_node)
+  else if (type_node == ieee128_float_type_node)
     return "__ieee128";
   else if (type_node == opaque_V4SI_type_node)
     return "opaque";
@@ -733,10 +733,16 @@ rs6000_init_builtins (void)
 
   if (TARGET_FLOAT128_TYPE)
     {
-      t = build_qualified_type (float128_type_node, TYPE_QUAL_CONST);
-      lang_hooks.types.register_builtin_type (float128_type_node,
+      if (TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128)
+	ieee128_float_type_node = long_double_type_node;
+      else
+	ieee128_float_type_node = float128_type_node;
+      t = build_qualified_type (ieee128_float_type_node, TYPE_QUAL_CONST);
+      lang_hooks.types.register_builtin_type (ieee128_float_type_node,
 					      "__ieee128");
     }
+  else
+    ieee128_float_type_node = NULL_TREE;
 
   /* Vector pair and vector quad support.  */
   vector_pair_type_node = make_node (OPAQUE_TYPE);
diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc
index d0c4e0fca87..11de8389fd6 100644
--- a/gcc/config/rs6000/rs6000-c.cc
+++ b/gcc/config/rs6000/rs6000-c.cc
@@ -578,15 +578,13 @@ rs6000_target_modify_macros (bool define_p, HOST_WIDE_INT flags)
     {
       rs6000_define_or_undefine_macro (define_p, "__FLOAT128__");
       if (define_p)
-	{
-	  rs6000_define_or_undefine_macro (true, "__float128=__ieee128");
-	  rs6000_define_or_undefine_macro (true, "__SIZEOF_FLOAT128__=16");
-	}
+	rs6000_define_or_undefine_macro (true, "__float128=__ieee128");
       else
-	{
-	  rs6000_define_or_undefine_macro (false, "__float128");
-	  rs6000_define_or_undefine_macro (false, "__SIZEOF_FLOAT128__");
-	}
+	rs6000_define_or_undefine_macro (false, "__float128");
+      if (ieee128_float_type_node && define_p)
+	rs6000_define_or_undefine_macro (true, "__SIZEOF_FLOAT128__=16");
+      else
+	rs6000_define_or_undefine_macro (false, "__SIZEOF_FLOAT128__");
     }
   /* OPTION_MASK_FLOAT128_HARDWARE can be turned on if -mcpu=power9 is used or
      via the target attribute/pragma.  */
@@ -626,7 +624,7 @@ rs6000_cpu_cpp_builtins (cpp_reader *pfile)
     builtin_define ("__FLOAT128_TYPE__");
   if (ibm128_float_type_node)
     builtin_define ("__SIZEOF_IBM128__=16");
-  if (TARGET_FLOAT128_KEYWORD)
+  if (ieee128_float_type_node)
     builtin_define ("__SIZEOF_IEEE128__=16");
 #ifdef TARGET_LIBC_PROVIDES_HWCAP_IN_TCB
   builtin_define ("__BUILTIN_CPU_SUPPORTS__");
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index c63c1ac173c..eddf8c8afe7 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -23678,14 +23678,14 @@ rs6000_eh_return_filter_mode (void)
   return TARGET_32BIT ? SImode : word_mode;
 }
 
-/* Target hook for translate_mode_attribute.  In the past, we used to convert
-   KFmode and KCmode to TFmode and TCmode if long double is IEEE 128-bit.  We
-   no longer do this because we always use the standard float128_type_node for
-   __float128, and we no longer try to use the long double type.  */
+/* Target hook for translate_mode_attribute.  */
 static machine_mode
 rs6000_translate_mode_attribute (machine_mode mode)
 {
-  if (FLOAT128_IBM_P (mode) && ibm128_float_type_node == long_double_type_node)
+  if ((FLOAT128_IEEE_P (mode)
+       && ieee128_float_type_node == long_double_type_node)
+      || (FLOAT128_IBM_P (mode)
+	  && ibm128_float_type_node == long_double_type_node))
     return COMPLEX_MODE_P (mode) ? E_TCmode : E_TFmode;
   return mode;
 }
@@ -23724,8 +23724,13 @@ rs6000_libgcc_floating_mode_supported_p (scalar_float_mode mode)
     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;
+      return TARGET_FLOAT128_TYPE && !TARGET_IEEEQUAD;
 
     default:
       return false;
@@ -23759,7 +23764,7 @@ rs6000_floatn_mode (int n, bool extended)
 
 	case 64:
 	  if (TARGET_FLOAT128_TYPE)
-	    return KFmode;
+	    return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode;
 	  else
 	    return opt_scalar_float_mode ();
 
@@ -23783,7 +23788,7 @@ rs6000_floatn_mode (int n, bool extended)
 
 	case 128:
 	  if (TARGET_FLOAT128_TYPE)
-	    return KFmode;
+	    return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode;
 	  else
 	    return opt_scalar_float_mode ();
 
@@ -23798,11 +23803,18 @@ rs6000_floatn_mode (int n, bool extended)
 static machine_mode
 rs6000_c_mode_for_suffix (char suffix)
 {
-  if (TARGET_FLOAT128_TYPE && (suffix == 'q' || suffix == 'Q'))
-    return KFmode;
+  if (TARGET_FLOAT128_TYPE)
+    {
+      if (suffix == 'q' || suffix == 'Q')
+	return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode;
 
-  if (TARGET_IBM128 && (suffix == 'w' || suffix == 'W'))
-    return FLOAT128_IBM_P (TFmode) ? TFmode : IFmode;
+      /* At the moment, we are not defining a suffix for IBM extended double.
+	 If/when the default for -mabi=ieeelongdouble is changed, and we want
+	 to support __ibm128 constants in legacy library code, we may need to
+	 re-evalaute this decision.  Currently, c-lex.cc only supports 'w' and
+	 'q' as machine dependent suffixes.  The x86_64 port uses 'w' for
+	 __float80 constants.  */
+    }
 
   return VOIDmode;
 }
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 4a1f6875747..f58f5f3f355 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -2268,6 +2268,7 @@ enum rs6000_builtin_type_index
   RS6000_BTI_dfloat64,		 /* dfloat64_type_node */
   RS6000_BTI_dfloat128,		 /* dfloat128_type_node */
   RS6000_BTI_void,	         /* void_type_node */
+  RS6000_BTI_ieee128_float,	 /* ieee 128-bit floating point */
   RS6000_BTI_ibm128_float,	 /* IBM 128-bit floating point */
   RS6000_BTI_const_str,		 /* pointer to const char * */
   RS6000_BTI_vector_pair,	 /* unsigned 256-bit types (vector pair).  */
@@ -2362,6 +2363,7 @@ enum rs6000_builtin_type_index
 #define dfloat64_type_internal_node	 (rs6000_builtin_types[RS6000_BTI_dfloat64])
 #define dfloat128_type_internal_node	 (rs6000_builtin_types[RS6000_BTI_dfloat128])
 #define void_type_internal_node		 (rs6000_builtin_types[RS6000_BTI_void])
+#define ieee128_float_type_node		 (rs6000_builtin_types[RS6000_BTI_ieee128_float])
 #define ibm128_float_type_node		 (rs6000_builtin_types[RS6000_BTI_ibm128_float])
 #define const_str_type_node		 (rs6000_builtin_types[RS6000_BTI_const_str])
 #define vector_pair_type_node		 (rs6000_builtin_types[RS6000_BTI_vector_pair])


More information about the Gcc-cvs mailing list