aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-10-08 16:17:32 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2010-10-08 16:17:32 +0100
commita75bfaa6cdea2dd7c2e8ac2aa4f52267b3213362 (patch)
treed7c6e9b6d0c3fea0b0d512fb08735055168c35e6 /gcc/opts.c
parente899aa1613680d530fad1848a13ff91236b91b44 (diff)
downloadgcc-a75bfaa6cdea2dd7c2e8ac2aa4f52267b3213362.zip
gcc-a75bfaa6cdea2dd7c2e8ac2aa4f52267b3213362.tar.gz
gcc-a75bfaa6cdea2dd7c2e8ac2aa4f52267b3213362.tar.bz2
Makefile.in (TM_H): Include $(FLAGS_H) instead of options.h.
* Makefile.in (TM_H): Include $(FLAGS_H) instead of options.h. (TREE_H): Include $(FLAGS_H) instead of options.h. (opts-common.o): Depend on $(FLAGS_H) instead of options.h. * c-objc-common.h (LANG_HOOKS_INIT_OPTIONS_STRUCT): Define. * common.opt (flag_complex_method, flag_evaluation_order, flag_ira_algorithm, flag_ira_region, flag_warn_unused_result): New Variable declarations. * configure.ac (tm_include_list): Include flags.h instead of options.h. * configure: Regenerate. * flags.h: Condition out contents for target libraries. Include options.h at end of file. (flag_complex_method, flag_ira_algorithm, flag_ira_region, flag_evaluation_order, flag_warn_unused_result): Remove. * gcc.c (main): Intialize global_options with global_options_init. * langhooks-def.h (lhd_init_options_struct): Declare. (LANG_HOOKS_INIT_OPTIONS_STRUCT): Define. (LANG_HOOKS_INITIALIZER): Include LANG_HOOKS_INIT_OPTIONS_STRUCT. * langhooks.c (lhd_init_options_struct): New. * langhooks.h (struct lang_hooks): Add init_options_struct. Update comment on init_options. * optc-gen.awk: Generate initializer for global_options_init, not global_options. * opth-gen.awk: Condition out structure declarations for target libraries. Declare global_options_init. * opts-common.c: Include flags.h instead of options.h. * opts.c (flag_warn_unused_result): Remove. (read_cmdline_options): Take gcc_options parameters. Pass them to read_cmdline_option. (initial_lang_mask, initial_min_crossjump_insns, initial_max_fields_for_field_sensitive, initial_loop_invariant_max_bbs_in_loop): Define at file scope. (init_options_once): New. Split out of decode_options. (init_options_struct): New. Split out of decode_options. (decode_cmdline_options_to_array_default_mask): New. (default_options_optimization): New. Split out of decode_options. (decode_options): Move most code to other functions. Update call to read_cmdline_options. (finish_options): New. Split out of decode_options. * opts.h (decode_options): Add gcc_options parameters. (init_options_once, init_options_struct, decode_cmdline_options_to_array_default_mask): New. * toplev.c (flag_complex_method, flag_ira_algorithm, flag_ira_region, flag_evaluation_order): Remove. (general_init): Use global_options_init for initial flag values for global_dc. (toplev_main): Call init_options_once, init_options_struct, lang_hooks.init_options_struct, decode_cmdline_options_to_array_default_mask and lang_hooks.init_option before decode_options. Update arguments to decode_options. * tree.h: Include flags.h instead of options.h. ada: * gcc-interface/misc.c (gnat_init_options_struct): New. Split out from gnat_init_options. (LANG_HOOKS_INIT_OPTIONS_STRUCT): Define. c-family: * c-common.c (parse_optimize_options): Call decode_cmdline_options_to_array_default_mask before decode_options. Update arguments to decode_options. * c-common.h (c_common_init_options_struct): Declare. * c-opts.c (c_common_init_options_struct): New. Split out from c_common_init_options. cp: * cp-objcp-common.h (LANG_HOOKS_INIT_OPTIONS_STRUCT): Define. fortran: * f95-lang.c (LANG_HOOKS_INIT_OPTIONS_STRUCT): Define. * gfortran.h (gfc_init_options_struct): Declare. * options.c (gfc_init_options_struct): New. Split out from gfc_init_options. java: * lang.c (java_init_options_struct): New. Split out from java_init_options. (LANG_HOOKS_INIT_OPTIONS_STRUCT): Define. lto: * lto-lang.c (lto_init_options): Change to lto_init_options_struct. Update parameters. (LANG_HOOKS_INIT_OPTIONS): Don't define. (LANG_HOOKS_INIT_OPTIONS_STRUCT): Define. From-SVN: r165189
Diffstat (limited to 'gcc/opts.c')
-rw-r--r--gcc/opts.c226
1 files changed, 142 insertions, 84 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index 03098b5..efee21e 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -353,9 +353,6 @@ DEF_VEC_ALLOC_P(const_char_p,heap);
static VEC(const_char_p,heap) *ignored_options;
-/* Language specific warning pass for unused results. */
-bool flag_warn_unused_result = false;
-
/* Input file names. */
const char **in_fnames;
unsigned num_in_fnames;
@@ -613,11 +610,14 @@ flag_instrument_functions_exclude_p (tree fndecl)
}
-/* Handle the vector of command line options. LANG_MASK
- contains has a single bit set representing the current
- language. HANDLERS describes what functions to call for the options. */
+/* Handle the vector of command line options, storing the results of
+ processing DECODED_OPTIONS and DECODED_OPTIONS_COUNT in OPTS and
+ OPTS_SET. LANG_MASK contains has a single bit set representing the
+ current language. HANDLERS describes what functions to call for
+ the options. */
static void
-read_cmdline_options (struct cl_decoded_option *decoded_options,
+read_cmdline_options (struct gcc_options *opts, struct gcc_options *opts_set,
+ struct cl_decoded_option *decoded_options,
unsigned int decoded_options_count,
unsigned int lang_mask,
const struct cl_option_handlers *handlers)
@@ -628,6 +628,11 @@ read_cmdline_options (struct cl_decoded_option *decoded_options,
{
if (decoded_options[i].opt_index == OPT_SPECIAL_input_file)
{
+ /* Input files should only ever appear on the main command
+ line. */
+ gcc_assert (opts == &global_options);
+ gcc_assert (opts_set == &global_options_set);
+
if (main_input_filename == NULL)
{
main_input_filename = decoded_options[i].arg;
@@ -638,76 +643,104 @@ read_cmdline_options (struct cl_decoded_option *decoded_options,
continue;
}
- read_cmdline_option (&global_options, &global_options_set,
+ read_cmdline_option (opts, opts_set,
decoded_options + i, lang_mask, handlers,
global_dc);
}
}
-/* Parse command line options and set default flag values. Do minimal
- options processing. The decoded options are placed in *DECODED_OPTIONS
- and *DECODED_OPTIONS_COUNT. */
+/* Language mask determined at initialization. */
+static unsigned int initial_lang_mask;
+
+/* Initial values of parameters we reset. */
+static int initial_min_crossjump_insns;
+static int initial_max_fields_for_field_sensitive;
+static int initial_loop_invariant_max_bbs_in_loop;
+
+/* Initialize global options-related settings at start-up. */
+
void
-decode_options (unsigned int argc, const char **argv,
- struct cl_decoded_option **decoded_options,
- unsigned int *decoded_options_count)
+init_options_once (void)
{
- static bool first_time_p = true;
- static int initial_min_crossjump_insns;
- static int initial_max_fields_for_field_sensitive;
- static int initial_loop_invariant_max_bbs_in_loop;
- static unsigned int initial_lang_mask;
- struct cl_option_handlers handlers;
+ /* Perform language-specific options initialization. */
+ initial_lang_mask = lang_hooks.option_lang_mask ();
+
+ lang_hooks.initialize_diagnostics (global_dc);
+
+ /* Save initial values of parameters we reset. */
+ initial_min_crossjump_insns
+ = compiler_params[PARAM_MIN_CROSSJUMP_INSNS].value;
+ initial_max_fields_for_field_sensitive
+ = compiler_params[PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE].value;
+ initial_loop_invariant_max_bbs_in_loop
+ = compiler_params[PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP].value;
+}
- unsigned int i, lang_mask;
+/* Initialize OPTS and OPTS_SET before using them in parsing options. */
+
+void
+init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set)
+{
+ *opts = global_options_init;
+ memset (opts_set, 0, sizeof (*opts_set));
+
+ /* Use priority coloring if cover classes is not defined for the
+ target. */
+ if (targetm.ira_cover_classes == NULL)
+ opts->x_flag_ira_algorithm = IRA_ALGORITHM_PRIORITY;
+
+ /* Initialize whether `char' is signed. */
+ opts->x_flag_signed_char = DEFAULT_SIGNED_CHAR;
+ /* Set this to a special "uninitialized" value. The actual default
+ is set after target options have been processed. */
+ opts->x_flag_short_enums = 2;
+
+ /* Initialize target_flags before targetm.target_option.optimization
+ so the latter can modify it. */
+ opts->x_target_flags = targetm.default_target_flags;
+
+ /* Some targets have ABI-specified unwind tables. */
+ opts->x_flag_unwind_tables = targetm.unwind_tables_default;
+}
+
+/* Decode command-line options to an array, like
+ decode_cmdline_options_to_array and with the same arguments but
+ using the default lang_mask. */
+
+void
+decode_cmdline_options_to_array_default_mask (unsigned int argc,
+ const char **argv,
+ struct cl_decoded_option **decoded_options,
+ unsigned int *decoded_options_count)
+{
+ decode_cmdline_options_to_array (argc, argv,
+ initial_lang_mask | CL_COMMON | CL_TARGET,
+ decoded_options, decoded_options_count);
+}
+
+/* Default the options in OPTS and OPTS_SET based on the optimization
+ settings in DECODED_OPTIONS and DECODED_OPTIONS_COUNT. */
+static void
+default_options_optimization (struct gcc_options *opts,
+ struct gcc_options *opts_set,
+ struct cl_decoded_option *decoded_options,
+ unsigned int decoded_options_count)
+{
+ unsigned int i;
int opt1;
int opt2;
int opt3;
int opt1_max;
int ofast = 0;
- enum unwind_info_type ui_except;
-
- if (first_time_p)
- {
- /* Perform language-specific options initialization. */
- initial_lang_mask = lang_mask = lang_hooks.option_lang_mask ();
-
- lang_hooks.initialize_diagnostics (global_dc);
-
- /* Save initial values of parameters we reset. */
- initial_min_crossjump_insns
- = compiler_params[PARAM_MIN_CROSSJUMP_INSNS].value;
- initial_max_fields_for_field_sensitive
- = compiler_params[PARAM_MAX_FIELDS_FOR_FIELD_SENSITIVE].value;
- initial_loop_invariant_max_bbs_in_loop
- = compiler_params[PARAM_LOOP_INVARIANT_MAX_BBS_IN_LOOP].value;
- }
- else
- lang_mask = initial_lang_mask;
-
- decode_cmdline_options_to_array (argc, argv,
- lang_mask | CL_COMMON | CL_TARGET,
- decoded_options, decoded_options_count);
- if (first_time_p)
- /* Perform language-specific options initialization. */
- lang_hooks.init_options (*decoded_options_count, *decoded_options);
- handlers.unknown_option_callback = unknown_option_callback;
- handlers.wrong_lang_callback = complain_wrong_lang;
- handlers.post_handling_callback = post_handling_callback;
- handlers.num_handlers = 3;
- handlers.handlers[0].handler = lang_handle_option;
- handlers.handlers[0].mask = lang_mask;
- handlers.handlers[1].handler = common_handle_option;
- handlers.handlers[1].mask = CL_COMMON;
- handlers.handlers[2].handler = target_handle_option;
- handlers.handlers[2].mask = CL_TARGET;
+ gcc_assert (opts == &global_options);
+ gcc_assert (opts_set = &global_options_set);
/* Scan to see what optimization level has been specified. That will
determine the default value of many flags. */
- for (i = 1; i < *decoded_options_count; i++)
+ for (i = 1; i < decoded_options_count; i++)
{
- struct cl_decoded_option *opt = &(*decoded_options)[i];
+ struct cl_decoded_option *opt = &decoded_options[i];
switch (opt->opt_index)
{
case OPT_O:
@@ -755,11 +788,6 @@ decode_options (unsigned int argc, const char **argv,
}
}
- /* Use priority coloring if cover classes is not defined for the
- target. */
- if (targetm.ira_cover_classes == NULL)
- flag_ira_algorithm = IRA_ALGORITHM_PRIORITY;
-
/* -O1 optimizations. */
opt1 = (optimize >= 1);
flag_defer_pop = opt1;
@@ -879,38 +907,68 @@ decode_options (unsigned int argc, const char **argv,
targetm.handle_ofast ();
}
+ /* Allow default optimizations to be specified on a per-machine basis. */
+ targetm.target_option.optimization (optimize, optimize_size);
+}
+
+static void finish_options (struct gcc_options *, struct gcc_options *);
+
+/* Parse command line options and set default flag values. Do minimal
+ options processing. The decoded options are in *DECODED_OPTIONS
+ and *DECODED_OPTIONS_COUNT. */
+void
+decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
+ struct cl_decoded_option *decoded_options,
+ unsigned int decoded_options_count)
+{
+ struct cl_option_handlers handlers;
+
+ unsigned int lang_mask;
+
+ lang_mask = initial_lang_mask;
+
+ handlers.unknown_option_callback = unknown_option_callback;
+ handlers.wrong_lang_callback = complain_wrong_lang;
+ handlers.post_handling_callback = post_handling_callback;
+ handlers.num_handlers = 3;
+ handlers.handlers[0].handler = lang_handle_option;
+ handlers.handlers[0].mask = lang_mask;
+ handlers.handlers[1].handler = common_handle_option;
+ handlers.handlers[1].mask = CL_COMMON;
+ handlers.handlers[2].handler = target_handle_option;
+ handlers.handlers[2].mask = CL_TARGET;
+
/* Enable -Werror=coverage-mismatch by default */
enable_warning_as_error ("coverage-mismatch", 1, lang_mask, &handlers,
global_dc);
- if (first_time_p)
- {
- /* Initialize whether `char' is signed. */
- flag_signed_char = DEFAULT_SIGNED_CHAR;
- /* Set this to a special "uninitialized" value. The actual default is
- set after target options have been processed. */
- flag_short_enums = 2;
-
- /* Initialize target_flags before
- targetm.target_option.optimization so the latter can modify
- it. */
- target_flags = targetm.default_target_flags;
-
- /* Some targets have ABI-specified unwind tables. */
- flag_unwind_tables = targetm.unwind_tables_default;
- }
+ default_options_optimization (opts, opts_set,
+ decoded_options, decoded_options_count);
#ifdef ENABLE_LTO
/* Clear any options currently held for LTO. */
lto_clear_user_options ();
#endif
- /* Allow default optimizations to be specified on a per-machine basis. */
- targetm.target_option.optimization (optimize, optimize_size);
-
- read_cmdline_options (*decoded_options, *decoded_options_count, lang_mask,
+ read_cmdline_options (opts, opts_set,
+ decoded_options, decoded_options_count, lang_mask,
&handlers);
+ finish_options (opts, opts_set);
+}
+
+/* After all options have been read into OPTS and OPTS_SET, finalize
+ settings of those options and diagnose incompatible
+ combinations. */
+static void
+finish_options (struct gcc_options *opts, struct gcc_options *opts_set)
+{
+ static bool first_time_p = true;
+ enum unwind_info_type ui_except;
+
+ gcc_assert (opts == &global_options);
+ gcc_assert (opts_set = &global_options_set);
+
if (dump_base_name && ! IS_ABSOLUTE_PATH (dump_base_name))
{
/* First try to make DUMP_BASE_NAME relative to the DUMP_DIR_NAME