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