aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMichael Meissner <meissner@linux.vnet.ibm.com>2017-10-31 18:56:05 +0000
committerMichael Meissner <meissner@gcc.gnu.org>2017-10-31 18:56:05 +0000
commitc67624232a1cb16a99497605dde681eee711dbbd (patch)
treeba35a870ef34fc78dab1cf19295e5566bcebb694 /gcc
parent6ff16d19d26a41cd7abb01e858529fae54de746a (diff)
downloadgcc-c67624232a1cb16a99497605dde681eee711dbbd.zip
gcc-c67624232a1cb16a99497605dde681eee711dbbd.tar.gz
gcc-c67624232a1cb16a99497605dde681eee711dbbd.tar.bz2
builtins.def (DEF_FLOATN_BUILTIN): Change most _Float<N> and _Float<N>X built-in functions so that the variant...
2017-10-31 Michael Meissner <meissner@linux.vnet.ibm.com> * builtins.def (DEF_FLOATN_BUILTIN): Change most _Float<N> and _Float<N>X built-in functions so that the variant without the "__builtin_" prefix is only enabled for the GNU C and Objective C languages when they are in non-strict ANSI/ISO mode. (DEF_EXT_LIB_FLOATN_NX_BUILTINS): Likewise. * target.def (floatn_builtin_p): Add a target hook to control whether _Float<N> and _Float<N>X built-in functions without the "__builtin_" prefix are enabled, and return true for C and Objective C in the default hook. Include langhooks.h in targhooks.c. * targhooks.h (default_floatn_builtin_p): Likewise. * targhooks.c (default_floatn_builtin_p): Likewise. * doc/tm.texi.in (TARGET_FLOATN_BUILTIN_P): Document the floatn_builtin_p target hook. * doc/tm.texi (TARGET_FLOATN_BUILTIN_P): Likewise. From-SVN: r254277
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog18
-rw-r--r--gcc/builtins.def30
-rw-r--r--gcc/doc/tm.texi11
-rw-r--r--gcc/doc/tm.texi.in2
-rw-r--r--gcc/target.def13
-rw-r--r--gcc/targhooks.c24
-rw-r--r--gcc/targhooks.h1
7 files changed, 87 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b73c5c6..0c059e5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,21 @@
+2017-10-31 Michael Meissner <meissner@linux.vnet.ibm.com>
+
+ * builtins.def (DEF_FLOATN_BUILTIN): Change most _Float<N> and
+ _Float<N>X built-in functions so that the variant without the
+ "__builtin_" prefix is only enabled for the GNU C and Objective C
+ languages when they are in non-strict ANSI/ISO mode.
+ (DEF_EXT_LIB_FLOATN_NX_BUILTINS): Likewise.
+ * target.def (floatn_builtin_p): Add a target hook to control
+ whether _Float<N> and _Float<N>X built-in functions without the
+ "__builtin_" prefix are enabled, and return true for C and
+ Objective C in the default hook. Include langhooks.h in
+ targhooks.c.
+ * targhooks.h (default_floatn_builtin_p): Likewise.
+ * targhooks.c (default_floatn_builtin_p): Likewise.
+ * doc/tm.texi.in (TARGET_FLOATN_BUILTIN_P): Document the
+ floatn_builtin_p target hook.
+ * doc/tm.texi (TARGET_FLOATN_BUILTIN_P): Likewise.
+
2017-10-31 Matthew Fortune <matthew.fortune@imgtec.com>
Eric Botcazou <ebotcazou@adacore.com>
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 1434f07..26118f1 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -130,18 +130,26 @@ along with GCC; see the file COPYING3. If not see
/* A set of GCC builtins for _FloatN and _FloatNx types. TYPE_MACRO is called
with an argument such as FLOAT32 to produce the enum value for the type. If
- we are being fully conformant we ignore the version of these builtins that
- does not being with __builtin_. */
+ we are compiling for the C language with GNU extensions, we enable the name
+ without the __builtin_ prefix as well as the name with the __builtin_
+ prefix. C++ does not enable these names by default because they don't have
+ the _Float<N> and _Float<N>X keywords, and a class based library should use
+ the __builtin_ names. */
+#undef DEF_FLOATN_BUILTIN
+#define DEF_FLOATN_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
+ DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
+ targetm.floatn_builtin_p ((int) ENUM), true, true, ATTRS, \
+ false, true)
#undef DEF_EXT_LIB_FLOATN_NX_BUILTINS
-#define DEF_EXT_LIB_FLOATN_NX_BUILTINS(ENUM, NAME, TYPE_MACRO, ATTRS) \
- DEF_EXT_LIB_BUILTIN (ENUM ## F16, NAME "f16", TYPE_MACRO (FLOAT16), ATTRS) \
- DEF_EXT_LIB_BUILTIN (ENUM ## F32, NAME "f32", TYPE_MACRO (FLOAT32), ATTRS) \
- DEF_EXT_LIB_BUILTIN (ENUM ## F64, NAME "f64", TYPE_MACRO (FLOAT64), ATTRS) \
- DEF_EXT_LIB_BUILTIN (ENUM ## F128, NAME "f128", TYPE_MACRO (FLOAT128), ATTRS)\
- DEF_EXT_LIB_BUILTIN (ENUM ## F32X, NAME "f32x", TYPE_MACRO (FLOAT32X), ATTRS)\
- DEF_EXT_LIB_BUILTIN (ENUM ## F64X, NAME "f64x", TYPE_MACRO (FLOAT64X), ATTRS)\
- DEF_EXT_LIB_BUILTIN (ENUM ## F128X, NAME "f128x", TYPE_MACRO (FLOAT128X), \
- ATTRS)
+#define DEF_EXT_LIB_FLOATN_NX_BUILTINS(ENUM, NAME, TYPE_MACRO, ATTRS) \
+ DEF_FLOATN_BUILTIN (ENUM ## F16, NAME "f16", TYPE_MACRO (FLOAT16), ATTRS) \
+ DEF_FLOATN_BUILTIN (ENUM ## F32, NAME "f32", TYPE_MACRO (FLOAT32), ATTRS) \
+ DEF_FLOATN_BUILTIN (ENUM ## F64, NAME "f64", TYPE_MACRO (FLOAT64), ATTRS) \
+ DEF_FLOATN_BUILTIN (ENUM ## F128, NAME "f128", TYPE_MACRO (FLOAT128), ATTRS) \
+ DEF_FLOATN_BUILTIN (ENUM ## F32X, NAME "f32x", TYPE_MACRO (FLOAT32X), ATTRS) \
+ DEF_FLOATN_BUILTIN (ENUM ## F64X, NAME "f64x", TYPE_MACRO (FLOAT64X), ATTRS) \
+ DEF_FLOATN_BUILTIN (ENUM ## F128X, NAME "f128x", TYPE_MACRO (FLOAT128X), \
+ ATTRS)
/* Like DEF_LIB_BUILTIN, except that the function is only a part of
the standard in C94 or above. */
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index be8b362..cba3fa6 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -4284,6 +4284,17 @@ ISO/IEC TS 18661-3:2015; that is, @var{n} is one of 32, 64, 128, or,
if @var{extended} is false, 16 or greater than 128 and a multiple of 32.
@end deftypefn
+@deftypefn {Target Hook} bool TARGET_FLOATN_BUILTIN_P (int @var{func})
+Define this to return true if the @code{_Float@var{n}} and
+@code{_Float@var{n}x} built-in functions should implicitly enable the
+built-in function without the @code{__builtin_} prefix in addition to the
+normal built-in function with the @code{__builtin_} prefix. The default is
+to only enable built-in functions without the @code{__builtin_} prefix for
+the GNU C langauge. In strict ANSI/ISO mode, the built-in function without
+the @code{__builtin_} prefix is not enabled. The argument @code{FUNC} is the
+@code{enum built_in_function} id of the function to be enabled.
+@end deftypefn
+
@deftypefn {Target Hook} bool TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P (machine_mode @var{mode})
Define this to return nonzero for machine modes for which the port has
small register classes. If this target hook returns nonzero for a given
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index d433e3a..e7d4ada 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3326,6 +3326,8 @@ stack.
@hook TARGET_FLOATN_MODE
+@hook TARGET_FLOATN_BUILTIN_P
+
@hook TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P
@node Scalar Return
diff --git a/gcc/target.def b/gcc/target.def
index 7bddb8b..65a415e 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -3458,6 +3458,19 @@ if @var{extended} is false, 16 or greater than 128 and a multiple of 32.",
opt_scalar_float_mode, (int n, bool extended),
default_floatn_mode)
+DEFHOOK
+(floatn_builtin_p,
+ "Define this to return true if the @code{_Float@var{n}} and\n\
+@code{_Float@var{n}x} built-in functions should implicitly enable the\n\
+built-in function without the @code{__builtin_} prefix in addition to the\n\
+normal built-in function with the @code{__builtin_} prefix. The default is\n\
+to only enable built-in functions without the @code{__builtin_} prefix for\n\
+the GNU C langauge. In strict ANSI/ISO mode, the built-in function without\n\
+the @code{__builtin_} prefix is not enabled. The argument @code{FUNC} is the\n\
+@code{enum built_in_function} id of the function to be enabled.",
+ bool, (int func),
+ default_floatn_builtin_p)
+
/* Compute cost of moving data from a register of class FROM to one of
TO, using MODE. */
DEFHOOK
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 92ecc90..b545bbb 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -81,7 +81,7 @@ along with GCC; see the file COPYING3. If not see
#include "predict.h"
#include "params.h"
#include "real.h"
-
+#include "langhooks.h"
bool
default_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED,
@@ -563,6 +563,28 @@ default_floatn_mode (int n, bool extended)
return opt_scalar_float_mode ();
}
+/* Define this to return true if the _Floatn and _Floatnx built-in functions
+ should implicitly enable the built-in function without the __builtin_ prefix
+ in addition to the normal built-in function with the __builtin_ prefix. The
+ default is to only enable built-in functions without the __builtin_ prefix
+ for the GNU C langauge. The argument FUNC is the enum builtin_in_function
+ id of the function to be enabled. */
+
+bool
+default_floatn_builtin_p (int func ATTRIBUTE_UNUSED)
+{
+ static bool first_time_p = true;
+ static bool c_or_objective_c;
+
+ if (first_time_p)
+ {
+ first_time_p = false;
+ c_or_objective_c = lang_GNU_C () || lang_GNU_OBJC ();
+ }
+
+ return c_or_objective_c;
+}
+
/* Make some target macros useable by target-independent code. */
bool
targhook_words_big_endian (void)
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index f60bca2..8686204 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -75,6 +75,7 @@ extern tree default_mangle_assembler_name (const char *);
extern bool default_scalar_mode_supported_p (scalar_mode);
extern bool default_libgcc_floating_mode_supported_p (scalar_float_mode);
extern opt_scalar_float_mode default_floatn_mode (int, bool);
+extern bool default_floatn_builtin_p (int);
extern bool targhook_words_big_endian (void);
extern bool targhook_float_words_big_endian (void);
extern bool default_float_exceptions_rounding_supported_p (void);