This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Predefine __SIZEOF_{FPREG,FLOAT{80,128}}__ on ia64 (PR target/56540)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jim Wilson <jimw at sifive dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Marc Glisse <marc dot glisse at inria dot fr>
- Date: Fri, 2 Mar 2018 16:04:09 +0100
- Subject: [PATCH] Predefine __SIZEOF_{FPREG,FLOAT{80,128}}__ on ia64 (PR target/56540)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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 <jakub@redhat.com>
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