OSDN Git Service

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