re PR target/57756 (Function target attribute is retaining state of previously seen function)

PR target/57756

The root-cause of this PR is that global_options is not restored to
default before calling ix86_valid_target_attribute_tree and hence
target attributes are incorrectly processed sometimes.

This patch refactors code in i386.c in functions in the call-chain of 
ix86_valid_target_attribute_tree to use any gcc_options struct passed
as a parameter. It replaces existing code which always uses the
global_options struct.

2013-10-15 Sriraman Tallam  <tmsriram@google.com>

	PR target/57756
	* optc-save-gen.awk: Add extra parameter to the save and restore
	target calls.
	* opth-gen.awk: Generate new TARGET_* macros  to accept a parameter.
	* tree.c (build_optimization_node): New parameter.  Add extra parameter
	to call to cl_optimization_save.
	(build_target_option_node): New parameter. Add extra parameter
	to call to cl_target_option_save.
	* tree.h (build_optimization_node): New parameter.
	(build_target_option_node): New parameter.
	* c-family/c-common.c (handle_optimize_attribute): Fix calls to
	build_optimization_node and build_target_option_node.
	* c-family/c-pragma.c (handle_pragma_optimize): Ditto.
	(handle_pragma_push_options): Ditto.
	* toplev.c (process_options): Ditto.
	* opts.c (init_options_struct): Check for opts_set non-null.
	* target.def (target_option.save): New parameter.
	(target_option.restore): New parameter.
	* tm.texi: Generate.
	* config/i386/i386-c.c (ix86_target_macros_internal): Ditto.
	(ix86_pragma_target_parse): Ditto.
	* config/i386/i386-protos.h (ix86_valid_target_attribute_tree): New
	parameters.
	* config/rs6000/rs6000.c (rs6000_option_override_internal): Fix calls
	to  build_optimization_node and build_target_option_node.
	(rs6000_valid_attribute_p): Ditto.
	(rs6000_pragma_target_parse): Ditto.
	* config/i386/i386.opt (x_ix86_target_flags_explicit): New TargetSave
	data.
	* config/i386/i386.h:
	TARGET_64BIT_P: New Macro
	TARGET_MMX_P: New Macro.
	TARGET_3DNOW_P: New Macro.
	TARGET_3DNOW_A_P: New Macro.
	TARGET_SSE_P: New Macro.
	TARGET_SSE2_P: New Macro.
	TARGET_SSE3_P: New Macro.
	TARGET_SSSE3_P: New Macro.
	TARGET_SSE4_1_P: New Macro.
	TARGET_SSE4_2_P: New Macro.
	TARGET_AVX_P: New Macro.
	TARGET_AVX2_P: New Macro.
	TARGET_AVX512F_P: New Macro.
	TARGET_AVX512PF_P: New Macro.
	TARGET_AVX512ER_P: New Macro.
	TARGET_AVX512CD_P: New Macro.
	TARGET_FMA_P: New Macro.
	TARGET_SSE4A_P: New Macro.
	TARGET_FMA4_P: New Macro.
	TARGET_XOP_P: New Macro.
	TARGET_LWP_P: New Macro.
	TARGET_ABM_P: New Macro.
	TARGET_BMI_P: New Macro.
	TARGET_BMI2_P: New Macro.
	TARGET_LZCNT_P: New Macro.
	TARGET_TBM_P: New Macro.
	TARGET_POPCNT_P: New Macro.
	TARGET_SAHF_P: New Macro.
	TARGET_MOVBE_P: New Macro.
	TARGET_CRC32_P: New Macro.
	TARGET_AES_P: New Macro.
	TARGET_PCLMUL_P: New Macro.
	TARGET_CMPXCHG16B_P: New Macro.
	TARGET_FSGSBASE_P: New Macro.
	TARGET_RDRND_P: New Macro.
	TARGET_F16C_P: New Macro.
	TARGET_RTM_P: New Macro.
	TARGET_HLE_P: New Macro.
	TARGET_RDSEED_P: New Macro.
	TARGET_PRFCHW_P: New Macro.
	TARGET_ADX_P: New Macro.
	TARGET_FXSR_P: New Macro.
	TARGET_XSAVE_P: New Macro.
	TARGET_XSAVEOPT_P: New Macro.
	TARGET_LP64_P: New Macro.
	TARGET_X32_P: New Macro.
	TARGET_FPMATH_DEFAULT_P: New Macro.
	TARGET_FLOAT_RETURNS_IN_80387_P: New Macro.
	* config/i386/i386.c (ix86_option_override_internal): New parameters.
	opts and opts_set.
	Change ix86_tune_string to access opts->x_ix86_tune_string.
	Change ix86_isa_flags to access opts->x_ix86_isa_flags.
	Change ix86_arch_string to access opts->x_ix86_arch_string.
	Change ix86_stringop_alg to access opts->x_ix86_stringop_alg.
	Change ix86_pmode to access opts->x_ix86_pmode.
	Change ix86_abi to access opts->x_ix86_abi.
	Change ix86_cmodel to access opts->x_ix86_cmodel.
	Change ix86_asm_dialect to access opts->x_ix86_asm_dialect.
	Change ix86_isa_flags_explicit to access
	opts->x_ix86_isa_flags_explicit.
	Change ix86_dump_tunes to access opts->x_ix86_dump_tunes.
	Change ix86_regparm to access opts->x_ix86_regparm.
	Change ix86_branch_cost to access opts->x_ix86_branch_cost.
	Change ix86_preferred_stack_boundary_arg to access
	opts->x_ix86_preferred_stack_boundary_arg.
	Change ix86_force_align_arg_pointer to access
	opts->x_ix86_force_align_arg_pointer.
	Change ix86_incoming_stack_boundar_arg to access
	opts->x_ix86_incoming_stack_boundar_arg.
	Change ix86_fpmath to access opts->x_ix86_fpmath.
	Change ix86_veclibabi_type to access opts->x_ix86_veclibabi_type.
	Change ix86_recip_name to access opts->x_ix86_recip_name.
	Change ix86_stack_protector_guard to access
	opts->x_ix86_stack_protector_guard.
	Change ix86_tune_memcpy_strategy to access
	opts->x_ix86_tune_memcpy_strategy.
	Change ix86_tune_memset_strategy to access
	opts->x_ix86_tune_memset_strategy.
	Change global_options to access opts.
	Change global_options_set to access opts_set.
        Change TARGET_64BIT to TARGET_64BIT_P (opts->...)
        Change TARGET_MMX to TARGET_MMX_P (opts->...)
        Change TARGET_3DNOW to TARGET_3DNOW_P (opts->...)
        Change TARGET_3DNOW_A to TARGET_3DNOW_A_P (opts->...)
        Change TARGET_SSE to TARGET_SSE_P (opts->...)
        Change TARGET_SSE2 to TARGET_SSE2_P (opts->...)
        Change TARGET_SSE3 to TARGET_SSE3_P (opts->...)
        Change TARGET_SSSE3 to TARGET_SSSE3_P (opts->...)
        Change TARGET_SSE4_1 to TARGET_SSE4_1_P (opts->...)
        Change TARGET_SSE4_2 to TARGET_SSE4_2_P (opts->...)
        Change TARGET_AVX to TARGET_AVX_P (opts->...)
        Change TARGET_AVX2 to TARGET_AVX2_P (opts->...)
        Change TARGET_AVX512F to TARGET_AVX512F_P (opts->...)
        Change TARGET_AVX512PF to TARGET_AVX512PF_P (opts->...)
        Change TARGET_AVX512ER to TARGET_AVX512ER_P (opts->...)
        Change TARGET_AVX512CD to TARGET_AVX512CD_P (opts->...)
        Change TARGET_FMA to TARGET_FMA_P (opts->...)
        Change TARGET_SSE4A to TARGET_SSE4A_P (opts->...)
        Change TARGET_FMA4 to TARGET_FMA4_P (opts->...)
        Change TARGET_XOP to TARGET_XOP_P (opts->...)
        Change TARGET_LWP to TARGET_LWP_P (opts->...)
        Change TARGET_ABM to TARGET_ABM_P (opts->...)
        Change TARGET_BMI to TARGET_BMI_P (opts->...)
        Change TARGET_BMI2 to TARGET_BMI2_P (opts->...)
        Change TARGET_LZCNT to TARGET_LZCNT_P (opts->...)
        Change TARGET_TBM to TARGET_TBM_P (opts->...)
        Change TARGET_POPCNT to TARGET_POPCNT_P (opts->...)
        Change TARGET_SAHF to TARGET_SAHF_P (opts->...)
        Change TARGET_MOVBE to TARGET_MOVBE_P (opts->...)
        Change TARGET_CRC32 to TARGET_CRC32_P (opts->...)
        Change TARGET_AES to TARGET_AES_P (opts->...)
        Change TARGET_PCLMUL to TARGET_PCLMUL_P (opts->...)
        Change TARGET_CMPXCHG16B to TARGET_CMPXCHG16B_P (opts->...)
        Change TARGET_FSGSBASE to TARGET_FSGSBASE_P (opts->...)
        Change TARGET_RDRND to TARGET_RDRND_P (opts->...)
        Change TARGET_F16C to TARGET_F16C_P (opts->...)
        Change TARGET_RTM to TARGET_RTM_P (opts->...)
        Change TARGET_HLE to TARGET_HLE_P (opts->...)
        Change TARGET_RDSEED to TARGET_RDSEED_P (opts->...)
        Change TARGET_PRFCHW to TARGET_PRFCHW_P (opts->...)
        Change TARGET_ADX to TARGET_ADX_P (opts->...)
        Change TARGET_FXSR to TARGET_FXSR_P (opts->...)
        Change TARGET_XSAVE to TARGET_XSAVE_P (opts->...)
        Change TARGET_XSAVEOPT to TARGET_XSAVEOPT_P (opts->...)
        Change TARGET_LP64 to TARGET_LP64_P (opts->...)
        Change TARGET_X32 to TARGET_X32_P (opts->...)
        Change TARGET_FPMATH_DEFAULT to TARGET_FPMATH_DEFAULT_P (opts->...)
        Change TARGET_FLOAT_RETURNS_IN_80387 to
	 TARGET_FLOAT_RETURNS_IN_80387_P (opts->...)
	(ix86_function_specific_save): New parameter. Use opts-> fields
	to replace global fields.
	(ix86_function_specific_restore): Ditto.
	(ix86_valid_target_attribute_inner_p): New parameters.
	Fix recursive call.
	Fix call to ix86_handle_option and set_option.
	(ix86_valid_target_attribute_tree): New parameters.
	Change global_options to access opts.
	Change global_options_set to access opts_set.
	Fix call to ix86_valid_target_attribute_inner_p.
	Change ix86_tune_string to access opts->x_ix86_tune_string.
	Change ix86_arch_string to access opts->x_ix86_arch_string.
	Change ix86_fpmath to access opts->x_ix86_fpmath
	Fix call to ix86_option_override_internal.
	Fix call to ix86_add_new_builtins.
	Fix calls to build_optimization_node and build_target_option_node.
	(ix86_valid_target_attribute_p): Remove access to global_options.
	Use new gcc_options structure func_options.
	Fix call to ix86_valid_target_attribute_tree.
	Fix call to  build_optimization_node.
	(get_builtin_code_for_version):	Fix call to
	ix86_valid_target_attribute_tree.

	PR target/57756
	* gcc.target/i386/pr57756.c: New test.
	* gcc.target/i386/pr57756_2.c: New test.

