]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/optc-gen.awk
[Ada] Avoid creating temporaries in Universal_Integer, continued
[thirdparty/gcc.git] / gcc / optc-gen.awk
CommitLineData
8d9254fc 1# Copyright (C) 2003-2020 Free Software Foundation, Inc.
776dc15d
KC
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
9dcd6f09 7# Free Software Foundation; either version 3, or (at your option) any
776dc15d
KC
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
9dcd6f09
NC
16# along with this program; see the file COPYING3. If not see
17# <http://www.gnu.org/licenses/>.
776dc15d
KC
18
19# This Awk script reads in the option records generated from
fc54bc84 20# opt-gather.awk, combines the flags of duplicate options and generates a
776dc15d
KC
21# C file.
22#
86fa5de4
JM
23
24# This program uses functions from opt-functions.awk and code from
25# opt-read.awk.
776dc15d 26#
86fa5de4 27# Usage: awk -f opt-functions.awk -f opt-read.awk -f optc-gen.awk \
776dc15d
KC
28# [-v header_name=header.h] < inputfile > options.c
29
776dc15d
KC
30# Dump that array of options into a C file.
31END {
f2bc201f 32
c2d89095
MLI
33
34# Combine the flags of identical switches. Switches
35# appear many times if they are handled by many front
36# ends, for example.
37for (i = 0; i < n_opts; i++) {
38 merged_flags[i] = flags[i]
39}
40for (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.
f2bc201f
MLI
48n_enabledby = 0;
49for (i = 0; i < n_langs; i++) {
50 n_enabledby_lang[i] = 0;
51}
52for (i = 0; i < n_opts; i++) {
53 enabledby_arg = opt_args("EnabledBy", flags[i]);
54 if (enabledby_arg != "") {
27e51192
TB
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) {
c2d89095 65 print "#error " opts[i] " EnabledBy(Wfoo && Wbar && Wbaz) currently not supported"
d919140b
MLI
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 == "") {
c2d89095
MLI
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 = "";
27e51192 78 if (logical_and != 0) {
d919140b
MLI
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 ";";
f2bc201f 95 }
f2bc201f
MLI
96 }
97 }
98
99 enabledby_arg = opt_args("LangEnabledBy", flags[i]);
100 if (enabledby_arg != "") {
0829c7f7 101 enabledby_langs = nth_arg(0, enabledby_arg);
f2bc201f 102 enabledby_name = nth_arg(1, enabledby_arg);
0829c7f7
MLI
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);
f2bc201f
MLI
106 }
107}
108
109
af47e6ac 110print "/* This file is auto-generated by optc-gen.awk. */"
776dc15d 111print ""
aeb70e78
RS
112n_headers = split(header_name, headers, " ")
113for (i = 1; i <= n_headers; i++)
114 print "#include " quote headers[i] quote
776dc15d 115print "#include " quote "opts.h" quote
fb664b5a 116print "#include " quote "intl.h" quote
c344a866 117print "#include " quote "insn-attr-common.h" quote
776dc15d
KC
118print ""
119
fd438373
MM
120if (n_extra_c_includes > 0) {
121 for (i = 0; i < n_extra_c_includes; i++) {
122 print "#include " quote extra_c_includes[i] quote
123 }
124 print ""
125}
126
e6d4b984
JM
127for (i = 0; i < n_enums; i++) {
128 name = enum_names[i]
129 type = enum_type[name]
130 print "static const struct cl_enum_arg cl_enum_" name \
131 "_data[] = "
132 print "{"
133 print enum_data[name] " { NULL, 0, 0 }"
134 print "};"
135 print ""
136 print "static void"
137 print "cl_enum_" name "_set (void *var, int value)"
138 print "{"
139 print " *((" type " *) var) = (" type ") value;"
140 print "}"
141 print ""
142 print "static int"
143 print "cl_enum_" name "_get (const void *var)"
144 print "{"
145 print " return (int) *((const " type " *) var);"
146 print "}"
147 print ""
148}
149
150print "const struct cl_enum cl_enums[] ="
151print "{"
152for (i = 0; i < n_enums; i++) {
153 name = enum_names[i]
154 ehelp = enum_help[name]
155 if (ehelp == "")
156 ehelp = "NULL"
157 else
158 ehelp = quote ehelp quote
159 unknown_error = enum_unknown_error[name]
160 if (unknown_error == "")
161 unknown_error = "NULL"
162 else
163 unknown_error = quote unknown_error quote
164 print " {"
165 print " " ehelp ","
166 print " " unknown_error ","
167 print " cl_enum_" name "_data,"
168 print " sizeof (" enum_type[name] "),"
169 print " cl_enum_" name "_set,"
170 print " cl_enum_" name "_get"
171 print " },"
172}
173print "};"
174print "const unsigned int cl_enums_count = " n_enums ";"
175print ""
176
a75bfaa6 177print "const struct gcc_options global_options_init =\n{"
e90afde6 178for (i = 0; i < n_extra_vars; i++) {
e3339d0f
JM
179 var = extra_vars[i]
180 init = extra_vars[i]
181 if (var ~ "=" ) {
182 sub(".*= *", "", init)
e3339d0f
JM
183 } else {
184 init = "0"
185 }
24f48c2f
JM
186 sub(" *=.*", "", var)
187 name = var
188 sub("^.*[ *]", "", name)
189 sub("\\[.*\\]$", "", name)
190 var_seen[name] = 1
191 print " " init ", /* " name " */"
e90afde6 192}
776dc15d
KC
193for (i = 0; i < n_opts; i++) {
194 name = var_name(flags[i]);
195 if (name == "")
196 continue;
197
e3339d0f
JM
198 init = opt_args("Init", flags[i])
199 if (init != "") {
200 if (name in var_init && var_init[name] != init)
201 print "#error multiple initializers for " name
202 var_init[name] = init
14c7833c 203 }
e3339d0f
JM
204}
205for (i = 0; i < n_opts; i++) {
206 name = var_name(flags[i]);
207 if (name == "")
208 continue;
209
210 if (name in var_seen)
211 continue;
212
213 if (name in var_init)
214 init = var_init[name]
215 else
216 init = "0"
a56a0779 217
e3339d0f 218 print " " init ", /* " name " */"
f7f655c7
DD
219
220 var_seen[name] = 1;
a56a0779 221}
ee133b69
RS
222for (i = 0; i < n_opts; i++) {
223 name = static_var(opts[i], flags[i]);
46625112
JM
224 if (name != "") {
225 print " 0, /* " name " (private state) */"
226 print "#undef x_" name
227 }
ee133b69 228}
5e46b0c6
ILT
229for (i = 0; i < n_opts; i++) {
230 if (flag_set_p("SetByCombined", flags[i]))
231 print " false, /* frontend_set_" var_name(flags[i]) " */"
232}
46625112 233print "};"
ee133b69 234print ""
a75bfaa6 235print "struct gcc_options global_options;"
d4d24ba4
JM
236print "struct gcc_options global_options_set;"
237print ""
776dc15d
KC
238
239print "const char * const lang_names[] =\n{"
240for (i = 0; i < n_langs; i++) {
f2bc201f 241 macros[i] = "CL_" lang_sanitized_name(langs[i])
776dc15d
KC
242 s = substr(" ", length (macros[i]))
243 print " " quote langs[i] quote ","
244 }
245
246print " 0\n};\n"
247print "const unsigned int cl_options_count = N_OPTS;\n"
58265ea6
GF
248print "#if (1U << " n_langs ") > CL_MIN_OPTION_CLASS"
249print " #error the number of languages exceeds the implementation limit"
250print "#endif"
c662432e 251print "const unsigned int cl_lang_count = " n_langs ";\n"
776dc15d
KC
252
253print "const struct cl_option cl_options[] =\n{"
254
14c7833c
L
255j = 0
256for (i = 0; i < n_opts; i++) {
776dc15d 257 back_chain[i] = "N_OPTS";
14c7833c
L
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];
a16d1645
RW
264 if (help[i + 1] == "")
265 help[i + 1] = help[i]
40a1cfba 266 else if (help[i] != "" && help[i + 1] != help[i])
71caddc5
MLI
267 print "#error Multiple different help strings for " \
268 opts[i] ":\n\t" help[i] "\n\t" help[i + 1]
269
14c7833c
L
270 i++;
271 back_chain[i] = "N_OPTS";
272 indices[opts[i]] = j;
273 }
274 j++;
275}
776dc15d 276
00abf86c 277optindex = 0
b167666c 278for (i = 0; i < n_opts; i++) {
a16d1645
RW
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.
b167666c 282 while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
b167666c
RS
283 i++;
284 }
776dc15d 285
b167666c 286 len = length (opts[i]);
9db94baa 287 enum = opt_enum(opts[i])
b167666c
RS
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;
776dc15d 299 }
b167666c 300 }
776dc15d 301
b167666c
RS
302 s = substr(" ", length (opts[i]))
303 if (i + 1 == n_opts)
304 comma = ""
776dc15d 305
b167666c 306 if (help[i] == "")
00abf86c 307 hlp = "NULL"
b167666c
RS
308 else
309 hlp = quote help[i] quote;
776dc15d 310
61ff2bdc
JM
311 missing_arg_error = opt_args("MissingArgError", flags[i])
312 if (missing_arg_error == "")
00abf86c 313 missing_arg_error = "NULL"
61ff2bdc
JM
314 else
315 missing_arg_error = quote missing_arg_error quote
316
2d2bd949
JM
317
318 warn_message = opt_args("Warn", flags[i])
319 if (warn_message == "")
00abf86c 320 warn_message = "NULL"
2d2bd949
JM
321 else
322 warn_message = quote warn_message quote
323
5de8299c
JM
324 alias_arg = opt_args("Alias", flags[i])
325 if (alias_arg == "") {
c0c12356
ML
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 }
68a57628
ML
335 else if (flag_set_p("Deprecated", flags[i]))
336 print "#error Deprecated was replaced with WarnRemoved"
337 else if (flag_set_p("WarnRemoved", flags[i])) {
338 alias_data = "NULL, NULL, OPT_SPECIAL_warn_removed"
c0c12356 339 if (warn_message != "NULL")
68a57628 340 print "#error WarnRemoved option with Warn"
c0c12356 341 if (flag_set_p("Report", flags[i]))
68a57628 342 print "#error WarnRemoved option with Report"
c0c12356 343 }
2d2bd949
JM
344 else
345 alias_data = "NULL, NULL, N_OPTS"
742b1804
JJ
346 if (flag_set_p("Enum.*", flags[i])) {
347 if (!flag_set_p("RejectNegative", flags[i]) \
9ed32e27 348 && opts[i] ~ "^[Wfgm]")
742b1804
JJ
349 print "#error Enum allowing negative form"
350 }
5de8299c
JM
351 } else {
352 alias_opt = nth_arg(0, alias_arg)
353 alias_posarg = nth_arg(1, alias_arg)
354 alias_negarg = nth_arg(2, alias_arg)
355
f6b3ca5a 356 if (var_ref(opts[i], flags[i]) != "(unsigned short) -1")
5de8299c
JM
357 print "#error Alias setting variable"
358
359 if (alias_posarg != "" && alias_negarg == "") {
360 if (!flag_set_p("RejectNegative", flags[i]) \
361 && opts[i] ~ "^[Wfm]")
362 print "#error Alias with single argument " \
363 "allowing negative form"
364 }
666a21a2
JM
365 if (alias_posarg != "" \
366 && flag_set_p("NegativeAlias", flags[i])) {
367 print "#error Alias with multiple arguments " \
368 "used with NegativeAlias"
369 }
5de8299c
JM
370
371 alias_opt = opt_enum(alias_opt)
372 if (alias_posarg == "")
373 alias_posarg = "NULL"
374 else
375 alias_posarg = quote alias_posarg quote
376 if (alias_negarg == "")
377 alias_negarg = "NULL"
378 else
379 alias_negarg = quote alias_negarg quote
380 alias_data = alias_posarg ", " alias_negarg ", " alias_opt
381 }
382
14c7833c
L
383 neg = opt_args("Negative", flags[i]);
384 if (neg != "")
385 idx = indices[neg]
386 else {
387 if (flag_set_p("RejectNegative", flags[i]))
388 idx = -1;
389 else {
9ed32e27 390 if (opts[i] ~ "^[Wfgm]")
14c7833c
L
391 idx = indices[opts[i]];
392 else
393 idx = -1;
394 }
395 }
b1c61c7e
RW
396 # Split the printf after %u to work around an ia64-hp-hpux11.23
397 # awk bug.
00abf86c
MS
398 printf(" /* [%i] = */ {\n", optindex)
399 printf(" %c-%s%c,\n %s,\n %s,\n %s,\n %s, %s, %u,",
2d2bd949 400 quote, opts[i], quote, hlp, missing_arg_error, warn_message,
5de8299c 401 alias_data, back_chain[i], len)
00abf86c 402 printf(" /* .neg_idx = */ %d,\n", idx)
aeb70e78
RS
403 condition = opt_args("Condition", flags[i])
404 cl_flags = switch_flags(flags[i])
300d83d9
JM
405 cl_bit_fields = switch_bit_fields(flags[i])
406 cl_zero_bit_fields = switch_bit_fields("")
aeb70e78
RS
407 if (condition != "")
408 printf("#if %s\n" \
409 " %s,\n" \
300d83d9 410 " 0, %s,\n" \
aeb70e78 411 "#else\n" \
300d83d9
JM
412 " 0,\n" \
413 " 1 /* Disabled. */, %s,\n" \
aeb70e78 414 "#endif\n",
300d83d9 415 condition, cl_flags, cl_bit_fields, cl_zero_bit_fields)
aeb70e78 416 else
300d83d9
JM
417 printf(" %s,\n" \
418 " 0, %s,\n",
419 cl_flags, cl_bit_fields)
63010089 420 printf(" %s, %s, %s }%s\n", var_ref(opts[i], flags[i]),
e88a9384
ML
421 var_set(flags[i]), integer_range_info(opt_args("IntegerRange", flags[i]),
422 opt_args("Init", flags[i]), opts[i]), comma)
00abf86c
MS
423
424 # Bump up the informational option index.
425 ++optindex
426 }
776dc15d
KC
427
428print "};"
ab442df7 429
7d5a5747
MLI
430print "\n\n"
431print "bool "
432print "common_handle_option_auto (struct gcc_options *opts, "
433print " struct gcc_options *opts_set, "
434print " const struct cl_decoded_option *decoded, "
435print " unsigned int lang_mask, int kind, "
436print " location_t loc, "
437print " const struct cl_option_handlers *handlers, "
438print " diagnostic_context *dc) "
439print "{ "
440print " size_t scode = decoded->opt_index; "
00abf86c 441print " HOST_WIDE_INT value = decoded->value; "
7d5a5747
MLI
442print " enum opt_code code = (enum opt_code) scode; "
443print " "
444print " gcc_assert (decoded->canonical_option_num_elements <= 2); "
445print " "
446print " switch (code) "
447print " { "
d919140b 448# Handle EnabledBy
7d5a5747
MLI
449for (i = 0; i < n_enabledby; i++) {
450 enabledby_name = enabledby[i];
451 print " case " opt_enum(enabledby_name) ":"
65d4f2cd 452 n_enables = split(enables[enabledby_name], thisenable, ";");
d919140b
MLI
453 n_enablesif = split(enablesif[enabledby_name], thisenableif, ";");
454 if (n_enables != n_enablesif) {
455 print "#error n_enables != n_enablesif: Something went wrong!"
456 }
7d5a5747
MLI
457 for (j = 1; j < n_enables; j++) {
458 opt_var_name = var_name(flags[opt_numbers[thisenable[j]]]);
9b095bf1 459 if (opt_var_name != "") {
d919140b
MLI
460 condition = "!opts_set->x_" opt_var_name
461 if (thisenableif[j] != "") {
a82122df
MK
462 value = "(" thisenableif[j] ")"
463 } else {
464 value = "value"
d919140b
MLI
465 }
466 print " if (" condition ")"
9b095bf1 467 print " handle_generated_option (opts, opts_set,"
a82122df 468 print " " opt_enum(thisenable[j]) ", NULL, " value ","
b9822443 469 print " lang_mask, kind, loc, handlers, true, dc);"
9b095bf1
MLI
470 } else {
471 print "#error " thisenable[j] " does not have a Var() flag"
472 }
7d5a5747
MLI
473 }
474 print " break;\n"
7d5a5747
MLI
475}
476print " default: "
477print " break; "
478print " } "
479print " return true; "
480print "} "
481
f2bc201f
MLI
482# Handle LangEnabledBy
483for (i = 0; i < n_langs; i++) {
484 lang_name = lang_sanitized_name(langs[i]);
485 mark_unused = " ATTRIBUTE_UNUSED";
486
487 print "\n\n"
488 print "bool "
489 print lang_name "_handle_option_auto (struct gcc_options *opts" mark_unused ", "
490 print " struct gcc_options *opts_set" mark_unused ", "
00abf86c 491 print " size_t scode" mark_unused ", const char *arg" mark_unused ", HOST_WIDE_INT value" mark_unused ", "
f2bc201f
MLI
492 print " unsigned int lang_mask" mark_unused ", int kind" mark_unused ", "
493 print " location_t loc" mark_unused ", "
494 print " const struct cl_option_handlers *handlers" mark_unused ", "
495 print " diagnostic_context *dc" mark_unused ") "
496 print "{ "
497 print " enum opt_code code = (enum opt_code) scode; "
498 print " "
499 print " switch (code) "
500 print " { "
501
502 for (k = 0; k < n_enabledby_lang[i]; k++) {
503 enabledby_name = enabledby[lang_name,k];
504 print " case " opt_enum(enabledby_name) ":"
65d4f2cd
MLI
505 n_thisenable = split(enables[lang_name,enabledby_name], thisenable, ";");
506 for (j = 1; j < n_thisenable; j++) {
507 n_thisenable_args = split(thisenable[j], thisenable_args, ",");
508 if (n_thisenable_args == 1) {
509 thisenable_opt = thisenable[j];
510 value = "value";
511 } else {
512 thisenable_opt = thisenable_args[1];
513 with_posarg = thisenable_args[2];
514 with_negarg = thisenable_args[3];
515 value = "value ? " with_posarg " : " with_negarg;
516 }
517 opt_var_name = var_name(flags[opt_numbers[thisenable_opt]]);
9b095bf1
MLI
518 if (opt_var_name != "") {
519 print " if (!opts_set->x_" opt_var_name ")"
520 print " handle_generated_option (opts, opts_set,"
65d4f2cd 521 print " " opt_enum(thisenable_opt) ", NULL, " value ","
b9822443 522 print " lang_mask, kind, loc, handlers, true, dc);"
9b095bf1 523 } else {
65d4f2cd 524 print "#error " thisenable_opt " does not have a Var() flag"
9b095bf1 525 }
f2bc201f
MLI
526 }
527 print " break;\n"
528 }
529 print " default: "
530 print " break; "
531 print " } "
532 print " return true; "
533 print "} "
534}
535
43f9a13c
MLI
536#Handle CPP()
537print "\n"
538print "#include " quote "cpplib.h" quote;
539print "void"
540print "cpp_handle_option_auto (const struct gcc_options * opts, "
541print " size_t scode, struct cpp_options * cpp_opts)"
542print "{ "
543print " enum opt_code code = (enum opt_code) scode; "
544print " "
545print " switch (code) "
546print " { "
547for (i = 0; i < n_opts; i++) {
548 # With identical flags, pick only the last one. The
549 # earlier loop ensured that it has all flags merged,
550 # and a nonempty help text if one of the texts was nonempty.
551 while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
552 i++;
553 }
554
555 cpp_option = nth_arg(0, opt_args("CPP", flags[i]));
2b71f4a4
MLI
556 if (cpp_option != "") {
557 opt_var_name = var_name(flags[i]);
558 init = opt_args("Init", flags[i])
559 if (opt_var_name != "" && init != "") {
560 print " case " opt_enum(opts[i]) ":"
561 print " cpp_opts->" cpp_option " = opts->x_" opt_var_name ";"
562 print " break;"
563 } else if (opt_var_name == "" && init == "") {
564 print "#error CPP() requires setting Init() and Var() for " opts[i]
565 } else if (opt_var_name != "") {
566 print "#error CPP() requires setting Init() for " opts[i]
567 } else {
568 print "#error CPP() requires setting Var() for " opts[i]
569 }
43f9a13c 570 }
776dc15d 571}
43f9a13c
MLI
572print " default: "
573print " break; "
574print " } "
575print "}\n"
576print "void"
577print "init_global_opts_from_cpp(struct gcc_options * opts, "
578print " const struct cpp_options * cpp_opts)"
579print "{ "
580for (i = 0; i < n_opts; i++) {
581 # With identical flags, pick only the last one. The
582 # earlier loop ensured that it has all flags merged,
583 # and a nonempty help text if one of the texts was nonempty.
584 while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
585 i++;
586 }
587 cpp_option = nth_arg(0, opt_args("CPP", flags[i]));
588 opt_var_name = var_name(flags[i]);
589 if (cpp_option != "" && opt_var_name != "") {
590 print " opts->x_" opt_var_name " = cpp_opts->" cpp_option ";"
591 }
592}
593print "} "
594
595}
596