Re: [PATCH] Make __ibm128 a distinct type, patch 2 of 2 (PR 85657)

2018-05-22 Thread Michael Meissner
Evidently I forgot the patch.

[gcc]
2018-05-21  Michael Meissner  

PR target/85657
* config/rs6000/rs6000-builtin.def (BU_IBM128_2): New helper macro
for __builtin_{,un}pack_ibm128.
(PACK_IF): Declare __builtin_{,un}pack_ibm128.
(UNPACK_IF): Likewise.
* config/rs6000/rs6000.c (rs6000_builtin_mask_calculate): The mask
for long double builtins (RS6000_BTM_LDBL128) requires that long
double is IBM extended double.
(rs6000_invalid_builtin): Add a new error message if the long
double {,un}pack builtins are used when long double is IEEE
128-bit floating point.
* config/rs6000/rs6000.h (RS6000_BTM_LDBL128): Update comment.
* doc/extend.texi (PowerPC builtins): Update documention for
__builtin_{,un}pack_longdouble.  Add documentation for
__builtin_{,un}pack_ibm128.

[gcc/testsuite]
2018-05-21  Michael Meissner  

PR target/85657
* gcc.target/powerpc/pr85657-4.c: New tests for pack/unpack
__ibm128 builtin functions, and whether an appropriate error
message is generate if the long double pack/unpack are used when
long double is IEEE 128.
* gcc.target/powerpc/pr85657-5.c: Likewise.
* gcc.target/powerpc/pr85657-6.c: Likewise.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797
Index: gcc/config/rs6000/rs6000-builtin.def
===
--- gcc/config/rs6000/rs6000-builtin.def(.../trunk) (revision 
260267)
+++ gcc/config/rs6000/rs6000-builtin.def(.../branches/ibm/ieee) 
(revision 260381)
@@ -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.  */
@@ -2315,6 +2326,9 @@ BU_P9_64BIT_MISC_0 (DARN, "darn", MISC
 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: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (.../trunk) (revision 260267)
+++ gcc/config/rs6000/rs6000.c  (.../branches/ibm/ieee) (revision 260381)
@@ -3891,7 +3891,8 @@ 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_IEEEQUAD)  ? RS6000_BTM_LDBL128   : 0)
  | ((TARGET_FLOAT128_TYPE) ? RS6000_BTM_FLOAT128  : 0)
  | ((TARGET_FLOAT128_HW)   ? RS6000_BTM_FLOAT128_HW : 0));
 }
@@ -15311,6 +15312,10 @@ rs6000_invalid_builtin (enum rs6000_buil
   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_LDBL128)
+  && (!TARGET_LONG_DOUBLE_128 || TARGET_IEEEQUAD))
+error ("builtin function %qs requires the %qs and %qs options",
+  name, "-mabi=ibmlongdouble", "-mlong-double-128");
   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",
Index: gcc/config/rs6000/rs6000.h

Re: [PATCH] Make __ibm128 a distinct type, patch 2 of 2 (PR 85657)

2018-05-21 Thread Segher Boessenkool
On Fri, May 18, 2018 at 07:27:15PM -0400, Michael Meissner wrote:
> Here is patch 2 of 2 to make __ibm128 a distinct type.  This patch makes the
> long double pack and unpack builtins only work if the long double type is IBM
> extended double.  It adds two new builtins to pack and unpack __ibm128 types.
> 
> This has been tested on a little endian power8 system with bootstrap and
> regression test (with the previous patch also applied).  Can I check this into
> the trunk and the GCC 8 branch?
> 
> [gcc]
> 2018-05-18  Michael Meissner  
> 
>   PR target/85657
>   * config/rs6000/rs6000-builtin.def (BU_IBM128_2): New helper macro
>   for __builtin_{,un}pack_ibm128.
>   (PACK_IF): Declare __builtin_{,un}pack_ibm128.
>   (UNPACK_IF): Likewise.
>   * config/rs6000/rs6000.c (rs6000_builtin_mask_calculate): The mask
>   for long double builtins (RS6000_BTM_LDBL128) requires that long
>   double is IBM extended double.
>   (rs6000_invalid_builtin): Add a new error message if the long
>   double {,un}pack builtins are used when long double is IEEE
>   128-bit floating point.
>   * config/rs6000/rs6000.h (RS6000_BTM_LDBL128): Update comment.
>   * doc/extend.texi (PowerPC builtins): Update documention for
>   __builtin_{,un}pack_longdouble.  Add documentation for
>   __builtin_{,un}pack_ibm128.
> 
> [gcc/testsuite]
> 2018-05-18  Michael Meissner  
> 
>   PR target/85657
>   * gcc.target/powerpc/pr85657-4.c: New tests for pack/unpack
>   __ibm128 builtin functions, and whether an appropriate error
>   message is generate if the long double pack/unpack are used when
>   long double is IEEE 128.
>   * gcc.target/powerpc/pr85657-5.c: Likewise.
>   * gcc.target/powerpc/pr85657-6.c: Likewise.

-ENOPATCH?


Segher


Re: [PATCH] Make __ibm128 a distinct type, patch 2 of 2 (PR 85657)

2018-05-18 Thread Michael Meissner
Here is patch 2 of 2 to make __ibm128 a distinct type.  This patch makes the
long double pack and unpack builtins only work if the long double type is IBM
extended double.  It adds two new builtins to pack and unpack __ibm128 types.

This has been tested on a little endian power8 system with bootstrap and
regression test (with the previous patch also applied).  Can I check this into
the trunk and the GCC 8 branch?

[gcc]
2018-05-18  Michael Meissner  

PR target/85657
* config/rs6000/rs6000-builtin.def (BU_IBM128_2): New helper macro
for __builtin_{,un}pack_ibm128.
(PACK_IF): Declare __builtin_{,un}pack_ibm128.
(UNPACK_IF): Likewise.
* config/rs6000/rs6000.c (rs6000_builtin_mask_calculate): The mask
for long double builtins (RS6000_BTM_LDBL128) requires that long
double is IBM extended double.
(rs6000_invalid_builtin): Add a new error message if the long
double {,un}pack builtins are used when long double is IEEE
128-bit floating point.
* config/rs6000/rs6000.h (RS6000_BTM_LDBL128): Update comment.
* doc/extend.texi (PowerPC builtins): Update documention for
__builtin_{,un}pack_longdouble.  Add documentation for
__builtin_{,un}pack_ibm128.

[gcc/testsuite]
2018-05-18  Michael Meissner  

PR target/85657
* gcc.target/powerpc/pr85657-4.c: New tests for pack/unpack
__ibm128 builtin functions, and whether an appropriate error
message is generate if the long double pack/unpack are used when
long double is IEEE 128.
* gcc.target/powerpc/pr85657-5.c: Likewise.
* gcc.target/powerpc/pr85657-6.c: Likewise.


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.ibm.com, phone: +1 (978) 899-4797