Add some gcc_asserts for vector extract processing.
[official-gcc.git] / gcc / langhooks.c
blob640bd012d1c5881094920f4514cb23829bf081e2
1 /* Default language-specific hooks.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
3 Contributed by Alexandre Oliva <aoliva@redhat.com>
5 This file is part of GCC.
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.
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.
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/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "target.h"
25 #include "rtl.h"
26 #include "tree.h"
27 #include "timevar.h"
28 #include "stringpool.h"
29 #include "diagnostic.h"
30 #include "intl.h"
31 #include "toplev.h"
32 #include "attribs.h"
33 #include "gimplify.h"
34 #include "langhooks.h"
35 #include "tree-diagnostic.h"
36 #include "output.h"
37 #include "timevar.h"
38 #include "stor-layout.h"
40 /* Do nothing; in many cases the default hook. */
42 void
43 lhd_do_nothing (void)
47 /* Do nothing (tree). */
49 void
50 lhd_do_nothing_t (tree ARG_UNUSED (t))
54 /* Pass through (tree). */
55 tree
56 lhd_pass_through_t (tree t)
58 return t;
61 /* Do nothing (int, int, int). Return NULL_TREE. */
63 tree
64 lhd_do_nothing_iii_return_null_tree (int ARG_UNUSED (i),
65 int ARG_UNUSED (j),
66 int ARG_UNUSED (k))
68 return NULL_TREE;
71 /* Do nothing (function). */
73 void
74 lhd_do_nothing_f (struct function * ARG_UNUSED (f))
78 /* Do nothing (return NULL_TREE). */
80 tree
81 lhd_return_null_tree (tree ARG_UNUSED (t))
83 return NULL_TREE;
86 /* Do nothing (return NULL_TREE). */
88 tree
89 lhd_return_null_const_tree (const_tree ARG_UNUSED (t))
91 return NULL_TREE;
94 /* The default post options hook. */
96 bool
97 lhd_post_options (const char ** ARG_UNUSED (pfilename))
99 /* Excess precision other than "fast" requires front-end
100 support. */
101 flag_excess_precision = EXCESS_PRECISION_FAST;
102 return false;
105 /* Called from by print-tree.c. */
107 void
108 lhd_print_tree_nothing (FILE * ARG_UNUSED (file),
109 tree ARG_UNUSED (node),
110 int ARG_UNUSED (indent))
114 /* Called from check_global_declaration. */
116 bool
117 lhd_warn_unused_global_decl (const_tree decl)
119 /* This is what used to exist in check_global_declaration. Probably
120 not many of these actually apply to non-C languages. */
122 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))
123 return false;
124 if (VAR_P (decl) && TREE_READONLY (decl))
125 return false;
126 if (DECL_IN_SYSTEM_HEADER (decl))
127 return false;
129 return true;
132 /* Set the DECL_ASSEMBLER_NAME for DECL. */
133 void
134 lhd_set_decl_assembler_name (tree decl)
136 tree id;
138 /* set_decl_assembler_name may be called on TYPE_DECL to record ODR
139 name for C++ types. By default types have no ODR names. */
140 if (TREE_CODE (decl) == TYPE_DECL)
141 return;
143 /* The language-independent code should never use the
144 DECL_ASSEMBLER_NAME for lots of DECLs. Only FUNCTION_DECLs and
145 VAR_DECLs for variables with static storage duration need a real
146 DECL_ASSEMBLER_NAME. */
147 gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
148 || (VAR_P (decl)
149 && (TREE_STATIC (decl)
150 || DECL_EXTERNAL (decl)
151 || TREE_PUBLIC (decl))));
153 /* By default, assume the name to use in assembly code is the same
154 as that used in the source language. (That's correct for C, and
155 GCC used to set DECL_ASSEMBLER_NAME to the same value as
156 DECL_NAME in build_decl, so this choice provides backwards
157 compatibility with existing front-ends. This assumption is wrapped
158 in a target hook, to allow for target-specific modification of the
159 identifier.
161 Can't use just the variable's own name for a variable whose scope
162 is less than the whole compilation. Concatenate a distinguishing
163 number - we use the DECL_UID. */
165 if (TREE_PUBLIC (decl) || DECL_FILE_SCOPE_P (decl))
166 id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
167 else
169 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
170 char *label;
172 ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
173 id = get_identifier (label);
176 SET_DECL_ASSEMBLER_NAME (decl, id);
179 /* Forcibly overwrite the DECL_ASSEMBLER_NAME for DECL to NAME. */
180 void
181 lhd_overwrite_decl_assembler_name (tree decl, tree name)
183 DECL_ASSEMBLER_NAME_RAW (decl) = name;
186 /* Type promotion for variable arguments. */
187 tree
188 lhd_type_promotes_to (tree ARG_UNUSED (type))
190 gcc_unreachable ();
193 /* Registration of machine- or os-specific builtin types. */
194 void
195 lhd_register_builtin_type (tree ARG_UNUSED (type),
196 const char * ARG_UNUSED (name))
200 /* Invalid use of an incomplete type. */
201 void
202 lhd_incomplete_type_error (location_t ARG_UNUSED (loc),
203 const_tree ARG_UNUSED (value), const_tree type)
205 gcc_assert (TREE_CODE (type) == ERROR_MARK);
206 return;
209 /* Provide a default routine for alias sets that always returns -1. This
210 is used by languages that don't need to do anything special. */
212 alias_set_type
213 lhd_get_alias_set (tree ARG_UNUSED (t))
215 return -1;
218 /* This is the default decl_printable_name function. */
220 const char *
221 lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity))
223 gcc_assert (decl && DECL_NAME (decl));
224 return IDENTIFIER_POINTER (DECL_NAME (decl));
227 /* This is the default dwarf_name function. */
229 const char *
230 lhd_dwarf_name (tree t, int verbosity)
232 gcc_assert (DECL_P (t));
234 return lang_hooks.decl_printable_name (t, verbosity);
237 /* This compares two types for equivalence ("compatible" in C-based languages).
238 This routine should only return 1 if it is sure. It should not be used
239 in contexts where erroneously returning 0 causes problems. */
242 lhd_types_compatible_p (tree x, tree y)
244 return TYPE_MAIN_VARIANT (x) == TYPE_MAIN_VARIANT (y);
247 /* lang_hooks.tree_dump.dump_tree: Dump language-specific parts of tree
248 nodes. Returns nonzero if it does not want the usual dumping of the
249 second argument. */
251 bool
252 lhd_tree_dump_dump_tree (void *di ATTRIBUTE_UNUSED, tree t ATTRIBUTE_UNUSED)
254 return false;
257 /* lang_hooks.tree_dump.type_qual: Determine type qualifiers in a
258 language-specific way. */
261 lhd_tree_dump_type_quals (const_tree t)
263 return TYPE_QUALS (t);
266 /* lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form. */
269 lhd_gimplify_expr (tree *expr_p ATTRIBUTE_UNUSED,
270 gimple_seq *pre_p ATTRIBUTE_UNUSED,
271 gimple_seq *post_p ATTRIBUTE_UNUSED)
273 return GS_UNHANDLED;
276 /* lang_hooks.tree_size: Determine the size of a tree with code C,
277 which is a language-specific tree code in category tcc_constant,
278 tcc_exceptional or tcc_type. The default expects never to be called. */
279 size_t
280 lhd_tree_size (enum tree_code c ATTRIBUTE_UNUSED)
282 gcc_unreachable ();
285 /* Return true if decl, which is a function decl, may be called by a
286 sibcall. */
288 bool
289 lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED)
291 return true;
294 /* Generic global declaration processing. This is meant to be called
295 by the front-ends at the end of parsing. C/C++ do their own thing,
296 but other front-ends may call this. */
298 void
299 global_decl_processing (void)
301 tree globals, decl, *vec;
302 int len, i;
304 timevar_stop (TV_PHASE_PARSING);
305 timevar_start (TV_PHASE_DEFERRED);
306 /* Really define vars that have had only a tentative definition.
307 Really output inline functions that must actually be callable
308 and have not been output so far. */
310 globals = lang_hooks.decls.getdecls ();
311 len = list_length (globals);
312 vec = XNEWVEC (tree, len);
314 /* Process the decls in reverse order--earliest first.
315 Put them into VEC from back to front, then take out from front. */
317 for (i = 0, decl = globals; i < len; i++, decl = DECL_CHAIN (decl))
318 vec[len - i - 1] = decl;
320 wrapup_global_declarations (vec, len);
321 timevar_stop (TV_PHASE_DEFERRED);
323 timevar_start (TV_PHASE_PARSING);
324 free (vec);
327 /* Called to perform language-specific initialization of CTX. */
328 void
329 lhd_initialize_diagnostics (diagnostic_context *ctx ATTRIBUTE_UNUSED)
333 /* Called to register dumps. */
334 void
335 lhd_register_dumps (gcc::dump_manager *)
339 /* Called to perform language-specific options initialization. */
340 void
341 lhd_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED,
342 struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED)
346 /* By default, always complain about options for the wrong language. */
347 bool
348 lhd_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED)
350 return true;
353 /* By default, no language-specific options are valid. */
354 bool
355 lhd_handle_option (size_t code ATTRIBUTE_UNUSED,
356 const char *arg ATTRIBUTE_UNUSED,
357 HOST_WIDE_INT value ATTRIBUTE_UNUSED,
358 int kind ATTRIBUTE_UNUSED,
359 location_t loc ATTRIBUTE_UNUSED,
360 const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
362 return false;
365 /* The default function to print out name of current function that caused
366 an error. */
367 void
368 lhd_print_error_function (diagnostic_context *context, const char *file,
369 diagnostic_info *diagnostic)
371 if (diagnostic_last_function_changed (context, diagnostic))
373 char *old_prefix = pp_take_prefix (context->printer);
374 tree abstract_origin = diagnostic_abstract_origin (diagnostic);
375 char *new_prefix = (file && abstract_origin == NULL)
376 ? file_name_as_prefix (context, file) : NULL;
378 pp_set_prefix (context->printer, new_prefix);
380 if (current_function_decl == NULL)
381 pp_printf (context->printer, _("At top level:"));
382 else
384 tree fndecl, ao;
386 if (abstract_origin)
388 ao = BLOCK_ABSTRACT_ORIGIN (abstract_origin);
389 gcc_assert (TREE_CODE (ao) == FUNCTION_DECL);
390 fndecl = ao;
392 else
393 fndecl = current_function_decl;
395 if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
396 pp_printf
397 (context->printer, _("In member function %qs"),
398 identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
399 else
400 pp_printf
401 (context->printer, _("In function %qs"),
402 identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
404 while (abstract_origin)
406 location_t *locus;
407 tree block = abstract_origin;
409 locus = &BLOCK_SOURCE_LOCATION (block);
410 fndecl = NULL;
411 block = BLOCK_SUPERCONTEXT (block);
412 while (block && TREE_CODE (block) == BLOCK
413 && BLOCK_ABSTRACT_ORIGIN (block))
415 ao = BLOCK_ABSTRACT_ORIGIN (block);
416 if (TREE_CODE (ao) == FUNCTION_DECL)
418 fndecl = ao;
419 break;
421 else if (TREE_CODE (ao) != BLOCK)
422 break;
424 block = BLOCK_SUPERCONTEXT (block);
426 if (fndecl)
427 abstract_origin = block;
428 else
430 while (block && TREE_CODE (block) == BLOCK)
431 block = BLOCK_SUPERCONTEXT (block);
433 if (block && TREE_CODE (block) == FUNCTION_DECL)
434 fndecl = block;
435 abstract_origin = NULL;
437 if (fndecl)
439 expanded_location s = expand_location (*locus);
440 pp_comma (context->printer);
441 pp_newline (context->printer);
442 if (s.file != NULL)
444 if (context->show_column)
445 pp_printf (context->printer,
446 _(" inlined from %qs at %r%s:%d:%d%R"),
447 identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
448 "locus", s.file, s.line, s.column);
449 else
450 pp_printf (context->printer,
451 _(" inlined from %qs at %r%s:%d%R"),
452 identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
453 "locus", s.file, s.line);
456 else
457 pp_printf (context->printer, _(" inlined from %qs"),
458 identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
461 pp_colon (context->printer);
464 diagnostic_set_last_function (context, diagnostic);
465 pp_newline_and_flush (context->printer);
466 context->printer->prefix = old_prefix;
467 free ((char*) new_prefix);
471 tree
472 lhd_make_node (enum tree_code code)
474 return make_node (code);
477 /* Default implementation of LANG_HOOKS_SIMULATE_ENUM_DECL. Assume a
478 simple int-based enumerator (which is all the hook can be used for
479 at present) and push each decl individually without any decoration.
481 This definition is suitable for LTO and is generic enough that it
482 might be reusable elsewhere. */
483 tree
484 lhd_simulate_enum_decl (location_t loc, const char *name,
485 vec<string_int_pair> values)
487 tree enumtype = lang_hooks.types.make_type (ENUMERAL_TYPE);
488 tree enumdecl = build_decl (loc, TYPE_DECL, get_identifier (name), enumtype);
489 TYPE_STUB_DECL (enumtype) = enumdecl;
491 tree value_chain = NULL_TREE;
492 string_int_pair *value;
493 unsigned int i;
494 FOR_EACH_VEC_ELT (values, i, value)
496 tree value_decl = build_decl (loc, CONST_DECL,
497 get_identifier (value->first), enumtype);
498 DECL_INITIAL (value_decl) = build_int_cst (integer_type_node,
499 value->second);
500 lang_hooks.decls.pushdecl (value_decl);
501 value_chain = tree_cons (value_decl, DECL_INITIAL (value_decl),
502 value_chain);
505 TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (integer_type_node);
506 TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (integer_type_node);
507 SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (integer_type_node));
508 TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);
509 layout_type (enumtype);
510 lang_hooks.decls.pushdecl (enumdecl);
512 return enumtype;
515 /* Default implementation of LANG_HOOKS_TYPE_FOR_SIZE.
516 Return an integer type with PRECISION bits of precision,
517 that is unsigned if UNSIGNEDP is nonzero, otherwise signed. */
519 tree
520 lhd_type_for_size (unsigned precision, int unsignedp)
522 int i;
524 if (precision == TYPE_PRECISION (integer_type_node))
525 return unsignedp ? unsigned_type_node : integer_type_node;
527 if (precision == TYPE_PRECISION (signed_char_type_node))
528 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
530 if (precision == TYPE_PRECISION (short_integer_type_node))
531 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
533 if (precision == TYPE_PRECISION (long_integer_type_node))
534 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
536 if (precision == TYPE_PRECISION (long_long_integer_type_node))
537 return unsignedp
538 ? long_long_unsigned_type_node
539 : long_long_integer_type_node;
541 for (i = 0; i < NUM_INT_N_ENTS; i ++)
542 if (int_n_enabled_p[i]
543 && precision == int_n_data[i].bitsize)
544 return (unsignedp ? int_n_trees[i].unsigned_type
545 : int_n_trees[i].signed_type);
547 if (precision <= TYPE_PRECISION (intQI_type_node))
548 return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
550 if (precision <= TYPE_PRECISION (intHI_type_node))
551 return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
553 if (precision <= TYPE_PRECISION (intSI_type_node))
554 return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
556 if (precision <= TYPE_PRECISION (intDI_type_node))
557 return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
559 if (precision <= TYPE_PRECISION (intTI_type_node))
560 return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
562 return NULL_TREE;
565 HOST_WIDE_INT
566 lhd_to_target_charset (HOST_WIDE_INT c)
568 return c;
571 tree
572 lhd_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se ATTRIBUTE_UNUSED)
574 return expr;
577 /* Return sharing kind if OpenMP sharing attribute of DECL is
578 predetermined, OMP_CLAUSE_DEFAULT_UNSPECIFIED otherwise. */
580 enum omp_clause_default_kind
581 lhd_omp_predetermined_sharing (tree decl ATTRIBUTE_UNUSED)
583 if (DECL_ARTIFICIAL (decl))
584 return OMP_CLAUSE_DEFAULT_SHARED;
585 return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
588 /* Generate code to copy SRC to DST. */
590 tree
591 lhd_omp_assignment (tree clause ATTRIBUTE_UNUSED, tree dst, tree src)
593 return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
596 /* Finalize clause C. */
598 void
599 lhd_omp_finish_clause (tree, gimple_seq *)
603 /* Return true if DECL is a scalar variable (for the purpose of
604 implicit firstprivatization). */
606 bool
607 lhd_omp_scalar_p (tree decl)
609 tree type = TREE_TYPE (decl);
610 if (TREE_CODE (type) == REFERENCE_TYPE)
611 type = TREE_TYPE (type);
612 if (TREE_CODE (type) == COMPLEX_TYPE)
613 type = TREE_TYPE (type);
614 if (INTEGRAL_TYPE_P (type)
615 || SCALAR_FLOAT_TYPE_P (type)
616 || TREE_CODE (type) == POINTER_TYPE)
617 return true;
618 return false;
621 /* Register language specific type size variables as potentially OpenMP
622 firstprivate variables. */
624 void
625 lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *c ATTRIBUTE_UNUSED,
626 tree t ATTRIBUTE_UNUSED)
630 /* Return true if TYPE is an OpenMP mappable type. */
632 bool
633 lhd_omp_mappable_type (tree type)
635 /* Mappable type has to be complete. */
636 if (type == error_mark_node || !COMPLETE_TYPE_P (type))
637 return false;
638 return true;
641 /* Common function for add_builtin_function, add_builtin_function_ext_scope
642 and simulate_builtin_function_decl. */
644 static tree
645 build_builtin_function (location_t location, const char *name, tree type,
646 int function_code, enum built_in_class cl,
647 const char *library_name, tree attrs)
649 tree id = get_identifier (name);
650 tree decl = build_decl (location, FUNCTION_DECL, id, type);
652 TREE_PUBLIC (decl) = 1;
653 DECL_EXTERNAL (decl) = 1;
655 set_decl_built_in_function (decl, cl, function_code);
657 if (library_name)
659 tree libname = get_identifier (library_name);
661 libname = targetm.mangle_decl_assembler_name (decl, libname);
662 SET_DECL_ASSEMBLER_NAME (decl, libname);
665 /* Possibly apply some default attributes to this built-in function. */
666 if (attrs)
667 decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN);
668 else
669 decl_attributes (&decl, NULL_TREE, 0);
671 return decl;
674 /* Create a builtin function. */
676 tree
677 add_builtin_function (const char *name,
678 tree type,
679 int function_code,
680 enum built_in_class cl,
681 const char *library_name,
682 tree attrs)
684 tree decl = build_builtin_function (BUILTINS_LOCATION, name, type,
685 function_code, cl, library_name, attrs);
686 return lang_hooks.builtin_function (decl);
689 /* Like add_builtin_function, but make sure the scope is the external scope.
690 This is used to delay putting in back end builtin functions until the ISA
691 that defines the builtin is declared via function specific target options,
692 which can save memory for machines like the x86_64 that have multiple ISAs.
693 If this points to the same function as builtin_function, the backend must
694 add all of the builtins at program initialization time. */
696 tree
697 add_builtin_function_ext_scope (const char *name,
698 tree type,
699 int function_code,
700 enum built_in_class cl,
701 const char *library_name,
702 tree attrs)
704 tree decl = build_builtin_function (BUILTINS_LOCATION, name, type,
705 function_code, cl, library_name, attrs);
706 return lang_hooks.builtin_function_ext_scope (decl);
709 /* Simulate a declaration of a target-specific built-in function at
710 location LOCATION, as though it had been declared directly in the
711 source language. NAME is the name of the function, TYPE is its function
712 type, FUNCTION_CODE is the target-specific function code, LIBRARY_NAME
713 is the name of the underlying library function (NULL if none) and
714 ATTRS is a list of function attributes.
716 Return the decl of the declared function. */
718 tree
719 simulate_builtin_function_decl (location_t location, const char *name,
720 tree type, int function_code,
721 const char *library_name, tree attrs)
723 tree decl = build_builtin_function (location, name, type,
724 function_code, BUILT_IN_MD,
725 library_name, attrs);
726 tree new_decl = lang_hooks.simulate_builtin_function_decl (decl);
728 /* Give the front end a chance to create a new decl if necessary,
729 but if the front end discards the decl in favour of a conflicting
730 (erroneous) previous definition, return the decl that we tried but
731 failed to add. This allows the caller to process the returned decl
732 normally, even though the source code won't be able to use it. */
733 if (TREE_CODE (new_decl) == FUNCTION_DECL
734 && fndecl_built_in_p (new_decl, function_code, BUILT_IN_MD))
735 return new_decl;
737 return decl;
740 tree
741 lhd_builtin_function (tree decl)
743 lang_hooks.decls.pushdecl (decl);
744 return decl;
747 /* Create a builtin type. */
749 tree
750 add_builtin_type (const char *name, tree type)
752 tree id = get_identifier (name);
753 tree decl = build_decl (BUILTINS_LOCATION, TYPE_DECL, id, type);
754 return lang_hooks.decls.pushdecl (decl);
757 /* LTO hooks. */
759 /* Used to save and restore any previously active section. */
760 static section *saved_section;
763 /* Begin a new LTO output section named NAME. This default implementation
764 saves the old section and emits assembly code to switch to the new
765 section. */
767 void
768 lhd_begin_section (const char *name)
770 section *section;
772 /* Save the old section so we can restore it in lto_end_asm_section. */
773 gcc_assert (!saved_section);
774 saved_section = in_section;
775 if (!saved_section)
776 saved_section = text_section;
778 /* Create a new section and switch to it. */
779 section = get_section (name, SECTION_DEBUG | SECTION_EXCLUDE, NULL);
780 switch_to_section (section);
784 /* Write DATA of length LEN to the current LTO output section. This default
785 implementation just calls assemble_string. */
787 void
788 lhd_append_data (const void *data, size_t len, void *)
790 if (data)
792 timevar_push (TV_IPA_LTO_OUTPUT);
793 assemble_string ((const char *)data, len);
794 timevar_pop (TV_IPA_LTO_OUTPUT);
799 /* Finish the current LTO output section. This default implementation emits
800 assembly code to switch to any section previously saved by
801 lhd_begin_section. */
803 void
804 lhd_end_section (void)
806 if (saved_section)
808 switch_to_section (saved_section);
809 saved_section = NULL;
813 /* Default implementation of enum_underlying_base_type using type_for_size. */
815 tree
816 lhd_enum_underlying_base_type (const_tree enum_type)
818 return lang_hooks.types.type_for_size (TYPE_PRECISION (enum_type),
819 TYPE_UNSIGNED (enum_type));
822 /* Default implementation of LANG_HOOKS_GET_SUBSTRING_LOCATION. */
824 const char *
825 lhd_get_substring_location (const substring_loc &, location_t *)
827 return "unimplemented";
830 /* Default implementation of LANG_HOOKS_DECL_DWARF_ATTRIBUTE. Don't add
831 any attributes. */
834 lhd_decl_dwarf_attribute (const_tree, int)
836 return -1;
839 /* Default implementation of LANG_HOOKS_TYPE_DWARF_ATTRIBUTE. Don't add
840 any attributes. */
843 lhd_type_dwarf_attribute (const_tree, int)
845 return -1;
848 /* Default implementation of LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING.
849 Just return TYPE_SIZE_UNIT unadjusted. */
851 tree
852 lhd_unit_size_without_reusable_padding (tree t)
854 return TYPE_SIZE_UNIT (t);
857 /* Returns true if the current lang_hooks represents the GNU C frontend. */
859 bool
860 lang_GNU_C (void)
862 return (strncmp (lang_hooks.name, "GNU C", 5) == 0
863 && (lang_hooks.name[5] == '\0' || ISDIGIT (lang_hooks.name[5])));
866 /* Returns true if the current lang_hooks represents the GNU C++ frontend. */
868 bool
869 lang_GNU_CXX (void)
871 return strncmp (lang_hooks.name, "GNU C++", 7) == 0;
874 /* Returns true if the current lang_hooks represents the GNU Fortran frontend. */
876 bool
877 lang_GNU_Fortran (void)
879 return strncmp (lang_hooks.name, "GNU Fortran", 11) == 0;
882 /* Returns true if the current lang_hooks represents the GNU Objective-C
883 frontend. */
885 bool
886 lang_GNU_OBJC (void)
888 return strncmp (lang_hooks.name, "GNU Objective-C", 15) == 0;