public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH], PR target/99708 - Define __SIZEOF_FLOAT128__ and __SIZEOF_IBM128__
@ 2022-02-15 17:49 Michael Meissner
  2022-02-15 19:45 ` Segher Boessenkool
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Meissner @ 2022-02-15 17:49 UTC (permalink / raw)
  To: gcc-patches, Michael Meissner, Segher Boessenkool,
	David Edelsohn, Bill Schmidt, Peter Bergner, Will Schmidt

Define __SIZEOF_FLOAT128__ and __SIZEOF_IBM128__.

Define the sizes of the PowerPC specific types __float128 and __ibm128 if those
types are enabled.

I tested this on a little endian power9 system and there were no regressions.
Can I check this into the trunk, and after a burn-in period, can I check this
into the GCC 10 and 11 branches?

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

gcc/
	PR target/99708
	* config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Define
	__SIZEOF_FLOAT128__ and __SIZEOF_IBM128__ if we have float128
	support.

gcc/testsuite/
	PR target/99708
	* gcc.target/powerpc/pr99708.c: New test.
---
 gcc/config/rs6000/rs6000-c.cc              | 12 ++++++++++--
 gcc/testsuite/gcc.target/powerpc/pr99708.c | 21 +++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/pr99708.c

diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc
index 15251efc209..b5f771d1308 100644
--- a/gcc/config/rs6000/rs6000-c.cc
+++ b/gcc/config/rs6000/rs6000-c.cc
@@ -581,9 +581,17 @@ 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, "__float128=__ieee128");
+	  rs6000_define_or_undefine_macro (true, "__SIZEOF_FLOAT128__=16");
+	  rs6000_define_or_undefine_macro (true, "__SIZEOF_IBM128__=16");
+	}
       else
-	rs6000_define_or_undefine_macro (false, "__float128");
+	{
+	  rs6000_define_or_undefine_macro (false, "__float128");
+	  rs6000_define_or_undefine_macro (false, "__SIZEOF_FLOAT128__");
+	  rs6000_define_or_undefine_macro (false, "__SIZEOF_IBM128__");
+	}
     }
   /* OPTION_MASK_FLOAT128_HARDWARE can be turned on if -mcpu=power9 is used or
      via the target attribute/pragma.  */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr99708.c b/gcc/testsuite/gcc.target/powerpc/pr99708.c
new file mode 100644
index 00000000000..d478f7bc4c0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr99708.c
@@ -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;
+}
+
-- 
2.35.1


-- 
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: meissner@linux.ibm.com

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

end of thread, other threads:[~2022-02-16 10:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-15 17:49 [PATCH], PR target/99708 - Define __SIZEOF_FLOAT128__ and __SIZEOF_IBM128__ Michael Meissner
2022-02-15 19:45 ` Segher Boessenkool
2022-02-15 20:18   ` Michael Meissner
2022-02-15 22:05     ` Segher Boessenkool
2022-02-15 23:05       ` Michael Meissner
2022-02-16 10:28         ` Segher Boessenkool

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).