aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorBill Schmidt <wschmidt@linux.ibm.com>2021-12-14 10:09:06 -0600
committerBill Schmidt <wschmidt@linux.ibm.com>2021-12-14 11:20:11 -0600
commit74aeb9726756aa79c21028712c26910866e33026 (patch)
tree404713a5185c5a9a177a21a137887572c1b75406 /gcc/config
parent3736837806fdb26daa51300bee1554bef89db9fe (diff)
downloadgcc-74aeb9726756aa79c21028712c26910866e33026.zip
gcc-74aeb9726756aa79c21028712c26910866e33026.tar.gz
gcc-74aeb9726756aa79c21028712c26910866e33026.tar.bz2
rs6000: Some builtins require IBM-128 long double format (PR103623)
2021-12-14 Bill Schmidt <wschmidt@linux.ibm.com> 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.
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/rs6000/rs6000-builtin-new.def15
-rw-r--r--gcc/config/rs6000/rs6000-call.c7
-rw-r--r--gcc/config/rs6000/rs6000-gen-builtins.c13
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 30556e5..f7f5d2c 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 d9736ea..3a43a76 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 %<long double%> 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 34ab70f..856770c1 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],