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