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