OSDN Git Service

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