diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-30 06:24:35 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-30 06:24:35 +0000 |
commit | a150399de633299feeb20899e9b178895dae0c1c (patch) | |
tree | 0f5f11110d7efae0a9f2bdcb0ba8512beb09a1ab /gcc/opt-functions.awk | |
parent | 4c34e98c7bf1e13e0107768ef4a161fb823c4f7f (diff) | |
download | gcc-a150399de633299feeb20899e9b178895dae0c1c.tar.gz |
* opt-functions.awk (flag_set_p, test_flag): New functions.
(switch_flags): Use them.
* opth-gen.awk: Use flag_set_p to check for flags.
* optc-gen.awk: Likewise. Use opt_args to check for Init(...) flags.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97237 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opt-functions.awk')
-rw-r--r-- | gcc/opt-functions.awk | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index 35ab4453f31..91628213696 100644 --- a/gcc/opt-functions.awk +++ b/gcc/opt-functions.awk @@ -18,6 +18,21 @@ # Some common subroutines for use by opt[ch]-gen.awk. +# Return nonzero if FLAGS contains a flag matching REGEX. +function flag_set_p(regex, flags) +{ + return (" " flags " ") ~ (" " regex " ") +} + +# Return STRING if FLAGS contains a flag matching regexp REGEX, +# otherwise return the empty string. +function test_flag(regex, flags, string) +{ + if (flag_set_p(regex, flags)) + return string + return "" +} + # If FLAGS contains a "NAME(...argument...)" flag, return the value # of the argument. Return the empty string otherwise. function opt_args(name, flags) @@ -47,24 +62,22 @@ function nth_arg(n, s) # Return a bitmask of CL_* values for option flags FLAGS. function switch_flags (flags) { - flags = " " flags " " result = "0" for (j = 0; j < n_langs; j++) { - regex = " " langs[j] " " + regex = langs[j] gsub ( "\\+", "\\+", regex ) - if (flags ~ regex) - result = result " | " macros[j] + result = result test_flag(regex, flags, " | " macros[j]) } - if (flags ~ " Common ") result = result " | CL_COMMON" - if (flags ~ " Target ") result = result " | CL_TARGET" - if (flags ~ " Joined ") result = result " | CL_JOINED" - if (flags ~ " JoinedOrMissing ") \ - result = result " | CL_JOINED | CL_MISSING_OK" - if (flags ~ " Separate ") result = result " | CL_SEPARATE" - if (flags ~ " RejectNegative ") result = result " | CL_REJECT_NEGATIVE" - if (flags ~ " UInteger ") result = result " | CL_UINTEGER" - if (flags ~ " Undocumented ") result = result " | CL_UNDOCUMENTED" - if (flags ~ " Report ") result = result " | CL_REPORT" + result = result \ + test_flag("Common", flags, " | CL_COMMON") \ + test_flag("Target", flags, " | CL_TARGET") \ + test_flag("Joined", flags, " | CL_JOINED") \ + test_flag("JoinedOrMissing", flags, " | CL_JOINED | CL_MISSING_OK") \ + 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("Report", flags, " | CL_REPORT") sub( "^0 \\| ", "", result ) return result } |