GCC Middle and Back End API Reference
|
#include "bconfig.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "errors.h"
#include "read-md.h"
#include "gensupport.h"
#include "rtl.def"
Data Structures | |
struct | position |
class | list_head< T > |
class | list_head< T >::range |
struct | acceptance_type |
class | parameter |
class | pattern_routine |
class | pattern_use |
class | rtx_test |
class | int_set |
class | transition |
class | decision |
class | state |
class | known_conditions |
class | stats |
class | merge_pattern_transition |
class | merge_pattern_info |
class | merge_state_result |
class | merge_state_info |
struct | test_pattern_hasher |
struct | create_pattern_info |
struct | state_size |
class | pattern_pos |
class | output_state |
Macros | |
#define | INCLUDE_ALGORITHM |
#define | DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) |
#define | NUM_TRUE_RTX_CODE ((int) FIRST_GENERATOR_RTX_CODE) |
#define | GENERATOR_FILE 1 |
Typedefs | |
typedef std::pair< transition *, state_size > | subroutine_candidate |
Enumerations | |
enum | true_rtx_doe { FIRST_GENERATOR_RTX_CODE } |
enum | position_type { POS_PEEP2_INSN , POS_XEXP , POS_XVECEXP0 } |
enum | routine_type { SUBPATTERN , RECOG , SPLIT , PEEPHOLE2 } |
enum | exit_state { ES_RETURNED , ES_FALLTHROUGH } |
#define GENERATOR_FILE 1 |
Referenced by rtx_writer::rtx_writer().
#define INCLUDE_ALGORITHM |
Generate code from machine description to recognize rtl as insns. Copyright (C) 1987-2025 Free Software Foundation, Inc. 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/>.
This program is used to produce insn-recog.cc, which contains a function called `recog' plus its subroutines. These functions contain a decision tree that recognizes whether an rtx, the argument given to recog, is a valid instruction. recog returns -1 if the rtx is not valid. If the rtx is valid, recog returns a nonnegative number which is the insn code number for the pattern that matched. This is the same as the order in the machine description of the entry that matched. This number can be used as an index into various insn_* tables, such as insn_template, insn_outfun, and insn_n_operands (found in insn-output.cc). The third argument to recog is an optional pointer to an int. If present, recog will accept a pattern if it matches except for missing CLOBBER expressions at the end. In that case, the value pointed to by the optional pointer will be set to the number of CLOBBERs that need to be added (it should be initialized to zero by the caller). If it is set nonzero, the caller should allocate a PARALLEL of the appropriate size, copy the initial entries, and call add_clobbers (found in insn-emit.cc) to fill in the CLOBBERs. This program also generates the function `split_insns', which returns 0 if the rtl could not be split, or it returns the split rtl as an INSN list. This program also generates the function `peephole2_insns', which returns 0 if the rtl could not be matched. If there was a match, the new rtl is returned in an INSN list, and LAST_INSN will point to the last recognized insn in the old sequence. At a high level, the algorithm used in this file is as follows: 1. Build up a decision tree for each routine, using the following approach to matching an rtx: - First determine the "shape" of the rtx, based on GET_CODE, XVECLEN and XINT. This phase examines SET_SRCs before SET_DESTs since SET_SRCs tend to be more distinctive. It examines other operands in numerical order, since the canonicalization rules prefer putting complex operands of commutative operators first. - Next check modes and predicates. This phase examines all operands in numerical order, even for SETs, since the mode of a SET_DEST is exact while the mode of a SET_SRC can be VOIDmode for constant integers. - Next check match_dups. - Finally check the C condition and (where appropriate) pnum_clobbers. 2. Try to optimize the tree by removing redundant tests, CSEing tests, folding tests together, etc. 3. Look for common subtrees and split them out into "pattern" routines. These common subtrees can be identical or they can differ in mode, code, or integer (usually an UNSPEC or UNSPEC_VOLATILE code). In the latter case the users of the pattern routine pass the appropriate mode, etc., as argument. For example, if two patterns contain: (plus:SI (match_operand:SI 1 "register_operand") (match_operand:SI 2 "register_operand")) we can split the associated matching code out into a subroutine. If a pattern contains: (minus:DI (match_operand:DI 1 "register_operand") (match_operand:DI 2 "register_operand")) then we can consider using the same matching routine for both the plus and minus expressions, passing PLUS and SImode in the former case and MINUS and DImode in the latter case. The main aim of this phase is to reduce the compile time of the insn-recog.cc code and to reduce the amount of object code in insn-recog.o. 4. Split the matching trees into functions, trying to limit the size of each function to a sensible amount. Again, the main aim of this phase is to reduce the compile time of insn-recog.cc. (It doesn't help with the size of insn-recog.o.) 5. Write out C++ code for each function.
#define NUM_TRUE_RTX_CODE ((int) FIRST_GENERATOR_RTX_CODE) |
Referenced by get_predicate_codes().
typedef std::pair<transition *, state_size> subroutine_candidate |
Pairs a transition with information about its target state.
enum exit_state |
enum position_type |
enum routine_type |
enum true_rtx_doe |
|
static |
Add a transition from FROM to a new, empty state that is taken when TEST == LABELS. OPTIONAL says whether the new transition should be optional. Return the new state.
References add_decision().
|
static |
Add to FROM a decision that performs TEST and has a single transition TRANS.
References list_head< T >::push_back().
Referenced by add_decision(), add_pattern_acceptance(), create_subroutine(), match_pattern_1(), and match_pattern_2().
|
static |
PARAMS2 is the "params" array for a pattern and PARAMS1 is the set of parameters that a particular state is going to pass to that pattern. Try to extend PARAMS1 and PARAMS2 so that there is a parameter that is equal to PARAM1 for the state and has a default value of PARAM2. Parameters beginning at START were added as part of the same match and so may be reused.
References force_unique_params_p, gcc_assert, i, parameter::is_param, and MAX_PATTERN_PARAMS.
Referenced by merge_patterns().
|
static |
Make S return the next unclaimed pattern routine result for CPI.
References rtx_test::accept(), add_decision(), acceptance_type::code, acceptance_type::full, create_pattern_info::next_result, acceptance_type::partial_p, SUBPATTERN, acceptance_type::type, and acceptance_type::u.
Referenced by populate_pattern_routine().
|
static |
Make sure that OS has a position variable for POS. ROOT_P is true if POS is the root position for the routine.
References assign_position_var(), position::base, position::id, output_state::id_to_var, POS_PEEP2_INSN, position::type, and output_state::var_to_id.
Referenced by assign_position_var(), assign_position_vars(), and print_subroutine_start().
|
static |
Make sure that OS has the position variables required by S.
References assign_position_var(), assign_position_vars(), list_head< T >::first, decision::next, and transition::next.
Referenced by assign_position_vars(), and print_subroutine_start().
|
static |
Emit code to initialize the variable associated with POS, if it isn't already valid in state OS. Indent each line by INDENT spaces. Update OS with the new state.
References position::arg, position::base, change_state(), gcc_assert, position::id, output_state::id_to_var, POS_PEEP2_INSN, POS_XEXP, POS_XVECEXP0, printf_indent(), output_state::seen_vars, position::type, and output_state::var_to_id.
Referenced by change_state(), and print_decision().
|
static |
Remove any optional transitions from S that turned out not to be useful.
References collapse_optional_decisions(), list_head< T >::first, decision::next, transition::next, list_head< T >::release(), list_head< T >::replace(), and list_head< T >::singleton().
Referenced by collapse_optional_decisions(), and optimize_subroutine_group().
Return the most deeply-nested position that is common to both POS1 and POS2. If the positions are from different instructions, return the one with the lowest insn_id.
References position::base, position::depth, and position::insn_id.
Referenced by populate_pattern_routine(), and split_out_patterns().
|
static |
Return true if all successful returns passing through D require the condition tested by COMMON to be true. When returning true, add all transitions like COMMON in D to WHERE. WHERE may contain a partial result on failure.
References rtx_test::ACCEPT, common_test_p(), list_head< T >::first, transition::from, rtx_test::kind, transition::labels, transition::next, transition::optional, list_head< T >::singleton(), and decision::test.
Referenced by common_test_p(), and find_common_test().
Compare positions POS1 and POS2 lexicographically.
References position::arg, position::base, position::depth, and position::type.
Referenced by operator<().
|
static |
Return true if A and B can be tested by a single test. If the test can be parameterised, store the parameter value for A in *PARAMA and the parameter value for B in *PARAMB, otherwise leave PARAMA and PARAMB alone.
References a, b, parameter::INT, parameter::MODE, rtx_test::PREDICATE, and rtx_test::SAVED_CONST_INT.
Referenced by test_pattern_hasher::equal(), and merge_patterns().
|
static |
Return true if PAT represents the biggest posssible match for SINFO; that is, if the next action of SINFO's state on return from PAT will be something that cannot be merged with any other state.
References merge_pattern_info::transitions.
Referenced by split_out_patterns().
In DEFINE_EXPAND, DEFINE_SPLIT, and DEFINE_PEEPHOLE2, we don't use the MATCH_OPERAND constraint, only the predicate. This is confusing to folks doing new ports, so help them not make the mistake.
References GET_CODE.
Referenced by validate_pattern().
|
static |
Turn S into a subroutine of type TYPE and add it to PROCS. Return a new state that performs a subroutine call to S.
References rtx_test::accept(), add_decision(), acceptance_type::partial_p, acceptance_type::subroutine_id, acceptance_type::type, and acceptance_type::u.
Referenced by find_subroutines().
|
static |
Try to promote common subtests in S to a single, shared decision. Also try to bunch tests for the same position together. POS is the position of the rtx tested before reaching S. KC are the conditions that are known to hold on entry to S.
References rtx_test::ACCEPT, rtx_test::C_TEST, rtx_test::CODE, cse_tests(), find_common_test(), list_head< T >::first, transition::from, gcc_assert, insert_decision_before(), transition::labels, MAX, decision::next, transition::next, transition::optional, rtx_test::PEEP2_COUNT, known_conditions::peep2_count, rtx_test::pos, known_conditions::position_tests, list_head< T >::release(), list_head< T >::replace(), decision::s, safe_to_hoist_p(), rtx_test::SET_OP, known_conditions::set_operands, decision::test, TESTED_CODE, TESTED_VECLEN, transition::to, rtx_test::VECLEN, and rtx_test::VECLEN_GE.
Referenced by cse_tests(), and optimize_subroutine_group().
|
static |
Look for a transition that is taken by all successful returns from a range of decisions starting at OUTER and that would be better performed by OUTER's state instead. On success, store all instances of that transition in WHERE and return the last decision in the range. The range could just be OUTER, or it could include later decisions as well. WITH_POSITION_P is true if only tests with position POS should be tried, false if any test should be tried. WORTHWHILE_SINGLE_P is true if the result is useful even when the range contains just a single decision with a single transition. KC are the conditions that are known to hold at OUTER.
References common_test_p(), list_head< T >::first, decision::next, safe_to_hoist_p(), list_head< T >::singleton(), decision::test, and transition::to.
Referenced by cse_tests().
Search for and return operand M, such that it has a matching constraint for operand N.
References find_matching_operand(), gcc_unreachable, GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, i, NULL, r, RTX_CODE, XEXP, XSTR, XVEC, XVECEXP, and XVECLEN.
Referenced by find_matching_operand(), and validate_pattern().
Search for and return operand N, stop when reaching node STOP.
References find_operand(), gcc_unreachable, GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, i, NULL, NULL_RTX, r, RTX_CODE, XEXP, XINT, XVEC, XVECEXP, and XVECLEN.
Referenced by find_operand(), match_pattern_2(), and validate_pattern().
Initialize the pos_operand fields of each state reachable from S. If OPERAND_POS[ID] >= 0, the position with id ID is stored in operands[OPERAND_POS[ID]] on entry to S.
References find_operand_positions(), list_head< T >::first, decision::next, transition::next, and rtx_test::SET_OP.
Referenced by find_operand_positions(), and optimize_subroutine_group().
|
static |
Walk state tree S, of type TYPE, and look for subtrees that would be better split into subroutines. Accumulate all such subroutines in PROCS. Return the size of the new state tree (excluding subroutines).
References rtx_test::ACCEPT, candidates, create_subroutine(), state_size::depth, find_subroutines(), list_head< T >::first, i, decision::if_statement_p(), rtx_test::kind, MAX, MAX_DEPTH, MAX_NUM_STATEMENTS, MIN_NUM_STATEMENTS, decision::next, transition::next, state_size::num_statements, rtx_test::pos, rtx_test::pos_operand, rtx_test::SET_OP, rtx_test::single_outcome_p(), list_head< T >::singleton(), subroutine_candidate_cmp(), and decision::test.
Referenced by find_subroutines(), and print_subroutine_group().
|
static |
Return the C failure value for a routine of type TYPE.
References gcc_unreachable, PEEPHOLE2, RECOG, SPLIT, and SUBPATTERN.
Referenced by print_decision(), and print_state().
|
static |
Return the rtx pattern for the list of rtxes in a define_peephole2.
References md_rtx_info::def, error_at(), GET_CODE, GET_NUM_ELEM, i, md_rtx_info::loc, rtvec_alloc(), RTVEC_ELT, rtx_alloc(), XVEC, XVECEXP, and XVECLEN.
Referenced by main().
Fill CODES with the set of codes that could be matched by PRED.
References pred_data::codes, i, and NUM_TRUE_RTX_CODE.
Referenced by match_pattern_2().
Return statistics about S.
References rtx_test::ACCEPT, list_head< T >::first, get_stats(), stats::longest_backtrack, stats::longest_backtrack_code, stats::longest_path, stats::longest_path_code, decision::next, transition::next, and stats::num_decisions.
Referenced by get_stats(), and optimize_subroutine_group().
|
static |
References fopen, header, header_name, and output_files.
Return true if the first path through D1 tests the same thing as D2.
Referenced by mutually_exclusive_p().
|
static |
SINFO matches a pattern for which we've decided to create a C routine. Return a decision that performs a call to the pattern routine, but leave the caller to add the transitions to it. Initialize CPI for this purpose. Also create a definition for the pattern routine, if it doesn't already have one. PARAMS are the parameters that SINFO passes to its pattern.
References list_head< T >::first, gcc_assert, i, pattern_routine::insn_p, create_pattern_info::next_result, merge_pattern_info::num_results, pattern_routine::param_types, merge_pattern_info::params, merge_state_result::pattern, rtx_test::pattern, pattern_routine::pattern_id, patterns, pattern_routine::pnum_clobbers_p, populate_pattern_routine(), pattern_routine::pos, rtx_test::pos, rtx_test::pos_operand, merge_state_result::root, create_pattern_info::routine, merge_pattern_info::routine, pattern_routine::s, sinfo::s, and decision::test.
Referenced by populate_pattern_routine(), and use_pattern().
|
static |
Insert a decision before decisions R to make them dependent on TEST == LABELS. OPTIONAL says whether the new transition should be optional.
References list_head< T >::push_back(), and r.
Referenced by cse_tests().
int main | ( | int | argc, |
const char ** | argv ) |
References add_implicit_parallel(), choose_output(), acceptance_type::code, md_rtx_info::def, FATAL_EXIT_CODE, FOR_EACH_VEC_ELT, acceptance_type::full, GET_CODE, get_peephole2_pattern(), handle_arg(), have_error, header, header_name, i, output_state::id_to_var, md_rtx_info::index, init_rtx_reader_args_cb(), match_pattern(), NULL, NULL_RTX, acceptance_type::num_clobbers, num_positions, optimize_subroutine_group(), output_files, acceptance_type::partial_p, patterns, PEEPHOLE2, print_pattern(), print_subroutine_group(), progname, read_md_rtx(), RECOG, remove_clobbers(), SPLIT, split_out_patterns(), SUCCESS_EXIT_CODE, acceptance_type::type, acceptance_type::u, use_pattern_routines_p, validate_pattern(), write_header(), and XVEC.
|
static |
Like match_pattern_1, but (if merge_states_p) try to merge the decisions with what's already in S, to reduce the amount of backtracking.
References match_pattern_1(), merge_into_state(), and merge_states_p.
Referenced by find_optab(), and main().
|
static |
Add new decisions to S that make it return ACCEPTANCE if: (1) the rtx doesn't match anything already matched by S (2) the rtx matches TOP_PATTERN and (3) the C test required by INFO->def is true For peephole2, TOP_PATTERN is a SEQUENCE of the instruction patterns to match, otherwise it is a single instruction pattern.
References rtx_test::accept(), add_decision(), rtx_test::c_test(), count, md_rtx_info::def, acceptance_type::full, get_c_test(), rtx_test::have_num_clobbers(), i, acceptance_type::match_len, match_pattern_2(), maybe_eval_c_test(), position::next, next_position(), acceptance_type::num_clobbers, rtx_test::peep2_count(), peep2_insn_pos_list, PEEPHOLE2, POS_PEEP2_INSN, RECOG, root_pos, acceptance_type::type, acceptance_type::u, XVECEXP, and XVECLEN.
Referenced by match_pattern().
|
static |
Add new decisions to S that check whether the rtx at position POS matches PATTERN. Return the state that is reached in that case. TOP_PATTERN is the overall pattern, as passed to match_pattern_1.
References add_decision(), rtx_test::code(), pred_data::codes, md_rtx_info::def, rtx_test::duplicate(), error_at(), find_operand(), FOR_EACH_VEC_ELT, gcc_assert, gcc_unreachable, GET_CODE, GET_MODE, get_predicate_codes(), GET_RTX_FORMAT, GET_RTX_NAME, i, rtx_test::int_field(), md_rtx_info::loc, lookup_predicate(), MAX, rtx_test::mode, pred_data::name, position::next, next_position(), NULL_RTX, num_operands, pattern_pos::pattern, pattern_pos::pos, POS_XEXP, POS_XVECEXP0, rtx_test::predicate, predicate_name(), REGNO, rtx_test::regno_field(), safe_predicate_mode(), SET, rtx_test::set_op(), pred_data::singleton, SUBREG_BYTE, rtx_test::subreg_field(), rtx_test::veclen(), rtx_test::veclen_ge(), rtx_test::wide_int_field(), worklist, XEXP, position::xexps, XINT, XVECEXP, position::xvecexp0s, XVECLEN, and XWINT.
Referenced by match_pattern_1().
|
static |
Try to merge S2's decision into D1, given that they have the same test. Fail only if EXCLUDE is nonnull and the new transition would have the same labels as *EXCLUDE. When returning true, set *NEXT_S1, *NEXT_S2 and *NEXT_EXCLUDE as for merge_into_state_1, or set *NEXT_S2 to null if the merge is complete.
References int_set::begin(), d1, d2, end(), int_set::end(), list_head< T >::first, gcc_assert, i, i1, i2, transition::labels, transition::optional, list_head< T >::push_back(), r, list_head< T >::replace(), list_head< T >::singleton(), and transition::to.
Referenced by merge_into_state_1().
Merge S2 into S1. If they both match a particular rtx, give priority to S1. Each state in S2 has a single decision.
References merge_into_state_1().
Referenced by match_pattern().
|
static |
Make progress in merging S2 into S1, given that each state in S2 has a single decision. If EXCLUDE is nonnull, avoid creating a new transition with the same test as S2's decision and with the labels in *EXCLUDE. Return true if there is still work to do. When returning true, set *NEXT_S1, *NEXT_S2 and *NEXT_EXCLUDE to the values that S1, S2 and EXCLUDE should have next time round. If S1 and S2 both match a particular rtx, give priority to S1.
References d1, d2, list_head< T >::last, merge_into_decision(), mutually_exclusive_p(), transition::optional, list_head< T >::push_back(), list_head< T >::release(), list_head< T >::singleton(), decision::test, and transition::to.
Referenced by merge_into_state().
|
static |
Try to make the state described by SINFO1 use the same pattern as the state described by SINFO2. Return true on success. SINFO1 and SINFO2 are known to have the same hash value.
References add_parameter(), compatible_tests_p(), d1, d2, FOR_EACH_VEC_ELT, gcc_assert, gcc_unreachable, i, parameter::is_param, transition::labels, merge_relative_positions(), transition::next, merge_state_info::num_transitions, merge_pattern_info::param_test, merge_pattern_info::param_test_p, merge_pattern_info::param_transition, merge_pattern_info::param_transition_p, merge_pattern_info::params, merge_state_result::params, merge_state_result::pattern, merge_state_info::res, merge_state_result::root, merge_state_info::s, set_parameter(), list_head< T >::singleton(), merge_state_info::to_states, transition_parameter_type(), merge_pattern_info::transitions, parameter::type, parameter::UNSET, update_parameters(), parameter::value, and rtx_test::WIDE_INT_FIELD.
Referenced by split_out_patterns().
|
static |
If *ROOTA is nonnull, return true if the same sequence of steps are required to reach A from *ROOTA as to reach B from ROOTB. If *ROOTA is null, update it if necessary in order to make the condition hold.
References a, b, position::insn_id, and relative_patterns_p.
Referenced by merge_patterns().
Return true if D1 and D2 cannot match the same rtx. All states reachable from D2 have single decisions and all those decisions have single transitions.
References int_set::begin(), d1, d2, int_set::end(), list_head< T >::first, has_same_test_p(), i1, i2, transition::labels, mutually_exclusive_p(), and transition::next.
Referenced by merge_into_state_1(), and mutually_exclusive_p().
|
static |
Return a position with the given BASE, TYPE and ARG. NEXT_PTR points to where the unique object that represents the position should be stored. Create the object if it doesn't already exist, otherwise reuse the object that is already there.
References position::arg, position::base, position::depth, position::id, position::insn_id, num_positions, POS_PEEP2_INSN, and position::type.
Referenced by match_pattern_1(), and match_pattern_2().
bool operator!= | ( | const acceptance_type & | a, |
const acceptance_type & | b ) |
References a, b, and operator==().
References operator==().
bool operator< | ( | const pattern_pos & | e1, |
const pattern_pos & | e2 ) |
Compare entries according to their depth-first order. There shouldn't be two entries at the same position.
References compare_positions(), gcc_assert, pattern_pos::pattern, and pattern_pos::pos.
bool operator== | ( | const acceptance_type & | a, |
const acceptance_type & | b ) |
Referenced by operator!=(), operator!=(), operator!=(), and operator!=().
References parameter::is_param, parameter::type, and parameter::value.
References a, rtx_test::ACCEPT, b, rtx_test::C_TEST, rtx_test::CODE, rtx_test::DUPLICATE, gcc_unreachable, rtx_test::HAVE_NUM_CLOBBERS, rtx_test::INT_FIELD, rtx_test::MODE, rtx_test::PATTERN, rtx_test::PEEP2_COUNT, rtx_test::PREDICATE, rtx_test::REGNO_FIELD, rtx_test::SAVED_CONST_INT, rtx_test::SET_OP, rtx_test::SUBREG_FIELD, rtx_test::VECLEN, rtx_test::VECLEN_GE, and rtx_test::WIDE_INT_FIELD.
|
static |
Optimize ROOT. Use TYPE to describe ROOT in status messages.
References collapse_optional_decisions(), collapse_optional_decisions_p, cse_tests(), cse_tests_p, find_operand_positions(), get_stats(), i, stats::longest_backtrack, stats::longest_backtrack_code, stats::longest_path, stats::longest_path_code, stats::num_decisions, num_operands, num_positions, known_conditions::peep2_count, known_conditions::position_tests, root_pos, known_conditions::set_operands, simplify_tests(), simplify_tests_p, and use_operand_variables_p.
Referenced by main().
|
static |
Return the C type of a parameter with type TYPE.
References parameter::CODE, gcc_unreachable, parameter::INT, parameter::MODE, parameter::UINT, parameter::UNSET, and parameter::WIDE_INT.
Referenced by print_pattern().
|
static |
Initialize new empty state NEWS so that it implements SINFO's pattern (here referred to as "P"). P may be the top level of a pattern routine or a subpattern that should be inlined into its parent pattern's routine (as per same_pattern_p). The choice of SINFO for a top-level pattern is arbitrary; it could be any of the states that use P. The choice for subpatterns follows the choice for the parent pattern. PARAMS gives the value of each parameter to P in terms of the parameters to the top-level pattern. If P itself is the top level pattern, PARAMS[I] is always "parameter (TYPE, true, I)".
References add_pattern_acceptance(), rtx_test::C_TEST, common_position(), list_head< T >::first, gcc_assert, gcc_unreachable, rtx_test::HAVE_NUM_CLOBBERS, i, init_pattern_use(), pattern_routine::insn_p, rtx_test::integer, parameter::is_param, rtx_test::is_param, transition::is_param, rtx_test::kind, transition::labels, rtx_test::mode, rtx_test::mode_is_param, transition::next, merge_pattern_info::num_results, merge_pattern_info::param_test, merge_pattern_info::param_test_p, merge_pattern_info::param_transition, merge_pattern_info::param_transition_p, merge_pattern_info::params, merge_state_result::pattern, pattern_def_states, pattern_routine::pnum_clobbers_p, populate_pattern_routine(), pattern_routine::pos, rtx_test::pos, rtx_test::pos_operand, rtx_test::PREDICATE, rtx_test::predicate, list_head< T >::push_back(), merge_state_info::res, create_pattern_info::routine, sinfo::s, same_pattern_p(), rtx_test::SAVED_CONST_INT, decision::test, merge_pattern_info::transitions, rtx_test::u, parameter::value, and rtx_test::value.
Referenced by init_pattern_use(), and populate_pattern_routine().
|
static |
USE is a decision that calls a pattern routine and SINFO is part of the original state tree that the call is supposed to replace. Add the transitions for SINFO and its substates to USE.
References list_head< T >::first, gcc_assert, i, transition::next, create_pattern_info::next_result, merge_state_result::pattern, pattern_use_states, populate_pattern_use(), sinfo::s, and merge_pattern_info::transitions.
Referenced by populate_pattern_use(), and use_pattern().
|
static |
Return the name of the predicate matched by MATCH_RTX.
References GET_CODE, match_rtx(), and XSTR.
Referenced by match_pattern_2(), and special_predicate_operand_p().
|
static |
Print code for the successful match described by ACCEPTANCE. INDENT and IS_FINAL are as for print_state.
References acceptance_type::code, ES_FALLTHROUGH, ES_RETURNED, acceptance_type::full, gcc_unreachable, get_insn_name(), acceptance_type::match_len, acceptance_type::num_clobbers, acceptance_type::partial_p, PEEPHOLE2, print_subroutine_call(), printf_indent(), RECOG, SPLIT, SUBPATTERN, acceptance_type::type, and acceptance_type::u.
Referenced by print_decision().
|
static |
Print the enumerator constant for CODE -- the upcase version of the name.
References GET_RTX_NAME.
Referenced by print_parameter_value().
|
static |
Print code to perform D. INDENT and IS_FINAL are as for print_state.
References rtx_test::ACCEPT, rtx_test::acceptance, change_state(), count, ES_FALLTHROUGH, ES_RETURNED, list_head< T >::first, gcc_assert, gcc_unreachable, get_failure_return(), decision::if_statement_p(), rtx_test::is_param, transition::is_param, rtx_test::kind, mark_optional_transitions_p, transition::next, rtx_test::opno, transition::optional, rtx_test::pos, rtx_test::pos_operand, print_acceptance(), print_label_value(), print_nonbool_test(), print_state(), print_test(), print_test_rtx(), printf_indent(), output_state::seen_vars, rtx_test::SET_OP, single_statement_p(), list_head< T >::singleton(), SUBPATTERN, terminal_pattern_p(), decision::test, test_position_available_p(), transition::to, output_state::type, and rtx_test::u.
Referenced by print_state().
|
static |
Emit a uint64_t as an integer constant expression. We need to take special care to avoid "decimal constant is so large that it is unsigned" warnings in the resulting code.
References HOST_BITS_PER_WIDE_INT, and HOST_WIDE_INT_PRINT_DEC_C.
Referenced by print_parameter_value().
|
static |
IS_PARAM and LABEL are taken from a transition whose source decision performs TEST. Print the C code for the label.
References rtx_test::kind, print_parameter_value(), and transition_parameter_type().
Referenced by print_decision(), and print_test().
|
static |
Print the C expression for non-boolean test TEST.
References rtx_test::ACCEPT, rtx_test::C_TEST, rtx_test::CODE, rtx_test::DUPLICATE, gcc_unreachable, rtx_test::HAVE_NUM_CLOBBERS, i, pattern_routine::insn_p, rtx_test::INT_FIELD, rtx_test::kind, rtx_test::MODE, rtx_test::opno, pattern_use::params, rtx_test::PATTERN, rtx_test::pattern, pattern_routine::pattern_id, rtx_test::PEEP2_COUNT, pattern_routine::pnum_clobbers_p, rtx_test::pos, rtx_test::PREDICATE, print_parameter_value(), print_test_rtx(), rtx_test::REGNO_FIELD, pattern_use::routine, rtx_test::SAVED_CONST_INT, rtx_test::SET_OP, rtx_test::SUBREG_FIELD, rtx_test::u, rtx_test::VECLEN, rtx_test::VECLEN_GE, and rtx_test::WIDE_INT_FIELD.
Referenced by print_decision(), and print_test().
|
static |
Print the C expression for actual parameter PARAM.
References parameter::CODE, gcc_unreachable, GET_MODE_NAME, parameter::INT, parameter::is_param, parameter::MODE, print_code(), print_host_wide_int(), parameter::type, parameter::UINT, parameter::UNSET, parameter::value, and parameter::WIDE_INT.
Referenced by print_label_value(), print_nonbool_test(), and print_test().
|
static |
Output the definition of pattern routine ROUTINE.
References i, pattern_routine::insn_p, pattern_routine::param_types, parameter_type_string(), pattern_routine::pattern_id, pattern_routine::pnum_clobbers_p, pattern_routine::pos, print_state(), print_subroutine_start(), pattern_routine::s, SUBPATTERN, and output_state::type.
Referenced by main().
|
static |
Print code to perform S, indent each line by INDENT spaces. IS_FINAL is true if there are no fallback decisions to test on failure; if the state fails then the entire routine fails.
References ES_FALLTHROUGH, ES_RETURNED, list_head< T >::first, get_failure_return(), decision::next, print_decision(), printf_indent(), and output_state::type.
Referenced by print_decision(), print_filtered_help(), print_pattern(), and print_subroutine().
|
static |
Output a routine of type TYPE that implements S. PROC_ID is the number of the subroutine associated with S, or 0 if S is the main routine.
References end(), gcc_unreachable, PEEPHOLE2, print_state(), print_subroutine_start(), RECOG, root_pos, SPLIT, SUBPATTERN, and output_state::type.
Referenced by print_subroutine_group().
|
static |
Print the code for subroutine call ACCEPTANCE (for which partial_p is known to be true). Return the C condition that indicates a successful match.
References gcc_unreachable, PEEPHOLE2, RECOG, SPLIT, SUBPATTERN, acceptance_type::subroutine_id, acceptance_type::type, and acceptance_type::u.
Referenced by print_acceptance().
|
static |
Print out a routine of type TYPE that performs ROOT.
References choose_output(), find_subroutines(), FOR_EACH_VEC_ELT, header, i, print_subroutine(), output_state::type, and use_subroutines_p.
Referenced by main().
|
static |
Print the open brace and variable definitions for a routine that implements S. ROOT is the deepest rtx from which S can access all relevant parts of the first instruction it matches. Initialize OS so that every relevant position has an rtx variable xN and so that only ROOT's variable has a valid value.
References assign_position_var(), assign_position_vars(), i, num_positions, RECOG, output_state::seen_vars, SUBPATTERN, output_state::type, and output_state::var_to_id.
Referenced by print_pattern(), and print_subroutine().
|
static |
If IS_PARAM, print code to compare TEST with the C variable i<VALUE+1>. If !IS_PARAM, print code to compare TEST with the C constant VALUE. Test for inequality if INVERT_P, otherwise test for equality.
References rtx_test::ACCEPT, rtx_test::C_TEST, rtx_test::CODE, rtx_test::data, rtx_test::DUPLICATE, gcc_assert, gcc_unreachable, rtx_test::HAVE_NUM_CLOBBERS, parameter::INT, rtx_test::INT_FIELD, rtx_test::integer, rtx_test::is_param, rtx_test::kind, rtx_test::min_len, parameter::MODE, rtx_test::MODE, rtx_test::mode, rtx_test::mode_is_param, pred_data::name, rtx_test::opno, rtx_test::PATTERN, rtx_test::PEEP2_COUNT, rtx_test::PREDICATE, rtx_test::predicate, print_label_value(), print_nonbool_test(), print_parameter_value(), print_test_rtx(), rtx_test::REGNO_FIELD, rtx_reader_ptr, rtx_test::SAVED_CONST_INT, rtx_test::SET_OP, rtx_test::string, rtx_test::SUBREG_FIELD, rtx_test::u, rtx_test::value, rtx_test::VECLEN, rtx_test::VECLEN_GE, and rtx_test::WIDE_INT_FIELD.
Referenced by print_decision().
|
static |
Print the C expression for the rtx tested by TEST.
References position::id, output_state::id_to_var, rtx_test::pos, and rtx_test::pos_operand.
Referenced by print_decision(), print_nonbool_test(), and print_test().
|
static |
Like printf, but print INDENT spaces at the beginning.
References ap, and vfprintf().
Referenced by change_state(), print_acceptance(), print_decision(), and print_state().
|
static |
Remove any matches that are no longer valid from the head of SINFO's list of matches.
References gcc_assert, and valid_result_p().
Referenced by split_out_patterns().
|
static |
Return true if *PATTERN_PTR is a PARALLEL in which at least one trailing rtx can be added automatically by add_clobbers. If so, update *ACCEPTANCE_PTR so that its num_clobbers field contains the number of such trailing rtxes and update *PATTERN_PTR so that it contains the pattern without those rtxes.
References acceptance_type::full, GET_CODE, i, acceptance_type::num_clobbers, REG_P, rtvec_alloc(), rtx_alloc(), acceptance_type::u, XEXP, XVEC, XVECEXP, and XVECLEN.
Referenced by main().
Return true if, for all X, PRED (X, MODE) implies that X has mode MODE.
References pred_data::codes, GET_MODE_CLASS, and pred_data::special.
Referenced by match_pattern_2().
|
static |
Return true if TEST can safely be performed at D, where the conditions in KC hold. TEST is known to occur along the first path from D (i.e. always following the first transition of the first decision). Any intervening tests can be used as negative proof that hoisting isn't safe, but only KC can be used as positive proof.
References rtx_test::ACCEPT, position::arg, position::base, rtx_test::C_TEST, rtx_test::CODE, rtx_test::DUPLICATE, gcc_unreachable, rtx_test::HAVE_NUM_CLOBBERS, position::id, rtx_test::INT_FIELD, rtx_test::kind, rtx_test::MODE, rtx_test::opno, rtx_test::PATTERN, rtx_test::PEEP2_COUNT, known_conditions::peep2_count, rtx_test::pos, POS_PEEP2_INSN, POS_XEXP, POS_XVECEXP0, known_conditions::position_tests, rtx_test::PREDICATE, rtx_test::REGNO_FIELD, rtx_test::SAVED_CONST_INT, rtx_test::SET_OP, known_conditions::set_operands, rtx_test::SUBREG_FIELD, decision::test, TESTED_CODE, TESTED_VECLEN, position::type, rtx_test::u, rtx_test::VECLEN, rtx_test::VECLEN_GE, and rtx_test::WIDE_INT_FIELD.
Referenced by cse_tests(), and find_common_test().
|
static |
PAT2 is a subpattern of PAT1. Return true if PAT2 should be inlined into PAT1's C routine.
References merge_pattern_info::num_users, and useful_pattern_p().
Referenced by populate_pattern_routine(), and split_out_patterns().
|
static |
PARAMS is an array of the parameters that a state is going to pass to a pattern routine. It is still incomplete; index I has a kind of parameter::UNSET if we don't yet know what the state will pass as parameter I. Try to make parameter ID equal VALUE, returning true on success.
References force_unique_params_p, i, and parameter::UNSET.
Referenced by merge_patterns().
|
static |
Try to squash several separate tests into simpler ones.
References rtx_test::CODE, d2, list_head< T >::first, IN_RANGE, MAX_SAVED_CONST_INT, decision::next, transition::next, rtx_test::PREDICATE, list_head< T >::release(), list_head< T >::replace(), rtx_test::SAVED_CONST_INT, simplify_tests(), list_head< T >::singleton(), transition::to, and rtx_test::WIDE_INT_FIELD.
Referenced by optimize_subroutine_group(), and simplify_tests().
|
static |
Return true if ACCEPTANCE requires only a single C statement even in a backtracking context.
References acceptance_type::full, gcc_unreachable, acceptance_type::num_clobbers, acceptance_type::partial_p, PEEPHOLE2, RECOG, SPLIT, SUBPATTERN, acceptance_type::type, and acceptance_type::u.
Referenced by print_decision().
Return true if OPERAND is a MATCH_OPERAND using a special predicate function.
References GET_CODE, lookup_predicate(), NULL, predicate_name(), and pred_data::special.
Referenced by validate_pattern().
|
static |
Look through the state trees in STATES for common patterns and split them into subroutines.
References rtx_test::ACCEPT, rtx_test::C_TEST, common_position(), merge_pattern_info::complete_p, complete_result_p(), d2, hash_table< Descriptor, Lazy, Allocator >::find_slot(), gcc_assert, rtx_test::HAVE_NUM_CLOBBERS, i, i2, merge_patterns(), transition::next, merge_pattern_info::num_results, merge_pattern_info::num_statements, merge_state_info::num_transitions, merge_pattern_info::num_users, merge_pattern_info::params, merge_pattern_transition::params, merge_state_result::pattern, pattern_c_test_p, pattern_def_states, pattern_have_num_clobbers_p, pattern_use_states, merge_state_result::prev, merge_state_info::prev_same_test, prune_invalid_results(), merge_state_info::res, merge_state_result::root, merge_state_info::s, sinfo::s, same_pattern_p(), list_head< T >::singleton(), merge_state_info::to_states, merge_pattern_info::transitions, update_parameters(), use_pattern(), useful_pattern_p(), and valid_result_p().
Referenced by main().
|
static |
Sort two subroutine_candidates so that the one with the largest number of statements comes last.
Referenced by find_subroutines().
|
static |
Return true if D is a call to a pattern routine and if there is some X such that the transition for pattern result N goes to a successful return with code X+N. When returning true, set *BASE_OUT to this X and *COUNT_OUT to the number of return values. (We know that every PATTERN decision has a transition for every successful return.)
References rtx_test::ACCEPT, rtx_test::acceptance, acceptance_type::code, count, list_head< T >::first, acceptance_type::full, rtx_test::kind, transition::next, rtx_test::PATTERN, list_head< T >::singleton(), decision::test, acceptance_type::u, and rtx_test::u.
Referenced by print_decision().
|
static |
Return true if TEST doesn't test an rtx or if the rtx it tests is already available in state OS.
References position::id, output_state::id_to_var, rtx_test::pos, rtx_test::pos_operand, and output_state::seen_vars.
Referenced by print_decision().
parameter::type_enum transition_parameter_type | ( | rtx_test::kind_enum | kind | ) |
Return the type of value that can be used to parameterize test KIND, or parameter::UNSET if none.
References rtx_test::ACCEPT, rtx_test::C_TEST, parameter::CODE, rtx_test::CODE, rtx_test::DUPLICATE, gcc_unreachable, rtx_test::HAVE_NUM_CLOBBERS, parameter::INT, rtx_test::INT_FIELD, parameter::MODE, rtx_test::MODE, rtx_test::PATTERN, rtx_test::PEEP2_COUNT, rtx_test::PREDICATE, rtx_test::REGNO_FIELD, rtx_test::SAVED_CONST_INT, rtx_test::SET_OP, rtx_test::SUBREG_FIELD, parameter::UINT, parameter::UNSET, rtx_test::VECLEN, rtx_test::VECLEN_GE, parameter::WIDE_INT, and rtx_test::WIDE_INT_FIELD.
Referenced by merge_patterns(), and print_label_value().
Update TO for any parameters that have been added to FROM since TO was last set. The extra parameters in FROM will be constants or instructions to duplicate earlier parameters.
References i.
Referenced by merge_patterns(), split_out_patterns(), and use_pattern().
|
static |
We have decided to replace SINFO's state with a call to a pattern routine. Make the change, creating a definition of the pattern routine if it doesn't have one already.
References init_pattern_use(), merge_pattern_info::params, merge_state_result::params, merge_state_result::pattern, populate_pattern_use(), list_head< T >::push_back(), list_head< T >::release(), sinfo::s, and update_parameters().
Referenced by split_out_patterns().
|
static |
True if PAT would be useful as a subroutine.
References MIN_COMBINE_COST, and merge_pattern_info::num_statements.
Referenced by same_pattern_p(), and split_out_patterns().
|
static |
PAT was previously matched against SINFO based on tentative matches for the target states of SINFO's state. Return true if the match still holds; that is, if the target states of SINFO's state still match the corresponding transitions of PAT.
References merge_state_result::pattern, and merge_pattern_info::transitions.
Referenced by prune_invalid_results(), and split_out_patterns().
|
static |
Check for various errors in PATTERN, which is part of INFO. SET is nonnull for a destination, and is the complete set pattern. SET_CODE is '=' for normal sets, and '+' within a context that requires in-out constraints.
References pred_data::allows_non_const, pred_data::allows_non_lvalue, CONST_INT_P, CONST_WIDE_INT_P, constraints, constraints_supported_in_insn_p(), md_rtx_info::def, error_at(), find_matching_operand(), find_operand(), gcc_unreachable, get_c_test(), GET_CODE, GET_MODE, GET_MODE_INNER, GET_MODE_NAME, GET_MODE_NUNITS(), GET_RTX_FORMAT, GET_RTX_LENGTH, GET_RTX_NAME, i, md_rtx_info::loc, lookup_predicate(), message_at(), NULL, NULL_RTX, RTX_CODE, SET, SET_DEST, SET_SRC, pred_data::special, special_predicate_operand_p(), UINTVAL, validate_pattern(), VECTOR_MODE_P, XEXP, XINT, XSTR, XVECEXP, and XVECLEN.
Referenced by main(), and validate_pattern().
|
static |
Begin the output file.
Referenced by optimize_subroutine_group().
Referenced by optimize_subroutine_group().
Whether to require each parameter passed to a pattern routine to be unique. Disabling this check for example allows unary operators with matching modes (like NEG) and unary operators with mismatched modes (like ZERO_EXTEND) to be matched by a single pattern. However, we then often have cases where the same value is passed too many times.
Referenced by add_parameter(), and set_parameter().
FILE* header = NULL |
Referenced by base_pool_allocator< TBlockAllocator >::allocate(), bb_loop_header_p(), do_rpo_vn_1(), phi_analyzer::dump(), dump_memory_report(), duplicate_loop_body_to_header_edge(), find_loop_guard(), flow_loop_nodes_find(), flow_loops_find(), handle_arg(), inline_read_section(), input_cgraph_opt_section(), ipa_odr_read_section(), ipa_prop_read_section(), lower_rec_input_clauses(), lto_create_simple_input_block(), lto_destroy_simple_output_block(), lto_free_section_data(), lto_get_section_data(), lto_input_mode_table(), lto_input_toplevel_asms(), lto_output_toplevel_asms(), lto_read_body_or_constructor(), lto_write_mode_table(), main(), print_subroutine_group(), produce_asm_for_decls(), produce_symbol_asm(), read_replacements_section(), ipa_icf::sem_item_optimizer::read_section(), base_pool_allocator< TBlockAllocator >::remove(), rev_post_order_and_mark_dfs_back_seme(), rotate_loop(), should_duplicate_loop_header_p(), fwd_jt_path_registry::thread_through_loop_header(), transform_to_exit_first_loop_alt(), and vect_schedule_slp_node().
char header_name[255] |
Referenced by handle_arg(), and main().
Whether to add comments for optional tests that we decided to keep. Can be useful when debugging the generator itself but is noise when debugging the generated code.
Referenced by print_decision().
|
static |
The maximum (approximate) depth of block nesting that an individual routine or subroutine should have. This limit is about keeping the output readable rather than reducing compile time.
Referenced by find_subroutines().
|
static |
The number of pseudo-statements a state can have before we consider splitting out substates into subroutines. This limit is about avoiding compile-time problems with very big functions (and also about keeping functions within --param optimization limits, etc.).
Referenced by find_subroutines().
|
static |
The maximum number of arguments that a pattern routine can have. The idea is to prevent one pattern getting a ridiculous number of arguments when it would be more beneficial to have a separate pattern routine instead.
Referenced by add_parameter().
Debugging variables to control which optimizations are performed. Note that disabling merge_states_p leads to very large output.
Referenced by match_pattern().
|
static |
The minimum number of pseudo-statements that can be used in a pattern routine.
Referenced by useful_pattern_p().
|
static |
The minimum number of pseudo-statements that a state must have before we split it out into a subroutine.
Referenced by find_subroutines().
static int num_operands |
The maximum operand number plus one.
Referenced by gen_proto(), match_pattern_2(), and optimize_subroutine_group().
|
static |
The number of positions created. Also one higher than the maximum position id.
Referenced by main(), next_position(), optimize_subroutine_group(), and print_subroutine_start().
auto_vec<FILE *, 10> output_files |
The list of output files.
Process source files and output type information. Copyright (C) 2002-2025 Free Software Foundation, Inc. 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/>.
Data types, macros, etc. used only in this file.
The list of output files.
Whether pattern routines should be allowed to test .md file C conditions. This requires passing insn around as a parameter, in case the C condition refers to it. In practice this tends to lead to bigger object files.
Referenced by split_out_patterns().
|
static |
The number of states used while defining pattern routines.
Referenced by populate_pattern_routine(), and split_out_patterns().
Whether pattern routines should be allowed to test whether pnum_clobbers is null. This requires passing pnum_clobbers around as a parameter.
Referenced by split_out_patterns().
|
static |
The number of states that were removed by calling pattern routines.
Referenced by populate_pattern_use(), and split_out_patterns().
|
static |
All defined patterns.
A list of all POS_PEEP2_INSNs. The entry for insn 0 is the root position, since we are given that instruction's pattern as x0.
Referenced by match_pattern_1().
Whether pattern routines should calculate positions relative to their rtx parameter rather than use absolute positions. This e.g. allows a pattern routine to be shared between a plain SET and a PARALLEL that includes a SET. In principle it sounds like this should be useful, especially for recog_for_combine, where the plain SET form is generated automatically from a PARALLEL of a single SET and some CLOBBERs. In practice it doesn't seem to help much and leads to slightly bigger object files.
Referenced by test_pattern_hasher::equal(), test_pattern_hasher::hash(), and merge_relative_positions().
|
static |
The root position (x0).
Referenced by match_pattern_1(), optimize_subroutine_group(), and print_subroutine().
Referenced by optimize_subroutine_group().
const unsigned char TESTED_CODE = 1 |
Indicates that we have tested GET_CODE (X) for a particular rtx X.
Referenced by cse_tests(), and safe_to_hoist_p().
const unsigned char TESTED_VECLEN = 2 |
Indicates that we have tested XVECLEN (X, 0) for a particular rtx X.
Referenced by cse_tests(), and safe_to_hoist_p().
Referenced by optimize_subroutine_group().
Referenced by print_subroutine_group().