From-SVN: r203634
This commit is contained in:
Sriraman Tallam 2013-10-15 21:43:21 +00:00 committed by Sriraman Tallam
parent a7d35bd6bd
commit bf7b5747bb
20 changed files with 863 additions and 408 deletions

View File

@ -1,3 +1,187 @@
2013-10-15 Sriraman Tallam <tmsriram@google.com>
PR target/57756
* optc-save-gen.awk: Add extra parameter to the save and restore
target calls.
* opth-gen.awk: Generate new TARGET_* macros to accept a parameter.
* tree.c (build_optimization_node): New parameter. Add extra parameter
to call to cl_optimization_save.
(build_target_option_node): New parameter. Add extra parameter
to call to cl_target_option_save.
* tree.h (build_optimization_node): New parameter.
(build_target_option_node): New parameter.
* c-family/c-common.c (handle_optimize_attribute): Fix calls to
build_optimization_node and build_target_option_node.
* c-family/c-pragma.c (handle_pragma_optimize): Ditto.
(handle_pragma_push_options): Ditto.
* toplev.c (process_options): Ditto.
* opts.c (init_options_struct): Check for opts_set non-null.
* target.def (target_option.save): New parameter.
(target_option.restore): New parameter.
* tm.texi: Generate.
* config/i386/i386-c.c (ix86_target_macros_internal): Ditto.
(ix86_pragma_target_parse): Ditto.
* config/i386/i386-protos.h (ix86_valid_target_attribute_tree): New
parameters.
* config/rs6000/rs6000.c (rs6000_option_override_internal): Fix calls
to build_optimization_node and build_target_option_node.
(rs6000_valid_attribute_p): Ditto.
(rs6000_pragma_target_parse): Ditto.
* config/i386/i386.opt (x_ix86_target_flags_explicit): New TargetSave
data.
* config/i386/i386.h:
TARGET_64BIT_P: New Macro
TARGET_MMX_P: New Macro.
TARGET_3DNOW_P: New Macro.
TARGET_3DNOW_A_P: New Macro.
TARGET_SSE_P: New Macro.
TARGET_SSE2_P: New Macro.
TARGET_SSE3_P: New Macro.
TARGET_SSSE3_P: New Macro.
TARGET_SSE4_1_P: New Macro.
TARGET_SSE4_2_P: New Macro.
TARGET_AVX_P: New Macro.
TARGET_AVX2_P: New Macro.
TARGET_AVX512F_P: New Macro.
TARGET_AVX512PF_P: New Macro.
TARGET_AVX512ER_P: New Macro.
TARGET_AVX512CD_P: New Macro.
TARGET_FMA_P: New Macro.
TARGET_SSE4A_P: New Macro.
TARGET_FMA4_P: New Macro.
TARGET_XOP_P: New Macro.
TARGET_LWP_P: New Macro.
TARGET_ABM_P: New Macro.
TARGET_BMI_P: New Macro.
TARGET_BMI2_P: New Macro.
TARGET_LZCNT_P: New Macro.
TARGET_TBM_P: New Macro.
TARGET_POPCNT_P: New Macro.
TARGET_SAHF_P: New Macro.
TARGET_MOVBE_P: New Macro.
TARGET_CRC32_P: New Macro.
TARGET_AES_P: New Macro.
TARGET_PCLMUL_P: New Macro.
TARGET_CMPXCHG16B_P: New Macro.
TARGET_FSGSBASE_P: New Macro.
TARGET_RDRND_P: New Macro.
TARGET_F16C_P: New Macro.
TARGET_RTM_P: New Macro.
TARGET_HLE_P: New Macro.
TARGET_RDSEED_P: New Macro.
TARGET_PRFCHW_P: New Macro.
TARGET_ADX_P: New Macro.
TARGET_FXSR_P: New Macro.
TARGET_XSAVE_P: New Macro.
TARGET_XSAVEOPT_P: New Macro.
TARGET_LP64_P: New Macro.
TARGET_X32_P: New Macro.
TARGET_FPMATH_DEFAULT_P: New Macro.
TARGET_FLOAT_RETURNS_IN_80387_P: New Macro.
* config/i386/i386.c (ix86_option_override_internal): New parameters.
opts and opts_set.
Change ix86_tune_string to access opts->x_ix86_tune_string.
Change ix86_isa_flags to access opts->x_ix86_isa_flags.
Change ix86_arch_string to access opts->x_ix86_arch_string.
Change ix86_stringop_alg to access opts->x_ix86_stringop_alg.
Change ix86_pmode to access opts->x_ix86_pmode.
Change ix86_abi to access opts->x_ix86_abi.
Change ix86_cmodel to access opts->x_ix86_cmodel.
Change ix86_asm_dialect to access opts->x_ix86_asm_dialect.
Change ix86_isa_flags_explicit to access
opts->x_ix86_isa_flags_explicit.
Change ix86_dump_tunes to access opts->x_ix86_dump_tunes.
Change ix86_regparm to access opts->x_ix86_regparm.
Change ix86_branch_cost to access opts->x_ix86_branch_cost.
Change ix86_preferred_stack_boundary_arg to access
opts->x_ix86_preferred_stack_boundary_arg.
Change ix86_force_align_arg_pointer to access
opts->x_ix86_force_align_arg_pointer.
Change ix86_incoming_stack_boundar_arg to access
opts->x_ix86_incoming_stack_boundar_arg.
Change ix86_fpmath to access opts->x_ix86_fpmath.
Change ix86_veclibabi_type to access opts->x_ix86_veclibabi_type.
Change ix86_recip_name to access opts->x_ix86_recip_name.
Change ix86_stack_protector_guard to access
opts->x_ix86_stack_protector_guard.
Change ix86_tune_memcpy_strategy to access
opts->x_ix86_tune_memcpy_strategy.
Change ix86_tune_memset_strategy to access
opts->x_ix86_tune_memset_strategy.
Change global_options to access opts.
Change global_options_set to access opts_set.
Change TARGET_64BIT to TARGET_64BIT_P (opts->...)
Change TARGET_MMX to TARGET_MMX_P (opts->...)
Change TARGET_3DNOW to TARGET_3DNOW_P (opts->...)
Change TARGET_3DNOW_A to TARGET_3DNOW_A_P (opts->...)
Change TARGET_SSE to TARGET_SSE_P (opts->...)
Change TARGET_SSE2 to TARGET_SSE2_P (opts->...)
Change TARGET_SSE3 to TARGET_SSE3_P (opts->...)
Change TARGET_SSSE3 to TARGET_SSSE3_P (opts->...)
Change TARGET_SSE4_1 to TARGET_SSE4_1_P (opts->...)
Change TARGET_SSE4_2 to TARGET_SSE4_2_P (opts->...)
Change TARGET_AVX to TARGET_AVX_P (opts->...)
Change TARGET_AVX2 to TARGET_AVX2_P (opts->...)
Change TARGET_AVX512F to TARGET_AVX512F_P (opts->...)
Change TARGET_AVX512PF to TARGET_AVX512PF_P (opts->...)
Change TARGET_AVX512ER to TARGET_AVX512ER_P (opts->...)
Change TARGET_AVX512CD to TARGET_AVX512CD_P (opts->...)
Change TARGET_FMA to TARGET_FMA_P (opts->...)
Change TARGET_SSE4A to TARGET_SSE4A_P (opts->...)
Change TARGET_FMA4 to TARGET_FMA4_P (opts->...)
Change TARGET_XOP to TARGET_XOP_P (opts->...)
Change TARGET_LWP to TARGET_LWP_P (opts->...)
Change TARGET_ABM to TARGET_ABM_P (opts->...)
Change TARGET_BMI to TARGET_BMI_P (opts->...)
Change TARGET_BMI2 to TARGET_BMI2_P (opts->...)
Change TARGET_LZCNT to TARGET_LZCNT_P (opts->...)
Change TARGET_TBM to TARGET_TBM_P (opts->...)
Change TARGET_POPCNT to TARGET_POPCNT_P (opts->...)
Change TARGET_SAHF to TARGET_SAHF_P (opts->...)
Change TARGET_MOVBE to TARGET_MOVBE_P (opts->...)
Change TARGET_CRC32 to TARGET_CRC32_P (opts->...)
Change TARGET_AES to TARGET_AES_P (opts->...)
Change TARGET_PCLMUL to TARGET_PCLMUL_P (opts->...)
Change TARGET_CMPXCHG16B to TARGET_CMPXCHG16B_P (opts->...)
Change TARGET_FSGSBASE to TARGET_FSGSBASE_P (opts->...)
Change TARGET_RDRND to TARGET_RDRND_P (opts->...)
Change TARGET_F16C to TARGET_F16C_P (opts->...)
Change TARGET_RTM to TARGET_RTM_P (opts->...)
Change TARGET_HLE to TARGET_HLE_P (opts->...)
Change TARGET_RDSEED to TARGET_RDSEED_P (opts->...)
Change TARGET_PRFCHW to TARGET_PRFCHW_P (opts->...)
Change TARGET_ADX to TARGET_ADX_P (opts->...)
Change TARGET_FXSR to TARGET_FXSR_P (opts->...)
Change TARGET_XSAVE to TARGET_XSAVE_P (opts->...)
Change TARGET_XSAVEOPT to TARGET_XSAVEOPT_P (opts->...)
Change TARGET_LP64 to TARGET_LP64_P (opts->...)
Change TARGET_X32 to TARGET_X32_P (opts->...)
Change TARGET_FPMATH_DEFAULT to TARGET_FPMATH_DEFAULT_P (opts->...)
Change TARGET_FLOAT_RETURNS_IN_80387 to
TARGET_FLOAT_RETURNS_IN_80387_P (opts->...)
(ix86_function_specific_save): New parameter. Use opts-> fields
to replace global fields.
(ix86_function_specific_restore): Ditto.
(ix86_valid_target_attribute_inner_p): New parameters.
Fix recursive call.
Fix call to ix86_handle_option and set_option.
(ix86_valid_target_attribute_tree): New parameters.
Change global_options to access opts.
Change global_options_set to access opts_set.
Fix call to ix86_valid_target_attribute_inner_p.
Change ix86_tune_string to access opts->x_ix86_tune_string.
Change ix86_arch_string to access opts->x_ix86_arch_string.
Change ix86_fpmath to access opts->x_ix86_fpmath
Fix call to ix86_option_override_internal.
Fix call to ix86_add_new_builtins.
Fix calls to build_optimization_node and build_target_option_node.
(ix86_valid_target_attribute_p): Remove access to global_options.
Use new gcc_options structure func_options.
Fix call to ix86_valid_target_attribute_tree.
Fix call to build_optimization_node.
(get_builtin_code_for_version): Fix call to
ix86_valid_target_attribute_tree.
2013-10-15 David Malcolm <dmalcolm@redhat.com>
* Makefile.in (PICFLAG): New.

