summaryrefslogtreecommitdiff
path: root/gcc/opts.c
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-14 20:18:43 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-14 20:18:43 +0000
commitff05e09e2d0d3b01e2dbc1d0d6d869cd0b1ce745 (patch)
tree93e6840750fcec57ca9299b96d2ddd12e82c2805 /gcc/opts.c
parent3d2931b52bc6e77b35fac2cabaf7e5e91db63f9a (diff)
downloadgcc-ff05e09e2d0d3b01e2dbc1d0d6d869cd0b1ce745.tar.gz
* config.gcc (extra_options): New variable for listing option files.
Add ${cpu_type}/${cpu_type}.opt to it if that file exists. * configure.ac (extra_opt_files): New AC_SUBST variable. (tm_file_list, tm_include_list): Include options.h first. * configure: Regenerate. * Makefile.in (extra_opt_files, ALL_OPT_FILES): New variables. (s-options): Use $(ALL_OPT_FILES) instead of $(lang_opt_files) (s-options-h): New rule. (options.h): Depend on it. (TEXI_GCCINT_FILES): Add options.texi. * hooks.h (hook_bool_size_t_constcharptr_int_true): Declare. * hooks.c (hook_bool_size_t_constcharptr_int_true): New function. * target.h (gcc_target): Add default_target_flags and handle_option. * target-def.h (TARGET_DEFAULT_TARGET_FLAGS) (TARGET_HANDLE_OPTION): New macros. (TARGET_INITIALIZER): Include them. * opt-functions.awk (opt_args, nth_arg): New functions. (switch_flags): Handle the "Target" flag. (var_args): Delete. (var_name): Use opt_args and nth_arg. (var_set, var_ref): Likewise. Handle "Mask" and "InverseMask". * opth-gen.awk: Declare target_flags. Declare MASK_* and TARGET_* macros for the "Mask" and "InverseMask" options. * opts.h (cl_var_cond): New enum. (cl_option): Replace the "has_set_value" and "set_value" fields with "var_cond" and "var_value". (CL_TARGET): New macro. (option_enabled, print_filtered_help): Declare. (decode_options): Move definition. * opts.c (handle_option): Search for the original option before removing any "no-" prefix. Handle CL_TARGET. Adjust for the new var_cond and var_value fields. Use targetm.handle_option to handle target options. (decode_options): Set target_flags to targetm.default_target_flags. (print_filtered_help): Make global. Handle CL_TARGET. (option_enabled): New function. * toplev.c (target_switches): Guard with #ifdef TARGET_SWITCHES. (display_target_options, set_target_switch, print_switch_values) (default_pch_valid_p): Guard uses of target_switches with #ifdef TARGET_SWITCHES. Also... (display_target_options): Display the CL_TARGET entries in cl_options. (set_target_option): Don't complain about the "" option when TARGET_SWITCHES is undefined. (print_switch_values): Use option_enabled. (default_pch_valid_p): Check cl_options[] when looking for something that has changed the value of target_flags. * c.opt: Remove documentation from top of file. * doc/gccint.texi: Add an "Options" chapter. Include options.texi. * doc/sourecebuild.texi: Refer to the new options documentation instead of c.opt. Document machine-specific .opt files. * doc/tm.texi (target_flags): Say that this variable is declared by options.h. (TARGET_DEFAULT_TARGET_FLAGS, TARGET_HANDLE_OPTION): Document. (TARGET_SWITCHES, TARGET_OPTIONS): Refer to the option files as an alternative. * doc/options.texi: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96448 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts.c')
-rw-r--r--gcc/opts.c74
1 files changed, 56 insertions, 18 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index c6940013a50..3361c9fe724 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -112,7 +112,6 @@ static void handle_options (unsigned int, const char **, unsigned int);
static void wrap_help (const char *help, const char *item, unsigned int);
static void print_help (void);
static void print_param_help (void);
-static void print_filtered_help (unsigned int flag);
static unsigned int print_switch (const char *text, unsigned int indent);
static void set_debug_level (enum debug_info_type type, int extended,
const char *arg);
@@ -277,10 +276,12 @@ handle_option (const char **argv, unsigned int lang_mask)
opt = argv[0];
- /* Drop the "no-" from negative switches. */
- if ((opt[1] == 'W' || opt[1] == 'f')
+ opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET);
+ if (opt_index == cl_options_count
+ && (opt[1] == 'W' || opt[1] == 'f' || opt[1] == 'm')
&& opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
{
+ /* Drop the "no-" from negative switches. */
size_t len = strlen (opt) - 3;
dup = xmalloc (len + 1);
@@ -289,9 +290,9 @@ handle_option (const char **argv, unsigned int lang_mask)
memcpy (dup + 2, opt + 5, len - 2 + 1);
opt = dup;
value = 0;
+ opt_index = find_opt (opt + 1, lang_mask | CL_COMMON | CL_TARGET);
}
- opt_index = find_opt (opt + 1, lang_mask | CL_COMMON);
if (opt_index == cl_options_count)
goto done;
@@ -335,7 +336,7 @@ handle_option (const char **argv, unsigned int lang_mask)
/* Now we've swallowed any potential argument, complain if this
is a switch for a different front end. */
- if (!(option->flags & (lang_mask | CL_COMMON)))
+ if (!(option->flags & (lang_mask | CL_COMMON | CL_TARGET)))
{
complain_wrong_lang (argv[0], option, lang_mask);
goto done;
@@ -361,17 +362,26 @@ handle_option (const char **argv, unsigned int lang_mask)
}
if (option->flag_var)
- {
- if (option->has_set_value)
- {
- if (value)
- *option->flag_var = option->set_value;
- else
- *option->flag_var = !option->set_value;
- }
- else
+ switch (option->var_cond)
+ {
+ case CLVC_BOOLEAN:
*option->flag_var = value;
- }
+ break;
+
+ case CLVC_EQUAL:
+ *option->flag_var = value ? option->var_value : !option->var_value;
+ break;
+
+ case CLVC_BIT_CLEAR:
+ case CLVC_BIT_SET:
+ if ((value != 0) == (option->var_cond == CLVC_BIT_SET))
+ *option->flag_var |= option->var_value;
+ else
+ *option->flag_var &= ~option->var_value;
+ if (option->flag_var == &target_flags)
+ target_flags_explicit |= option->var_value;
+ break;
+ }
if (option->flags & lang_mask)
if (lang_hooks.handle_option (opt_index, arg, value) == 0)
@@ -381,6 +391,10 @@ handle_option (const char **argv, unsigned int lang_mask)
if (common_handle_option (opt_index, arg, value) == 0)
result = 0;
+ if (result && (option->flags & CL_TARGET))
+ if (!targetm.handle_option (opt_index, arg, value))
+ result = 0;
+
done:
if (dup)
free (dup);
@@ -591,7 +605,7 @@ decode_options (unsigned int argc, const char **argv)
/* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
modify it. */
- target_flags = 0;
+ target_flags = targetm.default_target_flags;
set_target_switch ("");
/* Unwind tables are always present when a target has ABI-specified unwind
@@ -1223,7 +1237,7 @@ print_param_help (void)
}
/* Print help for a specific front-end, etc. */
-static void
+void
print_filtered_help (unsigned int flag)
{
unsigned int i, len, filter, indent = 0;
@@ -1231,7 +1245,7 @@ print_filtered_help (unsigned int flag)
const char *help, *opt, *tab;
static char *printed;
- if (flag == CL_COMMON)
+ if (flag == CL_COMMON || flag == CL_TARGET)
{
filter = flag;
if (!printed)
@@ -1378,3 +1392,27 @@ wrap_help (const char *help, const char *item, unsigned int item_width)
}
while (remaining);
}
+
+/* Return 1 if OPTION is enabled, 0 if it is disabled, or -1 if it isn't
+ a simple on-off switch. */
+
+int
+option_enabled (const struct cl_option *option)
+{
+ if (option->flag_var)
+ switch (option->var_cond)
+ {
+ case CLVC_BOOLEAN:
+ return *option->flag_var != 0;
+
+ case CLVC_EQUAL:
+ return *option->flag_var == option->var_value;
+
+ case CLVC_BIT_CLEAR:
+ return (*option->flag_var & option->var_value) == 0;
+
+ case CLVC_BIT_SET:
+ return (*option->flag_var & option->var_value) != 0;
+ }
+ return -1;
+}