summaryrefslogtreecommitdiff
path: root/gcc/opt-functions.awk
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-14 14:37:49 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-06-14 14:37:49 +0000
commitd6907cfaf67723c47ad4937c226c2567165fafee (patch)
tree7e6e307d1535c560e0c4c03640939d48c37b0da8 /gcc/opt-functions.awk
parent8cc44b16787fdc2e8c6d04b3d45b44468364c936 (diff)
downloadgcc-d6907cfaf67723c47ad4937c226c2567165fafee.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100937 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opt-functions.awk')
-rw-r--r--gcc/opt-functions.awk34
1 files changed, 30 insertions, 4 deletions
diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk
index 9097dfb8d96..b5124969cec 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -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) != "")