summaryrefslogtreecommitdiff
path: root/gcc/optc-gen.awk
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-11-26 23:18:28 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2010-11-26 23:18:28 +0000
commite6d4b9841c35629de91c36ba40ed247fef749037 (patch)
tree36e9808ac190cda7d402aca282c7bbe11cbf8b71 /gcc/optc-gen.awk
parent8a1ffe230e5f07f6eef4bd30088f4245783109ec (diff)
downloadgcc-e6d4b9841c35629de91c36ba40ed247fef749037.tar.gz
options.texi (Enum, EnumValue): Document new record types.
* doc/options.texi (Enum, EnumValue): Document new record types. (Enum): Document new option flag. * opt-functions.awk * optc-gen.awk: Handle enumerated option arguments. * opth-gen.awk: Handle enumerated option arguments. * opts-common.c (enum_arg_ok_for_language, enum_arg_to_value, enum_value_to_arg): New. (decode_cmdline_option): Handle enumerated arguments. (read_cmdline_option): Handle CL_ERR_ENUM_ARG. (set_option, option_enabled, get_option_state): Handle CLVC_ENUM. * opts.c (print_filtered_help, print_specific_help): Take lang_mask arguments. (print_filtered_help): Handle printing values of enumerated options. Print possible arguments for enumerated options. (print_specific_help): Update call to print_filtered_help. (common_handle_option): Update calls to print_specific_help. Use value rather than arg for OPT_fdiagnostics_show_location_. Don't handle OPT_ffp_contract_, OPT_fexcess_precision_, OPT_fvisibility_, OPT_ftls_model_, OPT_fira_algorithm_ or OPT_fira_region_ here. * opts.h (enum cl_var_type): Add CLVC_ENUM. (struct cl_option): Add var_enum. (CL_ENUM_CANONICAL, CL_ENUM_DRIVER_ONLY, struct cl_enum_arg, struct cl_enum, cl_enums, cl_enums_count): New. (CL_ERR_ENUM_ARG): Define. (CL_ERR_NEGATIVE): Update value. (enum_value_to_arg): Declare. * common.opt (flag_ira_algorithm, flag_ira_region, flag_fp_contract_mode, flag_excess_precision_cmdline, default_visibility, flag_tls_default): Remove Variable entries. (help_enum_printed): New Variable. (fdiagnostics-show-location=): Use Enum. Add associated SourceInclude, Enum and EnumValue entries. (fexcess-precision=, ffp-contract=, fira-algorithm=, fira-region=, ftls-model=, fvisibility=): Use Enum, Var and Init. Add associated Enum and EnumValue entries. po: * exgettext: Handle UnknownError. From-SVN: r167190
Diffstat (limited to 'gcc/optc-gen.awk')
-rw-r--r--gcc/optc-gen.awk76
1 files changed, 76 insertions, 0 deletions
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index 3bf0b8eacbb..4aaa2a6041a 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -34,6 +34,7 @@ BEGIN {
n_extra_target_vars = 0
n_extra_c_includes = 0
n_extra_h_includes = 0
+ n_enums = 0
quote = "\042"
comma = ","
FS=SUBSEP
@@ -80,6 +81,31 @@ BEGIN {
else if ($1 == "SourceInclude") {
extra_c_includes[n_extra_c_includes++] = $2;
}
+ else if ($1 == "Enum") {
+ props = $2
+ name = opt_args("Name", props)
+ type = opt_args("Type", props)
+ unknown_error = opt_args("UnknownError", props)
+ enum_names[n_enums] = name
+ enum_type[name] = type
+ enum_index[name] = n_enums
+ enum_unknown_error[name] = unknown_error
+ enum_help[name] = $3
+ n_enums++
+ }
+ else if ($1 == "EnumValue") {
+ props = $2
+ enum_name = opt_args("Enum", props)
+ string = opt_args("String", props)
+ value = opt_args("Value", props)
+ val_flags = "0"
+ val_flags = val_flags \
+ test_flag("Canonical", props, "| CL_ENUM_CANONICAL") \
+ test_flag("DriverOnly", props, "| CL_ENUM_DRIVER_ONLY")
+ enum_data[enum_name] = enum_data[enum_name] \
+ " { " quote string quote ", " value ", " val_flags \
+ " },\n"
+ }
else {
name = opt_args("Mask", $1)
if (name == "") {
@@ -116,6 +142,56 @@ if (n_extra_c_includes > 0) {
print ""
}
+for (i = 0; i < n_enums; i++) {
+ name = enum_names[i]
+ type = enum_type[name]
+ print "static const struct cl_enum_arg cl_enum_" name \
+ "_data[] = "
+ print "{"
+ print enum_data[name] " { NULL, 0, 0 }"
+ print "};"
+ print ""
+ print "static void"
+ print "cl_enum_" name "_set (void *var, int value)"
+ print "{"
+ print " *((" type " *) var) = (" type ") value;"
+ print "}"
+ print ""
+ print "static int"
+ print "cl_enum_" name "_get (const void *var)"
+ print "{"
+ print " return (int) *((const " type " *) var);"
+ print "}"
+ print ""
+}
+
+print "const struct cl_enum cl_enums[] ="
+print "{"
+for (i = 0; i < n_enums; i++) {
+ name = enum_names[i]
+ ehelp = enum_help[name]
+ if (ehelp == "")
+ ehelp = "NULL"
+ else
+ ehelp = quote ehelp quote
+ unknown_error = enum_unknown_error[name]
+ if (unknown_error == "")
+ unknown_error = "NULL"
+ else
+ unknown_error = quote unknown_error quote
+ print " {"
+ print " " ehelp ","
+ print " " unknown_error ","
+ print " cl_enum_" name "_data,"
+ print " sizeof (" enum_type[name] "),"
+ print " cl_enum_" name "_set,"
+ print " cl_enum_" name "_get"
+ print " },"
+}
+print "};"
+print "const unsigned int cl_enums_count = " n_enums ";"
+print ""
+
have_save = 0;
if (n_extra_target_vars)
have_save = 1