GCC Middle and Back End API Reference
|
#include "bconfig.h"
#include "system.h"
#include "coretypes.h"
#include <cpplib.h>
#include "rich-location.h"
#include "errors.h"
#include "hash-table.h"
#include "hash-set.h"
#include "is-a.h"
#include "ordered-hash-map.h"
#include "tree.def"
#include "builtins.def"
#include "internal-fn.def"
#include "case-cfn-macros.h"
Data Structures | |
class | id_base |
class | operator_id |
class | fn_id |
class | predicate_id |
class | user_id |
class | operand |
class | predicate |
struct | expr |
class | c_expr |
class | c_expr::id_tab |
class | capture |
class | if_expr |
class | with_expr |
class | simplify |
struct | sinfo |
struct | sinfo_hashmap_traits |
class | dt_node |
class | dt_operand |
class | dt_simplify |
class | decision_tree |
class | capture_info |
struct | capture_info::cinfo |
class | parser |
Macros | |
#define | SIZED_BASED_CHUNKS 1 |
#define | DEFTREECODE(SYM, STRING, TYPE, NARGS) SYM, |
#define | DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) ENUM, |
#define | DEF_INTERNAL_FN(CODE, FLAGS, FNSPEC) IFN_##CODE, |
#define | DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) CFN_##ENUM = int (ENUM), |
#define | DEF_INTERNAL_FN(CODE, FLAGS, FNSPEC) CFN_##CODE = int (END_BUILTINS) + int (IFN_##CODE), |
#define | DEFTREECODE(SYM, STRING, TYPE, NARGS) add_operator (SYM, # SYM, # TYPE, NARGS); |
#define | END_OF_BASE_TREE_CODES |
#define | DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) add_function (ENUM, "CFN_" # ENUM); |
#define | DEF_INTERNAL_FN(CODE, NAME, FNSPEC) add_function (IFN_##CODE, "CFN_" #CODE); |
Typedefs | |
typedef hash_map< nofree_string_hash, unsigned > | cid_map_t |
typedef ordered_hash_map< void *, sinfo *, sinfo_hashmap_traits > | sinfo_map_t |
Enumerations | |
enum | tree_code { MAX_TREE_CODES } |
enum | built_in_function { END_BUILTINS } |
enum | internal_fn { IFN_LAST } |
enum | combined_fn { CFN_LAST } |
Variables | |
unsigned | verbose |
static class line_maps * | line_table |
static FILE * | header_file |
static vec< int > | dbg_line_numbers |
static id_base * | null_id |
static hash_table< id_base > * | operators |
static unsigned | current_id |
static char * | fail_label |
#define DEF_BUILTIN | ( | ENUM, | |
N, | |||
C, | |||
T, | |||
LT, | |||
B, | |||
F, | |||
NA, | |||
AT, | |||
IM, | |||
COND ) add_function (ENUM, "CFN_" # ENUM); |
#define DEF_INTERNAL_FN | ( | CODE, | |
FLAGS, | |||
FNSPEC ) CFN_##CODE = int (END_BUILTINS) + int (IFN_##CODE), |
#define DEF_INTERNAL_FN | ( | CODE, | |
NAME, | |||
FNSPEC ) add_function (IFN_##CODE, "CFN_" #CODE); |
Pull in tree codes and builtin function codes from their definition files.
Pull in tree codes and builtin function codes from their definition files.
#define END_OF_BASE_TREE_CODES |
#define SIZED_BASED_CHUNKS 1 |
Find the file to write into next. We try to evenly distribute the contents over the different files.
Add a built-in or internal function identifier to the hash. ID is the name of its CFN_* enumeration value.
References fatal(), ggc_alloc(), id_base::hashval, and operators.
|
static |
Add a tree code identifier to the hash.
References fatal(), ggc_alloc(), id_base::hashval, and operators.
|
static |
Add a predicate identifier to the hash.
References fatal(), ggc_alloc(), id_base::hashval, and operators.
Referenced by parser::parse_pattern(), and parser::parse_predicates().
|
static |
Return true if the binary operator OP is ok for delayed substitution during for lowering.
References operator_id::code, and ggc_alloc().
Referenced by lower_for().
|
static |
AST lowering.
Lowering of commutative operators.
References cartesian_product(), ggc_alloc(), and i.
Referenced by cartesian_product(), commutate(), and lower_cond().
References ggc_alloc(), and NULL.
Referenced by decision_tree::gen(), and main().
Compare two AST operands O1 and O2 and return true if they are equal.
References id_base::FN, ggc_alloc(), expr::is_generic, id_base::kind, operand::OP_EXPR, operand::OP_PREDICATE, expr::operation, and expr::ops.
Referenced by decision_tree::cmp_node().
Lower OP to two operands in case it is marked as commutative.
References cartesian_product(), commutate(), commutative_op(), comparison_code_p(), expr, ggc_alloc(), i, expr::is_commutative, NULL, expr::operation, expr::ops, c_expr::r, subst(), swap_tree_comparison(), and vNULL.
Referenced by commutate(), and lower_commutative().
If ID has a pair of consecutive, commutative operands, return the index of the first, otherwise return -1.
References commutative_op(), commutative_ternary_tree_code(), commutative_tree_code(), ggc_alloc(), and i.
Referenced by commutate(), commutative_op(), dt_operand::gen_gimple_expr(), parser::parse_expr(), and vect_get_and_check_slp_defs().
Return true if CODE represents a ternary tree code for which the first two operands are commutative. Otherwise return false.
References ggc_alloc().
Referenced by inchash::add_hashable_expr(), commutative_op(), commutative_ternary_op_p(), first_commutative_argument(), fold_stmt_1(), fold_ternary_loc(), gimple_simplify(), hashable_expr_equal_p(), and vn_nary_op_compute_hash().
Return true if CODE represents a commutative tree code. Otherwise return false.
References ggc_alloc().
Referenced by inchash::add_hashable_expr(), analyze_agg_content_value(), check_scan_store(), pcom_worker::combinable_refs_p(), commutative_binary_op_p(), commutative_op(), cond_stmts_equal_p(), const_binop(), expand_omp_atomic_fetch_op(), first_commutative_argument(), fold_binary_loc(), fold_stmt_1(), gimple_simplify(), operand_compare::hash_operand(), hashable_expr_equal_p(), is_cond_scalar_reduction(), may_reassociate_p(), operand_compare::operand_equal_p(), parloops_is_simple_reduction(), parser::parse_expr(), reorder_operands(), vect_build_slp_tree_2(), vect_get_and_check_slp_defs(), vect_reassociating_reduction_p(), vectorizable_scan_store(), and vn_nary_op_compute_hash().
Compare function for finding equivalent transforms.
References compare_op(), ggc_alloc(), i, operand::OP_IF, and operand::OP_WITH.
Referenced by compare_op(), and sinfo_hashmap_traits::equal_keys().
Return true if CODE is a comparison.
References ggc_alloc().
Referenced by commutate(), and parser::parse_expr().
Return true if O refers to ID.
References contains_id(), ggc_alloc(), and i.
Referenced by contains_id(), and lower_for().
References dbg_line_numbers, fprintf_indent(), ggc_alloc(), and i.
Referenced by main().
|
static |
References ap, fopen, fputc(), ggc_alloc(), i, line_table, map, msg, and vfprintf().
Referenced by fatal_at(), fatal_at(), main(), warning_at(), and warning_at().
|
static |
Emit a logging call to the debug file to the file F, with the INDENT from either the RESULT location or the S's match location if RESULT is null.
References fprintf_indent(), ggc_alloc(), simplify::kind, operand::location, simplify::match, output_line_directive(), and simplify::SIMPLIFY.
Referenced by dt_simplify::gen_1().
References ap, diagnostic_cb(), ggc_alloc(), line_table, msg, and NULL.
Referenced by check_attr_test(), convert_syntax(), function_reader::create_edges(), parser::eat_ident(), parser::expect(), parser::finish_match_operand(), gen_automata_option(), gen_automaton(), gen_bypass(), gen_cpu_unit(), gen_excl_set(), gen_expand(), gen_insn(), gen_presence_absence_set(), gen_query_cpu_unit(), gen_split(), c_expr::gen_transform(), expr::gen_transform(), get_attr_value(), function_reader::handle_unknown_directive(), make_canonical(), make_length_attrs(), function_reader::parse_block(), parser::parse_c_expr(), parser::parse_capture(), parser::parse_expr(), parser::parse_for(), parser::parse_if(), function_reader::parse_insn(), function_reader::parse_insn_chain(), parser::parse_op(), parser::parse_operation(), parser::parse_operator_list(), function_reader::parse_param(), parser::parse_pattern(), parser::parse_result(), parse_section(), parse_section_layout(), parser::parse_simplify(), parser::peek(), preprocess_compact_syntax(), process_define_register_constraint(), process_template(), function_reader::read_rtx_operand_r(), parser::record_operlist(), capture_info::walk_c_expr(), and capture_info::walk_match().
|
static |
References ap, diagnostic_cb(), ggc_alloc(), line_table, msg, and NULL.
Compare 2 fns or generic_fns vector entries for vector sorting. Same operation entries with different number of arguments should be adjacent.
References ggc_alloc(), dt_operand::op, and expr::operation.
Referenced by dt_node::gen_kids().
Start or continue emitting a declaration in fprintf-like manner, printing both to F and global header_file, if non-null.
References ap, ggc_alloc(), header_file, and vfprintf().
Referenced by decision_tree::gen(), and write_predicate().
Finish a declaration being emitted by fp_decl.
References ggc_alloc(), and header_file.
Referenced by decision_tree::gen(), and write_predicate().
Like fprintf, but print INDENT spaces at the beginning.
References ap, fputc(), ggc_alloc(), and vfprintf().
Referenced by define_dump_logs(), emit_logging_call(), dt_operand::gen(), dt_simplify::gen(), decision_tree::gen(), dt_simplify::gen_1(), dt_operand::gen_generic_expr(), dt_operand::gen_gimple_expr(), dt_node::gen_kids_1(), dt_operand::gen_match_op(), dt_operand::gen_predicate(), c_expr::gen_transform(), capture::gen_transform(), expr::gen_transform(), and write_predicate().
|
static |
Get the type to be used for generating operand POS of OP from the various sources.
References ggc_alloc(), id_base::id, is_conversion(), NULL, and startswith().
Referenced by dt_simplify::gen_1(), and expr::gen_transform().
Lookup the identifier ID. Allow "null" if ALLOW_NULL.
References id_base::CODE, ggc_alloc(), i, NULL, null_id, operators, and startswith().
Referenced by parser::parse_c_expr(), parser::parse_for(), parser::parse_op(), parser::parse_operation(), parser::parse_operator_list(), parser::parse_pattern(), swap_tree_comparison(), and capture_info::walk_c_expr().
Free a block. To be used when known for certain it's not reachable.
Referenced by add_var_loc_to_decl(), adjust_agg_replacement_values(), modref_base_node< T >::collapse(), modref_tree< T >::collapse(), ctfc_delete_container(), ctfc_delete_strtab(), hash_table< Descriptor, Lazy, Allocator >::empty_slow(), hash_table< Descriptor, Lazy, Allocator >::expand(), fini_ssa_operands(), flow_loop_free(), vrange_ggc_alloc::free(), free_block(), free_cfg(), symbol_table::free_edge(), free_edge(), free_loc_descr(), free_node(), free_numbers_of_iterations_estimates(), free_param_decl_accesses(), free_simple_loop_desc(), general_init(), ggc_realloc(), gimple_seq_discard(), gimplify_assign(), gimplify_decl_expr(), gimplify_init_ctor_eval(), gimplify_target_expr(), init_expmed(), init_tree_optimization_optabs(), internal_get_tmp_var(), ipcp_free_transformation_sum(), loc_list_from_tree_1(), loop_optimizer_finalize(), lto_delete_in_decl_state(), lto_free_function_in_decl_state(), cgraph_edge::make_direct(), move_sese_region_to_fn(), native_encode_initializer(), phi_dynamic_object_size(), range_info_free(), release_function_body(), release_phi_node(), release_section_hash_entry(), symbol_table::release_symbol(), loop_exit_hasher::remove(), odr_name_hasher::remove(), varpool_node::remove(), ipcp_transformation::remove_argaggs_if(), ipa_vr::set_unknown(), jump_threader::simplify_control_stmt_condition(), ipa_vr::streamer_read(), tree_add_const_value_attribute(), type_hash_canon(), wide_int_to_tree_1(), hash_table< Descriptor, Lazy, Allocator >::~hash_table(), and jump_threader::~jump_threader().
Generate pattern matching and transform code shared between GENERIC and GIMPLE folding code from match-and-simplify description. Copyright (C) 2014-2024 Free Software Foundation, Inc. Contributed by Richard Biener <rguenther@suse.de> and Prathamesh Kulkarni <bilbotheelffriend@gmail.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/>.
Stubs for GGC referenced through instantiations triggered by hash-map.
References NULL.
Referenced by symtab_node::get_dump_name(), and simd_clone_struct_alloc().
Determine whether O or its children uses the conditional operation group GRP.
References ggc_alloc(), has_opt(), i, expr::ops, and expr::opt_grp.
Referenced by has_opt(), and lower_opt().
Code generation off the decision tree and the refered AST nodes.
References ggc_alloc().
Referenced by expr::gen_transform(), and get_operand_type().
expanded_location linemap_client_expand_location_to_spelling_point | ( | const line_maps * | set, |
location_t | loc, | ||
enum location_aspect | ) |
The rich_location class within libcpp requires a way to expand location_t instances, and relies on the client code providing a symbol named linemap_client_expand_location_to_spelling_point to do this. This is the implementation for genmatch.
References ggc_alloc(), and map.
Lower the AST for everything in SIMPLIFIERS.
References ggc_alloc(), lower_commutative(), lower_cond(), lower_for(), and lower_opt().
Referenced by gimplify_init_ctor_eval(), gimplify_init_ctor_eval_range(), initialize_iterators(), main(), and double_int::wide_mul_with_sign().
Lower operations marked as commutative in the AST of S and push the resulting patterns to SIMPLIFIERS.
References simplify::capture_ids, commutate(), simplify::for_vec, i, simplify::id, simplify::kind, simplify::match, and simplify::result.
Referenced by lower().
Lower the compare operand of COND_EXPRs to a GENERIC and a GIMPLE variant.
References cartesian_product(), expr, ggc_alloc(), i, lower_cond(), expr::operation, expr::ops, and vNULL.
Referenced by lower(), lower_cond(), and lower_cond().
Lower the compare operand of COND_EXPRs to a GENERIC and a GIMPLE variant.
References simplify::capture_ids, simplify::for_subst_vec, simplify::for_vec, i, simplify::id, simplify::kind, lower_cond(), simplify::match, and simplify::result.
Lower recorded fors for SIN and output to SIMPLIFIERS.
References binary_ok(), simplify::capture_ids, contains_id(), simplify::for_subst_vec, ggc_alloc(), i, id_base::id, simplify::id, c_expr::ids, simplify::kind, simplify::MATCH, simplify::match, null_id, replace_id(), simplify::result, si, simplify::SIMPLIFY, sin(), subst(), operator_id::tcc, vNULL, and worklist.
Referenced by lower().
Lower conditional convert operators in O, expanding it to a vector if required.
References ggc_alloc(), has_opt(), i, lower_opt(), and vNULL.
Strip conditional operations using group GRP from O and its children if STRIP, else replace them with an unconditional operation.
References expr, ggc_alloc(), i, lower_opt(), expr::ops, and expr::opt_grp.
Referenced by lower(), lower_opt(), lower_opt(), and lower_opt().
Lower conditional convert operators in the AST of S and push the resulting multiple patterns to SIMPLIFIERS.
References simplify::capture_ids, simplify::for_vec, i, simplify::id, simplify::kind, lower_opt(), simplify::match, and simplify::result.
int main | ( | int | argc, |
char ** | argv ) |
The genmatch generator program. It reads from a pattern description and outputs GIMPLE or GENERIC IL matching and simplification routines.
References choose_output(), define_dump_logs(), diagnostic_cb(), fopen, decision_tree::gen(), ggc_alloc(), header_file, i, decision_tree::insert(), line_table, lower(), predicate_id::matchers, NULL, id_base::NULL_ID, null_id, operators, decision_tree::print(), print_matches(), progname, c_expr::r, round_alloc_size(), parser::simplifiers, usage(), parser::user_predicates, verbose, write_header(), write_header_declarations(), write_header_includes(), and write_predicate().
Helper for easy comparing ID with tree code CODE.
References ggc_alloc().
|
static |
References dbg_line_numbers, DIR_SEPARATOR, ggc_alloc(), line_table, location_hash, map, and verbose.
Referenced by emit_logging_call(), dt_simplify::gen(), decision_tree::gen(), and dt_simplify::gen_1().
References ggc_alloc(), simplify::match, and print_operand().
Referenced by main().
Debugging routines for dumping the AST.
References gcc_unreachable, ggc_alloc(), i, and print_operand().
Referenced by dt_node::append_simplify(), print_matches(), decision_tree::print_node(), and print_operand().
In AST operand O replace operator ID with operator WITH.
References c_expr::c_expr(), expr, ggc_alloc(), i, id_base::id, c_expr::ids, and replace_id().
Referenced by lower_for(), and replace_id().
Helper for the linemap code.
Referenced by main().
id_base * swap_tree_comparison | ( | operator_id * | p | ) |
Return the comparison operators that results if the operands are swapped. This is safe for floating-point.
References operator_id::code, gcc_unreachable, get_operator(), and ggc_alloc().
Referenced by commutate().
Construct and display the help menu.
References ggc_alloc(), progname, and usage().
Helper for finish_match_operand, collecting captures of OP in CPTS recursively.
References ggc_alloc(), i, and walk_captures().
Referenced by parser::finish_match_operand(), and walk_captures().
References ap, diagnostic_cb(), ggc_alloc(), line_table, msg, and NULL.
Referenced by dt_node::append_simplify(), decision_tree::find_node(), dt_simplify::gen_1(), parser::parse_for(), capture_info::walk_c_expr(), and capture_info::walk_match().
|
static |
References ap, diagnostic_cb(), ggc_alloc(), line_table, msg, and NULL.
Write the common header for the GIMPLE/GENERIC IL matching routines.
References ggc_alloc().
References ggc_alloc().
Referenced by main().
Write out the correct include to the match-head fle containing the helper files.
References ggc_alloc(), and header_file.
Referenced by main().
void write_predicate | ( | FILE * | f, |
predicate_id * | p, | ||
decision_tree & | dt, | ||
bool | gimple ) |
Output code to implement the predicate P from the decision tree DT.
References fp_decl(), fp_decl_done(), fprintf_indent(), dt_node::gen_kids(), ggc_alloc(), id_base::id, id_base::nargs, and decision_tree::root.
Referenced by main().
|
static |
Current simplifier ID we are processing during insertion into the decision tree.
Referenced by decision_tree::find_node(), and decision_tree::insert().
|
static |
Line numbers for use by indirect line directives.
Referenced by define_dump_logs(), and output_line_directive().
|
static |
The current label failing the current matched pattern during code generation.
Referenced by compare_by_pieces(), compare_by_pieces_d::compare_by_pieces_d(), dt_simplify::gen_1(), expr::gen_transform(), and match_rtx().
|
static |
Secondary stream for fp_decl.
Referenced by fp_decl(), fp_decl_done(), main(), and write_header_includes().
libccp helpers.
Referenced by simple_diagnostic_path::add_event(), simple_diagnostic_path::add_thread_event(), lto_location_cache::apply_location_cache(), debug(), diagnostic_append_note(), diagnostic_cb(), diagnostic_for_asm(), emit_diagnostic(), emit_diagnostic_valist(), format_string_diagnostic_t::emit_warning_n_va(), error(), error_at(), error_n(), fatal_at(), fatal_at(), fatal_error(), fold_builtin_next_arg(), c_expr::gen_transform(), general_init(), get_expr_source_range(), gt_pch_restore(), diagnostic_context::includes_seen_p(), inform(), inform_n(), internal_error(), internal_error_no_backtrace(), main(), maybe_unwind_expanded_macro_loc(), optrecord_json_writer::optinfo_to_json(), output_line_directive(), pedwarn(), permerror(), permerror_opt(), process_options(), diagnostic_context::report_current_module(), set_block(), sorry(), sorry_at(), diagnostic_option_classifier::update_effective_level_from_pragmas(), use_new_line(), warning(), warning_at(), warning_at(), warning_at(), diagnostic_context::warning_enabled_at(), and warning_n().
|
static |
The special id "null", which matches nothing.
Referenced by get_operator(), lower_for(), and main().
|
static |
Hashtable of known pattern operators. This is pre-seeded from all known tree codes and all known builtin function ids.
Referenced by add_function(), add_operator(), add_predicate(), get_operator(), main(), parser::parse_for(), and parser::parse_operator_list().
unsigned verbose |
Global state.
Verboseness. 0 is quiet, 1 adds some warnings, 2 is for debugging.
Referenced by dt_node::append_simplify(), decision_tree::find_node(), decision_tree::gen(), dt_simplify::gen_1(), main(), output_line_directive(), capture_info::walk_c_expr(), and capture_info::walk_match().