aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/config/s390/s390-c.c59
-rw-r--r--gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-off-on.c11
-rw-r--r--gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-on-off.c11
3 files changed, 60 insertions, 21 deletions
diff --git a/gcc/config/s390/s390-c.c b/gcc/config/s390/s390-c.c
index 95cd2df..a5f5f56 100644
--- a/gcc/config/s390/s390-c.c
+++ b/gcc/config/s390/s390-c.c
@@ -294,9 +294,9 @@ s390_macro_to_expand (cpp_reader *pfile, const cpp_token *tok)
/* Helper function that defines or undefines macros. If SET is true, the macro
MACRO_DEF is defined. If SET is false, the macro MACRO_UNDEF is undefined.
Nothing is done if SET and WAS_SET have the same value. */
+template <typename F>
static void
-s390_def_or_undef_macro (cpp_reader *pfile,
- unsigned int mask,
+s390_def_or_undef_macro (cpp_reader *pfile, F is_set,
const struct cl_target_option *old_opts,
const struct cl_target_option *new_opts,
const char *macro_def, const char *macro_undef)
@@ -304,8 +304,8 @@ s390_def_or_undef_macro (cpp_reader *pfile,
bool was_set;
bool set;
- was_set = (!old_opts) ? false : old_opts->x_target_flags & mask;
- set = new_opts->x_target_flags & mask;
+ was_set = (!old_opts) ? false : is_set (old_opts);
+ set = is_set (new_opts);
if (was_set == set)
return;
if (set)
@@ -314,6 +314,19 @@ s390_def_or_undef_macro (cpp_reader *pfile,
cpp_undef (pfile, macro_undef);
}
+struct target_flag_set_p
+{
+ target_flag_set_p (unsigned int mask) : m_mask (mask) {}
+
+ bool
+ operator() (const struct cl_target_option *opts) const
+ {
+ return opts->x_target_flags & m_mask;
+ }
+
+ unsigned int m_mask;
+};
+
/* Internal function to either define or undef the appropriate system
macros. */
static void
@@ -321,18 +334,18 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
struct cl_target_option *opts,
const struct cl_target_option *old_opts)
{
- s390_def_or_undef_macro (pfile, MASK_OPT_HTM, old_opts, opts,
- "__HTM__", "__HTM__");
- s390_def_or_undef_macro (pfile, MASK_OPT_VX, old_opts, opts,
- "__VX__", "__VX__");
- s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
- "__VEC__=10303", "__VEC__");
- s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
- "__vector=__attribute__((vector_size(16)))",
+ s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_OPT_HTM), old_opts,
+ opts, "__HTM__", "__HTM__");
+ s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_OPT_VX), old_opts,
+ opts, "__VX__", "__VX__");
+ s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_ZVECTOR), old_opts,
+ opts, "__VEC__=10303", "__VEC__");
+ s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_ZVECTOR), old_opts,
+ opts, "__vector=__attribute__((vector_size(16)))",
"__vector__");
- s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
- "__bool=__attribute__((s390_vector_bool)) unsigned",
- "__bool");
+ s390_def_or_undef_macro (
+ pfile, target_flag_set_p (MASK_ZVECTOR), old_opts, opts,
+ "__bool=__attribute__((s390_vector_bool)) unsigned", "__bool");
{
char macro_def[64];
gcc_assert (s390_arch != PROCESSOR_NATIVE);
@@ -340,16 +353,20 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
cpp_undef (pfile, "__ARCH__");
cpp_define (pfile, macro_def);
}
+ s390_def_or_undef_macro (
+ pfile,
+ [] (const struct cl_target_option *opts) { return TARGET_VXE_P (opts); },
+ old_opts, opts, "__LONG_DOUBLE_VX__", "__LONG_DOUBLE_VX__");
if (!flag_iso)
{
- s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
- "__VECTOR_KEYWORD_SUPPORTED__",
+ s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_ZVECTOR),
+ old_opts, opts, "__VECTOR_KEYWORD_SUPPORTED__",
"__VECTOR_KEYWORD_SUPPORTED__");
- s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
- "vector=vector", "vector");
- s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
- "bool=bool", "bool");
+ s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_ZVECTOR),
+ old_opts, opts, "vector=vector", "vector");
+ s390_def_or_undef_macro (pfile, target_flag_set_p (MASK_ZVECTOR),
+ old_opts, opts, "bool=bool", "bool");
if (TARGET_ZVECTOR_P (opts->x_target_flags) && __vector_keyword == NULL)
{
__vector_keyword = get_identifier ("__vector");
diff --git a/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-off-on.c b/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-off-on.c
new file mode 100644
index 0000000..2d67679
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-off-on.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target target_attribute } */
+/* { dg-options "-march=z14" } */
+#if !defined(__LONG_DOUBLE_VX__)
+#error
+#endif
+
+#pragma GCC target("arch=zEC12")
+#if defined(__LONG_DOUBLE_VX__)
+#error
+#endif
diff --git a/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-on-off.c b/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-on-off.c
new file mode 100644
index 0000000..6f26431
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/vector/long-double-vx-macro-on-off.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target target_attribute } */
+/* { dg-options "-march=z13" } */
+#if defined(__LONG_DOUBLE_VX__)
+#error
+#endif
+
+#pragma GCC target("arch=z15")
+#if !defined(__LONG_DOUBLE_VX__)
+#error
+#endif