From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1005) id 9E7B43858407; Thu, 4 Aug 2022 22:49:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E7B43858407 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/work096)] Make 'w' the __ibm128 suffix. X-Act-Checkin: gcc X-Git-Author: Michael Meissner X-Git-Refname: refs/users/meissner/heads/work096 X-Git-Oldrev: 4c54bfeab72d7a56678ea421cd3a7d1a3002d44d X-Git-Newrev: 2c88d13fe7db79d7fbb7deb2254922988542e733 Message-Id: <20220804224941.9E7B43858407@sourceware.org> Date: Thu, 4 Aug 2022 22:49:41 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2022 22:49:41 -0000 https://gcc.gnu.org/g:2c88d13fe7db79d7fbb7deb2254922988542e733 commit 2c88d13fe7db79d7fbb7deb2254922988542e733 Author: Michael Meissner Date: Thu Aug 4 18:49:19 2022 -0400 Make 'w' the __ibm128 suffix. In writing code with __ibm128 support, it would be nice if we supported a suffix that marked __ibm128 constants. The preprocessor lexer supports using either 'q'/'Q' or 'w'/'W' as machine dependent suffixes. The 'q'/'Q' suffix was already taken for __float128 constants, so I added 'w' or 'W' as the suffix for the __ibm128 constant. I went to the file doc/extend.texi to document using a 'w' or 'W' suffix, but it appears that we already had documented using 'w'/'W' for __ibm128. This code adds this support to the GCC compiler. 2022-08-04 Michael Meissner gcc/ * config/rs6000/rs6000.cc (rs6000_c_mode_for_suffix): Add support for using 'w' or 'W' as the __ibm128 bit constant. gcc/testsuite/ * gcc.target/powerpc/ibm128-suffix.c: New test. Diff: --- gcc/config/rs6000/rs6000.cc | 15 ++---- gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c | 66 ++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 11 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 9d79fc0bb69..e13b6653fa9 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -23789,18 +23789,11 @@ rs6000_floatn_mode (int n, bool extended) static machine_mode rs6000_c_mode_for_suffix (char suffix) { - if (TARGET_FLOAT128_TYPE) - { - if (suffix == 'q' || suffix == 'Q') - return KFmode; + if (TARGET_FLOAT128_TYPE && (suffix == 'q' || suffix == 'Q')) + return KFmode; - /* 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. */ - } + else if (TARGET_IBM128 && (suffix == 'w' || suffix == 'W')) + return IFmode; 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..5c3d0562c90 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/ibm128-suffix.c @@ -0,0 +1,66 @@ +/* { dg-do run } */ +/* { dg-require-effective-target longdouble128 } */ +/* { dg-options "-O2" } */ + +#include +#include + +#ifdef DEBUG +#include +#endif + +/* Test whether the 'w' suffix creates appropriate __ibm128 bit constants. */ + +#ifndef NUMBER +#define NUMBER 123456789012345678901234567890123456.789 +#endif + +#define GLUE2(X,Y) X ## Y +#define GLUE(X,Y) GLUE2(X,Y) + +/* Full 128-bit constant. */ +__ibm128 i128_with_128bit_constant = GLUE(NUMBER,W); + +/* 64-bit constant that will fill in the bottom 64-bits with 0. */ +__ibm128 i128_with_64bit_constant = NUMBER; + +/* 64-bit constant. */ +double d64 = NUMBER; + +int +main (void) +{ + double hi_1 = __builtin_unpack_ibm128 (i128_with_128bit_constant, 0); + double lo_1 = __builtin_unpack_ibm128 (i128_with_128bit_constant, 1); + + double hi_2 = __builtin_unpack_ibm128 (i128_with_64bit_constant, 0); + double lo_2 = __builtin_unpack_ibm128 (i128_with_64bit_constant, 1); + +#ifdef DEBUG + printf ("i128_with_128bit_constant: (%.20g, %.20g)\n", hi_1, lo_1); + printf ("i128_with_64bit_constant: (%.20g, %.20g)\n", hi_2, lo_2); + printf ("d64: %.20g\n", d64); +#endif + + /* check sizes. */ + if (sizeof (NUMBER) != 8) + abort (); + + if (sizeof (GLUE(NUMBER,W)) != 16) + abort (); + + /* check if constant with 'w' suffix creates the full 128-bits. */ + if (hi_1 != d64 || lo_1 == 0.0) + abort (); + + /* check if constant without 'w' suffix creates a 64-bit constant which is + zero extended to 128-bit. */ + if (hi_2 != d64 || lo_2 != 0.0) + abort (); + +#ifdef DEBUG + printf ("No errors\n"); +#endif + + return 0; +}