re PR target/85657 (Make __ibm128 a separate type, even if long double uses the IBM...
authorMichael Meissner <meissner@linux.ibm.com>
Wed, 6 Jun 2018 22:54:17 +0000 (22:54 +0000)
committerMichael Meissner <meissner@gcc.gnu.org>
Wed, 6 Jun 2018 22:54:17 +0000 (22:54 +0000)
[gcc]
2018-06-06  Michael Meissner  <meissner@linux.ibm.com>

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  <meissner@linux.ibm.com>

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
gcc/config/rs6000/rs6000-builtin.def
gcc/config/rs6000/rs6000.c
gcc/doc/extend.texi
gcc/testsuite/ChangeLog

index f82ccb3d6e85e39e2c277754983b5e24baaec186..6d5a9b0dc9f1036d51a4fa50de659cba9b30e6f2 100644 (file)
        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  <jimw@sifive.com>
 
        * config/riscv/riscv.c (enum riscv_privilege_levels): New.
index 289c1825483ac28f29724fc3bdd50c9716b1e573..98702c7cf793d50d0c8e2d4e45626684198baf56 100644 (file)
                     | 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)
 
index bbee6cbc1e3e0f2ad0438ddc79cbe0d420001860..04186a07cd280e3a145c76634b413b1f4de258a2 100644 (file)
@@ -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;
     }
index 0c1c1b1dc169e8b6c406d34ee77adad8e25a6d3b..46b9a9251ce06cfb6de099a41b26fb1724310bfa 100644 (file)
@@ -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
index f359ed9f3ee3759bfcfe2d428c8323c61e050729..1bb75b2e00b1d7783f21abf03a12a61d36f60314 100644 (file)
@@ -1,3 +1,10 @@
+2018-06-06  Michael Meissner  <meissner@linux.ibm.com>
+
+       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  <tkoenig@gcc.gnu.org>
 
        PR fortran/85641