X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fopt-functions.awk;h=9097dfb8d9631bfef50c28c30e968245ea1483f3;hb=bc99e19413009c0e1e90305eb1a7fe10d58379ad;hp=35ab4453f313db7f497769c2413fe54ec52e180c;hpb=ff05e09e2d0d3b01e2dbc1d0d6d869cd0b1ce745;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk index 35ab4453f31..9097dfb8d96 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 } @@ -76,6 +89,17 @@ function var_name(flags) return nth_arg(0, opt_args("Var", flags)) } +# Return the type of variable that should be associated with the given flags. +function var_type(flags) +{ + if (!flag_set_p("Joined.*", flags)) + return "int " + else if (flag_set_p("UInteger", flags)) + return "int " + else + return "const char *" +} + # Given that an option has flags FLAGS, return an initializer for the # "var_cond" and "var_value" fields of its cl_options[] entry. function var_set(flags) @@ -84,11 +108,23 @@ function var_set(flags) if (s != "") return "CLVC_EQUAL, " s s = opt_args("Mask", flags); - if (s != "") - return "CLVC_BIT_SET, MASK_" s + if (s != "") { + vn = var_name(flags); + if (vn) + return "CLVC_BIT_SET, OPTION_MASK_" s + else + return "CLVC_BIT_SET, MASK_" s + } s = nth_arg(0, opt_args("InverseMask", flags)); - if (s != "") - return "CLVC_BIT_CLEAR, MASK_" s + if (s != "") { + vn = var_name(flags); + if (vn) + return "CLVC_BIT_CLEAR, OPTION_MASK_" s + else + return "CLVC_BIT_CLEAR, MASK_" s + } + if (var_type(flags) == "const char *") + return "CLVC_STRING, 0" return "CLVC_BOOLEAN, 0" }