View File

@ -9049,7 +9049,7 @@ handle_optimize_attribute (tree *node, tree name, tree args,
/* Parse options, and update the vector. */
parse_optimize_options (args, true);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)
= build_optimization_node ();
= build_optimization_node (&global_options);
/* Restore current options. */
cl_optimization_restore (&global_options, &cur_opts);

View File

@ -872,7 +872,7 @@ handle_pragma_optimize (cpp_reader *ARG_UNUSED(dummy))
parse_optimize_options (args, false);
current_optimize_pragma = chainon (current_optimize_pragma, args);
optimization_current_node = build_optimization_node ();
optimization_current_node = build_optimization_node (&global_options);
c_cpp_builtins_optimize_pragma (parse_in,
optimization_previous_node,
optimization_current_node);
@ -914,8 +914,8 @@ handle_pragma_push_options (cpp_reader *ARG_UNUSED(dummy))
options_stack = p;
/* Save optimization and target flags in binary format. */
p->optimize_binary = build_optimization_node ();
p->target_binary = build_target_option_node ();
p->optimize_binary = build_optimization_node (&global_options);
p->target_binary = build_target_option_node (&global_options);
/* Save optimization and target flags in string list format. */
p->optimize_strings = copy_list (current_optimize_pragma);

View File

@ -368,7 +368,7 @@ ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
static bool
ix86_pragma_target_parse (tree args, tree pop_target)
{
tree prev_tree = build_target_option_node ();
tree prev_tree = build_target_option_node (&global_options);
tree cur_tree;
struct cl_target_option *prev_opt;
struct cl_target_option *cur_opt;
@ -388,7 +388,8 @@ ix86_pragma_target_parse (tree args, tree pop_target)
}
else
{
cur_tree = ix86_valid_target_attribute_tree (args);
cur_tree = ix86_valid_target_attribute_tree (args, &global_options,
&global_options_set);
if (!cur_tree || cur_tree == error_mark_node)
{
cl_target_option_restore (&global_options,

View File

@ -220,7 +220,9 @@ extern int ix86_constant_alignment (tree, int);
extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *);
extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *);
extern int x86_field_alignment (tree, int);
extern tree ix86_valid_target_attribute_tree (tree);
extern tree ix86_valid_target_attribute_tree (tree,
struct gcc_options *,
struct gcc_options *);
extern unsigned int ix86_get_callcvt (const_tree);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -40,53 +40,99 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* Redefines for option macros. */
#define TARGET_64BIT TARGET_ISA_64BIT
#define TARGET_64BIT_P(x) TARGET_ISA_64BIT_P(x)
#define TARGET_MMX TARGET_ISA_MMX
#define TARGET_MMX_P(x) TARGET_ISA_MMX_P(x)
#define TARGET_3DNOW TARGET_ISA_3DNOW
#define TARGET_3DNOW_P(x) TARGET_ISA_3DNOW_P(x)
#define TARGET_3DNOW_A TARGET_ISA_3DNOW_A
#define TARGET_3DNOW_A_P(x) TARGET_ISA_3DNOW_A_P(x)
#define TARGET_SSE TARGET_ISA_SSE
#define TARGET_SSE_P(x) TARGET_ISA_SSE_P(x)
#define TARGET_SSE2 TARGET_ISA_SSE2
#define TARGET_SSE2_P(x) TARGET_ISA_SSE2_P(x)
#define TARGET_SSE3 TARGET_ISA_SSE3
#define TARGET_SSE3_P(x) TARGET_ISA_SSE3_P(x)
#define TARGET_SSSE3 TARGET_ISA_SSSE3
#define TARGET_SSSE3_P(x) TARGET_ISA_SSSE3_P(x)
#define TARGET_SSE4_1 TARGET_ISA_SSE4_1
#define TARGET_SSE4_1_P(x) TARGET_ISA_SSE4_1_P(x)
#define TARGET_SSE4_2 TARGET_ISA_SSE4_2
#define TARGET_SSE4_2_P(x) TARGET_ISA_SSE4_2_P(x)
#define TARGET_AVX TARGET_ISA_AVX
#define TARGET_AVX_P(x) TARGET_ISA_AVX_P(x)
#define TARGET_AVX2 TARGET_ISA_AVX2
#define TARGET_AVX2_P(x) TARGET_ISA_AVX2_P(x)
#define TARGET_AVX512F TARGET_ISA_AVX512F
#define TARGET_AVX512F_P(x) TARGET_ISA_AVX512F_P(x)
#define TARGET_AVX512PF TARGET_ISA_AVX512PF
#define TARGET_AVX512PF_P(x) TARGET_ISA_AVX512PF_P(x)
#define TARGET_AVX512ER TARGET_ISA_AVX512ER
#define TARGET_AVX512ER_P(x) TARGET_ISA_AVX512ER_P(x)
#define TARGET_AVX512CD TARGET_ISA_AVX512CD
#define TARGET_AVX512CD_P(x) TARGET_ISA_AVX512CD_P(x)
#define TARGET_FMA TARGET_ISA_FMA
#define TARGET_FMA_P(x) TARGET_ISA_FMA_P(x)
#define TARGET_SSE4A TARGET_ISA_SSE4A
#define TARGET_SSE4A_P(x) TARGET_ISA_SSE4A_P(x)
#define TARGET_FMA4 TARGET_ISA_FMA4
#define TARGET_FMA4_P(x) TARGET_ISA_FMA4_P(x)
#define TARGET_XOP TARGET_ISA_XOP
#define TARGET_XOP_P(x) TARGET_ISA_XOP_P(x)
#define TARGET_LWP TARGET_ISA_LWP
#define TARGET_LWP_P(x) TARGET_ISA_LWP_P(x)
#define TARGET_ROUND TARGET_ISA_ROUND
#define TARGET_ABM TARGET_ISA_ABM
#define TARGET_ABM_P(x) TARGET_ISA_ABM_P(x)
#define TARGET_BMI TARGET_ISA_BMI
#define TARGET_BMI_P(x) TARGET_ISA_BMI_P(x)
#define TARGET_BMI2 TARGET_ISA_BMI2
#define TARGET_BMI2_P(x) TARGET_ISA_BMI2_P(x)
#define TARGET_LZCNT TARGET_ISA_LZCNT
#define TARGET_LZCNT_P(x) TARGET_ISA_LZCNT_P(x)
#define TARGET_TBM TARGET_ISA_TBM
#define TARGET_TBM_P(x) TARGET_ISA_TBM_P(x)
#define TARGET_POPCNT TARGET_ISA_POPCNT
#define TARGET_POPCNT_P(x) TARGET_ISA_POPCNT_P(x)
#define TARGET_SAHF TARGET_ISA_SAHF
#define TARGET_SAHF_P(x) TARGET_ISA_SAHF_P(x)
#define TARGET_MOVBE TARGET_ISA_MOVBE
#define TARGET_MOVBE_P(x) TARGET_ISA_MOVBE_P(x)
#define TARGET_CRC32 TARGET_ISA_CRC32
#define TARGET_CRC32_P(x) TARGET_ISA_CRC32_P(x)
#define TARGET_AES TARGET_ISA_AES
#define TARGET_AES_P(x) TARGET_ISA_AES_P(x)
#define TARGET_PCLMUL TARGET_ISA_PCLMUL
#define TARGET_PCLMUL_P(x) TARGET_ISA_PCLMUL_P(x)
#define TARGET_CMPXCHG16B TARGET_ISA_CX16
#define TARGET_CMPXCHG16B_P(x) TARGET_ISA_CX16_P(x)
#define TARGET_FSGSBASE TARGET_ISA_FSGSBASE
#define TARGET_FSGSBASE_P(x) TARGET_ISA_FSGSBASE_P(x)
#define TARGET_RDRND TARGET_ISA_RDRND
#define TARGET_RDRND_P(x) TARGET_ISA_RDRND_P(x)
#define TARGET_F16C TARGET_ISA_F16C
#define TARGET_F16C_P(x) TARGET_ISA_F16C_P(x)
#define TARGET_RTM TARGET_ISA_RTM
#define TARGET_RTM_P(x) TARGET_ISA_RTM_P(x)
#define TARGET_HLE TARGET_ISA_HLE
#define TARGET_HLE_P(x) TARGET_ISA_HLE_P(x)
#define TARGET_RDSEED TARGET_ISA_RDSEED
#define TARGET_RDSEED_P(x) TARGET_ISA_RDSEED_P(x)
#define TARGET_PRFCHW TARGET_ISA_PRFCHW
#define TARGET_PRFCHW_P(x) TARGET_ISA_PRFCHW_P(x)
#define TARGET_ADX TARGET_ISA_ADX
#define TARGET_ADX_P(x) TARGET_ISA_ADX_P(x)
#define TARGET_FXSR TARGET_ISA_FXSR
#define TARGET_FXSR_P(x) TARGET_ISA_FXSR_P(x)
#define TARGET_XSAVE TARGET_ISA_XSAVE
#define TARGET_XSAVE_P(x) TARGET_ISA_XSAVE_P(x)
#define TARGET_XSAVEOPT TARGET_ISA_XSAVEOPT
#define TARGET_XSAVEOPT_P(x) TARGET_ISA_XSAVEOPT_P(x)
#define TARGET_LP64 TARGET_ABI_64
#define TARGET_LP64_P(x) TARGET_ABI_64_P(x)
#define TARGET_X32 TARGET_ABI_X32
#define TARGET_X32_P(x) TARGET_ABI_X32_P(x)
/* SSE4.1 defines round instructions */
#define OPTION_MASK_ISA_ROUND OPTION_MASK_ISA_SSE4_1
@ -212,7 +258,13 @@ extern const struct processor_costs ix86_size_cost;
(TARGET_64BIT && TARGET_SSE ? FPMATH_SSE : FPMATH_387)
#endif
#ifndef TARGET_FPMATH_DEFAULT_P
#define TARGET_FPMATH_DEFAULT_P(x) \
(TARGET_64BIT_P(x) && TARGET_SSE_P(x) ? FPMATH_SSE : FPMATH_387)
#endif
#define TARGET_FLOAT_RETURNS_IN_80387 TARGET_FLOAT_RETURNS
#define TARGET_FLOAT_RETURNS_IN_80387_P(x) TARGET_FLOAT_RETURNS_P(x)
/* 64bit Sledgehammer mode. For libgcc2 we make sure this is a
compile-time constant. */

View File

@ -61,9 +61,13 @@ TargetSave
HOST_WIDE_INT x_ix86_isa_flags_explicit
;; which flags were passed by the user
TargetSave
Variable
int ix86_target_flags_explicit
;; which flags were passed by the user
TargetSave
HOST_WIDE_INT x_ix86_target_flags_explicit
;; whether -mtune was not specified
TargetSave
unsigned char tune_defaulted

View File

@ -3716,7 +3716,7 @@ rs6000_option_override_internal (bool global_init_p)
/* Save the initial options in case the user does function specific options */
if (global_init_p)
target_option_default_node = target_option_current_node
= build_target_option_node ();
= build_target_option_node (&global_options);
/* If not explicitly specified via option, decide whether to generate the
extra blr's required to preserve the link stack on some cpus (eg, 476). */
@ -29751,7 +29751,7 @@ rs6000_valid_attribute_p (tree fndecl,
{
struct cl_target_option cur_target;
bool ret;
tree old_optimize = build_optimization_node ();
tree old_optimize = build_optimization_node (&global_options);
tree new_target, new_optimize;
tree func_optimize = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl);
@ -29778,7 +29778,7 @@ rs6000_valid_attribute_p (tree fndecl,
fprintf (stderr, "--------------------\n");
}
old_optimize = build_optimization_node ();
old_optimize = build_optimization_node (&global_options);
func_optimize = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl);
/* If the function changed the optimization levels as well as setting target
@ -29797,12 +29797,12 @@ rs6000_valid_attribute_p (tree fndecl,
if (ret)
{
ret = rs6000_option_override_internal (false);
new_target = build_target_option_node ();
new_target = build_target_option_node (&global_options);
}
else
new_target = NULL;
new_optimize = build_optimization_node ();
new_optimize = build_optimization_node (&global_options);
if (!new_target)
ret = false;
@ -29832,7 +29832,7 @@ rs6000_valid_attribute_p (tree fndecl,
bool
rs6000_pragma_target_parse (tree args, tree pop_target)
{
tree prev_tree = build_target_option_node ();
tree prev_tree = build_target_option_node (&global_options);
tree cur_tree;
struct cl_target_option *prev_opt, *cur_opt;
HOST_WIDE_INT prev_flags, cur_flags, diff_flags;
@ -29869,7 +29869,8 @@ rs6000_pragma_target_parse (tree args, tree pop_target)
rs6000_cpu_index = rs6000_tune_index = -1;
if (!rs6000_inner_target_options (args, false)
|| !rs6000_option_override_internal (false)
|| (cur_tree = build_target_option_node ()) == NULL_TREE)
|| (cur_tree = build_target_option_node (&global_options))
== NULL_TREE)
{
if (TARGET_DEBUG_BUILTIN || TARGET_DEBUG_TARGET)
fprintf (stderr, "invalid pragma\n");

View File

@ -9853,17 +9853,17 @@ the function declaration to hold a pointer to a target-specific
@code{struct cl_target_option} structure.
@end deftypefn
@deftypefn {Target Hook} void TARGET_OPTION_SAVE (struct cl_target_option *@var{ptr})
@deftypefn {Target Hook} void TARGET_OPTION_SAVE (struct cl_target_option *@var{ptr}, struct gcc_options *@var{opts})
This hook is called to save any additional target-specific information
in the @code{struct cl_target_option} structure for function-specific
options.
options from the @code{struct gcc_options} structure.
@xref{Option file format}.
@end deftypefn
@deftypefn {Target Hook} void TARGET_OPTION_RESTORE (struct cl_target_option *@var{ptr})
@deftypefn {Target Hook} void TARGET_OPTION_RESTORE (struct gcc_options *@var{opts}, struct cl_target_option *@var{ptr})
This hook is called to restore any additional target-specific
information in the @code{struct cl_target_option} structure for
function-specific options.
function-specific options to the @code{struct gcc_options} structure.
@end deftypefn
@deftypefn {Target Hook} void TARGET_OPTION_PRINT (FILE *@var{file}, int @var{indent}, struct cl_target_option *@var{ptr})

View File

@ -284,7 +284,7 @@ if (have_assert)
print "";
print " if (targetm.target_option.save)";
print " targetm.target_option.save (ptr);";
print " targetm.target_option.save (ptr, opts);";
print "";
for (i = 0; i < n_extra_target_vars; i++) {
@ -347,7 +347,7 @@ for (i = 0; i < n_target_char; i++) {
# variables.
print "";
print " if (targetm.target_option.restore)";
print " targetm.target_option.restore (ptr);";
print " targetm.target_option.restore (opts, ptr);";
print "}";

View File

@ -114,7 +114,6 @@ print "};"
print "extern struct gcc_options global_options;"
print "extern const struct gcc_options global_options_init;"
print "extern struct gcc_options global_options_set;"
print "#define target_flags_explicit global_options_set.x_target_flags"
print "#endif"
print "#endif"
print ""
@ -382,6 +381,8 @@ for (i = 0; i < n_opts; i++) {
}
print "#define TARGET_" name \
" ((" vname " & " mask name ") != 0)"
print "#define TARGET_" name "_P(" vname ")" \
" ((" vname " & " mask name ") != 0)"
}
}
for (i = 0; i < n_extra_masks; i++) {

View File

@ -279,10 +279,15 @@ init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set)
gcc_obstack_init (&opts_obstack);
*opts = global_options_init;
memset (opts_set, 0, sizeof (*opts_set));
if (opts_set)
memset (opts_set, 0, sizeof (*opts_set));
opts->x_param_values = XNEWVEC (int, num_params);
opts_set->x_param_values = XCNEWVEC (int, num_params);
if (opts_set)
opts_set->x_param_values = XCNEWVEC (int, num_params);
init_param_values (opts->x_param_values);
/* Initialize whether `char' is signed. */

View File

@ -4964,9 +4964,9 @@ DEFHOOK
(save,
"This hook is called to save any additional target-specific information\n\
in the @code{struct cl_target_option} structure for function-specific\n\
options.\n\
options from the @code{struct gcc_options} structure.\n\
@xref{Option file format}.",
void, (struct cl_target_option *ptr), NULL)
void, (struct cl_target_option *ptr, struct gcc_options *opts), NULL)
/* Function to restore any extra target state from the target options
structure. */
@ -4974,8 +4974,8 @@ DEFHOOK
(restore,
"This hook is called to restore any additional target-specific\n\
information in the @code{struct cl_target_option} structure for\n\
function-specific options.",
void, (struct cl_target_option *ptr), NULL)
function-specific options to the @code{struct gcc_options} structure.",
void, (struct gcc_options *opts, struct cl_target_option *ptr), NULL)
/* Function to print any extra target state from the target options
structure. */

