aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts-common.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-09-30 14:53:12 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2010-09-30 14:53:12 +0100
commit46625112d2613f6573f307c99b8e10c970748e15 (patch)
tree9e8ddd32df9fcfb0446877af547d5a2daa89da8b /gcc/opts-common.c
parent37ccfc46e8f0005bb8a3e08c189b95ca9948059a (diff)
downloadgcc-46625112d2613f6573f307c99b8e10c970748e15.zip
gcc-46625112d2613f6573f307c99b8e10c970748e15.tar.gz
gcc-46625112d2613f6573f307c99b8e10c970748e15.tar.bz2
opt-functions.awk (static_var): Update comment.
* opt-functions.awk (static_var): Update comment. (var_ref): Return offsetof expression or -1, not variable address. * optc-gen.awk: Generate structure field initializers instead of static variables. Expect -1 for missing variables instead of null pointer. Add gcc_options parameters to generated functions. * opth-gen.awk: Generate structure fields for static variables. Add gcc_options parameters to generated functions. * common.opt (optimize, optimize_size): Add variables. * config/i386/i386-c.c (ix86_pragma_target_parse): Pass &global_options to cl_target_option_restore. * config/i386/i386.c (ix86_valid_target_attribute_p): Pass &global_options to cl_optimization_restore, cl_target_option_save and cl_target_option_restore. (ix86_set_current_function): Pass &global_options to cl_target_option_restore. * config/pdp11/pdp11.h (optimize): Remove. * config/rs6000/rs6000.h (optimize): Remove. * config/sh/sh.h (optimize): Remove. * config/xtensa/xtensa.h (optimize): Remove. * coretypes.h (struct gcc_options): Declare. * diagnostic.c (diagnostic_initialize): Initialize context->option_state. (diagnostic_report_diagnostic): Pass option_state to option_enabled hook. * diagnostic.h (diagnostic_context.option_enabled): Add void * parameter. (diagnostic_context.option_state): New field. * final.c (final_start_function, final, final_scan_insn): Rename optimize parameter to optimize_p. * flags.h (optimize, optimize_size): Remove. * function.c (invoke_set_current_function_hook): Pass &global_options to cl_optimization_restore. * gcc.c (driver_handle_option): Take gcc_options parameter. Assert that it is &global_options. (process_command): Pass &global_options to read_cmdline_option. * ipa-pure-const.c (suggest_attribute): Pass &global_options to option_enabled. * lto-opts.c (lto_reissue_options): Use option_flag_var. Pass &global_options to set_option. * opts-common.c (handle_option, handle_generated_option, read_cmdline_option, set_option): Take explicit gcc_options parameters. Use option_flag_var. (option_flag_var): New. * opts.c (common_handle_option, lang_handle_option, target_handle_option): Take gcc_options parameter. Assert that it is &global_options. (read_cmdline_options): Pass &global_options to read_cmdline_option. (print_filtered_help): Use option_flag_var. Pass &global_options to option_enabled. (common_handle_option): Use option_flag_var. (option_enabled): Take opts parameter. Use option_flag_var. (get_option_state): Take gcc_options parameter. Use option_flag_var. Pass gcc_options parameter to option_enabled. (enable_warning_as_error): Pass &global_options to handle_generated_option. * opts.h (struct cl_option): Change flag_var to flag_var_offset. (cl_option_handler_func.handler): Take gcc_options parameter. (option_enabled, get_option_state, set_option, handle_option, handle_generated_option, read_cmdline_option): Take gcc_options parameters. * toplev.c (optimize, optimize_size): Remove. (print_switch_values): Pass &global_options to option_enabled. (option_affects_pch_p): Use option_flag_var. Pass &global_options to get_option_state. (general_init): Initialize global_dc->option_state. * tree.c (build_optimization_node): Pass &global_options to cl_optimization_save. (build_target_option_node): Pass &global_options to cl_target_option_save. c-family: * c-common.c (handle_optimize_attribute): Pass &global_options to cl_optimization_save and cl_optimization_restore. * c-opts.c (c_common_handle_option): Pass &global_options to handle_generated_option. * c-pragma.c (handle_pragma_diagnostic): Use option_flag_var. (handle_pragma_pop_options, handle_pragma_reset_options): Pass &global_options to cl_optimization_restore. From-SVN: r164751
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r--gcc/opts-common.c65
1 files changed, 42 insertions, 23 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 078610f..09e5b11 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -799,12 +799,13 @@ keep:
}
/* Handle option DECODED for the language indicated by LANG_MASK,
- using the handlers in HANDLERS. KIND is the diagnostic_t if this
- is a diagnostics option, DK_UNSPECIFIED otherwise. Returns false
- if the switch was invalid. */
+ using the handlers in HANDLERS and setting fields in OPTS. KIND is
+ the diagnostic_t if this is a diagnostics option, DK_UNSPECIFIED
+ otherwise. Returns false if the switch was invalid. */
bool
-handle_option (const struct cl_decoded_option *decoded,
+handle_option (struct gcc_options *opts,
+ const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind,
const struct cl_option_handlers *handlers)
{
@@ -812,15 +813,16 @@ handle_option (const struct cl_decoded_option *decoded,
const char *arg = decoded->arg;
int value = decoded->value;
const struct cl_option *option = &cl_options[opt_index];
+ void *flag_var = option_flag_var (opt_index, opts);
size_t i;
- if (option->flag_var)
- set_option (opt_index, value, arg, kind);
+ if (flag_var)
+ set_option (opts, opt_index, value, arg, kind);
for (i = 0; i < handlers->num_handlers; i++)
if (option->flags & handlers->handlers[i].mask)
{
- if (!handlers->handlers[i].handler (decoded,
+ if (!handlers->handlers[i].handler (opts, decoded,
lang_mask, kind, handlers))
return false;
else
@@ -837,14 +839,15 @@ handle_option (const struct cl_decoded_option *decoded,
command line. */
bool
-handle_generated_option (size_t opt_index, const char *arg, int value,
+handle_generated_option (struct gcc_options *opts, size_t opt_index,
+ const char *arg, int value,
unsigned int lang_mask, int kind,
const struct cl_option_handlers *handlers)
{
struct cl_decoded_option decoded;
generate_option (opt_index, arg, value, lang_mask, &decoded);
- return handle_option (&decoded, lang_mask, kind, handlers);
+ return handle_option (opts, &decoded, lang_mask, kind, handlers);
}
/* Fill in *DECODED with an option described by OPT_INDEX, ARG and
@@ -903,10 +906,11 @@ generate_option_input_file (const char *file,
}
/* Handle the switch DECODED for the language indicated by LANG_MASK,
- using the handlers in *HANDLERS. */
+ using the handlers in *HANDLERS and setting fields in OPTS. */
void
-read_cmdline_option (struct cl_decoded_option *decoded,
+read_cmdline_option (struct gcc_options *opts,
+ struct cl_decoded_option *decoded,
unsigned int lang_mask,
const struct cl_option_handlers *handlers)
{
@@ -959,45 +963,47 @@ read_cmdline_option (struct cl_decoded_option *decoded,
gcc_assert (!decoded->errors);
- if (!handle_option (decoded, lang_mask, DK_UNSPECIFIED, handlers))
+ if (!handle_option (opts, decoded, lang_mask, DK_UNSPECIFIED, handlers))
error ("unrecognized command line option %qs", opt);
}
-/* Set any variable for option OPT_INDEX according to VALUE and ARG,
+/* Set any field in OPTS for option OPT_INDEX according to VALUE and ARG,
diagnostic kind KIND. */
void
-set_option (int opt_index, int value, const char *arg, int kind)
+set_option (struct gcc_options *opts, int opt_index, int value,
+ const char *arg, int kind)
{
const struct cl_option *option = &cl_options[opt_index];
+ void *flag_var = option_flag_var (opt_index, opts);
- if (!option->flag_var)
+ if (!flag_var)
return;
switch (option->var_type)
{
case CLVC_BOOLEAN:
- *(int *) option->flag_var = value;
+ *(int *) flag_var = value;
break;
case CLVC_EQUAL:
- *(int *) option->flag_var = (value
- ? option->var_value
- : !option->var_value);
+ *(int *) flag_var = (value
+ ? option->var_value
+ : !option->var_value);
break;
case CLVC_BIT_CLEAR:
case CLVC_BIT_SET:
if ((value != 0) == (option->var_type == CLVC_BIT_SET))
- *(int *) option->flag_var |= option->var_value;
+ *(int *) flag_var |= option->var_value;
else
- *(int *) option->flag_var &= ~option->var_value;
- if (option->flag_var == &target_flags)
+ *(int *) flag_var &= ~option->var_value;
+ if (flag_var == &target_flags)
target_flags_explicit |= option->var_value;
break;
case CLVC_STRING:
- *(const char **) option->flag_var = arg;
+ *(const char **) flag_var = arg;
break;
}
@@ -1005,3 +1011,16 @@ set_option (int opt_index, int value, const char *arg, int kind)
diagnostic_classify_diagnostic (global_dc, opt_index, (diagnostic_t) kind,
UNKNOWN_LOCATION);
}
+
+/* Return the address of the flag variable for option OPT_INDEX in
+ options structure OPTS, or NULL if there is no flag variable. */
+
+void *
+option_flag_var (int opt_index, struct gcc_options *opts)
+{
+ const struct cl_option *option = &cl_options[opt_index];
+
+ if (option->flag_var_offset == (unsigned short) -1)
+ return NULL;
+ return (void *)(((char *) opts) + option->flag_var_offset);
+}