From: Michael Meissner <meissner@linux.ibm.com>
To: Michael Meissner <meissner@linux.ibm.com>,
gcc-patches@gcc.gnu.org,
Segher Boessenkool <segher@kernel.crashing.org>,
"Kewen.Lin" <linkw@linux.ibm.com>,
David Edelsohn <dje.gcc@gmail.com>,
Peter Bergner <bergner@linux.ibm.com>,
Will Schmidt <will_schmidt@vnet.ibm.com>
Subject: [PATCH 3/3] Add 'w' suffix for __ibm128 constants
Date: Thu, 18 Aug 2022 17:42:50 -0400 [thread overview]
Message-ID: <Yv6yWjMOMnkqLyrz@toto.the-meissners.org> (raw)
In-Reply-To: <Yv6vELPxsr5ywncp@toto.the-meissners.org>
Add 'w' suffix for __ibm128 constants.
In the documentation, we mention that 'w' or 'W' can be used as a suffix for
__ibm128 constants. We never implemented this. This patch fixes that.
In addition, the 'q' and 'Q' suffix were changed to use the mode used for the
__float128 type, instead of knowing whether to use KFmode or TFmode explicitly.
This will be used in a future patch where we change the mode used for __float128
on systems where long double is IEEE 128-bit.
I have tested this patch on the following systems:
1) LE Power10 using --with-cpu=power10 --with-long-double-format=ieee
2) LE Power10 using --with-cpu=power9 --with-long-double-format=ibm
3) LE Power10 using --with-cpu=power8 --with-long-double-format=ibm
4) LE Power10 using --with-cpu=power10 --with-long-double-format=ibm
5) LE Power9 using --with-cpu=power9 --with-long-double-format=ibm
6) BE Power8 using --with-cpu=power8 --with-long-double-format=ibm
7) BE Power8 using --with-cpu=power5 --with-long-double-format=ibm
There were no regressions in the build or in the tests.
Can I check this patch into the trunk?
Did we want to backport this to earlier GCC releases?
2022-08-17 Michael Meissner <meissner@linux.ibm.com>
gcc/
* config/rs6000/rs6000.cc (rs6000_c_mode_for_suffix): Allow 'w' or 'W'
for __ibm128 constants.
gcc/testsuite/
* gcc.target/powerpc/ibm128-suffix.c: New test.
---
gcc/config/rs6000/rs6000.cc | 25 ++++++++++---------
.../gcc.target/powerpc/ibm128-suffix.c | 13 ++++++++++
2 files changed, 26 insertions(+), 12 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index a6ec4c71ac0..046c538c748 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -23845,22 +23845,23 @@ rs6000_floatn_mode (int n, bool extended)
}
-/* Target hook for c_mode_for_suffix. */
+/* Target hook for c_mode_for_suffix. We use TYPE_MODE to follow the mode used
+ for __float128 and __ibm128.
+
+ Only two suffixes are allowed, 'q' and 'w'. The 'q' suffix is used for
+ float128 constants on both the x86 and PowerPC processors. Its use predates
+ the use of 'f128' for _Float128 constants, and existing code still uses it.
+
+ The 'w' suffix was used on the x86 processors for their 80-bit long
+ double. We use it for __ibm128 constants. */
static machine_mode
rs6000_c_mode_for_suffix (char suffix)
{
- if (TARGET_FLOAT128_TYPE)
- {
- if (suffix == 'q' || suffix == 'Q')
- return (FLOAT128_IEEE_P (TFmode)) ? TFmode : KFmode;
+ if (TARGET_FLOAT128_TYPE && (suffix == 'q' || suffix == 'Q'))
+ return TYPE_MODE (ieee128_float_type_node);
- /* At the moment, we are not defining a suffix for IBM extended double.
- If/when the default for -mabi=ieeelongdouble is changed, and we want
- to support __ibm128 constants in legacy library code, we may need to
- re-evalaute this decision. Currently, c-lex.cc only supports 'w' and
- 'q' as machine dependent suffixes. The x86_64 port uses 'w' for
- __float80 constants. */
- }
+ if (TARGET_IBM128 && (suffix == 'w' || suffix == 'W'))
+ return TYPE_MODE (ibm128_float_type_node);
return VOIDmode;
}
diff --git a/gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c b/gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c
new file mode 100644
index 00000000000..ff619860409
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target longdouble128 } */
+/* { dg-options "-O2" } */
+
+/* See if the 'w' suffix is accepted for __ibm128. */
+#ifndef NUMBER
+#define NUMBER 123456789012345678901234567890123456789E-10
+#endif
+
+#define GLUE2(X,Y) X ## Y
+#define GLUE(X,Y) GLUE2(X,Y)
+
+__ibm128 x = GLUE (NUMBER, w);
--
2.37.2
--
Michael Meissner, IBM
PO Box 98, Ayer, Massachusetts, USA, 01432
email: meissner@linux.ibm.com
prev parent reply other threads:[~2022-08-18 21:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-18 21:28 [PATCH 0/3] Improvements to __ibm128 on PowerPC Michael Meissner
2022-08-18 21:39 ` [PATCH 1/3] Allow __ibm128 even if IEEE 128-bit floating point is not supported Michael Meissner
2022-08-18 21:41 ` [PATCH 2/3] Allow __ibm128 with -msoft-float (PR target/105334) Michael Meissner
2022-08-18 21:42 ` Michael Meissner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yv6yWjMOMnkqLyrz@toto.the-meissners.org \
--to=meissner@linux.ibm.com \
--cc=bergner@linux.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=linkw@linux.ibm.com \
--cc=segher@kernel.crashing.org \
--cc=will_schmidt@vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).