]>
Commit | Line | Data |
---|---|---|
e8602e56 | 1 | /* Default language-specific hooks. |
711789cc | 2 | Copyright (C) 2001-2013 Free Software Foundation, Inc. |
e8602e56 | 3 | Contributed by Alexandre Oliva <aoliva@redhat.com> |
4 | ||
5a8b6e6a | 5 | This file is part of GCC. |
e8602e56 | 6 | |
5a8b6e6a | 7 | GCC is free software; you can redistribute it and/or modify |
e8602e56 | 8 | it under the terms of the GNU General Public License as published by |
8c4c00c1 | 9 | the Free Software Foundation; either version 3, or (at your option) |
e8602e56 | 10 | any later version. |
11 | ||
5a8b6e6a | 12 | GCC is distributed in the hope that it will be useful, |
e8602e56 | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
8c4c00c1 | 18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
e8602e56 | 20 | |
21 | #include "config.h" | |
22 | #include "system.h" | |
805e22b2 | 23 | #include "coretypes.h" |
eb586f2c | 24 | #include "intl.h" |
805e22b2 | 25 | #include "tm.h" |
e8602e56 | 26 | #include "toplev.h" |
27 | #include "tree.h" | |
9ed99284 | 28 | #include "stringpool.h" |
29 | #include "attribs.h" | |
e8602e56 | 30 | #include "tree-inline.h" |
a8783bee | 31 | #include "gimplify.h" |
723fbc55 | 32 | #include "rtl.h" |
33 | #include "insn-config.h" | |
341c61b7 | 34 | #include "flags.h" |
95898760 | 35 | #include "langhooks.h" |
97a424bc | 36 | #include "target.h" |
b0278d39 | 37 | #include "langhooks-def.h" |
2a576742 | 38 | #include "diagnostic.h" |
ce084dfc | 39 | #include "tree-diagnostic.h" |
bfec3452 | 40 | #include "cgraph.h" |
3d1c0354 | 41 | #include "timevar.h" |
7bfefa9d | 42 | #include "output.h" |
95898760 | 43 | |
7cd99a60 | 44 | /* Do nothing; in many cases the default hook. */ |
2a631e19 | 45 | |
7cd99a60 | 46 | void |
3ad4992f | 47 | lhd_do_nothing (void) |
7cd99a60 | 48 | { |
49 | } | |
50 | ||
c80c4f22 | 51 | /* Do nothing (tree). */ |
dbc42b78 | 52 | |
53 | void | |
9a03a746 | 54 | lhd_do_nothing_t (tree ARG_UNUSED (t)) |
dbc42b78 | 55 | { |
56 | } | |
57 | ||
58d82cd0 | 58 | /* Pass through (tree). */ |
59 | tree | |
60 | lhd_pass_through_t (tree t) | |
61 | { | |
62 | return t; | |
63 | } | |
64 | ||
37b9a732 | 65 | /* Do nothing (int, int, int). Return NULL_TREE. */ |
66 | ||
67 | tree | |
b27ac6b5 | 68 | lhd_do_nothing_iii_return_null_tree (int ARG_UNUSED (i), |
9a03a746 | 69 | int ARG_UNUSED (j), |
70 | int ARG_UNUSED (k)) | |
37b9a732 | 71 | { |
72 | return NULL_TREE; | |
73 | } | |
74 | ||
c80c4f22 | 75 | /* Do nothing (function). */ |
76 | ||
77 | void | |
9a03a746 | 78 | lhd_do_nothing_f (struct function * ARG_UNUSED (f)) |
c80c4f22 | 79 | { |
80 | } | |
81 | ||
04745efb | 82 | /* Do nothing (return NULL_TREE). */ |
83 | ||
54bd1509 | 84 | tree |
85 | lhd_return_null_tree_v (void) | |
86 | { | |
87 | return NULL_TREE; | |
88 | } | |
89 | ||
90 | /* Do nothing (return NULL_TREE). */ | |
91 | ||
04745efb | 92 | tree |
9a03a746 | 93 | lhd_return_null_tree (tree ARG_UNUSED (t)) |
04745efb | 94 | { |
95 | return NULL_TREE; | |
96 | } | |
97 | ||
b7bf20db | 98 | /* Do nothing (return NULL_TREE). */ |
99 | ||
100 | tree | |
101 | lhd_return_null_const_tree (const_tree ARG_UNUSED (t)) | |
102 | { | |
103 | return NULL_TREE; | |
104 | } | |
105 | ||
03bde601 | 106 | /* The default post options hook. */ |
107 | ||
108 | bool | |
9a03a746 | 109 | lhd_post_options (const char ** ARG_UNUSED (pfilename)) |
03bde601 | 110 | { |
c6418a4e | 111 | /* Excess precision other than "fast" requires front-end |
112 | support. */ | |
113 | flag_excess_precision_cmdline = EXCESS_PRECISION_FAST; | |
03bde601 | 114 | return false; |
115 | } | |
116 | ||
b7fced5e | 117 | /* Called from by print-tree.c. */ |
118 | ||
119 | void | |
9a03a746 | 120 | lhd_print_tree_nothing (FILE * ARG_UNUSED (file), |
121 | tree ARG_UNUSED (node), | |
122 | int ARG_UNUSED (indent)) | |
b7fced5e | 123 | { |
b3187c7c | 124 | } |
125 | ||
8d58a5a7 | 126 | /* Called from check_global_declarations. */ |
127 | ||
128 | bool | |
f8fd23c0 | 129 | lhd_warn_unused_global_decl (const_tree decl) |
8d58a5a7 | 130 | { |
131 | /* This is what used to exist in check_global_declarations. Probably | |
132 | not many of these actually apply to non-C languages. */ | |
133 | ||
81549c4d | 134 | if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl)) |
8d58a5a7 | 135 | return false; |
136 | if (TREE_CODE (decl) == VAR_DECL && TREE_READONLY (decl)) | |
137 | return false; | |
138 | if (DECL_IN_SYSTEM_HEADER (decl)) | |
139 | return false; | |
140 | ||
141 | return true; | |
142 | } | |
143 | ||
d1f6c8f2 | 144 | /* Set the DECL_ASSEMBLER_NAME for DECL. */ |
145 | void | |
3ad4992f | 146 | lhd_set_decl_assembler_name (tree decl) |
d1f6c8f2 | 147 | { |
97a424bc | 148 | tree id; |
149 | ||
d1f6c8f2 | 150 | /* The language-independent code should never use the |
151 | DECL_ASSEMBLER_NAME for lots of DECLs. Only FUNCTION_DECLs and | |
152 | VAR_DECLs for variables with static storage duration need a real | |
2045cdd4 | 153 | DECL_ASSEMBLER_NAME. */ |
a53ff4c1 | 154 | gcc_assert (TREE_CODE (decl) == FUNCTION_DECL |
155 | || (TREE_CODE (decl) == VAR_DECL | |
156 | && (TREE_STATIC (decl) | |
157 | || DECL_EXTERNAL (decl) | |
158 | || TREE_PUBLIC (decl)))); | |
48e1416a | 159 | |
a53ff4c1 | 160 | /* By default, assume the name to use in assembly code is the same |
161 | as that used in the source language. (That's correct for C, and | |
162 | GCC used to set DECL_ASSEMBLER_NAME to the same value as | |
163 | DECL_NAME in build_decl, so this choice provides backwards | |
97a424bc | 164 | compatibility with existing front-ends. This assumption is wrapped |
165 | in a target hook, to allow for target-specific modification of the | |
166 | identifier. | |
48e1416a | 167 | |
a53ff4c1 | 168 | Can't use just the variable's own name for a variable whose scope |
169 | is less than the whole compilation. Concatenate a distinguishing | |
170 | number - we use the DECL_UID. */ | |
97a424bc | 171 | |
262b29f2 | 172 | if (TREE_PUBLIC (decl) || DECL_FILE_SCOPE_P (decl)) |
97a424bc | 173 | id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl)); |
a53ff4c1 | 174 | else |
a6df3a0e | 175 | { |
a53ff4c1 | 176 | const char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); |
177 | char *label; | |
48e1416a | 178 | |
a53ff4c1 | 179 | ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl)); |
97a424bc | 180 | id = get_identifier (label); |
a6df3a0e | 181 | } |
97a424bc | 182 | SET_DECL_ASSEMBLER_NAME (decl, id); |
183 | ||
d1f6c8f2 | 184 | } |
185 | ||
63c62881 | 186 | /* Type promotion for variable arguments. */ |
187 | tree | |
9a03a746 | 188 | lhd_type_promotes_to (tree ARG_UNUSED (type)) |
63c62881 | 189 | { |
a53ff4c1 | 190 | gcc_unreachable (); |
63c62881 | 191 | } |
192 | ||
b268e47e | 193 | /* Registration of machine- or os-specific builtin types. */ |
194 | void | |
b27ac6b5 | 195 | lhd_register_builtin_type (tree ARG_UNUSED (type), |
9a03a746 | 196 | const char * ARG_UNUSED (name)) |
b268e47e | 197 | { |
198 | } | |
199 | ||
1dd25100 | 200 | /* Invalid use of an incomplete type. */ |
201 | void | |
f8fd23c0 | 202 | lhd_incomplete_type_error (const_tree ARG_UNUSED (value), const_tree type) |
1dd25100 | 203 | { |
a53ff4c1 | 204 | gcc_assert (TREE_CODE (type) == ERROR_MARK); |
205 | return; | |
1dd25100 | 206 | } |
207 | ||
df2114d0 | 208 | /* Provide a default routine for alias sets that always returns -1. This |
209 | is used by languages that don't need to do anything special. */ | |
210 | ||
32c2fdea | 211 | alias_set_type |
9a03a746 | 212 | lhd_get_alias_set (tree ARG_UNUSED (t)) |
df2114d0 | 213 | { |
214 | return -1; | |
215 | } | |
216 | ||
96554925 | 217 | /* This is the default decl_printable_name function. */ |
218 | ||
219 | const char * | |
9a03a746 | 220 | lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity)) |
96554925 | 221 | { |
a1080ab2 | 222 | gcc_assert (decl && DECL_NAME (decl)); |
96554925 | 223 | return IDENTIFIER_POINTER (DECL_NAME (decl)); |
224 | } | |
225 | ||
7d709201 | 226 | /* This is the default dwarf_name function. */ |
227 | ||
228 | const char * | |
229 | lhd_dwarf_name (tree t, int verbosity) | |
230 | { | |
231 | gcc_assert (DECL_P (t)); | |
232 | ||
233 | return lang_hooks.decl_printable_name (t, verbosity); | |
234 | } | |
235 | ||
4ee9c684 | 236 | /* This compares two types for equivalence ("compatible" in C-based languages). |
237 | This routine should only return 1 if it is sure. It should not be used | |
238 | in contexts where erroneously returning 0 causes problems. */ | |
239 | ||
240 | int | |
241 | lhd_types_compatible_p (tree x, tree y) | |
242 | { | |
243 | return TYPE_MAIN_VARIANT (x) == TYPE_MAIN_VARIANT (y); | |
244 | } | |
245 | ||
8851e806 | 246 | /* lang_hooks.tree_dump.dump_tree: Dump language-specific parts of tree |
6ef828f9 | 247 | nodes. Returns nonzero if it does not want the usual dumping of the |
3119c950 | 248 | second argument. */ |
249 | ||
fb84380a | 250 | bool |
3ad4992f | 251 | lhd_tree_dump_dump_tree (void *di ATTRIBUTE_UNUSED, tree t ATTRIBUTE_UNUSED) |
3119c950 | 252 | { |
fb84380a | 253 | return false; |
3119c950 | 254 | } |
255 | ||
8851e806 | 256 | /* lang_hooks.tree_dump.type_qual: Determine type qualifiers in a |
3119c950 | 257 | language-specific way. */ |
258 | ||
259 | int | |
f8fd23c0 | 260 | lhd_tree_dump_type_quals (const_tree t) |
3119c950 | 261 | { |
262 | return TYPE_QUALS (t); | |
263 | } | |
c3f16ae3 | 264 | |
4ee9c684 | 265 | /* lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form. */ |
266 | ||
267 | int | |
75a70cf9 | 268 | lhd_gimplify_expr (tree *expr_p ATTRIBUTE_UNUSED, |
269 | gimple_seq *pre_p ATTRIBUTE_UNUSED, | |
270 | gimple_seq *post_p ATTRIBUTE_UNUSED) | |
a0d8c66d | 271 | { |
4ee9c684 | 272 | return GS_UNHANDLED; |
a0d8c66d | 273 | } |
d3ea5d40 | 274 | |
295e387a | 275 | /* lang_hooks.tree_size: Determine the size of a tree with code C, |
ce45a448 | 276 | which is a language-specific tree code in category tcc_constant or |
277 | tcc_exceptional. The default expects never to be called. */ | |
295e387a | 278 | size_t |
3ad4992f | 279 | lhd_tree_size (enum tree_code c ATTRIBUTE_UNUSED) |
295e387a | 280 | { |
a53ff4c1 | 281 | gcc_unreachable (); |
295e387a | 282 | } |
283 | ||
e2e9c55b | 284 | /* Return true if decl, which is a function decl, may be called by a |
285 | sibcall. */ | |
286 | ||
287 | bool | |
9f627b1a | 288 | lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED) |
e2e9c55b | 289 | { |
290 | return true; | |
291 | } | |
292 | ||
d3ea5d40 | 293 | /* lang_hooks.decls.final_write_globals: perform final processing on |
037845e5 | 294 | global variables. */ |
d3ea5d40 | 295 | void |
3ad4992f | 296 | write_global_declarations (void) |
d3ea5d40 | 297 | { |
bfec3452 | 298 | tree globals, decl, *vec; |
299 | int len, i; | |
300 | ||
3d1c0354 | 301 | timevar_start (TV_PHASE_DEFERRED); |
d3ea5d40 | 302 | /* Really define vars that have had only a tentative definition. |
303 | Really output inline functions that must actually be callable | |
304 | and have not been output so far. */ | |
305 | ||
bfec3452 | 306 | globals = lang_hooks.decls.getdecls (); |
307 | len = list_length (globals); | |
308 | vec = XNEWVEC (tree, len); | |
d3ea5d40 | 309 | |
310 | /* Process the decls in reverse order--earliest first. | |
311 | Put them into VEC from back to front, then take out from front. */ | |
312 | ||
1767a056 | 313 | for (i = 0, decl = globals; i < len; i++, decl = DECL_CHAIN (decl)) |
d3ea5d40 | 314 | vec[len - i - 1] = decl; |
315 | ||
316 | wrapup_global_declarations (vec, len); | |
d3ea5d40 | 317 | check_global_declarations (vec, len); |
3d1c0354 | 318 | timevar_stop (TV_PHASE_DEFERRED); |
319 | ||
161121a9 | 320 | timevar_start (TV_PHASE_OPT_GEN); |
3d1c0354 | 321 | /* This lang hook is dual-purposed, and also finalizes the |
322 | compilation unit. */ | |
323 | finalize_compilation_unit (); | |
161121a9 | 324 | timevar_stop (TV_PHASE_OPT_GEN); |
3d1c0354 | 325 | |
161121a9 | 326 | timevar_start (TV_PHASE_DBGINFO); |
c131e678 | 327 | emit_debug_global_declarations (vec, len); |
161121a9 | 328 | timevar_stop (TV_PHASE_DBGINFO); |
d3ea5d40 | 329 | |
c131e678 | 330 | /* Clean up. */ |
d3ea5d40 | 331 | free (vec); |
332 | } | |
a6df3a0e | 333 | |
f63da8d3 | 334 | /* Called to perform language-specific initialization of CTX. */ |
335 | void | |
24ca3b4e | 336 | lhd_initialize_diagnostics (diagnostic_context *ctx ATTRIBUTE_UNUSED) |
f63da8d3 | 337 | { |
338 | } | |
339 | ||
e88d34f6 | 340 | /* Called to perform language-specific options initialization. */ |
341 | void | |
342 | lhd_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED, | |
343 | struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED) | |
344 | { | |
345 | } | |
346 | ||
347 | /* By default, always complain about options for the wrong language. */ | |
348 | bool | |
349 | lhd_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED) | |
350 | { | |
351 | return true; | |
352 | } | |
353 | ||
b78351e5 | 354 | /* By default, no language-specific options are valid. */ |
355 | bool | |
356 | lhd_handle_option (size_t code ATTRIBUTE_UNUSED, | |
357 | const char *arg ATTRIBUTE_UNUSED, | |
358 | int value ATTRIBUTE_UNUSED, int kind ATTRIBUTE_UNUSED, | |
3c6c0e40 | 359 | location_t loc ATTRIBUTE_UNUSED, |
b78351e5 | 360 | const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED) |
361 | { | |
362 | return false; | |
363 | } | |
364 | ||
2a576742 | 365 | /* The default function to print out name of current function that caused |
366 | an error. */ | |
367 | void | |
b8c23db3 | 368 | lhd_print_error_function (diagnostic_context *context, const char *file, |
369 | diagnostic_info *diagnostic) | |
2a576742 | 370 | { |
b8c23db3 | 371 | if (diagnostic_last_function_changed (context, diagnostic)) |
2a576742 | 372 | { |
373 | const char *old_prefix = context->printer->prefix; | |
ce084dfc | 374 | tree abstract_origin = diagnostic_abstract_origin (diagnostic); |
b8c23db3 | 375 | char *new_prefix = (file && abstract_origin == NULL) |
2cafe211 | 376 | ? file_name_as_prefix (context, file) : NULL; |
2a576742 | 377 | |
378 | pp_set_prefix (context->printer, new_prefix); | |
379 | ||
380 | if (current_function_decl == NULL) | |
eb586f2c | 381 | pp_printf (context->printer, _("At top level:")); |
2a576742 | 382 | else |
383 | { | |
b8c23db3 | 384 | tree fndecl, ao; |
385 | ||
386 | if (abstract_origin) | |
387 | { | |
388 | ao = BLOCK_ABSTRACT_ORIGIN (abstract_origin); | |
5a6ca2d1 | 389 | while (TREE_CODE (ao) == BLOCK |
390 | && BLOCK_ABSTRACT_ORIGIN (ao) | |
391 | && BLOCK_ABSTRACT_ORIGIN (ao) != ao) | |
b8c23db3 | 392 | ao = BLOCK_ABSTRACT_ORIGIN (ao); |
393 | gcc_assert (TREE_CODE (ao) == FUNCTION_DECL); | |
394 | fndecl = ao; | |
395 | } | |
396 | else | |
397 | fndecl = current_function_decl; | |
398 | ||
399 | if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE) | |
2a576742 | 400 | pp_printf |
b8c23db3 | 401 | (context->printer, _("In member function %qs"), |
abd3e6b5 | 402 | identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2))); |
2a576742 | 403 | else |
404 | pp_printf | |
b8c23db3 | 405 | (context->printer, _("In function %qs"), |
abd3e6b5 | 406 | identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2))); |
b8c23db3 | 407 | |
408 | while (abstract_origin) | |
409 | { | |
410 | location_t *locus; | |
411 | tree block = abstract_origin; | |
412 | ||
413 | locus = &BLOCK_SOURCE_LOCATION (block); | |
414 | fndecl = NULL; | |
415 | block = BLOCK_SUPERCONTEXT (block); | |
416 | while (block && TREE_CODE (block) == BLOCK | |
417 | && BLOCK_ABSTRACT_ORIGIN (block)) | |
418 | { | |
419 | ao = BLOCK_ABSTRACT_ORIGIN (block); | |
420 | ||
5a6ca2d1 | 421 | while (TREE_CODE (ao) == BLOCK |
422 | && BLOCK_ABSTRACT_ORIGIN (ao) | |
423 | && BLOCK_ABSTRACT_ORIGIN (ao) != ao) | |
b8c23db3 | 424 | ao = BLOCK_ABSTRACT_ORIGIN (ao); |
425 | ||
426 | if (TREE_CODE (ao) == FUNCTION_DECL) | |
427 | { | |
428 | fndecl = ao; | |
429 | break; | |
430 | } | |
431 | else if (TREE_CODE (ao) != BLOCK) | |
432 | break; | |
433 | ||
434 | block = BLOCK_SUPERCONTEXT (block); | |
435 | } | |
436 | if (fndecl) | |
437 | abstract_origin = block; | |
438 | else | |
439 | { | |
440 | while (block && TREE_CODE (block) == BLOCK) | |
441 | block = BLOCK_SUPERCONTEXT (block); | |
442 | ||
aa03bd5e | 443 | if (block && TREE_CODE (block) == FUNCTION_DECL) |
b8c23db3 | 444 | fndecl = block; |
445 | abstract_origin = NULL; | |
446 | } | |
447 | if (fndecl) | |
448 | { | |
449 | expanded_location s = expand_location (*locus); | |
dda4f0ec | 450 | pp_comma (context->printer); |
b8c23db3 | 451 | pp_newline (context->printer); |
452 | if (s.file != NULL) | |
453 | { | |
2c2efebb | 454 | if (context->show_column) |
b8c23db3 | 455 | pp_printf (context->printer, |
41609f8b | 456 | _(" inlined from %qs at %r%s:%d:%d%R"), |
abd3e6b5 | 457 | identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)), |
41609f8b | 458 | "locus", s.file, s.line, s.column); |
b8c23db3 | 459 | else |
b8c23db3 | 460 | pp_printf (context->printer, |
41609f8b | 461 | _(" inlined from %qs at %r%s:%d%R"), |
abd3e6b5 | 462 | identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)), |
41609f8b | 463 | "locus", s.file, s.line); |
b8c23db3 | 464 | |
465 | } | |
466 | else | |
467 | pp_printf (context->printer, _(" inlined from %qs"), | |
abd3e6b5 | 468 | identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2))); |
b8c23db3 | 469 | } |
470 | } | |
dda4f0ec | 471 | pp_colon (context->printer); |
2a576742 | 472 | } |
2a576742 | 473 | |
b8c23db3 | 474 | diagnostic_set_last_function (context, diagnostic); |
5f7f600e | 475 | pp_newline_and_flush (context->printer); |
2a576742 | 476 | context->printer->prefix = old_prefix; |
477 | free ((char*) new_prefix); | |
478 | } | |
479 | } | |
480 | ||
674b05f5 | 481 | tree |
482 | lhd_make_node (enum tree_code code) | |
483 | { | |
484 | return make_node (code); | |
485 | } | |
624d37a6 | 486 | |
487 | HOST_WIDE_INT | |
488 | lhd_to_target_charset (HOST_WIDE_INT c) | |
489 | { | |
490 | return c; | |
491 | } | |
54d7165a | 492 | |
493 | tree | |
c7d4e749 | 494 | lhd_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se ATTRIBUTE_UNUSED) |
54d7165a | 495 | { |
496 | return expr; | |
497 | } | |
1e8e9920 | 498 | |
499 | /* Return sharing kind if OpenMP sharing attribute of DECL is | |
500 | predetermined, OMP_CLAUSE_DEFAULT_UNSPECIFIED otherwise. */ | |
501 | ||
502 | enum omp_clause_default_kind | |
503 | lhd_omp_predetermined_sharing (tree decl ATTRIBUTE_UNUSED) | |
504 | { | |
505 | if (DECL_ARTIFICIAL (decl)) | |
506 | return OMP_CLAUSE_DEFAULT_SHARED; | |
507 | return OMP_CLAUSE_DEFAULT_UNSPECIFIED; | |
508 | } | |
509 | ||
510 | /* Generate code to copy SRC to DST. */ | |
511 | ||
512 | tree | |
513 | lhd_omp_assignment (tree clause ATTRIBUTE_UNUSED, tree dst, tree src) | |
514 | { | |
75a70cf9 | 515 | return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); |
1e8e9920 | 516 | } |
517 | ||
518 | /* Register language specific type size variables as potentially OpenMP | |
519 | firstprivate variables. */ | |
520 | ||
521 | void | |
522 | lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *c ATTRIBUTE_UNUSED, | |
523 | tree t ATTRIBUTE_UNUSED) | |
524 | { | |
525 | } | |
54be5d7e | 526 | |
bc7bff74 | 527 | /* Return true if TYPE is an OpenMP mappable type. By default return true |
528 | if type is complete. */ | |
529 | ||
530 | bool | |
531 | lhd_omp_mappable_type (tree type) | |
532 | { | |
533 | return COMPLETE_TYPE_P (type); | |
534 | } | |
535 | ||
24470055 | 536 | /* Common function for add_builtin_function and |
537 | add_builtin_function_ext_scope. */ | |
538 | static tree | |
539 | add_builtin_function_common (const char *name, | |
540 | tree type, | |
541 | int function_code, | |
542 | enum built_in_class cl, | |
543 | const char *library_name, | |
544 | tree attrs, | |
545 | tree (*hook) (tree)) | |
54be5d7e | 546 | { |
547 | tree id = get_identifier (name); | |
e60a6f7b | 548 | tree decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, id, type); |
54be5d7e | 549 | |
550 | TREE_PUBLIC (decl) = 1; | |
551 | DECL_EXTERNAL (decl) = 1; | |
552 | DECL_BUILT_IN_CLASS (decl) = cl; | |
ebb7d626 | 553 | |
8458f4ca | 554 | DECL_FUNCTION_CODE (decl) = (enum built_in_function) function_code; |
555 | ||
556 | /* DECL_FUNCTION_CODE is a bitfield; verify that the value fits. */ | |
557 | gcc_assert (DECL_FUNCTION_CODE (decl) == function_code); | |
54be5d7e | 558 | |
7d4c98bc | 559 | if (library_name) |
560 | { | |
561 | tree libname = get_identifier (library_name); | |
562 | SET_DECL_ASSEMBLER_NAME (decl, libname); | |
563 | } | |
54be5d7e | 564 | |
565 | /* Possibly apply some default attributes to this built-in function. */ | |
566 | if (attrs) | |
567 | decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN); | |
568 | else | |
569 | decl_attributes (&decl, NULL_TREE, 0); | |
570 | ||
24470055 | 571 | return hook (decl); |
572 | ||
573 | } | |
574 | ||
575 | /* Create a builtin function. */ | |
576 | ||
577 | tree | |
578 | add_builtin_function (const char *name, | |
579 | tree type, | |
580 | int function_code, | |
581 | enum built_in_class cl, | |
582 | const char *library_name, | |
583 | tree attrs) | |
584 | { | |
585 | return add_builtin_function_common (name, type, function_code, cl, | |
586 | library_name, attrs, | |
587 | lang_hooks.builtin_function); | |
588 | } | |
54be5d7e | 589 | |
24470055 | 590 | /* Like add_builtin_function, but make sure the scope is the external scope. |
591 | This is used to delay putting in back end builtin functions until the ISA | |
592 | that defines the builtin is declared via function specific target options, | |
593 | which can save memory for machines like the x86_64 that have multiple ISAs. | |
594 | If this points to the same function as builtin_function, the backend must | |
595 | add all of the builtins at program initialization time. */ | |
596 | ||
597 | tree | |
598 | add_builtin_function_ext_scope (const char *name, | |
599 | tree type, | |
600 | int function_code, | |
601 | enum built_in_class cl, | |
602 | const char *library_name, | |
603 | tree attrs) | |
604 | { | |
605 | return add_builtin_function_common (name, type, function_code, cl, | |
606 | library_name, attrs, | |
607 | lang_hooks.builtin_function_ext_scope); | |
54be5d7e | 608 | } |
609 | ||
610 | tree | |
611 | lhd_builtin_function (tree decl) | |
612 | { | |
613 | lang_hooks.decls.pushdecl (decl); | |
614 | return decl; | |
615 | } | |
7bfefa9d | 616 | |
549aab72 | 617 | /* Create a builtin type. */ |
618 | ||
619 | tree | |
620 | add_builtin_type (const char *name, tree type) | |
621 | { | |
622 | tree id = get_identifier (name); | |
623 | tree decl = build_decl (BUILTINS_LOCATION, TYPE_DECL, id, type); | |
624 | return lang_hooks.decls.pushdecl (decl); | |
625 | } | |
626 | ||
7bfefa9d | 627 | /* LTO hooks. */ |
628 | ||
629 | /* Used to save and restore any previously active section. */ | |
630 | static section *saved_section; | |
631 | ||
632 | ||
633 | /* Begin a new LTO output section named NAME. This default implementation | |
634 | saves the old section and emits assembly code to switch to the new | |
635 | section. */ | |
636 | ||
637 | void | |
638 | lhd_begin_section (const char *name) | |
639 | { | |
640 | section *section; | |
641 | ||
642 | /* Save the old section so we can restore it in lto_end_asm_section. */ | |
643 | gcc_assert (!saved_section); | |
644 | saved_section = in_section; | |
4e38f8ec | 645 | if (!saved_section) |
646 | saved_section = text_section; | |
7bfefa9d | 647 | |
648 | /* Create a new section and switch to it. */ | |
649 | section = get_section (name, SECTION_DEBUG, NULL); | |
650 | switch_to_section (section); | |
651 | } | |
652 | ||
653 | ||
654 | /* Write DATA of length LEN to the current LTO output section. This default | |
655 | implementation just calls assemble_string and frees BLOCK. */ | |
656 | ||
657 | void | |
658 | lhd_append_data (const void *data, size_t len, void *block) | |
659 | { | |
660 | if (data) | |
661 | assemble_string ((const char *)data, len); | |
662 | free (block); | |
663 | } | |
664 | ||
665 | ||
666 | /* Finish the current LTO output section. This default implementation emits | |
667 | assembly code to switch to any section previously saved by | |
668 | lhd_begin_section. */ | |
669 | ||
670 | void | |
671 | lhd_end_section (void) | |
672 | { | |
673 | if (saved_section) | |
674 | { | |
675 | switch_to_section (saved_section); | |
676 | saved_section = NULL; | |
677 | } | |
678 | } | |
d037099f | 679 | |
680 | /* Empty function that is replaced with appropriate language dependent | |
681 | frame cleanup function for _Cilk_spawn. */ | |
682 | ||
683 | void | |
684 | lhd_install_body_with_frame_cleanup (tree, tree) | |
685 | { | |
686 | } | |
687 | ||
688 | /* Empty function to handle cilk_valid_spawn. */ | |
689 | bool | |
690 | lhd_cilk_detect_spawn (tree *) | |
691 | { | |
692 | return false; | |
693 | } |