static void aarch64_update_cpp_builtins (cpp_reader *pfile) { aarch64_def_or_undef (flag_unsafe_math_optimizations, "__ARM_FP_FAST", pfile); builtin_define_with_int_value ("__ARM_ARCH", aarch64_architecture_version); builtin_define_with_int_value ("__ARM_SIZEOF_MINIMAL_ENUM", flag_short_enums ? 1 : 4); aarch64_def_or_undef (TARGET_BIG_END, "__AARCH64EB__", pfile); aarch64_def_or_undef (TARGET_BIG_END, "__ARM_BIG_ENDIAN", pfile); aarch64_def_or_undef (!TARGET_BIG_END, "__AARCH64EL__", pfile); aarch64_def_or_undef (TARGET_FLOAT, "__ARM_FEATURE_FMA", pfile); if (TARGET_FLOAT || TARGET_SIMD) { builtin_define_with_int_value ("__ARM_FP", 0x0E); builtin_define ("__ARM_FP16_FORMAT_IEEE"); builtin_define ("__ARM_FP16_ARGS"); } else cpp_undef (pfile, "__ARM_FP"); aarch64_def_or_undef (TARGET_SIMD, "__ARM_FEATURE_NUMERIC_MAXMIN", pfile); aarch64_def_or_undef (TARGET_SIMD, "__ARM_NEON", pfile); aarch64_def_or_undef (TARGET_CRC32, "__ARM_FEATURE_CRC32", pfile); cpp_undef (pfile, "__AARCH64_CMODEL_TINY__"); cpp_undef (pfile, "__AARCH64_CMODEL_SMALL__"); cpp_undef (pfile, "__AARCH64_CMODEL_LARGE__"); switch (aarch64_cmodel) { case AARCH64_CMODEL_TINY: case AARCH64_CMODEL_TINY_PIC: builtin_define ("__AARCH64_CMODEL_TINY__"); break; case AARCH64_CMODEL_SMALL: case AARCH64_CMODEL_SMALL_PIC: builtin_define ("__AARCH64_CMODEL_SMALL__"); break; case AARCH64_CMODEL_LARGE: builtin_define ("__AARCH64_CMODEL_LARGE__"); break; default: break; } aarch64_def_or_undef (TARGET_ILP32, "_ILP32", pfile); aarch64_def_or_undef (TARGET_ILP32, "__ILP32__", pfile); aarch64_def_or_undef (TARGET_CRYPTO, "__ARM_FEATURE_CRYPTO", pfile); }
static void def_or_undef_macro(struct cpp_reader* pfile, const char *name, bool def_p) { if (def_p) cpp_define (pfile, name); else cpp_undef (pfile, name); }
static void aarch64_def_or_undef (bool def_p, const char *macro, cpp_reader *pfile) { if (def_p) cpp_define (pfile, macro); else cpp_undef (pfile, macro); }
/* Internal function to either define or undef the appropriate system macros. */ static void 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__=10302", "__VEC__"); s390_def_or_undef_macro (pfile, 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"); { char macro_def[64]; gcc_assert (s390_arch != PROCESSOR_NATIVE); sprintf (macro_def, "__ARCH__=%d", processor_table[s390_arch].arch_level); cpp_undef (pfile, "__ARCH__"); cpp_define (pfile, macro_def); } if (!flag_iso) { s390_def_or_undef_macro (pfile, 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"); if (TARGET_ZVECTOR_P (opts->x_target_flags) && __vector_keyword == NULL) { __vector_keyword = get_identifier ("__vector"); C_CPP_HASHNODE (__vector_keyword)->flags |= NODE_CONDITIONAL; vector_keyword = get_identifier ("vector"); C_CPP_HASHNODE (vector_keyword)->flags |= NODE_CONDITIONAL; __bool_keyword = get_identifier ("__bool"); C_CPP_HASHNODE (__bool_keyword)->flags |= NODE_CONDITIONAL; bool_keyword = get_identifier ("bool"); C_CPP_HASHNODE (bool_keyword)->flags |= NODE_CONDITIONAL; _Bool_keyword = get_identifier ("_Bool"); C_CPP_HASHNODE (_Bool_keyword)->flags |= NODE_CONDITIONAL; /* Enable context-sensitive macros. */ cpp_get_callbacks (pfile)->macro_to_expand = s390_macro_to_expand; } } }
/* 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. */ static void s390_def_or_undef_macro (cpp_reader *pfile, unsigned int mask, 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; if (was_set == set) return; if (set) cpp_define (pfile, macro_def); else cpp_undef (pfile, macro_undef); }
/* Adjust the optimization macros when a #pragma GCC optimization is done to reflect the current level. */ void c_cpp_builtins_optimize_pragma (cpp_reader *pfile, tree prev_tree, tree cur_tree) { struct cl_optimization *prev = TREE_OPTIMIZATION (prev_tree); struct cl_optimization *cur = TREE_OPTIMIZATION (cur_tree); bool prev_fast_math; bool cur_fast_math; /* -undef turns off target-specific built-ins. */ if (flag_undef) return; /* Other target-independent built-ins determined by command-line options. */ if (!prev->x_optimize_size && cur->x_optimize_size) cpp_define (pfile, "__OPTIMIZE_SIZE__"); else if (prev->x_optimize_size && !cur->x_optimize_size) cpp_undef (pfile, "__OPTIMIZE_SIZE__"); if (!prev->x_optimize && cur->x_optimize) cpp_define (pfile, "__OPTIMIZE__"); else if (prev->x_optimize && !cur->x_optimize) cpp_undef (pfile, "__OPTIMIZE__"); prev_fast_math = fast_math_flags_struct_set_p (prev); cur_fast_math = fast_math_flags_struct_set_p (cur); if (!prev_fast_math && cur_fast_math) cpp_define (pfile, "__FAST_MATH__"); else if (prev_fast_math && !cur_fast_math) cpp_undef (pfile, "__FAST_MATH__"); if (!prev->x_flag_signaling_nans && cur->x_flag_signaling_nans) cpp_define (pfile, "__SUPPORT_SNAN__"); else if (prev->x_flag_signaling_nans && !cur->x_flag_signaling_nans) cpp_undef (pfile, "__SUPPORT_SNAN__"); if (!prev->x_flag_finite_math_only && cur->x_flag_finite_math_only) { cpp_undef (pfile, "__FINITE_MATH_ONLY__"); cpp_define (pfile, "__FINITE_MATH_ONLY__=1"); } else if (prev->x_flag_finite_math_only && !cur->x_flag_finite_math_only) { cpp_undef (pfile, "__FINITE_MATH_ONLY__"); cpp_define (pfile, "__FINITE_MATH_ONLY__=0"); } }
static void arm_cpu_builtins (struct cpp_reader* pfile) { def_or_undef_macro (pfile, "__ARM_FEATURE_DSP", TARGET_DSP_MULTIPLY); def_or_undef_macro (pfile, "__ARM_FEATURE_QBIT", TARGET_ARM_QBIT); def_or_undef_macro (pfile, "__ARM_FEATURE_SAT", TARGET_ARM_SAT); def_or_undef_macro (pfile, "__ARM_FEATURE_CRYPTO", TARGET_CRYPTO); def_or_undef_macro (pfile, "__ARM_FEATURE_UNALIGNED", unaligned_access); def_or_undef_macro (pfile, "__ARM_FEATURE_QRDMX", TARGET_NEON_RDMA); if (TARGET_CRC32) builtin_define ("__ARM_FEATURE_CRC32"); def_or_undef_macro (pfile, "__ARM_32BIT_STATE", TARGET_32BIT); if (TARGET_ARM_FEATURE_LDREX) builtin_define_with_int_value ("__ARM_FEATURE_LDREX", TARGET_ARM_FEATURE_LDREX); else cpp_undef (pfile, "__ARM_FEATURE_LDREX"); def_or_undef_macro (pfile, "__ARM_FEATURE_CLZ", ((TARGET_ARM_ARCH >= 5 && !TARGET_THUMB) || TARGET_ARM_ARCH_ISA_THUMB >=2)); def_or_undef_macro (pfile, "__ARM_FEATURE_NUMERIC_MAXMIN", TARGET_ARM_ARCH >= 8 && TARGET_NEON && TARGET_FPU_ARMV8); def_or_undef_macro (pfile, "__ARM_FEATURE_SIMD32", TARGET_INT_SIMD); builtin_define_with_int_value ("__ARM_SIZEOF_MINIMAL_ENUM", flag_short_enums ? 1 : 4); builtin_define_type_sizeof ("__ARM_SIZEOF_WCHAR_T", wchar_type_node); if (TARGET_ARM_ARCH_PROFILE) builtin_define_with_int_value ("__ARM_ARCH_PROFILE", TARGET_ARM_ARCH_PROFILE); /* Define __arm__ even when in thumb mode, for consistency with armcc. */ builtin_define ("__arm__"); if (TARGET_ARM_ARCH) builtin_define_with_int_value ("__ARM_ARCH", TARGET_ARM_ARCH); if (arm_arch_notm) builtin_define ("__ARM_ARCH_ISA_ARM"); builtin_define ("__APCS_32__"); def_or_undef_macro (pfile, "__thumb__", TARGET_THUMB); def_or_undef_macro (pfile, "__thumb2__", TARGET_THUMB2); if (TARGET_BIG_END) def_or_undef_macro (pfile, "__THUMBEB__", TARGET_THUMB); else def_or_undef_macro (pfile, "__THUMBEL__", TARGET_THUMB); if (TARGET_ARM_ARCH_ISA_THUMB) builtin_define_with_int_value ("__ARM_ARCH_ISA_THUMB", TARGET_ARM_ARCH_ISA_THUMB); if (TARGET_BIG_END) { builtin_define ("__ARMEB__"); builtin_define ("__ARM_BIG_ENDIAN"); } else { builtin_define ("__ARMEL__"); } if (TARGET_SOFT_FLOAT) builtin_define ("__SOFTFP__"); builtin_define ("__VFP_FP__"); if (TARGET_ARM_FP) builtin_define_with_int_value ("__ARM_FP", TARGET_ARM_FP); else cpp_undef (pfile, "__ARM_FP"); def_or_undef_macro (pfile, "__ARM_FP16_FORMAT_IEEE", arm_fp16_format == ARM_FP16_FORMAT_IEEE); def_or_undef_macro (pfile, "__ARM_FP16_FORMAT_ALTERNATIVE", arm_fp16_format == ARM_FP16_FORMAT_ALTERNATIVE); def_or_undef_macro (pfile, "__ARM_FP16_ARGS", arm_fp16_format != ARM_FP16_FORMAT_NONE); def_or_undef_macro (pfile, "__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", TARGET_VFP_FP16INST); def_or_undef_macro (pfile, "__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", TARGET_NEON_FP16INST); def_or_undef_macro (pfile, "__ARM_FEATURE_FMA", TARGET_FMA); def_or_undef_macro (pfile, "__ARM_NEON__", TARGET_NEON); def_or_undef_macro (pfile, "__ARM_NEON", TARGET_NEON); if (TARGET_NEON_FP) builtin_define_with_int_value ("__ARM_NEON_FP", TARGET_NEON_FP); else cpp_undef (pfile, "__ARM_NEON_FP"); /* Add a define for interworking. Needed when building libgcc.a. */ if (arm_cpp_interwork) builtin_define ("__THUMB_INTERWORK__"); builtin_define (arm_arch_name); if (arm_arch_xscale) builtin_define ("__XSCALE__"); if (arm_arch_iwmmxt) { builtin_define ("__IWMMXT__"); builtin_define ("__ARM_WMMX"); } if (arm_arch_iwmmxt2) builtin_define ("__IWMMXT2__"); /* ARMv6KZ was originally identified as the misspelled __ARM_ARCH_6ZK__. To preserve the existing behavior, the misspelled feature macro must still be defined. */ if (arm_arch6kz) builtin_define ("__ARM_ARCH_6ZK__"); if (TARGET_AAPCS_BASED) { if (arm_pcs_default == ARM_PCS_AAPCS_VFP) builtin_define ("__ARM_PCS_VFP"); else if (arm_pcs_default == ARM_PCS_AAPCS) builtin_define ("__ARM_PCS"); builtin_define ("__ARM_EABI__"); } def_or_undef_macro (pfile, "__ARM_ARCH_EXT_IDIV__", TARGET_IDIV); def_or_undef_macro (pfile, "__ARM_FEATURE_IDIV", TARGET_IDIV); def_or_undef_macro (pfile, "__ARM_ASM_SYNTAX_UNIFIED__", inline_asm_unified); }
/* Hook to validate the current #pragma GCC target and set the arch custom mode state. If ARGS is NULL, then POP_TARGET is used to reset the options. */ static bool arm_pragma_target_parse (tree args, tree pop_target) { tree prev_tree = build_target_option_node (&global_options); tree cur_tree; struct cl_target_option *prev_opt; struct cl_target_option *cur_opt; if (! args) { cur_tree = ((pop_target) ? pop_target : target_option_default_node); cl_target_option_restore (&global_options, TREE_TARGET_OPTION (cur_tree)); } else { cur_tree = arm_valid_target_attribute_tree (args, &global_options, &global_options_set); if (cur_tree == NULL_TREE) { cl_target_option_restore (&global_options, TREE_TARGET_OPTION (prev_tree)); return false; } } target_option_current_node = cur_tree; arm_reset_previous_fndecl (); /* Figure out the previous mode. */ prev_opt = TREE_TARGET_OPTION (prev_tree); cur_opt = TREE_TARGET_OPTION (cur_tree); gcc_assert (prev_opt); gcc_assert (cur_opt); if (cur_opt != prev_opt) { /* For the definitions, ensure all newly defined macros are considered as used for -Wunused-macros. There is no point warning about the compiler predefined macros. */ cpp_options *cpp_opts = cpp_get_options (parse_in); unsigned char saved_warn_unused_macros = cpp_opts->warn_unused_macros; unsigned char saved_warn_builtin_macro_redefined = cpp_opts->warn_builtin_macro_redefined; cpp_opts->warn_unused_macros = 0; cpp_opts->warn_builtin_macro_redefined = 0; /* Update macros. */ gcc_assert (cur_opt->x_target_flags == target_flags); /* This one can be redefined by the pragma without warning. */ cpp_undef (parse_in, "__ARM_FP"); arm_cpu_builtins (parse_in); cpp_opts->warn_builtin_macro_redefined = saved_warn_builtin_macro_redefined; cpp_opts->warn_unused_macros = saved_warn_unused_macros; } return true; }