aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2011-03-31 23:37:14 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2011-03-31 23:37:14 +0100
commit300d83d9de11381aa48273d5bdacb006955aa85f (patch)
tree329a018906d50347a718b59278baff52475262ef /gcc
parent4bce572db2a654c9f17bb798b8469df11d3147e3 (diff)
downloadgcc-300d83d9de11381aa48273d5bdacb006955aa85f.zip
gcc-300d83d9de11381aa48273d5bdacb006955aa85f.tar.gz
gcc-300d83d9de11381aa48273d5bdacb006955aa85f.tar.bz2
opts.h (cl_option): Add comments to fields.
* opts.h (cl_option): Add comments to fields. Add bit-fields for various flags. (CL_SEPARATE_NARGS_SHIFT, CL_SEPARATE_NARGS_MASK, CL_SEPARATE_ALIAS, CL_NO_DRIVER_ARG, CL_REJECT_DRIVER, CL_SAVE, CL_DISABLED, CL_REPOR, CL_REJECT_NEGATIVE, CL_MISSING_OK, CL_UINTEGER, CL_NEGATIVE_ALIAS): Remove. (CL_JOINED, CL_SEPARATE, CL_UNDOCUMENTED): Update bit positions. * opt-functions.awk (flag_init, switch_bit_fields): New. (switch_flags): Don't handle flags moved to bit-fields. Don't generate CL_MISSING_OK or CL_SAVE. * optc-gen.awk: Update to generate bit-field output as well as flags field. * gcc.c (driver_wrong_lang_callback): Use cl_reject_driver bit-field instead of CL_REJECT_DRIVER flag. * opts-common.c (generate_canonical_option, decode_cmdline_option): Use bit-fields instead of CL_* flags. * opts.c (maybe_default_option): Use cl_reject_negative bit-field instead of CL_REJECT_NEGATIVE flag. * toplev.c (print_switch_values): Use cl_report bit-field instead of CL_REPORT flag. From-SVN: r171804
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog23
-rw-r--r--gcc/gcc.c2
-rw-r--r--gcc/opt-functions.awk51
-rw-r--r--gcc/optc-gen.awk12
-rw-r--r--gcc/opts-common.c40
-rw-r--r--gcc/opts.c2
-rw-r--r--gcc/opts.h61
-rw-r--r--gcc/toplev.c2
8 files changed, 133 insertions, 60 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 045f18f..b293750 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,26 @@
+2011-03-31 Joseph Myers <joseph@codesourcery.com>
+
+ * opts.h (cl_option): Add comments to fields. Add bit-fields for
+ various flags.
+ (CL_SEPARATE_NARGS_SHIFT, CL_SEPARATE_NARGS_MASK,
+ CL_SEPARATE_ALIAS, CL_NO_DRIVER_ARG, CL_REJECT_DRIVER, CL_SAVE,
+ CL_DISABLED, CL_REPOR, CL_REJECT_NEGATIVE, CL_MISSING_OK,
+ CL_UINTEGER, CL_NEGATIVE_ALIAS): Remove.
+ (CL_JOINED, CL_SEPARATE, CL_UNDOCUMENTED): Update bit positions.
+ * opt-functions.awk (flag_init, switch_bit_fields): New.
+ (switch_flags): Don't handle flags moved to bit-fields. Don't
+ generate CL_MISSING_OK or CL_SAVE.
+ * optc-gen.awk: Update to generate bit-field output as well as
+ flags field.
+ * gcc.c (driver_wrong_lang_callback): Use cl_reject_driver
+ bit-field instead of CL_REJECT_DRIVER flag.
+ * opts-common.c (generate_canonical_option,
+ decode_cmdline_option): Use bit-fields instead of CL_* flags.
+ * opts.c (maybe_default_option): Use cl_reject_negative bit-field
+ instead of CL_REJECT_NEGATIVE flag.
+ * toplev.c (print_switch_values): Use cl_report bit-field instead
+ of CL_REPORT flag.
+
2011-03-31 Eric Botcazou <ebotcazou@adacore.com>
* tree-ssa-pre.c (create_component_ref_by_pieces_1) <ARRAY_REF>: Drop
diff --git a/gcc/gcc.c b/gcc/gcc.c
index c399d14..7ad959a 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3115,7 +3115,7 @@ driver_wrong_lang_callback (const struct cl_decoded_option *decoded,
options. */
const struct cl_option *option = &cl_options[decoded->opt_index];
- if (option->flags & CL_REJECT_DRIVER)
+ if (option->cl_reject_driver)
error ("unrecognized command line option %qs",
decoded->orig_option_with_args_text);
else
diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk
index f5f5cd4..19bdf3a 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -42,6 +42,16 @@ function test_flag(regex, flags, string)
return ""
}
+# Return a field initializer, with trailing comma, for a field that is
+# 1 if FLAGS contains a flag matching REGEX and 0 otherwise.
+function flag_init(regex, flags)
+{
+ if (flag_set_p(regex, flags))
+ return "1 /* " regex " */, "
+ else
+ return "0, "
+}
+
# If FLAGS contains a "NAME(...argument...)" flag, return the value
# of the argument. Return the empty string otherwise.
function opt_args(name, flags)
@@ -87,27 +97,38 @@ function switch_flags (flags)
test_flag("Common", flags, " | CL_COMMON") \
test_flag("Target", flags, " | CL_TARGET") \
test_flag("Driver", flags, " | CL_DRIVER") \
- test_flag("RejectDriver", flags, " | CL_REJECT_DRIVER") \
- test_flag("NoDriverArg", flags, " | CL_NO_DRIVER_ARG") \
- test_flag("SeparateAlias", flags, " | CL_SEPARATE_ALIAS") \
- test_flag("NegativeAlias", flags, " | CL_NEGATIVE_ALIAS") \
- test_flag("Save", flags, " | CL_SAVE") \
test_flag("Joined", flags, " | CL_JOINED") \
- test_flag("JoinedOrMissing", flags, " | CL_JOINED | CL_MISSING_OK") \
+ test_flag("JoinedOrMissing", flags, " | CL_JOINED") \
test_flag("Separate", flags, " | CL_SEPARATE") \
- test_flag("RejectNegative", flags, " | CL_REJECT_NEGATIVE") \
- test_flag("UInteger", flags, " | CL_UINTEGER") \
test_flag("Undocumented", flags, " | CL_UNDOCUMENTED") \
test_flag("Warning", flags, " | CL_WARNING") \
- test_flag("Optimization", flags, " | CL_OPTIMIZATION") \
- test_flag("Report", flags, " | CL_REPORT")
+ test_flag("Optimization", flags, " | CL_OPTIMIZATION")
+ sub( "^0 \\| ", "", result )
+ return result
+}
+
+# Return bit-field initializers for option flags FLAGS.
+function switch_bit_fields (flags)
+{
+ result = ""
sep_args = opt_args("Args", flags)
- if (sep_args != "") {
+ if (sep_args == "")
+ sep_args = 0
+ else
sep_args--
- result = result " | (" sep_args \
- " << CL_SEPARATE_NARGS_SHIFT)"
- }
- sub( "^0 \\| ", "", result )
+ result = result sep_args ", "
+
+ result = result \
+ flag_init("SeparateAlias", flags) \
+ flag_init("NegativeAlias", flags) \
+ flag_init("NoDriverArg", flags) \
+ flag_init("RejectDriver", flags) \
+ flag_init("RejectNegative", flags) \
+ flag_init("JoinedOrMissing", flags) \
+ flag_init("UInteger", flags) \
+ flag_init("Report", flags)
+
+ sub(", $", "", result)
return result
}
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index 24def35..a821c64 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -401,15 +401,21 @@ for (i = 0; i < n_opts; i++) {
printf(" %d,\n", idx)
condition = opt_args("Condition", flags[i])
cl_flags = switch_flags(flags[i])
+ cl_bit_fields = switch_bit_fields(flags[i])
+ cl_zero_bit_fields = switch_bit_fields("")
if (condition != "")
printf("#if %s\n" \
" %s,\n" \
+ " 0, %s,\n" \
"#else\n" \
- " CL_DISABLED,\n" \
+ " 0,\n" \
+ " 1 /* Disabled. */, %s,\n" \
"#endif\n",
- condition, cl_flags, cl_flags)
+ condition, cl_flags, cl_bit_fields, cl_zero_bit_fields)
else
- printf(" %s,\n", cl_flags)
+ printf(" %s,\n" \
+ " 0, %s,\n",
+ cl_flags, cl_bit_fields)
printf(" %s, %s }%s\n", var_ref(opts[i], flags[i]),
var_set(flags[i]), comma)
}
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index a88aed0..f54d64a 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -257,7 +257,7 @@ generate_canonical_option (size_t opt_index, const char *arg, int value,
const char *opt_text = option->opt_text;
if (value == 0
- && !(option->flags & CL_REJECT_NEGATIVE)
+ && !option->cl_reject_negative
&& (opt_text[1] == 'W' || opt_text[1] == 'f' || opt_text[1] == 'm'))
{
char *t = XNEWVEC (char, option->opt_len + 5);
@@ -276,7 +276,7 @@ generate_canonical_option (size_t opt_index, const char *arg, int value,
if (arg)
{
if ((option->flags & CL_SEPARATE)
- && !(option->flags & CL_SEPARATE_ALIAS))
+ && !option->cl_separate_alias)
{
decoded->canonical_option[0] = opt_text;
decoded->canonical_option[1] = arg;
@@ -412,7 +412,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
/* Reject negative form of switches that don't take negatives as
unrecognized. */
- if (!value && (option->flags & CL_REJECT_NEGATIVE))
+ if (!value && option->cl_reject_negative)
{
opt_index = OPT_SPECIAL_unknown;
errors |= CL_ERR_NEGATIVE;
@@ -424,18 +424,17 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
warn_message = option->warn_message;
/* Check to see if the option is disabled for this configuration. */
- if (option->flags & CL_DISABLED)
+ if (option->cl_disabled)
errors |= CL_ERR_DISABLED;
/* Determine whether there may be a separate argument based on
whether this option is being processed for the driver, and, if
so, how many such arguments. */
separate_arg_flag = ((option->flags & CL_SEPARATE)
- && !((option->flags & CL_NO_DRIVER_ARG)
+ && !(option->cl_no_driver_arg
&& (lang_mask & CL_DRIVER)));
separate_args = (separate_arg_flag
- ? ((option->flags & CL_SEPARATE_NARGS_MASK)
- >> CL_SEPARATE_NARGS_SHIFT) + 1
+ ? option->cl_separate_nargs + 1
: 0);
joined_arg_flag = (option->flags & CL_JOINED) != 0;
@@ -447,7 +446,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
argument to be persistent until the program exits. */
arg = argv[extra_args] + cl_options[opt_index].opt_len + 1 + adjust_len;
- if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
+ if (*arg == '\0' && !option->cl_missing_ok)
{
if (separate_arg_flag)
{
@@ -483,7 +482,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
/* Is this option an alias (or an ignored option, marked as an alias
of OPT_SPECIAL_ignore)? */
if (option->alias_target != N_OPTS
- && (!(option->flags & CL_SEPARATE_ALIAS) || have_separate_arg))
+ && (!option->cl_separate_alias || have_separate_arg))
{
size_t new_opt_index = option->alias_target;
@@ -501,13 +500,13 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
/* The new option must not be an alias itself. */
gcc_assert (new_option->alias_target == N_OPTS
- || (new_option->flags & CL_SEPARATE_ALIAS));
+ || new_option->cl_separate_alias);
if (option->neg_alias_arg)
{
gcc_assert (option->alias_arg != NULL);
gcc_assert (arg == NULL);
- gcc_assert (!(option->flags & CL_NEGATIVE_ALIAS));
+ gcc_assert (!option->cl_negative_alias);
if (value)
arg = option->alias_arg;
else
@@ -518,35 +517,34 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
{
gcc_assert (value == 1);
gcc_assert (arg == NULL);
- gcc_assert (!(option->flags & CL_NEGATIVE_ALIAS));
+ gcc_assert (!option->cl_negative_alias);
arg = option->alias_arg;
}
- if (option->flags & CL_NEGATIVE_ALIAS)
+ if (option->cl_negative_alias)
value = !value;
opt_index = new_opt_index;
option = new_option;
if (value == 0)
- gcc_assert (!(option->flags & CL_REJECT_NEGATIVE));
+ gcc_assert (!option->cl_reject_negative);
/* Recompute what arguments are allowed. */
separate_arg_flag = ((option->flags & CL_SEPARATE)
- && !((option->flags & CL_NO_DRIVER_ARG)
+ && !(option->cl_no_driver_arg
&& (lang_mask & CL_DRIVER)));
joined_arg_flag = (option->flags & CL_JOINED) != 0;
- if (separate_args > 1 || (option->flags & CL_SEPARATE_NARGS_MASK))
+ if (separate_args > 1 || option->cl_separate_nargs)
gcc_assert (separate_args
- == ((option->flags & CL_SEPARATE_NARGS_MASK)
- >> CL_SEPARATE_NARGS_SHIFT) + 1);
+ == (unsigned int) option->cl_separate_nargs + 1);
if (!(errors & CL_ERR_MISSING_ARG))
{
if (separate_arg_flag || joined_arg_flag)
{
- if ((option->flags & CL_MISSING_OK) && arg == NULL)
+ if (option->cl_missing_ok && arg == NULL)
arg = "";
gcc_assert (arg != NULL);
}
@@ -560,7 +558,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
gcc_assert (warn_message == NULL);
warn_message = option->warn_message;
}
- if (option->flags & CL_DISABLED)
+ if (option->cl_disabled)
errors |= CL_ERR_DISABLED;
}
}
@@ -570,7 +568,7 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
errors |= CL_ERR_WRONG_LANG;
/* If the switch takes an integer, convert it. */
- if (arg && (option->flags & CL_UINTEGER))
+ if (arg && option->cl_uinteger)
{
value = integral_argument (arg);
if (value == -1)
diff --git a/gcc/opts.c b/gcc/opts.c
index 8cce46a..cd581f6 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -382,7 +382,7 @@ maybe_default_option (struct gcc_options *opts,
lang_mask, DK_UNSPECIFIED, loc,
handlers, dc);
else if (default_opt->arg == NULL
- && !(option->flags & CL_REJECT_NEGATIVE))
+ && !option->cl_reject_negative)
handle_generated_option (opts, opts_set, default_opt->opt_index,
default_opt->arg, !default_opt->value,
lang_mask, DK_UNSPECIFIED, loc,
diff --git a/gcc/opts.h b/gcc/opts.h
index 4911778..15e717d 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -53,20 +53,60 @@ enum cl_var_type {
struct cl_option
{
+ /* Text of the option, including initial '-'. */
const char *opt_text;
+ /* Help text for --help, or NULL. */
const char *help;
+ /* Error message for missing argument, or NULL. */
const char *missing_argument_error;
+ /* Warning to give when this option is used, or NULL. */
const char *warn_message;
+ /* Argument of alias target when positive option given, or NULL. */
const char *alias_arg;
+ /* Argument of alias target when negative option given, or NULL. */
const char *neg_alias_arg;
+ /* Alias target, or N_OPTS if not an alias. */
unsigned short alias_target;
+ /* Previous option that is an initial substring of this one, or
+ N_OPTS if none. */
unsigned short back_chain;
+ /* Option length, not including initial '-'. */
unsigned char opt_len;
+ /* Next option in a sequence marked with Negative, or -1 if none. */
int neg_index;
+ /* CL_* flags for this option. */
unsigned int flags;
+ /* Disabled in this configuration. */
+ BOOL_BITFIELD cl_disabled : 1;
+ /* Options marked with CL_SEPARATE take a number of separate
+ arguments (1 to 4) that is one more than the number in this
+ bit-field. */
+ unsigned int cl_separate_nargs : 2;
+ /* Option is an alias when used with separate argument. */
+ BOOL_BITFIELD cl_separate_alias : 1;
+ /* Alias to negative form of option. */
+ BOOL_BITFIELD cl_negative_alias : 1;
+ /* Option takes no argument in the driver. */
+ BOOL_BITFIELD cl_no_driver_arg : 1;
+ /* Reject this option in the driver. */
+ BOOL_BITFIELD cl_reject_driver : 1;
+ /* Reject no- form. */
+ BOOL_BITFIELD cl_reject_negative : 1;
+ /* Missing argument OK (joined). */
+ BOOL_BITFIELD cl_missing_ok : 1;
+ /* Argument is an integer >=0. */
+ BOOL_BITFIELD cl_uinteger : 1;
+ /* Report argument with -fverbose-asm */
+ BOOL_BITFIELD cl_report : 1;
+ /* Offset of field for this option in struct gcc_options, or
+ (unsigned short) -1 if none. */
unsigned short flag_var_offset;
+ /* Index in cl_enums of enum used for this option's arguments, for
+ CLVC_ENUM options. */
unsigned short var_enum;
+ /* How this option's value is determined and sets a field. */
enum cl_var_type var_type;
+ /* Value or bit-mask with which to set a field. */
int var_value;
};
@@ -98,24 +138,9 @@ extern const unsigned int cl_lang_count;
This distinction is important because --help will not list options
which only have these higher bits set. */
-/* Options marked with CL_SEPARATE take a number of separate arguments
- (1 to 4) that is one more than the number in this bit-field. */
-#define CL_SEPARATE_NARGS_SHIFT 17
-#define CL_SEPARATE_NARGS_MASK (3U << CL_SEPARATE_NARGS_SHIFT)
-
-#define CL_SEPARATE_ALIAS (1U << 19) /* Option is an alias when used with separate argument. */
-#define CL_NO_DRIVER_ARG (1U << 20) /* Option takes no argument in the driver. */
-#define CL_REJECT_DRIVER (1U << 21) /* Reject this option in the driver. */
-#define CL_SAVE (1U << 22) /* Target-specific option for attribute. */
-#define CL_DISABLED (1U << 23) /* Disabled in this configuration. */
-#define CL_REPORT (1U << 24) /* Report argument with -fverbose-asm */
-#define CL_JOINED (1U << 25) /* If takes joined argument. */
-#define CL_SEPARATE (1U << 26) /* If takes a separate argument. */
-#define CL_REJECT_NEGATIVE (1U << 27) /* Reject no- form. */
-#define CL_MISSING_OK (1U << 28) /* Missing argument OK (joined). */
-#define CL_UINTEGER (1U << 29) /* Argument is an integer >=0. */
-#define CL_UNDOCUMENTED (1U << 30) /* Do not output with --help. */
-#define CL_NEGATIVE_ALIAS (1U << 31) /* Alias to negative form of option. */
+#define CL_JOINED (1U << 17) /* If takes joined argument. */
+#define CL_SEPARATE (1U << 18) /* If takes a separate argument. */
+#define CL_UNDOCUMENTED (1U << 19) /* Do not output with --help. */
/* Flags for an enumerated option argument. */
#define CL_ENUM_CANONICAL (1 << 0) /* Canonical for this value. */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 64af112..3b154a6 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -891,7 +891,7 @@ print_switch_values (print_switch_fn_type print_fn)
SWITCH_TYPE_DESCRIPTIVE, _("options enabled: "));
for (j = 0; j < cl_options_count; j++)
- if ((cl_options[j].flags & CL_REPORT)
+ if (cl_options[j].cl_report
&& option_enabled (j, &global_options) > 0)
pos = print_single_switch (print_fn, pos,
SWITCH_TYPE_ENABLED, cl_options[j].opt_text);