Line data Source code
1 : /* Default language-specific hooks.
2 : Copyright (C) 2001-2026 Free Software Foundation, Inc.
3 : Contributed by Alexandre Oliva <aoliva@redhat.com>
4 :
5 : This file is part of GCC.
6 :
7 : GCC is free software; you can redistribute it and/or modify
8 : it under the terms of the GNU General Public License as published by
9 : the Free Software Foundation; either version 3, or (at your option)
10 : any later version.
11 :
12 : GCC is distributed in the hope that it will be useful,
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
18 : along with GCC; see the file COPYING3. If not see
19 : <http://www.gnu.org/licenses/>. */
20 :
21 : #define INCLUDE_VECTOR
22 : #include "config.h"
23 : #include "system.h"
24 : #include "coretypes.h"
25 : #include "target.h"
26 : #include "rtl.h"
27 : #include "tree.h"
28 : #include "timevar.h"
29 : #include "stringpool.h"
30 : #include "diagnostic.h"
31 : #include "intl.h"
32 : #include "toplev.h"
33 : #include "attribs.h"
34 : #include "gimplify.h"
35 : #include "langhooks.h"
36 : #include "tree-diagnostic.h"
37 : #include "output.h"
38 : #include "timevar.h"
39 : #include "stor-layout.h"
40 : #include "cgraph.h"
41 : #include "debug.h"
42 : #include "diagnostics/text-sink.h"
43 :
44 : /* Do nothing; in many cases the default hook. */
45 :
46 : void
47 69980 : lhd_do_nothing (void)
48 : {
49 69980 : }
50 :
51 : /* Do nothing (tree). */
52 :
53 : void
54 4748988 : lhd_do_nothing_t (tree ARG_UNUSED (t))
55 : {
56 4748988 : }
57 :
58 : /* Pass through (tree). */
59 : tree
60 424 : lhd_pass_through_t (tree t)
61 : {
62 424 : return t;
63 : }
64 :
65 : /* Do nothing (int, int, int). Return NULL_TREE. */
66 :
67 : tree
68 0 : lhd_do_nothing_iii_return_null_tree (int ARG_UNUSED (i),
69 : int ARG_UNUSED (j),
70 : int ARG_UNUSED (k))
71 : {
72 0 : return NULL_TREE;
73 : }
74 :
75 : /* Do nothing (function). */
76 :
77 : void
78 0 : lhd_do_nothing_f (struct function * ARG_UNUSED (f))
79 : {
80 0 : }
81 :
82 : /* Do nothing (return NULL_TREE). */
83 :
84 : tree
85 0 : lhd_return_null_tree (tree ARG_UNUSED (t))
86 : {
87 0 : return NULL_TREE;
88 : }
89 :
90 : /* Do nothing (return NULL_TREE). */
91 :
92 : tree
93 9201 : lhd_return_null_const_tree (const_tree ARG_UNUSED (t))
94 : {
95 9201 : return NULL_TREE;
96 : }
97 :
98 : /* The default post options hook. */
99 :
100 : bool
101 1331 : lhd_post_options (const char ** ARG_UNUSED (pfilename))
102 : {
103 : /* Excess precision other than "fast" requires front-end
104 : support. */
105 1331 : flag_excess_precision = EXCESS_PRECISION_FAST;
106 1331 : return false;
107 : }
108 :
109 : /* Called from by print-tree.cc. */
110 :
111 : void
112 71 : lhd_print_tree_nothing (FILE * ARG_UNUSED (file),
113 : tree ARG_UNUSED (node),
114 : int ARG_UNUSED (indent))
115 : {
116 71 : }
117 :
118 : /* Called from check_global_declaration. */
119 :
120 : bool
121 6 : lhd_warn_unused_global_decl (const_tree decl)
122 : {
123 : /* This is what used to exist in check_global_declaration. Probably
124 : not many of these actually apply to non-C languages. */
125 :
126 6 : if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))
127 : return false;
128 6 : if (VAR_P (decl) && TREE_READONLY (decl))
129 : return false;
130 6 : if (DECL_IN_SYSTEM_HEADER (decl))
131 : return false;
132 :
133 : return true;
134 : }
135 :
136 : /* Set the DECL_ASSEMBLER_NAME for DECL. */
137 : void
138 6325336 : lhd_set_decl_assembler_name (tree decl)
139 : {
140 6325336 : tree id;
141 :
142 : /* set_decl_assembler_name may be called on TYPE_DECL to record ODR
143 : name for C++ types. By default types have no ODR names. */
144 6325336 : if (TREE_CODE (decl) == TYPE_DECL)
145 : return;
146 :
147 : /* The language-independent code should never use the
148 : DECL_ASSEMBLER_NAME for lots of DECLs. Only FUNCTION_DECLs and
149 : VAR_DECLs for variables with static storage duration need a real
150 : DECL_ASSEMBLER_NAME. */
151 6282181 : gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
152 : || (VAR_P (decl)
153 : && (TREE_STATIC (decl)
154 : || DECL_EXTERNAL (decl)
155 : || TREE_PUBLIC (decl))));
156 :
157 : /* By default, assume the name to use in assembly code is the same
158 : as that used in the source language. (That's correct for C, and
159 : GCC used to set DECL_ASSEMBLER_NAME to the same value as
160 : DECL_NAME in build_decl, so this choice provides backwards
161 : compatibility with existing front-ends. This assumption is wrapped
162 : in a target hook, to allow for target-specific modification of the
163 : identifier.
164 :
165 : Can't use just the variable's own name for a variable whose scope
166 : is less than the whole compilation. Concatenate a distinguishing
167 : number. */
168 :
169 6282181 : if (TREE_PUBLIC (decl) || DECL_FILE_SCOPE_P (decl))
170 6049747 : id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
171 : else
172 : {
173 232434 : const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
174 232434 : static unsigned long num;
175 232434 : char *label;
176 :
177 232434 : ASM_FORMAT_PRIVATE_NAME (label, name, num++);
178 232434 : id = get_identifier (label);
179 : }
180 :
181 6282181 : SET_DECL_ASSEMBLER_NAME (decl, id);
182 : }
183 :
184 : /* Forcibly overwrite the DECL_ASSEMBLER_NAME for DECL to NAME. */
185 : void
186 170519580 : lhd_overwrite_decl_assembler_name (tree decl, tree name)
187 : {
188 170519580 : DECL_ASSEMBLER_NAME_RAW (decl) = name;
189 170519580 : }
190 :
191 : /* Type promotion for variable arguments. */
192 : tree
193 0 : lhd_type_promotes_to (tree ARG_UNUSED (type))
194 : {
195 0 : gcc_unreachable ();
196 : }
197 :
198 : /* Registration of machine- or os-specific builtin types. */
199 : void
200 130460 : lhd_register_builtin_type (tree ARG_UNUSED (type),
201 : const char * ARG_UNUSED (name))
202 : {
203 130460 : }
204 :
205 : /* Invalid use of an incomplete type. */
206 : void
207 0 : lhd_incomplete_type_error (location_t ARG_UNUSED (loc),
208 : const_tree ARG_UNUSED (value), const_tree type)
209 : {
210 0 : gcc_assert (TREE_CODE (type) == ERROR_MARK);
211 0 : return;
212 : }
213 :
214 : /* Provide a default routine for alias sets that always returns -1. This
215 : is used by languages that don't need to do anything special. */
216 :
217 : alias_set_type
218 1035777523 : lhd_get_alias_set (tree ARG_UNUSED (t))
219 : {
220 1035777523 : return -1;
221 : }
222 :
223 : /* This is the default decl_printable_name function. */
224 :
225 : const char *
226 7980485 : lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity))
227 : {
228 7980485 : gcc_assert (decl && DECL_NAME (decl));
229 7980485 : return IDENTIFIER_POINTER (DECL_NAME (decl));
230 : }
231 :
232 : /* This is the default dwarf_name function. */
233 :
234 : const char *
235 7622848 : lhd_dwarf_name (tree t, int verbosity)
236 : {
237 7622848 : gcc_assert (DECL_P (t));
238 :
239 7622848 : return lang_hooks.decl_printable_name (t, verbosity);
240 : }
241 :
242 : /* This compares two types for equivalence ("compatible" in C-based languages).
243 : This routine should only return 1 if it is sure. It should not be used
244 : in contexts where erroneously returning 0 causes problems. */
245 :
246 : int
247 0 : lhd_types_compatible_p (tree x, tree y)
248 : {
249 0 : return TYPE_MAIN_VARIANT (x) == TYPE_MAIN_VARIANT (y);
250 : }
251 :
252 : /* lang_hooks.tree_dump.dump_tree: Dump language-specific parts of tree
253 : nodes. Returns nonzero if it does not want the usual dumping of the
254 : second argument. */
255 :
256 : bool
257 0 : lhd_tree_dump_dump_tree (void *di ATTRIBUTE_UNUSED, tree t ATTRIBUTE_UNUSED)
258 : {
259 0 : return false;
260 : }
261 :
262 : /* lang_hooks.tree_dump.type_qual: Determine type qualifiers in a
263 : language-specific way. */
264 :
265 : int
266 4 : lhd_tree_dump_type_quals (const_tree t)
267 : {
268 4 : return TYPE_QUALS (t);
269 : }
270 :
271 : /* lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form. */
272 :
273 : int
274 85797242 : lhd_gimplify_expr (tree *expr_p ATTRIBUTE_UNUSED,
275 : gimple_seq *pre_p ATTRIBUTE_UNUSED,
276 : gimple_seq *post_p ATTRIBUTE_UNUSED)
277 : {
278 85797242 : return GS_UNHANDLED;
279 : }
280 :
281 : /* lang_hooks.tree_size: Determine the size of a tree with code C,
282 : which is a language-specific tree code in category tcc_constant,
283 : tcc_exceptional or tcc_type. The default expects never to be called. */
284 : size_t
285 0 : lhd_tree_size (enum tree_code c ATTRIBUTE_UNUSED)
286 : {
287 0 : gcc_unreachable ();
288 : }
289 :
290 : /* Return true if decl, which is a function decl, may be called by a
291 : sibcall. */
292 :
293 : bool
294 129350 : lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED)
295 : {
296 129350 : return true;
297 : }
298 :
299 : /* Generic global declaration processing. This is meant to be called
300 : by the front-ends at the end of parsing. C/C++ do their own thing,
301 : but other front-ends may call this. */
302 :
303 : void
304 31278 : global_decl_processing (void)
305 : {
306 31278 : tree globals, decl, *vec;
307 31278 : int len, i;
308 :
309 31278 : timevar_stop (TV_PHASE_PARSING);
310 31278 : timevar_start (TV_PHASE_DEFERRED);
311 : /* Really define vars that have had only a tentative definition.
312 : Really output inline functions that must actually be callable
313 : and have not been output so far. */
314 :
315 31278 : globals = lang_hooks.decls.getdecls ();
316 31278 : len = list_length (globals);
317 31278 : vec = XNEWVEC (tree, len);
318 :
319 : /* Process the decls in reverse order--earliest first.
320 : Put them into VEC from back to front, then take out from front. */
321 :
322 140620637 : for (i = 0, decl = globals; i < len; i++, decl = DECL_CHAIN (decl))
323 140558081 : vec[len - i - 1] = decl;
324 :
325 31278 : wrapup_global_declarations (vec, len);
326 31278 : timevar_stop (TV_PHASE_DEFERRED);
327 :
328 31278 : timevar_start (TV_PHASE_PARSING);
329 31278 : free (vec);
330 31278 : }
331 :
332 : /* Called to perform language-specific initialization of CTX. */
333 : void
334 77264 : lhd_initialize_diagnostics (diagnostics::context *ctx ATTRIBUTE_UNUSED)
335 : {
336 77264 : }
337 :
338 : /* Called to register dumps. */
339 : void
340 167842 : lhd_register_dumps (gcc::dump_manager *)
341 : {
342 167842 : }
343 :
344 : /* Called to perform language-specific options initialization. */
345 : void
346 31005 : lhd_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED,
347 : struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED)
348 : {
349 31005 : }
350 :
351 : /* By default, always complain about options for the wrong language. */
352 : bool
353 6 : lhd_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED)
354 : {
355 6 : return true;
356 : }
357 :
358 : /* By default, no language-specific options are valid. */
359 : bool
360 0 : lhd_handle_option (size_t code ATTRIBUTE_UNUSED,
361 : const char *arg ATTRIBUTE_UNUSED,
362 : HOST_WIDE_INT value ATTRIBUTE_UNUSED,
363 : int kind ATTRIBUTE_UNUSED,
364 : location_t loc ATTRIBUTE_UNUSED,
365 : const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
366 : {
367 0 : return false;
368 : }
369 :
370 : /* The default function to print out name of current function that caused
371 : an error. */
372 : void
373 105105 : lhd_print_error_function (diagnostics::text_sink &text_output,
374 : const char *file,
375 : const diagnostics::diagnostic_info *diagnostic)
376 : {
377 105105 : diagnostics::context *const context = &text_output.get_context ();
378 105105 : if (diagnostic_last_function_changed (context, diagnostic))
379 : {
380 15620 : pretty_printer *const pp = text_output.get_printer ();
381 15620 : char *old_prefix = pp_take_prefix (pp);
382 15620 : tree abstract_origin = diagnostic_abstract_origin (diagnostic);
383 15620 : char *new_prefix = (file && abstract_origin == NULL)
384 15620 : ? text_output.file_name_as_prefix (file) : NULL;
385 :
386 15620 : pp_set_prefix (pp, new_prefix);
387 :
388 15620 : if (current_function_decl == NULL)
389 599 : pp_printf (pp, _("At top level:"));
390 : else
391 : {
392 15021 : tree fndecl, ao;
393 :
394 15021 : if (abstract_origin)
395 : {
396 192 : ao = BLOCK_ABSTRACT_ORIGIN (abstract_origin);
397 192 : gcc_assert (TREE_CODE (ao) == FUNCTION_DECL);
398 : fndecl = ao;
399 : }
400 : else
401 : fndecl = current_function_decl;
402 :
403 15021 : if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
404 6 : pp_printf
405 6 : (pp, _("In member function %qs"),
406 6 : identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
407 : else
408 15015 : pp_printf
409 15015 : (pp, _("In function %qs"),
410 15015 : identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
411 :
412 15270 : while (abstract_origin)
413 : {
414 249 : location_t *locus;
415 249 : tree block = abstract_origin;
416 :
417 249 : locus = &BLOCK_SOURCE_LOCATION (block);
418 249 : fndecl = NULL;
419 249 : block = BLOCK_SUPERCONTEXT (block);
420 521 : while (block && TREE_CODE (block) == BLOCK
421 544 : && BLOCK_ABSTRACT_ORIGIN (block))
422 : {
423 80 : ao = BLOCK_ABSTRACT_ORIGIN (block);
424 80 : if (TREE_CODE (ao) == FUNCTION_DECL)
425 : {
426 : fndecl = ao;
427 : break;
428 : }
429 23 : else if (TREE_CODE (ao) != BLOCK)
430 : break;
431 :
432 23 : block = BLOCK_SUPERCONTEXT (block);
433 : }
434 249 : if (fndecl)
435 : abstract_origin = block;
436 : else
437 : {
438 445 : while (block && TREE_CODE (block) == BLOCK)
439 253 : block = BLOCK_SUPERCONTEXT (block);
440 :
441 192 : if (block && TREE_CODE (block) == FUNCTION_DECL)
442 : fndecl = block;
443 : abstract_origin = NULL;
444 : }
445 : if (fndecl)
446 : {
447 249 : expanded_location s = expand_location (*locus);
448 249 : pp_comma (pp);
449 249 : pp_newline (pp);
450 249 : if (s.file != NULL)
451 : {
452 249 : if (context->m_show_column)
453 249 : pp_printf (pp,
454 249 : _(" inlined from %qs at %r%s:%d:%d%R"),
455 249 : identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
456 : "locus", s.file, s.line, s.column);
457 : else
458 0 : pp_printf (pp,
459 0 : _(" inlined from %qs at %r%s:%d%R"),
460 0 : identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
461 : "locus", s.file, s.line);
462 :
463 : }
464 : else
465 0 : pp_printf (pp, _(" inlined from %qs"),
466 0 : identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
467 : }
468 : }
469 15021 : pp_colon (pp);
470 : }
471 :
472 15620 : diagnostic_set_last_function (context, diagnostic);
473 15620 : pp_newline_and_flush (pp);
474 15620 : pp->set_prefix (old_prefix);
475 : }
476 105105 : }
477 :
478 : tree
479 223483 : lhd_make_node (enum tree_code code)
480 : {
481 223483 : return make_node (code);
482 : }
483 :
484 : /* Default implementation of LANG_HOOKS_SIMULATE_ENUM_DECL. Assume a
485 : simple int-based enumerator (which is all the hook can be used for
486 : at present) and push each decl individually without any decoration.
487 :
488 : This definition is suitable for LTO and is generic enough that it
489 : might be reusable elsewhere. */
490 : tree
491 0 : lhd_simulate_enum_decl (location_t loc, const char *name,
492 : vec<string_int_pair> *values_ptr)
493 : {
494 0 : tree enumtype = lang_hooks.types.make_type (ENUMERAL_TYPE);
495 0 : tree enumdecl = build_decl (loc, TYPE_DECL, get_identifier (name), enumtype);
496 0 : TYPE_STUB_DECL (enumtype) = enumdecl;
497 :
498 0 : tree value_chain = NULL_TREE;
499 0 : string_int_pair *value;
500 0 : vec<string_int_pair> values = *values_ptr;
501 0 : unsigned int i;
502 0 : FOR_EACH_VEC_ELT (values, i, value)
503 : {
504 0 : tree value_decl = build_decl (loc, CONST_DECL,
505 : get_identifier (value->first), enumtype);
506 0 : DECL_INITIAL (value_decl) = build_int_cst (integer_type_node,
507 0 : value->second);
508 0 : lang_hooks.decls.pushdecl (value_decl);
509 0 : value_chain = tree_cons (value_decl, DECL_INITIAL (value_decl),
510 : value_chain);
511 : }
512 :
513 0 : TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (integer_type_node);
514 0 : TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (integer_type_node);
515 0 : SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (integer_type_node));
516 0 : TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);
517 0 : layout_type (enumtype);
518 0 : lang_hooks.decls.pushdecl (enumdecl);
519 :
520 0 : return enumtype;
521 : }
522 :
523 : /* Default implementation of LANG_HOOKS_SIMULATE_RECORD_DECL.
524 : Just create a normal RECORD_TYPE and a TYPE_DECL for it. */
525 : tree
526 0 : lhd_simulate_record_decl (location_t loc, const char *name,
527 : array_slice<const tree> fields)
528 : {
529 0 : for (unsigned int i = 1; i < fields.size (); ++i)
530 : /* Reversed by finish_builtin_struct. */
531 0 : DECL_CHAIN (fields[i]) = fields[i - 1];
532 :
533 0 : tree type = lang_hooks.types.make_type (RECORD_TYPE);
534 0 : finish_builtin_struct (type, name, fields.back (), NULL_TREE);
535 :
536 0 : tree decl = build_decl (loc, TYPE_DECL, get_identifier (name), type);
537 0 : lang_hooks.decls.pushdecl (decl);
538 :
539 0 : return type;
540 : }
541 :
542 : /* Default implementation of LANG_HOOKS_TYPE_FOR_SIZE.
543 : Return an integer type with PRECISION bits of precision,
544 : that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
545 :
546 : tree
547 108842 : lhd_type_for_size (unsigned precision, int unsignedp)
548 : {
549 108842 : int i;
550 :
551 108842 : if (precision == TYPE_PRECISION (integer_type_node))
552 21800 : return unsignedp ? unsigned_type_node : integer_type_node;
553 :
554 87042 : if (precision == TYPE_PRECISION (signed_char_type_node))
555 21757 : return unsignedp ? unsigned_char_type_node : signed_char_type_node;
556 :
557 65285 : if (precision == TYPE_PRECISION (short_integer_type_node))
558 21758 : return unsignedp ? short_unsigned_type_node : short_integer_type_node;
559 :
560 43527 : if (precision == TYPE_PRECISION (long_integer_type_node))
561 21771 : return unsignedp ? long_unsigned_type_node : long_integer_type_node;
562 :
563 21756 : if (precision == TYPE_PRECISION (long_long_integer_type_node))
564 0 : return unsignedp
565 0 : ? long_long_unsigned_type_node
566 0 : : long_long_integer_type_node;
567 :
568 21756 : for (i = 0; i < NUM_INT_N_ENTS; i ++)
569 21756 : if (int_n_enabled_p[i]
570 21756 : && precision == int_n_data[i].bitsize)
571 21756 : return (unsignedp ? int_n_trees[i].unsigned_type
572 21756 : : int_n_trees[i].signed_type);
573 :
574 0 : if (precision <= TYPE_PRECISION (intQI_type_node))
575 0 : return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
576 :
577 0 : if (precision <= TYPE_PRECISION (intHI_type_node))
578 0 : return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
579 :
580 0 : if (precision <= TYPE_PRECISION (intSI_type_node))
581 0 : return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
582 :
583 0 : if (precision <= TYPE_PRECISION (intDI_type_node))
584 0 : return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
585 :
586 0 : if (precision <= TYPE_PRECISION (intTI_type_node))
587 0 : return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
588 :
589 : return NULL_TREE;
590 : }
591 :
592 : HOST_WIDE_INT
593 4523609 : lhd_to_target_charset (HOST_WIDE_INT c)
594 : {
595 4523609 : return c;
596 : }
597 :
598 : tree
599 1371865706 : lhd_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se ATTRIBUTE_UNUSED)
600 : {
601 1371865706 : return expr;
602 : }
603 :
604 : /* Return sharing kind if OpenMP sharing attribute of DECL is
605 : predetermined, OMP_CLAUSE_DEFAULT_UNSPECIFIED otherwise. */
606 :
607 : enum omp_clause_default_kind
608 0 : lhd_omp_predetermined_sharing (tree decl)
609 : {
610 0 : if (DECL_ARTIFICIAL (decl))
611 0 : return OMP_CLAUSE_DEFAULT_SHARED;
612 : return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
613 : }
614 :
615 : /* Return sharing kind if OpenMP mapping attribute of DECL is
616 : predetermined, OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED otherwise. */
617 :
618 : enum omp_clause_defaultmap_kind
619 0 : lhd_omp_predetermined_mapping (tree decl)
620 : {
621 0 : if (DECL_ARTIFICIAL (decl))
622 0 : return OMP_CLAUSE_DEFAULTMAP_TO;
623 : return OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
624 : }
625 :
626 : /* Generate code to copy SRC to DST. */
627 :
628 : tree
629 0 : lhd_omp_assignment (tree clause ATTRIBUTE_UNUSED, tree dst, tree src)
630 : {
631 0 : return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
632 : }
633 :
634 : /* Finalize clause C. */
635 :
636 : void
637 49701 : lhd_omp_finish_clause (tree, gimple_seq *, bool)
638 : {
639 49701 : }
640 :
641 : /* Return array size; cf. omp_array_data. */
642 :
643 : tree
644 0 : lhd_omp_array_size (tree, gimple_seq *)
645 : {
646 0 : return NULL_TREE;
647 : }
648 :
649 : /* Returns true when additional mappings for a decl are needed. */
650 :
651 : bool
652 36511 : lhd_omp_deep_mapping_p (const gimple *, tree)
653 : {
654 36511 : return false;
655 : }
656 :
657 : /* Returns number of additional mappings for a decl. */
658 :
659 : tree
660 40818 : lhd_omp_deep_mapping_cnt (const gimple *, tree, gimple_seq *)
661 : {
662 40818 : return NULL_TREE;
663 : }
664 :
665 : /* Do the additional mappings. */
666 :
667 : void
668 0 : lhd_omp_deep_mapping (const gimple *, tree, unsigned HOST_WIDE_INT, tree, tree,
669 : tree, tree, tree, gimple_seq *)
670 : {
671 0 : }
672 :
673 : /* Look up an OpenMP "declare mapper" mapper. */
674 :
675 : tree
676 0 : lhd_omp_mapper_lookup (tree, tree)
677 : {
678 0 : return NULL_TREE;
679 : }
680 :
681 : /* Given the representation used by the front-end to contain a mapper
682 : directive, return the statement for the directive itself. */
683 :
684 : tree
685 0 : lhd_omp_extract_mapper_directive (tree)
686 : {
687 0 : return error_mark_node;
688 : }
689 :
690 : /* Return a simplified form for OMP_ARRAY_SECTION argument, or
691 : error_mark_node if impossible. */
692 :
693 : tree
694 0 : lhd_omp_map_array_section (location_t, tree)
695 : {
696 0 : return error_mark_node;
697 : }
698 :
699 : /* Return true if DECL is a scalar variable (for the purpose of
700 : implicit firstprivatization & mapping). Only if alloc_ptr_ok
701 : are allocatables and pointers accepted. */
702 :
703 : bool
704 22914 : lhd_omp_scalar_p (tree decl, bool ptr_ok)
705 : {
706 22914 : tree type = TREE_TYPE (decl);
707 22914 : if (TREE_CODE (type) == REFERENCE_TYPE)
708 3688 : type = TREE_TYPE (type);
709 22914 : if (TREE_CODE (type) == COMPLEX_TYPE)
710 36 : type = TREE_TYPE (type);
711 22914 : if (INTEGRAL_TYPE_P (type)
712 22914 : || SCALAR_FLOAT_TYPE_P (type)
713 9961 : || (ptr_ok && TREE_CODE (type) == POINTER_TYPE))
714 12973 : return true;
715 : return false;
716 : }
717 :
718 : /* Return static initializer for DECL. */
719 :
720 : tree *
721 4650 : lhd_omp_get_decl_init (tree decl)
722 : {
723 4650 : return &DECL_INITIAL (decl);
724 : }
725 :
726 : /* Free any extra memory used to hold initializer information for
727 : variable declarations. */
728 :
729 : void
730 5335 : lhd_omp_finish_decl_inits (void)
731 : {
732 5335 : }
733 :
734 : /* Register language specific type size variables as potentially OpenMP
735 : firstprivate variables. */
736 :
737 : void
738 8761 : lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *c ATTRIBUTE_UNUSED,
739 : tree t ATTRIBUTE_UNUSED)
740 : {
741 8761 : }
742 :
743 : /* Common function for add_builtin_function, add_builtin_function_ext_scope
744 : and simulate_builtin_function_decl. */
745 :
746 : static tree
747 819602156 : build_builtin_function (location_t location, const char *name, tree type,
748 : int function_code, enum built_in_class cl,
749 : const char *library_name, tree attrs)
750 : {
751 819602156 : tree id = get_identifier (name);
752 819602156 : tree decl = build_decl (location, FUNCTION_DECL, id, type);
753 :
754 819602156 : TREE_PUBLIC (decl) = 1;
755 819602156 : DECL_EXTERNAL (decl) = 1;
756 :
757 819602156 : set_decl_built_in_function (decl, cl, function_code);
758 :
759 819602156 : if (library_name)
760 : {
761 263569168 : tree libname = get_identifier (library_name);
762 :
763 263569168 : libname = targetm.mangle_decl_assembler_name (decl, libname);
764 263569168 : SET_DECL_ASSEMBLER_NAME (decl, libname);
765 : }
766 :
767 : /* Possibly apply some default attributes to this built-in function. */
768 819602156 : if (attrs)
769 478081802 : decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN);
770 : else
771 341520354 : decl_attributes (&decl, NULL_TREE, 0);
772 :
773 819602156 : return decl;
774 : }
775 :
776 : /* Create a builtin function. */
777 :
778 : tree
779 808396639 : add_builtin_function (const char *name,
780 : tree type,
781 : int function_code,
782 : enum built_in_class cl,
783 : const char *library_name,
784 : tree attrs)
785 : {
786 808396639 : tree decl = build_builtin_function (BUILTINS_LOCATION, name, type,
787 : function_code, cl, library_name, attrs);
788 808396639 : return lang_hooks.builtin_function (decl);
789 : }
790 :
791 : /* Like add_builtin_function, but make sure the scope is the external scope.
792 : This is used to delay putting in back end builtin functions until the ISA
793 : that defines the builtin is declared via function specific target options,
794 : which can save memory for machines like the x86_64 that have multiple ISAs.
795 : If this points to the same function as builtin_function, the backend must
796 : add all of the builtins at program initialization time. */
797 :
798 : tree
799 11205517 : add_builtin_function_ext_scope (const char *name,
800 : tree type,
801 : int function_code,
802 : enum built_in_class cl,
803 : const char *library_name,
804 : tree attrs)
805 : {
806 11205517 : tree decl = build_builtin_function (BUILTINS_LOCATION, name, type,
807 : function_code, cl, library_name, attrs);
808 11205517 : return lang_hooks.builtin_function_ext_scope (decl);
809 : }
810 :
811 : /* Simulate a declaration of a target-specific built-in function at
812 : location LOCATION, as though it had been declared directly in the
813 : source language. NAME is the name of the function, TYPE is its function
814 : type, FUNCTION_CODE is the target-specific function code, LIBRARY_NAME
815 : is the name of the underlying library function (NULL if none) and
816 : ATTRS is a list of function attributes.
817 :
818 : Return the decl of the declared function. */
819 :
820 : tree
821 0 : simulate_builtin_function_decl (location_t location, const char *name,
822 : tree type, int function_code,
823 : const char *library_name, tree attrs)
824 : {
825 0 : tree decl = build_builtin_function (location, name, type,
826 : function_code, BUILT_IN_MD,
827 : library_name, attrs);
828 0 : tree new_decl = lang_hooks.simulate_builtin_function_decl (decl);
829 :
830 : /* Give the front end a chance to create a new decl if necessary,
831 : but if the front end discards the decl in favour of a conflicting
832 : (erroneous) previous definition, return the decl that we tried but
833 : failed to add. This allows the caller to process the returned decl
834 : normally, even though the source code won't be able to use it. */
835 0 : if (TREE_CODE (new_decl) == FUNCTION_DECL
836 0 : && fndecl_built_in_p (new_decl, function_code, BUILT_IN_MD))
837 0 : return new_decl;
838 :
839 : return decl;
840 : }
841 :
842 : tree
843 0 : lhd_builtin_function (tree decl)
844 : {
845 0 : lang_hooks.decls.pushdecl (decl);
846 0 : return decl;
847 : }
848 :
849 : /* Create a builtin type. */
850 :
851 : tree
852 0 : add_builtin_type (const char *name, tree type)
853 : {
854 0 : tree id = get_identifier (name);
855 0 : tree decl = build_decl (BUILTINS_LOCATION, TYPE_DECL, id, type);
856 0 : return lang_hooks.decls.pushdecl (decl);
857 : }
858 :
859 : /* LTO hooks. */
860 :
861 : /* Used to save and restore any previously active section. */
862 : static section *saved_section;
863 :
864 :
865 : /* Begin a new LTO output section named NAME. This default implementation
866 : saves the old section and emits assembly code to switch to the new
867 : section. */
868 :
869 : void
870 423127 : lhd_begin_section (const char *name)
871 : {
872 423127 : section *section;
873 :
874 : /* Save the old section so we can restore it in lto_end_asm_section. */
875 423127 : gcc_assert (!saved_section);
876 423127 : saved_section = in_section;
877 423127 : if (!saved_section)
878 21725 : saved_section = text_section;
879 :
880 : /* Create a new section and switch to it. */
881 423127 : section = get_section (name, SECTION_DEBUG | SECTION_EXCLUDE, NULL, true);
882 423127 : switch_to_section (section);
883 423127 : }
884 :
885 :
886 : /* Write DATA of length LEN to the current LTO output section. This default
887 : implementation just calls assemble_string. */
888 :
889 : void
890 4737541 : lhd_append_data (const void *data, size_t len, void *)
891 : {
892 4737541 : if (data)
893 : {
894 4737541 : timevar_push (TV_IPA_LTO_OUTPUT);
895 4737541 : assemble_string ((const char *)data, len);
896 4737541 : timevar_pop (TV_IPA_LTO_OUTPUT);
897 : }
898 4737541 : }
899 :
900 :
901 : /* Finish the current LTO output section. This default implementation emits
902 : assembly code to switch to any section previously saved by
903 : lhd_begin_section. */
904 :
905 : void
906 423127 : lhd_end_section (void)
907 : {
908 423127 : if (saved_section)
909 : {
910 423127 : switch_to_section (saved_section);
911 423127 : saved_section = NULL;
912 : }
913 423127 : }
914 :
915 : /* Default implementation of enum_underlying_base_type using type_for_size. */
916 :
917 : tree
918 91205 : lhd_enum_underlying_base_type (const_tree enum_type)
919 : {
920 91205 : return lang_hooks.types.type_for_size (TYPE_PRECISION (enum_type),
921 91205 : TYPE_UNSIGNED (enum_type));
922 : }
923 :
924 : /* Default implementation of LANG_HOOKS_GET_SUBSTRING_LOCATION. */
925 :
926 : const char *
927 541 : lhd_get_substring_location (const substring_loc &, location_t *)
928 : {
929 541 : return "unimplemented";
930 : }
931 :
932 : /* Default implementation of LANG_HOOKS_DECL_DWARF_ATTRIBUTE. Don't add
933 : any attributes. */
934 :
935 : int
936 6072327 : lhd_decl_dwarf_attribute (const_tree, int)
937 : {
938 6072327 : return -1;
939 : }
940 :
941 : /* Default implementation of LANG_HOOKS_TYPE_DWARF_ATTRIBUTE. Don't add
942 : any attributes. */
943 :
944 : int
945 114204 : lhd_type_dwarf_attribute (const_tree, int)
946 : {
947 114204 : return -1;
948 : }
949 :
950 : /* Default implementation of LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING.
951 : Just return TYPE_SIZE_UNIT unadjusted. */
952 :
953 : tree
954 7661 : lhd_unit_size_without_reusable_padding (tree t)
955 : {
956 7661 : return TYPE_SIZE_UNIT (t);
957 : }
958 :
959 : /* Default implementation for the finalize_early_debug hook. */
960 :
961 : void
962 51990 : lhd_finalize_early_debug (void)
963 : {
964 : /* Emit early debug for reachable functions, and by consequence,
965 : locally scoped symbols. */
966 51990 : struct cgraph_node *cnode;
967 574090 : FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (cnode)
968 522100 : (*debug_hooks->early_global_decl) (cnode->decl);
969 51990 : }
970 :
971 : /* Default implementation of LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE. */
972 :
973 : const char *
974 0 : lhd_get_sarif_source_language (const char *)
975 : {
976 0 : return NULL;
977 : }
978 :
979 : /* Returns true if the current lang_hooks represents the GNU C frontend. */
980 :
981 : bool
982 520337 : lang_GNU_C (void)
983 : {
984 520337 : return (startswith (lang_hooks.name, "GNU C")
985 520337 : && (lang_hooks.name[5] == '\0' || ISDIGIT (lang_hooks.name[5])));
986 : }
987 :
988 : /* Returns true if the current lang_hooks represents the GNU C++ frontend. */
989 :
990 : bool
991 18015 : lang_GNU_CXX (void)
992 : {
993 18015 : return startswith (lang_hooks.name, "GNU C++");
994 : }
995 :
996 : /* Returns true if the current lang_hooks represents the GNU Fortran frontend. */
997 :
998 : bool
999 212531 : lang_GNU_Fortran (void)
1000 : {
1001 212531 : return startswith (lang_hooks.name, "GNU Fortran");
1002 : }
1003 :
1004 : /* Returns true if the current lang_hooks represents the GNU Objective-C
1005 : frontend. */
1006 :
1007 : bool
1008 119358 : lang_GNU_OBJC (void)
1009 : {
1010 119358 : return startswith (lang_hooks.name, "GNU Objective-C");
1011 : }
|