From f0e5e942351ba2b2637efdcb092adc4eeb92fcc3 Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Wed, 6 Jun 2018 22:54:17 +0000 Subject: [PATCH] re PR target/85657 (Make __ibm128 a separate type, even if long double uses the IBM double-double format) [gcc] 2018-06-06 Michael Meissner PR target/85657 * config/rs6000/rs6000-builtin.def (BU_IBM128_2): New helper macro for __ibm128 built-in functions. (PACK_IF): Add __ibm128 pack/unpack functions. (UNPACK_IF): Likewise. * config/rs6000/rs6000.c (rs6000_builtin_mask_calculate): Do not enable long double built-in functions if long double is IEEE 128-bit floating point. (rs6000_invalid_builtin): Update long double built-in function error message. (rs6000_expand_builtin): For PACK_IF and UNPACK_IF built-in functions, adjust the built-in function to use the long double built-in function if __ibm128 and long double are the same type. * doc/extend.texi (PowerPC builtins): Update documention for __builtin_{,un}pack_longdouble. Add documentation for __builtin_{,un}pack_ibm128. [gcc/testsuite] 2018-06-06 Michael Meissner PR target/85657 * gcc.target/powerpc/pr85657-4.c: New tests. * gcc.target/powerpc/pr85657-5.c: Likewise. * gcc.target/powerpc/pr85657-6.c: Likewise. From-SVN: r261253 --- gcc/ChangeLog | 17 +++++++++++++ gcc/config/rs6000/rs6000-builtin.def | 14 +++++++++++ gcc/config/rs6000/rs6000.c | 37 ++++++++++++++++++++++++---- gcc/doc/extend.texi | 32 +++++++++++++++++++++--- gcc/testsuite/ChangeLog | 7 ++++++ 5 files changed, 98 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f82ccb3d6e8..6d5a9b0dc9f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -18,6 +18,23 @@ long double is IBM extended double. Make __float128 use the long double type if long double is IEEE 128-bit. + PR target/85657 + * config/rs6000/rs6000-builtin.def (BU_IBM128_2): New helper + macro for __ibm128 built-in functions. + (PACK_IF): Add __ibm128 pack/unpack functions. + (UNPACK_IF): Likewise. + * config/rs6000/rs6000.c (rs6000_builtin_mask_calculate): Do not + enable long double built-in functions if long double is IEEE + 128-bit floating point. + (rs6000_invalid_builtin): Update long double built-in function + error message. + (rs6000_expand_builtin): For PACK_IF and UNPACK_IF built-in + functions, adjust the built-in function to use the long double + built-in function if __ibm128 and long double are the same type. + * doc/extend.texi (PowerPC builtins): Update documention for + __builtin_{,un}pack_longdouble. Add documentation for + __builtin_{,un}pack_ibm128. + 2018-06-06 Jim Wilson * config/riscv/riscv.c (enum riscv_privilege_levels): New. diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index 289c1825483..98702c7cf79 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -628,6 +628,17 @@ | RS6000_BTC_BINARY), \ CODE_FOR_ ## ICODE) /* ICODE */ +/* 128-bit __ibm128 floating point builtins (use -mfloat128 to indicate that + __ibm128 is available). */ +#define BU_IBM128_2(ENUM, NAME, ATTR, ICODE) \ + RS6000_BUILTIN_2 (MISC_BUILTIN_ ## ENUM, /* ENUM */ \ + "__builtin_" NAME, /* NAME */ \ + (RS6000_BTM_HARD_FLOAT /* MASK */ \ + | RS6000_BTM_FLOAT128), \ + (RS6000_BTC_ ## ATTR /* ATTR */ \ + | RS6000_BTC_BINARY), \ + CODE_FOR_ ## ICODE) /* ICODE */ + /* Miscellaneous builtins for instructions added in ISA 3.0. These instructions don't require either the DFP or VSX options, just the basic ISA 3.0 enablement since they operate on general purpose registers. */ @@ -2324,6 +2335,9 @@ BU_P9_64BIT_MISC_0 (DARN, "darn", MISC, darn) BU_LDBL128_2 (PACK_TF, "pack_longdouble", CONST, packtf) BU_LDBL128_2 (UNPACK_TF, "unpack_longdouble", CONST, unpacktf) +BU_IBM128_2 (PACK_IF, "pack_ibm128", CONST, packif) +BU_IBM128_2 (UNPACK_IF, "unpack_ibm128", CONST, unpackif) + BU_P7_MISC_2 (PACK_V1TI, "pack_vector_int128", CONST, packv1ti) BU_P7_MISC_2 (UNPACK_V1TI, "unpack_vector_int128", CONST, unpackv1ti) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index bbee6cbc1e3..04186a07cd2 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -3907,7 +3907,9 @@ rs6000_builtin_mask_calculate (void) | ((TARGET_HTM) ? RS6000_BTM_HTM : 0) | ((TARGET_DFP) ? RS6000_BTM_DFP : 0) | ((TARGET_HARD_FLOAT) ? RS6000_BTM_HARD_FLOAT : 0) - | ((TARGET_LONG_DOUBLE_128) ? RS6000_BTM_LDBL128 : 0) + | ((TARGET_LONG_DOUBLE_128 + && TARGET_HARD_FLOAT + && !TARGET_IEEEQUAD) ? RS6000_BTM_LDBL128 : 0) | ((TARGET_FLOAT128_TYPE) ? RS6000_BTM_FLOAT128 : 0) | ((TARGET_FLOAT128_HW) ? RS6000_BTM_FLOAT128_HW : 0)); } @@ -15339,10 +15341,15 @@ rs6000_invalid_builtin (enum rs6000_builtins fncode) else if ((fnmask & RS6000_BTM_P9_MISC) == RS6000_BTM_P9_MISC) error ("builtin function %qs requires the %qs option", name, "-mcpu=power9"); - else if ((fnmask & (RS6000_BTM_HARD_FLOAT | RS6000_BTM_LDBL128)) - == (RS6000_BTM_HARD_FLOAT | RS6000_BTM_LDBL128)) - error ("builtin function %qs requires the %qs and %qs options", - name, "-mhard-float", "-mlong-double-128"); + else if ((fnmask & RS6000_BTM_LDBL128) == RS6000_BTM_LDBL128) + { + if (!TARGET_HARD_FLOAT) + error ("builtin function %qs requires the %qs option", name, + "-mhard-float"); + else + error ("builtin function %qs requires the %qs option", name, + TARGET_IEEEQUAD ? "-mabi=ibmlongdouble" : "-mlong-double-128"); + } else if ((fnmask & RS6000_BTM_HARD_FLOAT) != 0) error ("builtin function %qs requires the %qs option", name, "-mhard-float"); @@ -16213,6 +16220,26 @@ rs6000_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED, } break; + /* For the pack and unpack int128 routines, fix up the builtin so it + uses the correct IBM128 type. */ + case MISC_BUILTIN_PACK_IF: + if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD) + { + icode = CODE_FOR_packtf; + fcode = MISC_BUILTIN_PACK_TF; + uns_fcode = (size_t)fcode; + } + break; + + case MISC_BUILTIN_UNPACK_IF: + if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD) + { + icode = CODE_FOR_unpacktf; + fcode = MISC_BUILTIN_UNPACK_TF; + uns_fcode = (size_t)fcode; + } + break; + default: break; } diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 0c1c1b1dc16..46b9a9251ce 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -15801,6 +15801,8 @@ processors: @smallexample uint64_t __builtin_ppc_get_timebase (); unsigned long __builtin_ppc_mftb (); +__ibm128 __builtin_unpack_ibm128 (__ibm128, int); +__ibm128 __builtin_pack_ibm128 (double, double); @end smallexample The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb} @@ -15883,10 +15885,32 @@ the reciprocal estimate instructions. The following functions require @option{-mhard-float} and @option{-mmultiple} options. -@smallexample -long double __builtin_pack_longdouble (double, double); -double __builtin_unpack_longdouble (long double, int); -@end smallexample +The @code{__builtin_unpack_longdouble} function takes a +@code{long double} argument and a compile time constant of 0 or 1. If +the constant is 0, the first @code{double} within the +@code{long double} is returned, otherwise the second @code{double} +is returned. The @code{__builtin_unpack_longdouble} function is only +availble if @code{long double} uses the IBM extended double +representation. + +The @code{__builtin_pack_longdouble} function takes two @code{double} +arguments and returns a @code{long double} value that combines the two +arguments. The @code{__builtin_pack_longdouble} function is only +availble if @code{long double} uses the IBM extended double +representation. + +The @code{__builtin_unpack_ibm128} function takes a @code{__ibm128} +argument and a compile time constant of 0 or 1. If the constant is 0, +the first @code{double} within the @code{__ibm128} is returned, +otherwise the second @code{double} is returned. + +The @code{__builtin_pack_ibm128} function takes two @code{double} +arguments and returns a @code{__ibm128} value that combines the two +arguments. + +Additional built-in functions are available for the 64-bit PowerPC +family of processors, for efficient use of 128-bit floating point +(@code{__float128}) values. @node Basic PowerPC Built-in Functions Available on ISA 2.06 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f359ed9f3ee..1bb75b2e00b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-06-06 Michael Meissner + + PR target/85657 + * gcc.target/powerpc/pr85657-4.c: New tests. + * gcc.target/powerpc/pr85657-5.c: Likewise. + * gcc.target/powerpc/pr85657-6.c: Likewise. + 2018-06-06 Thomas Koenig PR fortran/85641 -- 2.30.2