From f7f655c70668e1d6b8e7d438fb8c94d927bcd3ef Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Thu, 28 Apr 2005 16:52:12 -0400 Subject: optc-gen.awk (END): Make sure no variable is defined more than once. * optc-gen.awk (END): Make sure no variable is defined more than once. * opth-gen.awk (END): Allocate bits on a per-variable basis. Allow for bitfield variables other than target_flags. * doc/options.text (Mask): Document that you may specify a variable other than target_flags. From-SVN: r98940 --- gcc/ChangeLog | 9 +++++++++ gcc/doc/options.texi | 22 ++++++++++++++-------- gcc/optc-gen.awk | 4 ++++ gcc/opth-gen.awk | 33 ++++++++++++++++++++++++++------- 4 files changed, 53 insertions(+), 15 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 15f1932..4a0d723 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2005-04-28 DJ Delorie + + * optc-gen.awk (END): Make sure no variable is defined more + than once. + * opth-gen.awk (END): Allocate bits on a per-variable basis. + Allow for bitfield variables other than target_flags. + * doc/options.text (Mask): Document that you may specify a + variable other than target_flags. + 2005-04-28 Martin Koegler PR rtl-optimization/18877 diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi index ccc6c910..d5d1984 100644 --- a/gcc/doc/options.texi +++ b/gcc/doc/options.texi @@ -154,14 +154,20 @@ The variable specified by the @code{Var} property should be statically 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 options-processing script will automatically allocate a unique -bit for the option and set the macro @code{MASK_@var{name}} to the -appropriate bitmask. It will also declare a @code{TARGET_@var{name}} -macro that has the value 1 when the option is active and 0 otherwise. -You can disable this behavior using @code{MaskExists}. +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. If the option is attached to @samp{target_flags}, +the script will set the macro @code{MASK_@var{name}} to the appropriate +bitmask. It will also declare a @code{TARGET_@var{name}} macro that has +the value 1 when the option is active and 0 otherwise. If you use @code{Var} +to attach the option to a different variable, the associated macros are +called @code{OPTION_MASK_@var{name}} and @code{OPTION_@var{name}} respectively. + +You can disable automatic bit alloction using @code{MaskExists}. @item InverseMask(@var{othername}) @itemx InverseMask(@var{othername}, @var{thisname}) diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index f458b65..ebf6a44 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -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; } diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk index b5a4c57..92c0e7e 100644 --- a/gcc/opth-gen.awk +++ b/gcc/opth-gen.awk @@ -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] \ -- cgit v1.1