From 86fa5de4fc7a62813adacf107775d3ebc9bb65c2 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sat, 21 May 2011 12:34:29 +0100 Subject: [PATCH] opt-read.awk: New. * opt-read.awk: New. Split out of optc-gen.awk and opth-gen.awk. * optc-gen.awk: Move common code to opt-read.awk. * opth-gen.awk: Likewise. * Makefile.in (options.c, s-options-h): Update to use opt-read.awk. From-SVN: r173995 --- gcc/ChangeLog | 8 ++++ gcc/Makefile.in | 12 +++-- gcc/opt-read.awk | 119 +++++++++++++++++++++++++++++++++++++++++++++++ gcc/optc-gen.awk | 99 ++------------------------------------- gcc/opth-gen.awk | 98 ++------------------------------------ 5 files changed, 143 insertions(+), 193 deletions(-) create mode 100644 gcc/opt-read.awk diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f9c65da2546..fcb71b7854f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2011-05-21 Joseph Myers + + * opt-read.awk: New. Split out of optc-gen.awk and opth-gen.awk. + * optc-gen.awk: Move common code to opt-read.awk. + * opth-gen.awk: Likewise. + * Makefile.in (options.c, s-options-h): Update to use + opt-read.awk. + 2011-05-20 Nathan Froyd * godump.c (go_format_type): Don't use TYPE_ARG_TYPES. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 57b9607be94..a9d20c5a21a 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2263,13 +2263,17 @@ s-options: $(ALL_OPT_FILES) Makefile $(srcdir)/opt-gather.awk $(SHELL) $(srcdir)/../move-if-change tmp-optionlist optionlist $(STAMP) s-options -options.c: optionlist $(srcdir)/opt-functions.awk $(srcdir)/optc-gen.awk - $(AWK) -f $(srcdir)/opt-functions.awk -f $(srcdir)/optc-gen.awk \ +options.c: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opt-read.awk \ + $(srcdir)/optc-gen.awk + $(AWK) -f $(srcdir)/opt-functions.awk -f $(srcdir)/opt-read.awk \ + -f $(srcdir)/optc-gen.awk \ -v header_name="config.h system.h coretypes.h tm.h" < $< > $@ options.h: s-options-h ; @true -s-options-h: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opth-gen.awk - $(AWK) -f $(srcdir)/opt-functions.awk -f $(srcdir)/opth-gen.awk \ +s-options-h: optionlist $(srcdir)/opt-functions.awk $(srcdir)/opt-read.awk \ + $(srcdir)/opth-gen.awk + $(AWK) -f $(srcdir)/opt-functions.awk -f $(srcdir)/opt-read.awk \ + -f $(srcdir)/opth-gen.awk \ < $< > tmp-options.h $(SHELL) $(srcdir)/../move-if-change tmp-options.h options.h $(STAMP) $@ diff --git a/gcc/opt-read.awk b/gcc/opt-read.awk new file mode 100644 index 00000000000..c488ed5cde5 --- /dev/null +++ b/gcc/opt-read.awk @@ -0,0 +1,119 @@ +# Copyright (C) 2003,2004,2005,2006,2007,2008, 2010, 2011 +# Free Software Foundation, Inc. +# Contributed by Kelley Cook, June 2004. +# Original code from Neil Booth, May 2003. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3, or (at your option) any +# later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING3. If not see +# . + +# Read in the option records generated from opt-gather.awk. + +BEGIN { + n_opts = 0 + n_langs = 0 + n_target_save = 0 + n_extra_vars = 0 + n_extra_target_vars = 0 + n_extra_masks = 0 + n_extra_c_includes = 0 + n_extra_h_includes = 0 + n_enums = 0 + have_save = 0; + quote = "\042" + comma = "," + FS=SUBSEP + # Default the name of header created from opth-gen.awk to options.h + if (header_name == "") header_name="options.h" +} + +# Collect the text and flags of each option into an array + { + if ($1 == "Language") { + langs[n_langs] = $2 + n_langs++; + } + else if ($1 == "TargetSave") { + # Make sure the declarations are put in source order + target_save_decl[n_target_save] = $2 + n_target_save++ + } + else if ($1 == "Variable") { + extra_vars[n_extra_vars] = $2 + n_extra_vars++ + } + else if ($1 == "TargetVariable") { + # Combination of TargetSave and Variable + extra_vars[n_extra_vars] = $2 + n_extra_vars++ + + var = $2 + sub(" *=.*", "", var) + orig_var = var + name = var + type = var + sub("^.*[ *]", "", name) + sub(" *" name "$", "", type) + target_save_decl[n_target_save] = type " x_" name + n_target_save++ + + extra_target_vars[n_extra_target_vars] = name + n_extra_target_vars++ + } + else if ($1 == "HeaderInclude") { + extra_h_includes[n_extra_h_includes++] = $2; + } + 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 == "") { + opts[n_opts] = $1 + flags[n_opts] = $2 + help[n_opts] = $3 + for (i = 4; i <= NF; i++) + help[n_opts] = help[n_opts] " " $i + n_opts++; + } + else { + extra_masks[n_extra_masks++] = name + } + } + } + diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index 9408ced9c44..2c4df708801 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -21,104 +21,13 @@ # opt-gather.awk, combines the flags of duplicate options and generates a # C file. # -# This program uses functions from opt-functions.awk + +# This program uses functions from opt-functions.awk and code from +# opt-read.awk. # -# Usage: awk -f opt-functions.awk -f optc-gen.awk \ +# Usage: awk -f opt-functions.awk -f opt-read.awk -f optc-gen.awk \ # [-v header_name=header.h] < inputfile > options.c -BEGIN { - n_opts = 0 - n_langs = 0 - n_target_save = 0 - n_extra_vars = 0 - n_extra_target_vars = 0 - n_extra_c_includes = 0 - n_extra_h_includes = 0 - n_enums = 0 - quote = "\042" - comma = "," - FS=SUBSEP - # Default the name of header created from opth-gen.awk to options.h - if (header_name == "") header_name="options.h" -} - -# Collect the text and flags of each option into an array - { - if ($1 == "Language") { - langs[n_langs] = $2 - n_langs++; - } - else if ($1 == "TargetSave") { - # Make sure the declarations are put in source order - target_save_decl[n_target_save] = $2 - n_target_save++ - } - else if ($1 == "Variable") { - extra_vars[n_extra_vars] = $2 - n_extra_vars++ - } - else if ($1 == "TargetVariable") { - # Combination of TargetSave and Variable - extra_vars[n_extra_vars] = $2 - n_extra_vars++ - - var = $2 - sub(" *=.*", "", var) - orig_var = var - name = var - type = var - sub("^.*[ *]", "", name) - sub(" *" name "$", "", type) - target_save_decl[n_target_save] = type " x_" name - n_target_save++ - - extra_target_vars[n_extra_target_vars] = name - n_extra_target_vars++; - } - else if ($1 == "HeaderInclude") { - extra_h_includes[n_extra_h_includes++] = $2; - } - 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 == "") { - opts[n_opts] = $1 - flags[n_opts] = $2 - help[n_opts] = $3 - for (i = 4; i <= NF; i++) - help[n_opts] = help[n_opts] " " $i - n_opts++; - } - } - } - # Dump that array of options into a C file. END { print "/* This file is auto-generated by optc-gen.awk. */" diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk index 01c2e46331b..7877d033b69 100644 --- a/gcc/opth-gen.awk +++ b/gcc/opth-gen.awk @@ -21,100 +21,10 @@ # opt-gather.awk, combines the flags of duplicate options and generates a # C header file. # -# This program uses functions from opt-functions.awk -# Usage: awk -f opt-functions.awk -f opth-gen.awk < inputfile > options.h - -BEGIN { - n_opts = 0 - n_langs = 0 - n_target_save = 0 - n_extra_vars = 0 - n_extra_target_vars = 0 - n_extra_masks = 0 - n_extra_c_includes = 0 - n_extra_h_includes = 0 - have_save = 0; - quote = "\042" - FS=SUBSEP -} - -# Collect the text and flags of each option into an array - { - if ($1 == "Language") { - langs[n_langs] = $2 - n_langs++; - } - else if ($1 == "TargetSave") { - # Make sure the declarations are put in source order - target_save_decl[n_target_save] = $2 - n_target_save++ - } - else if ($1 == "Variable") { - extra_vars[n_extra_vars] = $2 - n_extra_vars++ - } - else if ($1 == "TargetVariable") { - # Combination of TargetSave and Variable - extra_vars[n_extra_vars] = $2 - n_extra_vars++ - - var = $2 - sub(" *=.*", "", var) - orig_var = var - name = var - type = var - sub("^.*[ *]", "", name) - sub(" *" name "$", "", type) - target_save_decl[n_target_save] = type " x_" name - n_target_save++ - - extra_target_vars[n_extra_target_vars] = name - n_extra_target_vars++ - } - else if ($1 == "HeaderInclude") { - extra_h_includes[n_extra_h_includes++] = $2; - } - 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 == "") { - opts[n_opts] = $1 - flags[n_opts] = $2 - help[n_opts] = $3 - n_opts++; - } - else { - extra_masks[n_extra_masks++] = name - } - } - } +# This program uses functions from opt-functions.awk and code from +# opt-read.awk. +# Usage: awk -f opt-functions.awk -f opt-read.awk -f opth-gen.awk \ +# < inputfile > options.h # Dump out an enumeration into a .h file. # Combine the flags of duplicate options. -- 2.30.2