]>
Commit | Line | Data |
---|---|---|
7cf0dbf3 | 1 | # Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010 |
2 | # Free Software Foundation, Inc. | |
e8b212b8 | 3 | # Contributed by Kelley Cook, June 2004. |
4 | # Original code from Neil Booth, May 2003. | |
5 | # | |
6 | # This program is free software; you can redistribute it and/or modify it | |
7 | # under the terms of the GNU General Public License as published by the | |
8c4c00c1 | 8 | # Free Software Foundation; either version 3, or (at your option) any |
e8b212b8 | 9 | # later version. |
10 | # | |
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License | |
8c4c00c1 | 17 | # along with this program; see the file COPYING3. If not see |
18 | # <http://www.gnu.org/licenses/>. | |
e8b212b8 | 19 | |
20 | # This Awk script reads in the option records generated from | |
63433b97 | 21 | # opt-gather.awk, combines the flags of duplicate options and generates a |
e8b212b8 | 22 | # C file. |
23 | # | |
24 | # This program uses functions from opt-functions.awk | |
25 | # | |
26 | # Usage: awk -f opt-functions.awk -f optc-gen.awk \ | |
27 | # [-v header_name=header.h] < inputfile > options.c | |
28 | ||
29 | BEGIN { | |
30 | n_opts = 0 | |
31 | n_langs = 0 | |
46f8e3b0 | 32 | n_target_save = 0 |
0f8defe5 | 33 | n_extra_vars = 0 |
e8b212b8 | 34 | quote = "\042" |
35 | comma = "," | |
36 | FS=SUBSEP | |
37 | # Default the name of header created from opth-gen.awk to options.h | |
38 | if (header_name == "") header_name="options.h" | |
39 | } | |
40 | ||
41 | # Collect the text and flags of each option into an array | |
42 | { | |
43 | if ($1 == "Language") { | |
44 | langs[n_langs] = $2 | |
45 | n_langs++; | |
46 | } | |
46f8e3b0 | 47 | else if ($1 == "TargetSave") { |
48 | # Make sure the declarations are put in source order | |
49 | target_save_decl[n_target_save] = $2 | |
50 | n_target_save++ | |
51 | } | |
0f8defe5 | 52 | else if ($1 == "Variable") { |
53 | extra_vars[n_extra_vars] = $2 | |
54 | n_extra_vars++ | |
55 | } | |
e8b212b8 | 56 | else { |
a9341855 | 57 | name = opt_args("Mask", $1) |
58 | if (name == "") { | |
59 | opts[n_opts] = $1 | |
60 | flags[n_opts] = $2 | |
61 | help[n_opts] = $3 | |
1df76a79 | 62 | for (i = 4; i <= NF; i++) |
63 | help[n_opts] = help[n_opts] " " $i | |
a9341855 | 64 | n_opts++; |
65 | } | |
e8b212b8 | 66 | } |
67 | } | |
68 | ||
69 | # Dump that array of options into a C file. | |
70 | END { | |
30b0f428 | 71 | print "/* This file is auto-generated by optc-gen.awk. */" |
e8b212b8 | 72 | print "" |
5c5ccba2 | 73 | n_headers = split(header_name, headers, " ") |
74 | for (i = 1; i <= n_headers; i++) | |
75 | print "#include " quote headers[i] quote | |
e8b212b8 | 76 | print "#include " quote "opts.h" quote |
6ce616df | 77 | print "#include " quote "intl.h" quote |
e8b212b8 | 78 | print "" |
f83b64ca | 79 | print "#ifndef GCC_DRIVER" |
46f8e3b0 | 80 | print "#include " quote "flags.h" quote |
81 | print "#include " quote "target.h" quote | |
486ae7e7 | 82 | print "#endif /* GCC_DRIVER */" |
a1baa5f1 | 83 | print "" |
e8b212b8 | 84 | |
46f8e3b0 | 85 | have_save = 0; |
f3f006ad | 86 | print "const struct gcc_options global_options_init =\n{" |
0f8defe5 | 87 | for (i = 0; i < n_extra_vars; i++) { |
5ae82d58 | 88 | var = extra_vars[i] |
89 | init = extra_vars[i] | |
90 | if (var ~ "=" ) { | |
91 | sub(".*= *", "", init) | |
92 | sub(" *=.*", "", var) | |
93 | sub("^.*[ *]", "", var) | |
d7175aef | 94 | sub("\\[.*\\]$", "", var) |
5ae82d58 | 95 | } else { |
96 | init = "0" | |
97 | } | |
98 | var_seen[var] = 1 | |
99 | print " " init ", /* " var " */" | |
0f8defe5 | 100 | } |
e8b212b8 | 101 | for (i = 0; i < n_opts; i++) { |
46f8e3b0 | 102 | if (flag_set_p("Save", flags[i])) |
103 | have_save = 1; | |
104 | ||
e8b212b8 | 105 | name = var_name(flags[i]); |
106 | if (name == "") | |
107 | continue; | |
108 | ||
5ae82d58 | 109 | init = opt_args("Init", flags[i]) |
110 | if (init != "") { | |
111 | if (name in var_init && var_init[name] != init) | |
112 | print "#error multiple initializers for " name | |
113 | var_init[name] = init | |
a1baa5f1 | 114 | } |
5ae82d58 | 115 | } |
116 | for (i = 0; i < n_opts; i++) { | |
117 | name = var_name(flags[i]); | |
118 | if (name == "") | |
119 | continue; | |
120 | ||
121 | if (name in var_seen) | |
122 | continue; | |
123 | ||
124 | if (name in var_init) | |
125 | init = var_init[name] | |
126 | else | |
127 | init = "0" | |
a150399d | 128 | |
5ae82d58 | 129 | print " " init ", /* " name " */" |
c5e839cb | 130 | |
131 | var_seen[name] = 1; | |
a150399d | 132 | } |
d6907cfa | 133 | for (i = 0; i < n_opts; i++) { |
134 | name = static_var(opts[i], flags[i]); | |
2c5d2e39 | 135 | if (name != "") { |
136 | print " 0, /* " name " (private state) */" | |
137 | print "#undef x_" name | |
138 | } | |
d6907cfa | 139 | } |
2c5d2e39 | 140 | print "};" |
d6907cfa | 141 | print "" |
f3f006ad | 142 | print "struct gcc_options global_options;" |
f83b64ca | 143 | print "struct gcc_options global_options_set;" |
144 | print "" | |
e8b212b8 | 145 | |
146 | print "const char * const lang_names[] =\n{" | |
147 | for (i = 0; i < n_langs; i++) { | |
148 | macros[i] = "CL_" langs[i] | |
ca40ed4b | 149 | gsub( "[^" alnum "_]", "X", macros[i] ) |
e8b212b8 | 150 | s = substr(" ", length (macros[i])) |
151 | print " " quote langs[i] quote "," | |
152 | } | |
153 | ||
154 | print " 0\n};\n" | |
155 | print "const unsigned int cl_options_count = N_OPTS;\n" | |
87c75316 | 156 | print "const unsigned int cl_lang_count = " n_langs ";\n" |
e8b212b8 | 157 | |
158 | print "const struct cl_option cl_options[] =\n{" | |
159 | ||
a1baa5f1 | 160 | j = 0 |
161 | for (i = 0; i < n_opts; i++) { | |
e8b212b8 | 162 | back_chain[i] = "N_OPTS"; |
a1baa5f1 | 163 | indices[opts[i]] = j; |
164 | # Combine the flags of identical switches. Switches | |
165 | # appear many times if they are handled by many front | |
166 | # ends, for example. | |
167 | while( i + 1 != n_opts && opts[i] == opts[i + 1] ) { | |
168 | flags[i + 1] = flags[i] " " flags[i + 1]; | |
e6a03973 | 169 | if (help[i + 1] == "") |
170 | help[i + 1] = help[i] | |
0863a8f4 | 171 | else if (help[i] != "" && help[i + 1] != help[i]) |
172 | print "warning: multiple different help strings for " \ | |
173 | opts[i] ":\n\t" help[i] "\n\t" help[i + 1] \ | |
174 | | "cat 1>&2" | |
a1baa5f1 | 175 | i++; |
176 | back_chain[i] = "N_OPTS"; | |
177 | indices[opts[i]] = j; | |
178 | } | |
179 | j++; | |
180 | } | |
e8b212b8 | 181 | |
d39ef3aa | 182 | for (i = 0; i < n_opts; i++) { |
e6a03973 | 183 | # With identical flags, pick only the last one. The |
184 | # earlier loop ensured that it has all flags merged, | |
185 | # and a nonempty help text if one of the texts was nonempty. | |
d39ef3aa | 186 | while( i + 1 != n_opts && opts[i] == opts[i + 1] ) { |
d39ef3aa | 187 | i++; |
188 | } | |
e8b212b8 | 189 | |
d39ef3aa | 190 | len = length (opts[i]); |
d4c7816a | 191 | enum = opt_enum(opts[i]) |
d39ef3aa | 192 | |
193 | # If this switch takes joined arguments, back-chain all | |
194 | # subsequent switches to it for which it is a prefix. If | |
195 | # a later switch S is a longer prefix of a switch T, T | |
196 | # will be back-chained to S in a later iteration of this | |
197 | # for() loop, which is what we want. | |
198 | if (flag_set_p("Joined.*", flags[i])) { | |
199 | for (j = i + 1; j < n_opts; j++) { | |
200 | if (substr (opts[j], 1, len) != opts[i]) | |
201 | break; | |
202 | back_chain[j] = enum; | |
e8b212b8 | 203 | } |
d39ef3aa | 204 | } |
e8b212b8 | 205 | |
d39ef3aa | 206 | s = substr(" ", length (opts[i])) |
207 | if (i + 1 == n_opts) | |
208 | comma = "" | |
e8b212b8 | 209 | |
d39ef3aa | 210 | if (help[i] == "") |
211 | hlp = "0" | |
212 | else | |
213 | hlp = quote help[i] quote; | |
e8b212b8 | 214 | |
fecf9011 | 215 | missing_arg_error = opt_args("MissingArgError", flags[i]) |
216 | if (missing_arg_error == "") | |
217 | missing_arg_error = "0" | |
218 | else | |
219 | missing_arg_error = quote missing_arg_error quote | |
220 | ||
3b0273a1 | 221 | |
222 | warn_message = opt_args("Warn", flags[i]) | |
223 | if (warn_message == "") | |
224 | warn_message = "0" | |
225 | else | |
226 | warn_message = quote warn_message quote | |
227 | ||
67089c6b | 228 | alias_arg = opt_args("Alias", flags[i]) |
229 | if (alias_arg == "") { | |
3b0273a1 | 230 | if (flag_set_p("Ignore", flags[i])) |
231 | alias_data = "NULL, NULL, OPT_SPECIAL_ignore" | |
232 | else | |
233 | alias_data = "NULL, NULL, N_OPTS" | |
67089c6b | 234 | } else { |
235 | alias_opt = nth_arg(0, alias_arg) | |
236 | alias_posarg = nth_arg(1, alias_arg) | |
237 | alias_negarg = nth_arg(2, alias_arg) | |
238 | ||
2c5d2e39 | 239 | if (var_ref(opts[i], flags[i]) != "-1") |
67089c6b | 240 | print "#error Alias setting variable" |
241 | ||
242 | if (alias_posarg != "" && alias_negarg == "") { | |
243 | if (!flag_set_p("RejectNegative", flags[i]) \ | |
244 | && opts[i] ~ "^[Wfm]") | |
245 | print "#error Alias with single argument " \ | |
246 | "allowing negative form" | |
247 | } | |
248 | ||
249 | alias_opt = opt_enum(alias_opt) | |
250 | if (alias_posarg == "") | |
251 | alias_posarg = "NULL" | |
252 | else | |
253 | alias_posarg = quote alias_posarg quote | |
254 | if (alias_negarg == "") | |
255 | alias_negarg = "NULL" | |
256 | else | |
257 | alias_negarg = quote alias_negarg quote | |
258 | alias_data = alias_posarg ", " alias_negarg ", " alias_opt | |
259 | } | |
260 | ||
a1baa5f1 | 261 | neg = opt_args("Negative", flags[i]); |
262 | if (neg != "") | |
263 | idx = indices[neg] | |
264 | else { | |
265 | if (flag_set_p("RejectNegative", flags[i])) | |
266 | idx = -1; | |
267 | else { | |
268 | if (opts[i] ~ "^[Wfm]") | |
269 | idx = indices[opts[i]]; | |
270 | else | |
271 | idx = -1; | |
272 | } | |
273 | } | |
13c2c394 | 274 | # Split the printf after %u to work around an ia64-hp-hpux11.23 |
275 | # awk bug. | |
3b0273a1 | 276 | printf(" { %c-%s%c,\n %s,\n %s,\n %s,\n %s, %s, %u,", |
277 | quote, opts[i], quote, hlp, missing_arg_error, warn_message, | |
67089c6b | 278 | alias_data, back_chain[i], len) |
13c2c394 | 279 | printf(" %d,\n", idx) |
5c5ccba2 | 280 | condition = opt_args("Condition", flags[i]) |
281 | cl_flags = switch_flags(flags[i]) | |
282 | if (condition != "") | |
283 | printf("#if %s\n" \ | |
284 | " %s,\n" \ | |
285 | "#else\n" \ | |
286 | " CL_DISABLED,\n" \ | |
287 | "#endif\n", | |
288 | condition, cl_flags, cl_flags) | |
289 | else | |
290 | printf(" %s,\n", cl_flags) | |
d6907cfa | 291 | printf(" %s, %s }%s\n", var_ref(opts[i], flags[i]), |
292 | var_set(flags[i]), comma) | |
e8b212b8 | 293 | } |
294 | ||
295 | print "};" | |
46f8e3b0 | 296 | |
297 | print ""; | |
5cd72fe5 | 298 | print "#if !defined(GCC_DRIVER) && !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS)" |
46f8e3b0 | 299 | print ""; |
300 | print "/* Save optimization variables into a structure. */" | |
301 | print "void"; | |
2c5d2e39 | 302 | print "cl_optimization_save (struct cl_optimization *ptr, struct gcc_options *opts)"; |
46f8e3b0 | 303 | print "{"; |
304 | ||
305 | n_opt_char = 2; | |
306 | n_opt_short = 0; | |
307 | n_opt_int = 0; | |
308 | n_opt_other = 0; | |
309 | var_opt_char[0] = "optimize"; | |
310 | var_opt_char[1] = "optimize_size"; | |
311 | var_opt_range["optimize"] = "0, 255"; | |
312 | var_opt_range["optimize_size"] = "0, 255"; | |
313 | ||
314 | # Sort by size to mimic how the structure is laid out to be friendlier to the | |
315 | # cache. | |
316 | ||
317 | for (i = 0; i < n_opts; i++) { | |
318 | if (flag_set_p("Optimization", flags[i])) { | |
319 | name = var_name(flags[i]) | |
320 | if(name == "") | |
321 | continue; | |
322 | ||
323 | if(name in var_opt_seen) | |
324 | continue; | |
325 | ||
326 | var_opt_seen[name]++; | |
327 | otype = var_type_struct(flags[i]); | |
328 | if (otype ~ "^((un)?signed +)?int *$") | |
329 | var_opt_int[n_opt_int++] = name; | |
330 | ||
331 | else if (otype ~ "^((un)?signed +)?short *$") | |
332 | var_opt_short[n_opt_short++] = name; | |
333 | ||
334 | else if (otype ~ "^((un)?signed +)?char *$") { | |
335 | var_opt_char[n_opt_char++] = name; | |
336 | if (otype ~ "^unsigned +char *$") | |
337 | var_opt_range[name] = "0, 255" | |
338 | else if (otype ~ "^signed +char *$") | |
339 | var_opt_range[name] = "-128, 127" | |
340 | } | |
341 | else | |
342 | var_opt_other[n_opt_other++] = name; | |
343 | } | |
344 | } | |
345 | ||
346 | for (i = 0; i < n_opt_char; i++) { | |
347 | name = var_opt_char[i]; | |
348 | if (var_opt_range[name] != "") | |
2c5d2e39 | 349 | print " gcc_assert (IN_RANGE (opts->x_" name ", " var_opt_range[name] "));"; |
46f8e3b0 | 350 | } |
351 | ||
352 | print ""; | |
353 | for (i = 0; i < n_opt_other; i++) { | |
2c5d2e39 | 354 | print " ptr->x_" var_opt_other[i] " = opts->x_" var_opt_other[i] ";"; |
46f8e3b0 | 355 | } |
356 | ||
357 | for (i = 0; i < n_opt_int; i++) { | |
2c5d2e39 | 358 | print " ptr->x_" var_opt_int[i] " = opts->x_" var_opt_int[i] ";"; |
46f8e3b0 | 359 | } |
360 | ||
361 | for (i = 0; i < n_opt_short; i++) { | |
2c5d2e39 | 362 | print " ptr->x_" var_opt_short[i] " = opts->x_" var_opt_short[i] ";"; |
46f8e3b0 | 363 | } |
364 | ||
365 | for (i = 0; i < n_opt_char; i++) { | |
2c5d2e39 | 366 | print " ptr->x_" var_opt_char[i] " = opts->x_" var_opt_char[i] ";"; |
46f8e3b0 | 367 | } |
368 | ||
369 | print "}"; | |
370 | ||
371 | print ""; | |
372 | print "/* Restore optimization options from a structure. */"; | |
373 | print "void"; | |
2c5d2e39 | 374 | print "cl_optimization_restore (struct gcc_options *opts, struct cl_optimization *ptr)"; |
46f8e3b0 | 375 | print "{"; |
376 | ||
377 | for (i = 0; i < n_opt_other; i++) { | |
2c5d2e39 | 378 | print " opts->x_" var_opt_other[i] " = ptr->x_" var_opt_other[i] ";"; |
46f8e3b0 | 379 | } |
380 | ||
381 | for (i = 0; i < n_opt_int; i++) { | |
2c5d2e39 | 382 | print " opts->x_" var_opt_int[i] " = ptr->x_" var_opt_int[i] ";"; |
46f8e3b0 | 383 | } |
384 | ||
385 | for (i = 0; i < n_opt_short; i++) { | |
2c5d2e39 | 386 | print " opts->x_" var_opt_short[i] " = ptr->x_" var_opt_short[i] ";"; |
46f8e3b0 | 387 | } |
388 | ||
389 | for (i = 0; i < n_opt_char; i++) { | |
2c5d2e39 | 390 | print " opts->x_" var_opt_char[i] " = ptr->x_" var_opt_char[i] ";"; |
46f8e3b0 | 391 | } |
392 | ||
4bec06b3 | 393 | print " targetm.override_options_after_change ();"; |
46f8e3b0 | 394 | print "}"; |
395 | ||
396 | print ""; | |
397 | print "/* Print optimization options from a structure. */"; | |
398 | print "void"; | |
399 | print "cl_optimization_print (FILE *file,"; | |
400 | print " int indent_to,"; | |
401 | print " struct cl_optimization *ptr)"; | |
402 | print "{"; | |
403 | ||
404 | print " fputs (\"\\n\", file);"; | |
405 | for (i = 0; i < n_opt_other; i++) { | |
5ae82d58 | 406 | print " if (ptr->x_" var_opt_other[i] ")"; |
95dcf70a | 407 | print " fprintf (file, \"%*s%s (%#lx)\\n\","; |
46f8e3b0 | 408 | print " indent_to, \"\","; |
409 | print " \"" var_opt_other[i] "\","; | |
5ae82d58 | 410 | print " (unsigned long)ptr->x_" var_opt_other[i] ");"; |
46f8e3b0 | 411 | print ""; |
412 | } | |
413 | ||
414 | for (i = 0; i < n_opt_int; i++) { | |
5ae82d58 | 415 | print " if (ptr->x_" var_opt_int[i] ")"; |
95dcf70a | 416 | print " fprintf (file, \"%*s%s (%#x)\\n\","; |
46f8e3b0 | 417 | print " indent_to, \"\","; |
418 | print " \"" var_opt_int[i] "\","; | |
5ae82d58 | 419 | print " ptr->x_" var_opt_int[i] ");"; |
46f8e3b0 | 420 | print ""; |
421 | } | |
422 | ||
423 | for (i = 0; i < n_opt_short; i++) { | |
5ae82d58 | 424 | print " if (ptr->x_" var_opt_short[i] ")"; |
95dcf70a | 425 | print " fprintf (file, \"%*s%s (%#x)\\n\","; |
46f8e3b0 | 426 | print " indent_to, \"\","; |
427 | print " \"" var_opt_short[i] "\","; | |
5ae82d58 | 428 | print " ptr->x_" var_opt_short[i] ");"; |
46f8e3b0 | 429 | print ""; |
430 | } | |
431 | ||
432 | for (i = 0; i < n_opt_char; i++) { | |
5ae82d58 | 433 | print " if (ptr->x_" var_opt_char[i] ")"; |
95dcf70a | 434 | print " fprintf (file, \"%*s%s (%#x)\\n\","; |
46f8e3b0 | 435 | print " indent_to, \"\","; |
436 | print " \"" var_opt_char[i] "\","; | |
5ae82d58 | 437 | print " ptr->x_" var_opt_char[i] ");"; |
46f8e3b0 | 438 | print ""; |
439 | } | |
440 | ||
441 | print "}"; | |
442 | ||
443 | print ""; | |
444 | print "/* Save selected option variables into a structure. */" | |
445 | print "void"; | |
2c5d2e39 | 446 | print "cl_target_option_save (struct cl_target_option *ptr, struct gcc_options *opts)"; |
46f8e3b0 | 447 | print "{"; |
448 | ||
449 | n_target_char = 0; | |
450 | n_target_short = 0; | |
451 | n_target_int = 0; | |
452 | n_target_other = 0; | |
453 | ||
454 | if (have_save) { | |
455 | for (i = 0; i < n_opts; i++) { | |
456 | if (flag_set_p("Save", flags[i])) { | |
457 | name = var_name(flags[i]) | |
458 | if(name == "") | |
459 | name = "target_flags"; | |
460 | ||
461 | if(name in var_save_seen) | |
462 | continue; | |
463 | ||
464 | var_save_seen[name]++; | |
465 | otype = var_type_struct(flags[i]) | |
466 | if (otype ~ "^((un)?signed +)?int *$") | |
467 | var_target_int[n_target_int++] = name; | |
468 | ||
469 | else if (otype ~ "^((un)?signed +)?short *$") | |
470 | var_target_short[n_target_short++] = name; | |
471 | ||
472 | else if (otype ~ "^((un)?signed +)?char *$") { | |
473 | var_target_char[n_target_char++] = name; | |
474 | if (otype ~ "^unsigned +char *$") | |
475 | var_target_range[name] = "0, 255" | |
476 | else if (otype ~ "^signed +char *$") | |
477 | var_target_range[name] = "-128, 127" | |
478 | } | |
479 | else | |
480 | var_target_other[n_target_other++] = name; | |
481 | } | |
482 | } | |
483 | } else { | |
484 | var_target_int[n_target_int++] = "target_flags"; | |
485 | } | |
486 | ||
487 | have_assert = 0; | |
488 | for (i = 0; i < n_target_char; i++) { | |
489 | name = var_target_char[i]; | |
490 | if (var_target_range[name] != "") { | |
491 | have_assert = 1; | |
2c5d2e39 | 492 | print " gcc_assert (IN_RANGE (opts->x_" name ", " var_target_range[name] "));"; |
46f8e3b0 | 493 | } |
494 | } | |
495 | ||
496 | if (have_assert) | |
497 | print ""; | |
498 | ||
499 | print " if (targetm.target_option.save)"; | |
500 | print " targetm.target_option.save (ptr);"; | |
501 | print ""; | |
502 | ||
503 | for (i = 0; i < n_target_other; i++) { | |
2c5d2e39 | 504 | print " ptr->x_" var_target_other[i] " = opts->x_" var_target_other[i] ";"; |
46f8e3b0 | 505 | } |
506 | ||
507 | for (i = 0; i < n_target_int; i++) { | |
2c5d2e39 | 508 | print " ptr->x_" var_target_int[i] " = opts->x_" var_target_int[i] ";"; |
46f8e3b0 | 509 | } |
510 | ||
511 | for (i = 0; i < n_target_short; i++) { | |
2c5d2e39 | 512 | print " ptr->x_" var_target_short[i] " = opts->x_" var_target_short[i] ";"; |
46f8e3b0 | 513 | } |
514 | ||
515 | for (i = 0; i < n_target_char; i++) { | |
2c5d2e39 | 516 | print " ptr->x_" var_target_char[i] " = opts->x_" var_target_char[i] ";"; |
46f8e3b0 | 517 | } |
518 | ||
519 | print "}"; | |
520 | ||
521 | print ""; | |
522 | print "/* Restore selected current options from a structure. */"; | |
523 | print "void"; | |
2c5d2e39 | 524 | print "cl_target_option_restore (struct gcc_options *opts, struct cl_target_option *ptr)"; |
46f8e3b0 | 525 | print "{"; |
526 | ||
527 | for (i = 0; i < n_target_other; i++) { | |
2c5d2e39 | 528 | print " opts->x_" var_target_other[i] " = ptr->x_" var_target_other[i] ";"; |
46f8e3b0 | 529 | } |
530 | ||
531 | for (i = 0; i < n_target_int; i++) { | |
2c5d2e39 | 532 | print " opts->x_" var_target_int[i] " = ptr->x_" var_target_int[i] ";"; |
46f8e3b0 | 533 | } |
534 | ||
535 | for (i = 0; i < n_target_short; i++) { | |
2c5d2e39 | 536 | print " opts->x_" var_target_short[i] " = ptr->x_" var_target_short[i] ";"; |
46f8e3b0 | 537 | } |
538 | ||
539 | for (i = 0; i < n_target_char; i++) { | |
2c5d2e39 | 540 | print " opts->x_" var_target_char[i] " = ptr->x_" var_target_char[i] ";"; |
46f8e3b0 | 541 | } |
542 | ||
543 | # This must occur after the normal variables in case the code depends on those | |
544 | # variables. | |
545 | print ""; | |
546 | print " if (targetm.target_option.restore)"; | |
547 | print " targetm.target_option.restore (ptr);"; | |
548 | ||
549 | print "}"; | |
550 | ||
551 | print ""; | |
552 | print "/* Print optimization options from a structure. */"; | |
553 | print "void"; | |
554 | print "cl_target_option_print (FILE *file,"; | |
555 | print " int indent,"; | |
556 | print " struct cl_target_option *ptr)"; | |
557 | print "{"; | |
558 | ||
559 | print " fputs (\"\\n\", file);"; | |
560 | for (i = 0; i < n_target_other; i++) { | |
5ae82d58 | 561 | print " if (ptr->x_" var_target_other[i] ")"; |
95dcf70a | 562 | print " fprintf (file, \"%*s%s (%#lx)\\n\","; |
46f8e3b0 | 563 | print " indent, \"\","; |
564 | print " \"" var_target_other[i] "\","; | |
5ae82d58 | 565 | print " (unsigned long)ptr->x_" var_target_other[i] ");"; |
46f8e3b0 | 566 | print ""; |
567 | } | |
568 | ||
569 | for (i = 0; i < n_target_int; i++) { | |
5ae82d58 | 570 | print " if (ptr->x_" var_target_int[i] ")"; |
95dcf70a | 571 | print " fprintf (file, \"%*s%s (%#x)\\n\","; |
46f8e3b0 | 572 | print " indent, \"\","; |
573 | print " \"" var_target_int[i] "\","; | |
5ae82d58 | 574 | print " ptr->x_" var_target_int[i] ");"; |
46f8e3b0 | 575 | print ""; |
576 | } | |
577 | ||
578 | for (i = 0; i < n_target_short; i++) { | |
5ae82d58 | 579 | print " if (ptr->x_" var_target_short[i] ")"; |
95dcf70a | 580 | print " fprintf (file, \"%*s%s (%#x)\\n\","; |
46f8e3b0 | 581 | print " indent, \"\","; |
582 | print " \"" var_target_short[i] "\","; | |
5ae82d58 | 583 | print " ptr->x_" var_target_short[i] ");"; |
46f8e3b0 | 584 | print ""; |
585 | } | |
586 | ||
587 | for (i = 0; i < n_target_char; i++) { | |
5ae82d58 | 588 | print " if (ptr->x_" var_target_char[i] ")"; |
95dcf70a | 589 | print " fprintf (file, \"%*s%s (%#x)\\n\","; |
46f8e3b0 | 590 | print " indent, \"\","; |
591 | print " \"" var_target_char[i] "\","; | |
5ae82d58 | 592 | print " ptr->x_" var_target_char[i] ");"; |
46f8e3b0 | 593 | print ""; |
594 | } | |
595 | ||
596 | print ""; | |
597 | print " if (targetm.target_option.print)"; | |
598 | print " targetm.target_option.print (file, indent, ptr);"; | |
599 | ||
600 | print "}"; | |
601 | print "#endif"; | |
602 | ||
e8b212b8 | 603 | } |