1 # Copyright (C) 2003-2016 Free Software Foundation, Inc.
2 # Contributed by Kelley Cook, June 2004.
3 # Original code from Neil Booth, May 2003.
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
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.
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/>.
19 # This Awk script reads in the option records generated from
20 # opt-gather.awk, combines the flags of duplicate options and generates a
24 # This program uses functions from opt-functions.awk and code from
27 # Usage: awk -f opt-functions.awk -f opt-read.awk -f optc-save-gen.awk \
28 # [-v header_name=header.h] < inputfile > options-save.c
30 # Dump that array of options into a C file.
32 print "/* This file is auto-generated by optc-save-gen.awk. */"
34 n_headers =
split(header_name
, headers
, " ")
35 for (i =
1; i
<= n_headers
; i
++)
36 print "#include " quote headers
[i
] quote
37 print "#include " quote
"opts.h" quote
38 print "#include " quote
"intl.h" quote
40 print "#include " quote
"flags.h" quote
41 print "#include " quote
"target.h" quote
42 print "#include " quote
"inchash.h" quote
43 print "#include " quote
"hash-set.h" quote
44 print "#include " quote
"machmode.h" quote
45 print "#include " quote
"vec.h" quote
46 print "#include " quote
"double-int.h" quote
47 print "#include " quote
"input.h" quote
48 print "#include " quote
"alias.h" quote
49 print "#include " quote
"symtab.h" quote
50 print "#include " quote
"wide-int.h" quote
51 print "#include " quote
"inchash.h" quote
52 print "#include " quote
"tree.h" quote
53 print "#include " quote
"fold-const.h" quote
54 print "#include " quote
"tree-ssa-alias.h" quote
55 print "#include " quote
"is-a.h" quote
56 print "#include " quote
"predict.h" quote
57 print "#include " quote
"function.h" quote
58 print "#include " quote
"basic-block.h" quote
59 print "#include " quote
"gimple-expr.h" quote
60 print "#include " quote
"gimple.h" quote
61 print "#include " quote
"data-streamer.h" quote
62 print "#include " quote
"ipa-ref.h" quote
63 print "#include " quote
"cgraph.h" quote
66 if (n_extra_c_includes
> 0) {
67 for (i =
0; i
< n_extra_c_includes
; i
++) {
68 print "#include " quote extra_c_includes
[i
] quote
74 if (n_extra_target_vars
)
77 for (i =
0; i
< n_opts
; i
++) {
78 if (flag_set_p
("Save", flags
[i
]))
82 print "/* Save optimization variables into a structure. */"
84 print "cl_optimization_save (struct cl_optimization *ptr, struct gcc_options *opts)";
92 var_opt_char
[0] =
"optimize";
93 var_opt_char
[1] =
"optimize_size";
94 var_opt_char
[2] =
"optimize_debug";
95 var_opt_range
["optimize"] =
"0, 255";
96 var_opt_range
["optimize_size"] =
"0, 1";
97 var_opt_range
["optimize_debug"] =
"0, 1";
99 # Sort by size to mimic how the structure is laid out to be friendlier to the
102 for (i =
0; i
< n_opts
; i
++) {
103 if (flag_set_p
("Optimization", flags
[i
])) {
104 name = var_name
(flags
[i
])
108 if(name in var_opt_seen
)
111 var_opt_seen
[name
]++;
112 otype = var_type_struct
(flags
[i
]);
113 if (otype ~
"^((un)?signed +)?int *$")
114 var_opt_int
[n_opt_int
++] = name
;
116 else if (otype ~
"^((un)?signed +)?short *$")
117 var_opt_short
[n_opt_short
++] = name
;
119 else if (otype ~
("^enum +[_" alnum
"]+ *"))
120 var_opt_enum
[n_opt_enum
++] = name
;
122 else if (otype ~
"^((un)?signed +)?char *$") {
123 var_opt_char
[n_opt_char
++] = name
;
124 if (otype ~
"^unsigned +char *$")
125 var_opt_range
[name
] =
"0, 255"
126 else if (otype ~
"^signed +char *$")
127 var_opt_range
[name
] =
"-128, 127"
130 var_opt_other
[n_opt_other
++] = name
;
134 for (i =
0; i
< n_opt_char
; i
++) {
135 name = var_opt_char
[i
];
136 if (var_opt_range
[name
] != "")
137 print " gcc_assert (IN_RANGE (opts->x_" name
", " var_opt_range
[name
] "));";
141 for (i =
0; i
< n_opt_other
; i
++) {
142 print " ptr->x_" var_opt_other
[i
] " = opts->x_" var_opt_other
[i
] ";";
145 for (i =
0; i
< n_opt_int
; i
++) {
146 print " ptr->x_" var_opt_int
[i
] " = opts->x_" var_opt_int
[i
] ";";
149 for (i =
0; i
< n_opt_enum
; i
++) {
150 print " ptr->x_" var_opt_enum
[i
] " = opts->x_" var_opt_enum
[i
] ";";
153 for (i =
0; i
< n_opt_short
; i
++) {
154 print " ptr->x_" var_opt_short
[i
] " = opts->x_" var_opt_short
[i
] ";";
157 for (i =
0; i
< n_opt_char
; i
++) {
158 print " ptr->x_" var_opt_char
[i
] " = opts->x_" var_opt_char
[i
] ";";
164 print "/* Restore optimization options from a structure. */";
166 print "cl_optimization_restore (struct gcc_options *opts, struct cl_optimization *ptr)";
169 for (i =
0; i
< n_opt_other
; i
++) {
170 print " opts->x_" var_opt_other
[i
] " = ptr->x_" var_opt_other
[i
] ";";
173 for (i =
0; i
< n_opt_int
; i
++) {
174 print " opts->x_" var_opt_int
[i
] " = ptr->x_" var_opt_int
[i
] ";";
177 for (i =
0; i
< n_opt_enum
; i
++) {
178 print " opts->x_" var_opt_enum
[i
] " = ptr->x_" var_opt_enum
[i
] ";";
181 for (i =
0; i
< n_opt_short
; i
++) {
182 print " opts->x_" var_opt_short
[i
] " = ptr->x_" var_opt_short
[i
] ";";
185 for (i =
0; i
< n_opt_char
; i
++) {
186 print " opts->x_" var_opt_char
[i
] " = ptr->x_" var_opt_char
[i
] ";";
189 print " targetm.override_options_after_change ();";
193 print "/* Print optimization options from a structure. */";
195 print "cl_optimization_print (FILE *file,";
196 print " int indent_to,";
197 print " struct cl_optimization *ptr)";
200 print " fputs (\"\\n\", file);";
201 for (i =
0; i
< n_opt_other
; i
++) {
202 print " if (ptr->x_" var_opt_other
[i
] ")";
203 print " fprintf (file, \"%*s%s (%#lx)\\n\",";
204 print " indent_to, \"\",";
205 print " \"" var_opt_other
[i
] "\",";
206 print " (unsigned long)ptr->x_" var_opt_other
[i
] ");";
210 for (i =
0; i
< n_opt_int
; i
++) {
211 print " if (ptr->x_" var_opt_int
[i
] ")";
212 print " fprintf (file, \"%*s%s (%#x)\\n\",";
213 print " indent_to, \"\",";
214 print " \"" var_opt_int
[i
] "\",";
215 print " ptr->x_" var_opt_int
[i
] ");";
219 for (i =
0; i
< n_opt_enum
; i
++) {
220 print " fprintf (file, \"%*s%s (%#x)\\n\",";
221 print " indent_to, \"\",";
222 print " \"" var_opt_enum
[i
] "\",";
223 print " (int) ptr->x_" var_opt_enum
[i
] ");";
227 for (i =
0; i
< n_opt_short
; i
++) {
228 print " if (ptr->x_" var_opt_short
[i
] ")";
229 print " fprintf (file, \"%*s%s (%#x)\\n\",";
230 print " indent_to, \"\",";
231 print " \"" var_opt_short
[i
] "\",";
232 print " ptr->x_" var_opt_short
[i
] ");";
236 for (i =
0; i
< n_opt_char
; i
++) {
237 print " if (ptr->x_" var_opt_char
[i
] ")";
238 print " fprintf (file, \"%*s%s (%#x)\\n\",";
239 print " indent_to, \"\",";
240 print " \"" var_opt_char
[i
] "\",";
241 print " ptr->x_" var_opt_char
[i
] ");";
248 print "/* Print different optimization variables from structures provided as arguments. */";
250 print "cl_optimization_print_diff (FILE *file,";
251 print " int indent_to,";
252 print " struct cl_optimization *ptr1,";
253 print " struct cl_optimization *ptr2)";
256 print " fputs (\"\\n\", file);";
257 for (i =
0; i
< n_opt_other
; i
++) {
258 print " if (ptr1->x_" var_opt_other
[i
] " != ptr2->x_" var_opt_other
[i
] ")";
259 print " fprintf (file, \"%*s%s (%#lx/%#lx)\\n\",";
260 print " indent_to, \"\",";
261 print " \"" var_opt_other
[i
] "\",";
262 print " (unsigned long)ptr1->x_" var_opt_other
[i
] ",";
263 print " (unsigned long)ptr2->x_" var_opt_other
[i
] ");";
267 for (i =
0; i
< n_opt_int
; i
++) {
268 print " if (ptr1->x_" var_opt_int
[i
] " != ptr2->x_" var_opt_int
[i
] ")";
269 print " fprintf (file, \"%*s%s (%#x/%#x)\\n\",";
270 print " indent_to, \"\",";
271 print " \"" var_opt_int
[i
] "\",";
272 print " ptr1->x_" var_opt_int
[i
] ",";
273 print " ptr2->x_" var_opt_int
[i
] ");";
277 for (i =
0; i
< n_opt_enum
; i
++) {
278 print " if (ptr1->x_" var_opt_enum
[i
] " != ptr2->x_" var_opt_enum
[i
] ")";
279 print " fprintf (file, \"%*s%s (%#x/%#x)\\n\",";
280 print " indent_to, \"\",";
281 print " \"" var_opt_enum
[i
] "\",";
282 print " (int) ptr1->x_" var_opt_enum
[i
] ",";
283 print " (int) ptr2->x_" var_opt_enum
[i
] ");";
287 for (i =
0; i
< n_opt_short
; i
++) {
288 print " if (ptr1->x_" var_opt_short
[i
] " != ptr2->x_" var_opt_short
[i
] ")";
289 print " fprintf (file, \"%*s%s (%#x/%#x)\\n\",";
290 print " indent_to, \"\",";
291 print " \"" var_opt_short
[i
] "\",";
292 print " ptr1->x_" var_opt_short
[i
] ",";
293 print " ptr2->x_" var_opt_short
[i
] ");";
297 for (i =
0; i
< n_opt_char
; i
++) {
298 print " if (ptr1->x_" var_opt_char
[i
] " != ptr2->x_" var_opt_char
[i
] ")";
299 print " fprintf (file, \"%*s%s (%#x/%#x)\\n\",";
300 print " indent_to, \"\",";
301 print " \"" var_opt_char
[i
] "\",";
302 print " ptr1->x_" var_opt_char
[i
] ",";
303 print " ptr2->x_" var_opt_char
[i
] ");";
311 print "/* Save selected option variables into a structure. */"
313 print "cl_target_option_save (struct cl_target_option *ptr, struct gcc_options *opts)";
323 for (i =
0; i
< n_opts
; i
++) {
324 if (flag_set_p
("Save", flags
[i
])) {
325 name = var_name
(flags
[i
])
327 name =
"target_flags";
329 if(name in var_save_seen
)
332 var_save_seen
[name
]++;
333 otype = var_type_struct
(flags
[i
])
334 if (otype ~
"^((un)?signed +)?int *$")
335 var_target_int
[n_target_int
++] = name
;
337 else if (otype ~
"^((un)?signed +)?short *$")
338 var_target_short
[n_target_short
++] = name
;
340 else if (otype ~
("^enum +[_" alnum
"]+ *$"))
341 var_target_enum
[n_target_enum
++] = name
;
343 else if (otype ~
"^((un)?signed +)?char *$") {
344 var_target_char
[n_target_char
++] = name
;
345 if (otype ~
"^unsigned +char *$")
346 var_target_range
[name
] =
"0, 255"
347 else if (otype ~
"^signed +char *$")
348 var_target_range
[name
] =
"-128, 127"
349 if (otype == var_type
(flags
[i
]))
350 var_target_range
[name
] =
""
353 var_target_other
[n_target_other
++] = name
;
357 var_target_int
[n_target_int
++] =
"target_flags";
361 for (i =
0; i
< n_target_char
; i
++) {
362 name = var_target_char
[i
];
363 if (var_target_range
[name
] != "") {
365 print " gcc_assert (IN_RANGE (opts->x_" name
", " var_target_range
[name
] "));";
372 print " if (targetm.target_option.save)";
373 print " targetm.target_option.save (ptr, opts);";
376 for (i =
0; i
< n_extra_target_vars
; i
++) {
377 print " ptr->x_" extra_target_vars
[i
] " = opts->x_" extra_target_vars
[i
] ";";
380 for (i =
0; i
< n_target_other
; i
++) {
381 print " ptr->x_" var_target_other
[i
] " = opts->x_" var_target_other
[i
] ";";
384 for (i =
0; i
< n_target_enum
; i
++) {
385 print " ptr->x_" var_target_enum
[i
] " = opts->x_" var_target_enum
[i
] ";";
388 for (i =
0; i
< n_target_int
; i
++) {
389 print " ptr->x_" var_target_int
[i
] " = opts->x_" var_target_int
[i
] ";";
392 for (i =
0; i
< n_target_short
; i
++) {
393 print " ptr->x_" var_target_short
[i
] " = opts->x_" var_target_short
[i
] ";";
396 for (i =
0; i
< n_target_char
; i
++) {
397 print " ptr->x_" var_target_char
[i
] " = opts->x_" var_target_char
[i
] ";";
403 print "/* Restore selected current options from a structure. */";
405 print "cl_target_option_restore (struct gcc_options *opts, struct cl_target_option *ptr)";
408 for (i =
0; i
< n_extra_target_vars
; i
++) {
409 print " opts->x_" extra_target_vars
[i
] " = ptr->x_" extra_target_vars
[i
] ";";
412 for (i =
0; i
< n_target_other
; i
++) {
413 print " opts->x_" var_target_other
[i
] " = ptr->x_" var_target_other
[i
] ";";
416 for (i =
0; i
< n_target_enum
; i
++) {
417 print " opts->x_" var_target_enum
[i
] " = ptr->x_" var_target_enum
[i
] ";";
420 for (i =
0; i
< n_target_int
; i
++) {
421 print " opts->x_" var_target_int
[i
] " = ptr->x_" var_target_int
[i
] ";";
424 for (i =
0; i
< n_target_short
; i
++) {
425 print " opts->x_" var_target_short
[i
] " = ptr->x_" var_target_short
[i
] ";";
428 for (i =
0; i
< n_target_char
; i
++) {
429 print " opts->x_" var_target_char
[i
] " = ptr->x_" var_target_char
[i
] ";";
432 # This must occur after the normal variables in case the code depends on those
435 print " if (targetm.target_option.restore)";
436 print " targetm.target_option.restore (opts, ptr);";
441 print "/* Print optimization options from a structure. */";
443 print "cl_target_option_print (FILE *file,";
444 print " int indent,";
445 print " struct cl_target_option *ptr)";
448 print " fputs (\"\\n\", file);";
449 for (i =
0; i
< n_target_other
; i
++) {
450 print " if (ptr->x_" var_target_other
[i
] ")";
451 if (host_wide_int
[var_target_other
[i
]] ==
"yes")
452 print " fprintf (file, \"%*s%s (%#\" HOST_WIDE_INT_PRINT \"x)\\n\",";
454 print " fprintf (file, \"%*s%s (%#x)\\n\",";
455 print " indent, \"\",";
456 print " \"" var_target_other
[i
] "\",";
457 if (host_wide_int
[var_target_other
[i
]] ==
"yes")
458 print " ptr->x_" var_target_other
[i
] ");";
460 print " (unsigned long)ptr->x_" var_target_other
[i
] ");";
464 for (i =
0; i
< n_target_enum
; i
++) {
465 print " if (ptr->x_" var_target_enum
[i
] ")";
466 print " fprintf (file, \"%*s%s (%#x)\\n\",";
467 print " indent, \"\",";
468 print " \"" var_target_enum
[i
] "\",";
469 print " ptr->x_" var_target_enum
[i
] ");";
473 for (i =
0; i
< n_target_int
; i
++) {
474 print " if (ptr->x_" var_target_int
[i
] ")";
475 print " fprintf (file, \"%*s%s (%#x)\\n\",";
476 print " indent, \"\",";
477 print " \"" var_target_int
[i
] "\",";
478 print " ptr->x_" var_target_int
[i
] ");";
482 for (i =
0; i
< n_target_short
; i
++) {
483 print " if (ptr->x_" var_target_short
[i
] ")";
484 print " fprintf (file, \"%*s%s (%#x)\\n\",";
485 print " indent, \"\",";
486 print " \"" var_target_short
[i
] "\",";
487 print " ptr->x_" var_target_short
[i
] ");";
491 for (i =
0; i
< n_target_char
; i
++) {
492 print " if (ptr->x_" var_target_char
[i
] ")";
493 print " fprintf (file, \"%*s%s (%#x)\\n\",";
494 print " indent, \"\",";
495 print " \"" var_target_char
[i
] "\",";
496 print " ptr->x_" var_target_char
[i
] ");";
501 print " if (targetm.target_option.print)";
502 print " targetm.target_option.print (file, indent, ptr);";
506 print "/* Print different target option variables from structures provided as arguments. */";
508 print "cl_target_option_print_diff (FILE *file,";
509 print " int indent ATTRIBUTE_UNUSED,";
510 print " struct cl_target_option *ptr1 ATTRIBUTE_UNUSED,";
511 print " struct cl_target_option *ptr2 ATTRIBUTE_UNUSED)";
514 print " fputs (\"\\n\", file);";
515 for (i =
0; i
< n_target_other
; i
++) {
516 print " if (ptr1->x_" var_target_other
[i
] " != ptr2->x_" var_target_other
[i
] ")";
517 if (host_wide_int
[var_target_other
[i
]] ==
"yes")
518 print " fprintf (file, \"%*s%s (%#\" HOST_WIDE_INT_PRINT \"x/%#\" HOST_WIDE_INT_PRINT \"x)\\n\",";
520 print " fprintf (file, \"%*s%s (%#x/%#x)\\n\",";
521 print " indent, \"\",";
522 print " \"" var_target_other
[i
] "\",";
523 if (host_wide_int
[var_target_other
[i
]] ==
"yes") {
524 print " ptr1->x_" var_target_other
[i
] ",";
525 print " ptr2->x_" var_target_other
[i
] ");";
528 print " (unsigned long)ptr1->x_" var_target_other
[i
] ",";
529 print " (unsigned long)ptr2->x_" var_target_other
[i
] ");";
534 for (i =
0; i
< n_target_enum
; i
++) {
535 print " if (ptr1->x_" var_target_enum
[i
] " != ptr2->x_" var_target_enum
[i
] ")";
536 print " fprintf (file, \"%*s%s (%#x/%#x)\\n\",";
537 print " indent, \"\",";
538 print " \"" var_target_enum
[i
] "\",";
539 print " ptr1->x_" var_target_enum
[i
] ",";
540 print " ptr2->x_" var_target_enum
[i
] ");";
544 for (i =
0; i
< n_target_int
; i
++) {
545 print " if (ptr1->x_" var_target_int
[i
] " != ptr2->x_" var_target_int
[i
] ")";
546 print " fprintf (file, \"%*s%s (%#x/%#x)\\n\",";
547 print " indent, \"\",";
548 print " \"" var_target_int
[i
] "\",";
549 print " ptr1->x_" var_target_int
[i
] ",";
550 print " ptr2->x_" var_target_int
[i
] ");";
554 for (i =
0; i
< n_target_short
; i
++) {
555 print " if (ptr1->x_" var_target_short
[i
] " != ptr2->x_" var_target_short
[i
] ")";
556 print " fprintf (file, \"%*s%s (%#x/%#x)\\n\",";
557 print " indent, \"\",";
558 print " \"" var_target_short
[i
] "\",";
559 print " ptr1->x_" var_target_short
[i
] ",";
560 print " ptr2->x_" var_target_short
[i
] ");";
564 for (i =
0; i
< n_target_char
; i
++) {
565 print " if (ptr1->x_" var_target_char
[i
] " != ptr2->x_" var_target_char
[i
] ")";
566 print " fprintf (file, \"%*s%s (%#x/%#x)\\n\",";
567 print " indent, \"\",";
568 print " \"" var_target_char
[i
] "\",";
569 print " ptr1->x_" var_target_char
[i
] ",";
570 print " ptr2->x_" var_target_char
[i
] ");";
577 print "/* Compare two target options */";
579 print "cl_target_option_eq (struct cl_target_option const *ptr1 ATTRIBUTE_UNUSED,";
580 print " struct cl_target_option const *ptr2 ATTRIBUTE_UNUSED)";
586 for (i =
0; i
< n_target_save
; i
++) {
587 var = target_save_decl
[i
];
588 sub (" *=.*", "", var
);
591 sub("^.*[ *]", "", name
)
592 sub(" *" name
"$", "", type
)
593 if (target_save_decl
[i
] ~
"^const char \\*+[_" alnum
"]+$")
594 var_target_str
[n_target_str
++] = name
;
596 if (target_save_decl
[i
] ~
" .*\\[.+\\]+$") {
598 sub("[^\\[]+\\[", "", size
);
599 sub("\\]$", "", size
);
600 sub("\\[.+", "", name
)
601 sub(" [^ ]+$", "", type
)
602 var_target_array
[n_target_array
] = name
603 var_target_array_type
[n_target_array
] = type
604 var_target_array_size
[n_target_array
++] = size
607 var_target_val_type
[n_target_val
] = type
;
608 var_target_val
[n_target_val
++] = name
;
613 for (i =
0; i
< n_opts
; i
++) {
614 if (flag_set_p
("Save", flags
[i
])) {
615 name = var_name
(flags
[i
])
617 name =
"target_flags";
619 if(name in var_list_seen
)
622 var_list_seen
[name
]++;
623 otype = var_type_struct
(flags
[i
])
624 if (otype ~
"^const char \\**$")
625 var_target_str
[n_target_str
++] =
"x_" name
;
627 var_target_val_type
[n_target_val
] = otype
;
628 var_target_val
[n_target_val
++] =
"x_" name
;
633 var_target_val_type
[n_target_val
] =
"int";
634 var_target_val
[n_target_val
++] =
"x_target_flags";
637 for (i =
0; i
< n_target_str
; i
++) {
638 name = var_target_str
[i
]
639 print " if (ptr1->" name
" != ptr2->" name
;
640 print " && (!ptr1->" name
" || !ptr2->" name
641 print " || strcmp (ptr1->" name
", ptr2->" name
")))";
642 print " return false;";
644 for (i =
0; i
< n_target_array
; i
++) {
645 name = var_target_array
[i
]
646 size = var_target_array_size
[i
]
647 type = var_target_array_type
[i
]
648 print " if (ptr1->" name
" != ptr2->" name
"";
649 print " || memcmp (ptr1->" name
", ptr2->" name
", " size
" * sizeof(" type
")))"
650 print " return false;";
652 for (i =
0; i
< n_target_val
; i
++) {
653 name = var_target_val
[i
]
654 print " if (ptr1->" name
" != ptr2->" name
")";
655 print " return false;";
658 print " return true;";
663 print "/* Hash target options */";
665 print "cl_target_option_hash (struct cl_target_option const *ptr ATTRIBUTE_UNUSED)";
667 print " inchash::hash hstate;";
668 for (i =
0; i
< n_target_str
; i
++) {
669 name = var_target_str
[i
]
670 print " if (ptr->" name
")";
671 print " hstate.add (ptr->" name
", strlen (ptr->" name
"));";
673 print " hstate.add_int (0);";
675 for (i =
0; i
< n_target_array
; i
++) {
676 name= var_target_array
[i
]
677 size = var_target_array_size
[i
]
678 type = var_target_array_type
[i
]
679 print " hstate.add_int (" size
");";
680 print " hstate.add (ptr->" name
", sizeof (" type
") * " size
");";
682 for (i =
0; i
< n_target_val
; i
++) {
683 name = var_target_val
[i
]
684 print " hstate.add_wide_int (ptr->" name
");";
686 print " return hstate.end ();";
690 print "/* Stream out target options */";
692 print "cl_target_option_stream_out (struct output_block *ob ATTRIBUTE_UNUSED,";
693 print " struct bitpack_d *bp ATTRIBUTE_UNUSED,";
694 print " struct cl_target_option *ptr ATTRIBUTE_UNUSED)";
696 for (i =
0; i
< n_target_str
; i
++) {
697 name = var_target_str
[i
]
698 print " bp_pack_string (ob, bp, ptr->" name
", true);";
700 for (i =
0; i
< n_target_array
; i
++) {
701 name = var_target_array
[i
]
702 size = var_target_array_size
[i
]
703 print " for (unsigned i = 0; i < " size
"; i++)"
704 print " bp_pack_value (bp, ptr->" name
"[i], 64);";
706 for (i =
0; i
< n_target_val
; i
++) {
707 name = var_target_val
[i
]
708 print " bp_pack_value (bp, ptr->" name
", 64);";
713 print "/* Stream in target options */";
715 print "cl_target_option_stream_in (struct data_in *data_in ATTRIBUTE_UNUSED,";
716 print " struct bitpack_d *bp ATTRIBUTE_UNUSED,";
717 print " struct cl_target_option *ptr ATTRIBUTE_UNUSED)";
719 for (i =
0; i
< n_target_str
; i
++) {
720 name = var_target_str
[i
]
721 print " ptr->" name
" = bp_unpack_string (data_in, bp);";
722 print " if (ptr->" name
")";
723 print " ptr->" name
" = xstrdup (ptr->" name
");";
725 for (i =
0; i
< n_target_array
; i
++) {
726 name = var_target_array
[i
]
727 size = var_target_array_size
[i
]
728 print " for (int i = " size
" - 1; i >= 0; i--)"
729 print " ptr->" name
"[i] = (" var_target_array_type
[i
] ") bp_unpack_value (bp, 64);";
731 for (i =
0; i
< n_target_val
; i
++) {
732 name = var_target_val
[i
]
733 print " ptr->" name
" = (" var_target_val_type
[i
] ") bp_unpack_value (bp, 64);";
739 var_opt_val
[0] =
"x_optimize"
740 var_opt_val_type
[0] =
"char "
741 var_opt_val
[1] =
"x_optimize_size"
742 var_opt_val
[2] =
"x_optimize_debug"
743 var_opt_val_type
[1] =
"char "
744 var_opt_val_type
[2] =
"char "
745 for (i =
0; i
< n_opts
; i
++) {
746 if (flag_set_p
("Optimization", flags
[i
])) {
747 name = var_name
(flags
[i
])
751 if(name in var_opt_list_seen
)
754 var_opt_list_seen
[name
]++;
756 otype = var_type_struct
(flags
[i
])
757 var_opt_val_type
[n_opt_val
] = otype
;
758 var_opt_val
[n_opt_val
++] =
"x_" name
;
762 print "/* Hash optimization options */";
764 print "cl_optimization_hash (struct cl_optimization const *ptr ATTRIBUTE_UNUSED)";
766 print " inchash::hash hstate;";
767 for (i =
0; i
< n_opt_val
; i
++) {
768 name = var_opt_val
[i
]
769 print " hstate.add_wide_int (ptr->" name
");";
771 print " return hstate.end ();";
775 print "/* Stream out optimization options */";
777 print "cl_optimization_stream_out (struct bitpack_d *bp,";
778 print " struct cl_optimization *ptr)";
780 for (i =
0; i
< n_opt_val
; i
++) {
781 name = var_opt_val
[i
]
782 print " bp_pack_value (bp, ptr->" name
", 64);";
787 print "/* Stream in optimization options */";
789 print "cl_optimization_stream_in (struct bitpack_d *bp,";
790 print " struct cl_optimization *ptr)";
792 for (i =
0; i
< n_opt_val
; i
++) {
793 name = var_opt_val
[i
]
794 print " ptr->" name
" = (" var_opt_val_type
[i
] ") bp_unpack_value (bp, 64);";