/* 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)
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)
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
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);
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");