GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "timevar.h"
#include "stringpool.h"
#include "diagnostic.h"
#include "intl.h"
#include "toplev.h"
#include "attribs.h"
#include "gimplify.h"
#include "langhooks.h"
#include "tree-diagnostic.h"
#include "output.h"
#include "stor-layout.h"
#include "cgraph.h"
#include "debug.h"
#include "diagnostic-format-text.h"
Variables | |
static section * | saved_section |
tree add_builtin_function | ( | const char * | name, |
tree | type, | ||
int | function_code, | ||
enum built_in_class | cl, | ||
const char * | library_name, | ||
tree | attrs ) |
Create a builtin function.
References build_builtin_function(), lang_hooks::builtin_function, and BUILTINS_LOCATION.
Referenced by local_define_builtin(), and tree_ssa_prefetch_arrays().
tree add_builtin_function_ext_scope | ( | const char * | name, |
tree | type, | ||
int | function_code, | ||
enum built_in_class | cl, | ||
const char * | library_name, | ||
tree | attrs ) |
Like add_builtin_function, but make sure the scope is the external scope. This is used to delay putting in back end builtin functions until the ISA that defines the builtin is declared via function specific target options, which can save memory for machines like the x86_64 that have multiple ISAs. If this points to the same function as builtin_function, the backend must add all of the builtins at program initialization time.
References build_builtin_function(), lang_hooks::builtin_function_ext_scope, and BUILTINS_LOCATION.
Referenced by rt_bb_visited::rt_bb_visited().
Create a builtin type.
References build_decl(), BUILTINS_LOCATION, lang_hooks::decls, get_identifier(), and lang_hooks_for_decls::pushdecl.
|
static |
Common function for add_builtin_function, add_builtin_function_ext_scope and simulate_builtin_function_decl.
References ATTR_FLAG_BUILT_IN, build_decl(), decl_attributes(), DECL_EXTERNAL, get_identifier(), NULL_TREE, SET_DECL_ASSEMBLER_NAME, set_decl_built_in_function(), targetm, and TREE_PUBLIC.
Referenced by add_builtin_function(), add_builtin_function_ext_scope(), and simulate_builtin_function_decl().
void global_decl_processing | ( | void | ) |
Generic global declaration processing. This is meant to be called by the front-ends at the end of parsing. C/C++ do their own thing, but other front-ends may call this.
References DECL_CHAIN, lang_hooks::decls, free(), lang_hooks_for_decls::getdecls, i, list_length(), timevar_start(), timevar_stop(), and wrapup_global_declarations().
bool lang_GNU_C | ( | void | ) |
Returns true if the current lang_hooks represents the GNU C frontend.
References lang_hooks::name, and startswith().
Referenced by default_floatn_builtin_p(), maybe_warn_implicit_fallthrough(), and process_options().
bool lang_GNU_CXX | ( | void | ) |
Returns true if the current lang_hooks represents the GNU C++ frontend.
References lang_hooks::name, and startswith().
Referenced by fold_cond_expr_with_comparison(), and maybe_warn_implicit_fallthrough().
bool lang_GNU_Fortran | ( | void | ) |
Returns true if the current lang_hooks represents the GNU Fortran frontend.
References lang_hooks::name, and startswith().
Referenced by check_omp_nesting_restrictions(), gimplify_bind_expr(), gimplify_omp_for(), gimplify_omp_loop(), gimplify_scan_omp_clauses(), maybe_warn_switch_unreachable_and_auto_init(), omp_accumulate_sibling_list(), omp_context_name_list_prop(), and omp_default_clause().
bool lang_GNU_OBJC | ( | void | ) |
Returns true if the current lang_hooks represents the GNU Objective-C frontend.
References lang_hooks::name, and startswith().
Referenced by default_floatn_builtin_p(), and maybe_warn_implicit_fallthrough().
void lhd_append_data | ( | const void * | data, |
size_t | len, | ||
void * | ) |
Write DATA of length LEN to the current LTO output section. This default implementation just calls assemble_string.
References assemble_string(), timevar_pop(), and timevar_push().
void lhd_begin_section | ( | const char * | name | ) |
Begin a new LTO output section named NAME. This default implementation saves the old section and emits assembly code to switch to the new section.
References gcc_assert, get_section(), in_section, NULL, saved_section, SECTION_DEBUG, SECTION_EXCLUDE, switch_to_section(), and text_section.
References lang_hooks::decls, and lang_hooks_for_decls::pushdecl.
By default, always complain about options for the wrong language.
References option().
int lhd_decl_dwarf_attribute | ( | const_tree | , |
int | ) |
Default implementation of LANG_HOOKS_DECL_DWARF_ATTRIBUTE. Don't add any attributes.
bool lhd_decl_ok_for_sibcall | ( | const_tree | decl | ) |
Return true if decl, which is a function decl, may be called by a sibcall.
const char * lhd_decl_printable_name | ( | tree | decl, |
int | ARG_UNUSEDverbosity ) |
This is the default decl_printable_name function.
References DECL_NAME, gcc_assert, and IDENTIFIER_POINTER.
void lhd_do_nothing | ( | void | ) |
Default language-specific hooks. Copyright (C) 2001-2025 Free Software Foundation, Inc. Contributed by Alexandre Oliva <aoliva@redhat.com> This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
Do nothing; in many cases the default hook.
void lhd_do_nothing_f | ( | struct function * | ARG_UNUSEDf | ) |
Do nothing (function).
tree lhd_do_nothing_iii_return_null_tree | ( | int | ARG_UNUSEDi, |
int | ARG_UNUSEDj, | ||
int | ARG_UNUSEDk ) |
void lhd_do_nothing_t | ( | tree | ARG_UNUSEDt | ) |
Do nothing (tree).
const char * lhd_dwarf_name | ( | tree | t, |
int | verbosity ) |
This is the default dwarf_name function.
References DECL_P, lang_hooks::decl_printable_name, and gcc_assert.
void lhd_end_section | ( | void | ) |
Finish the current LTO output section. This default implementation emits assembly code to switch to any section previously saved by lhd_begin_section.
References NULL, saved_section, and switch_to_section().
tree lhd_enum_underlying_base_type | ( | const_tree | enum_type | ) |
Default implementation of enum_underlying_base_type using type_for_size.
References lang_hooks_for_types::type_for_size, TYPE_PRECISION, TYPE_UNSIGNED, and lang_hooks::types.
void lhd_finalize_early_debug | ( | void | ) |
Default implementation for the finalize_early_debug hook.
References debug_hooks, symtab_node::decl, and FOR_EACH_FUNCTION_WITH_GIMPLE_BODY.
alias_set_type lhd_get_alias_set | ( | tree | ARG_UNUSEDt | ) |
Provide a default routine for alias sets that always returns -1. This is used by languages that don't need to do anything special.
const char * lhd_get_sarif_source_language | ( | const char * | ) |
Default implementation of LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE.
References NULL.
const char * lhd_get_substring_location | ( | const substring_loc & | , |
location_t * | out_loc ) |
Default implementation of LANG_HOOKS_GET_SUBSTRING_LOCATION.
int lhd_gimplify_expr | ( | tree * | expr_p, |
gimple_seq * | pre_p, | ||
gimple_seq * | post_p ) |
lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form.
References GS_UNHANDLED.
bool lhd_handle_option | ( | size_t | code, |
const char * | arg, | ||
HOST_WIDE_INT | value, | ||
int | kind, | ||
location_t | loc, | ||
const struct cl_option_handlers * | handlers ) |
By default, no language-specific options are valid.
void lhd_incomplete_type_error | ( | location_t | ARG_UNUSEDloc, |
const_tree | ARG_UNUSEDvalue, | ||
const_tree | type ) |
Invalid use of an incomplete type.
References gcc_assert, and TREE_CODE.
void lhd_init_options | ( | unsigned int | decoded_options_count, |
struct cl_decoded_option * | decoded_options ) |
Called to perform language-specific options initialization.
void lhd_initialize_diagnostics | ( | diagnostic_context * | ctx | ) |
Called to perform language-specific initialization of CTX.
References make_node().
tree lhd_omp_array_size | ( | tree | , |
gimple_seq * | ) |
Return array size; cf. omp_array_data.
References NULL_TREE.
void lhd_omp_deep_mapping | ( | const gimple * | , |
tree | , | ||
unsigned | HOST_WIDE_INT, | ||
tree | , | ||
tree | , | ||
tree | , | ||
tree | , | ||
tree | , | ||
gimple_seq * | ) |
Do the additional mappings.
tree lhd_omp_deep_mapping_cnt | ( | const gimple * | , |
tree | , | ||
gimple_seq * | ) |
Returns number of additional mappings for a decl.
References NULL_TREE.
Returns true when additional mappings for a decl are needed.
void lhd_omp_finish_clause | ( | tree | , |
gimple_seq * | , | ||
bool | ) |
Finalize clause C.
void lhd_omp_finish_decl_inits | ( | void | ) |
Free any extra memory used to hold initializer information for variable declarations.
void lhd_omp_firstprivatize_type_sizes | ( | struct gimplify_omp_ctx * | c, |
tree | t ) |
Register language specific type size variables as potentially OpenMP firstprivate variables.
Return static initializer for DECL.
References DECL_INITIAL.
enum omp_clause_defaultmap_kind lhd_omp_predetermined_mapping | ( | tree | decl | ) |
Return sharing kind if OpenMP mapping attribute of DECL is predetermined, OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED otherwise.
References DECL_ARTIFICIAL, OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED, and OMP_CLAUSE_DEFAULTMAP_TO.
enum omp_clause_default_kind lhd_omp_predetermined_sharing | ( | tree | decl | ) |
Return sharing kind if OpenMP sharing attribute of DECL is predetermined, OMP_CLAUSE_DEFAULT_UNSPECIFIED otherwise.
References DECL_ARTIFICIAL, OMP_CLAUSE_DEFAULT_SHARED, and OMP_CLAUSE_DEFAULT_UNSPECIFIED.
Return true if DECL is a scalar variable (for the purpose of implicit firstprivatization & mapping). Only if alloc_ptr_ok are allocatables and pointers accepted.
References INTEGRAL_TYPE_P, SCALAR_FLOAT_TYPE_P, TREE_CODE, and TREE_TYPE.
Forcibly overwrite the DECL_ASSEMBLER_NAME for DECL to NAME.
References DECL_ASSEMBLER_NAME_RAW.
bool lhd_post_options | ( | const char ** | ARG_UNUSEDpfilename | ) |
The default post options hook.
References EXCESS_PRECISION_FAST.
void lhd_print_error_function | ( | diagnostic_text_output_format & | text_output, |
const char * | file, | ||
const diagnostic_info * | diagnostic ) |
The default function to print out name of current function that caused an error.
References _, BLOCK_ABSTRACT_ORIGIN, BLOCK_SOURCE_LOCATION, BLOCK_SUPERCONTEXT, current_function_decl, lang_hooks::decl_printable_name, diagnostic_abstract_origin, diagnostic_last_function_changed, diagnostic_set_last_function, expand_location(), diagnostic_text_output_format::file_name_as_prefix(), gcc_assert, diagnostic_output_format::get_context(), diagnostic_output_format::get_printer(), identifier_to_locale(), diagnostic_context::m_show_column, NULL, pp_colon, pp_comma, pp_newline(), pp_newline_and_flush(), pp_printf(), pp_set_prefix(), pp_take_prefix(), pretty_printer::set_prefix(), TREE_CODE, and TREE_TYPE.
void lhd_print_tree_nothing | ( | FILE * | ARG_UNUSEDfile, |
tree | ARG_UNUSEDnode, | ||
int | ARG_UNUSEDindent ) |
Called from by print-tree.cc.
void lhd_register_builtin_type | ( | tree | ARG_UNUSEDtype, |
const char * | ARG_UNUSEDname ) |
Registration of machine- or os-specific builtin types.
void lhd_register_dumps | ( | gcc::dump_manager * | ) |
Called to register dumps.
tree lhd_return_null_const_tree | ( | const_tree | ARG_UNUSEDt | ) |
Do nothing (return NULL_TREE).
References NULL_TREE.
void lhd_set_decl_assembler_name | ( | tree | decl | ) |
Set the DECL_ASSEMBLER_NAME for DECL.
References ASM_FORMAT_PRIVATE_NAME, DECL_EXTERNAL, DECL_FILE_SCOPE_P, DECL_NAME, gcc_assert, get_identifier(), IDENTIFIER_POINTER, SET_DECL_ASSEMBLER_NAME, targetm, TREE_CODE, TREE_PUBLIC, TREE_STATIC, and VAR_P.
Referenced by gimplify_init_constructor().
tree lhd_simulate_enum_decl | ( | location_t | loc, |
const char * | name, | ||
vec< string_int_pair > * | values_ptr ) |
Default implementation of LANG_HOOKS_SIMULATE_ENUM_DECL. Assume a simple int-based enumerator (which is all the hook can be used for at present) and push each decl individually without any decoration. This definition is suitable for LTO and is generic enough that it might be reusable elsewhere.
References build_decl(), build_int_cst(), DECL_INITIAL, lang_hooks::decls, FOR_EACH_VEC_ELT, get_identifier(), i, integer_type_node, layout_type(), lang_hooks_for_types::make_type, NULL_TREE, lang_hooks_for_decls::pushdecl, SET_TYPE_ALIGN, tree_cons(), TYPE_ALIGN, TYPE_MAX_VALUE, TYPE_MIN_VALUE, TYPE_PRECISION, TYPE_STUB_DECL, and lang_hooks::types.
tree lhd_simulate_record_decl | ( | location_t | loc, |
const char * | name, | ||
array_slice< const tree > | fields ) |
Default implementation of LANG_HOOKS_SIMULATE_RECORD_DECL. Just create a normal RECORD_TYPE and a TYPE_DECL for it.
References build_decl(), DECL_CHAIN, lang_hooks::decls, fields, finish_builtin_struct(), get_identifier(), i, lang_hooks_for_types::make_type, NULL_TREE, lang_hooks_for_decls::pushdecl, and lang_hooks::types.
HOST_WIDE_INT lhd_to_target_charset | ( | HOST_WIDE_INT | c | ) |
lang_hooks.tree_dump.dump_tree: Dump language-specific parts of tree nodes. Returns nonzero if it does not want the usual dumping of the second argument.
int lhd_tree_dump_type_quals | ( | const_tree | t | ) |
lang_hooks.tree_dump.type_qual: Determine type qualifiers in a language-specific way.
References TYPE_QUALS.
size_t lhd_tree_size | ( | enum tree_code | c | ) |
lang_hooks.tree_size: Determine the size of a tree with code C, which is a language-specific tree code in category tcc_constant, tcc_exceptional or tcc_type. The default expects never to be called.
References gcc_unreachable.
int lhd_type_dwarf_attribute | ( | const_tree | , |
int | ) |
Default implementation of LANG_HOOKS_TYPE_DWARF_ATTRIBUTE. Don't add any attributes.
tree lhd_type_for_size | ( | unsigned | precision, |
int | unsignedp ) |
Default implementation of LANG_HOOKS_TYPE_FOR_SIZE. Return an integer type with PRECISION bits of precision, that is unsigned if UNSIGNEDP is nonzero, otherwise signed.
References i, int_n_data, int_n_enabled_p, int_n_trees, intDI_type_node, integer_type_node, intHI_type_node, intQI_type_node, intSI_type_node, intTI_type_node, long_integer_type_node, long_long_integer_type_node, long_long_unsigned_type_node, long_unsigned_type_node, NULL_TREE, short_integer_type_node, short_unsigned_type_node, signed_char_type_node, TYPE_PRECISION, unsigned_char_type_node, unsigned_intDI_type_node, unsigned_intHI_type_node, unsigned_intQI_type_node, unsigned_intSI_type_node, unsigned_intTI_type_node, and unsigned_type_node.
Type promotion for variable arguments.
References gcc_unreachable.
This compares two types for equivalence ("compatible" in C-based languages). This routine should only return 1 if it is sure. It should not be used in contexts where erroneously returning 0 causes problems.
References TYPE_MAIN_VARIANT, and y.
Default implementation of LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING. Just return TYPE_SIZE_UNIT unadjusted.
References TYPE_SIZE_UNIT.
bool lhd_warn_unused_global_decl | ( | const_tree | decl | ) |
Called from check_global_declaration.
References DECL_DECLARED_INLINE_P, DECL_IN_SYSTEM_HEADER, TREE_CODE, TREE_READONLY, and VAR_P.
tree simulate_builtin_function_decl | ( | location_t | location, |
const char * | name, | ||
tree | type, | ||
int | function_code, | ||
const char * | library_name, | ||
tree | attrs ) |
Simulate a declaration of a target-specific built-in function at location LOCATION, as though it had been declared directly in the source language. NAME is the name of the function, TYPE is its function type, FUNCTION_CODE is the target-specific function code, LIBRARY_NAME is the name of the underlying library function (NULL if none) and ATTRS is a list of function attributes. Return the decl of the declared function.
References build_builtin_function(), BUILT_IN_MD, fndecl_built_in_p(), lang_hooks::simulate_builtin_function_decl, and TREE_CODE.
|
static |
LTO hooks.
Used to save and restore any previously active section.
Referenced by lhd_begin_section(), and lhd_end_section().