public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work032)] PowerPC: Add long double target-supports.
@ 2021-01-14 3:16 Michael Meissner
0 siblings, 0 replies; 2+ messages in thread
From: Michael Meissner @ 2021-01-14 3:16 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:19478d92f2275245f1b44949c6bced7028f43eaa
commit 19478d92f2275245f1b44949c6bced7028f43eaa
Author: Michael Meissner <meissner@linux.ibm.com>
Date: Wed Jan 13 22:16:25 2021 -0500
PowerPC: Add long double target-supports.
This patch adds 6 target supports to test what type of PowerPC long double is
used by the test:
1) Long double uses the IBM 128-bit extended double format;
2) Long double uses the IEEE 128-bit format;
3) We can force long double to use IBM 128-bit and GLIBC works;
4) We can force long double to use IEEE 128-bit and GLIBC works;
5) Long double uses one of the 128-bit formats; (and)
6) Long double uses the 64-bit format.
gcc/testsuite/
2021-01-13 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.
Diff:
---
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 47d4c45e9eb..9834ba708fe 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2354,6 +2354,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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gcc(refs/users/meissner/heads/work032)] PowerPC: Add long double target-supports.
@ 2021-01-14 23:35 Michael Meissner
0 siblings, 0 replies; 2+ messages in thread
From: Michael Meissner @ 2021-01-14 23:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e2f323e48ff24d070406f12cce9f6535630ba437
commit e2f323e48ff24d070406f12cce9f6535630ba437
Author: Michael Meissner <meissner@linux.ibm.com>
Date: Thu Jan 14 18:32:40 2021 -0500
PowerPC: Add long double target-supports.
This patch adds 6 target supports to test what type of PowerPC long double is
used by the test:
1) Current long double uses the IBM 128-bit extended double format;
2) Current long double uses the IEEE 128-bit format;
3) Current long double is 64-bit;
4) We can force long double to use IBM 128-bit and GLIBC works;
5) We can force long double to use IEEE 128-bit and GLIBC works; (and)
6) We can force long double to use 64-bit and GLIBC works.
gcc/testsuite/
2021-01-13 Michael Meissner <meissner@linux.ibm.com>
* lib/target-supports.exp
(check_effective_target_ppc_long_double_ibm128): New function.
(check_effective_target_ppc_long_double_ieee128): New function.
(check_effective_target_ppc_long_double_64bit): New function.
(add_options_for_ppc_long_double_override_ibm128): New function.
(check_effective_target_ppc_long_double_override_ibm128): New
function.
(add_options_for_ppc_long_double_override_ieee128): New function.
(check_effective_target_ppc_long_double_override_ieee128): New
function.
(add_options_for_ppc_long_double_override_64bit): New function.
(check_effective_target_ppc_long_double_override_64bit): New
function.
Diff:
---
gcc/testsuite/lib/target-supports.exp | 155 ++++++++++++++++++++++++++++++++++
1 file changed, 155 insertions(+)
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 47d4c45e9eb..2badb495adc 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2354,6 +2354,161 @@ 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_ibm128 { } {
+ 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_ieee128 { } {
+ 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
+ }
+ }]
+}
+
+# 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
+ }
+ }]
+}
+
+# Like check_effective_target_ppc_long_double_ibm128, 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 add_options_for_ppc_long_double_override_ibm128 { flags } {
+ if { [istarget powerpc*-*-*] } {
+ return "$flags -mlong-double-128 -Wno-psabi -mabi=ibmlongdouble"
+ }
+ return "$flags"
+}
+
+proc check_effective_target_ppc_long_double_override_ibm128 { } {
+ return [check_runtime_nocache ppc_long_double_ovveride_ibm128 {
+ #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
+ }
+ } [add_options_for_ppc_long_double_override_ibm128 ""]]
+}
+
+# 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 add_options_for_ppc_long_double_override_ieee128 { flags } {
+ if { [istarget powerpc*-*-*] } {
+ return "$flags -mlong-double-128 -Wno-psabi -mabi=ieeelongdouble"
+ }
+ return "$flags"
+}
+
+proc check_effective_target_ppc_long_double_override_ieee128 { } {
+ return [check_runtime_nocache ppc_long_double_ovveride_ieee128 {
+ #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
+ }
+ } [add_options_for_ppc_long_double_override_ieee128 ""]]
+}
+
+# Like check_effective_target_ppc_long_double_64bit, but override the long
+# double format to be 64-bit explicitly.
+
+proc add_options_for_ppc_long_double_override_64bit { flags } {
+ if { [istarget powerpc*-*-*] } {
+ return "$flags -mlong-double-64"
+ }
+ return "$flags"
+}
+
+proc check_effective_target_ppc_long_double_override_64bit { } {
+ return [check_runtime_nocache ppc_long_double_ovveride_64bit {
+ #include <string.h>
+ #include <stdio.h>
+ volatile double a = 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_128__)
+ return 1;
+ #else
+ if (sizeof (long double) != sizeof (double))
+ return 1;
+ 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
+ }
+ } [add_options_for_ppc_long_double_override_64bit ""]]
+}
+
# Return 1 if the target supports executing VSX instructions, 0
# otherwise. Cache the result.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-14 23:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14 3:16 [gcc(refs/users/meissner/heads/work032)] PowerPC: Add long double target-supports Michael Meissner
2021-01-14 23:35 Michael Meissner
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).