opt-functions.awk (global_state_p, [...]): New.
* opt-functions.awk (global_state_p, needs_state_p, static_var): New. (var_ref): Take the option's flags as a second parameter. Check static_var. * optc-gen.awk: Declare local state variables. Pass flags to var_ref. From-SVN: r100937
This commit is contained in:
parent
efe4c4e7d2
commit
ee133b6978
|
@ -1,3 +1,10 @@
|
|||
2005-06-14 Richard Sandiford <richard@codesourcery.com>
|
||||
|
||||
* opt-functions.awk (global_state_p, needs_state_p, static_var): New.
|
||||
(var_ref): Take the option's flags as a second parameter. Check
|
||||
static_var.
|
||||
* optc-gen.awk: Declare local state variables. Pass flags to var_ref.
|
||||
|
||||
2005-06-14 Eric Botcazou <ebotcazou@libertysurf.fr>
|
||||
|
||||
PR target/20301
|
||||
|
|
|
@ -89,6 +89,32 @@ function var_name(flags)
|
|||
return nth_arg(0, opt_args("Var", flags))
|
||||
}
|
||||
|
||||
# Return true if the option described by FLAGS has a globally-visible state.
|
||||
function global_state_p(flags)
|
||||
{
|
||||
return (var_name(flags) != "" \
|
||||
|| opt_args("Mask", flags) != "" \
|
||||
|| opt_args("InverseMask", flags) != "")
|
||||
}
|
||||
|
||||
# Return true if the option described by FLAGS must have some state
|
||||
# associated with it.
|
||||
function needs_state_p(flags)
|
||||
{
|
||||
return flag_set_p("Target", flags)
|
||||
}
|
||||
|
||||
# If FLAGS describes an option that needs a static state variable,
|
||||
# return the name of that variable, otherwise return "". NAME is
|
||||
# the name of the option.
|
||||
function static_var(name, flags)
|
||||
{
|
||||
if (global_state_p(flags) || !needs_state_p(flags))
|
||||
return ""
|
||||
gsub ("[^A-Za-z0-9]", "_", name)
|
||||
return "VAR_" name
|
||||
}
|
||||
|
||||
# Return the type of variable that should be associated with the given flags.
|
||||
function var_type(flags)
|
||||
{
|
||||
|
@ -128,11 +154,11 @@ function var_set(flags)
|
|||
return "CLVC_BOOLEAN, 0"
|
||||
}
|
||||
|
||||
# Given that an option has flags FLAGS, return an initializer for the
|
||||
# "flag_var" field of its cl_options[] entry.
|
||||
function var_ref(flags)
|
||||
# Given that an option called NAME has flags FLAGS, return an initializer
|
||||
# for the "flag_var" field of its cl_options[] entry.
|
||||
function var_ref(name, flags)
|
||||
{
|
||||
name = var_name(flags)
|
||||
name = var_name(flags) static_var(name, flags)
|
||||
if (name != "")
|
||||
return "&" name
|
||||
if (opt_args("Mask", flags) != "")
|
||||
|
|
|
@ -85,6 +85,14 @@ for (i = 0; i < n_opts; i++) {
|
|||
var_seen[name] = 1;
|
||||
}
|
||||
|
||||
print ""
|
||||
print "/* Local state variables. */"
|
||||
for (i = 0; i < n_opts; i++) {
|
||||
name = static_var(opts[i], flags[i]);
|
||||
if (name != "")
|
||||
print "static " var_type(flags[i]) name ";"
|
||||
}
|
||||
print ""
|
||||
|
||||
print "const char * const lang_names[] =\n{"
|
||||
for (i = 0; i < n_langs; i++) {
|
||||
|
@ -152,7 +160,8 @@ for (i = 0; i < n_opts; i++) {
|
|||
condition, cl_flags, cl_flags)
|
||||
else
|
||||
printf(" %s,\n", cl_flags)
|
||||
printf(" %s, %s }%s\n", var_ref(flags[i]), var_set(flags[i]), comma)
|
||||
printf(" %s, %s }%s\n", var_ref(opts[i], flags[i]),
|
||||
var_set(flags[i]), comma)
|
||||
}
|
||||
|
||||
print "};"
|
||||
|
|
Loading…
Reference in New Issue