From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1725) id D93D9385843F; Tue, 14 Dec 2021 17:20:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D93D9385843F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: William Schmidt To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5963] rs6000: Some builtins require IBM-128 long double format (PR103623) X-Act-Checkin: gcc X-Git-Author: Bill Schmidt X-Git-Refname: refs/heads/master X-Git-Oldrev: 3736837806fdb26daa51300bee1554bef89db9fe X-Git-Newrev: 74aeb9726756aa79c21028712c26910866e33026 Message-Id: <20211214172023.D93D9385843F@sourceware.org> Date: Tue, 14 Dec 2021 17:20:23 +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: Tue, 14 Dec 2021 17:20:24 -0000 https://gcc.gnu.org/g:74aeb9726756aa79c21028712c26910866e33026 commit r12-5963-g74aeb9726756aa79c21028712c26910866e33026 Author: Bill Schmidt Date: Tue Dec 14 10:09:06 2021 -0600 rs6000: Some builtins require IBM-128 long double format (PR103623) 2021-12-14 Bill Schmidt gcc/ PR target/103623 * config/rs6000/rs6000-builtin-new.def (__builtin_pack_longdouble): Add ibmld attribute. (__builtin_unpack_longdouble): Likewise. * config/rs6000/rs6000-call.c (rs6000_expand_new_builtin): Add special handling for ibmld attribute. * config/rs6000/rs6000-gen-builtins.c (attrinfo): Add isibmld. (parse_bif_attrs): Handle ibmld. (write_decls): Likewise. (write_bif_static_init): Likewise. Diff: --- gcc/config/rs6000/rs6000-builtin-new.def | 15 +++++++-------- gcc/config/rs6000/rs6000-call.c | 7 +++++++ gcc/config/rs6000/rs6000-gen-builtins.c | 13 +++++++++++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/gcc/config/rs6000/rs6000-builtin-new.def b/gcc/config/rs6000/rs6000-builtin-new.def index 30556e5c7f2..f7f5d2c32a4 100644 --- a/gcc/config/rs6000/rs6000-builtin-new.def +++ b/gcc/config/rs6000/rs6000-builtin-new.def @@ -137,6 +137,7 @@ ; lxvrse Needs special handling for load-rightmost, sign-extended ; lxvrze Needs special handling for load-rightmost, zero-extended ; endian Needs special handling for endianness +; ibmld Restrict usage to the case when TFmode is IBM-128 ; ; Each attribute corresponds to extra processing required when ; the built-in is expanded. All such special processing should @@ -215,13 +216,10 @@ double __builtin_mffsl (); MFFSL rs6000_mffsl {} -; This thing really assumes long double == __ibm128, and I'm told it has -; been used as such within libgcc. Given that __builtin_pack_ibm128 -; exists for the same purpose, this should really not be used at all. -; TODO: Consider adding special handling for this to warn whenever -; long double is not __ibm128. +; This is redundant with __builtin_pack_ibm128, as it requires long +; double to be __ibm128. Should probably be deprecated. const long double __builtin_pack_longdouble (double, double); - PACK_TF packtf {} + PACK_TF packtf {ibmld} unsigned long __builtin_ppc_mftb (); MFTB rs6000_mftb_di {32bit} @@ -244,9 +242,10 @@ const double __builtin_unpack_ibm128 (__ibm128, const int<1>); UNPACK_IF unpackif {} -; See above comments for __builtin_pack_longdouble. +; This is redundant with __builtin_unpack_ibm128, as it requires long +; double to be __ibm128. Should probably be deprecated. const double __builtin_unpack_longdouble (long double, const int<1>); - UNPACK_TF unpacktf {} + UNPACK_TF unpacktf {ibmld} ; Builtins that have been around just about forever, but not quite. diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c index d9736eaf21c..3a43a768c5c 100644 --- a/gcc/config/rs6000/rs6000-call.c +++ b/gcc/config/rs6000/rs6000-call.c @@ -15741,6 +15741,13 @@ rs6000_expand_new_builtin (tree exp, rtx target, return const0_rtx; } + if (bif_is_ibmld (*bifaddr) && !FLOAT128_2REG_P (TFmode)) + { + error ("%<%s%> requires % to be IBM 128-bit format", + bifaddr->bifname); + return const0_rtx; + } + if (bif_is_cpu (*bifaddr)) return new_cpu_expand_builtin (fcode, exp, target); diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index 34ab70f7609..856770c1659 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -92,6 +92,7 @@ along with GCC; see the file COPYING3. If not see lxvrse Needs special handling for load-rightmost, sign-extended lxvrze Needs special handling for load-rightmost, zero-extended endian Needs special handling for endianness + ibmld Restrict usage to the case when TFmode is IBM-128 An example stanza might look like this: @@ -390,6 +391,7 @@ struct attrinfo bool islxvrse; bool islxvrze; bool isendian; + bool isibmld; }; /* Fields associated with a function prototype (bif or overload). */ @@ -1435,6 +1437,8 @@ parse_bif_attrs (attrinfo *attrptr) attrptr->islxvrze = 1; else if (!strcmp (attrname, "endian")) attrptr->isendian = 1; + else if (!strcmp (attrname, "ibmld")) + attrptr->isibmld = 1; else { diag (oldpos, "unknown attribute.\n"); @@ -1468,14 +1472,14 @@ parse_bif_attrs (attrinfo *attrptr) "ldvec = %d, stvec = %d, reve = %d, pred = %d, htm = %d, " "htmspr = %d, htmcr = %d, mma = %d, quad = %d, pair = %d, " "mmaint = %d, no32bit = %d, 32bit = %d, cpu = %d, ldstmask = %d, " - "lxvrse = %d, lxvrze = %d, endian = %d.\n", + "lxvrse = %d, lxvrze = %d, endian = %d, ibmdld= %d.\n", attrptr->isinit, attrptr->isset, attrptr->isextract, attrptr->isnosoft, attrptr->isldvec, attrptr->isstvec, attrptr->isreve, attrptr->ispred, attrptr->ishtm, attrptr->ishtmspr, attrptr->ishtmcr, attrptr->ismma, attrptr->isquad, attrptr->ispair, attrptr->ismmaint, attrptr->isno32bit, attrptr->is32bit, attrptr->iscpu, attrptr->isldstmask, attrptr->islxvrse, - attrptr->islxvrze, attrptr->isendian); + attrptr->islxvrze, attrptr->isendian, attrptr->isibmld); #endif return PC_OK; @@ -2289,6 +2293,7 @@ write_decls (void) fprintf (header_file, "#define bif_lxvrse_bit\t\t(0x00080000)\n"); fprintf (header_file, "#define bif_lxvrze_bit\t\t(0x00100000)\n"); fprintf (header_file, "#define bif_endian_bit\t\t(0x00200000)\n"); + fprintf (header_file, "#define bif_ibmld_bit\t\t(0x00400000)\n"); fprintf (header_file, "\n"); fprintf (header_file, "#define bif_is_init(x)\t\t((x).bifattrs & bif_init_bit)\n"); @@ -2334,6 +2339,8 @@ write_decls (void) "#define bif_is_lxvrze(x)\t((x).bifattrs & bif_lxvrze_bit)\n"); fprintf (header_file, "#define bif_is_endian(x)\t((x).bifattrs & bif_endian_bit)\n"); + fprintf (header_file, + "#define bif_is_ibmld(x)\t((x).bifattrs & bif_ibmld_bit)\n"); fprintf (header_file, "\n"); /* #### Note that the _x is added for now to avoid conflict with @@ -2568,6 +2575,8 @@ write_bif_static_init (void) fprintf (init_file, " | bif_lxvrze_bit"); if (bifp->attrs.isendian) fprintf (init_file, " | bif_endian_bit"); + if (bifp->attrs.isibmld) + fprintf (init_file, " | bif_ibmld_bit"); fprintf (init_file, ",\n"); fprintf (init_file, " /* restr_opnd */\t{%d, %d, %d},\n", bifp->proto.restr_opnd[0], bifp->proto.restr_opnd[1],