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 71834 : lhd_do_nothing (void)
48 : {
49 71834 : }
50 :
51 : /* Do nothing (tree). */
52 :
53 : void
54 4766031 : lhd_do_nothing_t (tree ARG_UNUSED (t))
55 : {
56 4766031 : }
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 9222 : lhd_return_null_const_tree (const_tree ARG_UNUSED (t))
94 : {
95 9222 : 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 5 : 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 5 : if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))
127 : return false;
128 5 : if (VAR_P (decl) && TREE_READONLY (decl))
129 : return false;
130 5 : 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 6360639 : lhd_set_decl_assembler_name (tree decl)
139 : {
140 6360639 : 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 6360639 : 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 6317140 : 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 6317140 : if (TREE_PUBLIC (decl) || DECL_FILE_SCOPE_P (decl))
170 6082042 : id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
171 : else
172 : {
173 235098 : const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
174 235098 : static unsigned long num;
175 235098 : char *label;
176 :
177 235098 : ASM_FORMAT_PRIVATE_NAME (label, name, num++);
178 235098 : id = get_identifier (label);
179 : }
180 :
181 6317140 : SET_DECL_ASSEMBLER_NAME (decl, id);
182 : }
183 :
184 : /* Forcibly overwrite the DECL_ASSEMBLER_NAME for DECL to NAME. */
185 : void
186 171922025 : lhd_overwrite_decl_assembler_name (tree decl, tree name)
187 : {
188 171922025 : DECL_ASSEMBLER_NAME_RAW (decl) = name;
189 171922025 : }
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 131548 : lhd_register_builtin_type (tree ARG_UNUSED (type),
201 : const char * ARG_UNUSED (name))
202 : {
203 131548 : }
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 1045026275 : lhd_get_alias_set (tree ARG_UNUSED (t))
219 : {
220 1045026275 : return -1;
221 : }
222 :
223 : /* This is the default decl_printable_name function. */
224 :
225 : const char *
226 7978886 : lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity))
227 : {
228 7978886 : gcc_assert (decl && DECL_NAME (decl));
229 7978886 : return IDENTIFIER_POINTER (DECL_NAME (decl));
230 : }
231 :
232 : /* This is the default dwarf_name function. */
233 :
234 : const char *
235 7617812 : lhd_dwarf_name (tree t, int verbosity)
236 : {
237 7617812 : gcc_assert (DECL_P (t));
238 :
239 7617812 : 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 618 : lhd_tree_dump_dump_tree (void *di ATTRIBUTE_UNUSED, tree t ATTRIBUTE_UNUSED)
258 : {
259 618 : return false;
260 : }
261 :
262 : /* lang_hooks.tree_dump.type_qual: Determine type qualifiers in a
263 : language-specific way. */
264 :
265 : int
266 102 : lhd_tree_dump_type_quals (const_tree t)
267 : {
268 102 : return TYPE_QUALS (t);
269 : }
270 :
271 : /* lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form. */
272 :
273 : int
274 86739765 : lhd_gimplify_expr (tree *expr_p ATTRIBUTE_UNUSED,
275 : gimple_seq *pre_p ATTRIBUTE_UNUSED,
276 : gimple_seq *post_p ATTRIBUTE_UNUSED)
277 : {
278 86739765 : 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 128212 : lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED)
295 : {
296 128212 : 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 31550 : global_decl_processing (void)
305 : {
306 31550 : tree globals, decl, *vec;
307 31550 : int len, i;
308 :
309 31550 : timevar_stop (TV_PHASE_PARSING);
310 31550 : 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 31550 : globals = lang_hooks.decls.getdecls ();
316 31550 : len = list_length (globals);
317 31550 : 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 141875820 : for (i = 0, decl = globals; i < len; i++, decl = DECL_CHAIN (decl))
323 141812720 : vec[len - i - 1] = decl;
324 :
325 31550 : wrapup_global_declarations (vec, len);
326 31550 : timevar_stop (TV_PHASE_DEFERRED);
327 :
328 31550 : timevar_start (TV_PHASE_PARSING);
329 31550 : free (vec);
330 31550 : }
331 :
332 : /* Called to perform language-specific initialization of CTX. */
333 : void
334 78490 : lhd_initialize_diagnostics (diagnostics::context *ctx ATTRIBUTE_UNUSED)
335 : {
336 78490 : }
337 :
338 : /* Called to register dumps. */
339 : void
340 169784 : lhd_register_dumps (gcc::dump_manager *)
341 : {
342 169784 : }
343 :
344 : /* Called to perform language-specific options initialization. */
345 : void
346 31237 : lhd_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED,
347 : struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED)
348 : {
349 31237 : }
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 106186 : lhd_print_error_function (diagnostics::text_sink &text_output,
374 : const char *file,
375 : const diagnostics::diagnostic_info *diagnostic)
376 : {
377 106186 : diagnostics::context *const context = &text_output.get_context ();
378 106186 : if (diagnostic_last_function_changed (context, diagnostic))
379 : {
380 15832 : pretty_printer *const pp = text_output.get_printer ();
381 15832 : char *old_prefix = pp_take_prefix (pp);
382 15832 : tree abstract_origin = diagnostic_abstract_origin (diagnostic);
383 15832 : char *new_prefix = (file && abstract_origin == NULL)
384 15832 : ? text_output.file_name_as_prefix (file) : NULL;
385 :
386 15832 : pp_set_prefix (pp, new_prefix);
387 :
388 15832 : if (current_function_decl == NULL)
389 599 : pp_printf (pp, _("At top level:"));
390 : else
391 : {
392 15233 : tree fndecl, ao;
393 :
394 15233 : if (abstract_origin)
395 : {
396 197 : ao = BLOCK_ABSTRACT_ORIGIN (abstract_origin);
397 197 : gcc_assert (TREE_CODE (ao) == FUNCTION_DECL);
398 : fndecl = ao;
399 : }
400 : else
401 : fndecl = current_function_decl;
402 :
403 15233 : if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
404 8 : pp_printf
405 8 : (pp, _("In member function %qs"),
406 8 : identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
407 : else
408 15225 : pp_printf
409 15225 : (pp, _("In function %qs"),
410 15225 : identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
411 :
412 15492 : while (abstract_origin)
413 : {
414 259 : location_t *locus;
415 259 : tree block = abstract_origin;
416 :
417 259 : locus = &BLOCK_SOURCE_LOCATION (block);
418 259 : fndecl = NULL;
419 259 : block = BLOCK_SUPERCONTEXT (block);
420 542 : while (block && TREE_CODE (block) == BLOCK
421 566 : && BLOCK_ABSTRACT_ORIGIN (block))
422 : {
423 86 : ao = BLOCK_ABSTRACT_ORIGIN (block);
424 86 : if (TREE_CODE (ao) == FUNCTION_DECL)
425 : {
426 : fndecl = ao;
427 : break;
428 : }
429 24 : else if (TREE_CODE (ao) != BLOCK)
430 : break;
431 :
432 24 : block = BLOCK_SUPERCONTEXT (block);
433 : }
434 259 : if (fndecl)
435 : abstract_origin = block;
436 : else
437 : {
438 455 : while (block && TREE_CODE (block) == BLOCK)
439 258 : block = BLOCK_SUPERCONTEXT (block);
440 :
441 197 : if (block && TREE_CODE (block) == FUNCTION_DECL)
442 : fndecl = block;
443 : abstract_origin = NULL;
444 : }
445 : if (fndecl)
446 : {
447 259 : expanded_location s = expand_location (*locus);
448 259 : pp_comma (pp);
449 259 : pp_newline (pp);
450 259 : if (s.file != NULL)
451 : {
452 259 : if (context->m_show_column)
453 259 : pp_printf (pp,
454 259 : _(" inlined from %qs at %r%s:%d:%d%R"),
455 259 : 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 15233 : pp_colon (pp);
470 : }
471 :
472 15832 : diagnostic_set_last_function (context, diagnostic);
473 15832 : pp_newline_and_flush (pp);
474 15832 : pp->set_prefix (old_prefix);
475 : }
476 106186 : }
477 :
478 : tree
479 225942 : lhd_make_node (enum tree_code code)
480 : {
481 225942 : 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 109837 : lhd_type_for_size (unsigned precision, int unsignedp)
548 : {
549 109837 : int i;
550 :
551 109837 : if (precision == TYPE_PRECISION (integer_type_node))
552 21999 : return unsignedp ? unsigned_type_node : integer_type_node;
553 :
554 87838 : if (precision == TYPE_PRECISION (signed_char_type_node))
555 21956 : return unsignedp ? unsigned_char_type_node : signed_char_type_node;
556 :
557 65882 : if (precision == TYPE_PRECISION (short_integer_type_node))
558 21957 : return unsignedp ? short_unsigned_type_node : short_integer_type_node;
559 :
560 43925 : if (precision == TYPE_PRECISION (long_integer_type_node))
561 21970 : return unsignedp ? long_unsigned_type_node : long_integer_type_node;
562 :
563 21955 : 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 21955 : for (i = 0; i < NUM_INT_N_ENTS; i ++)
569 21955 : if (int_n_enabled_p[i]
570 21955 : && precision == int_n_data[i].bitsize)
571 21955 : return (unsignedp ? int_n_trees[i].unsigned_type
572 21955 : : 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 4556341 : lhd_to_target_charset (HOST_WIDE_INT c)
594 : {
595 4556341 : return c;
596 : }
597 :
598 : tree
599 1200476731 : lhd_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se ATTRIBUTE_UNUSED)
600 : {
601 1200476731 : 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 49702 : lhd_omp_finish_clause (tree, gimple_seq *, bool)
638 : {
639 49702 : }
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 : /* Return false, implying that no additional data-mapping operations
650 : are required for the tree containing a map clause. */
651 :
652 : bool
653 37096 : lhd_omp_deep_mapping_p (const gimple *, tree)
654 : {
655 37096 : return false;
656 : }
657 :
658 : /* Return NULL_TREE, implying that no additional data-mapping operations
659 : are required for the tree containing a map clause. */
660 :
661 : tree
662 41397 : lhd_omp_deep_mapping_cnt (const gimple *, tree, gimple_seq *)
663 : {
664 41397 : return NULL_TREE;
665 : }
666 :
667 : /* Do nothing as no additional data-mapping operations
668 : are required for the second argument that contains a map clause. */
669 :
670 : void
671 0 : lhd_omp_deep_mapping (const gimple *, tree, unsigned HOST_WIDE_INT, tree, tree,
672 : tree, tree, tree, gimple_seq *)
673 : {
674 0 : }
675 :
676 : /* Look up an OpenMP "declare mapper" mapper. */
677 :
678 : tree
679 0 : lhd_omp_mapper_lookup (tree, tree)
680 : {
681 0 : return NULL_TREE;
682 : }
683 :
684 : /* Given the representation used by the front-end to contain a mapper
685 : directive, return the statement for the directive itself. */
686 :
687 : tree
688 0 : lhd_omp_extract_mapper_directive (tree)
689 : {
690 0 : return error_mark_node;
691 : }
692 :
693 : /* Return a simplified form for OMP_ARRAY_SECTION argument, or
694 : error_mark_node if impossible. */
695 :
696 : tree
697 0 : lhd_omp_map_array_section (location_t, tree)
698 : {
699 0 : return error_mark_node;
700 : }
701 :
702 : /* Return true if DECL is a scalar variable (for the purpose of
703 : implicit firstprivatization & mapping). Only if alloc_ptr_ok
704 : are allocatables and pointers accepted. */
705 :
706 : bool
707 23171 : lhd_omp_scalar_p (tree decl, bool ptr_ok)
708 : {
709 23171 : tree type = TREE_TYPE (decl);
710 23171 : if (TREE_CODE (type) == REFERENCE_TYPE)
711 3816 : type = TREE_TYPE (type);
712 23171 : if (TREE_CODE (type) == COMPLEX_TYPE)
713 36 : type = TREE_TYPE (type);
714 23171 : if (INTEGRAL_TYPE_P (type)
715 23171 : || SCALAR_FLOAT_TYPE_P (type)
716 10139 : || (ptr_ok && TREE_CODE (type) == POINTER_TYPE))
717 13052 : return true;
718 : return false;
719 : }
720 :
721 : /* Return static initializer for DECL. */
722 :
723 : tree *
724 4685 : lhd_omp_get_decl_init (tree decl)
725 : {
726 4685 : return &DECL_INITIAL (decl);
727 : }
728 :
729 : /* Free any extra memory used to hold initializer information for
730 : variable declarations. */
731 :
732 : void
733 5401 : lhd_omp_finish_decl_inits (void)
734 : {
735 5401 : }
736 :
737 : /* Register language specific type size variables as potentially OpenMP
738 : firstprivate variables. */
739 :
740 : void
741 8765 : lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *c ATTRIBUTE_UNUSED,
742 : tree t ATTRIBUTE_UNUSED)
743 : {
744 8765 : }
745 :
746 : /* Common function for add_builtin_function, add_builtin_function_ext_scope
747 : and simulate_builtin_function_decl. */
748 :
749 : static tree
750 827373294 : build_builtin_function (location_t location, const char *name, tree type,
751 : int function_code, enum built_in_class cl,
752 : const char *library_name, tree attrs)
753 : {
754 827373294 : tree id = get_identifier (name);
755 827373294 : tree decl = build_decl (location, FUNCTION_DECL, id, type);
756 :
757 827373294 : TREE_PUBLIC (decl) = 1;
758 827373294 : DECL_EXTERNAL (decl) = 1;
759 :
760 827373294 : set_decl_built_in_function (decl, cl, function_code);
761 :
762 827373294 : if (library_name)
763 : {
764 266003939 : tree libname = get_identifier (library_name);
765 :
766 266003939 : libname = targetm.mangle_decl_assembler_name (decl, libname);
767 266003939 : SET_DECL_ASSEMBLER_NAME (decl, libname);
768 : }
769 :
770 : /* Possibly apply some default attributes to this built-in function. */
771 827373294 : if (attrs)
772 483245876 : decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN);
773 : else
774 344127418 : decl_attributes (&decl, NULL_TREE, 0);
775 :
776 827373294 : return decl;
777 : }
778 :
779 : /* Create a builtin function. */
780 :
781 : tree
782 816105171 : add_builtin_function (const char *name,
783 : tree type,
784 : int function_code,
785 : enum built_in_class cl,
786 : const char *library_name,
787 : tree attrs)
788 : {
789 816105171 : tree decl = build_builtin_function (BUILTINS_LOCATION, name, type,
790 : function_code, cl, library_name, attrs);
791 816105171 : return lang_hooks.builtin_function (decl);
792 : }
793 :
794 : /* Like add_builtin_function, but make sure the scope is the external scope.
795 : This is used to delay putting in back end builtin functions until the ISA
796 : that defines the builtin is declared via function specific target options,
797 : which can save memory for machines like the x86_64 that have multiple ISAs.
798 : If this points to the same function as builtin_function, the backend must
799 : add all of the builtins at program initialization time. */
800 :
801 : tree
802 11268123 : add_builtin_function_ext_scope (const char *name,
803 : tree type,
804 : int function_code,
805 : enum built_in_class cl,
806 : const char *library_name,
807 : tree attrs)
808 : {
809 11268123 : tree decl = build_builtin_function (BUILTINS_LOCATION, name, type,
810 : function_code, cl, library_name, attrs);
811 11268123 : return lang_hooks.builtin_function_ext_scope (decl);
812 : }
813 :
814 : /* Simulate a declaration of a target-specific built-in function at
815 : location LOCATION, as though it had been declared directly in the
816 : source language. NAME is the name of the function, TYPE is its function
817 : type, FUNCTION_CODE is the target-specific function code, LIBRARY_NAME
818 : is the name of the underlying library function (NULL if none) and
819 : ATTRS is a list of function attributes.
820 :
821 : Return the decl of the declared function. */
822 :
823 : tree
824 0 : simulate_builtin_function_decl (location_t location, const char *name,
825 : tree type, int function_code,
826 : const char *library_name, tree attrs)
827 : {
828 0 : tree decl = build_builtin_function (location, name, type,
829 : function_code, BUILT_IN_MD,
830 : library_name, attrs);
831 0 : tree new_decl = lang_hooks.simulate_builtin_function_decl (decl);
832 :
833 : /* Give the front end a chance to create a new decl if necessary,
834 : but if the front end discards the decl in favour of a conflicting
835 : (erroneous) previous definition, return the decl that we tried but
836 : failed to add. This allows the caller to process the returned decl
837 : normally, even though the source code won't be able to use it. */
838 0 : if (TREE_CODE (new_decl) == FUNCTION_DECL
839 0 : && fndecl_built_in_p (new_decl, function_code, BUILT_IN_MD))
840 0 : return new_decl;
841 :
842 : return decl;
843 : }
844 :
845 : tree
846 0 : lhd_builtin_function (tree decl)
847 : {
848 0 : lang_hooks.decls.pushdecl (decl);
849 0 : return decl;
850 : }
851 :
852 : /* Create a builtin type. */
853 :
854 : tree
855 0 : add_builtin_type (const char *name, tree type)
856 : {
857 0 : tree id = get_identifier (name);
858 0 : tree decl = build_decl (BUILTINS_LOCATION, TYPE_DECL, id, type);
859 0 : return lang_hooks.decls.pushdecl (decl);
860 : }
861 :
862 : /* LTO hooks. */
863 :
864 : /* Used to save and restore any previously active section. */
865 : static section *saved_section;
866 :
867 :
868 : /* Begin a new LTO output section named NAME. This default implementation
869 : saves the old section and emits assembly code to switch to the new
870 : section. */
871 :
872 : void
873 425663 : lhd_begin_section (const char *name)
874 : {
875 425663 : section *section;
876 :
877 : /* Save the old section so we can restore it in lto_end_asm_section. */
878 425663 : gcc_assert (!saved_section);
879 425663 : saved_section = in_section;
880 425663 : if (!saved_section)
881 21857 : saved_section = text_section;
882 :
883 : /* Create a new section and switch to it. */
884 425663 : section = get_section (name, SECTION_DEBUG | SECTION_EXCLUDE, NULL, true);
885 425663 : switch_to_section (section);
886 425663 : }
887 :
888 :
889 : /* Write DATA of length LEN to the current LTO output section. This default
890 : implementation just calls assemble_string. */
891 :
892 : void
893 4745685 : lhd_append_data (const void *data, size_t len, void *)
894 : {
895 4745685 : if (data)
896 : {
897 4745685 : timevar_push (TV_IPA_LTO_OUTPUT);
898 4745685 : assemble_string ((const char *)data, len);
899 4745685 : timevar_pop (TV_IPA_LTO_OUTPUT);
900 : }
901 4745685 : }
902 :
903 :
904 : /* Finish the current LTO output section. This default implementation emits
905 : assembly code to switch to any section previously saved by
906 : lhd_begin_section. */
907 :
908 : void
909 425663 : lhd_end_section (void)
910 : {
911 425663 : if (saved_section)
912 : {
913 425663 : switch_to_section (saved_section);
914 425663 : saved_section = NULL;
915 : }
916 425663 : }
917 :
918 : /* Default implementation of enum_underlying_base_type using type_for_size. */
919 :
920 : tree
921 1256 : lhd_enum_underlying_base_type (const_tree enum_type)
922 : {
923 1256 : return lang_hooks.types.type_for_size (TYPE_PRECISION (enum_type),
924 1256 : TYPE_UNSIGNED (enum_type));
925 : }
926 :
927 : /* Default implementation of LANG_HOOKS_GET_SUBSTRING_LOCATION. */
928 :
929 : const char *
930 542 : lhd_get_substring_location (const substring_loc &, location_t *)
931 : {
932 542 : return "unimplemented";
933 : }
934 :
935 : /* Default implementation of LANG_HOOKS_DECL_DWARF_ATTRIBUTE. Don't add
936 : any attributes. */
937 :
938 : int
939 6083497 : lhd_decl_dwarf_attribute (const_tree, int)
940 : {
941 6083497 : return -1;
942 : }
943 :
944 : /* Default implementation of LANG_HOOKS_TYPE_DWARF_ATTRIBUTE. Don't add
945 : any attributes. */
946 :
947 : int
948 114244 : lhd_type_dwarf_attribute (const_tree, int)
949 : {
950 114244 : return -1;
951 : }
952 :
953 : /* Default implementation of LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING.
954 : Just return TYPE_SIZE_UNIT unadjusted. */
955 :
956 : tree
957 7663 : lhd_unit_size_without_reusable_padding (tree t)
958 : {
959 7663 : return TYPE_SIZE_UNIT (t);
960 : }
961 :
962 : /* Default implementation for the finalize_early_debug hook. */
963 :
964 : void
965 53113 : lhd_finalize_early_debug (void)
966 : {
967 : /* Emit early debug for reachable functions, and by consequence,
968 : locally scoped symbols. */
969 53113 : struct cgraph_node *cnode;
970 581967 : FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (cnode)
971 528854 : (*debug_hooks->early_global_decl) (cnode->decl);
972 53113 : }
973 :
974 : /* Default implementation of LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE. */
975 :
976 : const char *
977 0 : lhd_get_sarif_source_language (const char *)
978 : {
979 0 : return NULL;
980 : }
981 :
982 : /* Returns true if the current lang_hooks represents the GNU C frontend. */
983 :
984 : bool
985 525577 : lang_GNU_C (void)
986 : {
987 525577 : return (startswith (lang_hooks.name, "GNU C")
988 525577 : && (lang_hooks.name[5] == '\0' || ISDIGIT (lang_hooks.name[5])));
989 : }
990 :
991 : /* Returns true if the current lang_hooks represents the GNU C++ frontend. */
992 :
993 : bool
994 18294 : lang_GNU_CXX (void)
995 : {
996 18294 : return startswith (lang_hooks.name, "GNU C++");
997 : }
998 :
999 : /* Returns true if the current lang_hooks represents the GNU Fortran frontend. */
1000 :
1001 : bool
1002 212574 : lang_GNU_Fortran (void)
1003 : {
1004 212574 : return startswith (lang_hooks.name, "GNU Fortran");
1005 : }
1006 :
1007 : /* Returns true if the current lang_hooks represents the GNU Objective-C
1008 : frontend. */
1009 :
1010 : bool
1011 120608 : lang_GNU_OBJC (void)
1012 : {
1013 120608 : return startswith (lang_hooks.name, "GNU Objective-C");
1014 : }
|