diff mbox series

rs6000: Fix mangling for 128-bit float

Message ID 466d3b3c3002c15c4aca004af1a6c39877f0252b.1527878168.git.segher@kernel.crashing.org
State New
Headers show
Series rs6000: Fix mangling for 128-bit float | expand

Commit Message

Segher Boessenkool June 1, 2018, 6:41 p.m. UTC
This patch changes the (C++) mangling of the 128-bit float types.
IBM long double ("double-double") is mangled as "g", as before, and
IEEE 128-bit long double is mangled as "u9__ieee128".

Bootstrapped and tested on powerpc64-linux {-m32,-m64} (Power7) and
on powerpc64le-linux (Power9).  Also tested manually; testsuite
patches will follow soon.

Committing to trunk.


Segher


2018-06-01  Segher Boessenkool  <segher@kernel.crashing.org>

	* config/rs6000/rs6000.c (rs6000_mangle_type): Change the mangling of
	the 128-bit floating point types.  Fix function comment.


---
 gcc/config/rs6000/rs6000.c | 31 +++++++------------------------
 1 file changed, 7 insertions(+), 24 deletions(-)

Comments

Joseph Myers June 1, 2018, 9:33 p.m. UTC | #1
On Fri, 1 Jun 2018, Segher Boessenkool wrote:

> This patch changes the (C++) mangling of the 128-bit float types.
> IBM long double ("double-double") is mangled as "g", as before, and
> IEEE 128-bit long double is mangled as "u9__ieee128".

To be clear: given this mangling (which certainly simplifies the ABI), is 
the intent that only one type with double-double format, and only one type 
with binary128 format, will be accessible in any given C++ compilation, to 
avoid ICEs (bugs 85075 and 85518) from different types having the same 
mangling?  So __ibm128 *will* be the same type as long double when those 
have the same format, and likewise long double, __float128, __ieee128 and 
__typeof (__builtin_inff128 ()) will have the same type when they have the 
same format?

You can have the simple mangling that's compatible between different 
choices of long double, or you can have the types being consistently 
different so people can e.g. overload and write templates using them 
without worrying about the possibility that __ieee128 might or might not 
be the same type as long double depending on the compiler options, but you 
can't have both without running into problems.
Segher Boessenkool June 1, 2018, 9:49 p.m. UTC | #2
On Fri, Jun 01, 2018 at 09:33:57PM +0000, Joseph Myers wrote:
> On Fri, 1 Jun 2018, Segher Boessenkool wrote:
> 
> > This patch changes the (C++) mangling of the 128-bit float types.
> > IBM long double ("double-double") is mangled as "g", as before, and
> > IEEE 128-bit long double is mangled as "u9__ieee128".
> 
> To be clear: given this mangling (which certainly simplifies the ABI), is 
> the intent that only one type with double-double format, and only one type 
> with binary128 format, will be accessible in any given C++ compilation, to 
> avoid ICEs (bugs 85075 and 85518) from different types having the same 
> mangling?  So __ibm128 *will* be the same type as long double when those 
> have the same format, and likewise long double, __float128, __ieee128 and 
> __typeof (__builtin_inff128 ()) will have the same type when they have the 
> same format?

Yes.  (__float128 is just a #define btw.)

> You can have the simple mangling that's compatible between different 
> choices of long double, or you can have the types being consistently 
> different so people can e.g. overload and write templates using them 
> without worrying about the possibility that __ieee128 might or might not 
> be the same type as long double depending on the compiler options, but you 
> can't have both without running into problems.

Right.  But given how much this simplifies, we'll just have to bite the
bullet and get this to work properly.


Segher
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index fab8ee3..a755491 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -31983,8 +31983,9 @@  rs6000_handle_altivec_attribute (tree *node,
   return NULL_TREE;
 }
 
-/* AltiVec defines four built-in scalar types that serve as vector
-   elements; we must teach the compiler how to mangle them.  */
+/* AltiVec defines five built-in scalar types that serve as vector
+   elements; we must teach the compiler how to mangle them.  The 128-bit
+   floating point mangling is target-specific as well.  */
 
 static const char *
 rs6000_mangle_type (const_tree type)
@@ -32001,30 +32002,12 @@  rs6000_mangle_type (const_tree type)
   if (type == bool_int_type_node) return "U6__booli";
   if (type == bool_long_long_type_node) return "U6__boolx";
 
-  /* Use a unique name for __float128 rather than trying to use "e" or "g". Use
-     "g" for IBM extended double, no matter whether it is long double (using
-     -mabi=ibmlongdouble) or the distinct __ibm128 type.  */
-  if (TARGET_FLOAT128_TYPE)
-    {
-      if (type == ieee128_float_type_node)
-	return "U10__float128";
-
-      if (type == ibm128_float_type_node)
-	return "u8__ibm128";
-
-      if (TARGET_LONG_DOUBLE_128 && type == long_double_type_node)
-	return (TARGET_IEEEQUAD) ? "U10__float128" : "g";
-    }
-
-  /* Mangle IBM extended float long double as `g' (__float128) on
-     powerpc*-linux where long-double-64 previously was the default.  */
-  if (TYPE_MAIN_VARIANT (type) == long_double_type_node
-      && TARGET_ELF
-      && TARGET_LONG_DOUBLE_128
-      && !TARGET_IEEEQUAD)
+  if (SCALAR_FLOAT_TYPE_P (type) && FLOAT128_IBM_P (TYPE_MODE (type)))
     return "g";
+  if (SCALAR_FLOAT_TYPE_P (type) && FLOAT128_IEEE_P (TYPE_MODE (type)))
+    return "u9__ieee128";
 
-  /* For all other types, use normal C++ mangling.  */
+  /* For all other types, use the default mangling.  */
   return NULL;
 }