[PATCH 1/3] PowerPC: Add long double target-supports.
Michael Meissner
meissner@linux.ibm.com
Fri Dec 4 04:06:12 GMT 2020
PowerPC: Add long double target-supports.
I messed up posting this patch, using the wrong subject line. This patch is
what I meant to post.
This patch replaces the patch submitted on November 21st:
| Date: Sat, 21 Nov 2020 00:33:52 -0500
| Subject: [PATCH 1/3] PowerPC: Add long double target-supports.
| Message-ID: <20201121053352.GC17995@ibm-toto.the-meissners.org>
| https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559839.html
I expanded the target supports to include more options to select targets with
an appropriate long double format. There are four options to check whether the
current long double is:
1) 128-bit using the IBM extended double format;
2) 128-bit using the IEEE format;
3) Long double is 128-bits (i.e. either IBM or IEEE); (and)
4) Long double is 64-bits.
I also added two new target supports:
1) If you can switch the long double to IBM extended double via compiler
options and the GLIBC supports this change. If you are using an
existing GLIBC with IBM long double, this should work since you aren't
switching the long double format.
2) And likewise if you can switch the long double to IEEE 128-bit.
This patch and the following 2 other patches were tested together on a power9
little endian server system. I built 4 compilers:
1) Compiler without modifications;
2) Compiler using my other patches configured for IBM long double;
3) Compiler using my other patches configured for IEEE long double; (and)
4) Compiler using my other patches configure for 64-bit double.
While I used the other patches to test the 64-bit and IEEE long double, these 3
patches should work for the default builds with IBM 128-bit, and they will
continue to work once all of the long double support patches are in. The two
tests that are patched in the next two patches, now work in all environments.
Can I apply these patches to the master branch?
gcc/testsuite/
2020-12-03 Michael Meissner <meissner@linux.ibm.com>
* lib/target-supports.exp
(check_effective_target_ppc_long_double_ibm): New function.
(check_effective_target_ppc_long_double_ieee): New function.
(check_effective_target_ppc_long_double_override_ibm): New function.
(check_effective_target_ppc_long_double_override_ieee): New function.
(check_effective_target_ppc_long_double_128bit): New function.
(check_effective_target_ppc_long_double_64bit): New function.
---
gcc/testsuite/lib/target-supports.exp | 122 ++++++++++++++++++++++++++
1 file changed, 122 insertions(+)
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index ff6bc5f4b92..01b82843bf5 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2348,6 +2348,128 @@ proc check_effective_target_ppc_ieee128_ok { } {
}]
}
+# See if the target is a powerpc with the long double format that uses the IBM
+# extended double format.
+
+proc check_effective_target_ppc_long_double_ibm { } {
+ return [check_cached_effective_target ppc_long_double_ibm {
+ int main()
+ {
+ #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
+ return 1;
+ #else
+ return 0;
+ #endif
+ }
+ }]
+}
+
+# See if the target is a powerpc with the long double format that uses the IEEE
+# 128-bit format.
+
+proc check_effective_target_ppc_long_double_ieee { } {
+ return [check_cached_effective_target ppc_long_double_ieee {
+ int main()
+ {
+ #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
+ return 1;
+ #else
+ return 0;
+ #endif
+ }
+ }]
+}
+
+# Like check_effective_target_ppc_long_double_ibm, but check if we can
+# explicitly override the long double format to use the IBM 128-bit extended
+# double format, and GLIBC supports doing this override by switching the
+# sprintf to handle long double.
+
+proc check_effective_target_ppc_long_double_override_ibm { } {
+ set options "-mlong-double-128 -mabi=ibmlongdouble -Wno-psabi"
+ check_runtime_nocache ppc_long_double_ovveride_ibm {
+ #include <string.h>
+ #include <stdio.h>
+ volatile __ibm128 a = (__ibm128) 3.0;
+ volatile long double one = 1.0L;
+ volatile long double two = 2.0L;
+ volatile long double b;
+ char buffer[20];
+ int main()
+ {
+ #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IBM128__)
+ return 1;
+ #else
+ b = one + two;
+ if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)
+ return 1;
+ sprintf (buffer, "%lg", b);
+ return strcmp (buffer, "3") != 0;
+ #endif
+ }
+ } $options
+}
+
+# Like check_effective_target_ppc_long_double_ieee, but check if we can
+# explicitly override the long double format to use the IEEE 128-bit format,
+# and GLIBC supports doing this override by switching the sprintf to handle
+# long double.
+
+proc check_effective_target_ppc_long_double_override_ieee { } {
+ set options "-mlong-double-128 -mabi=ieeelongdouble -Wno-psabi"
+ check_runtime_nocache ppc_long_double_ovveride_ieee {
+ #include <string.h>
+ #include <stdio.h>
+ volatile _Float128 a = 3.0f128;
+ volatile long double one = 1.0L;
+ volatile long double two = 2.0L;
+ volatile long double b;
+ char buffer[20];
+ int main()
+ {
+ #if !defined(_ARCH_PPC) || !defined(__LONG_DOUBLE_IEEE128__)
+ return 1;
+ #else
+ b = one + two;
+ if (memcmp ((void *)&a, (void *)&b, sizeof (long double)) != 0)
+ return 1;
+ sprintf (buffer, "%lg", b);
+ return strcmp (buffer, "3") != 0;
+ #endif
+ }
+ } $options
+}
+
+# See if the target is a powerpc with the long double format that is 128-bits.
+
+proc check_effective_target_ppc_long_double_128bit { } {
+ return [check_cached_effective_target ppc_long_double_128bit {
+ int main()
+ {
+ #ifndef _ARCH_PPC
+ return 1;
+ #else
+ return sizeof (long double) != 16;
+ #endif
+ }
+ }]
+}
+
+# See if the target is a powerpc with the long double format that is 64-bit.
+
+proc check_effective_target_ppc_long_double_64bit { } {
+ return [check_cached_effective_target ppc_long_double_64bit {
+ int main()
+ {
+ #ifndef _ARCH_PPC
+ return 1;
+ #else
+ return sizeof (long double) != 8;
+ #endif
+ }
+ }]
+}
+
# Return 1 if the target supports executing VSX instructions, 0
# otherwise. Cache the result.
--
2.22.0
--
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.ibm.com, phone: +1 (978) 899-4797
More information about the Gcc-patches
mailing list