Define __SIZEOF_FLOAT128__ and __SIZEOF_IBM128__.
authorMichael Meissner <meissner@linux.ibm.com>
Thu, 17 Feb 2022 03:00:00 +0000 (22:00 -0500)
committerMichael Meissner <meissner@linux.ibm.com>
Thu, 17 Feb 2022 03:00:00 +0000 (22:00 -0500)
Define the sizes of the PowerPC specific types __float128 and __ibm128 if those
types are enabled.

This patch will define __SIZEOF_IBM128__ and __SIZEOF_FLOAT128__ if their
respective types are created in the compiler.  Currently, this means both of
these will be defined if float128 support is enabled.  But at some point in
the future, __ibm128 could be enabled without enabling float128 support and
__SIZEOF_IBM128__ would be defined.

2022-02-16  Michael Meissner  <meissner@the-meissners.org>

gcc/
PR target/99708
* config/rs6000/rs6000-c.cc (rs6000_cpu_cpp_builtins): Define
__SIZEOF_IBM128__ if the IBM 128-bit long double type is created.
Define __SIZEOF_FLOAT128__ if the IEEE 128-bit floating point type
is created.

gcc/testsuite/
PR target/99708
* gcc.target/powerpc/pr99708.c: New test.

gcc/config/rs6000/rs6000-c.cc
gcc/testsuite/gcc.target/powerpc/pr99708.c [new file with mode: 0644]

index 15251ef..d2e480a 100644 (file)
@@ -623,7 +623,11 @@ rs6000_cpu_cpp_builtins (cpp_reader *pfile)
   if (TARGET_FRSQRTES)
     builtin_define ("__RSQRTEF__");
   if (TARGET_FLOAT128_TYPE)
-    builtin_define ("__FLOAT128_TYPE__");
+      builtin_define ("__FLOAT128_TYPE__");
+  if (ibm128_float_type_node)
+    builtin_define ("__SIZEOF_IBM128__=16");
+  if (ieee128_float_type_node)
+    builtin_define ("__SIZEOF_FLOAT128__=16");
 #ifdef TARGET_LIBC_PROVIDES_HWCAP_IN_TCB
   builtin_define ("__BUILTIN_CPU_SUPPORTS__");
 #endif
diff --git a/gcc/testsuite/gcc.target/powerpc/pr99708.c b/gcc/testsuite/gcc.target/powerpc/pr99708.c
new file mode 100644 (file)
index 0000000..d478f7b
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+/* { require-effective-target ppc_float128_sw } */
+/* { dg-options "-O2 -mvsx -mfloat128" } */
+
+/*
+ * PR target/99708
+ *
+ * Verify that __SIZEOF_FLOAT128__ and __SIZEOF_IBM128__ are properly defined.
+ */
+
+#include <stdlib.h>
+
+int main (void)
+{
+  if (__SIZEOF_FLOAT128__ != sizeof (__float128)
+      || __SIZEOF_IBM128__ != sizeof (__ibm128))
+    abort ();
+
+  return 0;
+}
+