]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/lto/lto-lang.c
* lto-lang.c (lto_attribute_table): Handle *tm regparm.
[thirdparty/gcc.git] / gcc / lto / lto-lang.c
1 /* Language-dependent hooks for LTO.
2 Copyright 2009, 2010 Free Software Foundation, Inc.
3 Contributed by CodeSourcery, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
20
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "flags.h"
25 #include "tm.h"
26 #include "tree.h"
27 #include "target.h"
28 #include "langhooks.h"
29 #include "langhooks-def.h"
30 #include "debug.h"
31 #include "lto-tree.h"
32 #include "lto.h"
33 #include "tree-inline.h"
34 #include "gimple.h"
35 #include "diagnostic-core.h"
36 #include "toplev.h"
37 #include "lto-streamer.h"
38
39 static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
40 static tree handle_leaf_attribute (tree *, tree, tree, int, bool *);
41 static tree handle_const_attribute (tree *, tree, tree, int, bool *);
42 static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
43 static tree handle_pure_attribute (tree *, tree, tree, int, bool *);
44 static tree handle_novops_attribute (tree *, tree, tree, int, bool *);
45 static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
46 static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *);
47 static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
48 static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
49 static tree handle_transaction_pure_attribute (tree *, tree, tree, int, bool *);
50 static tree ignore_attribute (tree *, tree, tree, int, bool *);
51
52 static tree handle_format_attribute (tree *, tree, tree, int, bool *);
53 static tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
54
55 /* Table of machine-independent attributes supported in GIMPLE. */
56 const struct attribute_spec lto_attribute_table[] =
57 {
58 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
59 do_diagnostic } */
60 { "noreturn", 0, 0, true, false, false,
61 handle_noreturn_attribute, false },
62 { "leaf", 0, 0, true, false, false,
63 handle_leaf_attribute, false },
64 /* The same comments as for noreturn attributes apply to const ones. */
65 { "const", 0, 0, true, false, false,
66 handle_const_attribute, false },
67 { "malloc", 0, 0, true, false, false,
68 handle_malloc_attribute, false },
69 { "pure", 0, 0, true, false, false,
70 handle_pure_attribute, false },
71 { "no vops", 0, 0, true, false, false,
72 handle_novops_attribute, false },
73 { "nonnull", 0, -1, false, true, true,
74 handle_nonnull_attribute, false },
75 { "nothrow", 0, 0, true, false, false,
76 handle_nothrow_attribute, false },
77 { "sentinel", 0, 1, false, true, true,
78 handle_sentinel_attribute, false },
79 { "type generic", 0, 0, false, true, true,
80 handle_type_generic_attribute, false },
81 { "transaction_pure", 0, 0, false, true, true,
82 handle_transaction_pure_attribute, false },
83 /* For internal use only. The leading '*' both prevents its usage in
84 source code and signals that it may be overridden by machine tables. */
85 { "*tm regparm", 0, 0, false, true, true,
86 ignore_attribute, false },
87 { NULL, 0, 0, false, false, false, NULL, false }
88 };
89
90 /* Give the specifications for the format attributes, used by C and all
91 descendants. */
92
93 const struct attribute_spec lto_format_attribute_table[] =
94 {
95 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
96 affects_type_identity } */
97 { "format", 3, 3, false, true, true,
98 handle_format_attribute, false },
99 { "format_arg", 1, 1, false, true, true,
100 handle_format_arg_attribute, false },
101 { NULL, 0, 0, false, false, false, NULL, false }
102 };
103
104 enum built_in_attribute
105 {
106 #define DEF_ATTR_NULL_TREE(ENUM) ENUM,
107 #define DEF_ATTR_INT(ENUM, VALUE) ENUM,
108 #define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
109 #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
110 #include "builtin-attrs.def"
111 #undef DEF_ATTR_NULL_TREE
112 #undef DEF_ATTR_INT
113 #undef DEF_ATTR_IDENT
114 #undef DEF_ATTR_TREE_LIST
115 ATTR_LAST
116 };
117
118 static GTY(()) tree built_in_attributes[(int) ATTR_LAST];
119
120 /* Builtin types. */
121
122 enum lto_builtin_type
123 {
124 #define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME,
125 #define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME,
126 #define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME,
127 #define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME,
128 #define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
129 #define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
130 #define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME,
131 #define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) NAME,
132 #define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) NAME,
133 #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
134 #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
135 #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
136 #define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
137 #define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
138 #define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG6) \
139 NAME,
140 #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
141 #include "builtin-types.def"
142 #undef DEF_PRIMITIVE_TYPE
143 #undef DEF_FUNCTION_TYPE_0
144 #undef DEF_FUNCTION_TYPE_1
145 #undef DEF_FUNCTION_TYPE_2
146 #undef DEF_FUNCTION_TYPE_3
147 #undef DEF_FUNCTION_TYPE_4
148 #undef DEF_FUNCTION_TYPE_5
149 #undef DEF_FUNCTION_TYPE_6
150 #undef DEF_FUNCTION_TYPE_7
151 #undef DEF_FUNCTION_TYPE_VAR_0
152 #undef DEF_FUNCTION_TYPE_VAR_1
153 #undef DEF_FUNCTION_TYPE_VAR_2
154 #undef DEF_FUNCTION_TYPE_VAR_3
155 #undef DEF_FUNCTION_TYPE_VAR_4
156 #undef DEF_FUNCTION_TYPE_VAR_5
157 #undef DEF_POINTER_TYPE
158 BT_LAST
159 };
160
161 typedef enum lto_builtin_type builtin_type;
162
163 static GTY(()) tree builtin_types[(int) BT_LAST + 1];
164
165 static GTY(()) tree string_type_node;
166 static GTY(()) tree const_string_type_node;
167 static GTY(()) tree wint_type_node;
168 static GTY(()) tree intmax_type_node;
169 static GTY(()) tree uintmax_type_node;
170 static GTY(()) tree signed_size_type_node;
171
172 /* Flags needed to process builtins.def. */
173 int flag_isoc94;
174 int flag_isoc99;
175
176 /* Attribute handlers. */
177
178 /* Handle a "noreturn" attribute; arguments as in
179 struct attribute_spec.handler. */
180
181 static tree
182 handle_noreturn_attribute (tree *node, tree ARG_UNUSED (name),
183 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
184 bool * ARG_UNUSED (no_add_attrs))
185 {
186 tree type = TREE_TYPE (*node);
187
188 if (TREE_CODE (*node) == FUNCTION_DECL)
189 TREE_THIS_VOLATILE (*node) = 1;
190 else if (TREE_CODE (type) == POINTER_TYPE
191 && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
192 TREE_TYPE (*node)
193 = build_pointer_type
194 (build_type_variant (TREE_TYPE (type),
195 TYPE_READONLY (TREE_TYPE (type)), 1));
196 else
197 gcc_unreachable ();
198
199 return NULL_TREE;
200 }
201
202 /* Handle a "leaf" attribute; arguments as in
203 struct attribute_spec.handler. */
204
205 static tree
206 handle_leaf_attribute (tree *node, tree name,
207 tree ARG_UNUSED (args),
208 int ARG_UNUSED (flags), bool *no_add_attrs)
209 {
210 if (TREE_CODE (*node) != FUNCTION_DECL)
211 {
212 warning (OPT_Wattributes, "%qE attribute ignored", name);
213 *no_add_attrs = true;
214 }
215 if (!TREE_PUBLIC (*node))
216 {
217 warning (OPT_Wattributes, "%qE attribute has no effect on unit local functions", name);
218 *no_add_attrs = true;
219 }
220
221 return NULL_TREE;
222 }
223
224 /* Handle a "const" attribute; arguments as in
225 struct attribute_spec.handler. */
226
227 static tree
228 handle_const_attribute (tree *node, tree ARG_UNUSED (name),
229 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
230 bool * ARG_UNUSED (no_add_attrs))
231 {
232 tree type = TREE_TYPE (*node);
233
234 /* See FIXME comment on noreturn in c_common_attribute_table. */
235 if (TREE_CODE (*node) == FUNCTION_DECL)
236 TREE_READONLY (*node) = 1;
237 else if (TREE_CODE (type) == POINTER_TYPE
238 && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
239 TREE_TYPE (*node)
240 = build_pointer_type
241 (build_type_variant (TREE_TYPE (type), 1,
242 TREE_THIS_VOLATILE (TREE_TYPE (type))));
243 else
244 gcc_unreachable ();
245
246 return NULL_TREE;
247 }
248
249
250 /* Handle a "malloc" attribute; arguments as in
251 struct attribute_spec.handler. */
252
253 static tree
254 handle_malloc_attribute (tree *node, tree ARG_UNUSED (name),
255 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
256 bool * ARG_UNUSED (no_add_attrs))
257 {
258 if (TREE_CODE (*node) == FUNCTION_DECL
259 && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (*node))))
260 DECL_IS_MALLOC (*node) = 1;
261 else
262 gcc_unreachable ();
263
264 return NULL_TREE;
265 }
266
267
268 /* Handle a "pure" attribute; arguments as in
269 struct attribute_spec.handler. */
270
271 static tree
272 handle_pure_attribute (tree *node, tree ARG_UNUSED (name),
273 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
274 bool * ARG_UNUSED (no_add_attrs))
275 {
276 if (TREE_CODE (*node) == FUNCTION_DECL)
277 DECL_PURE_P (*node) = 1;
278 else
279 gcc_unreachable ();
280
281 return NULL_TREE;
282 }
283
284
285 /* Handle a "no vops" attribute; arguments as in
286 struct attribute_spec.handler. */
287
288 static tree
289 handle_novops_attribute (tree *node, tree ARG_UNUSED (name),
290 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
291 bool *ARG_UNUSED (no_add_attrs))
292 {
293 gcc_assert (TREE_CODE (*node) == FUNCTION_DECL);
294 DECL_IS_NOVOPS (*node) = 1;
295 return NULL_TREE;
296 }
297
298
299 /* Helper for nonnull attribute handling; fetch the operand number
300 from the attribute argument list. */
301
302 static bool
303 get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp)
304 {
305 /* Verify the arg number is a constant. */
306 if (TREE_CODE (arg_num_expr) != INTEGER_CST
307 || TREE_INT_CST_HIGH (arg_num_expr) != 0)
308 return false;
309
310 *valp = TREE_INT_CST_LOW (arg_num_expr);
311 return true;
312 }
313
314 /* Handle the "nonnull" attribute. */
315
316 static tree
317 handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name),
318 tree args, int ARG_UNUSED (flags),
319 bool * ARG_UNUSED (no_add_attrs))
320 {
321 tree type = *node;
322
323 /* If no arguments are specified, all pointer arguments should be
324 non-null. Verify a full prototype is given so that the arguments
325 will have the correct types when we actually check them later. */
326 if (!args)
327 {
328 gcc_assert (prototype_p (type));
329 return NULL_TREE;
330 }
331
332 /* Argument list specified. Verify that each argument number references
333 a pointer argument. */
334 for (; args; args = TREE_CHAIN (args))
335 {
336 tree argument;
337 unsigned HOST_WIDE_INT arg_num = 0, ck_num;
338
339 if (!get_nonnull_operand (TREE_VALUE (args), &arg_num))
340 gcc_unreachable ();
341
342 argument = TYPE_ARG_TYPES (type);
343 if (argument)
344 {
345 for (ck_num = 1; ; ck_num++)
346 {
347 if (!argument || ck_num == arg_num)
348 break;
349 argument = TREE_CHAIN (argument);
350 }
351
352 gcc_assert (argument
353 && TREE_CODE (TREE_VALUE (argument)) == POINTER_TYPE);
354 }
355 }
356
357 return NULL_TREE;
358 }
359
360
361 /* Handle a "nothrow" attribute; arguments as in
362 struct attribute_spec.handler. */
363
364 static tree
365 handle_nothrow_attribute (tree *node, tree ARG_UNUSED (name),
366 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
367 bool * ARG_UNUSED (no_add_attrs))
368 {
369 if (TREE_CODE (*node) == FUNCTION_DECL)
370 TREE_NOTHROW (*node) = 1;
371 else
372 gcc_unreachable ();
373
374 return NULL_TREE;
375 }
376
377
378 /* Handle a "sentinel" attribute. */
379
380 static tree
381 handle_sentinel_attribute (tree *node, tree ARG_UNUSED (name), tree args,
382 int ARG_UNUSED (flags),
383 bool * ARG_UNUSED (no_add_attrs))
384 {
385 gcc_assert (stdarg_p (*node));
386
387 if (args)
388 {
389 tree position = TREE_VALUE (args);
390 gcc_assert (TREE_CODE (position) == INTEGER_CST);
391 if (tree_int_cst_lt (position, integer_zero_node))
392 gcc_unreachable ();
393 }
394
395 return NULL_TREE;
396 }
397
398 /* Handle a "type_generic" attribute. */
399
400 static tree
401 handle_type_generic_attribute (tree *node, tree ARG_UNUSED (name),
402 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
403 bool * ARG_UNUSED (no_add_attrs))
404 {
405 /* Ensure we have a function type. */
406 gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
407
408 /* Ensure we have a variadic function. */
409 gcc_assert (!prototype_p (*node) || stdarg_p (*node));
410
411 return NULL_TREE;
412 }
413
414 /* Handle a "transaction_pure" attribute. */
415
416 static tree
417 handle_transaction_pure_attribute (tree *node, tree ARG_UNUSED (name),
418 tree ARG_UNUSED (args),
419 int ARG_UNUSED (flags),
420 bool * ARG_UNUSED (no_add_attrs))
421 {
422 /* Ensure we have a function type. */
423 gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
424
425 return NULL_TREE;
426 }
427
428 /* Ignore the given attribute. Used when this attribute may be usefully
429 overridden by the target, but is not used generically. */
430
431 static tree
432 ignore_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
433 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
434 bool *no_add_attrs)
435 {
436 *no_add_attrs = true;
437 return NULL_TREE;
438 }
439
440 /* Handle a "format" attribute; arguments as in
441 struct attribute_spec.handler. */
442
443 static tree
444 handle_format_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
445 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
446 bool *no_add_attrs)
447 {
448 *no_add_attrs = true;
449 return NULL_TREE;
450 }
451
452
453 /* Handle a "format_arg" attribute; arguments as in
454 struct attribute_spec.handler. */
455
456 tree
457 handle_format_arg_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
458 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
459 bool *no_add_attrs)
460 {
461 *no_add_attrs = true;
462 return NULL_TREE;
463 }
464
465
466 /* Cribbed from c-common.c. */
467
468 static void
469 def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...)
470 {
471 tree t;
472 tree *args = XALLOCAVEC (tree, n);
473 va_list list;
474 int i;
475
476 va_start (list, n);
477 for (i = 0; i < n; ++i)
478 {
479 builtin_type a = (builtin_type) va_arg (list, int);
480 t = builtin_types[a];
481 if (t == error_mark_node)
482 goto egress;
483 args[i] = t;
484 }
485 va_end (list);
486
487 t = builtin_types[ret];
488 if (t == error_mark_node)
489 goto egress;
490 if (var)
491 t = build_varargs_function_type_array (t, n, args);
492 else
493 t = build_function_type_array (t, n, args);
494
495 egress:
496 builtin_types[def] = t;
497 va_end (list);
498 }
499
500 /* Used to help initialize the builtin-types.def table. When a type of
501 the correct size doesn't exist, use error_mark_node instead of NULL.
502 The later results in segfaults even when a decl using the type doesn't
503 get invoked. */
504
505 static tree
506 builtin_type_for_size (int size, bool unsignedp)
507 {
508 tree type = lang_hooks.types.type_for_size (size, unsignedp);
509 return type ? type : error_mark_node;
510 }
511
512 /* Support for DEF_BUILTIN. */
513
514 static void
515 def_builtin_1 (enum built_in_function fncode, const char *name,
516 enum built_in_class fnclass, tree fntype, tree libtype,
517 bool both_p, bool fallback_p, bool nonansi_p,
518 tree fnattrs, bool implicit_p)
519 {
520 tree decl;
521 const char *libname;
522
523 if (fntype == error_mark_node)
524 return;
525
526 libname = name + strlen ("__builtin_");
527 decl = add_builtin_function (name, fntype, fncode, fnclass,
528 (fallback_p ? libname : NULL),
529 fnattrs);
530
531 if (both_p
532 && !flag_no_builtin
533 && !(nonansi_p && flag_no_nonansi_builtin))
534 add_builtin_function (libname, libtype, fncode, fnclass,
535 NULL, fnattrs);
536
537 set_builtin_decl (fncode, decl, implicit_p);
538 }
539
540
541 /* Initialize the attribute table for all the supported builtins. */
542
543 static void
544 lto_init_attributes (void)
545 {
546 /* Fill in the built_in_attributes array. */
547 #define DEF_ATTR_NULL_TREE(ENUM) \
548 built_in_attributes[(int) ENUM] = NULL_TREE;
549 #define DEF_ATTR_INT(ENUM, VALUE) \
550 built_in_attributes[(int) ENUM] = build_int_cst (NULL_TREE, VALUE);
551 #define DEF_ATTR_IDENT(ENUM, STRING) \
552 built_in_attributes[(int) ENUM] = get_identifier (STRING);
553 #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) \
554 built_in_attributes[(int) ENUM] \
555 = tree_cons (built_in_attributes[(int) PURPOSE], \
556 built_in_attributes[(int) VALUE], \
557 built_in_attributes[(int) CHAIN]);
558 #include "builtin-attrs.def"
559 #undef DEF_ATTR_NULL_TREE
560 #undef DEF_ATTR_INT
561 #undef DEF_ATTR_IDENT
562 #undef DEF_ATTR_TREE_LIST
563 }
564
565 /* Create builtin types and functions. VA_LIST_REF_TYPE_NODE and
566 VA_LIST_ARG_TYPE_NODE are used in builtin-types.def. */
567
568 static void
569 lto_define_builtins (tree va_list_ref_type_node ATTRIBUTE_UNUSED,
570 tree va_list_arg_type_node ATTRIBUTE_UNUSED)
571 {
572 #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
573 builtin_types[ENUM] = VALUE;
574 #define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \
575 def_fn_type (ENUM, RETURN, 0, 0);
576 #define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \
577 def_fn_type (ENUM, RETURN, 0, 1, ARG1);
578 #define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \
579 def_fn_type (ENUM, RETURN, 0, 2, ARG1, ARG2);
580 #define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
581 def_fn_type (ENUM, RETURN, 0, 3, ARG1, ARG2, ARG3);
582 #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
583 def_fn_type (ENUM, RETURN, 0, 4, ARG1, ARG2, ARG3, ARG4);
584 #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
585 def_fn_type (ENUM, RETURN, 0, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
586 #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
587 ARG6) \
588 def_fn_type (ENUM, RETURN, 0, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
589 #define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
590 ARG6, ARG7) \
591 def_fn_type (ENUM, RETURN, 0, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7);
592 #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \
593 def_fn_type (ENUM, RETURN, 1, 0);
594 #define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \
595 def_fn_type (ENUM, RETURN, 1, 1, ARG1);
596 #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \
597 def_fn_type (ENUM, RETURN, 1, 2, ARG1, ARG2);
598 #define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
599 def_fn_type (ENUM, RETURN, 1, 3, ARG1, ARG2, ARG3);
600 #define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
601 def_fn_type (ENUM, RETURN, 1, 4, ARG1, ARG2, ARG3, ARG4);
602 #define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
603 def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
604 #define DEF_POINTER_TYPE(ENUM, TYPE) \
605 builtin_types[(int) ENUM] = build_pointer_type (builtin_types[(int) TYPE]);
606
607 #include "builtin-types.def"
608
609 #undef DEF_PRIMITIVE_TYPE
610 #undef DEF_FUNCTION_TYPE_1
611 #undef DEF_FUNCTION_TYPE_2
612 #undef DEF_FUNCTION_TYPE_3
613 #undef DEF_FUNCTION_TYPE_4
614 #undef DEF_FUNCTION_TYPE_5
615 #undef DEF_FUNCTION_TYPE_6
616 #undef DEF_FUNCTION_TYPE_VAR_0
617 #undef DEF_FUNCTION_TYPE_VAR_1
618 #undef DEF_FUNCTION_TYPE_VAR_2
619 #undef DEF_FUNCTION_TYPE_VAR_3
620 #undef DEF_FUNCTION_TYPE_VAR_4
621 #undef DEF_FUNCTION_TYPE_VAR_5
622 #undef DEF_POINTER_TYPE
623 builtin_types[(int) BT_LAST] = NULL_TREE;
624
625 lto_init_attributes ();
626
627 #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P,\
628 NONANSI_P, ATTRS, IMPLICIT, COND) \
629 if (NAME && COND) \
630 def_builtin_1 (ENUM, NAME, CLASS, builtin_types[(int) TYPE], \
631 builtin_types[(int) LIBTYPE], BOTH_P, FALLBACK_P, \
632 NONANSI_P, built_in_attributes[(int) ATTRS], IMPLICIT);
633 #include "builtins.def"
634 #undef DEF_BUILTIN
635 }
636
637 static GTY(()) tree registered_builtin_types;
638
639 /* Language hooks. */
640
641 static unsigned int
642 lto_option_lang_mask (void)
643 {
644 return CL_LTO;
645 }
646
647 static bool
648 lto_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED)
649 {
650 /* The LTO front end inherits all the options from the first front
651 end that was used. However, not all the original front end
652 options make sense in LTO.
653
654 A real solution would be to filter this in collect2, but collect2
655 does not have access to all the option attributes to know what to
656 filter. So, in lto1 we silently accept inherited flags and do
657 nothing about it. */
658 return false;
659 }
660
661 static void
662 lto_init_options_struct (struct gcc_options *opts)
663 {
664 /* By default, C99-like requirements for complex multiply and divide.
665 ??? Until the complex method is encoded in the IL this is the only
666 safe choice. This will pessimize Fortran code with LTO unless
667 people specify a complex method manually or use -ffast-math. */
668 opts->x_flag_complex_method = 2;
669 }
670
671 /* Handle command-line option SCODE. If the option takes an argument, it is
672 stored in ARG, which is otherwise NULL. VALUE holds either a numerical
673 argument or a binary value indicating whether the positive or negative form
674 of the option was supplied. */
675
676 const char *resolution_file_name;
677 static bool
678 lto_handle_option (size_t scode, const char *arg,
679 int value ATTRIBUTE_UNUSED, int kind ATTRIBUTE_UNUSED,
680 location_t loc ATTRIBUTE_UNUSED,
681 const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
682 {
683 enum opt_code code = (enum opt_code) scode;
684 bool result = true;
685
686 switch (code)
687 {
688 case OPT_fresolution_:
689 resolution_file_name = arg;
690 break;
691
692 case OPT_Wabi:
693 warn_psabi = value;
694 break;
695
696 default:
697 break;
698 }
699
700 return result;
701 }
702
703 /* Perform post-option processing. Does additional initialization based on
704 command-line options. PFILENAME is the main input filename. Returns false
705 to enable subsequent back-end initialization. */
706
707 static bool
708 lto_post_options (const char **pfilename ATTRIBUTE_UNUSED)
709 {
710 /* -fltrans and -fwpa are mutually exclusive. Check for that here. */
711 if (flag_wpa && flag_ltrans)
712 error ("-fwpa and -fltrans are mutually exclusive");
713
714 if (flag_ltrans)
715 {
716 flag_generate_lto = 0;
717
718 /* During LTRANS, we are not looking at the whole program, only
719 a subset of the whole callgraph. */
720 flag_whole_program = 0;
721 }
722
723 if (flag_wpa)
724 flag_generate_lto = 1;
725
726 /* Excess precision other than "fast" requires front-end
727 support. */
728 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
729
730 /* Initialize the compiler back end. */
731 return false;
732 }
733
734 /* Return an integer type with PRECISION bits of precision,
735 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
736
737 static tree
738 lto_type_for_size (unsigned precision, int unsignedp)
739 {
740 if (precision == TYPE_PRECISION (integer_type_node))
741 return unsignedp ? unsigned_type_node : integer_type_node;
742
743 if (precision == TYPE_PRECISION (signed_char_type_node))
744 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
745
746 if (precision == TYPE_PRECISION (short_integer_type_node))
747 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
748
749 if (precision == TYPE_PRECISION (long_integer_type_node))
750 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
751
752 if (precision == TYPE_PRECISION (long_long_integer_type_node))
753 return unsignedp
754 ? long_long_unsigned_type_node
755 : long_long_integer_type_node;
756
757 if (precision <= TYPE_PRECISION (intQI_type_node))
758 return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
759
760 if (precision <= TYPE_PRECISION (intHI_type_node))
761 return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
762
763 if (precision <= TYPE_PRECISION (intSI_type_node))
764 return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
765
766 if (precision <= TYPE_PRECISION (intDI_type_node))
767 return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
768
769 if (precision <= TYPE_PRECISION (intTI_type_node))
770 return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
771
772 return NULL_TREE;
773 }
774
775
776 /* Return a data type that has machine mode MODE.
777 If the mode is an integer,
778 then UNSIGNEDP selects between signed and unsigned types.
779 If the mode is a fixed-point mode,
780 then UNSIGNEDP selects between saturating and nonsaturating types. */
781
782 static tree
783 lto_type_for_mode (enum machine_mode mode, int unsigned_p)
784 {
785 tree t;
786
787 if (mode == TYPE_MODE (integer_type_node))
788 return unsigned_p ? unsigned_type_node : integer_type_node;
789
790 if (mode == TYPE_MODE (signed_char_type_node))
791 return unsigned_p ? unsigned_char_type_node : signed_char_type_node;
792
793 if (mode == TYPE_MODE (short_integer_type_node))
794 return unsigned_p ? short_unsigned_type_node : short_integer_type_node;
795
796 if (mode == TYPE_MODE (long_integer_type_node))
797 return unsigned_p ? long_unsigned_type_node : long_integer_type_node;
798
799 if (mode == TYPE_MODE (long_long_integer_type_node))
800 return unsigned_p ? long_long_unsigned_type_node : long_long_integer_type_node;
801
802 if (mode == QImode)
803 return unsigned_p ? unsigned_intQI_type_node : intQI_type_node;
804
805 if (mode == HImode)
806 return unsigned_p ? unsigned_intHI_type_node : intHI_type_node;
807
808 if (mode == SImode)
809 return unsigned_p ? unsigned_intSI_type_node : intSI_type_node;
810
811 if (mode == DImode)
812 return unsigned_p ? unsigned_intDI_type_node : intDI_type_node;
813
814 #if HOST_BITS_PER_WIDE_INT >= 64
815 if (mode == TYPE_MODE (intTI_type_node))
816 return unsigned_p ? unsigned_intTI_type_node : intTI_type_node;
817 #endif
818
819 if (mode == TYPE_MODE (float_type_node))
820 return float_type_node;
821
822 if (mode == TYPE_MODE (double_type_node))
823 return double_type_node;
824
825 if (mode == TYPE_MODE (long_double_type_node))
826 return long_double_type_node;
827
828 if (mode == TYPE_MODE (void_type_node))
829 return void_type_node;
830
831 if (mode == TYPE_MODE (build_pointer_type (char_type_node)))
832 return (unsigned_p
833 ? make_unsigned_type (GET_MODE_PRECISION (mode))
834 : make_signed_type (GET_MODE_PRECISION (mode)));
835
836 if (mode == TYPE_MODE (build_pointer_type (integer_type_node)))
837 return (unsigned_p
838 ? make_unsigned_type (GET_MODE_PRECISION (mode))
839 : make_signed_type (GET_MODE_PRECISION (mode)));
840
841 if (COMPLEX_MODE_P (mode))
842 {
843 enum machine_mode inner_mode;
844 tree inner_type;
845
846 if (mode == TYPE_MODE (complex_float_type_node))
847 return complex_float_type_node;
848 if (mode == TYPE_MODE (complex_double_type_node))
849 return complex_double_type_node;
850 if (mode == TYPE_MODE (complex_long_double_type_node))
851 return complex_long_double_type_node;
852
853 if (mode == TYPE_MODE (complex_integer_type_node) && !unsigned_p)
854 return complex_integer_type_node;
855
856 inner_mode = GET_MODE_INNER (mode);
857 inner_type = lto_type_for_mode (inner_mode, unsigned_p);
858 if (inner_type != NULL_TREE)
859 return build_complex_type (inner_type);
860 }
861 else if (VECTOR_MODE_P (mode))
862 {
863 enum machine_mode inner_mode = GET_MODE_INNER (mode);
864 tree inner_type = lto_type_for_mode (inner_mode, unsigned_p);
865 if (inner_type != NULL_TREE)
866 return build_vector_type_for_mode (inner_type, mode);
867 }
868
869 if (mode == TYPE_MODE (dfloat32_type_node))
870 return dfloat32_type_node;
871 if (mode == TYPE_MODE (dfloat64_type_node))
872 return dfloat64_type_node;
873 if (mode == TYPE_MODE (dfloat128_type_node))
874 return dfloat128_type_node;
875
876 if (ALL_SCALAR_FIXED_POINT_MODE_P (mode))
877 {
878 if (mode == TYPE_MODE (short_fract_type_node))
879 return unsigned_p ? sat_short_fract_type_node : short_fract_type_node;
880 if (mode == TYPE_MODE (fract_type_node))
881 return unsigned_p ? sat_fract_type_node : fract_type_node;
882 if (mode == TYPE_MODE (long_fract_type_node))
883 return unsigned_p ? sat_long_fract_type_node : long_fract_type_node;
884 if (mode == TYPE_MODE (long_long_fract_type_node))
885 return unsigned_p ? sat_long_long_fract_type_node
886 : long_long_fract_type_node;
887
888 if (mode == TYPE_MODE (unsigned_short_fract_type_node))
889 return unsigned_p ? sat_unsigned_short_fract_type_node
890 : unsigned_short_fract_type_node;
891 if (mode == TYPE_MODE (unsigned_fract_type_node))
892 return unsigned_p ? sat_unsigned_fract_type_node
893 : unsigned_fract_type_node;
894 if (mode == TYPE_MODE (unsigned_long_fract_type_node))
895 return unsigned_p ? sat_unsigned_long_fract_type_node
896 : unsigned_long_fract_type_node;
897 if (mode == TYPE_MODE (unsigned_long_long_fract_type_node))
898 return unsigned_p ? sat_unsigned_long_long_fract_type_node
899 : unsigned_long_long_fract_type_node;
900
901 if (mode == TYPE_MODE (short_accum_type_node))
902 return unsigned_p ? sat_short_accum_type_node : short_accum_type_node;
903 if (mode == TYPE_MODE (accum_type_node))
904 return unsigned_p ? sat_accum_type_node : accum_type_node;
905 if (mode == TYPE_MODE (long_accum_type_node))
906 return unsigned_p ? sat_long_accum_type_node : long_accum_type_node;
907 if (mode == TYPE_MODE (long_long_accum_type_node))
908 return unsigned_p ? sat_long_long_accum_type_node
909 : long_long_accum_type_node;
910
911 if (mode == TYPE_MODE (unsigned_short_accum_type_node))
912 return unsigned_p ? sat_unsigned_short_accum_type_node
913 : unsigned_short_accum_type_node;
914 if (mode == TYPE_MODE (unsigned_accum_type_node))
915 return unsigned_p ? sat_unsigned_accum_type_node
916 : unsigned_accum_type_node;
917 if (mode == TYPE_MODE (unsigned_long_accum_type_node))
918 return unsigned_p ? sat_unsigned_long_accum_type_node
919 : unsigned_long_accum_type_node;
920 if (mode == TYPE_MODE (unsigned_long_long_accum_type_node))
921 return unsigned_p ? sat_unsigned_long_long_accum_type_node
922 : unsigned_long_long_accum_type_node;
923
924 if (mode == QQmode)
925 return unsigned_p ? sat_qq_type_node : qq_type_node;
926 if (mode == HQmode)
927 return unsigned_p ? sat_hq_type_node : hq_type_node;
928 if (mode == SQmode)
929 return unsigned_p ? sat_sq_type_node : sq_type_node;
930 if (mode == DQmode)
931 return unsigned_p ? sat_dq_type_node : dq_type_node;
932 if (mode == TQmode)
933 return unsigned_p ? sat_tq_type_node : tq_type_node;
934
935 if (mode == UQQmode)
936 return unsigned_p ? sat_uqq_type_node : uqq_type_node;
937 if (mode == UHQmode)
938 return unsigned_p ? sat_uhq_type_node : uhq_type_node;
939 if (mode == USQmode)
940 return unsigned_p ? sat_usq_type_node : usq_type_node;
941 if (mode == UDQmode)
942 return unsigned_p ? sat_udq_type_node : udq_type_node;
943 if (mode == UTQmode)
944 return unsigned_p ? sat_utq_type_node : utq_type_node;
945
946 if (mode == HAmode)
947 return unsigned_p ? sat_ha_type_node : ha_type_node;
948 if (mode == SAmode)
949 return unsigned_p ? sat_sa_type_node : sa_type_node;
950 if (mode == DAmode)
951 return unsigned_p ? sat_da_type_node : da_type_node;
952 if (mode == TAmode)
953 return unsigned_p ? sat_ta_type_node : ta_type_node;
954
955 if (mode == UHAmode)
956 return unsigned_p ? sat_uha_type_node : uha_type_node;
957 if (mode == USAmode)
958 return unsigned_p ? sat_usa_type_node : usa_type_node;
959 if (mode == UDAmode)
960 return unsigned_p ? sat_uda_type_node : uda_type_node;
961 if (mode == UTAmode)
962 return unsigned_p ? sat_uta_type_node : uta_type_node;
963 }
964
965 for (t = registered_builtin_types; t; t = TREE_CHAIN (t))
966 if (TYPE_MODE (TREE_VALUE (t)) == mode)
967 return TREE_VALUE (t);
968
969 return NULL_TREE;
970 }
971
972 /* Return true if we are in the global binding level. */
973
974 static bool
975 lto_global_bindings_p (void)
976 {
977 return cfun == NULL;
978 }
979
980 static void
981 lto_set_decl_assembler_name (tree decl)
982 {
983 /* This is almost the same as lhd_set_decl_assembler_name, except that
984 we need to uniquify file-scope names, even if they are not
985 TREE_PUBLIC, to avoid conflicts between individual files. */
986 tree id;
987
988 if (TREE_PUBLIC (decl))
989 id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
990 else
991 {
992 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
993 char *label;
994
995 ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
996 id = get_identifier (label);
997 }
998
999 SET_DECL_ASSEMBLER_NAME (decl, id);
1000 }
1001
1002 static tree
1003 lto_pushdecl (tree t ATTRIBUTE_UNUSED)
1004 {
1005 /* Do nothing, since we get all information from DWARF and LTO
1006 sections. */
1007 return NULL_TREE;
1008 }
1009
1010 static tree
1011 lto_getdecls (void)
1012 {
1013 /* We have our own write_globals langhook, hence the getdecls
1014 langhook shouldn't be used, except by dbxout.c, so we can't
1015 just abort here. */
1016 return NULL_TREE;
1017 }
1018
1019 static void
1020 lto_write_globals (void)
1021 {
1022 tree *vec = VEC_address (tree, lto_global_var_decls);
1023 int len = VEC_length (tree, lto_global_var_decls);
1024 wrapup_global_declarations (vec, len);
1025 emit_debug_global_declarations (vec, len);
1026 VEC_free (tree, gc, lto_global_var_decls);
1027 }
1028
1029 static tree
1030 lto_builtin_function (tree decl)
1031 {
1032 return decl;
1033 }
1034
1035 static void
1036 lto_register_builtin_type (tree type, const char *name)
1037 {
1038 tree decl;
1039
1040 decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier (name), type);
1041 DECL_ARTIFICIAL (decl) = 1;
1042 if (!TYPE_NAME (type))
1043 TYPE_NAME (type) = decl;
1044
1045 registered_builtin_types = tree_cons (0, type, registered_builtin_types);
1046 }
1047
1048 /* Build nodes that would have be created by the C front-end; necessary
1049 for including builtin-types.def and ultimately builtins.def. */
1050
1051 static void
1052 lto_build_c_type_nodes (void)
1053 {
1054 gcc_assert (void_type_node);
1055
1056 void_list_node = build_tree_list (NULL_TREE, void_type_node);
1057 string_type_node = build_pointer_type (char_type_node);
1058 const_string_type_node
1059 = build_pointer_type (build_qualified_type (char_type_node, TYPE_QUAL_CONST));
1060
1061 if (strcmp (SIZE_TYPE, "unsigned int") == 0)
1062 {
1063 intmax_type_node = integer_type_node;
1064 uintmax_type_node = unsigned_type_node;
1065 signed_size_type_node = integer_type_node;
1066 }
1067 else if (strcmp (SIZE_TYPE, "long unsigned int") == 0)
1068 {
1069 intmax_type_node = long_integer_type_node;
1070 uintmax_type_node = long_unsigned_type_node;
1071 signed_size_type_node = long_integer_type_node;
1072 }
1073 else if (strcmp (SIZE_TYPE, "long long unsigned int") == 0)
1074 {
1075 intmax_type_node = long_long_integer_type_node;
1076 uintmax_type_node = long_long_unsigned_type_node;
1077 signed_size_type_node = long_long_integer_type_node;
1078 }
1079 else
1080 gcc_unreachable ();
1081
1082 wint_type_node = unsigned_type_node;
1083 pid_type_node = integer_type_node;
1084 }
1085
1086 /* Re-compute TYPE_CANONICAL for NODE and related types. */
1087
1088 static void
1089 lto_register_canonical_types (tree node)
1090 {
1091 if (!node
1092 || !TYPE_P (node))
1093 return;
1094
1095 TYPE_CANONICAL (node) = NULL_TREE;
1096 TYPE_CANONICAL (node) = gimple_register_canonical_type (node);
1097
1098 if (POINTER_TYPE_P (node)
1099 || TREE_CODE (node) == COMPLEX_TYPE
1100 || TREE_CODE (node) == ARRAY_TYPE)
1101 lto_register_canonical_types (TREE_TYPE (node));
1102 }
1103
1104 /* Perform LTO-specific initialization. */
1105
1106 static bool
1107 lto_init (void)
1108 {
1109 unsigned i;
1110
1111 /* We need to generate LTO if running in WPA mode. */
1112 flag_generate_lto = flag_wpa;
1113
1114 /* Initialize libcpp line maps for gcc_assert to work. */
1115 linemap_add (line_table, LC_ENTER, 0, NULL, 0);
1116
1117 /* Create the basic integer types. */
1118 build_common_tree_nodes (flag_signed_char, /*short_double=*/false);
1119
1120 /* The global tree for the main identifier is filled in by
1121 language-specific front-end initialization that is not run in the
1122 LTO back-end. It appears that all languages that perform such
1123 initialization currently do so in the same way, so we do it here. */
1124 if (main_identifier_node == NULL_TREE)
1125 main_identifier_node = get_identifier ("main");
1126
1127 /* In the C++ front-end, fileptr_type_node is defined as a variant
1128 copy of of ptr_type_node, rather than ptr_node itself. The
1129 distinction should only be relevant to the front-end, so we
1130 always use the C definition here in lto1. */
1131 gcc_assert (fileptr_type_node == ptr_type_node);
1132 gcc_assert (TYPE_MAIN_VARIANT (fileptr_type_node) == ptr_type_node);
1133
1134 ptrdiff_type_node = integer_type_node;
1135
1136 lto_build_c_type_nodes ();
1137 gcc_assert (va_list_type_node);
1138
1139 if (TREE_CODE (va_list_type_node) == ARRAY_TYPE)
1140 {
1141 tree x = build_pointer_type (TREE_TYPE (va_list_type_node));
1142 lto_define_builtins (x, x);
1143 }
1144 else
1145 {
1146 lto_define_builtins (va_list_type_node,
1147 build_reference_type (va_list_type_node));
1148 }
1149
1150 targetm.init_builtins ();
1151 build_common_builtin_nodes ();
1152
1153 /* Assign names to the builtin types, otherwise they'll end up
1154 as __unknown__ in debug info.
1155 ??? We simply need to stop pre-seeding the streamer cache.
1156 Below is modeled after from c-common.c:c_common_nodes_and_builtins */
1157 #define NAME_TYPE(t,n) \
1158 if (t) \
1159 TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL, \
1160 get_identifier (n), t)
1161 NAME_TYPE (integer_type_node, "int");
1162 NAME_TYPE (char_type_node, "char");
1163 NAME_TYPE (long_integer_type_node, "long int");
1164 NAME_TYPE (unsigned_type_node, "unsigned int");
1165 NAME_TYPE (long_unsigned_type_node, "long unsigned int");
1166 NAME_TYPE (long_long_integer_type_node, "long long int");
1167 NAME_TYPE (long_long_unsigned_type_node, "long long unsigned int");
1168 NAME_TYPE (short_integer_type_node, "short int");
1169 NAME_TYPE (short_unsigned_type_node, "short unsigned int");
1170 if (signed_char_type_node != char_type_node)
1171 NAME_TYPE (signed_char_type_node, "signed char");
1172 if (unsigned_char_type_node != char_type_node)
1173 NAME_TYPE (unsigned_char_type_node, "unsigned char");
1174 NAME_TYPE (float_type_node, "float");
1175 NAME_TYPE (double_type_node, "double");
1176 NAME_TYPE (long_double_type_node, "long double");
1177 NAME_TYPE (void_type_node, "void");
1178 NAME_TYPE (boolean_type_node, "bool");
1179 #undef NAME_TYPE
1180
1181 /* Register the common node types with the canonical type machinery so
1182 we properly share alias-sets across languages and TUs. Do not
1183 expose the common nodes as type merge target - those that should be
1184 are already exposed so by pre-loading the LTO streamer caches. */
1185 for (i = 0; i < itk_none; ++i)
1186 lto_register_canonical_types (integer_types[i]);
1187 /* The sizetypes are not used to access data so we do not need to
1188 do anything about them. */
1189 for (i = 0; i < TI_MAX; ++i)
1190 lto_register_canonical_types (global_trees[i]);
1191
1192 /* Initialize LTO-specific data structures. */
1193 lto_global_var_decls = VEC_alloc (tree, gc, 256);
1194 in_lto_p = true;
1195
1196 return true;
1197 }
1198
1199 /* Initialize tree structures required by the LTO front end. */
1200
1201 static void lto_init_ts (void)
1202 {
1203 tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1;
1204 }
1205
1206 #undef LANG_HOOKS_NAME
1207 #define LANG_HOOKS_NAME "GNU GIMPLE"
1208 #undef LANG_HOOKS_OPTION_LANG_MASK
1209 #define LANG_HOOKS_OPTION_LANG_MASK lto_option_lang_mask
1210 #undef LANG_HOOKS_COMPLAIN_WRONG_LANG_P
1211 #define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lto_complain_wrong_lang_p
1212 #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
1213 #define LANG_HOOKS_INIT_OPTIONS_STRUCT lto_init_options_struct
1214 #undef LANG_HOOKS_HANDLE_OPTION
1215 #define LANG_HOOKS_HANDLE_OPTION lto_handle_option
1216 #undef LANG_HOOKS_POST_OPTIONS
1217 #define LANG_HOOKS_POST_OPTIONS lto_post_options
1218 #undef LANG_HOOKS_GET_ALIAS_SET
1219 #define LANG_HOOKS_GET_ALIAS_SET gimple_get_alias_set
1220 #undef LANG_HOOKS_TYPE_FOR_MODE
1221 #define LANG_HOOKS_TYPE_FOR_MODE lto_type_for_mode
1222 #undef LANG_HOOKS_TYPE_FOR_SIZE
1223 #define LANG_HOOKS_TYPE_FOR_SIZE lto_type_for_size
1224 #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
1225 #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME lto_set_decl_assembler_name
1226 #undef LANG_HOOKS_GLOBAL_BINDINGS_P
1227 #define LANG_HOOKS_GLOBAL_BINDINGS_P lto_global_bindings_p
1228 #undef LANG_HOOKS_PUSHDECL
1229 #define LANG_HOOKS_PUSHDECL lto_pushdecl
1230 #undef LANG_HOOKS_GETDECLS
1231 #define LANG_HOOKS_GETDECLS lto_getdecls
1232 #undef LANG_HOOKS_WRITE_GLOBALS
1233 #define LANG_HOOKS_WRITE_GLOBALS lto_write_globals
1234 #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
1235 #define LANG_HOOKS_REGISTER_BUILTIN_TYPE lto_register_builtin_type
1236 #undef LANG_HOOKS_BUILTIN_FUNCTION
1237 #define LANG_HOOKS_BUILTIN_FUNCTION lto_builtin_function
1238 #undef LANG_HOOKS_INIT
1239 #define LANG_HOOKS_INIT lto_init
1240 #undef LANG_HOOKS_PARSE_FILE
1241 #define LANG_HOOKS_PARSE_FILE lto_main
1242 #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
1243 #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION tree_rest_of_compilation
1244 #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS
1245 #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS true
1246 #undef LANG_HOOKS_TYPES_COMPATIBLE_P
1247 #define LANG_HOOKS_TYPES_COMPATIBLE_P NULL
1248 #undef LANG_HOOKS_EH_PERSONALITY
1249 #define LANG_HOOKS_EH_PERSONALITY lto_eh_personality
1250
1251 /* Attribute hooks. */
1252 #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE
1253 #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE lto_attribute_table
1254 #undef LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE
1255 #define LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE lto_format_attribute_table
1256
1257 #undef LANG_HOOKS_BEGIN_SECTION
1258 #define LANG_HOOKS_BEGIN_SECTION lto_obj_begin_section
1259 #undef LANG_HOOKS_APPEND_DATA
1260 #define LANG_HOOKS_APPEND_DATA lto_obj_append_data
1261 #undef LANG_HOOKS_END_SECTION
1262 #define LANG_HOOKS_END_SECTION lto_obj_end_section
1263
1264 #undef LANG_HOOKS_INIT_TS
1265 #define LANG_HOOKS_INIT_TS lto_init_ts
1266
1267 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
1268
1269 /* Language hooks that are not part of lang_hooks. */
1270
1271 tree
1272 convert (tree type ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED)
1273 {
1274 gcc_unreachable ();
1275 }
1276
1277 /* Tree walking support. */
1278
1279 static enum lto_tree_node_structure_enum
1280 lto_tree_node_structure (union lang_tree_node *t ATTRIBUTE_UNUSED)
1281 {
1282 return TS_LTO_GENERIC;
1283 }
1284
1285 #include "ggc.h"
1286 #include "gtype-lto.h"
1287 #include "gt-lto-lto-lang.h"