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