This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [options] Allow Var() and Mask() to be used together
> It sounds like we'll have TARGET_* macros associated with non-target
> things. Using MASK_* constants for non-target options might also be
> dangerous because of the risk of a name clash.
>
> I think it would also make sense to extend:
This one uses:
#define OPTION_MASK_BART (1 << 1)
#define OPTION_BART ((warn_dj2 & OPTION_MASK_BART) != 0)
for this:
Wdj-bart
C Var(warn_dj2) Mask(BART)
Warn about DJ bart
with these errors:
#error too many target masks
#error too many masks for warn_dj
Index: optc-gen.awk
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optc-gen.awk,v
retrieving revision 2.4
diff -p -U3 -r2.4 optc-gen.awk
--- optc-gen.awk 13 Apr 2005 08:47:19 -0000 2.4
+++ optc-gen.awk 28 Apr 2005 02:39:32 -0000
@@ -72,9 +72,13 @@ for (i = 0; i < n_opts; i++) {
init = opt_args("Init", flags[i])
if (init != "")
init = " = " init;
+ else if (name in var_seen)
+ continue;
printf ("/* Set by -%s.\n %s */\nint %s%s;\n\n",
opts[i], help[i], name,init)
+
+ var_seen[name] = 1;
}
Index: opth-gen.awk
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opth-gen.awk,v
retrieving revision 2.5
diff -p -U3 -r2.5 opth-gen.awk
--- opth-gen.awk 13 Apr 2005 08:47:19 -0000 2.5
+++ opth-gen.awk 28 Apr 2005 02:39:32 -0000
@@ -75,24 +75,43 @@ for (i = 0; i < n_opts; i++) {
}
-masknum = 0
for (i = 0; i < n_opts; i++) {
name = opt_args("Mask", flags[i])
+ vname = var_name(flags[i])
+ mask = "MASK_"
+ if (vname != "") {
+ mask = "OPTION_MASK_"
+ }
if (name != "" && !flag_set_p("MaskExists", flags[i]))
- print "#define MASK_" name " (1 << " masknum++ ")"
+ print "#define " mask name " (1 << " masknum[vname]++ ")"
}
for (i = 0; i < n_extra_masks; i++) {
- print "#define MASK_" extra_masks[i] " (1 << " masknum++ ")"
+ print "#define MASK_" extra_masks[i] " (1 << " masknum[""]++ ")"
+}
+
+for (var in masknum) {
+ if (masknum[var] > 31) {
+ if (var == "")
+ print "#error too many target masks"
+ else
+ print "#error too many masks for " var
+ }
}
-if (masknum > 31)
- print "#error too many target masks"
print ""
for (i = 0; i < n_opts; i++) {
name = opt_args("Mask", flags[i])
+ vname = var_name(flags[i])
+ macro = "OPTION_"
+ mask = "OPTION_MASK_"
+ if (vname == "") {
+ vname = "target_flags"
+ macro = "TARGET_"
+ mask = "MASK_"
+ }
if (name != "" && !flag_set_p("MaskExists", flags[i]))
- print "#define TARGET_" name \
- " ((target_flags & MASK_" name ") != 0)"
+ print "#define " macro name \
+ " ((" vname " & " mask name ") != 0)"
}
for (i = 0; i < n_extra_masks; i++) {
print "#define TARGET_" extra_masks[i] \
Index: doc/options.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/options.texi,v
retrieving revision 1.3
diff -p -U3 -r1.3 doc/options.texi
--- doc/options.texi 13 Apr 2005 08:47:20 -0000 1.3
+++ doc/options.texi 28 Apr 2005 02:39:32 -0000
@@ -154,8 +154,10 @@ The variable specified by the @code{Var}
initialized to @var{value}.
@item Mask(@var{name})
-The option is associated with a bit in the @code{target_flags} variable
-(@pxref{Run-time Target}) and is active when that bit is set.
+The option is associated with a bit in the @code{target_flags}
+variable (@pxref{Run-time Target}) and is active when that bit is set.
+You may also specify @code{Var} to select a variable other than
+@code{target_flags}.
The options-processing script will automatically allocate a unique
bit for the option and set the macro @code{MASK_@var{name}} to the