From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id AC10B3857359; Fri, 9 Sep 2022 18:21:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC10B3857359 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662747686; bh=WPpMwyxfEPKD7dT+tnqZgozCa+lKrKNjVXRqoWK1c1U=; h=From:To:Subject:Date:From; b=Xn8WdE5UFZiqKSGEDrNRicfKEJ3J0iSftknR3u1DOAAkOOq1H98a6vYkop+ubfTG1 i0lVysWuq4uM+yabGW5LuCG2EXxbuQCQ6vnNa5c1j/JBPFjqmDtiQaCe8nXDRzjqyM vnLjx0+PtmB6iOE+VksXa4iH/8L3ENcSXD9e14mM= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Michael Meissner To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/meissner/heads/work100)] Add 'w' suffix for __ibm128 constants. X-Act-Checkin: gcc X-Git-Author: Michael Meissner X-Git-Refname: refs/users/meissner/heads/work100 X-Git-Oldrev: 5b604c7aec602ea2236b10f604f5093b1911bd92 X-Git-Newrev: 53e9f1bbe7d6a94d89948f1287d98ebaa59b9db0 Message-Id: <20220909182126.AC10B3857359@sourceware.org> Date: Fri, 9 Sep 2022 18:21:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:53e9f1bbe7d6a94d89948f1287d98ebaa59b9db0 commit 53e9f1bbe7d6a94d89948f1287d98ebaa59b9db0 Author: Michael Meissner Date: Fri Sep 9 14:18:47 2022 -0400 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. 2022-09-09 Michael Meissner 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. Diff: --- gcc/config/rs6000/rs6000.cc | 25 ++++++++++++------------ gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c | 13 ++++++++++++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 1c5436208f1..49d9017e4ca 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -23850,22 +23850,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);