]>
Commit | Line | Data |
---|---|---|
7bfefa9d | 1 | /* Language-dependent hooks for LTO. |
8e8f6434 | 2 | Copyright (C) 2009-2018 Free Software Foundation, Inc. |
7bfefa9d | 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" | |
4cba6f60 | 24 | #include "target.h" |
9ef16211 | 25 | #include "function.h" |
9ef16211 | 26 | #include "basic-block.h" |
7bfefa9d | 27 | #include "tree.h" |
9ef16211 | 28 | #include "gimple.h" |
4cba6f60 | 29 | #include "stringpool.h" |
4cba6f60 | 30 | #include "diagnostic-core.h" |
9ed99284 | 31 | #include "stor-layout.h" |
7bfefa9d | 32 | #include "langhooks.h" |
33 | #include "langhooks-def.h" | |
34 | #include "debug.h" | |
35 | #include "lto-tree.h" | |
36 | #include "lto.h" | |
30a86690 | 37 | #include "stringpool.h" |
38 | #include "attribs.h" | |
7bfefa9d | 39 | |
025fe22b | 40 | /* LTO specific dumps. */ |
41 | int lto_link_dump_id, decl_merge_dump_id, partition_dump_id; | |
42 | ||
7bfefa9d | 43 | static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *); |
4a68fd3c | 44 | static tree handle_leaf_attribute (tree *, tree, tree, int, bool *); |
7bfefa9d | 45 | static tree handle_const_attribute (tree *, tree, tree, int, bool *); |
46 | static tree handle_malloc_attribute (tree *, tree, tree, int, bool *); | |
47 | static tree handle_pure_attribute (tree *, tree, tree, int, bool *); | |
48 | static tree handle_novops_attribute (tree *, tree, tree, int, bool *); | |
49 | static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *); | |
50 | static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *); | |
51 | static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *); | |
52 | static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *); | |
ea0e88d1 | 53 | static tree handle_transaction_pure_attribute (tree *, tree, tree, int, bool *); |
3affb5a8 | 54 | static tree handle_returns_twice_attribute (tree *, tree, tree, int, bool *); |
e6c4532a | 55 | static tree handle_patchable_function_entry_attribute (tree *, tree, tree, |
56 | int, bool *); | |
c8c597a7 | 57 | static tree ignore_attribute (tree *, tree, tree, int, bool *); |
58 | ||
7bfefa9d | 59 | static tree handle_format_attribute (tree *, tree, tree, int, bool *); |
c8010b80 | 60 | static tree handle_fnspec_attribute (tree *, tree, tree, int, bool *); |
7bfefa9d | 61 | static tree handle_format_arg_attribute (tree *, tree, tree, int, bool *); |
62 | ||
dab0e385 | 63 | /* Helper to define attribute exclusions. */ |
64 | #define ATTR_EXCL(name, function, type, variable) \ | |
65 | { name, function, type, variable } | |
66 | ||
67 | /* Define attributes that are mutually exclusive with one another. */ | |
68 | static const struct attribute_spec::exclusions attr_noreturn_exclusions[] = | |
69 | { | |
70 | ATTR_EXCL ("noreturn", true, true, true), | |
71 | ATTR_EXCL ("alloc_align", true, true, true), | |
72 | ATTR_EXCL ("alloc_size", true, true, true), | |
73 | ATTR_EXCL ("const", true, true, true), | |
74 | ATTR_EXCL ("malloc", true, true, true), | |
75 | ATTR_EXCL ("pure", true, true, true), | |
76 | ATTR_EXCL ("returns_twice", true, true, true), | |
77 | ATTR_EXCL ("warn_unused_result", true, true, true), | |
78 | ATTR_EXCL (NULL, false, false, false), | |
79 | }; | |
80 | ||
81 | static const struct attribute_spec::exclusions attr_returns_twice_exclusions[] = | |
82 | { | |
83 | ATTR_EXCL ("noreturn", true, true, true), | |
84 | ATTR_EXCL (NULL, false, false, false), | |
85 | }; | |
86 | ||
87 | static const struct attribute_spec::exclusions attr_const_pure_exclusions[] = | |
88 | { | |
89 | ATTR_EXCL ("const", true, true, true), | |
90 | ATTR_EXCL ("noreturn", true, true, true), | |
91 | ATTR_EXCL ("pure", true, true, true), | |
92 | ATTR_EXCL (NULL, false, false, false) | |
93 | }; | |
94 | ||
7bfefa9d | 95 | /* Table of machine-independent attributes supported in GIMPLE. */ |
96 | const struct attribute_spec lto_attribute_table[] = | |
97 | { | |
672bc44d | 98 | /* { name, min_len, max_len, decl_req, type_req, fn_type_req, |
99 | affects_type_identity, handler, exclude } */ | |
100 | { "noreturn", 0, 0, true, false, false, false, | |
101 | handle_noreturn_attribute, | |
dab0e385 | 102 | attr_noreturn_exclusions }, |
672bc44d | 103 | { "leaf", 0, 0, true, false, false, false, |
104 | handle_leaf_attribute, NULL }, | |
7bfefa9d | 105 | /* The same comments as for noreturn attributes apply to const ones. */ |
672bc44d | 106 | { "const", 0, 0, true, false, false, false, |
107 | handle_const_attribute, | |
dab0e385 | 108 | attr_const_pure_exclusions }, |
672bc44d | 109 | { "malloc", 0, 0, true, false, false, false, |
110 | handle_malloc_attribute, NULL }, | |
111 | { "pure", 0, 0, true, false, false, false, | |
112 | handle_pure_attribute, | |
dab0e385 | 113 | attr_const_pure_exclusions }, |
672bc44d | 114 | { "no vops", 0, 0, true, false, false, false, |
115 | handle_novops_attribute, NULL }, | |
116 | { "nonnull", 0, -1, false, true, true, false, | |
117 | handle_nonnull_attribute, NULL }, | |
118 | { "nothrow", 0, 0, true, false, false, false, | |
119 | handle_nothrow_attribute, NULL }, | |
120 | { "patchable_function_entry", 1, 2, true, false, false, false, | |
e6c4532a | 121 | handle_patchable_function_entry_attribute, |
672bc44d | 122 | NULL }, |
123 | { "returns_twice", 0, 0, true, false, false, false, | |
124 | handle_returns_twice_attribute, | |
dab0e385 | 125 | attr_returns_twice_exclusions }, |
672bc44d | 126 | { "sentinel", 0, 1, false, true, true, false, |
127 | handle_sentinel_attribute, NULL }, | |
128 | { "type generic", 0, 0, false, true, true, false, | |
129 | handle_type_generic_attribute, NULL }, | |
130 | { "fn spec", 1, 1, false, true, true, false, | |
131 | handle_fnspec_attribute, NULL }, | |
132 | { "transaction_pure", 0, 0, false, true, true, false, | |
133 | handle_transaction_pure_attribute, NULL }, | |
c8c597a7 | 134 | /* For internal use only. The leading '*' both prevents its usage in |
135 | source code and signals that it may be overridden by machine tables. */ | |
672bc44d | 136 | { "*tm regparm", 0, 0, false, true, true, false, |
137 | ignore_attribute, NULL }, | |
138 | { NULL, 0, 0, false, false, false, false, NULL, NULL } | |
7bfefa9d | 139 | }; |
140 | ||
141 | /* Give the specifications for the format attributes, used by C and all | |
142 | descendants. */ | |
143 | ||
144 | const struct attribute_spec lto_format_attribute_table[] = | |
145 | { | |
672bc44d | 146 | /* { name, min_len, max_len, decl_req, type_req, fn_type_req, |
147 | affects_type_identity, handler, exclude } */ | |
148 | { "format", 3, 3, false, true, true, false, | |
149 | handle_format_attribute, NULL }, | |
150 | { "format_arg", 1, 1, false, true, true, false, | |
151 | handle_format_arg_attribute, NULL }, | |
152 | { NULL, 0, 0, false, false, false, false, NULL, NULL } | |
7bfefa9d | 153 | }; |
154 | ||
155 | enum built_in_attribute | |
156 | { | |
157 | #define DEF_ATTR_NULL_TREE(ENUM) ENUM, | |
158 | #define DEF_ATTR_INT(ENUM, VALUE) ENUM, | |
c8010b80 | 159 | #define DEF_ATTR_STRING(ENUM, VALUE) ENUM, |
7bfefa9d | 160 | #define DEF_ATTR_IDENT(ENUM, STRING) ENUM, |
161 | #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) ENUM, | |
162 | #include "builtin-attrs.def" | |
163 | #undef DEF_ATTR_NULL_TREE | |
164 | #undef DEF_ATTR_INT | |
c8010b80 | 165 | #undef DEF_ATTR_STRING |
7bfefa9d | 166 | #undef DEF_ATTR_IDENT |
167 | #undef DEF_ATTR_TREE_LIST | |
168 | ATTR_LAST | |
169 | }; | |
170 | ||
171 | static GTY(()) tree built_in_attributes[(int) ATTR_LAST]; | |
172 | ||
173 | /* Builtin types. */ | |
174 | ||
175 | enum lto_builtin_type | |
176 | { | |
177 | #define DEF_PRIMITIVE_TYPE(NAME, VALUE) NAME, | |
178 | #define DEF_FUNCTION_TYPE_0(NAME, RETURN) NAME, | |
179 | #define DEF_FUNCTION_TYPE_1(NAME, RETURN, ARG1) NAME, | |
180 | #define DEF_FUNCTION_TYPE_2(NAME, RETURN, ARG1, ARG2) NAME, | |
181 | #define DEF_FUNCTION_TYPE_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME, | |
182 | #define DEF_FUNCTION_TYPE_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME, | |
183 | #define DEF_FUNCTION_TYPE_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) NAME, | |
3c77ca67 | 184 | #define DEF_FUNCTION_TYPE_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
185 | ARG6) NAME, | |
186 | #define DEF_FUNCTION_TYPE_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ | |
187 | ARG6, ARG7) NAME, | |
188 | #define DEF_FUNCTION_TYPE_8(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ | |
189 | ARG6, ARG7, ARG8) NAME, | |
43895be5 | 190 | #define DEF_FUNCTION_TYPE_9(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
191 | ARG6, ARG7, ARG8, ARG9) NAME, | |
192 | #define DEF_FUNCTION_TYPE_10(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ | |
193 | ARG6, ARG7, ARG8, ARG9, ARG10) NAME, | |
194 | #define DEF_FUNCTION_TYPE_11(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ | |
195 | ARG6, ARG7, ARG8, ARG9, ARG10, ARG11) NAME, | |
7bfefa9d | 196 | #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME, |
197 | #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME, | |
198 | #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME, | |
199 | #define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME, | |
200 | #define DEF_FUNCTION_TYPE_VAR_4(NAME, RETURN, ARG1, ARG2, ARG3, ARG4) NAME, | |
201 | #define DEF_FUNCTION_TYPE_VAR_5(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG6) \ | |
6349b8cc | 202 | NAME, |
e561d5e1 | 203 | #define DEF_FUNCTION_TYPE_VAR_6(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
204 | ARG6) NAME, | |
6349b8cc | 205 | #define DEF_FUNCTION_TYPE_VAR_7(NAME, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
206 | ARG6, ARG7) NAME, | |
7bfefa9d | 207 | #define DEF_POINTER_TYPE(NAME, TYPE) NAME, |
208 | #include "builtin-types.def" | |
209 | #undef DEF_PRIMITIVE_TYPE | |
210 | #undef DEF_FUNCTION_TYPE_0 | |
211 | #undef DEF_FUNCTION_TYPE_1 | |
212 | #undef DEF_FUNCTION_TYPE_2 | |
213 | #undef DEF_FUNCTION_TYPE_3 | |
214 | #undef DEF_FUNCTION_TYPE_4 | |
215 | #undef DEF_FUNCTION_TYPE_5 | |
216 | #undef DEF_FUNCTION_TYPE_6 | |
217 | #undef DEF_FUNCTION_TYPE_7 | |
bc7bff74 | 218 | #undef DEF_FUNCTION_TYPE_8 |
43895be5 | 219 | #undef DEF_FUNCTION_TYPE_9 |
220 | #undef DEF_FUNCTION_TYPE_10 | |
221 | #undef DEF_FUNCTION_TYPE_11 | |
7bfefa9d | 222 | #undef DEF_FUNCTION_TYPE_VAR_0 |
223 | #undef DEF_FUNCTION_TYPE_VAR_1 | |
224 | #undef DEF_FUNCTION_TYPE_VAR_2 | |
225 | #undef DEF_FUNCTION_TYPE_VAR_3 | |
226 | #undef DEF_FUNCTION_TYPE_VAR_4 | |
227 | #undef DEF_FUNCTION_TYPE_VAR_5 | |
e561d5e1 | 228 | #undef DEF_FUNCTION_TYPE_VAR_6 |
6349b8cc | 229 | #undef DEF_FUNCTION_TYPE_VAR_7 |
7bfefa9d | 230 | #undef DEF_POINTER_TYPE |
231 | BT_LAST | |
232 | }; | |
233 | ||
234 | typedef enum lto_builtin_type builtin_type; | |
235 | ||
236 | static GTY(()) tree builtin_types[(int) BT_LAST + 1]; | |
237 | ||
238 | static GTY(()) tree string_type_node; | |
239 | static GTY(()) tree const_string_type_node; | |
240 | static GTY(()) tree wint_type_node; | |
241 | static GTY(()) tree intmax_type_node; | |
242 | static GTY(()) tree uintmax_type_node; | |
243 | static GTY(()) tree signed_size_type_node; | |
244 | ||
245 | /* Flags needed to process builtins.def. */ | |
7bfefa9d | 246 | int flag_isoc94; |
247 | int flag_isoc99; | |
060fc206 | 248 | int flag_isoc11; |
7bfefa9d | 249 | |
250 | /* Attribute handlers. */ | |
251 | ||
252 | /* Handle a "noreturn" attribute; arguments as in | |
253 | struct attribute_spec.handler. */ | |
254 | ||
255 | static tree | |
256 | handle_noreturn_attribute (tree *node, tree ARG_UNUSED (name), | |
257 | tree ARG_UNUSED (args), int ARG_UNUSED (flags), | |
258 | bool * ARG_UNUSED (no_add_attrs)) | |
259 | { | |
260 | tree type = TREE_TYPE (*node); | |
261 | ||
262 | if (TREE_CODE (*node) == FUNCTION_DECL) | |
263 | TREE_THIS_VOLATILE (*node) = 1; | |
264 | else if (TREE_CODE (type) == POINTER_TYPE | |
265 | && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE) | |
266 | TREE_TYPE (*node) | |
267 | = build_pointer_type | |
268 | (build_type_variant (TREE_TYPE (type), | |
269 | TYPE_READONLY (TREE_TYPE (type)), 1)); | |
270 | else | |
271 | gcc_unreachable (); | |
272 | ||
273 | return NULL_TREE; | |
274 | } | |
275 | ||
4a68fd3c | 276 | /* Handle a "leaf" attribute; arguments as in |
277 | struct attribute_spec.handler. */ | |
278 | ||
279 | static tree | |
280 | handle_leaf_attribute (tree *node, tree name, | |
281 | tree ARG_UNUSED (args), | |
282 | int ARG_UNUSED (flags), bool *no_add_attrs) | |
283 | { | |
284 | if (TREE_CODE (*node) != FUNCTION_DECL) | |
285 | { | |
286 | warning (OPT_Wattributes, "%qE attribute ignored", name); | |
287 | *no_add_attrs = true; | |
288 | } | |
289 | if (!TREE_PUBLIC (*node)) | |
290 | { | |
291 | warning (OPT_Wattributes, "%qE attribute has no effect on unit local functions", name); | |
292 | *no_add_attrs = true; | |
293 | } | |
294 | ||
295 | return NULL_TREE; | |
296 | } | |
7bfefa9d | 297 | |
298 | /* Handle a "const" attribute; arguments as in | |
299 | struct attribute_spec.handler. */ | |
300 | ||
301 | static tree | |
302 | handle_const_attribute (tree *node, tree ARG_UNUSED (name), | |
303 | tree ARG_UNUSED (args), int ARG_UNUSED (flags), | |
304 | bool * ARG_UNUSED (no_add_attrs)) | |
305 | { | |
dab0e385 | 306 | if (TREE_CODE (*node) != FUNCTION_DECL |
307 | || !DECL_BUILT_IN (*node)) | |
308 | inform (UNKNOWN_LOCATION, "%s:%s: %E: %E", __FILE__, __func__, *node, name); | |
309 | ||
7bfefa9d | 310 | tree type = TREE_TYPE (*node); |
311 | ||
312 | /* See FIXME comment on noreturn in c_common_attribute_table. */ | |
313 | if (TREE_CODE (*node) == FUNCTION_DECL) | |
314 | TREE_READONLY (*node) = 1; | |
315 | else if (TREE_CODE (type) == POINTER_TYPE | |
316 | && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE) | |
317 | TREE_TYPE (*node) | |
318 | = build_pointer_type | |
319 | (build_type_variant (TREE_TYPE (type), 1, | |
320 | TREE_THIS_VOLATILE (TREE_TYPE (type)))); | |
321 | else | |
322 | gcc_unreachable (); | |
323 | ||
324 | return NULL_TREE; | |
325 | } | |
326 | ||
327 | ||
328 | /* Handle a "malloc" attribute; arguments as in | |
329 | struct attribute_spec.handler. */ | |
330 | ||
331 | static tree | |
332 | handle_malloc_attribute (tree *node, tree ARG_UNUSED (name), | |
333 | tree ARG_UNUSED (args), int ARG_UNUSED (flags), | |
334 | bool * ARG_UNUSED (no_add_attrs)) | |
335 | { | |
336 | if (TREE_CODE (*node) == FUNCTION_DECL | |
337 | && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (*node)))) | |
338 | DECL_IS_MALLOC (*node) = 1; | |
339 | else | |
340 | gcc_unreachable (); | |
341 | ||
342 | return NULL_TREE; | |
343 | } | |
344 | ||
345 | ||
346 | /* Handle a "pure" attribute; arguments as in | |
347 | struct attribute_spec.handler. */ | |
348 | ||
349 | static tree | |
350 | handle_pure_attribute (tree *node, tree ARG_UNUSED (name), | |
351 | tree ARG_UNUSED (args), int ARG_UNUSED (flags), | |
352 | bool * ARG_UNUSED (no_add_attrs)) | |
353 | { | |
354 | if (TREE_CODE (*node) == FUNCTION_DECL) | |
355 | DECL_PURE_P (*node) = 1; | |
356 | else | |
357 | gcc_unreachable (); | |
358 | ||
359 | return NULL_TREE; | |
360 | } | |
361 | ||
362 | ||
363 | /* Handle a "no vops" attribute; arguments as in | |
364 | struct attribute_spec.handler. */ | |
365 | ||
366 | static tree | |
367 | handle_novops_attribute (tree *node, tree ARG_UNUSED (name), | |
368 | tree ARG_UNUSED (args), int ARG_UNUSED (flags), | |
369 | bool *ARG_UNUSED (no_add_attrs)) | |
370 | { | |
371 | gcc_assert (TREE_CODE (*node) == FUNCTION_DECL); | |
372 | DECL_IS_NOVOPS (*node) = 1; | |
373 | return NULL_TREE; | |
374 | } | |
375 | ||
376 | ||
377 | /* Helper for nonnull attribute handling; fetch the operand number | |
378 | from the attribute argument list. */ | |
379 | ||
380 | static bool | |
381 | get_nonnull_operand (tree arg_num_expr, unsigned HOST_WIDE_INT *valp) | |
382 | { | |
383 | /* Verify the arg number is a constant. */ | |
e1d65c9f | 384 | if (!tree_fits_uhwi_p (arg_num_expr)) |
7bfefa9d | 385 | return false; |
386 | ||
f9ae6f95 | 387 | *valp = TREE_INT_CST_LOW (arg_num_expr); |
7bfefa9d | 388 | return true; |
389 | } | |
390 | ||
391 | /* Handle the "nonnull" attribute. */ | |
392 | ||
393 | static tree | |
394 | handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name), | |
395 | tree args, int ARG_UNUSED (flags), | |
396 | bool * ARG_UNUSED (no_add_attrs)) | |
397 | { | |
398 | tree type = *node; | |
7bfefa9d | 399 | |
400 | /* If no arguments are specified, all pointer arguments should be | |
401 | non-null. Verify a full prototype is given so that the arguments | |
1dc4d519 | 402 | will have the correct types when we actually check them later. |
403 | Avoid diagnosing type-generic built-ins since those have no | |
404 | prototype. */ | |
7bfefa9d | 405 | if (!args) |
406 | { | |
1dc4d519 | 407 | gcc_assert (prototype_p (type) |
408 | || !TYPE_ATTRIBUTES (type) | |
409 | || lookup_attribute ("type generic", TYPE_ATTRIBUTES (type))); | |
410 | ||
7bfefa9d | 411 | return NULL_TREE; |
412 | } | |
413 | ||
414 | /* Argument list specified. Verify that each argument number references | |
415 | a pointer argument. */ | |
f018d957 | 416 | for (; args; args = TREE_CHAIN (args)) |
7bfefa9d | 417 | { |
418 | tree argument; | |
419 | unsigned HOST_WIDE_INT arg_num = 0, ck_num; | |
420 | ||
421 | if (!get_nonnull_operand (TREE_VALUE (args), &arg_num)) | |
422 | gcc_unreachable (); | |
423 | ||
424 | argument = TYPE_ARG_TYPES (type); | |
425 | if (argument) | |
426 | { | |
427 | for (ck_num = 1; ; ck_num++) | |
428 | { | |
429 | if (!argument || ck_num == arg_num) | |
430 | break; | |
431 | argument = TREE_CHAIN (argument); | |
432 | } | |
433 | ||
434 | gcc_assert (argument | |
435 | && TREE_CODE (TREE_VALUE (argument)) == POINTER_TYPE); | |
436 | } | |
437 | } | |
438 | ||
439 | return NULL_TREE; | |
440 | } | |
441 | ||
442 | ||
443 | /* Handle a "nothrow" attribute; arguments as in | |
444 | struct attribute_spec.handler. */ | |
445 | ||
446 | static tree | |
447 | handle_nothrow_attribute (tree *node, tree ARG_UNUSED (name), | |
448 | tree ARG_UNUSED (args), int ARG_UNUSED (flags), | |
449 | bool * ARG_UNUSED (no_add_attrs)) | |
450 | { | |
451 | if (TREE_CODE (*node) == FUNCTION_DECL) | |
452 | TREE_NOTHROW (*node) = 1; | |
453 | else | |
454 | gcc_unreachable (); | |
455 | ||
456 | return NULL_TREE; | |
457 | } | |
458 | ||
459 | ||
460 | /* Handle a "sentinel" attribute. */ | |
461 | ||
462 | static tree | |
463 | handle_sentinel_attribute (tree *node, tree ARG_UNUSED (name), tree args, | |
464 | int ARG_UNUSED (flags), | |
465 | bool * ARG_UNUSED (no_add_attrs)) | |
466 | { | |
c33080b9 | 467 | gcc_assert (stdarg_p (*node)); |
7bfefa9d | 468 | |
469 | if (args) | |
470 | { | |
471 | tree position = TREE_VALUE (args); | |
472 | gcc_assert (TREE_CODE (position) == INTEGER_CST); | |
473 | if (tree_int_cst_lt (position, integer_zero_node)) | |
474 | gcc_unreachable (); | |
475 | } | |
476 | ||
477 | return NULL_TREE; | |
478 | } | |
479 | ||
480 | /* Handle a "type_generic" attribute. */ | |
481 | ||
482 | static tree | |
483 | handle_type_generic_attribute (tree *node, tree ARG_UNUSED (name), | |
484 | tree ARG_UNUSED (args), int ARG_UNUSED (flags), | |
485 | bool * ARG_UNUSED (no_add_attrs)) | |
486 | { | |
7bfefa9d | 487 | /* Ensure we have a function type. */ |
488 | gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE); | |
489 | ||
7bfefa9d | 490 | /* Ensure we have a variadic function. */ |
c33080b9 | 491 | gcc_assert (!prototype_p (*node) || stdarg_p (*node)); |
7bfefa9d | 492 | |
493 | return NULL_TREE; | |
494 | } | |
495 | ||
ea0e88d1 | 496 | /* Handle a "transaction_pure" attribute. */ |
497 | ||
498 | static tree | |
499 | handle_transaction_pure_attribute (tree *node, tree ARG_UNUSED (name), | |
500 | tree ARG_UNUSED (args), | |
501 | int ARG_UNUSED (flags), | |
502 | bool * ARG_UNUSED (no_add_attrs)) | |
503 | { | |
504 | /* Ensure we have a function type. */ | |
505 | gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE); | |
506 | ||
507 | return NULL_TREE; | |
508 | } | |
509 | ||
3affb5a8 | 510 | /* Handle a "returns_twice" attribute. */ |
511 | ||
512 | static tree | |
513 | handle_returns_twice_attribute (tree *node, tree ARG_UNUSED (name), | |
514 | tree ARG_UNUSED (args), | |
515 | int ARG_UNUSED (flags), | |
516 | bool * ARG_UNUSED (no_add_attrs)) | |
517 | { | |
518 | gcc_assert (TREE_CODE (*node) == FUNCTION_DECL); | |
519 | ||
520 | DECL_IS_RETURNS_TWICE (*node) = 1; | |
521 | ||
522 | return NULL_TREE; | |
523 | } | |
524 | ||
e6c4532a | 525 | static tree |
526 | handle_patchable_function_entry_attribute (tree *, tree, tree, int, bool *) | |
527 | { | |
528 | /* Nothing to be done here. */ | |
529 | return NULL_TREE; | |
530 | } | |
531 | ||
c8c597a7 | 532 | /* Ignore the given attribute. Used when this attribute may be usefully |
533 | overridden by the target, but is not used generically. */ | |
534 | ||
535 | static tree | |
536 | ignore_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name), | |
537 | tree ARG_UNUSED (args), int ARG_UNUSED (flags), | |
538 | bool *no_add_attrs) | |
539 | { | |
540 | *no_add_attrs = true; | |
541 | return NULL_TREE; | |
542 | } | |
543 | ||
7bfefa9d | 544 | /* Handle a "format" attribute; arguments as in |
545 | struct attribute_spec.handler. */ | |
546 | ||
547 | static tree | |
548 | handle_format_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name), | |
549 | tree ARG_UNUSED (args), int ARG_UNUSED (flags), | |
550 | bool *no_add_attrs) | |
551 | { | |
552 | *no_add_attrs = true; | |
553 | return NULL_TREE; | |
554 | } | |
555 | ||
556 | ||
557 | /* Handle a "format_arg" attribute; arguments as in | |
558 | struct attribute_spec.handler. */ | |
559 | ||
560 | tree | |
561 | handle_format_arg_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name), | |
562 | tree ARG_UNUSED (args), int ARG_UNUSED (flags), | |
563 | bool *no_add_attrs) | |
564 | { | |
565 | *no_add_attrs = true; | |
566 | return NULL_TREE; | |
567 | } | |
568 | ||
569 | ||
c8010b80 | 570 | /* Handle a "fn spec" attribute; arguments as in |
571 | struct attribute_spec.handler. */ | |
572 | ||
573 | static tree | |
574 | handle_fnspec_attribute (tree *node ATTRIBUTE_UNUSED, tree ARG_UNUSED (name), | |
575 | tree args, int ARG_UNUSED (flags), | |
576 | bool *no_add_attrs ATTRIBUTE_UNUSED) | |
577 | { | |
578 | gcc_assert (args | |
579 | && TREE_CODE (TREE_VALUE (args)) == STRING_CST | |
580 | && !TREE_CHAIN (args)); | |
581 | return NULL_TREE; | |
582 | } | |
583 | ||
7bfefa9d | 584 | /* Cribbed from c-common.c. */ |
585 | ||
586 | static void | |
587 | def_fn_type (builtin_type def, builtin_type ret, bool var, int n, ...) | |
588 | { | |
3a939d12 | 589 | tree t; |
590 | tree *args = XALLOCAVEC (tree, n); | |
7bfefa9d | 591 | va_list list; |
592 | int i; | |
62cc770a | 593 | bool err = false; |
7bfefa9d | 594 | |
595 | va_start (list, n); | |
596 | for (i = 0; i < n; ++i) | |
597 | { | |
598 | builtin_type a = (builtin_type) va_arg (list, int); | |
599 | t = builtin_types[a]; | |
600 | if (t == error_mark_node) | |
62cc770a | 601 | err = true; |
3a939d12 | 602 | args[i] = t; |
7bfefa9d | 603 | } |
604 | va_end (list); | |
605 | ||
7bfefa9d | 606 | t = builtin_types[ret]; |
62cc770a | 607 | if (err) |
608 | t = error_mark_node; | |
7bfefa9d | 609 | if (t == error_mark_node) |
62cc770a | 610 | ; |
611 | else if (var) | |
3a939d12 | 612 | t = build_varargs_function_type_array (t, n, args); |
613 | else | |
614 | t = build_function_type_array (t, n, args); | |
7bfefa9d | 615 | |
7bfefa9d | 616 | builtin_types[def] = t; |
617 | } | |
618 | ||
619 | /* Used to help initialize the builtin-types.def table. When a type of | |
620 | the correct size doesn't exist, use error_mark_node instead of NULL. | |
621 | The later results in segfaults even when a decl using the type doesn't | |
622 | get invoked. */ | |
623 | ||
624 | static tree | |
625 | builtin_type_for_size (int size, bool unsignedp) | |
626 | { | |
8950f928 | 627 | tree type = lang_hooks.types.type_for_size (size, unsignedp); |
7bfefa9d | 628 | return type ? type : error_mark_node; |
629 | } | |
630 | ||
631 | /* Support for DEF_BUILTIN. */ | |
632 | ||
633 | static void | |
634 | def_builtin_1 (enum built_in_function fncode, const char *name, | |
635 | enum built_in_class fnclass, tree fntype, tree libtype, | |
636 | bool both_p, bool fallback_p, bool nonansi_p, | |
637 | tree fnattrs, bool implicit_p) | |
638 | { | |
639 | tree decl; | |
640 | const char *libname; | |
641 | ||
642 | if (fntype == error_mark_node) | |
643 | return; | |
644 | ||
645 | libname = name + strlen ("__builtin_"); | |
646 | decl = add_builtin_function (name, fntype, fncode, fnclass, | |
647 | (fallback_p ? libname : NULL), | |
648 | fnattrs); | |
649 | ||
650 | if (both_p | |
651 | && !flag_no_builtin | |
652 | && !(nonansi_p && flag_no_nonansi_builtin)) | |
653 | add_builtin_function (libname, libtype, fncode, fnclass, | |
654 | NULL, fnattrs); | |
655 | ||
b9a16870 | 656 | set_builtin_decl (fncode, decl, implicit_p); |
7bfefa9d | 657 | } |
658 | ||
659 | ||
660 | /* Initialize the attribute table for all the supported builtins. */ | |
661 | ||
662 | static void | |
663 | lto_init_attributes (void) | |
664 | { | |
665 | /* Fill in the built_in_attributes array. */ | |
666 | #define DEF_ATTR_NULL_TREE(ENUM) \ | |
667 | built_in_attributes[(int) ENUM] = NULL_TREE; | |
668 | #define DEF_ATTR_INT(ENUM, VALUE) \ | |
669 | built_in_attributes[(int) ENUM] = build_int_cst (NULL_TREE, VALUE); | |
c8010b80 | 670 | #define DEF_ATTR_STRING(ENUM, VALUE) \ |
671 | built_in_attributes[(int) ENUM] = build_string (strlen (VALUE), VALUE); | |
7bfefa9d | 672 | #define DEF_ATTR_IDENT(ENUM, STRING) \ |
673 | built_in_attributes[(int) ENUM] = get_identifier (STRING); | |
674 | #define DEF_ATTR_TREE_LIST(ENUM, PURPOSE, VALUE, CHAIN) \ | |
675 | built_in_attributes[(int) ENUM] \ | |
676 | = tree_cons (built_in_attributes[(int) PURPOSE], \ | |
677 | built_in_attributes[(int) VALUE], \ | |
678 | built_in_attributes[(int) CHAIN]); | |
679 | #include "builtin-attrs.def" | |
680 | #undef DEF_ATTR_NULL_TREE | |
681 | #undef DEF_ATTR_INT | |
c8010b80 | 682 | #undef DEF_ATTR_STRING |
7bfefa9d | 683 | #undef DEF_ATTR_IDENT |
684 | #undef DEF_ATTR_TREE_LIST | |
685 | } | |
686 | ||
687 | /* Create builtin types and functions. VA_LIST_REF_TYPE_NODE and | |
688 | VA_LIST_ARG_TYPE_NODE are used in builtin-types.def. */ | |
689 | ||
690 | static void | |
691 | lto_define_builtins (tree va_list_ref_type_node ATTRIBUTE_UNUSED, | |
692 | tree va_list_arg_type_node ATTRIBUTE_UNUSED) | |
693 | { | |
694 | #define DEF_PRIMITIVE_TYPE(ENUM, VALUE) \ | |
695 | builtin_types[ENUM] = VALUE; | |
696 | #define DEF_FUNCTION_TYPE_0(ENUM, RETURN) \ | |
697 | def_fn_type (ENUM, RETURN, 0, 0); | |
698 | #define DEF_FUNCTION_TYPE_1(ENUM, RETURN, ARG1) \ | |
699 | def_fn_type (ENUM, RETURN, 0, 1, ARG1); | |
700 | #define DEF_FUNCTION_TYPE_2(ENUM, RETURN, ARG1, ARG2) \ | |
701 | def_fn_type (ENUM, RETURN, 0, 2, ARG1, ARG2); | |
702 | #define DEF_FUNCTION_TYPE_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ | |
703 | def_fn_type (ENUM, RETURN, 0, 3, ARG1, ARG2, ARG3); | |
704 | #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ | |
705 | def_fn_type (ENUM, RETURN, 0, 4, ARG1, ARG2, ARG3, ARG4); | |
706 | #define DEF_FUNCTION_TYPE_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \ | |
707 | def_fn_type (ENUM, RETURN, 0, 5, ARG1, ARG2, ARG3, ARG4, ARG5); | |
708 | #define DEF_FUNCTION_TYPE_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ | |
709 | ARG6) \ | |
710 | def_fn_type (ENUM, RETURN, 0, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); | |
711 | #define DEF_FUNCTION_TYPE_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ | |
712 | ARG6, ARG7) \ | |
713 | def_fn_type (ENUM, RETURN, 0, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7); | |
bc7bff74 | 714 | #define DEF_FUNCTION_TYPE_8(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
715 | ARG6, ARG7, ARG8) \ | |
716 | def_fn_type (ENUM, RETURN, 0, 8, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \ | |
717 | ARG7, ARG8); | |
43895be5 | 718 | #define DEF_FUNCTION_TYPE_9(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
719 | ARG6, ARG7, ARG8, ARG9) \ | |
720 | def_fn_type (ENUM, RETURN, 0, 9, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \ | |
721 | ARG7, ARG8, ARG9); | |
722 | #define DEF_FUNCTION_TYPE_10(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ | |
723 | ARG6, ARG7, ARG8, ARG9, ARG10) \ | |
724 | def_fn_type (ENUM, RETURN, 0, 10, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \ | |
725 | ARG7, ARG8, ARG9, ARG10); | |
726 | #define DEF_FUNCTION_TYPE_11(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ | |
727 | ARG6, ARG7, ARG8, ARG9, ARG10, ARG11) \ | |
728 | def_fn_type (ENUM, RETURN, 0, 11, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, \ | |
729 | ARG7, ARG8, ARG9, ARG10, ARG11); | |
7bfefa9d | 730 | #define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN) \ |
731 | def_fn_type (ENUM, RETURN, 1, 0); | |
732 | #define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1) \ | |
733 | def_fn_type (ENUM, RETURN, 1, 1, ARG1); | |
734 | #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \ | |
735 | def_fn_type (ENUM, RETURN, 1, 2, ARG1, ARG2); | |
736 | #define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3) \ | |
737 | def_fn_type (ENUM, RETURN, 1, 3, ARG1, ARG2, ARG3); | |
738 | #define DEF_FUNCTION_TYPE_VAR_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ | |
739 | def_fn_type (ENUM, RETURN, 1, 4, ARG1, ARG2, ARG3, ARG4); | |
740 | #define DEF_FUNCTION_TYPE_VAR_5(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5) \ | |
741 | def_fn_type (ENUM, RETURN, 1, 5, ARG1, ARG2, ARG3, ARG4, ARG5); | |
e561d5e1 | 742 | #define DEF_FUNCTION_TYPE_VAR_6(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
743 | ARG6) \ | |
744 | def_fn_type (ENUM, RETURN, 1, 6, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6); | |
6349b8cc | 745 | #define DEF_FUNCTION_TYPE_VAR_7(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4, ARG5, \ |
746 | ARG6, ARG7) \ | |
747 | def_fn_type (ENUM, RETURN, 1, 7, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7); | |
7bfefa9d | 748 | #define DEF_POINTER_TYPE(ENUM, TYPE) \ |
749 | builtin_types[(int) ENUM] = build_pointer_type (builtin_types[(int) TYPE]); | |
750 | ||
751 | #include "builtin-types.def" | |
752 | ||
753 | #undef DEF_PRIMITIVE_TYPE | |
3c77ca67 | 754 | #undef DEF_FUNCTION_TYPE_0 |
7bfefa9d | 755 | #undef DEF_FUNCTION_TYPE_1 |
756 | #undef DEF_FUNCTION_TYPE_2 | |
757 | #undef DEF_FUNCTION_TYPE_3 | |
758 | #undef DEF_FUNCTION_TYPE_4 | |
759 | #undef DEF_FUNCTION_TYPE_5 | |
760 | #undef DEF_FUNCTION_TYPE_6 | |
3c77ca67 | 761 | #undef DEF_FUNCTION_TYPE_7 |
762 | #undef DEF_FUNCTION_TYPE_8 | |
43895be5 | 763 | #undef DEF_FUNCTION_TYPE_9 |
764 | #undef DEF_FUNCTION_TYPE_10 | |
765 | #undef DEF_FUNCTION_TYPE_11 | |
7bfefa9d | 766 | #undef DEF_FUNCTION_TYPE_VAR_0 |
767 | #undef DEF_FUNCTION_TYPE_VAR_1 | |
768 | #undef DEF_FUNCTION_TYPE_VAR_2 | |
769 | #undef DEF_FUNCTION_TYPE_VAR_3 | |
770 | #undef DEF_FUNCTION_TYPE_VAR_4 | |
771 | #undef DEF_FUNCTION_TYPE_VAR_5 | |
e561d5e1 | 772 | #undef DEF_FUNCTION_TYPE_VAR_6 |
6349b8cc | 773 | #undef DEF_FUNCTION_TYPE_VAR_7 |
7bfefa9d | 774 | #undef DEF_POINTER_TYPE |
775 | builtin_types[(int) BT_LAST] = NULL_TREE; | |
776 | ||
777 | lto_init_attributes (); | |
778 | ||
779 | #define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P,\ | |
780 | NONANSI_P, ATTRS, IMPLICIT, COND) \ | |
781 | if (NAME && COND) \ | |
782 | def_builtin_1 (ENUM, NAME, CLASS, builtin_types[(int) TYPE], \ | |
783 | builtin_types[(int) LIBTYPE], BOTH_P, FALLBACK_P, \ | |
784 | NONANSI_P, built_in_attributes[(int) ATTRS], IMPLICIT); | |
785 | #include "builtins.def" | |
7bfefa9d | 786 | } |
787 | ||
788 | static GTY(()) tree registered_builtin_types; | |
789 | ||
7bfefa9d | 790 | /* Language hooks. */ |
791 | ||
792 | static unsigned int | |
e88d34f6 | 793 | lto_option_lang_mask (void) |
794 | { | |
795 | return CL_LTO; | |
796 | } | |
797 | ||
798 | static bool | |
799 | lto_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED) | |
800 | { | |
801 | /* The LTO front end inherits all the options from the first front | |
802 | end that was used. However, not all the original front end | |
803 | options make sense in LTO. | |
804 | ||
805 | A real solution would be to filter this in collect2, but collect2 | |
806 | does not have access to all the option attributes to know what to | |
807 | filter. So, in lto1 we silently accept inherited flags and do | |
808 | nothing about it. */ | |
809 | return false; | |
810 | } | |
811 | ||
812 | static void | |
f3f006ad | 813 | lto_init_options_struct (struct gcc_options *opts) |
7bfefa9d | 814 | { |
97e90c2e | 815 | /* By default, C99-like requirements for complex multiply and divide. |
816 | ??? Until the complex method is encoded in the IL this is the only | |
817 | safe choice. This will pessimize Fortran code with LTO unless | |
818 | people specify a complex method manually or use -ffast-math. */ | |
f3f006ad | 819 | opts->x_flag_complex_method = 2; |
7bfefa9d | 820 | } |
821 | ||
822 | /* Handle command-line option SCODE. If the option takes an argument, it is | |
823 | stored in ARG, which is otherwise NULL. VALUE holds either a numerical | |
824 | argument or a binary value indicating whether the positive or negative form | |
825 | of the option was supplied. */ | |
826 | ||
827 | const char *resolution_file_name; | |
b78351e5 | 828 | static bool |
11dc3713 | 829 | lto_handle_option (size_t scode, const char *arg, |
8e18705e | 830 | HOST_WIDE_INT value ATTRIBUTE_UNUSED, |
831 | int kind ATTRIBUTE_UNUSED, | |
3c6c0e40 | 832 | location_t loc ATTRIBUTE_UNUSED, |
b78351e5 | 833 | const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED) |
7bfefa9d | 834 | { |
835 | enum opt_code code = (enum opt_code) scode; | |
b78351e5 | 836 | bool result = true; |
7bfefa9d | 837 | |
838 | switch (code) | |
839 | { | |
eb4ef3d1 | 840 | case OPT_fresolution_: |
7bfefa9d | 841 | resolution_file_name = arg; |
7bfefa9d | 842 | break; |
843 | ||
844 | case OPT_Wabi: | |
845 | warn_psabi = value; | |
846 | break; | |
847 | ||
3e17769e | 848 | case OPT_fwpa: |
849 | flag_wpa = value ? "" : NULL; | |
850 | break; | |
851 | ||
7bfefa9d | 852 | default: |
853 | break; | |
854 | } | |
855 | ||
856 | return result; | |
857 | } | |
858 | ||
859 | /* Perform post-option processing. Does additional initialization based on | |
860 | command-line options. PFILENAME is the main input filename. Returns false | |
861 | to enable subsequent back-end initialization. */ | |
862 | ||
863 | static bool | |
864 | lto_post_options (const char **pfilename ATTRIBUTE_UNUSED) | |
865 | { | |
7bfefa9d | 866 | /* -fltrans and -fwpa are mutually exclusive. Check for that here. */ |
867 | if (flag_wpa && flag_ltrans) | |
48cf7037 | 868 | error ("-fwpa and -fltrans are mutually exclusive"); |
7bfefa9d | 869 | |
870 | if (flag_ltrans) | |
871 | { | |
872 | flag_generate_lto = 0; | |
873 | ||
874 | /* During LTRANS, we are not looking at the whole program, only | |
875 | a subset of the whole callgraph. */ | |
876 | flag_whole_program = 0; | |
877 | } | |
878 | ||
879 | if (flag_wpa) | |
880 | flag_generate_lto = 1; | |
881 | ||
4c4a180d | 882 | /* Initialize the codegen flags according to the output type. */ |
883 | switch (flag_lto_linker_output) | |
884 | { | |
885 | case LTO_LINKER_OUTPUT_REL: /* .o: incremental link producing LTO IL */ | |
278cec16 | 886 | /* Configure compiler same way as normal frontend would do with -flto: |
887 | this way we read the trees (declarations & types), symbol table, | |
888 | optimization summaries and link them. Subsequently we output new LTO | |
889 | file. */ | |
890 | flag_lto = ""; | |
891 | flag_incremental_link = INCREMENTAL_LINK_LTO; | |
4c4a180d | 892 | flag_whole_program = 0; |
278cec16 | 893 | flag_wpa = 0; |
894 | flag_generate_lto = 1; | |
895 | /* It would be cool to produce .o file directly, but our current | |
896 | simple objects does not contain the lto symbol markers. Go the slow | |
897 | way through the asm file. */ | |
898 | lang_hooks.lto.begin_section = lhd_begin_section; | |
899 | lang_hooks.lto.append_data = lhd_append_data; | |
900 | lang_hooks.lto.end_section = lhd_end_section; | |
901 | if (flag_ltrans) | |
902 | error ("-flinker-output=rel and -fltrans are mutually exclussive"); | |
903 | break; | |
904 | ||
905 | case LTO_LINKER_OUTPUT_NOLTOREL: /* .o: incremental link producing asm */ | |
906 | flag_whole_program = 0; | |
907 | flag_incremental_link = INCREMENTAL_LINK_NOLTO; | |
4c4a180d | 908 | break; |
909 | ||
910 | case LTO_LINKER_OUTPUT_DYN: /* .so: PID library */ | |
911 | /* On some targets, like i386 it makes sense to build PIC library wihout | |
912 | -fpic for performance reasons. So no need to adjust flags. */ | |
913 | break; | |
914 | ||
915 | case LTO_LINKER_OUTPUT_PIE: /* PIE binary */ | |
916 | /* If -fPIC or -fPIE was used at compile time, be sure that | |
917 | flag_pie is 2. */ | |
918 | flag_pie = MAX (flag_pie, flag_pic); | |
21dae9f7 | 919 | flag_pic = flag_pie; |
12f79006 | 920 | flag_shlib = 0; |
4c4a180d | 921 | break; |
922 | ||
923 | case LTO_LINKER_OUTPUT_EXEC: /* Normal executable */ | |
924 | flag_pic = 0; | |
925 | flag_pie = 0; | |
12f79006 | 926 | flag_shlib = 0; |
4c4a180d | 927 | break; |
928 | ||
929 | case LTO_LINKER_OUTPUT_UNKNOWN: | |
930 | break; | |
931 | } | |
932 | ||
7bfefa9d | 933 | /* Excess precision other than "fast" requires front-end |
934 | support. */ | |
935 | flag_excess_precision_cmdline = EXCESS_PRECISION_FAST; | |
936 | ||
2236cf7a | 937 | /* When partitioning, we can tear appart STRING_CSTs uses from the same |
938 | TU into multiple partitions. Without constant merging the constants | |
939 | might not be equal at runtime. See PR50199. */ | |
940 | if (!flag_merge_constants) | |
941 | flag_merge_constants = 1; | |
942 | ||
7bfefa9d | 943 | /* Initialize the compiler back end. */ |
944 | return false; | |
945 | } | |
946 | ||
7bfefa9d | 947 | /* Return a data type that has machine mode MODE. |
948 | If the mode is an integer, | |
949 | then UNSIGNEDP selects between signed and unsigned types. | |
950 | If the mode is a fixed-point mode, | |
951 | then UNSIGNEDP selects between saturating and nonsaturating types. */ | |
952 | ||
953 | static tree | |
3754d046 | 954 | lto_type_for_mode (machine_mode mode, int unsigned_p) |
7bfefa9d | 955 | { |
956 | tree t; | |
8f88884c | 957 | int i; |
7bfefa9d | 958 | |
959 | if (mode == TYPE_MODE (integer_type_node)) | |
960 | return unsigned_p ? unsigned_type_node : integer_type_node; | |
961 | ||
962 | if (mode == TYPE_MODE (signed_char_type_node)) | |
963 | return unsigned_p ? unsigned_char_type_node : signed_char_type_node; | |
964 | ||
965 | if (mode == TYPE_MODE (short_integer_type_node)) | |
966 | return unsigned_p ? short_unsigned_type_node : short_integer_type_node; | |
967 | ||
968 | if (mode == TYPE_MODE (long_integer_type_node)) | |
969 | return unsigned_p ? long_unsigned_type_node : long_integer_type_node; | |
970 | ||
971 | if (mode == TYPE_MODE (long_long_integer_type_node)) | |
972 | return unsigned_p ? long_long_unsigned_type_node : long_long_integer_type_node; | |
973 | ||
8f88884c | 974 | for (i = 0; i < NUM_INT_N_ENTS; i ++) |
975 | if (int_n_enabled_p[i] | |
976 | && mode == int_n_data[i].m) | |
977 | return (unsigned_p ? int_n_trees[i].unsigned_type | |
978 | : int_n_trees[i].signed_type); | |
979 | ||
7bfefa9d | 980 | if (mode == QImode) |
981 | return unsigned_p ? unsigned_intQI_type_node : intQI_type_node; | |
982 | ||
983 | if (mode == HImode) | |
984 | return unsigned_p ? unsigned_intHI_type_node : intHI_type_node; | |
985 | ||
986 | if (mode == SImode) | |
987 | return unsigned_p ? unsigned_intSI_type_node : intSI_type_node; | |
988 | ||
989 | if (mode == DImode) | |
990 | return unsigned_p ? unsigned_intDI_type_node : intDI_type_node; | |
991 | ||
992 | #if HOST_BITS_PER_WIDE_INT >= 64 | |
993 | if (mode == TYPE_MODE (intTI_type_node)) | |
994 | return unsigned_p ? unsigned_intTI_type_node : intTI_type_node; | |
995 | #endif | |
996 | ||
997 | if (mode == TYPE_MODE (float_type_node)) | |
998 | return float_type_node; | |
999 | ||
1000 | if (mode == TYPE_MODE (double_type_node)) | |
1001 | return double_type_node; | |
1002 | ||
1003 | if (mode == TYPE_MODE (long_double_type_node)) | |
1004 | return long_double_type_node; | |
1005 | ||
1006 | if (mode == TYPE_MODE (void_type_node)) | |
1007 | return void_type_node; | |
1008 | ||
7a6aeeed | 1009 | if (mode == TYPE_MODE (build_pointer_type (char_type_node)) |
1010 | || mode == TYPE_MODE (build_pointer_type (integer_type_node))) | |
1011 | { | |
1012 | unsigned int precision | |
1013 | = GET_MODE_PRECISION (as_a <scalar_int_mode> (mode)); | |
1014 | return (unsigned_p | |
1015 | ? make_unsigned_type (precision) | |
1016 | : make_signed_type (precision)); | |
1017 | } | |
7bfefa9d | 1018 | |
1019 | if (COMPLEX_MODE_P (mode)) | |
1020 | { | |
3754d046 | 1021 | machine_mode inner_mode; |
7bfefa9d | 1022 | tree inner_type; |
1023 | ||
1024 | if (mode == TYPE_MODE (complex_float_type_node)) | |
1025 | return complex_float_type_node; | |
1026 | if (mode == TYPE_MODE (complex_double_type_node)) | |
1027 | return complex_double_type_node; | |
1028 | if (mode == TYPE_MODE (complex_long_double_type_node)) | |
1029 | return complex_long_double_type_node; | |
1030 | ||
1031 | if (mode == TYPE_MODE (complex_integer_type_node) && !unsigned_p) | |
1032 | return complex_integer_type_node; | |
1033 | ||
1034 | inner_mode = GET_MODE_INNER (mode); | |
1035 | inner_type = lto_type_for_mode (inner_mode, unsigned_p); | |
1036 | if (inner_type != NULL_TREE) | |
1037 | return build_complex_type (inner_type); | |
1038 | } | |
8464736b | 1039 | else if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL |
1040 | && valid_vector_subparts_p (GET_MODE_NUNITS (mode))) | |
1041 | { | |
1042 | unsigned int elem_bits = vector_element_size (GET_MODE_BITSIZE (mode), | |
1043 | GET_MODE_NUNITS (mode)); | |
1044 | tree bool_type = build_nonstandard_boolean_type (elem_bits); | |
1045 | return build_vector_type_for_mode (bool_type, mode); | |
1046 | } | |
f08ee65f | 1047 | else if (VECTOR_MODE_P (mode) |
1048 | && valid_vector_subparts_p (GET_MODE_NUNITS (mode))) | |
7bfefa9d | 1049 | { |
3754d046 | 1050 | machine_mode inner_mode = GET_MODE_INNER (mode); |
7bfefa9d | 1051 | tree inner_type = lto_type_for_mode (inner_mode, unsigned_p); |
1052 | if (inner_type != NULL_TREE) | |
1053 | return build_vector_type_for_mode (inner_type, mode); | |
1054 | } | |
1055 | ||
1056 | if (mode == TYPE_MODE (dfloat32_type_node)) | |
1057 | return dfloat32_type_node; | |
1058 | if (mode == TYPE_MODE (dfloat64_type_node)) | |
1059 | return dfloat64_type_node; | |
1060 | if (mode == TYPE_MODE (dfloat128_type_node)) | |
1061 | return dfloat128_type_node; | |
1062 | ||
1063 | if (ALL_SCALAR_FIXED_POINT_MODE_P (mode)) | |
1064 | { | |
1065 | if (mode == TYPE_MODE (short_fract_type_node)) | |
1066 | return unsigned_p ? sat_short_fract_type_node : short_fract_type_node; | |
1067 | if (mode == TYPE_MODE (fract_type_node)) | |
1068 | return unsigned_p ? sat_fract_type_node : fract_type_node; | |
1069 | if (mode == TYPE_MODE (long_fract_type_node)) | |
1070 | return unsigned_p ? sat_long_fract_type_node : long_fract_type_node; | |
1071 | if (mode == TYPE_MODE (long_long_fract_type_node)) | |
1072 | return unsigned_p ? sat_long_long_fract_type_node | |
1073 | : long_long_fract_type_node; | |
1074 | ||
1075 | if (mode == TYPE_MODE (unsigned_short_fract_type_node)) | |
1076 | return unsigned_p ? sat_unsigned_short_fract_type_node | |
1077 | : unsigned_short_fract_type_node; | |
1078 | if (mode == TYPE_MODE (unsigned_fract_type_node)) | |
1079 | return unsigned_p ? sat_unsigned_fract_type_node | |
1080 | : unsigned_fract_type_node; | |
1081 | if (mode == TYPE_MODE (unsigned_long_fract_type_node)) | |
1082 | return unsigned_p ? sat_unsigned_long_fract_type_node | |
1083 | : unsigned_long_fract_type_node; | |
1084 | if (mode == TYPE_MODE (unsigned_long_long_fract_type_node)) | |
1085 | return unsigned_p ? sat_unsigned_long_long_fract_type_node | |
1086 | : unsigned_long_long_fract_type_node; | |
1087 | ||
1088 | if (mode == TYPE_MODE (short_accum_type_node)) | |
1089 | return unsigned_p ? sat_short_accum_type_node : short_accum_type_node; | |
1090 | if (mode == TYPE_MODE (accum_type_node)) | |
1091 | return unsigned_p ? sat_accum_type_node : accum_type_node; | |
1092 | if (mode == TYPE_MODE (long_accum_type_node)) | |
1093 | return unsigned_p ? sat_long_accum_type_node : long_accum_type_node; | |
1094 | if (mode == TYPE_MODE (long_long_accum_type_node)) | |
1095 | return unsigned_p ? sat_long_long_accum_type_node | |
1096 | : long_long_accum_type_node; | |
1097 | ||
1098 | if (mode == TYPE_MODE (unsigned_short_accum_type_node)) | |
1099 | return unsigned_p ? sat_unsigned_short_accum_type_node | |
1100 | : unsigned_short_accum_type_node; | |
1101 | if (mode == TYPE_MODE (unsigned_accum_type_node)) | |
1102 | return unsigned_p ? sat_unsigned_accum_type_node | |
1103 | : unsigned_accum_type_node; | |
1104 | if (mode == TYPE_MODE (unsigned_long_accum_type_node)) | |
1105 | return unsigned_p ? sat_unsigned_long_accum_type_node | |
1106 | : unsigned_long_accum_type_node; | |
1107 | if (mode == TYPE_MODE (unsigned_long_long_accum_type_node)) | |
1108 | return unsigned_p ? sat_unsigned_long_long_accum_type_node | |
1109 | : unsigned_long_long_accum_type_node; | |
1110 | ||
1111 | if (mode == QQmode) | |
1112 | return unsigned_p ? sat_qq_type_node : qq_type_node; | |
1113 | if (mode == HQmode) | |
1114 | return unsigned_p ? sat_hq_type_node : hq_type_node; | |
1115 | if (mode == SQmode) | |
1116 | return unsigned_p ? sat_sq_type_node : sq_type_node; | |
1117 | if (mode == DQmode) | |
1118 | return unsigned_p ? sat_dq_type_node : dq_type_node; | |
1119 | if (mode == TQmode) | |
1120 | return unsigned_p ? sat_tq_type_node : tq_type_node; | |
1121 | ||
1122 | if (mode == UQQmode) | |
1123 | return unsigned_p ? sat_uqq_type_node : uqq_type_node; | |
1124 | if (mode == UHQmode) | |
1125 | return unsigned_p ? sat_uhq_type_node : uhq_type_node; | |
1126 | if (mode == USQmode) | |
1127 | return unsigned_p ? sat_usq_type_node : usq_type_node; | |
1128 | if (mode == UDQmode) | |
1129 | return unsigned_p ? sat_udq_type_node : udq_type_node; | |
1130 | if (mode == UTQmode) | |
1131 | return unsigned_p ? sat_utq_type_node : utq_type_node; | |
1132 | ||
1133 | if (mode == HAmode) | |
1134 | return unsigned_p ? sat_ha_type_node : ha_type_node; | |
1135 | if (mode == SAmode) | |
1136 | return unsigned_p ? sat_sa_type_node : sa_type_node; | |
1137 | if (mode == DAmode) | |
1138 | return unsigned_p ? sat_da_type_node : da_type_node; | |
1139 | if (mode == TAmode) | |
1140 | return unsigned_p ? sat_ta_type_node : ta_type_node; | |
1141 | ||
1142 | if (mode == UHAmode) | |
1143 | return unsigned_p ? sat_uha_type_node : uha_type_node; | |
1144 | if (mode == USAmode) | |
1145 | return unsigned_p ? sat_usa_type_node : usa_type_node; | |
1146 | if (mode == UDAmode) | |
1147 | return unsigned_p ? sat_uda_type_node : uda_type_node; | |
1148 | if (mode == UTAmode) | |
1149 | return unsigned_p ? sat_uta_type_node : uta_type_node; | |
1150 | } | |
1151 | ||
1152 | for (t = registered_builtin_types; t; t = TREE_CHAIN (t)) | |
1153 | if (TYPE_MODE (TREE_VALUE (t)) == mode) | |
1154 | return TREE_VALUE (t); | |
1155 | ||
1156 | return NULL_TREE; | |
1157 | } | |
1158 | ||
1d2bb655 | 1159 | /* Return true if we are in the global binding level. */ |
1160 | ||
1161 | static bool | |
1162 | lto_global_bindings_p (void) | |
7bfefa9d | 1163 | { |
1164 | return cfun == NULL; | |
1165 | } | |
1166 | ||
1167 | static void | |
1168 | lto_set_decl_assembler_name (tree decl) | |
1169 | { | |
1170 | /* This is almost the same as lhd_set_decl_assembler_name, except that | |
1171 | we need to uniquify file-scope names, even if they are not | |
1172 | TREE_PUBLIC, to avoid conflicts between individual files. */ | |
1173 | tree id; | |
1174 | ||
1175 | if (TREE_PUBLIC (decl)) | |
1176 | id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl)); | |
1177 | else | |
1178 | { | |
1179 | const char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); | |
1180 | char *label; | |
1181 | ||
1182 | ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl)); | |
1183 | id = get_identifier (label); | |
1184 | } | |
1185 | ||
1186 | SET_DECL_ASSEMBLER_NAME (decl, id); | |
1187 | } | |
1188 | ||
1189 | static tree | |
1190 | lto_pushdecl (tree t ATTRIBUTE_UNUSED) | |
1191 | { | |
1192 | /* Do nothing, since we get all information from DWARF and LTO | |
1193 | sections. */ | |
1194 | return NULL_TREE; | |
1195 | } | |
1196 | ||
1197 | static tree | |
1198 | lto_getdecls (void) | |
1199 | { | |
5cd33168 | 1200 | /* We have our own write_globals langhook, hence the getdecls |
1201 | langhook shouldn't be used, except by dbxout.c, so we can't | |
1202 | just abort here. */ | |
1203 | return NULL_TREE; | |
7bfefa9d | 1204 | } |
1205 | ||
7bfefa9d | 1206 | static tree |
1207 | lto_builtin_function (tree decl) | |
1208 | { | |
7bfefa9d | 1209 | return decl; |
1210 | } | |
1211 | ||
1212 | static void | |
1213 | lto_register_builtin_type (tree type, const char *name) | |
1214 | { | |
1215 | tree decl; | |
1216 | ||
7bfefa9d | 1217 | if (!TYPE_NAME (type)) |
883554eb | 1218 | { |
1219 | decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, | |
1220 | get_identifier (name), type); | |
1221 | DECL_ARTIFICIAL (decl) = 1; | |
1222 | TYPE_NAME (type) = decl; | |
1223 | } | |
7bfefa9d | 1224 | |
1225 | registered_builtin_types = tree_cons (0, type, registered_builtin_types); | |
1226 | } | |
1227 | ||
1228 | /* Build nodes that would have be created by the C front-end; necessary | |
1229 | for including builtin-types.def and ultimately builtins.def. */ | |
1230 | ||
1231 | static void | |
1232 | lto_build_c_type_nodes (void) | |
1233 | { | |
1234 | gcc_assert (void_type_node); | |
1235 | ||
1236 | void_list_node = build_tree_list (NULL_TREE, void_type_node); | |
1237 | string_type_node = build_pointer_type (char_type_node); | |
1238 | const_string_type_node | |
1239 | = build_pointer_type (build_qualified_type (char_type_node, TYPE_QUAL_CONST)); | |
1240 | ||
1241 | if (strcmp (SIZE_TYPE, "unsigned int") == 0) | |
1242 | { | |
1243 | intmax_type_node = integer_type_node; | |
1244 | uintmax_type_node = unsigned_type_node; | |
1245 | signed_size_type_node = integer_type_node; | |
1246 | } | |
1247 | else if (strcmp (SIZE_TYPE, "long unsigned int") == 0) | |
1248 | { | |
1249 | intmax_type_node = long_integer_type_node; | |
1250 | uintmax_type_node = long_unsigned_type_node; | |
1251 | signed_size_type_node = long_integer_type_node; | |
1252 | } | |
6dd40464 | 1253 | else if (strcmp (SIZE_TYPE, "long long unsigned int") == 0) |
1254 | { | |
1255 | intmax_type_node = long_long_integer_type_node; | |
1256 | uintmax_type_node = long_long_unsigned_type_node; | |
1257 | signed_size_type_node = long_long_integer_type_node; | |
1258 | } | |
7bfefa9d | 1259 | else |
9f75f026 | 1260 | { |
1261 | int i; | |
1262 | ||
1263 | signed_size_type_node = NULL_TREE; | |
1264 | for (i = 0; i < NUM_INT_N_ENTS; i++) | |
1265 | if (int_n_enabled_p[i]) | |
1266 | { | |
1267 | char name[50]; | |
1268 | sprintf (name, "__int%d unsigned", int_n_data[i].bitsize); | |
1269 | ||
1270 | if (strcmp (name, SIZE_TYPE) == 0) | |
1271 | { | |
1272 | intmax_type_node = int_n_trees[i].signed_type; | |
1273 | uintmax_type_node = int_n_trees[i].unsigned_type; | |
1274 | signed_size_type_node = int_n_trees[i].signed_type; | |
1275 | } | |
1276 | } | |
1277 | if (signed_size_type_node == NULL_TREE) | |
1278 | gcc_unreachable (); | |
1279 | } | |
7bfefa9d | 1280 | |
1281 | wint_type_node = unsigned_type_node; | |
1282 | pid_type_node = integer_type_node; | |
1283 | } | |
1284 | ||
7bfefa9d | 1285 | /* Perform LTO-specific initialization. */ |
1286 | ||
1287 | static bool | |
1288 | lto_init (void) | |
1289 | { | |
9f75f026 | 1290 | int i; |
1291 | ||
92bc38e7 | 1292 | /* Initialize LTO-specific data structures. */ |
1293 | in_lto_p = true; | |
1294 | ||
7bfefa9d | 1295 | /* We need to generate LTO if running in WPA mode. */ |
278cec16 | 1296 | flag_generate_lto = (flag_incremental_link == INCREMENTAL_LINK_LTO |
1297 | || flag_wpa != NULL); | |
7bfefa9d | 1298 | |
7bfefa9d | 1299 | /* Create the basic integer types. */ |
600695e0 | 1300 | build_common_tree_nodes (flag_signed_char); |
7bfefa9d | 1301 | |
7bfefa9d | 1302 | /* The global tree for the main identifier is filled in by |
1303 | language-specific front-end initialization that is not run in the | |
1304 | LTO back-end. It appears that all languages that perform such | |
1305 | initialization currently do so in the same way, so we do it here. */ | |
1306 | if (main_identifier_node == NULL_TREE) | |
1307 | main_identifier_node = get_identifier ("main"); | |
1308 | ||
1309 | /* In the C++ front-end, fileptr_type_node is defined as a variant | |
47ae02b7 | 1310 | copy of ptr_type_node, rather than ptr_node itself. The |
7bfefa9d | 1311 | distinction should only be relevant to the front-end, so we |
4e551c7d | 1312 | always use the C definition here in lto1. |
1313 | Likewise for const struct tm*. */ | |
1314 | for (unsigned i = 0; | |
1315 | i < sizeof (builtin_structptr_types) / sizeof (builtin_structptr_type); | |
1316 | ++i) | |
1317 | { | |
1318 | gcc_assert (builtin_structptr_types[i].node | |
1319 | == builtin_structptr_types[i].base); | |
1320 | gcc_assert (TYPE_MAIN_VARIANT (builtin_structptr_types[i].node) | |
1321 | == builtin_structptr_types[i].base); | |
1322 | } | |
7bfefa9d | 1323 | |
7bfefa9d | 1324 | lto_build_c_type_nodes (); |
1325 | gcc_assert (va_list_type_node); | |
1326 | ||
1327 | if (TREE_CODE (va_list_type_node) == ARRAY_TYPE) | |
1328 | { | |
1329 | tree x = build_pointer_type (TREE_TYPE (va_list_type_node)); | |
1330 | lto_define_builtins (x, x); | |
1331 | } | |
1332 | else | |
1333 | { | |
fc8393b7 | 1334 | lto_define_builtins (build_reference_type (va_list_type_node), |
1335 | va_list_type_node); | |
7bfefa9d | 1336 | } |
fc8393b7 | 1337 | |
7bfefa9d | 1338 | targetm.init_builtins (); |
1339 | build_common_builtin_nodes (); | |
1340 | ||
6abc14d6 | 1341 | /* Assign names to the builtin types, otherwise they'll end up |
1342 | as __unknown__ in debug info. | |
1343 | ??? We simply need to stop pre-seeding the streamer cache. | |
1344 | Below is modeled after from c-common.c:c_common_nodes_and_builtins */ | |
1345 | #define NAME_TYPE(t,n) \ | |
1346 | if (t) \ | |
1347 | TYPE_NAME (t) = build_decl (UNKNOWN_LOCATION, TYPE_DECL, \ | |
1348 | get_identifier (n), t) | |
1349 | NAME_TYPE (integer_type_node, "int"); | |
1350 | NAME_TYPE (char_type_node, "char"); | |
1351 | NAME_TYPE (long_integer_type_node, "long int"); | |
1352 | NAME_TYPE (unsigned_type_node, "unsigned int"); | |
1353 | NAME_TYPE (long_unsigned_type_node, "long unsigned int"); | |
1354 | NAME_TYPE (long_long_integer_type_node, "long long int"); | |
1355 | NAME_TYPE (long_long_unsigned_type_node, "long long unsigned int"); | |
1356 | NAME_TYPE (short_integer_type_node, "short int"); | |
1357 | NAME_TYPE (short_unsigned_type_node, "short unsigned int"); | |
1358 | if (signed_char_type_node != char_type_node) | |
1359 | NAME_TYPE (signed_char_type_node, "signed char"); | |
1360 | if (unsigned_char_type_node != char_type_node) | |
1361 | NAME_TYPE (unsigned_char_type_node, "unsigned char"); | |
1362 | NAME_TYPE (float_type_node, "float"); | |
1363 | NAME_TYPE (double_type_node, "double"); | |
1364 | NAME_TYPE (long_double_type_node, "long double"); | |
1365 | NAME_TYPE (void_type_node, "void"); | |
1366 | NAME_TYPE (boolean_type_node, "bool"); | |
0baf842d | 1367 | NAME_TYPE (complex_float_type_node, "complex float"); |
1368 | NAME_TYPE (complex_double_type_node, "complex double"); | |
1369 | NAME_TYPE (complex_long_double_type_node, "complex long double"); | |
9f75f026 | 1370 | for (i = 0; i < NUM_INT_N_ENTS; i++) |
1371 | if (int_n_enabled_p[i]) | |
1372 | { | |
1373 | char name[50]; | |
1374 | sprintf (name, "__int%d", int_n_data[i].bitsize); | |
1375 | NAME_TYPE (int_n_trees[i].signed_type, name); | |
1376 | } | |
6abc14d6 | 1377 | #undef NAME_TYPE |
1378 | ||
7bfefa9d | 1379 | return true; |
1380 | } | |
1381 | ||
025fe22b | 1382 | /* Register c++-specific dumps. */ |
1383 | ||
1384 | void | |
1385 | lto_register_dumps (gcc::dump_manager *dumps) | |
1386 | { | |
1387 | lto_link_dump_id = dumps->dump_register | |
1388 | (".lto-link", "ipa-lto-link", "ipa-lto-link", | |
1389 | DK_ipa, OPTGROUP_NONE, false); | |
1390 | decl_merge_dump_id = dumps->dump_register | |
1391 | (".lto-decl-merge", "ipa-lto-decl-merge", "ipa-lto-decl-merge", | |
1392 | DK_ipa, OPTGROUP_NONE, false); | |
1393 | partition_dump_id = dumps->dump_register | |
1394 | (".lto-partition", "ipa-lto-partition", "ipa-lto-partition", | |
1395 | DK_ipa, OPTGROUP_NONE, false); | |
1396 | } | |
1397 | ||
1398 | ||
7bfefa9d | 1399 | /* Initialize tree structures required by the LTO front end. */ |
1400 | ||
1401 | static void lto_init_ts (void) | |
1402 | { | |
1403 | tree_contains_struct[NAMESPACE_DECL][TS_DECL_MINIMAL] = 1; | |
1404 | } | |
1405 | ||
1406 | #undef LANG_HOOKS_NAME | |
1407 | #define LANG_HOOKS_NAME "GNU GIMPLE" | |
e88d34f6 | 1408 | #undef LANG_HOOKS_OPTION_LANG_MASK |
1409 | #define LANG_HOOKS_OPTION_LANG_MASK lto_option_lang_mask | |
1410 | #undef LANG_HOOKS_COMPLAIN_WRONG_LANG_P | |
1411 | #define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lto_complain_wrong_lang_p | |
f3f006ad | 1412 | #undef LANG_HOOKS_INIT_OPTIONS_STRUCT |
1413 | #define LANG_HOOKS_INIT_OPTIONS_STRUCT lto_init_options_struct | |
025fe22b | 1414 | #undef LANG_HOOKS_REGISTER_DUMPS |
1415 | #define LANG_HOOKS_REGISTER_DUMPS lto_register_dumps | |
7bfefa9d | 1416 | #undef LANG_HOOKS_HANDLE_OPTION |
1417 | #define LANG_HOOKS_HANDLE_OPTION lto_handle_option | |
1418 | #undef LANG_HOOKS_POST_OPTIONS | |
1419 | #define LANG_HOOKS_POST_OPTIONS lto_post_options | |
1420 | #undef LANG_HOOKS_GET_ALIAS_SET | |
1421 | #define LANG_HOOKS_GET_ALIAS_SET gimple_get_alias_set | |
1422 | #undef LANG_HOOKS_TYPE_FOR_MODE | |
1423 | #define LANG_HOOKS_TYPE_FOR_MODE lto_type_for_mode | |
7bfefa9d | 1424 | #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME |
1425 | #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME lto_set_decl_assembler_name | |
1426 | #undef LANG_HOOKS_GLOBAL_BINDINGS_P | |
1427 | #define LANG_HOOKS_GLOBAL_BINDINGS_P lto_global_bindings_p | |
1428 | #undef LANG_HOOKS_PUSHDECL | |
1429 | #define LANG_HOOKS_PUSHDECL lto_pushdecl | |
1430 | #undef LANG_HOOKS_GETDECLS | |
1431 | #define LANG_HOOKS_GETDECLS lto_getdecls | |
7bfefa9d | 1432 | #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE |
1433 | #define LANG_HOOKS_REGISTER_BUILTIN_TYPE lto_register_builtin_type | |
1434 | #undef LANG_HOOKS_BUILTIN_FUNCTION | |
1435 | #define LANG_HOOKS_BUILTIN_FUNCTION lto_builtin_function | |
1436 | #undef LANG_HOOKS_INIT | |
1437 | #define LANG_HOOKS_INIT lto_init | |
1438 | #undef LANG_HOOKS_PARSE_FILE | |
1439 | #define LANG_HOOKS_PARSE_FILE lto_main | |
7bfefa9d | 1440 | #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS |
1441 | #define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS true | |
1442 | #undef LANG_HOOKS_TYPES_COMPATIBLE_P | |
1443 | #define LANG_HOOKS_TYPES_COMPATIBLE_P NULL | |
3c9e9cba | 1444 | #undef LANG_HOOKS_EH_PERSONALITY |
1445 | #define LANG_HOOKS_EH_PERSONALITY lto_eh_personality | |
7bfefa9d | 1446 | |
1447 | /* Attribute hooks. */ | |
1448 | #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE | |
1449 | #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE lto_attribute_table | |
1450 | #undef LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE | |
1451 | #define LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE lto_format_attribute_table | |
1452 | ||
1453 | #undef LANG_HOOKS_BEGIN_SECTION | |
3ba0ce47 | 1454 | #define LANG_HOOKS_BEGIN_SECTION lto_obj_begin_section |
7bfefa9d | 1455 | #undef LANG_HOOKS_APPEND_DATA |
3ba0ce47 | 1456 | #define LANG_HOOKS_APPEND_DATA lto_obj_append_data |
7bfefa9d | 1457 | #undef LANG_HOOKS_END_SECTION |
3ba0ce47 | 1458 | #define LANG_HOOKS_END_SECTION lto_obj_end_section |
7bfefa9d | 1459 | |
1460 | #undef LANG_HOOKS_INIT_TS | |
1461 | #define LANG_HOOKS_INIT_TS lto_init_ts | |
1462 | ||
1463 | struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; | |
1464 | ||
1465 | /* Language hooks that are not part of lang_hooks. */ | |
1466 | ||
1467 | tree | |
1468 | convert (tree type ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED) | |
1469 | { | |
1470 | gcc_unreachable (); | |
1471 | } | |
1472 | ||
1473 | /* Tree walking support. */ | |
1474 | ||
1475 | static enum lto_tree_node_structure_enum | |
1476 | lto_tree_node_structure (union lang_tree_node *t ATTRIBUTE_UNUSED) | |
1477 | { | |
1478 | return TS_LTO_GENERIC; | |
1479 | } | |
1480 | ||
7bfefa9d | 1481 | #include "gtype-lto.h" |
1482 | #include "gt-lto-lto-lang.h" |