annotate gcc/optc-gen.awk @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1 # Copyright (C) 2003-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 # Contributed by Kelley Cook, June 2004.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 # Original code from Neil Booth, May 2003.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 # This program is free software; you can redistribute it and/or modify it
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 # under the terms of the GNU General Public License as published by the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 # Free Software Foundation; either version 3, or (at your option) any
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 # later version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 # GNU General Public License for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 # along with this program; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 # <http://www.gnu.org/licenses/>.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 # This Awk script reads in the option records generated from
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 # opt-gather.awk, combines the flags of duplicate options and generates a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 # C file.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #
111
kono
parents: 67
diff changeset
23
kono
parents: 67
diff changeset
24 # This program uses functions from opt-functions.awk and code from
kono
parents: 67
diff changeset
25 # opt-read.awk.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #
111
kono
parents: 67
diff changeset
27 # Usage: awk -f opt-functions.awk -f opt-read.awk -f optc-gen.awk \
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 # [-v header_name=header.h] < inputfile > options.c
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 # Dump that array of options into a C file.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 END {
111
kono
parents: 67
diff changeset
32
kono
parents: 67
diff changeset
33
kono
parents: 67
diff changeset
34 # Combine the flags of identical switches. Switches
kono
parents: 67
diff changeset
35 # appear many times if they are handled by many front
kono
parents: 67
diff changeset
36 # ends, for example.
kono
parents: 67
diff changeset
37 for (i = 0; i < n_opts; i++) {
kono
parents: 67
diff changeset
38 merged_flags[i] = flags[i]
kono
parents: 67
diff changeset
39 }
kono
parents: 67
diff changeset
40 for (i = 0; i < n_opts; i++) {
kono
parents: 67
diff changeset
41 while(i + 1 != n_opts && opts[i] == opts[i + 1] ) {
kono
parents: 67
diff changeset
42 merged_flags[i + 1] = merged_flags[i] " " merged_flags[i + 1];
kono
parents: 67
diff changeset
43 i++;
kono
parents: 67
diff changeset
44 }
kono
parents: 67
diff changeset
45 }
kono
parents: 67
diff changeset
46
kono
parents: 67
diff changeset
47 # Record EnabledBy and LangEnabledBy uses.
kono
parents: 67
diff changeset
48 n_enabledby = 0;
kono
parents: 67
diff changeset
49 for (i = 0; i < n_langs; i++) {
kono
parents: 67
diff changeset
50 n_enabledby_lang[i] = 0;
kono
parents: 67
diff changeset
51 }
kono
parents: 67
diff changeset
52 for (i = 0; i < n_opts; i++) {
kono
parents: 67
diff changeset
53 enabledby_arg = opt_args("EnabledBy", flags[i]);
kono
parents: 67
diff changeset
54 if (enabledby_arg != "") {
kono
parents: 67
diff changeset
55 logical_and = index(enabledby_arg, " && ");
kono
parents: 67
diff changeset
56 if (logical_and != 0) {
kono
parents: 67
diff changeset
57 # EnabledBy(arg1 && arg2)
kono
parents: 67
diff changeset
58 split_sep = " && ";
kono
parents: 67
diff changeset
59 } else {
kono
parents: 67
diff changeset
60 # EnabledBy(arg) or EnabledBy(arg1 || arg2 || arg3)
kono
parents: 67
diff changeset
61 split_sep = " \\|\\| ";
kono
parents: 67
diff changeset
62 }
kono
parents: 67
diff changeset
63 n_enabledby_names = split(enabledby_arg, enabledby_names, split_sep);
kono
parents: 67
diff changeset
64 if (logical_and != 0 && n_enabledby_names > 2) {
kono
parents: 67
diff changeset
65 print "#error " opts[i] " EnabledBy(Wfoo && Wbar && Wbaz) currently not supported"
kono
parents: 67
diff changeset
66 }
kono
parents: 67
diff changeset
67 for (j = 1; j <= n_enabledby_names; j++) {
kono
parents: 67
diff changeset
68 enabledby_name = enabledby_names[j];
kono
parents: 67
diff changeset
69 enabledby_index = opt_numbers[enabledby_name];
kono
parents: 67
diff changeset
70 if (enabledby_index == "") {
kono
parents: 67
diff changeset
71 print "#error " opts[i] " Enabledby(" enabledby_name "), unknown option '" enabledby_name "'"
kono
parents: 67
diff changeset
72 } else if (!flag_set_p("Common", merged_flags[enabledby_index])) {
kono
parents: 67
diff changeset
73 print "#error " opts[i] " Enabledby(" enabledby_name "), '" \
kono
parents: 67
diff changeset
74 enabledby_name "' must have flag 'Common'" \
kono
parents: 67
diff changeset
75 " to use Enabledby(), otherwise use LangEnabledBy()"
kono
parents: 67
diff changeset
76 } else {
kono
parents: 67
diff changeset
77 condition = "";
kono
parents: 67
diff changeset
78 if (logical_and != 0) {
kono
parents: 67
diff changeset
79 opt_var_name_1 = search_var_name(enabledby_names[1], opt_numbers, opts, flags, n_opts);
kono
parents: 67
diff changeset
80 opt_var_name_2 = search_var_name(enabledby_names[2], opt_numbers, opts, flags, n_opts);
kono
parents: 67
diff changeset
81 if (opt_var_name_1 == "") {
kono
parents: 67
diff changeset
82 print "#error " enabledby_names[1] " does not have a Var() flag"
kono
parents: 67
diff changeset
83 }
kono
parents: 67
diff changeset
84 if (opt_var_name_2 == "") {
kono
parents: 67
diff changeset
85 print "#error " enabledby_names[2] " does not have a Var() flag"
kono
parents: 67
diff changeset
86 }
kono
parents: 67
diff changeset
87 condition = "opts->x_" opt_var_name_1 " && opts->x_" opt_var_name_2;
kono
parents: 67
diff changeset
88 }
kono
parents: 67
diff changeset
89 if (enables[enabledby_name] == "") {
kono
parents: 67
diff changeset
90 enabledby[n_enabledby] = enabledby_name;
kono
parents: 67
diff changeset
91 n_enabledby++;
kono
parents: 67
diff changeset
92 }
kono
parents: 67
diff changeset
93 enables[enabledby_name] = enables[enabledby_name] opts[i] ";";
kono
parents: 67
diff changeset
94 enablesif[enabledby_name] = enablesif[enabledby_name] condition ";";
kono
parents: 67
diff changeset
95 }
kono
parents: 67
diff changeset
96 }
kono
parents: 67
diff changeset
97 }
kono
parents: 67
diff changeset
98
kono
parents: 67
diff changeset
99 enabledby_arg = opt_args("LangEnabledBy", flags[i]);
kono
parents: 67
diff changeset
100 if (enabledby_arg != "") {
kono
parents: 67
diff changeset
101 enabledby_langs = nth_arg(0, enabledby_arg);
kono
parents: 67
diff changeset
102 enabledby_name = nth_arg(1, enabledby_arg);
kono
parents: 67
diff changeset
103 enabledby_posarg = nth_arg(2, enabledby_arg);
kono
parents: 67
diff changeset
104 enabledby_negarg = nth_arg(3, enabledby_arg);
kono
parents: 67
diff changeset
105 lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enabledby_negarg);
kono
parents: 67
diff changeset
106 }
kono
parents: 67
diff changeset
107 }
kono
parents: 67
diff changeset
108
kono
parents: 67
diff changeset
109
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110 print "/* This file is auto-generated by optc-gen.awk. */"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 print ""
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 n_headers = split(header_name, headers, " ")
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 for (i = 1; i <= n_headers; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 print "#include " quote headers[i] quote
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 print "#include " quote "opts.h" quote
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 print "#include " quote "intl.h" quote
111
kono
parents: 67
diff changeset
117 print "#include " quote "insn-attr-common.h" quote
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 print ""
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
120 if (n_extra_c_includes > 0) {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
121 for (i = 0; i < n_extra_c_includes; i++) {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
122 print "#include " quote extra_c_includes[i] quote
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
123 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
124 print ""
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
125 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
126
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
127 for (i = 0; i < n_enums; i++) {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
128 name = enum_names[i]
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
129 type = enum_type[name]
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
130 print "static const struct cl_enum_arg cl_enum_" name \
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
131 "_data[] = "
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
132 print "{"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
133 print enum_data[name] " { NULL, 0, 0 }"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
134 print "};"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
135 print ""
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
136 print "static void"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
137 print "cl_enum_" name "_set (void *var, int value)"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
138 print "{"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
139 print " *((" type " *) var) = (" type ") value;"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
140 print "}"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
141 print ""
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
142 print "static int"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
143 print "cl_enum_" name "_get (const void *var)"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
144 print "{"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
145 print " return (int) *((const " type " *) var);"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
146 print "}"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
147 print ""
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
148 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
149
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
150 print "const struct cl_enum cl_enums[] ="
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
151 print "{"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
152 for (i = 0; i < n_enums; i++) {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
153 name = enum_names[i]
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
154 ehelp = enum_help[name]
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
155 if (ehelp == "")
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
156 ehelp = "NULL"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
157 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
158 ehelp = quote ehelp quote
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
159 unknown_error = enum_unknown_error[name]
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
160 if (unknown_error == "")
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
161 unknown_error = "NULL"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
162 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
163 unknown_error = quote unknown_error quote
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
164 print " {"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
165 print " " ehelp ","
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
166 print " " unknown_error ","
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
167 print " cl_enum_" name "_data,"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
168 print " sizeof (" enum_type[name] "),"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
169 print " cl_enum_" name "_set,"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
170 print " cl_enum_" name "_get"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
171 print " },"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
172 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
173 print "};"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
174 print "const unsigned int cl_enums_count = " n_enums ";"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
175 print ""
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
176
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
177 print "const struct gcc_options global_options_init =\n{"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
178 for (i = 0; i < n_extra_vars; i++) {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
179 var = extra_vars[i]
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
180 init = extra_vars[i]
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
181 if (var ~ "=" ) {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
182 sub(".*= *", "", init)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
183 } else {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
184 init = "0"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
185 }
111
kono
parents: 67
diff changeset
186 sub(" *=.*", "", var)
kono
parents: 67
diff changeset
187 name = var
kono
parents: 67
diff changeset
188 sub("^.*[ *]", "", name)
kono
parents: 67
diff changeset
189 sub("\\[.*\\]$", "", name)
kono
parents: 67
diff changeset
190 var_seen[name] = 1
kono
parents: 67
diff changeset
191 print " " init ", /* " name " */"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
192 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 for (i = 0; i < n_opts; i++) {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 name = var_name(flags[i]);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 if (name == "")
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
198 init = opt_args("Init", flags[i])
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
199 if (init != "") {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
200 if (name in var_init && var_init[name] != init)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
201 print "#error multiple initializers for " name
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
202 var_init[name] = init
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
204 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
205 for (i = 0; i < n_opts; i++) {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
206 name = var_name(flags[i]);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
207 if (name == "")
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
208 continue;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
210 if (name in var_seen)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
211 continue;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
212
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
213 if (name in var_init)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
214 init = var_init[name]
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
215 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
216 init = "0"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
217
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
218 print " " init ", /* " name " */"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 var_seen[name] = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 for (i = 0; i < n_opts; i++) {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 name = static_var(opts[i], flags[i]);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
224 if (name != "") {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
225 print " 0, /* " name " (private state) */"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
226 print "#undef x_" name
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
227 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
229 for (i = 0; i < n_opts; i++) {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
230 if (flag_set_p("SetByCombined", flags[i]))
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
231 print " false, /* frontend_set_" var_name(flags[i]) " */"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
232 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
233 print "};"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
234 print ""
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
235 print "struct gcc_options global_options;"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
236 print "struct gcc_options global_options_set;"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 print ""
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 print "const char * const lang_names[] =\n{"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 for (i = 0; i < n_langs; i++) {
111
kono
parents: 67
diff changeset
241 macros[i] = "CL_" lang_sanitized_name(langs[i])
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 s = substr(" ", length (macros[i]))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 print " " quote langs[i] quote ","
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 print " 0\n};\n"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 print "const unsigned int cl_options_count = N_OPTS;\n"
111
kono
parents: 67
diff changeset
248 print "#if (1U << " n_langs ") > CL_MIN_OPTION_CLASS"
kono
parents: 67
diff changeset
249 print " #error the number of languages exceeds the implementation limit"
kono
parents: 67
diff changeset
250 print "#endif"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 print "const unsigned int cl_lang_count = " n_langs ";\n"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 print "const struct cl_option cl_options[] =\n{"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 j = 0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 for (i = 0; i < n_opts; i++) {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 back_chain[i] = "N_OPTS";
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 indices[opts[i]] = j;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 # Combine the flags of identical switches. Switches
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260 # appear many times if they are handled by many front
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 # ends, for example.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 flags[i + 1] = flags[i] " " flags[i + 1];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 if (help[i + 1] == "")
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 help[i + 1] = help[i]
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
266 else if (help[i] != "" && help[i + 1] != help[i])
111
kono
parents: 67
diff changeset
267 print "#error Multiple different help strings for " \
kono
parents: 67
diff changeset
268 opts[i] ":\n\t" help[i] "\n\t" help[i + 1]
kono
parents: 67
diff changeset
269
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 i++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 back_chain[i] = "N_OPTS";
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 indices[opts[i]] = j;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 j++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
277 optindex = 0
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 for (i = 0; i < n_opts; i++) {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 # With identical flags, pick only the last one. The
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 # earlier loop ensured that it has all flags merged,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 # and a nonempty help text if one of the texts was nonempty.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 i++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 len = length (opts[i]);
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
287 enum = opt_enum(opts[i])
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 # If this switch takes joined arguments, back-chain all
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 # subsequent switches to it for which it is a prefix. If
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 # a later switch S is a longer prefix of a switch T, T
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 # will be back-chained to S in a later iteration of this
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 # for() loop, which is what we want.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 if (flag_set_p("Joined.*", flags[i])) {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 for (j = i + 1; j < n_opts; j++) {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 if (substr (opts[j], 1, len) != opts[i])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 back_chain[j] = enum;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 s = substr(" ", length (opts[i]))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 if (i + 1 == n_opts)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 comma = ""
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 if (help[i] == "")
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
307 hlp = "NULL"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 hlp = quote help[i] quote;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
311 missing_arg_error = opt_args("MissingArgError", flags[i])
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
312 if (missing_arg_error == "")
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
313 missing_arg_error = "NULL"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
314 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
315 missing_arg_error = quote missing_arg_error quote
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
316
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
317
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
318 warn_message = opt_args("Warn", flags[i])
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
319 if (warn_message == "")
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
320 warn_message = "NULL"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
321 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
322 warn_message = quote warn_message quote
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
323
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
324 alias_arg = opt_args("Alias", flags[i])
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
325 if (alias_arg == "") {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
326 if (flag_set_p("Ignore", flags[i])) {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
327 alias_data = "NULL, NULL, OPT_SPECIAL_ignore"
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
328 if (warn_message != "NULL")
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
329 print "#error Ignored option with Warn"
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
330 if (var_name(flags[i]) != "")
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
331 print "#error Ignored option with Var"
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
332 if (flag_set_p("Report", flags[i]))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
333 print "#error Ignored option with Report"
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
334 }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
335 else if (flag_set_p("Deprecated", flags[i]))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
336 print "#error Deprecated was replaced with WarnRemoved"
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
337 else if (flag_set_p("WarnRemoved", flags[i])) {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
338 alias_data = "NULL, NULL, OPT_SPECIAL_warn_removed"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
339 if (warn_message != "NULL")
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
340 print "#error WarnRemoved option with Warn"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
341 if (flag_set_p("Report", flags[i]))
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
342 print "#error WarnRemoved option with Report"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
343 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
344 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
345 alias_data = "NULL, NULL, N_OPTS"
111
kono
parents: 67
diff changeset
346 if (flag_set_p("Enum.*", flags[i])) {
kono
parents: 67
diff changeset
347 if (!flag_set_p("RejectNegative", flags[i]) \
kono
parents: 67
diff changeset
348 && opts[i] ~ "^[Wfgm]")
kono
parents: 67
diff changeset
349 print "#error Enum allowing negative form"
kono
parents: 67
diff changeset
350 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
351 } else {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
352 alias_opt = nth_arg(0, alias_arg)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
353 alias_posarg = nth_arg(1, alias_arg)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
354 alias_negarg = nth_arg(2, alias_arg)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
355
111
kono
parents: 67
diff changeset
356 if (var_ref(opts[i], flags[i]) != "(unsigned short) -1")
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
357 print "#error Alias setting variable"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
358
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
359 if (alias_posarg != "" && alias_negarg == "") {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
360 if (!flag_set_p("RejectNegative", flags[i]) \
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
361 && opts[i] ~ "^[Wfm]")
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
362 print "#error Alias with single argument " \
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
363 "allowing negative form"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
364 }
111
kono
parents: 67
diff changeset
365 if (alias_posarg != "" \
kono
parents: 67
diff changeset
366 && flag_set_p("NegativeAlias", flags[i])) {
kono
parents: 67
diff changeset
367 print "#error Alias with multiple arguments " \
kono
parents: 67
diff changeset
368 "used with NegativeAlias"
kono
parents: 67
diff changeset
369 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
370
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
371 alias_opt = opt_enum(alias_opt)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
372 if (alias_posarg == "")
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
373 alias_posarg = "NULL"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
374 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
375 alias_posarg = quote alias_posarg quote
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
376 if (alias_negarg == "")
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
377 alias_negarg = "NULL"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
378 else
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
379 alias_negarg = quote alias_negarg quote
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
380 alias_data = alias_posarg ", " alias_negarg ", " alias_opt
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
381 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
382
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 neg = opt_args("Negative", flags[i]);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 if (neg != "")
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 idx = indices[neg]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 else {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 if (flag_set_p("RejectNegative", flags[i]))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 idx = -1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 else {
111
kono
parents: 67
diff changeset
390 if (opts[i] ~ "^[Wfgm]")
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 idx = indices[opts[i]];
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 idx = -1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 # Split the printf after %u to work around an ia64-hp-hpux11.23
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 # awk bug.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
398 printf(" /* [%i] = */ {\n", optindex)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
399 printf(" %c-%s%c,\n %s,\n %s,\n %s,\n %s, %s, %u,",
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
400 quote, opts[i], quote, hlp, missing_arg_error, warn_message,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
401 alias_data, back_chain[i], len)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
402 printf(" /* .neg_idx = */ %d,\n", idx)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 condition = opt_args("Condition", flags[i])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 cl_flags = switch_flags(flags[i])
111
kono
parents: 67
diff changeset
405 cl_bit_fields = switch_bit_fields(flags[i])
kono
parents: 67
diff changeset
406 cl_zero_bit_fields = switch_bit_fields("")
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 if (condition != "")
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 printf("#if %s\n" \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 " %s,\n" \
111
kono
parents: 67
diff changeset
410 " 0, %s,\n" \
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 "#else\n" \
111
kono
parents: 67
diff changeset
412 " 0,\n" \
kono
parents: 67
diff changeset
413 " 1 /* Disabled. */, %s,\n" \
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 "#endif\n",
111
kono
parents: 67
diff changeset
415 condition, cl_flags, cl_bit_fields, cl_zero_bit_fields)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
416 else
111
kono
parents: 67
diff changeset
417 printf(" %s,\n" \
kono
parents: 67
diff changeset
418 " 0, %s,\n",
kono
parents: 67
diff changeset
419 cl_flags, cl_bit_fields)
kono
parents: 67
diff changeset
420 printf(" %s, %s, %s }%s\n", var_ref(opts[i], flags[i]),
kono
parents: 67
diff changeset
421 var_set(flags[i]), integer_range_info(opt_args("IntegerRange", flags[i]),
kono
parents: 67
diff changeset
422 opt_args("Init", flags[i]), opts[i]), comma)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
423
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
424 # Bump up the informational option index.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
425 ++optindex
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
426 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
427
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 print "};"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
429
111
kono
parents: 67
diff changeset
430 print "\n\n"
kono
parents: 67
diff changeset
431 print "bool "
kono
parents: 67
diff changeset
432 print "common_handle_option_auto (struct gcc_options *opts, "
kono
parents: 67
diff changeset
433 print " struct gcc_options *opts_set, "
kono
parents: 67
diff changeset
434 print " const struct cl_decoded_option *decoded, "
kono
parents: 67
diff changeset
435 print " unsigned int lang_mask, int kind, "
kono
parents: 67
diff changeset
436 print " location_t loc, "
kono
parents: 67
diff changeset
437 print " const struct cl_option_handlers *handlers, "
kono
parents: 67
diff changeset
438 print " diagnostic_context *dc) "
kono
parents: 67
diff changeset
439 print "{ "
kono
parents: 67
diff changeset
440 print " size_t scode = decoded->opt_index; "
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
441 print " HOST_WIDE_INT value = decoded->value; "
111
kono
parents: 67
diff changeset
442 print " enum opt_code code = (enum opt_code) scode; "
kono
parents: 67
diff changeset
443 print " "
kono
parents: 67
diff changeset
444 print " gcc_assert (decoded->canonical_option_num_elements <= 2); "
kono
parents: 67
diff changeset
445 print " "
kono
parents: 67
diff changeset
446 print " switch (code) "
kono
parents: 67
diff changeset
447 print " { "
kono
parents: 67
diff changeset
448 # Handle EnabledBy
kono
parents: 67
diff changeset
449 for (i = 0; i < n_enabledby; i++) {
kono
parents: 67
diff changeset
450 enabledby_name = enabledby[i];
kono
parents: 67
diff changeset
451 print " case " opt_enum(enabledby_name) ":"
kono
parents: 67
diff changeset
452 n_enables = split(enables[enabledby_name], thisenable, ";");
kono
parents: 67
diff changeset
453 n_enablesif = split(enablesif[enabledby_name], thisenableif, ";");
kono
parents: 67
diff changeset
454 if (n_enables != n_enablesif) {
kono
parents: 67
diff changeset
455 print "#error n_enables != n_enablesif: Something went wrong!"
kono
parents: 67
diff changeset
456 }
kono
parents: 67
diff changeset
457 for (j = 1; j < n_enables; j++) {
kono
parents: 67
diff changeset
458 opt_var_name = var_name(flags[opt_numbers[thisenable[j]]]);
kono
parents: 67
diff changeset
459 if (opt_var_name != "") {
kono
parents: 67
diff changeset
460 condition = "!opts_set->x_" opt_var_name
kono
parents: 67
diff changeset
461 if (thisenableif[j] != "") {
kono
parents: 67
diff changeset
462 value = "(" thisenableif[j] ")"
kono
parents: 67
diff changeset
463 } else {
kono
parents: 67
diff changeset
464 value = "value"
kono
parents: 67
diff changeset
465 }
kono
parents: 67
diff changeset
466 print " if (" condition ")"
kono
parents: 67
diff changeset
467 print " handle_generated_option (opts, opts_set,"
kono
parents: 67
diff changeset
468 print " " opt_enum(thisenable[j]) ", NULL, " value ","
kono
parents: 67
diff changeset
469 print " lang_mask, kind, loc, handlers, true, dc);"
kono
parents: 67
diff changeset
470 } else {
kono
parents: 67
diff changeset
471 print "#error " thisenable[j] " does not have a Var() flag"
kono
parents: 67
diff changeset
472 }
kono
parents: 67
diff changeset
473 }
kono
parents: 67
diff changeset
474 print " break;\n"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 }
111
kono
parents: 67
diff changeset
476 print " default: "
kono
parents: 67
diff changeset
477 print " break; "
kono
parents: 67
diff changeset
478 print " } "
kono
parents: 67
diff changeset
479 print " return true; "
kono
parents: 67
diff changeset
480 print "} "
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481
111
kono
parents: 67
diff changeset
482 # Handle LangEnabledBy
kono
parents: 67
diff changeset
483 for (i = 0; i < n_langs; i++) {
kono
parents: 67
diff changeset
484 lang_name = lang_sanitized_name(langs[i]);
kono
parents: 67
diff changeset
485 mark_unused = " ATTRIBUTE_UNUSED";
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486
111
kono
parents: 67
diff changeset
487 print "\n\n"
kono
parents: 67
diff changeset
488 print "bool "
kono
parents: 67
diff changeset
489 print lang_name "_handle_option_auto (struct gcc_options *opts" mark_unused ", "
kono
parents: 67
diff changeset
490 print " struct gcc_options *opts_set" mark_unused ", "
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
491 print " size_t scode" mark_unused ", const char *arg" mark_unused ", HOST_WIDE_INT value" mark_unused ", "
111
kono
parents: 67
diff changeset
492 print " unsigned int lang_mask" mark_unused ", int kind" mark_unused ", "
kono
parents: 67
diff changeset
493 print " location_t loc" mark_unused ", "
kono
parents: 67
diff changeset
494 print " const struct cl_option_handlers *handlers" mark_unused ", "
kono
parents: 67
diff changeset
495 print " diagnostic_context *dc" mark_unused ") "
kono
parents: 67
diff changeset
496 print "{ "
kono
parents: 67
diff changeset
497 print " enum opt_code code = (enum opt_code) scode; "
kono
parents: 67
diff changeset
498 print " "
kono
parents: 67
diff changeset
499 print " switch (code) "
kono
parents: 67
diff changeset
500 print " { "
kono
parents: 67
diff changeset
501
kono
parents: 67
diff changeset
502 for (k = 0; k < n_enabledby_lang[i]; k++) {
kono
parents: 67
diff changeset
503 enabledby_name = enabledby[lang_name,k];
kono
parents: 67
diff changeset
504 print " case " opt_enum(enabledby_name) ":"
kono
parents: 67
diff changeset
505 n_thisenable = split(enables[lang_name,enabledby_name], thisenable, ";");
kono
parents: 67
diff changeset
506 for (j = 1; j < n_thisenable; j++) {
kono
parents: 67
diff changeset
507 n_thisenable_args = split(thisenable[j], thisenable_args, ",");
kono
parents: 67
diff changeset
508 if (n_thisenable_args == 1) {
kono
parents: 67
diff changeset
509 thisenable_opt = thisenable[j];
kono
parents: 67
diff changeset
510 value = "value";
kono
parents: 67
diff changeset
511 } else {
kono
parents: 67
diff changeset
512 thisenable_opt = thisenable_args[1];
kono
parents: 67
diff changeset
513 with_posarg = thisenable_args[2];
kono
parents: 67
diff changeset
514 with_negarg = thisenable_args[3];
kono
parents: 67
diff changeset
515 value = "value ? " with_posarg " : " with_negarg;
kono
parents: 67
diff changeset
516 }
kono
parents: 67
diff changeset
517 opt_var_name = var_name(flags[opt_numbers[thisenable_opt]]);
kono
parents: 67
diff changeset
518 if (opt_var_name != "") {
kono
parents: 67
diff changeset
519 print " if (!opts_set->x_" opt_var_name ")"
kono
parents: 67
diff changeset
520 print " handle_generated_option (opts, opts_set,"
kono
parents: 67
diff changeset
521 print " " opt_enum(thisenable_opt) ", NULL, " value ","
kono
parents: 67
diff changeset
522 print " lang_mask, kind, loc, handlers, true, dc);"
kono
parents: 67
diff changeset
523 } else {
kono
parents: 67
diff changeset
524 print "#error " thisenable_opt " does not have a Var() flag"
kono
parents: 67
diff changeset
525 }
kono
parents: 67
diff changeset
526 }
kono
parents: 67
diff changeset
527 print " break;\n"
kono
parents: 67
diff changeset
528 }
kono
parents: 67
diff changeset
529 print " default: "
kono
parents: 67
diff changeset
530 print " break; "
kono
parents: 67
diff changeset
531 print " } "
kono
parents: 67
diff changeset
532 print " return true; "
kono
parents: 67
diff changeset
533 print "} "
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535
111
kono
parents: 67
diff changeset
536 #Handle CPP()
kono
parents: 67
diff changeset
537 print "\n"
kono
parents: 67
diff changeset
538 print "#include " quote "cpplib.h" quote;
kono
parents: 67
diff changeset
539 print "void"
kono
parents: 67
diff changeset
540 print "cpp_handle_option_auto (const struct gcc_options * opts, "
kono
parents: 67
diff changeset
541 print " size_t scode, struct cpp_options * cpp_opts)"
kono
parents: 67
diff changeset
542 print "{ "
kono
parents: 67
diff changeset
543 print " enum opt_code code = (enum opt_code) scode; "
kono
parents: 67
diff changeset
544 print " "
kono
parents: 67
diff changeset
545 print " switch (code) "
kono
parents: 67
diff changeset
546 print " { "
kono
parents: 67
diff changeset
547 for (i = 0; i < n_opts; i++) {
kono
parents: 67
diff changeset
548 # With identical flags, pick only the last one. The
kono
parents: 67
diff changeset
549 # earlier loop ensured that it has all flags merged,
kono
parents: 67
diff changeset
550 # and a nonempty help text if one of the texts was nonempty.
kono
parents: 67
diff changeset
551 while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
kono
parents: 67
diff changeset
552 i++;
kono
parents: 67
diff changeset
553 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
554
111
kono
parents: 67
diff changeset
555 cpp_option = nth_arg(0, opt_args("CPP", flags[i]));
kono
parents: 67
diff changeset
556 if (cpp_option != "") {
kono
parents: 67
diff changeset
557 opt_var_name = var_name(flags[i]);
kono
parents: 67
diff changeset
558 init = opt_args("Init", flags[i])
kono
parents: 67
diff changeset
559 if (opt_var_name != "" && init != "") {
kono
parents: 67
diff changeset
560 print " case " opt_enum(opts[i]) ":"
kono
parents: 67
diff changeset
561 print " cpp_opts->" cpp_option " = opts->x_" opt_var_name ";"
kono
parents: 67
diff changeset
562 print " break;"
kono
parents: 67
diff changeset
563 } else if (opt_var_name == "" && init == "") {
kono
parents: 67
diff changeset
564 print "#error CPP() requires setting Init() and Var() for " opts[i]
kono
parents: 67
diff changeset
565 } else if (opt_var_name != "") {
kono
parents: 67
diff changeset
566 print "#error CPP() requires setting Init() for " opts[i]
kono
parents: 67
diff changeset
567 } else {
kono
parents: 67
diff changeset
568 print "#error CPP() requires setting Var() for " opts[i]
kono
parents: 67
diff changeset
569 }
kono
parents: 67
diff changeset
570 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 }
111
kono
parents: 67
diff changeset
572 print " default: "
kono
parents: 67
diff changeset
573 print " break; "
kono
parents: 67
diff changeset
574 print " } "
kono
parents: 67
diff changeset
575 print "}\n"
kono
parents: 67
diff changeset
576 print "void"
kono
parents: 67
diff changeset
577 print "init_global_opts_from_cpp(struct gcc_options * opts, "
kono
parents: 67
diff changeset
578 print " const struct cpp_options * cpp_opts)"
kono
parents: 67
diff changeset
579 print "{ "
kono
parents: 67
diff changeset
580 for (i = 0; i < n_opts; i++) {
kono
parents: 67
diff changeset
581 # With identical flags, pick only the last one. The
kono
parents: 67
diff changeset
582 # earlier loop ensured that it has all flags merged,
kono
parents: 67
diff changeset
583 # and a nonempty help text if one of the texts was nonempty.
kono
parents: 67
diff changeset
584 while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
kono
parents: 67
diff changeset
585 i++;
kono
parents: 67
diff changeset
586 }
kono
parents: 67
diff changeset
587 cpp_option = nth_arg(0, opt_args("CPP", flags[i]));
kono
parents: 67
diff changeset
588 opt_var_name = var_name(flags[i]);
kono
parents: 67
diff changeset
589 if (cpp_option != "" && opt_var_name != "") {
kono
parents: 67
diff changeset
590 print " opts->x_" opt_var_name " = cpp_opts->" cpp_option ";"
kono
parents: 67
diff changeset
591 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 }
111
kono
parents: 67
diff changeset
593 print "} "
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596