Re: [PATCH] Predefine __SIZEOF_{FPREG,FLOAT{80,128}}__ on ia64 (PR target/56540)

2018-03-02 Thread Jeff Law
On 03/02/2018 08:04 AM, Jakub Jelinek wrote:
> Hi!
> 
> GCC predefines __SIZEOF_*__ macros for the types it provides, so that
> 1) one can easily test if those types are available
> 2) can use it even in places where sizeof is not usable, like preprocessor
>conditionals
> Unfortunately, this isn't done for target types that the middle-end doesn't
> know about.  On x86 __SIZEOF_FLOAT128__=16 and __SIZEOF_FLOAT80__={16,12}
> are already predefined.  For consistency and above reasons it would be nice
> to do the same on ia64, hppa and powerpc* too.
> 
> Tested with a cross to ia64 on the testcase, ok for trunk?
> 
> 2018-03-02  Jakub Jelinek  
> 
>   PR target/56540
>   * config/ia64/ia64.h (TARGET_CPU_CPP_BUILTINS): Predefine
>   __SIZEOF_{FPREG,FLOAT{80,128}}__ macros.
> 
>   * gcc.target/ia64/pr56540.c: New test.
OK.
jeff


[PATCH] Predefine __SIZEOF_{FPREG,FLOAT{80,128}}__ on ia64 (PR target/56540)

2018-03-02 Thread Jakub Jelinek
Hi!

GCC predefines __SIZEOF_*__ macros for the types it provides, so that
1) one can easily test if those types are available
2) can use it even in places where sizeof is not usable, like preprocessor
   conditionals
Unfortunately, this isn't done for target types that the middle-end doesn't
know about.  On x86 __SIZEOF_FLOAT128__=16 and __SIZEOF_FLOAT80__={16,12}
are already predefined.  For consistency and above reasons it would be nice
to do the same on ia64, hppa and powerpc* too.

Tested with a cross to ia64 on the testcase, ok for trunk?

2018-03-02  Jakub Jelinek  

PR target/56540
* config/ia64/ia64.h (TARGET_CPU_CPP_BUILTINS): Predefine
__SIZEOF_{FPREG,FLOAT{80,128}}__ macros.

* gcc.target/ia64/pr56540.c: New test.

--- gcc/config/ia64/ia64.h.jj   2018-01-03 10:20:09.144536194 +0100
+++ gcc/config/ia64/ia64.h  2018-03-02 15:12:44.006654878 +0100
@@ -38,6 +38,9 @@ do {  \
builtin_define("__itanium__");  \
if (TARGET_BIG_ENDIAN)  \
  builtin_define("__BIG_ENDIAN__"); \
+   builtin_define("__SIZEOF_FPREG__=16");  \
+   builtin_define("__SIZEOF_FLOAT80__=16");\
+   builtin_define("__SIZEOF_FLOAT128__=16");\
 } while (0)
 
 #ifndef SUBTARGET_EXTRA_SPECS
--- gcc/testsuite/gcc.target/ia64/pr56540.c.jj  2018-03-02 15:28:20.464781858 
+0100
+++ gcc/testsuite/gcc.target/ia64/pr56540.c 2018-03-02 15:30:12.728813200 
+0100
@@ -0,0 +1,6 @@
+/* PR target/56540 */
+/* { dg-do compile } */
+
+extern int a[__SIZEOF_FPREG__ != sizeof (__fpreg) ? -1 : 1];
+extern int b[__SIZEOF_FLOAT80__ != sizeof (__float80) ? -1 : 1];
+extern int c[__SIZEOF_FLOAT128__ != sizeof (__float128) ? -1 : 1];

Jakub