View File

@ -1,3 +1,9 @@
2013-10-15 Sriraman Tallam <tmsriram@google.com>
PR target/57756
* gcc.target/i386/pr57756.c: New test.
* gcc.target/i386/pr57756_2.c: New test.
2013-10-15 Richard Sandiford <rdsandiford@googlemail.com>
* gcc.dg/torture/builtin-self.c: New file.

View File

@ -0,0 +1,22 @@
/* callee cannot be inlined into caller because it has a higher
target ISA. */
/* { dg-do compile } */
__attribute__((always_inline,target("sse4.2")))
__inline int callee () /* { dg-error "inlining failed in call to always_inline" } */
{
return 0;
}
__attribute__((target("sse")))
__inline int caller ()
{
return callee(); /* { dg-error "called from here" } */
}
int main ()
{
return caller();
}
/* callee cannot be inlined into caller because it has a higher
target ISA. */

View File

@ -0,0 +1,132 @@
/* { dg-do run } */
/* { dg-options "-mno-sse2 -mno-popcnt -mno-avx" } */
__attribute__((always_inline,target("avx2")))
__inline int c1 ()
{
return 0;
}
__attribute__((always_inline,target("avx")))
__inline int c2 ()
{
return 0;
}
__attribute__((always_inline,target("popcnt")))
__inline int c3 ()
{
return 0;
}
__attribute__((always_inline,target("sse4.2")))
__inline int c4 ()
{
return 0;
}
__attribute__((always_inline,target("sse4.1")))
__inline int c5 ()
{
return 0;
}
__attribute__((always_inline,target("ssse3")))
__inline int c6 ()
{
return 0;
}
__attribute__((always_inline,target("sse3")))
__inline int c7 ()
{
return 0;
}
__attribute__((always_inline,target("sse2")))
__inline int c8 ()
{
return 0;
}
int nop ()
{
return 1;
}
#pragma GCC push_options
#pragma GCC target("sse2")
int C8 ()
{
return c8 ();
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC target("sse3")
int C7 ()
{
return c7 ();
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC target("ssse3")
int C6 ()
{
return c6 ();
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC target("sse4.1")
int C5 ()
{
return c5 ();
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC target("sse4.2")
int C4 ()
{
return c4 ();
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC target("popcnt")
int C3 ()
{
return c3 ();
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC target("avx")
int C2 ()
{
return c2 ();
}
#pragma GCC pop_options
#pragma GCC push_options
#pragma GCC target("avx2")
int C1 ()
{
return c1 ();
}
#pragma GCC pop_options
int main ()
{
return C1 () + C2 () + C3 () + C4 () + C5 () + C6 () + C7 () + C8 ();
}

View File

@ -1575,7 +1575,7 @@ process_options (void)
DK_ERROR, UNKNOWN_LOCATION);
/* Save the current optimization options. */
optimization_default_node = build_optimization_node ();
optimization_default_node = build_optimization_node (&global_options);
optimization_current_node = optimization_default_node;
}

View File

@ -11598,10 +11598,10 @@ cl_option_hash_eq (const void *x, const void *y)
return (memcmp (xp, yp, len) == 0);
}
/* Build an OPTIMIZATION_NODE based on the current options. */
/* Build an OPTIMIZATION_NODE based on the options in OPTS. */
tree
build_optimization_node (void)
build_optimization_node (struct gcc_options *opts)
{
tree t;
void **slot;
@ -11609,7 +11609,7 @@ build_optimization_node (void)
/* Use the cache of optimization nodes. */
cl_optimization_save (TREE_OPTIMIZATION (cl_optimization_node),
&global_options);
opts);
slot = htab_find_slot (cl_option_hash_table, cl_optimization_node, INSERT);
t = (tree) *slot;
@ -11626,10 +11626,10 @@ build_optimization_node (void)
return t;
}
/* Build a TARGET_OPTION_NODE based on the current options. */
/* Build a TARGET_OPTION_NODE based on the options in OPTS. */
tree
build_target_option_node (void)
build_target_option_node (struct gcc_options *opts)
{
tree t;
void **slot;
@ -11637,7 +11637,7 @@ build_target_option_node (void)
/* Use the cache of optimization nodes. */
cl_target_option_save (TREE_TARGET_OPTION (cl_target_option_node),
&global_options);
opts);
slot = htab_find_slot (cl_option_hash_table, cl_target_option_node, INSERT);
t = (tree) *slot;

View File

@ -2654,16 +2654,16 @@ extern vec<tree, va_gc> **decl_debug_args_insert (tree);
#define TREE_OPTIMIZATION_BASE_OPTABS(NODE) \
(OPTIMIZATION_NODE_CHECK (NODE)->optimization.base_optabs)
/* Return a tree node that encapsulates the current optimization options. */
extern tree build_optimization_node (void);
/* Return a tree node that encapsulates the optimization options in OPTS. */
extern tree build_optimization_node (struct gcc_options *opts);
extern void init_tree_optimization_optabs (tree);
#define TREE_TARGET_OPTION(NODE) \
(&TARGET_OPTION_NODE_CHECK (NODE)->target_option.opts)
/* Return a tree node that encapsulates the current target options. */
extern tree build_target_option_node (void);
/* Return a tree node that encapsulates the target options in OPTS. */
extern tree build_target_option_node (struct gcc_options *opts);
#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)