From patchwork Wed Jun 22 19:02:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 101536 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 4E601B6F86 for ; Thu, 23 Jun 2011 05:02:50 +1000 (EST) Received: (qmail 26495 invoked by alias); 22 Jun 2011 19:02:49 -0000 Received: (qmail 26475 invoked by uid 22791); 22 Jun 2011 19:02:46 -0000 X-SWARE-Spam-Status: No, hits=-0.4 required=5.0 tests=AWL, BAYES_50, TW_XG, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Jun 2011 19:02:27 +0000 Received: (qmail 25901 invoked from network); 22 Jun 2011 19:02:26 -0000 Received: from unknown (HELO digraph.polyomino.org.uk) (joseph@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Jun 2011 19:02:26 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.72) (envelope-from ) id 1QZSgu-0002AL-Fl for gcc-patches@gcc.gnu.org; Wed, 22 Jun 2011 19:02:20 +0000 Date: Wed, 22 Jun 2011 19:02:20 +0000 (UTC) From: "Joseph S. Myers" To: gcc-patches@gcc.gnu.org Subject: Move params code and hook to libcommon-target Message-ID: MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch continues preparing for the driver to use the option-handling hooks from cc1 by moving the definitions of --param arguments and associated target-specific defaults to common code. The params themselves go in params.c along with the initialization code formerly in toplev.c; the hook TARGET_OPTION_DEFAULT_PARAMS moves to the common hooks structure. Bootstrapped with no regressions on x86_64-unknown-linux-gnu, and tested building cc1 and xgcc for crosses to: ia64-elf powerpc-eabi sh-elf spu-elf. Will commit to trunk in the absence of objections from more specific maintainers. 2011-06-22 Joseph Myers * params.c: Include common/common-target.h. Don't include tm.h. (lang_independent_params): Move from toplev.c. (global_init_params): New. * params.h (global_init_params): Declare. * target.def (default_params): Move to common-target.def. * toplev.c (lang_independent_options): Remove. (lang_independent_params): Move to params.c. (general_init): Use global_init_params. * common/common-target.def (option_default_params): Move from target.def. * common/config/ia64/ia64-common.c: Include params.h. (ia64_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move from ia64.c. * common/config/rs6000/rs6000-common.c: Include params.h. (rs6000_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move from rs6000.c. * common/config/sh/sh-common.c: Include params.h. (sh_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move from sh.c. * common/config/spu/spu-common.c: Include params.h. (spu_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move from spu.c. * config/ia64/ia64.c (ia64_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move to ia64-common.c. * config/rs6000/rs6000.c (rs6000_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move to rs6000-common.c. * config/sh/sh.c (sh_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move to sh-common.c. * config/spu/spu.c (spu_option_default_params, TARGET_OPTION_DEFAULT_PARAMS): Move to spu-common.c. * Makefile.in (OBJS): Remove params.o. (OBJS-libcommon-target): Add params.o. (params.o, $(common_out_object_file)): Update dependencies. * doc/tm.texi: Regenerate. Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi (revision 175248) +++ gcc/doc/tm.texi (working copy) @@ -762,7 +762,7 @@ options are changed via @code{#pragma GC Set target-dependent initial values of fields in @var{opts}. @end deftypefn -@deftypefn {Target Hook} void TARGET_OPTION_DEFAULT_PARAMS (void) +@deftypefn {Common Target Hook} void TARGET_OPTION_DEFAULT_PARAMS (void) Set target-dependent default values for @option{--param} settings, using calls to @code{set_default_param_value}. @end deftypefn Index: gcc/target.def =================================================================== --- gcc/target.def (revision 175248) +++ gcc/target.def (working copy) @@ -2545,13 +2545,6 @@ DEFHOOK void, (void), hook_void_void) -DEFHOOK -(default_params, -"Set target-dependent default values for @option{--param} settings, using\ - calls to @code{set_default_param_value}.", - void, (void), - hook_void_void) - /* Function to determine if one function can inline another function. */ #undef HOOK_PREFIX #define HOOK_PREFIX "TARGET_" Index: gcc/params.c =================================================================== --- gcc/params.c (revision 175248) +++ gcc/params.c (working copy) @@ -1,5 +1,5 @@ /* params.c - Run-time parameters. - Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2009, 2010 + Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Written by Mark Mitchell . @@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. #include "config.h" #include "system.h" #include "coretypes.h" -#include "tm.h" +#include "common/common-target.h" #include "params.h" #include "diagnostic-core.h" @@ -38,6 +38,14 @@ static size_t num_compiler_params; default values determined. */ static bool params_finished; +static const param_info lang_independent_params[] = { +#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \ + { OPTION, DEFAULT, MIN, MAX, HELP }, +#include "params.def" +#undef DEFPARAM + { NULL, 0, 0, 0, NULL } +}; + /* Add the N PARAMS to the current list of compiler parameters. */ void @@ -56,6 +64,16 @@ add_params (const param_info params[], s num_compiler_params += n; } +/* Add all parameters and default values that can be set in both the + driver and the compiler proper. */ + +void +global_init_params (void) +{ + add_params (lang_independent_params, LAST_PARAM); + targetm_common.option_default_params (); +} + /* Note that all parameters have been added and all default values set. */ Index: gcc/params.h =================================================================== --- gcc/params.h (revision 175248) +++ gcc/params.h (working copy) @@ -105,6 +105,11 @@ extern void maybe_set_param_value (compi extern void set_default_param_value (compiler_param num, int value); +/* Add all parameters and default values that can be set in both the + driver and the compiler proper. */ + +extern void global_init_params (void); + /* Note that all parameters have been added and all default values set. */ extern void finish_params (void); Index: gcc/toplev.c =================================================================== --- gcc/toplev.c (revision 175248) +++ gcc/toplev.c (working copy) @@ -183,25 +183,9 @@ struct target_flag_state *this_target_fl #define this_target_flag_state (&default_target_flag_state) #endif -typedef struct -{ - const char *const string; - int *const variable; - const int on_value; -} -lang_independent_options; - /* The user symbol prefix after having resolved same. */ const char *user_label_prefix; -static const param_info lang_independent_params[] = { -#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \ - { OPTION, DEFAULT, MIN, MAX, HELP }, -#include "params.def" -#undef DEFPARAM - { NULL, 0, 0, 0, NULL } -}; - /* Output files for assembler code (real compiler output) and debugging dumps. */ @@ -1213,10 +1197,10 @@ general_init (const char *argv0) init_reg_sets (); /* Register the language-independent parameters. */ - add_params (lang_independent_params, LAST_PARAM); - targetm.target_option.default_params (); + global_init_params (); - /* This must be done after add_params but before argument processing. */ + /* This must be done after global_init_params but before argument + processing. */ init_ggc_heuristics(); init_optimization_passes (); statistics_early_init (); Index: gcc/common/config/ia64/ia64-common.c =================================================================== --- gcc/common/config/ia64/ia64-common.c (revision 175248) +++ gcc/common/config/ia64/ia64-common.c (working copy) @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. #include "common/common-target-def.h" #include "opts.h" #include "flags.h" +#include "params.h" /* Implement overriding of the optimization options. */ static const struct default_options ia64_option_optimization_table[] = @@ -83,8 +84,25 @@ ia64_except_unwind_info (struct gcc_opti return UI_TARGET; } +/* Implement TARGET_OPTION_DEFAULT_PARAMS. */ + +static void +ia64_option_default_params (void) +{ + /* Let the scheduler form additional regions. */ + set_default_param_value (PARAM_MAX_SCHED_EXTEND_REGIONS_ITERS, 2); + + /* Set the default values for cache-related parameters. */ + set_default_param_value (PARAM_SIMULTANEOUS_PREFETCHES, 6); + set_default_param_value (PARAM_L1_CACHE_LINE_SIZE, 32); + + set_default_param_value (PARAM_SCHED_MEM_TRUE_DEP_COST, 4); +} + #undef TARGET_OPTION_OPTIMIZATION_TABLE #define TARGET_OPTION_OPTIMIZATION_TABLE ia64_option_optimization_table +#undef TARGET_OPTION_DEFAULT_PARAMS +#define TARGET_OPTION_DEFAULT_PARAMS ia64_option_default_params #undef TARGET_EXCEPT_UNWIND_INFO #define TARGET_EXCEPT_UNWIND_INFO ia64_except_unwind_info Index: gcc/common/config/spu/spu-common.c =================================================================== --- gcc/common/config/spu/spu-common.c (revision 175248) +++ gcc/common/config/spu/spu-common.c (working copy) @@ -24,6 +24,7 @@ #include "common/common-target-def.h" #include "opts.h" #include "flags.h" +#include "params.h" static void spu_option_init_struct (struct gcc_options *opts) @@ -32,12 +33,24 @@ spu_option_init_struct (struct gcc_optio opts->x_flag_rename_registers = 1; } +/* Implement TARGET_OPTION_DEFAULT_PARAMS. */ +static void +spu_option_default_params (void) +{ + /* Override some of the default param values. With so many registers + larger values are better for these params. */ + set_default_param_value (PARAM_MAX_PENDING_LIST_LENGTH, 128); +} + #undef TARGET_DEFAULT_TARGET_FLAGS #define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT) #undef TARGET_OPTION_INIT_STRUCT #define TARGET_OPTION_INIT_STRUCT spu_option_init_struct +#undef TARGET_OPTION_DEFAULT_PARAMS +#define TARGET_OPTION_DEFAULT_PARAMS spu_option_default_params + #undef TARGET_EXCEPT_UNWIND_INFO #define TARGET_EXCEPT_UNWIND_INFO sjlj_except_unwind_info Index: gcc/common/config/rs6000/rs6000-common.c =================================================================== --- gcc/common/config/rs6000/rs6000-common.c (revision 175248) +++ gcc/common/config/rs6000/rs6000-common.c (working copy) @@ -28,6 +28,7 @@ #include "common/common-target-def.h" #include "opts.h" #include "flags.h" +#include "params.h" /* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */ static const struct default_options rs6000_option_optimization_table[] = @@ -51,6 +52,15 @@ rs6000_option_init_struct (struct gcc_op opts->x_flag_section_anchors = 1; } +/* Implement TARGET_OPTION_DEFAULT_PARAMS. */ + +static void +rs6000_option_default_params (void) +{ + /* Double growth factor to counter reduced min jump length. */ + set_default_param_value (PARAM_MAX_GROW_COPY_BB_INSNS, 16); +} + /* If not otherwise specified by a target, make 'long double' equivalent to 'double'. */ @@ -316,6 +326,9 @@ rs6000_handle_option (struct gcc_options #undef TARGET_OPTION_INIT_STRUCT #define TARGET_OPTION_INIT_STRUCT rs6000_option_init_struct +#undef TARGET_OPTION_DEFAULT_PARAMS +#define TARGET_OPTION_DEFAULT_PARAMS rs6000_option_default_params + #undef TARGET_OPTION_OPTIMIZATION_TABLE #define TARGET_OPTION_OPTIMIZATION_TABLE rs6000_option_optimization_table Index: gcc/common/config/sh/sh-common.c =================================================================== --- gcc/common/config/sh/sh-common.c (revision 175248) +++ gcc/common/config/sh/sh-common.c (working copy) @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. #include "common/common-target-def.h" #include "opts.h" #include "flags.h" +#include "params.h" /* Set default optimization options. */ static const struct default_options sh_option_optimization_table[] = @@ -196,10 +197,19 @@ sh_option_init_struct (struct gcc_option opts->x_flag_finite_math_only = 2; } +/* Implement TARGET_OPTION_DEFAULT_PARAMS. */ +static void +sh_option_default_params (void) +{ + set_default_param_value (PARAM_SIMULTANEOUS_PREFETCHES, 2); +} + #undef TARGET_OPTION_OPTIMIZATION_TABLE #define TARGET_OPTION_OPTIMIZATION_TABLE sh_option_optimization_table #undef TARGET_OPTION_INIT_STRUCT #define TARGET_OPTION_INIT_STRUCT sh_option_init_struct +#undef TARGET_OPTION_DEFAULT_PARAMS +#define TARGET_OPTION_DEFAULT_PARAMS sh_option_default_params #undef TARGET_DEFAULT_TARGET_FLAGS #define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT #undef TARGET_HANDLE_OPTION Index: gcc/common/common-target.def =================================================================== --- gcc/common/common-target.def (revision 175248) +++ gcc/common/common-target.def (working copy) @@ -50,6 +50,13 @@ DEFHOOKPOD "", const struct default_options *, empty_optimization_table) +DEFHOOK +(option_default_params, +"Set target-dependent default values for @option{--param} settings, using\ + calls to @code{set_default_param_value}.", + void, (void), + hook_void_void) + /* The initial value of target_flags. */ DEFHOOKPOD (default_target_flags, Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in (revision 175248) +++ gcc/Makefile.in (working copy) @@ -1355,7 +1355,6 @@ OBJS = \ options-save.o \ opts-global.o \ opts.o \ - params.o \ passes.o \ plugin.o \ pointer-set.o \ @@ -1504,8 +1503,8 @@ OBJS-libcommon = diagnostic.o pretty-pri # Objects in libcommon-target.a, used by drivers and by the core # compiler and containing target-dependent code. -OBJS-libcommon-target = $(common_out_object_file) prefix.o opts-common.o \ - options.o vec.o hooks.o common/common-targhooks.o +OBJS-libcommon-target = $(common_out_object_file) prefix.o params.o \ + opts-common.o options.o vec.o hooks.o common/common-targhooks.o # This lists all host objects for the front ends. ALL_HOST_FRONTEND_OBJS = $(C_OBJS) \ @@ -3538,8 +3537,8 @@ ifcvt.o : ifcvt.c $(CONFIG_H) $(SYSTEM_H $(TARGET_H) $(BASIC_BLOCK_H) $(EXPR_H) output.h $(EXCEPT_H) $(TM_P_H) \ $(OPTABS_H) $(CFGLOOP_H) hard-reg-set.h $(TIMEVAR_H) \ $(TREE_PASS_H) $(DF_H) $(DBGCNT_H) -params.o : params.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(PARAMS_H) \ - $(DIAGNOSTIC_CORE_H) +params.o : params.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(COMMON_TARGET_H) \ + $(PARAMS_H) $(DIAGNOSTIC_CORE_H) pointer-set.o: pointer-set.c pointer-set.h $(CONFIG_H) $(SYSTEM_H) hooks.o: hooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(HOOKS_H) pretty-print.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h intl.h $(PRETTY_PRINT_H) @@ -3564,7 +3563,7 @@ $(out_object_file): $(out_file) $(CONFIG $(out_file) $(OUTPUT_OPTION) $(common_out_object_file): $(common_out_file) $(CONFIG_H) $(SYSTEM_H) \ - coretypes.h $(COMMON_TARGET_H) $(COMMON_TARGET_DEF_H) \ + coretypes.h $(COMMON_TARGET_H) $(COMMON_TARGET_DEF_H) $(PARAMS_H) \ $(DIAGNOSTIC_CORE_H) $(FLAGS_H) $(OPTS_H) $(TM_H) $(TM_P_H) $(MACHMODE_H) $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \ $< $(OUTPUT_OPTION) Index: gcc/config/spu/spu.c =================================================================== --- gcc/config/spu/spu.c (revision 175248) +++ gcc/config/spu/spu.c (working copy) @@ -149,7 +149,6 @@ char regs_ever_allocated[FIRST_PSEUDO_RE /* Prototypes and external defs. */ static void spu_option_override (void); -static void spu_option_default_params (void); static void spu_init_builtins (void); static tree spu_builtin_decl (unsigned, bool); static bool spu_scalar_mode_supported_p (enum machine_mode mode); @@ -487,9 +486,6 @@ static void spu_setup_incoming_varargs ( #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE spu_option_override -#undef TARGET_OPTION_DEFAULT_PARAMS -#define TARGET_OPTION_DEFAULT_PARAMS spu_option_default_params - #undef TARGET_CONDITIONAL_REGISTER_USAGE #define TARGET_CONDITIONAL_REGISTER_USAGE spu_conditional_register_usage @@ -508,15 +504,6 @@ static void spu_setup_incoming_varargs ( struct gcc_target targetm = TARGET_INITIALIZER; -/* Implement TARGET_OPTION_DEFAULT_PARAMS. */ -static void -spu_option_default_params (void) -{ - /* Override some of the default param values. With so many registers - larger values are better for these params. */ - set_default_param_value (PARAM_MAX_PENDING_LIST_LENGTH, 128); -} - /* Implement TARGET_OPTION_OVERRIDE. */ static void spu_option_override (void) Index: gcc/config/sh/sh.c =================================================================== --- gcc/config/sh/sh.c (revision 175248) +++ gcc/config/sh/sh.c (working copy) @@ -182,7 +182,6 @@ static int noncall_uses_reg (rtx, rtx, r static rtx gen_block_redirect (rtx, int, int); static void sh_reorg (void); static void sh_option_override (void); -static void sh_option_default_params (void); static void output_stack_adjust (int, rtx, int, HARD_REG_SET *, bool); static rtx frame_insn (rtx); static rtx push (int); @@ -345,8 +344,6 @@ static const struct attribute_spec sh_at #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE sh_option_override -#undef TARGET_OPTION_DEFAULT_PARAMS -#define TARGET_OPTION_DEFAULT_PARAMS sh_option_default_params #undef TARGET_PRINT_OPERAND #define TARGET_PRINT_OPERAND sh_print_operand @@ -578,14 +575,6 @@ static const struct attribute_spec sh_at struct gcc_target targetm = TARGET_INITIALIZER; - -/* Implement TARGET_OPTION_DEFAULT_PARAMS. */ -static void -sh_option_default_params (void) -{ - set_default_param_value (PARAM_SIMULTANEOUS_PREFETCHES, 2); -} - /* Implement TARGET_OPTION_OVERRIDE macro. Validate and override various options, and do some machine dependent initialization. */ static void Index: gcc/config/ia64/ia64.c =================================================================== --- gcc/config/ia64/ia64.c (revision 175248) +++ gcc/config/ia64/ia64.c (working copy) @@ -192,7 +192,6 @@ static rtx gen_fr_spill_x (rtx, rtx, rtx static rtx gen_fr_restore_x (rtx, rtx, rtx); static void ia64_option_override (void); -static void ia64_option_default_params (void); static bool ia64_can_eliminate (const int, const int); static enum machine_mode hfa_element_mode (const_tree, bool); static void ia64_setup_incoming_varargs (cumulative_args_t, enum machine_mode, @@ -377,8 +376,6 @@ static const struct attribute_spec ia64_ #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE ia64_option_override -#undef TARGET_OPTION_DEFAULT_PARAMS -#define TARGET_OPTION_DEFAULT_PARAMS ia64_option_default_params #undef TARGET_ASM_FUNCTION_PROLOGUE #define TARGET_ASM_FUNCTION_PROLOGUE ia64_output_function_prologue @@ -10859,20 +10856,6 @@ ia64_invalid_binary_op (int op ATTRIBUTE return NULL; } -/* Implement TARGET_OPTION_DEFAULT_PARAMS. */ -static void -ia64_option_default_params (void) -{ - /* Let the scheduler form additional regions. */ - set_default_param_value (PARAM_MAX_SCHED_EXTEND_REGIONS_ITERS, 2); - - /* Set the default values for cache-related parameters. */ - set_default_param_value (PARAM_SIMULTANEOUS_PREFETCHES, 6); - set_default_param_value (PARAM_L1_CACHE_LINE_SIZE, 32); - - set_default_param_value (PARAM_SCHED_MEM_TRUE_DEP_COST, 4); -} - /* HP-UX version_id attribute. For object foo, if the version_id is set to 1234 put out an alias of '.alias foo "foo{1234}" We can't use "foo{1234}" in anything Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 175248) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -1045,7 +1045,6 @@ static rtx altivec_expand_vec_set_builti static rtx altivec_expand_vec_ext_builtin (tree, rtx); static int get_element_number (tree, tree); static void rs6000_option_override (void); -static void rs6000_option_default_params (void); static int rs6000_loop_align_max_skip (rtx); static int first_altivec_reg_to_save (void); static unsigned int compute_vrsave_mask (void); @@ -1528,9 +1527,6 @@ static const struct attribute_spec rs600 #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE rs6000_option_override -#undef TARGET_OPTION_DEFAULT_PARAMS -#define TARGET_OPTION_DEFAULT_PARAMS rs6000_option_default_params - #undef TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \ rs6000_builtin_vectorized_function @@ -3678,15 +3674,6 @@ rs6000_preferred_simd_mode (enum machine return word_mode; } -/* Implement TARGET_OPTION_DEFAULT_PARAMS. */ - -static void -rs6000_option_default_params (void) -{ - /* Double growth factor to counter reduced min jump length. */ - set_default_param_value (PARAM_MAX_GROW_COPY_BB_INSNS, 16); -} - /* Handler for the Mathematical Acceleration Subsystem (mass) interface to a library with vectorized intrinsics. */