Rebase.
[official-gcc.git] / gcc / lto / lto-lang.c
blob937b7e5753f825d93434eebb5ecc5cd6a8336e3c
1 /* Language-dependent hooks for LTO.
2 Copyright (C) 2009-2014 Free Software Foundation, Inc.
3 Contributed by CodeSourcery, Inc.
5 This file is part of GCC.
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.
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.
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/>. */
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 "stringpool.h"
28 #include "stor-layout.h"
29 #include "target.h"
30 #include "langhooks.h"
31 #include "langhooks-def.h"
32 #include "debug.h"
33 #include "lto-tree.h"
34 #include "lto.h"
35 #include "tree-inline.h"
36 #include "basic-block.h"
37 #include "tree-ssa-alias.h"
38 #include "internal-fn.h"
39 #include "gimple-expr.h"
40 #include "is-a.h"
41 #include "gimple.h"
42 #include "diagnostic-core.h"
43 #include "toplev.h"
44 #include "lto-streamer.h"
45 #include "cilk.h"
47 static tree lto_type_for_size (unsigned, int);
49 static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
50 static tree handle_leaf_attribute (tree *, tree, tree, int, bool *);
51 static tree handle_const_attribute (tree *, tree, tree, int, bool *);
52 static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
53 static tree handle_pure_attribute (tree *, tree, tree, int, bool *);
54 static tree handle_novops_attribute (tree *, tree, tree, int, bool *);
55 static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
56 static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *);
57 static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
58 static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
59 static tree handle_transaction_pure_attribute (tree *, tree, tree, int, bool *);
60 static tree handle_returns_twice_attribute (tree *, tree, tree, int, bool *);
61 static tree ignore_attribute (tree *, tree, tree, int, bool *);
63 static tree handle_format_attribute (tree *, tree, tree, int, bool *);
64 static tree handle_fnspec_attribute (tree *, tree, tree, int, bool *);
65 static tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
67 /* Table of machine-independent attributes supported in GIMPLE. */
68 const struct attribute_spec lto_attribute_table[] =
70 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
71 do_diagnostic } */
72 { "noreturn", 0, 0, true, false, false,
73 handle_noreturn_attribute, false },
74 { "leaf", 0, 0, true, false, false,
75 handle_leaf_attribute, false },
76 /* The same comments as for noreturn attributes apply to const ones. */
77 { "const", 0, 0, true, false, false,
78 handle_const_attribute, false },
79 { "malloc", 0, 0, true, false, false,
80 handle_malloc_attribute, false },
81 { "pure", 0, 0, true, false, false,
82 handle_pure_attribute, false },
83 { "no vops", 0, 0, true, false, false,
84 handle_novops_attribute, false },
85 { "nonnull", 0, -1, false, true, true,
86 handle_nonnull_attribute, false },
87 { "nothrow", 0, 0, true, false, false,
88 handle_nothrow_attribute, false },
89 { "returns_twice", 0, 0, true, false, false,
90 handle_returns_twice_attribute, false },
91 { "sentinel", 0, 1, false, true, true,
92 handle_sentinel_attribute, false },
93 { "type generic", 0, 0, false, true, true,
94 handle_type_generic_attribute, false },
95 { "fn spec", 1, 1, false, true, true,
96 handle_fnspec_attribute, false },
97 { "transaction_pure", 0, 0, false, true, true,
98 handle_transaction_pure_attribute, false },
99 /* For internal use only. The leading '*' both prevents its usage in
100 source code and signals that it may be overridden by machine tables. */
101 { "*tm regparm", 0, 0, false, true, true,
102 ignore_attribute, false },
103 { NULL, 0, 0, false, false, false, NULL, false }
106 /* Give the specifications for the format attributes, used by C and all
107 descendants. */
109 const struct attribute_spec lto_format_attribute_table[] =
111 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
112 affects_type_identity } */
113 { "format", 3, 3, false, true, true,
114 handle_format_attribute, false },
115 { "format_arg", 1, 1, false, true, true,
116 handle_format_arg_attribute, false },
117 { NULL, 0, 0, false, false, false, NULL, false }
120 enum built_in_attribute
122 #define DEF_ATTR_NULL_TREE(ENUM) ENUM,
123 #define DEF_ATTR_INT(ENUM, VALUE) ENUM,
124 #define DEF_ATTR_STRING(ENUM, VALUE) ENUM,
125 #define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
126 #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
127 #include "builtin-attrs.def"
128 #undef DEF_ATTR_NULL_TREE
129 #undef DEF_ATTR_INT
130 #undef DEF_ATTR_STRING
131 #undef DEF_ATTR_IDENT
132 #undef DEF_ATTR_TREE_LIST
133 ATTR_LAST
136 static GTY(()) tree built_in_attributes[(int) ATTR_LAST];
138 /* Builtin types. */
140 enum lto_builtin_type
142 #define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME,
143 #define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME,
144 #define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME,
145 #define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME,
146 #define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
147 #define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
148 #define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME,
149 #define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
150 ARG6) NAME,
151 #define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
152 ARG6, ARG7) NAME,
153 #define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
154 ARG6, ARG7, ARG8) NAME,
155 #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
156 #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
157 #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
158 #define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
159 #define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
160 #define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG6) \
161 NAME,
162 #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
163 #include "builtin-types.def"
164 #undef DEF_PRIMITIVE_TYPE
165 #undef DEF_FUNCTION_TYPE_0
166 #undef DEF_FUNCTION_TYPE_1
167 #undef DEF_FUNCTION_TYPE_2
168 #undef DEF_FUNCTION_TYPE_3
169 #undef DEF_FUNCTION_TYPE_4
170 #undef DEF_FUNCTION_TYPE_5
171 #undef DEF_FUNCTION_TYPE_6
172 #undef DEF_FUNCTION_TYPE_7
173 #undef DEF_FUNCTION_TYPE_8
174 #undef DEF_FUNCTION_TYPE_VAR_0
175 #undef DEF_FUNCTION_TYPE_VAR_1
176 #undef DEF_FUNCTION_TYPE_VAR_2
177 #undef DEF_FUNCTION_TYPE_VAR_3
178 #undef DEF_FUNCTION_TYPE_VAR_4
179 #undef DEF_FUNCTION_TYPE_VAR_5
180 #undef DEF_POINTER_TYPE
181 BT_LAST
184 typedef enum lto_builtin_type builtin_type;
186 static GTY(()) tree builtin_types[(int) BT_LAST + 1];
188 static GTY(()) tree string_type_node;
189 static GTY(()) tree const_string_type_node;
190 static GTY(()) tree wint_type_node;
191 static GTY(()) tree intmax_type_node;
192 static GTY(()) tree uintmax_type_node;
193 static GTY(()) tree signed_size_type_node;
195 /* Flags needed to process builtins.def. */
196 int flag_isoc94;
197 int flag_isoc99;
198 int flag_isoc11;
200 /* Attribute handlers. */
202 /* Handle a "noreturn" attribute; arguments as in
203 struct attribute_spec.handler. */
205 static tree
206 handle_noreturn_attribute (tree *node, tree ARG_UNUSED (name),
207 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
208 bool * ARG_UNUSED (no_add_attrs))
210 tree type = TREE_TYPE (*node);
212 if (TREE_CODE (*node) == FUNCTION_DECL)
213 TREE_THIS_VOLATILE (*node) = 1;
214 else if (TREE_CODE (type) == POINTER_TYPE
215 && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
216 TREE_TYPE (*node)
217 = build_pointer_type
218 (build_type_variant (TREE_TYPE (type),
219 TYPE_READONLY (TREE_TYPE (type)), 1));
220 else
221 gcc_unreachable ();
223 return NULL_TREE;
226 /* Handle a "leaf" attribute; arguments as in
227 struct attribute_spec.handler. */
229 static tree
230 handle_leaf_attribute (tree *node, tree name,
231 tree ARG_UNUSED (args),
232 int ARG_UNUSED (flags), bool *no_add_attrs)
234 if (TREE_CODE (*node) != FUNCTION_DECL)
236 warning (OPT_Wattributes, "%qE attribute ignored", name);
237 *no_add_attrs = true;
239 if (!TREE_PUBLIC (*node))
241 warning (OPT_Wattributes, "%qE attribute has no effect on unit local functions", name);
242 *no_add_attrs = true;
245 return NULL_TREE;
248 /* Handle a "const" attribute; arguments as in
249 struct attribute_spec.handler. */
251 static tree
252 handle_const_attribute (tree *node, tree ARG_UNUSED (name),
253 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
254 bool * ARG_UNUSED (no_add_attrs))
256 tree type = TREE_TYPE (*node);
258 /* See FIXME comment on noreturn in c_common_attribute_table. */
259 if (TREE_CODE (*node) == FUNCTION_DECL)
260 TREE_READONLY (*node) = 1;
261 else if (TREE_CODE (type) == POINTER_TYPE
262 && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
263 TREE_TYPE (*node)
264 = build_pointer_type
265 (build_type_variant (TREE_TYPE (type), 1,
266 TREE_THIS_VOLATILE (TREE_TYPE (type))));
267 else
268 gcc_unreachable ();
270 return NULL_TREE;
274 /* Handle a "malloc" attribute; arguments as in
275 struct attribute_spec.handler. */
277 static tree
278 handle_malloc_attribute (tree *node, tree ARG_UNUSED (name),
279 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
280 bool * ARG_UNUSED (no_add_attrs))
282 if (TREE_CODE (*node) == FUNCTION_DECL
283 && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (*node))))
284 DECL_IS_MALLOC (*node) = 1;
285 else
286 gcc_unreachable ();
288 return NULL_TREE;
292 /* Handle a "pure" attribute; arguments as in
293 struct attribute_spec.handler. */
295 static tree
296 handle_pure_attribute (tree *node, tree ARG_UNUSED (name),
297 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
298 bool * ARG_UNUSED (no_add_attrs))
300 if (TREE_CODE (*node) == FUNCTION_DECL)
301 DECL_PURE_P (*node) = 1;
302 else
303 gcc_unreachable ();
305 return NULL_TREE;
309 /* Handle a "no vops" attribute; arguments as in
310 struct attribute_spec.handler. */
312 static tree
313 handle_novops_attribute (tree *node, tree ARG_UNUSED (name),
314 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
315 bool *ARG_UNUSED (no_add_attrs))
317 gcc_assert (TREE_CODE (*node) == FUNCTION_DECL);
318 DECL_IS_NOVOPS (*node) = 1;
319 return NULL_TREE;
323 /* Helper for nonnull attribute handling; fetch the operand number
324 from the attribute argument list. */
326 static bool
327 get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp)
329 /* Verify the arg number is a constant. */
330 if (!tree_fits_uhwi_p (arg_num_expr))
331 return false;
333 *valp = TREE_INT_CST_LOW (arg_num_expr);
334 return true;
337 /* Handle the "nonnull" attribute. */
339 static tree
340 handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name),
341 tree args, int ARG_UNUSED (flags),
342 bool * ARG_UNUSED (no_add_attrs))
344 tree type = *node;
346 /* If no arguments are specified, all pointer arguments should be
347 non-null. Verify a full prototype is given so that the arguments
348 will have the correct types when we actually check them later. */
349 if (!args)
351 gcc_assert (prototype_p (type));
352 return NULL_TREE;
355 /* Argument list specified. Verify that each argument number references
356 a pointer argument. */
357 for (; args; args = TREE_CHAIN (args))
359 tree argument;
360 unsigned HOST_WIDE_INT arg_num = 0, ck_num;
362 if (!get_nonnull_operand (TREE_VALUE (args), &arg_num))
363 gcc_unreachable ();
365 argument = TYPE_ARG_TYPES (type);
366 if (argument)
368 for (ck_num = 1; ; ck_num++)
370 if (!argument || ck_num == arg_num)
371 break;
372 argument = TREE_CHAIN (argument);
375 gcc_assert (argument
376 && TREE_CODE (TREE_VALUE (argument)) == POINTER_TYPE);
380 return NULL_TREE;
384 /* Handle a "nothrow" attribute; arguments as in
385 struct attribute_spec.handler. */
387 static tree
388 handle_nothrow_attribute (tree *node, tree ARG_UNUSED (name),
389 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
390 bool * ARG_UNUSED (no_add_attrs))
392 if (TREE_CODE (*node) == FUNCTION_DECL)
393 TREE_NOTHROW (*node) = 1;
394 else
395 gcc_unreachable ();
397 return NULL_TREE;
401 /* Handle a "sentinel" attribute. */
403 static tree
404 handle_sentinel_attribute (tree *node, tree ARG_UNUSED (name), tree args,
405 int ARG_UNUSED (flags),
406 bool * ARG_UNUSED (no_add_attrs))
408 gcc_assert (stdarg_p (*node));
410 if (args)
412 tree position = TREE_VALUE (args);
413 gcc_assert (TREE_CODE (position) == INTEGER_CST);
414 if (tree_int_cst_lt (position, integer_zero_node))
415 gcc_unreachable ();
418 return NULL_TREE;
421 /* Handle a "type_generic" attribute. */
423 static tree
424 handle_type_generic_attribute (tree *node, tree ARG_UNUSED (name),
425 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
426 bool * ARG_UNUSED (no_add_attrs))
428 /* Ensure we have a function type. */
429 gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
431 /* Ensure we have a variadic function. */
432 gcc_assert (!prototype_p (*node) || stdarg_p (*node));
434 return NULL_TREE;
437 /* Handle a "transaction_pure" attribute. */
439 static tree
440 handle_transaction_pure_attribute (tree *node, tree ARG_UNUSED (name),
441 tree ARG_UNUSED (args),
442 int ARG_UNUSED (flags),
443 bool * ARG_UNUSED (no_add_attrs))
445 /* Ensure we have a function type. */
446 gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
448 return NULL_TREE;
451 /* Handle a "returns_twice" attribute. */
453 static tree
454 handle_returns_twice_attribute (tree *node, tree ARG_UNUSED (name),
455 tree ARG_UNUSED (args),
456 int ARG_UNUSED (flags),
457 bool * ARG_UNUSED (no_add_attrs))
459 gcc_assert (TREE_CODE (*node) == FUNCTION_DECL);
461 DECL_IS_RETURNS_TWICE (*node) = 1;
463 return NULL_TREE;
466 /* Ignore the given attribute. Used when this attribute may be usefully
467 overridden by the target, but is not used generically. */
469 static tree
470 ignore_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
471 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
472 bool *no_add_attrs)
474 *no_add_attrs = true;
475 return NULL_TREE;
478 /* Handle a "format" attribute; arguments as in
479 struct attribute_spec.handler. */
481 static tree
482 handle_format_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
483 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
484 bool *no_add_attrs)
486 *no_add_attrs = true;
487 return NULL_TREE;
491 /* Handle a "format_arg" attribute; arguments as in
492 struct attribute_spec.handler. */
494 tree
495 handle_format_arg_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
496 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
497 bool *no_add_attrs)
499 *no_add_attrs = true;
500 return NULL_TREE;
504 /* Handle a "fn spec" attribute; arguments as in
505 struct attribute_spec.handler. */
507 static tree
508 handle_fnspec_attribute (tree *node ATTRIBUTE_UNUSED, tree ARG_UNUSED (name),
509 tree args, int ARG_UNUSED (flags),
510 bool *no_add_attrs ATTRIBUTE_UNUSED)
512 gcc_assert (args
513 && TREE_CODE (TREE_VALUE (args)) == STRING_CST
514 && !TREE_CHAIN (args));
515 return NULL_TREE;
518 /* Cribbed from c-common.c. */
520 static void
521 def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...)
523 tree t;
524 tree *args = XALLOCAVEC (tree, n);
525 va_list list;
526 int i;
528 va_start (list, n);
529 for (i = 0; i < n; ++i)
531 builtin_type a = (builtin_type) va_arg (list, int);
532 t = builtin_types[a];
533 if (t == error_mark_node)
534 goto egress;
535 args[i] = t;
537 va_end (list);
539 t = builtin_types[ret];
540 if (t == error_mark_node)
541 goto egress;
542 if (var)
543 t = build_varargs_function_type_array (t, n, args);
544 else
545 t = build_function_type_array (t, n, args);
547 egress:
548 builtin_types[def] = t;
549 va_end (list);
552 /* Used to help initialize the builtin-types.def table. When a type of
553 the correct size doesn't exist, use error_mark_node instead of NULL.
554 The later results in segfaults even when a decl using the type doesn't
555 get invoked. */
557 static tree
558 builtin_type_for_size (int size, bool unsignedp)
560 tree type = lto_type_for_size (size, unsignedp);
561 return type ? type : error_mark_node;
564 /* Support for DEF_BUILTIN. */
566 static void
567 def_builtin_1 (enum built_in_function fncode, const char *name,
568 enum built_in_class fnclass, tree fntype, tree libtype,
569 bool both_p, bool fallback_p, bool nonansi_p,
570 tree fnattrs, bool implicit_p)
572 tree decl;
573 const char *libname;
575 if (fntype == error_mark_node)
576 return;
578 libname = name + strlen ("__builtin_");
579 decl = add_builtin_function (name, fntype, fncode, fnclass,
580 (fallback_p ? libname : NULL),
581 fnattrs);
583 if (both_p
584 && !flag_no_builtin
585 && !(nonansi_p && flag_no_nonansi_builtin))
586 add_builtin_function (libname, libtype, fncode, fnclass,
587 NULL, fnattrs);
589 set_builtin_decl (fncode, decl, implicit_p);
593 /* Initialize the attribute table for all the supported builtins. */
595 static void
596 lto_init_attributes (void)
598 /* Fill in the built_in_attributes array. */
599 #define DEF_ATTR_NULL_TREE(ENUM) \
600 built_in_attributes[(int) ENUM] = NULL_TREE;
601 #define DEF_ATTR_INT(ENUM, VALUE) \
602 built_in_attributes[(int) ENUM] = build_int_cst (NULL_TREE, VALUE);
603 #define DEF_ATTR_STRING(ENUM, VALUE) \
604 built_in_attributes[(int) ENUM] = build_string (strlen (VALUE), VALUE);
605 #define DEF_ATTR_IDENT(ENUM, STRING) \
606 built_in_attributes[(int) ENUM] = get_identifier (STRING);
607 #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) \
608 built_in_attributes[(int) ENUM] \
609 = tree_cons (built_in_attributes[(int) PURPOSE], \
610 built_in_attributes[(int) VALUE], \
611 built_in_attributes[(int) CHAIN]);
612 #include "builtin-attrs.def"
613 #undef DEF_ATTR_NULL_TREE
614 #undef DEF_ATTR_INT
615 #undef DEF_ATTR_STRING
616 #undef DEF_ATTR_IDENT
617 #undef DEF_ATTR_TREE_LIST
620 /* Create builtin types and functions. VA_LIST_REF_TYPE_NODE and
621 VA_LIST_ARG_TYPE_NODE are used in builtin-types.def. */
623 static void
624 lto_define_builtins (tree va_list_ref_type_node ATTRIBUTE_UNUSED,
625 tree va_list_arg_type_node ATTRIBUTE_UNUSED)
627 #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
628 builtin_types[ENUM] = VALUE;
629 #define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \
630 def_fn_type (ENUM, RETURN, 0, 0);
631 #define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \
632 def_fn_type (ENUM, RETURN, 0, 1, ARG1);
633 #define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \
634 def_fn_type (ENUM, RETURN, 0, 2, ARG1, ARG2);
635 #define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
636 def_fn_type (ENUM, RETURN, 0, 3, ARG1, ARG2, ARG3);
637 #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
638 def_fn_type (ENUM, RETURN, 0, 4, ARG1, ARG2, ARG3, ARG4);
639 #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
640 def_fn_type (ENUM, RETURN, 0, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
641 #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
642 ARG6) \
643 def_fn_type (ENUM, RETURN, 0, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
644 #define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
645 ARG6, ARG7) \
646 def_fn_type (ENUM, RETURN, 0, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7);
647 #define DEF_FUNCTION_TYPE_8(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
648 ARG6, ARG7, ARG8) \
649 def_fn_type (ENUM, RETURN, 0, 8, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \
650 ARG7, ARG8);
651 #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \
652 def_fn_type (ENUM, RETURN, 1, 0);
653 #define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \
654 def_fn_type (ENUM, RETURN, 1, 1, ARG1);
655 #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \
656 def_fn_type (ENUM, RETURN, 1, 2, ARG1, ARG2);
657 #define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
658 def_fn_type (ENUM, RETURN, 1, 3, ARG1, ARG2, ARG3);
659 #define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
660 def_fn_type (ENUM, RETURN, 1, 4, ARG1, ARG2, ARG3, ARG4);
661 #define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
662 def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
663 #define DEF_POINTER_TYPE(ENUM, TYPE) \
664 builtin_types[(int) ENUM] = build_pointer_type (builtin_types[(int) TYPE]);
666 #include "builtin-types.def"
668 #undef DEF_PRIMITIVE_TYPE
669 #undef DEF_FUNCTION_TYPE_0
670 #undef DEF_FUNCTION_TYPE_1
671 #undef DEF_FUNCTION_TYPE_2
672 #undef DEF_FUNCTION_TYPE_3
673 #undef DEF_FUNCTION_TYPE_4
674 #undef DEF_FUNCTION_TYPE_5
675 #undef DEF_FUNCTION_TYPE_6
676 #undef DEF_FUNCTION_TYPE_7
677 #undef DEF_FUNCTION_TYPE_8
678 #undef DEF_FUNCTION_TYPE_VAR_0
679 #undef DEF_FUNCTION_TYPE_VAR_1
680 #undef DEF_FUNCTION_TYPE_VAR_2
681 #undef DEF_FUNCTION_TYPE_VAR_3
682 #undef DEF_FUNCTION_TYPE_VAR_4
683 #undef DEF_FUNCTION_TYPE_VAR_5
684 #undef DEF_POINTER_TYPE
685 builtin_types[(int) BT_LAST] = NULL_TREE;
687 lto_init_attributes ();
689 #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P,\
690 NONANSI_P, ATTRS, IMPLICIT, COND) \
691 if (NAME && COND) \
692 def_builtin_1 (ENUM, NAME, CLASS, builtin_types[(int) TYPE], \
693 builtin_types[(int) LIBTYPE], BOTH_P, FALLBACK_P, \
694 NONANSI_P, built_in_attributes[(int) ATTRS], IMPLICIT);
695 #include "builtins.def"
696 #undef DEF_BUILTIN
699 static GTY(()) tree registered_builtin_types;
701 /* Language hooks. */
703 static unsigned int
704 lto_option_lang_mask (void)
706 return CL_LTO;
709 static bool
710 lto_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED)
712 /* The LTO front end inherits all the options from the first front
713 end that was used. However, not all the original front end
714 options make sense in LTO.
716 A real solution would be to filter this in collect2, but collect2
717 does not have access to all the option attributes to know what to
718 filter. So, in lto1 we silently accept inherited flags and do
719 nothing about it. */
720 return false;
723 static void
724 lto_init_options_struct (struct gcc_options *opts)
726 /* By default, C99-like requirements for complex multiply and divide.
727 ??? Until the complex method is encoded in the IL this is the only
728 safe choice. This will pessimize Fortran code with LTO unless
729 people specify a complex method manually or use -ffast-math. */
730 opts->x_flag_complex_method = 2;
733 /* Handle command-line option SCODE. If the option takes an argument, it is
734 stored in ARG, which is otherwise NULL. VALUE holds either a numerical
735 argument or a binary value indicating whether the positive or negative form
736 of the option was supplied. */
738 const char *resolution_file_name;
739 static bool
740 lto_handle_option (size_t scode, const char *arg,
741 int value ATTRIBUTE_UNUSED, int kind ATTRIBUTE_UNUSED,
742 location_t loc ATTRIBUTE_UNUSED,
743 const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
745 enum opt_code code = (enum opt_code) scode;
746 bool result = true;
748 switch (code)
750 case OPT_fresolution_:
751 resolution_file_name = arg;
752 break;
754 case OPT_Wabi:
755 warn_psabi = value;
756 break;
758 case OPT_fwpa:
759 flag_wpa = value ? "" : NULL;
760 break;
762 default:
763 break;
766 return result;
769 /* Perform post-option processing. Does additional initialization based on
770 command-line options. PFILENAME is the main input filename. Returns false
771 to enable subsequent back-end initialization. */
773 static bool
774 lto_post_options (const char **pfilename ATTRIBUTE_UNUSED)
776 /* -fltrans and -fwpa are mutually exclusive. Check for that here. */
777 if (flag_wpa && flag_ltrans)
778 error ("-fwpa and -fltrans are mutually exclusive");
780 if (flag_ltrans)
782 flag_generate_lto = 0;
784 /* During LTRANS, we are not looking at the whole program, only
785 a subset of the whole callgraph. */
786 flag_whole_program = 0;
789 if (flag_wpa)
790 flag_generate_lto = 1;
792 /* Excess precision other than "fast" requires front-end
793 support. */
794 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
796 /* Initialize the compiler back end. */
797 return false;
800 /* Return an integer type with PRECISION bits of precision,
801 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
803 static tree
804 lto_type_for_size (unsigned precision, int unsignedp)
806 if (precision == TYPE_PRECISION (integer_type_node))
807 return unsignedp ? unsigned_type_node : integer_type_node;
809 if (precision == TYPE_PRECISION (signed_char_type_node))
810 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
812 if (precision == TYPE_PRECISION (short_integer_type_node))
813 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
815 if (precision == TYPE_PRECISION (long_integer_type_node))
816 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
818 if (precision == TYPE_PRECISION (long_long_integer_type_node))
819 return unsignedp
820 ? long_long_unsigned_type_node
821 : long_long_integer_type_node;
823 if (precision <= TYPE_PRECISION (intQI_type_node))
824 return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
826 if (precision <= TYPE_PRECISION (intHI_type_node))
827 return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
829 if (precision <= TYPE_PRECISION (intSI_type_node))
830 return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
832 if (precision <= TYPE_PRECISION (intDI_type_node))
833 return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
835 if (precision <= TYPE_PRECISION (intTI_type_node))
836 return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
838 return NULL_TREE;
842 /* Return a data type that has machine mode MODE.
843 If the mode is an integer,
844 then UNSIGNEDP selects between signed and unsigned types.
845 If the mode is a fixed-point mode,
846 then UNSIGNEDP selects between saturating and nonsaturating types. */
848 static tree
849 lto_type_for_mode (enum machine_mode mode, int unsigned_p)
851 tree t;
853 if (mode == TYPE_MODE (integer_type_node))
854 return unsigned_p ? unsigned_type_node : integer_type_node;
856 if (mode == TYPE_MODE (signed_char_type_node))
857 return unsigned_p ? unsigned_char_type_node : signed_char_type_node;
859 if (mode == TYPE_MODE (short_integer_type_node))
860 return unsigned_p ? short_unsigned_type_node : short_integer_type_node;
862 if (mode == TYPE_MODE (long_integer_type_node))
863 return unsigned_p ? long_unsigned_type_node : long_integer_type_node;
865 if (mode == TYPE_MODE (long_long_integer_type_node))
866 return unsigned_p ? long_long_unsigned_type_node : long_long_integer_type_node;
868 if (mode == QImode)
869 return unsigned_p ? unsigned_intQI_type_node : intQI_type_node;
871 if (mode == HImode)
872 return unsigned_p ? unsigned_intHI_type_node : intHI_type_node;
874 if (mode == SImode)
875 return unsigned_p ? unsigned_intSI_type_node : intSI_type_node;
877 if (mode == DImode)
878 return unsigned_p ? unsigned_intDI_type_node : intDI_type_node;
880 #if HOST_BITS_PER_WIDE_INT >= 64
881 if (mode == TYPE_MODE (intTI_type_node))
882 return unsigned_p ? unsigned_intTI_type_node : intTI_type_node;
883 #endif
885 if (mode == TYPE_MODE (float_type_node))
886 return float_type_node;
888 if (mode == TYPE_MODE (double_type_node))
889 return double_type_node;
891 if (mode == TYPE_MODE (long_double_type_node))
892 return long_double_type_node;
894 if (mode == TYPE_MODE (void_type_node))
895 return void_type_node;
897 if (mode == TYPE_MODE (build_pointer_type (char_type_node)))
898 return (unsigned_p
899 ? make_unsigned_type (GET_MODE_PRECISION (mode))
900 : make_signed_type (GET_MODE_PRECISION (mode)));
902 if (mode == TYPE_MODE (build_pointer_type (integer_type_node)))
903 return (unsigned_p
904 ? make_unsigned_type (GET_MODE_PRECISION (mode))
905 : make_signed_type (GET_MODE_PRECISION (mode)));
907 if (COMPLEX_MODE_P (mode))
909 enum machine_mode inner_mode;
910 tree inner_type;
912 if (mode == TYPE_MODE (complex_float_type_node))
913 return complex_float_type_node;
914 if (mode == TYPE_MODE (complex_double_type_node))
915 return complex_double_type_node;
916 if (mode == TYPE_MODE (complex_long_double_type_node))
917 return complex_long_double_type_node;
919 if (mode == TYPE_MODE (complex_integer_type_node) && !unsigned_p)
920 return complex_integer_type_node;
922 inner_mode = GET_MODE_INNER (mode);
923 inner_type = lto_type_for_mode (inner_mode, unsigned_p);
924 if (inner_type != NULL_TREE)
925 return build_complex_type (inner_type);
927 else if (VECTOR_MODE_P (mode))
929 enum machine_mode inner_mode = GET_MODE_INNER (mode);
930 tree inner_type = lto_type_for_mode (inner_mode, unsigned_p);
931 if (inner_type != NULL_TREE)
932 return build_vector_type_for_mode (inner_type, mode);
935 if (mode == TYPE_MODE (dfloat32_type_node))
936 return dfloat32_type_node;
937 if (mode == TYPE_MODE (dfloat64_type_node))
938 return dfloat64_type_node;
939 if (mode == TYPE_MODE (dfloat128_type_node))
940 return dfloat128_type_node;
942 if (ALL_SCALAR_FIXED_POINT_MODE_P (mode))
944 if (mode == TYPE_MODE (short_fract_type_node))
945 return unsigned_p ? sat_short_fract_type_node : short_fract_type_node;
946 if (mode == TYPE_MODE (fract_type_node))
947 return unsigned_p ? sat_fract_type_node : fract_type_node;
948 if (mode == TYPE_MODE (long_fract_type_node))
949 return unsigned_p ? sat_long_fract_type_node : long_fract_type_node;
950 if (mode == TYPE_MODE (long_long_fract_type_node))
951 return unsigned_p ? sat_long_long_fract_type_node
952 : long_long_fract_type_node;
954 if (mode == TYPE_MODE (unsigned_short_fract_type_node))
955 return unsigned_p ? sat_unsigned_short_fract_type_node
956 : unsigned_short_fract_type_node;
957 if (mode == TYPE_MODE (unsigned_fract_type_node))
958 return unsigned_p ? sat_unsigned_fract_type_node
959 : unsigned_fract_type_node;
960 if (mode == TYPE_MODE (unsigned_long_fract_type_node))
961 return unsigned_p ? sat_unsigned_long_fract_type_node
962 : unsigned_long_fract_type_node;
963 if (mode == TYPE_MODE (unsigned_long_long_fract_type_node))
964 return unsigned_p ? sat_unsigned_long_long_fract_type_node
965 : unsigned_long_long_fract_type_node;
967 if (mode == TYPE_MODE (short_accum_type_node))
968 return unsigned_p ? sat_short_accum_type_node : short_accum_type_node;
969 if (mode == TYPE_MODE (accum_type_node))
970 return unsigned_p ? sat_accum_type_node : accum_type_node;
971 if (mode == TYPE_MODE (long_accum_type_node))
972 return unsigned_p ? sat_long_accum_type_node : long_accum_type_node;
973 if (mode == TYPE_MODE (long_long_accum_type_node))
974 return unsigned_p ? sat_long_long_accum_type_node
975 : long_long_accum_type_node;
977 if (mode == TYPE_MODE (unsigned_short_accum_type_node))
978 return unsigned_p ? sat_unsigned_short_accum_type_node
979 : unsigned_short_accum_type_node;
980 if (mode == TYPE_MODE (unsigned_accum_type_node))
981 return unsigned_p ? sat_unsigned_accum_type_node
982 : unsigned_accum_type_node;
983 if (mode == TYPE_MODE (unsigned_long_accum_type_node))
984 return unsigned_p ? sat_unsigned_long_accum_type_node
985 : unsigned_long_accum_type_node;
986 if (mode == TYPE_MODE (unsigned_long_long_accum_type_node))
987 return unsigned_p ? sat_unsigned_long_long_accum_type_node
988 : unsigned_long_long_accum_type_node;
990 if (mode == QQmode)
991 return unsigned_p ? sat_qq_type_node : qq_type_node;
992 if (mode == HQmode)
993 return unsigned_p ? sat_hq_type_node : hq_type_node;
994 if (mode == SQmode)
995 return unsigned_p ? sat_sq_type_node : sq_type_node;
996 if (mode == DQmode)
997 return unsigned_p ? sat_dq_type_node : dq_type_node;
998 if (mode == TQmode)
999 return unsigned_p ? sat_tq_type_node : tq_type_node;
1001 if (mode == UQQmode)
1002 return unsigned_p ? sat_uqq_type_node : uqq_type_node;
1003 if (mode == UHQmode)
1004 return unsigned_p ? sat_uhq_type_node : uhq_type_node;
1005 if (mode == USQmode)
1006 return unsigned_p ? sat_usq_type_node : usq_type_node;
1007 if (mode == UDQmode)
1008 return unsigned_p ? sat_udq_type_node : udq_type_node;
1009 if (mode == UTQmode)
1010 return unsigned_p ? sat_utq_type_node : utq_type_node;
1012 if (mode == HAmode)
1013 return unsigned_p ? sat_ha_type_node : ha_type_node;
1014 if (mode == SAmode)
1015 return unsigned_p ? sat_sa_type_node : sa_type_node;
1016 if (mode == DAmode)
1017 return unsigned_p ? sat_da_type_node : da_type_node;
1018 if (mode == TAmode)
1019 return unsigned_p ? sat_ta_type_node : ta_type_node;
1021 if (mode == UHAmode)
1022 return unsigned_p ? sat_uha_type_node : uha_type_node;
1023 if (mode == USAmode)
1024 return unsigned_p ? sat_usa_type_node : usa_type_node;
1025 if (mode == UDAmode)
1026 return unsigned_p ? sat_uda_type_node : uda_type_node;
1027 if (mode == UTAmode)
1028 return unsigned_p ? sat_uta_type_node : uta_type_node;
1031 for (t = registered_builtin_types; t; t = TREE_CHAIN (t))
1032 if (TYPE_MODE (TREE_VALUE (t)) == mode)
1033 return TREE_VALUE (t);
1035 return NULL_TREE;
1038 /* Return true if we are in the global binding level. */
1040 static bool
1041 lto_global_bindings_p (void)
1043 return cfun == NULL;
1046 static void
1047 lto_set_decl_assembler_name (tree decl)
1049 /* This is almost the same as lhd_set_decl_assembler_name, except that
1050 we need to uniquify file-scope names, even if they are not
1051 TREE_PUBLIC, to avoid conflicts between individual files. */
1052 tree id;
1054 if (TREE_PUBLIC (decl))
1055 id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
1056 else
1058 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1059 char *label;
1061 ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
1062 id = get_identifier (label);
1065 SET_DECL_ASSEMBLER_NAME (decl, id);
1068 static tree
1069 lto_pushdecl (tree t ATTRIBUTE_UNUSED)
1071 /* Do nothing, since we get all information from DWARF and LTO
1072 sections. */
1073 return NULL_TREE;
1076 static tree
1077 lto_getdecls (void)
1079 /* We have our own write_globals langhook, hence the getdecls
1080 langhook shouldn't be used, except by dbxout.c, so we can't
1081 just abort here. */
1082 return NULL_TREE;
1085 static void
1086 lto_write_globals (void)
1088 if (flag_wpa)
1089 return;
1091 /* Output debug info for global variables. */
1092 varpool_node *vnode;
1093 FOR_EACH_DEFINED_VARIABLE (vnode)
1094 if (!decl_function_context (vnode->decl))
1095 debug_hooks->global_decl (vnode->decl);
1098 static tree
1099 lto_builtin_function (tree decl)
1101 return decl;
1104 static void
1105 lto_register_builtin_type (tree type, const char *name)
1107 tree decl;
1109 if (!TYPE_NAME (type))
1111 decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
1112 get_identifier (name), type);
1113 DECL_ARTIFICIAL (decl) = 1;
1114 TYPE_NAME (type) = decl;
1117 registered_builtin_types = tree_cons (0, type, registered_builtin_types);
1120 /* Build nodes that would have be created by the C front-end; necessary
1121 for including builtin-types.def and ultimately builtins.def. */
1123 static void
1124 lto_build_c_type_nodes (void)
1126 gcc_assert (void_type_node);
1128 void_list_node = build_tree_list (NULL_TREE, void_type_node);
1129 string_type_node = build_pointer_type (char_type_node);
1130 const_string_type_node
1131 = build_pointer_type (build_qualified_type (char_type_node, TYPE_QUAL_CONST));
1133 if (strcmp (SIZE_TYPE, "unsigned int") == 0)
1135 intmax_type_node = integer_type_node;
1136 uintmax_type_node = unsigned_type_node;
1137 signed_size_type_node = integer_type_node;
1139 else if (strcmp (SIZE_TYPE, "long unsigned int") == 0)
1141 intmax_type_node = long_integer_type_node;
1142 uintmax_type_node = long_unsigned_type_node;
1143 signed_size_type_node = long_integer_type_node;
1145 else if (strcmp (SIZE_TYPE, "long long unsigned int") == 0)
1147 intmax_type_node = long_long_integer_type_node;
1148 uintmax_type_node = long_long_unsigned_type_node;
1149 signed_size_type_node = long_long_integer_type_node;
1151 else
1152 gcc_unreachable ();
1154 wint_type_node = unsigned_type_node;
1155 pid_type_node = integer_type_node;
1158 /* Perform LTO-specific initialization. */
1160 static bool
1161 lto_init (void)
1163 /* We need to generate LTO if running in WPA mode. */
1164 flag_generate_lto = (flag_wpa != NULL);
1166 /* Create the basic integer types. */
1167 build_common_tree_nodes (flag_signed_char, flag_short_double);
1169 /* The global tree for the main identifier is filled in by
1170 language-specific front-end initialization that is not run in the
1171 LTO back-end. It appears that all languages that perform such
1172 initialization currently do so in the same way, so we do it here. */
1173 if (main_identifier_node == NULL_TREE)
1174 main_identifier_node = get_identifier ("main");
1176 /* In the C++ front-end, fileptr_type_node is defined as a variant
1177 copy of of ptr_type_node, rather than ptr_node itself. The
1178 distinction should only be relevant to the front-end, so we
1179 always use the C definition here in lto1. */
1180 gcc_assert (fileptr_type_node == ptr_type_node);
1181 gcc_assert (TYPE_MAIN_VARIANT (fileptr_type_node) == ptr_type_node);
1183 ptrdiff_type_node = integer_type_node;
1185 lto_build_c_type_nodes ();
1186 gcc_assert (va_list_type_node);
1188 if (TREE_CODE (va_list_type_node) == ARRAY_TYPE)
1190 tree x = build_pointer_type (TREE_TYPE (va_list_type_node));
1191 lto_define_builtins (x, x);
1193 else
1195 lto_define_builtins (va_list_type_node,
1196 build_reference_type (va_list_type_node));
1199 if (flag_cilkplus)
1200 cilk_init_builtins ();
1202 targetm.init_builtins ();
1203 build_common_builtin_nodes ();
1205 /* Assign names to the builtin types, otherwise they'll end up
1206 as __unknown__ in debug info.
1207 ??? We simply need to stop pre-seeding the streamer cache.
1208 Below is modeled after from c-common.c:c_common_nodes_and_builtins */
1209 #define NAME_TYPE(t,n) \
1210 if (t) \
1211 TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL, \
1212 get_identifier (n), t)
1213 NAME_TYPE (integer_type_node, "int");
1214 NAME_TYPE (char_type_node, "char");
1215 NAME_TYPE (long_integer_type_node, "long int");
1216 NAME_TYPE (unsigned_type_node, "unsigned int");
1217 NAME_TYPE (long_unsigned_type_node, "long unsigned int");
1218 NAME_TYPE (long_long_integer_type_node, "long long int");
1219 NAME_TYPE (long_long_unsigned_type_node, "long long unsigned int");
1220 NAME_TYPE (short_integer_type_node, "short int");
1221 NAME_TYPE (short_unsigned_type_node, "short unsigned int");
1222 if (signed_char_type_node != char_type_node)
1223 NAME_TYPE (signed_char_type_node, "signed char");
1224 if (unsigned_char_type_node != char_type_node)
1225 NAME_TYPE (unsigned_char_type_node, "unsigned char");
1226 NAME_TYPE (float_type_node, "float");
1227 NAME_TYPE (double_type_node, "double");
1228 NAME_TYPE (long_double_type_node, "long double");
1229 NAME_TYPE (void_type_node, "void");
1230 NAME_TYPE (boolean_type_node, "bool");
1231 NAME_TYPE (complex_float_type_node, "complex float");
1232 NAME_TYPE (complex_double_type_node, "complex double");
1233 NAME_TYPE (complex_long_double_type_node, "complex long double");
1234 if (int128_integer_type_node)
1235 NAME_TYPE (int128_integer_type_node, "__int128");
1236 #undef NAME_TYPE
1238 /* Initialize LTO-specific data structures. */
1239 in_lto_p = true;
1241 return true;
1244 /* Initialize tree structures required by the LTO front end. */
1246 static void lto_init_ts (void)
1248 tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1;
1251 #undef LANG_HOOKS_NAME
1252 #define LANG_HOOKS_NAME "GNU GIMPLE"
1253 #undef LANG_HOOKS_OPTION_LANG_MASK
1254 #define LANG_HOOKS_OPTION_LANG_MASK lto_option_lang_mask
1255 #undef LANG_HOOKS_COMPLAIN_WRONG_LANG_P
1256 #define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lto_complain_wrong_lang_p
1257 #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
1258 #define LANG_HOOKS_INIT_OPTIONS_STRUCT lto_init_options_struct
1259 #undef LANG_HOOKS_HANDLE_OPTION
1260 #define LANG_HOOKS_HANDLE_OPTION lto_handle_option
1261 #undef LANG_HOOKS_POST_OPTIONS
1262 #define LANG_HOOKS_POST_OPTIONS lto_post_options
1263 #undef LANG_HOOKS_GET_ALIAS_SET
1264 #define LANG_HOOKS_GET_ALIAS_SET gimple_get_alias_set
1265 #undef LANG_HOOKS_TYPE_FOR_MODE
1266 #define LANG_HOOKS_TYPE_FOR_MODE lto_type_for_mode
1267 #undef LANG_HOOKS_TYPE_FOR_SIZE
1268 #define LANG_HOOKS_TYPE_FOR_SIZE lto_type_for_size
1269 #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
1270 #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME lto_set_decl_assembler_name
1271 #undef LANG_HOOKS_GLOBAL_BINDINGS_P
1272 #define LANG_HOOKS_GLOBAL_BINDINGS_P lto_global_bindings_p
1273 #undef LANG_HOOKS_PUSHDECL
1274 #define LANG_HOOKS_PUSHDECL lto_pushdecl
1275 #undef LANG_HOOKS_GETDECLS
1276 #define LANG_HOOKS_GETDECLS lto_getdecls
1277 #undef LANG_HOOKS_WRITE_GLOBALS
1278 #define LANG_HOOKS_WRITE_GLOBALS lto_write_globals
1279 #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
1280 #define LANG_HOOKS_REGISTER_BUILTIN_TYPE lto_register_builtin_type
1281 #undef LANG_HOOKS_BUILTIN_FUNCTION
1282 #define LANG_HOOKS_BUILTIN_FUNCTION lto_builtin_function
1283 #undef LANG_HOOKS_INIT
1284 #define LANG_HOOKS_INIT lto_init
1285 #undef LANG_HOOKS_PARSE_FILE
1286 #define LANG_HOOKS_PARSE_FILE lto_main
1287 #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS
1288 #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS true
1289 #undef LANG_HOOKS_TYPES_COMPATIBLE_P
1290 #define LANG_HOOKS_TYPES_COMPATIBLE_P NULL
1291 #undef LANG_HOOKS_EH_PERSONALITY
1292 #define LANG_HOOKS_EH_PERSONALITY lto_eh_personality
1294 /* Attribute hooks. */
1295 #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE
1296 #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE lto_attribute_table
1297 #undef LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE
1298 #define LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE lto_format_attribute_table
1300 #undef LANG_HOOKS_BEGIN_SECTION
1301 #define LANG_HOOKS_BEGIN_SECTION lto_obj_begin_section
1302 #undef LANG_HOOKS_APPEND_DATA
1303 #define LANG_HOOKS_APPEND_DATA lto_obj_append_data
1304 #undef LANG_HOOKS_END_SECTION
1305 #define LANG_HOOKS_END_SECTION lto_obj_end_section
1307 #undef LANG_HOOKS_INIT_TS
1308 #define LANG_HOOKS_INIT_TS lto_init_ts
1310 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
1312 /* Language hooks that are not part of lang_hooks. */
1314 tree
1315 convert (tree type ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED)
1317 gcc_unreachable ();
1320 /* Tree walking support. */
1322 static enum lto_tree_node_structure_enum
1323 lto_tree_node_structure (union lang_tree_node *t ATTRIBUTE_UNUSED)
1325 return TS_LTO_GENERIC;
1328 #include "gtype-lto.h"
1329 #include "gt-lto-lto-lang.h"