gcc/ada/
[official-gcc.git] / gcc / lto / lto-lang.c
bloba4ae2a80a6882a21ed8068b289d0bbde7e99d164
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 "predict.h"
37 #include "vec.h"
38 #include "hashtab.h"
39 #include "hash-set.h"
40 #include "machmode.h"
41 #include "hard-reg-set.h"
42 #include "input.h"
43 #include "function.h"
44 #include "basic-block.h"
45 #include "tree-ssa-alias.h"
46 #include "internal-fn.h"
47 #include "gimple-expr.h"
48 #include "is-a.h"
49 #include "gimple.h"
50 #include "diagnostic-core.h"
51 #include "toplev.h"
52 #include "hash-map.h"
53 #include "plugin-api.h"
54 #include "ipa-ref.h"
55 #include "cgraph.h"
56 #include "lto-streamer.h"
57 #include "cilk.h"
59 static tree lto_type_for_size (unsigned, int);
61 static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
62 static tree handle_leaf_attribute (tree *, tree, tree, int, bool *);
63 static tree handle_const_attribute (tree *, tree, tree, int, bool *);
64 static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
65 static tree handle_pure_attribute (tree *, tree, tree, int, bool *);
66 static tree handle_novops_attribute (tree *, tree, tree, int, bool *);
67 static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
68 static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *);
69 static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
70 static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
71 static tree handle_transaction_pure_attribute (tree *, tree, tree, int, bool *);
72 static tree handle_returns_twice_attribute (tree *, tree, tree, int, bool *);
73 static tree ignore_attribute (tree *, tree, tree, int, bool *);
75 static tree handle_format_attribute (tree *, tree, tree, int, bool *);
76 static tree handle_fnspec_attribute (tree *, tree, tree, int, bool *);
77 static tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
79 /* Table of machine-independent attributes supported in GIMPLE. */
80 const struct attribute_spec lto_attribute_table[] =
82 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
83 do_diagnostic } */
84 { "noreturn", 0, 0, true, false, false,
85 handle_noreturn_attribute, false },
86 { "leaf", 0, 0, true, false, false,
87 handle_leaf_attribute, false },
88 /* The same comments as for noreturn attributes apply to const ones. */
89 { "const", 0, 0, true, false, false,
90 handle_const_attribute, false },
91 { "malloc", 0, 0, true, false, false,
92 handle_malloc_attribute, false },
93 { "pure", 0, 0, true, false, false,
94 handle_pure_attribute, false },
95 { "no vops", 0, 0, true, false, false,
96 handle_novops_attribute, false },
97 { "nonnull", 0, -1, false, true, true,
98 handle_nonnull_attribute, false },
99 { "nothrow", 0, 0, true, false, false,
100 handle_nothrow_attribute, false },
101 { "returns_twice", 0, 0, true, false, false,
102 handle_returns_twice_attribute, false },
103 { "sentinel", 0, 1, false, true, true,
104 handle_sentinel_attribute, false },
105 { "type generic", 0, 0, false, true, true,
106 handle_type_generic_attribute, false },
107 { "fn spec", 1, 1, false, true, true,
108 handle_fnspec_attribute, false },
109 { "transaction_pure", 0, 0, false, true, true,
110 handle_transaction_pure_attribute, false },
111 /* For internal use only. The leading '*' both prevents its usage in
112 source code and signals that it may be overridden by machine tables. */
113 { "*tm regparm", 0, 0, false, true, true,
114 ignore_attribute, false },
115 { NULL, 0, 0, false, false, false, NULL, false }
118 /* Give the specifications for the format attributes, used by C and all
119 descendants. */
121 const struct attribute_spec lto_format_attribute_table[] =
123 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
124 affects_type_identity } */
125 { "format", 3, 3, false, true, true,
126 handle_format_attribute, false },
127 { "format_arg", 1, 1, false, true, true,
128 handle_format_arg_attribute, false },
129 { NULL, 0, 0, false, false, false, NULL, false }
132 enum built_in_attribute
134 #define DEF_ATTR_NULL_TREE(ENUM) ENUM,
135 #define DEF_ATTR_INT(ENUM, VALUE) ENUM,
136 #define DEF_ATTR_STRING(ENUM, VALUE) ENUM,
137 #define DEF_ATTR_IDENT(ENUM, STRING) ENUM,
138 #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM,
139 #include "builtin-attrs.def"
140 #undef DEF_ATTR_NULL_TREE
141 #undef DEF_ATTR_INT
142 #undef DEF_ATTR_STRING
143 #undef DEF_ATTR_IDENT
144 #undef DEF_ATTR_TREE_LIST
145 ATTR_LAST
148 static GTY(()) tree built_in_attributes[(int) ATTR_LAST];
150 /* Builtin types. */
152 enum lto_builtin_type
154 #define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME,
155 #define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME,
156 #define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME,
157 #define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME,
158 #define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
159 #define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
160 #define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME,
161 #define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
162 ARG6) NAME,
163 #define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
164 ARG6, ARG7) NAME,
165 #define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
166 ARG6, ARG7, ARG8) NAME,
167 #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
168 #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
169 #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
170 #define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
171 #define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME,
172 #define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG6) \
173 NAME,
174 #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
175 #include "builtin-types.def"
176 #undef DEF_PRIMITIVE_TYPE
177 #undef DEF_FUNCTION_TYPE_0
178 #undef DEF_FUNCTION_TYPE_1
179 #undef DEF_FUNCTION_TYPE_2
180 #undef DEF_FUNCTION_TYPE_3
181 #undef DEF_FUNCTION_TYPE_4
182 #undef DEF_FUNCTION_TYPE_5
183 #undef DEF_FUNCTION_TYPE_6
184 #undef DEF_FUNCTION_TYPE_7
185 #undef DEF_FUNCTION_TYPE_8
186 #undef DEF_FUNCTION_TYPE_VAR_0
187 #undef DEF_FUNCTION_TYPE_VAR_1
188 #undef DEF_FUNCTION_TYPE_VAR_2
189 #undef DEF_FUNCTION_TYPE_VAR_3
190 #undef DEF_FUNCTION_TYPE_VAR_4
191 #undef DEF_FUNCTION_TYPE_VAR_5
192 #undef DEF_POINTER_TYPE
193 BT_LAST
196 typedef enum lto_builtin_type builtin_type;
198 static GTY(()) tree builtin_types[(int) BT_LAST + 1];
200 static GTY(()) tree string_type_node;
201 static GTY(()) tree const_string_type_node;
202 static GTY(()) tree wint_type_node;
203 static GTY(()) tree intmax_type_node;
204 static GTY(()) tree uintmax_type_node;
205 static GTY(()) tree signed_size_type_node;
207 /* Flags needed to process builtins.def. */
208 int flag_isoc94;
209 int flag_isoc99;
210 int flag_isoc11;
212 /* Attribute handlers. */
214 /* Handle a "noreturn" attribute; arguments as in
215 struct attribute_spec.handler. */
217 static tree
218 handle_noreturn_attribute (tree *node, tree ARG_UNUSED (name),
219 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
220 bool * ARG_UNUSED (no_add_attrs))
222 tree type = TREE_TYPE (*node);
224 if (TREE_CODE (*node) == FUNCTION_DECL)
225 TREE_THIS_VOLATILE (*node) = 1;
226 else if (TREE_CODE (type) == POINTER_TYPE
227 && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
228 TREE_TYPE (*node)
229 = build_pointer_type
230 (build_type_variant (TREE_TYPE (type),
231 TYPE_READONLY (TREE_TYPE (type)), 1));
232 else
233 gcc_unreachable ();
235 return NULL_TREE;
238 /* Handle a "leaf" attribute; arguments as in
239 struct attribute_spec.handler. */
241 static tree
242 handle_leaf_attribute (tree *node, tree name,
243 tree ARG_UNUSED (args),
244 int ARG_UNUSED (flags), bool *no_add_attrs)
246 if (TREE_CODE (*node) != FUNCTION_DECL)
248 warning (OPT_Wattributes, "%qE attribute ignored", name);
249 *no_add_attrs = true;
251 if (!TREE_PUBLIC (*node))
253 warning (OPT_Wattributes, "%qE attribute has no effect on unit local functions", name);
254 *no_add_attrs = true;
257 return NULL_TREE;
260 /* Handle a "const" attribute; arguments as in
261 struct attribute_spec.handler. */
263 static tree
264 handle_const_attribute (tree *node, tree ARG_UNUSED (name),
265 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
266 bool * ARG_UNUSED (no_add_attrs))
268 tree type = TREE_TYPE (*node);
270 /* See FIXME comment on noreturn in c_common_attribute_table. */
271 if (TREE_CODE (*node) == FUNCTION_DECL)
272 TREE_READONLY (*node) = 1;
273 else if (TREE_CODE (type) == POINTER_TYPE
274 && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
275 TREE_TYPE (*node)
276 = build_pointer_type
277 (build_type_variant (TREE_TYPE (type), 1,
278 TREE_THIS_VOLATILE (TREE_TYPE (type))));
279 else
280 gcc_unreachable ();
282 return NULL_TREE;
286 /* Handle a "malloc" attribute; arguments as in
287 struct attribute_spec.handler. */
289 static tree
290 handle_malloc_attribute (tree *node, tree ARG_UNUSED (name),
291 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
292 bool * ARG_UNUSED (no_add_attrs))
294 if (TREE_CODE (*node) == FUNCTION_DECL
295 && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (*node))))
296 DECL_IS_MALLOC (*node) = 1;
297 else
298 gcc_unreachable ();
300 return NULL_TREE;
304 /* Handle a "pure" attribute; arguments as in
305 struct attribute_spec.handler. */
307 static tree
308 handle_pure_attribute (tree *node, tree ARG_UNUSED (name),
309 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
310 bool * ARG_UNUSED (no_add_attrs))
312 if (TREE_CODE (*node) == FUNCTION_DECL)
313 DECL_PURE_P (*node) = 1;
314 else
315 gcc_unreachable ();
317 return NULL_TREE;
321 /* Handle a "no vops" attribute; arguments as in
322 struct attribute_spec.handler. */
324 static tree
325 handle_novops_attribute (tree *node, tree ARG_UNUSED (name),
326 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
327 bool *ARG_UNUSED (no_add_attrs))
329 gcc_assert (TREE_CODE (*node) == FUNCTION_DECL);
330 DECL_IS_NOVOPS (*node) = 1;
331 return NULL_TREE;
335 /* Helper for nonnull attribute handling; fetch the operand number
336 from the attribute argument list. */
338 static bool
339 get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp)
341 /* Verify the arg number is a constant. */
342 if (!tree_fits_uhwi_p (arg_num_expr))
343 return false;
345 *valp = TREE_INT_CST_LOW (arg_num_expr);
346 return true;
349 /* Handle the "nonnull" attribute. */
351 static tree
352 handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name),
353 tree args, int ARG_UNUSED (flags),
354 bool * ARG_UNUSED (no_add_attrs))
356 tree type = *node;
358 /* If no arguments are specified, all pointer arguments should be
359 non-null. Verify a full prototype is given so that the arguments
360 will have the correct types when we actually check them later. */
361 if (!args)
363 gcc_assert (prototype_p (type));
364 return NULL_TREE;
367 /* Argument list specified. Verify that each argument number references
368 a pointer argument. */
369 for (; args; args = TREE_CHAIN (args))
371 tree argument;
372 unsigned HOST_WIDE_INT arg_num = 0, ck_num;
374 if (!get_nonnull_operand (TREE_VALUE (args), &arg_num))
375 gcc_unreachable ();
377 argument = TYPE_ARG_TYPES (type);
378 if (argument)
380 for (ck_num = 1; ; ck_num++)
382 if (!argument || ck_num == arg_num)
383 break;
384 argument = TREE_CHAIN (argument);
387 gcc_assert (argument
388 && TREE_CODE (TREE_VALUE (argument)) == POINTER_TYPE);
392 return NULL_TREE;
396 /* Handle a "nothrow" attribute; arguments as in
397 struct attribute_spec.handler. */
399 static tree
400 handle_nothrow_attribute (tree *node, tree ARG_UNUSED (name),
401 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
402 bool * ARG_UNUSED (no_add_attrs))
404 if (TREE_CODE (*node) == FUNCTION_DECL)
405 TREE_NOTHROW (*node) = 1;
406 else
407 gcc_unreachable ();
409 return NULL_TREE;
413 /* Handle a "sentinel" attribute. */
415 static tree
416 handle_sentinel_attribute (tree *node, tree ARG_UNUSED (name), tree args,
417 int ARG_UNUSED (flags),
418 bool * ARG_UNUSED (no_add_attrs))
420 gcc_assert (stdarg_p (*node));
422 if (args)
424 tree position = TREE_VALUE (args);
425 gcc_assert (TREE_CODE (position) == INTEGER_CST);
426 if (tree_int_cst_lt (position, integer_zero_node))
427 gcc_unreachable ();
430 return NULL_TREE;
433 /* Handle a "type_generic" attribute. */
435 static tree
436 handle_type_generic_attribute (tree *node, tree ARG_UNUSED (name),
437 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
438 bool * ARG_UNUSED (no_add_attrs))
440 /* Ensure we have a function type. */
441 gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
443 /* Ensure we have a variadic function. */
444 gcc_assert (!prototype_p (*node) || stdarg_p (*node));
446 return NULL_TREE;
449 /* Handle a "transaction_pure" attribute. */
451 static tree
452 handle_transaction_pure_attribute (tree *node, tree ARG_UNUSED (name),
453 tree ARG_UNUSED (args),
454 int ARG_UNUSED (flags),
455 bool * ARG_UNUSED (no_add_attrs))
457 /* Ensure we have a function type. */
458 gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
460 return NULL_TREE;
463 /* Handle a "returns_twice" attribute. */
465 static tree
466 handle_returns_twice_attribute (tree *node, tree ARG_UNUSED (name),
467 tree ARG_UNUSED (args),
468 int ARG_UNUSED (flags),
469 bool * ARG_UNUSED (no_add_attrs))
471 gcc_assert (TREE_CODE (*node) == FUNCTION_DECL);
473 DECL_IS_RETURNS_TWICE (*node) = 1;
475 return NULL_TREE;
478 /* Ignore the given attribute. Used when this attribute may be usefully
479 overridden by the target, but is not used generically. */
481 static tree
482 ignore_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;
490 /* Handle a "format" attribute; arguments as in
491 struct attribute_spec.handler. */
493 static tree
494 handle_format_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
495 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
496 bool *no_add_attrs)
498 *no_add_attrs = true;
499 return NULL_TREE;
503 /* Handle a "format_arg" attribute; arguments as in
504 struct attribute_spec.handler. */
506 tree
507 handle_format_arg_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
508 tree ARG_UNUSED (args), int ARG_UNUSED (flags),
509 bool *no_add_attrs)
511 *no_add_attrs = true;
512 return NULL_TREE;
516 /* Handle a "fn spec" attribute; arguments as in
517 struct attribute_spec.handler. */
519 static tree
520 handle_fnspec_attribute (tree *node ATTRIBUTE_UNUSED, tree ARG_UNUSED (name),
521 tree args, int ARG_UNUSED (flags),
522 bool *no_add_attrs ATTRIBUTE_UNUSED)
524 gcc_assert (args
525 && TREE_CODE (TREE_VALUE (args)) == STRING_CST
526 && !TREE_CHAIN (args));
527 return NULL_TREE;
530 /* Cribbed from c-common.c. */
532 static void
533 def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...)
535 tree t;
536 tree *args = XALLOCAVEC (tree, n);
537 va_list list;
538 int i;
539 bool err = false;
541 va_start (list, n);
542 for (i = 0; i < n; ++i)
544 builtin_type a = (builtin_type) va_arg (list, int);
545 t = builtin_types[a];
546 if (t == error_mark_node)
547 err = true;
548 args[i] = t;
550 va_end (list);
552 t = builtin_types[ret];
553 if (err)
554 t = error_mark_node;
555 if (t == error_mark_node)
557 else if (var)
558 t = build_varargs_function_type_array (t, n, args);
559 else
560 t = build_function_type_array (t, n, args);
562 builtin_types[def] = t;
565 /* Used to help initialize the builtin-types.def table. When a type of
566 the correct size doesn't exist, use error_mark_node instead of NULL.
567 The later results in segfaults even when a decl using the type doesn't
568 get invoked. */
570 static tree
571 builtin_type_for_size (int size, bool unsignedp)
573 tree type = lto_type_for_size (size, unsignedp);
574 return type ? type : error_mark_node;
577 /* Support for DEF_BUILTIN. */
579 static void
580 def_builtin_1 (enum built_in_function fncode, const char *name,
581 enum built_in_class fnclass, tree fntype, tree libtype,
582 bool both_p, bool fallback_p, bool nonansi_p,
583 tree fnattrs, bool implicit_p)
585 tree decl;
586 const char *libname;
588 if (fntype == error_mark_node)
589 return;
591 libname = name + strlen ("__builtin_");
592 decl = add_builtin_function (name, fntype, fncode, fnclass,
593 (fallback_p ? libname : NULL),
594 fnattrs);
596 if (both_p
597 && !flag_no_builtin
598 && !(nonansi_p && flag_no_nonansi_builtin))
599 add_builtin_function (libname, libtype, fncode, fnclass,
600 NULL, fnattrs);
602 set_builtin_decl (fncode, decl, implicit_p);
606 /* Initialize the attribute table for all the supported builtins. */
608 static void
609 lto_init_attributes (void)
611 /* Fill in the built_in_attributes array. */
612 #define DEF_ATTR_NULL_TREE(ENUM) \
613 built_in_attributes[(int) ENUM] = NULL_TREE;
614 #define DEF_ATTR_INT(ENUM, VALUE) \
615 built_in_attributes[(int) ENUM] = build_int_cst (NULL_TREE, VALUE);
616 #define DEF_ATTR_STRING(ENUM, VALUE) \
617 built_in_attributes[(int) ENUM] = build_string (strlen (VALUE), VALUE);
618 #define DEF_ATTR_IDENT(ENUM, STRING) \
619 built_in_attributes[(int) ENUM] = get_identifier (STRING);
620 #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) \
621 built_in_attributes[(int) ENUM] \
622 = tree_cons (built_in_attributes[(int) PURPOSE], \
623 built_in_attributes[(int) VALUE], \
624 built_in_attributes[(int) CHAIN]);
625 #include "builtin-attrs.def"
626 #undef DEF_ATTR_NULL_TREE
627 #undef DEF_ATTR_INT
628 #undef DEF_ATTR_STRING
629 #undef DEF_ATTR_IDENT
630 #undef DEF_ATTR_TREE_LIST
633 /* Create builtin types and functions. VA_LIST_REF_TYPE_NODE and
634 VA_LIST_ARG_TYPE_NODE are used in builtin-types.def. */
636 static void
637 lto_define_builtins (tree va_list_ref_type_node ATTRIBUTE_UNUSED,
638 tree va_list_arg_type_node ATTRIBUTE_UNUSED)
640 #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \
641 builtin_types[ENUM] = VALUE;
642 #define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \
643 def_fn_type (ENUM, RETURN, 0, 0);
644 #define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \
645 def_fn_type (ENUM, RETURN, 0, 1, ARG1);
646 #define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \
647 def_fn_type (ENUM, RETURN, 0, 2, ARG1, ARG2);
648 #define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
649 def_fn_type (ENUM, RETURN, 0, 3, ARG1, ARG2, ARG3);
650 #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
651 def_fn_type (ENUM, RETURN, 0, 4, ARG1, ARG2, ARG3, ARG4);
652 #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
653 def_fn_type (ENUM, RETURN, 0, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
654 #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
655 ARG6) \
656 def_fn_type (ENUM, RETURN, 0, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
657 #define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
658 ARG6, ARG7) \
659 def_fn_type (ENUM, RETURN, 0, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7);
660 #define DEF_FUNCTION_TYPE_8(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \
661 ARG6, ARG7, ARG8) \
662 def_fn_type (ENUM, RETURN, 0, 8, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \
663 ARG7, ARG8);
664 #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \
665 def_fn_type (ENUM, RETURN, 1, 0);
666 #define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \
667 def_fn_type (ENUM, RETURN, 1, 1, ARG1);
668 #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \
669 def_fn_type (ENUM, RETURN, 1, 2, ARG1, ARG2);
670 #define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3) \
671 def_fn_type (ENUM, RETURN, 1, 3, ARG1, ARG2, ARG3);
672 #define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
673 def_fn_type (ENUM, RETURN, 1, 4, ARG1, ARG2, ARG3, ARG4);
674 #define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \
675 def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5);
676 #define DEF_POINTER_TYPE(ENUM, TYPE) \
677 builtin_types[(int) ENUM] = build_pointer_type (builtin_types[(int) TYPE]);
679 #include "builtin-types.def"
681 #undef DEF_PRIMITIVE_TYPE
682 #undef DEF_FUNCTION_TYPE_0
683 #undef DEF_FUNCTION_TYPE_1
684 #undef DEF_FUNCTION_TYPE_2
685 #undef DEF_FUNCTION_TYPE_3
686 #undef DEF_FUNCTION_TYPE_4
687 #undef DEF_FUNCTION_TYPE_5
688 #undef DEF_FUNCTION_TYPE_6
689 #undef DEF_FUNCTION_TYPE_7
690 #undef DEF_FUNCTION_TYPE_8
691 #undef DEF_FUNCTION_TYPE_VAR_0
692 #undef DEF_FUNCTION_TYPE_VAR_1
693 #undef DEF_FUNCTION_TYPE_VAR_2
694 #undef DEF_FUNCTION_TYPE_VAR_3
695 #undef DEF_FUNCTION_TYPE_VAR_4
696 #undef DEF_FUNCTION_TYPE_VAR_5
697 #undef DEF_POINTER_TYPE
698 builtin_types[(int) BT_LAST] = NULL_TREE;
700 lto_init_attributes ();
702 #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P,\
703 NONANSI_P, ATTRS, IMPLICIT, COND) \
704 if (NAME && COND) \
705 def_builtin_1 (ENUM, NAME, CLASS, builtin_types[(int) TYPE], \
706 builtin_types[(int) LIBTYPE], BOTH_P, FALLBACK_P, \
707 NONANSI_P, built_in_attributes[(int) ATTRS], IMPLICIT);
708 #include "builtins.def"
709 #undef DEF_BUILTIN
712 static GTY(()) tree registered_builtin_types;
714 /* Language hooks. */
716 static unsigned int
717 lto_option_lang_mask (void)
719 return CL_LTO;
722 static bool
723 lto_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED)
725 /* The LTO front end inherits all the options from the first front
726 end that was used. However, not all the original front end
727 options make sense in LTO.
729 A real solution would be to filter this in collect2, but collect2
730 does not have access to all the option attributes to know what to
731 filter. So, in lto1 we silently accept inherited flags and do
732 nothing about it. */
733 return false;
736 static void
737 lto_init_options_struct (struct gcc_options *opts)
739 /* By default, C99-like requirements for complex multiply and divide.
740 ??? Until the complex method is encoded in the IL this is the only
741 safe choice. This will pessimize Fortran code with LTO unless
742 people specify a complex method manually or use -ffast-math. */
743 opts->x_flag_complex_method = 2;
746 /* Handle command-line option SCODE. If the option takes an argument, it is
747 stored in ARG, which is otherwise NULL. VALUE holds either a numerical
748 argument or a binary value indicating whether the positive or negative form
749 of the option was supplied. */
751 const char *resolution_file_name;
752 static bool
753 lto_handle_option (size_t scode, const char *arg,
754 int value ATTRIBUTE_UNUSED, int kind ATTRIBUTE_UNUSED,
755 location_t loc ATTRIBUTE_UNUSED,
756 const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
758 enum opt_code code = (enum opt_code) scode;
759 bool result = true;
761 switch (code)
763 case OPT_fresolution_:
764 resolution_file_name = arg;
765 break;
767 case OPT_Wabi:
768 warn_psabi = value;
769 break;
771 case OPT_fwpa:
772 flag_wpa = value ? "" : NULL;
773 break;
775 default:
776 break;
779 return result;
782 /* Perform post-option processing. Does additional initialization based on
783 command-line options. PFILENAME is the main input filename. Returns false
784 to enable subsequent back-end initialization. */
786 static bool
787 lto_post_options (const char **pfilename ATTRIBUTE_UNUSED)
789 /* -fltrans and -fwpa are mutually exclusive. Check for that here. */
790 if (flag_wpa && flag_ltrans)
791 error ("-fwpa and -fltrans are mutually exclusive");
793 if (flag_ltrans)
795 flag_generate_lto = 0;
797 /* During LTRANS, we are not looking at the whole program, only
798 a subset of the whole callgraph. */
799 flag_whole_program = 0;
802 if (flag_wpa)
803 flag_generate_lto = 1;
805 /* Excess precision other than "fast" requires front-end
806 support. */
807 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
809 /* Initialize the compiler back end. */
810 return false;
813 /* Return an integer type with PRECISION bits of precision,
814 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
816 static tree
817 lto_type_for_size (unsigned precision, int unsignedp)
819 if (precision == TYPE_PRECISION (integer_type_node))
820 return unsignedp ? unsigned_type_node : integer_type_node;
822 if (precision == TYPE_PRECISION (signed_char_type_node))
823 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
825 if (precision == TYPE_PRECISION (short_integer_type_node))
826 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
828 if (precision == TYPE_PRECISION (long_integer_type_node))
829 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
831 if (precision == TYPE_PRECISION (long_long_integer_type_node))
832 return unsignedp
833 ? long_long_unsigned_type_node
834 : long_long_integer_type_node;
836 if (precision <= TYPE_PRECISION (intQI_type_node))
837 return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
839 if (precision <= TYPE_PRECISION (intHI_type_node))
840 return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
842 if (precision <= TYPE_PRECISION (intSI_type_node))
843 return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
845 if (precision <= TYPE_PRECISION (intDI_type_node))
846 return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
848 if (precision <= TYPE_PRECISION (intTI_type_node))
849 return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
851 return NULL_TREE;
855 /* Return a data type that has machine mode MODE.
856 If the mode is an integer,
857 then UNSIGNEDP selects between signed and unsigned types.
858 If the mode is a fixed-point mode,
859 then UNSIGNEDP selects between saturating and nonsaturating types. */
861 static tree
862 lto_type_for_mode (machine_mode mode, int unsigned_p)
864 tree t;
866 if (mode == TYPE_MODE (integer_type_node))
867 return unsigned_p ? unsigned_type_node : integer_type_node;
869 if (mode == TYPE_MODE (signed_char_type_node))
870 return unsigned_p ? unsigned_char_type_node : signed_char_type_node;
872 if (mode == TYPE_MODE (short_integer_type_node))
873 return unsigned_p ? short_unsigned_type_node : short_integer_type_node;
875 if (mode == TYPE_MODE (long_integer_type_node))
876 return unsigned_p ? long_unsigned_type_node : long_integer_type_node;
878 if (mode == TYPE_MODE (long_long_integer_type_node))
879 return unsigned_p ? long_long_unsigned_type_node : long_long_integer_type_node;
881 if (mode == QImode)
882 return unsigned_p ? unsigned_intQI_type_node : intQI_type_node;
884 if (mode == HImode)
885 return unsigned_p ? unsigned_intHI_type_node : intHI_type_node;
887 if (mode == SImode)
888 return unsigned_p ? unsigned_intSI_type_node : intSI_type_node;
890 if (mode == DImode)
891 return unsigned_p ? unsigned_intDI_type_node : intDI_type_node;
893 #if HOST_BITS_PER_WIDE_INT >= 64
894 if (mode == TYPE_MODE (intTI_type_node))
895 return unsigned_p ? unsigned_intTI_type_node : intTI_type_node;
896 #endif
898 if (mode == TYPE_MODE (float_type_node))
899 return float_type_node;
901 if (mode == TYPE_MODE (double_type_node))
902 return double_type_node;
904 if (mode == TYPE_MODE (long_double_type_node))
905 return long_double_type_node;
907 if (mode == TYPE_MODE (void_type_node))
908 return void_type_node;
910 if (mode == TYPE_MODE (build_pointer_type (char_type_node)))
911 return (unsigned_p
912 ? make_unsigned_type (GET_MODE_PRECISION (mode))
913 : make_signed_type (GET_MODE_PRECISION (mode)));
915 if (mode == TYPE_MODE (build_pointer_type (integer_type_node)))
916 return (unsigned_p
917 ? make_unsigned_type (GET_MODE_PRECISION (mode))
918 : make_signed_type (GET_MODE_PRECISION (mode)));
920 if (COMPLEX_MODE_P (mode))
922 machine_mode inner_mode;
923 tree inner_type;
925 if (mode == TYPE_MODE (complex_float_type_node))
926 return complex_float_type_node;
927 if (mode == TYPE_MODE (complex_double_type_node))
928 return complex_double_type_node;
929 if (mode == TYPE_MODE (complex_long_double_type_node))
930 return complex_long_double_type_node;
932 if (mode == TYPE_MODE (complex_integer_type_node) && !unsigned_p)
933 return complex_integer_type_node;
935 inner_mode = GET_MODE_INNER (mode);
936 inner_type = lto_type_for_mode (inner_mode, unsigned_p);
937 if (inner_type != NULL_TREE)
938 return build_complex_type (inner_type);
940 else if (VECTOR_MODE_P (mode))
942 machine_mode inner_mode = GET_MODE_INNER (mode);
943 tree inner_type = lto_type_for_mode (inner_mode, unsigned_p);
944 if (inner_type != NULL_TREE)
945 return build_vector_type_for_mode (inner_type, mode);
948 if (mode == TYPE_MODE (dfloat32_type_node))
949 return dfloat32_type_node;
950 if (mode == TYPE_MODE (dfloat64_type_node))
951 return dfloat64_type_node;
952 if (mode == TYPE_MODE (dfloat128_type_node))
953 return dfloat128_type_node;
955 if (ALL_SCALAR_FIXED_POINT_MODE_P (mode))
957 if (mode == TYPE_MODE (short_fract_type_node))
958 return unsigned_p ? sat_short_fract_type_node : short_fract_type_node;
959 if (mode == TYPE_MODE (fract_type_node))
960 return unsigned_p ? sat_fract_type_node : fract_type_node;
961 if (mode == TYPE_MODE (long_fract_type_node))
962 return unsigned_p ? sat_long_fract_type_node : long_fract_type_node;
963 if (mode == TYPE_MODE (long_long_fract_type_node))
964 return unsigned_p ? sat_long_long_fract_type_node
965 : long_long_fract_type_node;
967 if (mode == TYPE_MODE (unsigned_short_fract_type_node))
968 return unsigned_p ? sat_unsigned_short_fract_type_node
969 : unsigned_short_fract_type_node;
970 if (mode == TYPE_MODE (unsigned_fract_type_node))
971 return unsigned_p ? sat_unsigned_fract_type_node
972 : unsigned_fract_type_node;
973 if (mode == TYPE_MODE (unsigned_long_fract_type_node))
974 return unsigned_p ? sat_unsigned_long_fract_type_node
975 : unsigned_long_fract_type_node;
976 if (mode == TYPE_MODE (unsigned_long_long_fract_type_node))
977 return unsigned_p ? sat_unsigned_long_long_fract_type_node
978 : unsigned_long_long_fract_type_node;
980 if (mode == TYPE_MODE (short_accum_type_node))
981 return unsigned_p ? sat_short_accum_type_node : short_accum_type_node;
982 if (mode == TYPE_MODE (accum_type_node))
983 return unsigned_p ? sat_accum_type_node : accum_type_node;
984 if (mode == TYPE_MODE (long_accum_type_node))
985 return unsigned_p ? sat_long_accum_type_node : long_accum_type_node;
986 if (mode == TYPE_MODE (long_long_accum_type_node))
987 return unsigned_p ? sat_long_long_accum_type_node
988 : long_long_accum_type_node;
990 if (mode == TYPE_MODE (unsigned_short_accum_type_node))
991 return unsigned_p ? sat_unsigned_short_accum_type_node
992 : unsigned_short_accum_type_node;
993 if (mode == TYPE_MODE (unsigned_accum_type_node))
994 return unsigned_p ? sat_unsigned_accum_type_node
995 : unsigned_accum_type_node;
996 if (mode == TYPE_MODE (unsigned_long_accum_type_node))
997 return unsigned_p ? sat_unsigned_long_accum_type_node
998 : unsigned_long_accum_type_node;
999 if (mode == TYPE_MODE (unsigned_long_long_accum_type_node))
1000 return unsigned_p ? sat_unsigned_long_long_accum_type_node
1001 : unsigned_long_long_accum_type_node;
1003 if (mode == QQmode)
1004 return unsigned_p ? sat_qq_type_node : qq_type_node;
1005 if (mode == HQmode)
1006 return unsigned_p ? sat_hq_type_node : hq_type_node;
1007 if (mode == SQmode)
1008 return unsigned_p ? sat_sq_type_node : sq_type_node;
1009 if (mode == DQmode)
1010 return unsigned_p ? sat_dq_type_node : dq_type_node;
1011 if (mode == TQmode)
1012 return unsigned_p ? sat_tq_type_node : tq_type_node;
1014 if (mode == UQQmode)
1015 return unsigned_p ? sat_uqq_type_node : uqq_type_node;
1016 if (mode == UHQmode)
1017 return unsigned_p ? sat_uhq_type_node : uhq_type_node;
1018 if (mode == USQmode)
1019 return unsigned_p ? sat_usq_type_node : usq_type_node;
1020 if (mode == UDQmode)
1021 return unsigned_p ? sat_udq_type_node : udq_type_node;
1022 if (mode == UTQmode)
1023 return unsigned_p ? sat_utq_type_node : utq_type_node;
1025 if (mode == HAmode)
1026 return unsigned_p ? sat_ha_type_node : ha_type_node;
1027 if (mode == SAmode)
1028 return unsigned_p ? sat_sa_type_node : sa_type_node;
1029 if (mode == DAmode)
1030 return unsigned_p ? sat_da_type_node : da_type_node;
1031 if (mode == TAmode)
1032 return unsigned_p ? sat_ta_type_node : ta_type_node;
1034 if (mode == UHAmode)
1035 return unsigned_p ? sat_uha_type_node : uha_type_node;
1036 if (mode == USAmode)
1037 return unsigned_p ? sat_usa_type_node : usa_type_node;
1038 if (mode == UDAmode)
1039 return unsigned_p ? sat_uda_type_node : uda_type_node;
1040 if (mode == UTAmode)
1041 return unsigned_p ? sat_uta_type_node : uta_type_node;
1044 for (t = registered_builtin_types; t; t = TREE_CHAIN (t))
1045 if (TYPE_MODE (TREE_VALUE (t)) == mode)
1046 return TREE_VALUE (t);
1048 return NULL_TREE;
1051 /* Return true if we are in the global binding level. */
1053 static bool
1054 lto_global_bindings_p (void)
1056 return cfun == NULL;
1059 static void
1060 lto_set_decl_assembler_name (tree decl)
1062 /* This is almost the same as lhd_set_decl_assembler_name, except that
1063 we need to uniquify file-scope names, even if they are not
1064 TREE_PUBLIC, to avoid conflicts between individual files. */
1065 tree id;
1067 if (TREE_PUBLIC (decl))
1068 id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
1069 else
1071 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1072 char *label;
1074 ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
1075 id = get_identifier (label);
1078 SET_DECL_ASSEMBLER_NAME (decl, id);
1081 static tree
1082 lto_pushdecl (tree t ATTRIBUTE_UNUSED)
1084 /* Do nothing, since we get all information from DWARF and LTO
1085 sections. */
1086 return NULL_TREE;
1089 static tree
1090 lto_getdecls (void)
1092 /* We have our own write_globals langhook, hence the getdecls
1093 langhook shouldn't be used, except by dbxout.c, so we can't
1094 just abort here. */
1095 return NULL_TREE;
1098 static void
1099 lto_write_globals (void)
1101 if (flag_wpa)
1102 return;
1104 /* Output debug info for global variables. */
1105 varpool_node *vnode;
1106 FOR_EACH_DEFINED_VARIABLE (vnode)
1107 if (!decl_function_context (vnode->decl))
1108 debug_hooks->global_decl (vnode->decl);
1111 static tree
1112 lto_builtin_function (tree decl)
1114 return decl;
1117 static void
1118 lto_register_builtin_type (tree type, const char *name)
1120 tree decl;
1122 if (!TYPE_NAME (type))
1124 decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL,
1125 get_identifier (name), type);
1126 DECL_ARTIFICIAL (decl) = 1;
1127 TYPE_NAME (type) = decl;
1130 registered_builtin_types = tree_cons (0, type, registered_builtin_types);
1133 /* Build nodes that would have be created by the C front-end; necessary
1134 for including builtin-types.def and ultimately builtins.def. */
1136 static void
1137 lto_build_c_type_nodes (void)
1139 gcc_assert (void_type_node);
1141 void_list_node = build_tree_list (NULL_TREE, void_type_node);
1142 string_type_node = build_pointer_type (char_type_node);
1143 const_string_type_node
1144 = build_pointer_type (build_qualified_type (char_type_node, TYPE_QUAL_CONST));
1146 if (strcmp (SIZE_TYPE, "unsigned int") == 0)
1148 intmax_type_node = integer_type_node;
1149 uintmax_type_node = unsigned_type_node;
1150 signed_size_type_node = integer_type_node;
1152 else if (strcmp (SIZE_TYPE, "long unsigned int") == 0)
1154 intmax_type_node = long_integer_type_node;
1155 uintmax_type_node = long_unsigned_type_node;
1156 signed_size_type_node = long_integer_type_node;
1158 else if (strcmp (SIZE_TYPE, "long long unsigned int") == 0)
1160 intmax_type_node = long_long_integer_type_node;
1161 uintmax_type_node = long_long_unsigned_type_node;
1162 signed_size_type_node = long_long_integer_type_node;
1164 else
1166 int i;
1168 signed_size_type_node = NULL_TREE;
1169 for (i = 0; i < NUM_INT_N_ENTS; i++)
1170 if (int_n_enabled_p[i])
1172 char name[50];
1173 sprintf (name, "__int%d unsigned", int_n_data[i].bitsize);
1175 if (strcmp (name, SIZE_TYPE) == 0)
1177 intmax_type_node = int_n_trees[i].signed_type;
1178 uintmax_type_node = int_n_trees[i].unsigned_type;
1179 signed_size_type_node = int_n_trees[i].signed_type;
1182 if (signed_size_type_node == NULL_TREE)
1183 gcc_unreachable ();
1186 wint_type_node = unsigned_type_node;
1187 pid_type_node = integer_type_node;
1190 /* Perform LTO-specific initialization. */
1192 static bool
1193 lto_init (void)
1195 int i;
1197 /* We need to generate LTO if running in WPA mode. */
1198 flag_generate_lto = (flag_wpa != NULL);
1200 /* Create the basic integer types. */
1201 build_common_tree_nodes (flag_signed_char, flag_short_double);
1203 /* The global tree for the main identifier is filled in by
1204 language-specific front-end initialization that is not run in the
1205 LTO back-end. It appears that all languages that perform such
1206 initialization currently do so in the same way, so we do it here. */
1207 if (main_identifier_node == NULL_TREE)
1208 main_identifier_node = get_identifier ("main");
1210 /* In the C++ front-end, fileptr_type_node is defined as a variant
1211 copy of of ptr_type_node, rather than ptr_node itself. The
1212 distinction should only be relevant to the front-end, so we
1213 always use the C definition here in lto1. */
1214 gcc_assert (fileptr_type_node == ptr_type_node);
1215 gcc_assert (TYPE_MAIN_VARIANT (fileptr_type_node) == ptr_type_node);
1217 ptrdiff_type_node = integer_type_node;
1219 lto_build_c_type_nodes ();
1220 gcc_assert (va_list_type_node);
1222 if (TREE_CODE (va_list_type_node) == ARRAY_TYPE)
1224 tree x = build_pointer_type (TREE_TYPE (va_list_type_node));
1225 lto_define_builtins (x, x);
1227 else
1229 lto_define_builtins (build_reference_type (va_list_type_node),
1230 va_list_type_node);
1233 if (flag_cilkplus)
1234 cilk_init_builtins ();
1236 targetm.init_builtins ();
1237 build_common_builtin_nodes ();
1239 /* Assign names to the builtin types, otherwise they'll end up
1240 as __unknown__ in debug info.
1241 ??? We simply need to stop pre-seeding the streamer cache.
1242 Below is modeled after from c-common.c:c_common_nodes_and_builtins */
1243 #define NAME_TYPE(t,n) \
1244 if (t) \
1245 TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL, \
1246 get_identifier (n), t)
1247 NAME_TYPE (integer_type_node, "int");
1248 NAME_TYPE (char_type_node, "char");
1249 NAME_TYPE (long_integer_type_node, "long int");
1250 NAME_TYPE (unsigned_type_node, "unsigned int");
1251 NAME_TYPE (long_unsigned_type_node, "long unsigned int");
1252 NAME_TYPE (long_long_integer_type_node, "long long int");
1253 NAME_TYPE (long_long_unsigned_type_node, "long long unsigned int");
1254 NAME_TYPE (short_integer_type_node, "short int");
1255 NAME_TYPE (short_unsigned_type_node, "short unsigned int");
1256 if (signed_char_type_node != char_type_node)
1257 NAME_TYPE (signed_char_type_node, "signed char");
1258 if (unsigned_char_type_node != char_type_node)
1259 NAME_TYPE (unsigned_char_type_node, "unsigned char");
1260 NAME_TYPE (float_type_node, "float");
1261 NAME_TYPE (double_type_node, "double");
1262 NAME_TYPE (long_double_type_node, "long double");
1263 NAME_TYPE (void_type_node, "void");
1264 NAME_TYPE (boolean_type_node, "bool");
1265 NAME_TYPE (complex_float_type_node, "complex float");
1266 NAME_TYPE (complex_double_type_node, "complex double");
1267 NAME_TYPE (complex_long_double_type_node, "complex long double");
1268 for (i = 0; i < NUM_INT_N_ENTS; i++)
1269 if (int_n_enabled_p[i])
1271 char name[50];
1272 sprintf (name, "__int%d", int_n_data[i].bitsize);
1273 NAME_TYPE (int_n_trees[i].signed_type, name);
1275 #undef NAME_TYPE
1277 /* Initialize LTO-specific data structures. */
1278 in_lto_p = true;
1280 return true;
1283 /* Initialize tree structures required by the LTO front end. */
1285 static void lto_init_ts (void)
1287 tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1;
1290 #undef LANG_HOOKS_NAME
1291 #define LANG_HOOKS_NAME "GNU GIMPLE"
1292 #undef LANG_HOOKS_OPTION_LANG_MASK
1293 #define LANG_HOOKS_OPTION_LANG_MASK lto_option_lang_mask
1294 #undef LANG_HOOKS_COMPLAIN_WRONG_LANG_P
1295 #define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lto_complain_wrong_lang_p
1296 #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
1297 #define LANG_HOOKS_INIT_OPTIONS_STRUCT lto_init_options_struct
1298 #undef LANG_HOOKS_HANDLE_OPTION
1299 #define LANG_HOOKS_HANDLE_OPTION lto_handle_option
1300 #undef LANG_HOOKS_POST_OPTIONS
1301 #define LANG_HOOKS_POST_OPTIONS lto_post_options
1302 #undef LANG_HOOKS_GET_ALIAS_SET
1303 #define LANG_HOOKS_GET_ALIAS_SET gimple_get_alias_set
1304 #undef LANG_HOOKS_TYPE_FOR_MODE
1305 #define LANG_HOOKS_TYPE_FOR_MODE lto_type_for_mode
1306 #undef LANG_HOOKS_TYPE_FOR_SIZE
1307 #define LANG_HOOKS_TYPE_FOR_SIZE lto_type_for_size
1308 #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
1309 #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME lto_set_decl_assembler_name
1310 #undef LANG_HOOKS_GLOBAL_BINDINGS_P
1311 #define LANG_HOOKS_GLOBAL_BINDINGS_P lto_global_bindings_p
1312 #undef LANG_HOOKS_PUSHDECL
1313 #define LANG_HOOKS_PUSHDECL lto_pushdecl
1314 #undef LANG_HOOKS_GETDECLS
1315 #define LANG_HOOKS_GETDECLS lto_getdecls
1316 #undef LANG_HOOKS_WRITE_GLOBALS
1317 #define LANG_HOOKS_WRITE_GLOBALS lto_write_globals
1318 #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
1319 #define LANG_HOOKS_REGISTER_BUILTIN_TYPE lto_register_builtin_type
1320 #undef LANG_HOOKS_BUILTIN_FUNCTION
1321 #define LANG_HOOKS_BUILTIN_FUNCTION lto_builtin_function
1322 #undef LANG_HOOKS_INIT
1323 #define LANG_HOOKS_INIT lto_init
1324 #undef LANG_HOOKS_PARSE_FILE
1325 #define LANG_HOOKS_PARSE_FILE lto_main
1326 #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS
1327 #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS true
1328 #undef LANG_HOOKS_TYPES_COMPATIBLE_P
1329 #define LANG_HOOKS_TYPES_COMPATIBLE_P NULL
1330 #undef LANG_HOOKS_EH_PERSONALITY
1331 #define LANG_HOOKS_EH_PERSONALITY lto_eh_personality
1333 /* Attribute hooks. */
1334 #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE
1335 #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE lto_attribute_table
1336 #undef LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE
1337 #define LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE lto_format_attribute_table
1339 #undef LANG_HOOKS_BEGIN_SECTION
1340 #define LANG_HOOKS_BEGIN_SECTION lto_obj_begin_section
1341 #undef LANG_HOOKS_APPEND_DATA
1342 #define LANG_HOOKS_APPEND_DATA lto_obj_append_data
1343 #undef LANG_HOOKS_END_SECTION
1344 #define LANG_HOOKS_END_SECTION lto_obj_end_section
1346 #undef LANG_HOOKS_INIT_TS
1347 #define LANG_HOOKS_INIT_TS lto_init_ts
1349 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
1351 /* Language hooks that are not part of lang_hooks. */
1353 tree
1354 convert (tree type ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED)
1356 gcc_unreachable ();
1359 /* Tree walking support. */
1361 static enum lto_tree_node_structure_enum
1362 lto_tree_node_structure (union lang_tree_node *t ATTRIBUTE_UNUSED)
1364 return TS_LTO_GENERIC;
1367 #include "gtype-lto.h"
1368 #include "gt-lto-lto-lang.h"