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 "obstack.h"
#include "read-md.h"
#include "gensupport.h"
Data Structures | |
class | constraint_data |
Macros | |
#define | NO_MODE_TEST(EXP) |
#define | FOR_ALL_CONSTRAINTS(iter_) |
Functions | |
static bool | validate_exp (rtx exp, const char *name, file_location loc) |
static void | process_define_predicate (md_rtx_info *info) |
static void | write_predicate_subfunction (struct pred_data *p) |
static bool | needs_variable (rtx exp, const char *var) |
static void | mark_mode_tests (rtx exp) |
static bool | generate_switch_p (rtx exp) |
static void | add_mode_tests (struct pred_data *p) |
static void | write_extract_subexp (const char *path) |
static void | write_match_code (const char *path, const char *codes) |
static void | write_predicate_expr (rtx exp) |
static void | write_match_code_switch (rtx exp) |
static void | write_predicate_stmts (rtx exp) |
static void | write_one_predicate_function (struct pred_data *p) |
static const char * | mangle (const char *name) |
static void | add_constraint (const char *name, const char *regclass, rtx exp, bool is_memory, bool is_special_memory, bool is_relaxed_memory, bool is_address, file_location loc, const char *filter=nullptr) |
static void | process_define_constraint (md_rtx_info *info) |
static void | process_define_register_constraint (md_rtx_info *info) |
static void | choose_enum_order (void) |
static void | write_enum_constraint_num (void) |
static void | write_lookup_constraint_1 (void) |
static void | write_lookup_constraint_array (void) |
static void | write_insn_constraint_len (void) |
static void | write_reg_class_for_constraint_1 (void) |
static void | write_tm_constrs_h (void) |
static void | write_constraint_satisfied_p_array (void) |
static void | write_insn_const_int_ok_for_constraint (void) |
static void | write_init_reg_class_start_regs () |
static void | write_range_function (const char *name, unsigned int start, unsigned int end) |
static void | write_allows_reg_mem_function (void) |
static void | print_type_tree (const vec< std::pair< unsigned int, const char * > > &vec, unsigned int start, unsigned int end, const char *fallback, unsigned int indent) |
static void | write_get_register_filter () |
static void | write_get_register_filter_id () |
static void | write_tm_preds_h (void) |
static void | write_insn_preds_c (void) |
static bool | parse_option (const char *opt) |
int | main (int argc, const char **argv) |
#define FOR_ALL_CONSTRAINTS | ( | iter_ | ) |
#define NO_MODE_TEST | ( | EXP | ) |
Given an RTL expression EXP, find all subexpressions which we may assume to perform mode tests. Normal MATCH_OPERAND does; MATCH_CODE doesn't as such (although certain codes always have VOIDmode); and we have to assume that MATCH_TEST does not. These combine in almost-boolean fashion - the only exception is that (not X) must be assumed not to perform a mode test, whether or not X does. The mark is the RTL /v flag, which is true for subexpressions which do *not* perform mode tests.
Referenced by add_mode_tests(), and mark_mode_tests().
|
static |
Add one constraint, of any sort, to the tables. NAME is its name; REGCLASS is the register class, if any; EXP is the expression to test, if any; IS_MEMORY, IS_SPECIAL_MEMORY, IS_RELAXED_MEMORY and IS_ADDRESS indicate memory, special memory, and address constraints, respectively; LOC is the .md file location; FILTER is the filter condition for a register constraint, or null if none. Not all combinations of arguments are valid; most importantly, REGCLASS is mutually exclusive with EXP, and IS_MEMORY/IS_SPECIAL_MEMORY/IS_RELAXED_MEMORY/IS_ADDRESS are only meaningful for constraints with EXP. This function enforces all syntactic and semantic rules about what constraints can be defined.
References constraint_data::c_name, compute_test_codes(), const_dbl_constraints, const_int_constraints, constraint_max_namelen, constraints_by_letter_table, error_at(), constraint_data::exp, exp(), constraint_data::filter, general_mem, generic_constraint_letters, GET_CODE, GET_RTX_NAME, have_address_constraints, have_const_int_constraints, have_extra_constraints, have_memory_constraints, have_register_constraints, have_relaxed_memory_constraints, have_special_memory_constraints, constraint_data::is_address, constraint_data::is_const_dbl, constraint_data::is_const_int, constraint_data::is_extra, constraint_data::is_memory, constraint_data::is_register, constraint_data::is_relaxed_memory, constraint_data::is_special_memory, last_constraint_ptr, constraint_data::loc, mangle(), MAX, constraint_data::maybe_allows_mem, constraint_data::maybe_allows_reg, message_at(), constraint_data::name, constraint_data::namelen, constraint_data::next_textual, constraint_data::next_this_letter, num_constraints, NUM_RTX_CODE, constraint_data::regclass, regclass(), rtl_obstack, validate_exp(), XEXP, and XSTR.
Referenced by process_define_constraint(), and process_define_register_constraint().
|
static |
Given a predicate, work out where in its RTL expression to add tests for proper modes. Special predicates do not get any such tests. We try to avoid adding tests when we don't have to; in particular, other normal predicates can be counted on to do it for us.
References pred_data::codes, pred_data::exp, gcc_assert, generate_switch_p(), GET_CODE, i, mark_mode_tests(), NO_MODE_TEST, NUM_RTX_CODE, rtx_alloc(), pred_data::special, TARGET_SUPPORTS_WIDE_INT, XEXP, and XSTR.
Referenced by write_one_predicate_function().
|
static |
Put the constraints into enum order. We want to keep constraints of the same type together so that query functions can be simple range checks.
References address_end, address_start, const_int_end, const_int_start, enum_order, FOR_ALL_CONSTRAINTS, gcc_assert, constraint_data::is_address, constraint_data::is_const_int, constraint_data::is_memory, constraint_data::is_register, constraint_data::is_relaxed_memory, constraint_data::is_special_memory, constraint_data::maybe_allows_mem, maybe_allows_mem_end, maybe_allows_mem_start, maybe_allows_none_end, maybe_allows_none_start, constraint_data::maybe_allows_reg, maybe_allows_reg_end, maybe_allows_reg_start, memory_end, memory_start, num_constraints, register_end, register_start, relaxed_memory_end, relaxed_memory_start, satisfied_start, special_memory_end, and special_memory_start.
Referenced by main().
Determine whether the expression EXP is a MATCH_CODE that should be written as a switch statement.
References exp(), GET_CODE, and XSTR.
Referenced by add_mode_tests(), and write_predicate_stmts().
int main | ( | int | argc, |
const char ** | argv ) |
Master control.
References choose_enum_order(), md_rtx_info::def, fatal(), FATAL_EXIT_CODE, gen_constrs, gen_header, GET_CODE, have_error, init_rtx_reader_args_cb(), parse_option(), process_define_constraint(), process_define_predicate(), process_define_register_constraint(), progname, read_md_rtx(), SUCCESS_EXIT_CODE, write_insn_preds_c(), write_tm_constrs_h(), and write_tm_preds_h().
|
static |
Convert NAME, which contains angle brackets and/or underscores, to a string that can be used as part of a C identifier. The string comes from the rtl_obstack.
References constraint_data::name, and rtl_obstack.
Referenced by add_constraint().
|
static |
References error(), exp(), gcc_unreachable, GET_CODE, GET_MODE, lookup_predicate(), mark_mode_tests(), NO_MODE_TEST, pred_data::special, XEXP, and XSTR.
Referenced by add_mode_tests(), and mark_mode_tests().
Given a predicate expression EXP, from form NAME, determine whether it refers to the variable given as VAR.
References exp(), gcc_unreachable, GET_CODE, GET_MODE, needs_variable(), XEXP, and XSTR.
Referenced by needs_variable(), and write_tm_constrs_h().
|
static |
References gen_constrs, and gen_header.
Referenced by main().
|
static |
VEC is a list of key/value pairs, with the keys being lower bounds of a range. Output a decision tree that handles the keys covered by [VEC[START], VEC[END]), returning FALLBACK for keys lower then VEC[START]'s. INDENT is the number of spaces to indent the code.
References constraint_data::c_name, end(), enum_order, and print_type_tree().
Referenced by print_type_tree(), and write_tm_preds_h().
|
static |
Process a DEFINE_CONSTRAINT, DEFINE_MEMORY_CONSTRAINT, DEFINE_SPECIAL_MEMORY_CONSTRAINT, DEFINE_RELAXED_MEMORY_CONSTRAINT, or DEFINE_ADDRESS_CONSTRAINT expression, C.
References add_constraint(), md_rtx_info::def, GET_CODE, md_rtx_info::loc, XEXP, and XSTR.
Referenced by main().
|
static |
Predicates are defined with (define_predicate) or (define_special_predicate) expressions in the machine description.
References md_rtx_info::def, md_rtx_info::loc, validate_exp(), XEXP, and XSTR.
Referenced by main().
|
static |
Process a DEFINE_REGISTER_CONSTRAINT expression, C.
References add_constraint(), md_rtx_info::def, md_rtx_info::loc, and XSTR.
Referenced by main().
|
static |
Given a predicate expression EXP, from form NAME at location LOC, verify that it does not contain any RTL constructs which are not valid in predicate definitions. Returns true if EXP is INvalid; issues error messages, caller need not.
References error_at(), exp(), gcc_fallthrough, GET_CODE, GET_RTX_NAME, message_at(), validate_exp(), XEXP, and XSTR.
Referenced by add_constraint(), process_define_predicate(), and validate_exp().
|
static |
Write a definition for insn_extra_constraint_allows_reg_mem function.
References constraint_data::c_name, enum_order, maybe_allows_mem_end, maybe_allows_mem_start, maybe_allows_none_end, maybe_allows_none_start, maybe_allows_reg_end, and maybe_allows_reg_start.
Referenced by write_tm_preds_h().
|
static |
Write out the wrapper function, constraint_satisfied_p, that maps a CONSTRAINT_xxx constant to one of the predicate functions generated above.
References constraint_data::c_name, enum_order, i, num_constraints, and satisfied_start.
Referenced by write_insn_preds_c().
|
static |
Write out an enumeration with one entry per machine-specific constraint.
References constraint_data::c_name, enum_order, i, and num_constraints.
Referenced by write_tm_preds_h().
|
static |
PATH is a string describing a path from the root of an RTL expression to an inner subexpression to be tested. Output code which computes the subexpression from the variable holding the root of the expression.
References gcc_unreachable, and i.
Referenced by write_match_code(), and write_match_code_switch().
|
static |
Print the get_register_filter function, which returns a pointer to the start register filter for a given constraint, or null if none.
References constraint_data::c_name, constraint_data::filter, FOR_ALL_CONSTRAINTS, get_register_filter_id(), constraint_data::is_register, and register_filters.
Referenced by write_tm_preds_h().
|
static |
Print the get_register_filter_id function, which returns the index of the given constraint's register filter in this_target_constraints->register_filters, or -1 if none.
References constraint_data::c_name, constraint_data::filter, FOR_ALL_CONSTRAINTS, get_register_filter_id(), constraint_data::is_register, and register_filters.
Referenced by write_tm_preds_h().
|
static |
Print the init_reg_class_start_regs function, which initializes this_target_constraints->register_filters from the C conditions in the define_register_constraints.
References i, md_reader::print_c_condition(), register_filters, and rtx_reader_ptr.
Referenced by write_insn_preds_c().
|
static |
Write out the function which computes whether a given value matches a given CONST_INT constraint. This doesn't just forward to constraint_satisfied_p because caller passes the INTVAL, not the RTX.
References constraint_data::c_name, constraint_data::exp, FOR_ALL_CONSTRAINTS, constraint_data::is_const_int, write_predicate_expr(), and XEXP.
Referenced by write_insn_preds_c().
|
static |
Write out a function which looks at a string and determines what the constraint name length is.
References constraints_by_letter_table, error(), fmt_size_t, HOST_SIZE_T_PRINT_UNSIGNED, i, constraint_data::namelen, and constraint_data::next_this_letter.
Referenced by write_tm_preds_h().
|
static |
Write insn-preds.cc. N.B. the list of headers to include was copied from genrecog; it may not be ideal. FUTURE: Write #line markers referring back to the machine description. (Can't practically do this now since we don't know the line number of the C block - just the line number of the enclosing expression.)
References constraint_max_namelen, FOR_ALL_PREDICATES, md_reader::get_top_level_filename(), have_const_int_constraints, have_register_constraints, md_reader_ptr, progname, write_constraint_satisfied_p_array(), write_init_reg_class_start_regs(), write_insn_const_int_ok_for_constraint(), write_lookup_constraint_1(), write_lookup_constraint_array(), write_one_predicate_function(), and write_reg_class_for_constraint_1().
Referenced by main().
|
static |
Write out a function which looks at a string and determines what constraint name, if any, it begins with.
References constraint_data::c_name, constraints_by_letter_table, fmt_size_t, HOST_SIZE_T_PRINT_UNSIGNED, i, constraint_data::name, constraint_data::namelen, and constraint_data::next_this_letter.
Referenced by write_insn_preds_c().
|
static |
Write out an array that maps single-letter characters to their constraints (if that fits in a character) or 255 if lookup_constraint_1 must be called.
References constraint_data::c_name, constraints_by_letter_table, i, and constraint_data::namelen.
Referenced by write_insn_preds_c().
|
static |
CODES is a list of RTX codes. Write out an expression which determines whether the operand has one of those codes.
References pred_data::codes, scan_comma_elt(), and write_extract_subexp().
Referenced by write_predicate_expr().
|
static |
Write the MATCH_CODE expression EXP as a switch statement.
References pred_data::codes, exp(), scan_comma_elt(), write_extract_subexp(), and XSTR.
Referenced by write_predicate_stmts().
|
static |
Given a predicate, write out a complete C function to compute it.
References add_mode_tests(), pred_data::exp, pred_data::name, write_predicate_stmts(), and write_predicate_subfunction().
Referenced by write_insn_preds_c().
|
static |
EXP is an RTL (sub)expression for a predicate. Recursively descend the expression and write out an equivalent C expression.
References exp(), gcc_unreachable, GET_CODE, GET_MODE, mode_name, md_reader::print_c_condition(), rtx_reader_ptr, write_match_code(), write_predicate_expr(), XEXP, and XSTR.
Referenced by write_insn_const_int_ok_for_constraint(), write_predicate_expr(), and write_predicate_stmts().
|
static |
Given a predicate expression EXP, write out a sequence of stmts to evaluate it. This is similar to write_predicate_expr but can generate efficient switch statements.
References exp(), generate_switch_p(), GET_CODE, write_match_code_switch(), write_predicate_expr(), and XEXP.
Referenced by write_one_predicate_function(), and write_tm_constrs_h().
|
static |
Given a predicate, if it has an embedded C block, write the block out as a static inline subroutine, and augment the RTL test with a match_test that calls that subroutine. For instance, (define_predicate "basereg_operand" (match_operand 0 "register_operand") { if (GET_CODE (op) == SUBREG) op = SUBREG_REG (op); return REG_POINTER (op); }) becomes static inline bool basereg_operand_1(rtx op, machine_mode mode) { if (GET_CODE (op) == SUBREG) op = SUBREG_REG (op); return REG_POINTER (op); } (define_predicate "basereg_operand" (and (match_operand 0 "register_operand") (match_test "basereg_operand_1 (op, mode)"))) The only wart is that there's no way to insist on a { } string in an RTL template, so we have to handle "" strings.
References pred_data::c_block, pred_data::exp, pred_data::name, md_reader::print_md_ptr_loc(), rtl_obstack, rtx_alloc(), rtx_reader_ptr, XEXP, and XSTR.
Referenced by write_one_predicate_function().
|
static |
Write a definition for a function NAME that returns true if a given constraint_num is in the range [START, END).
References constraint_data::c_name, end(), enum_order, and constraint_data::name.
Referenced by write_tm_preds_h().
|
static |
Write out the function which computes the register class corresponding to a register constraint.
References constraint_data::c_name, FOR_ALL_CONSTRAINTS, constraint_data::is_register, and constraint_data::regclass.
Referenced by write_insn_preds_c().
|
static |
Write out the functions which compute whether a given value matches a given non-register constraint.
References constraint_data::c_name, error(), constraint_data::exp, FOR_ALL_CONSTRAINTS, md_reader::get_top_level_filename(), constraint_data::is_register, md_reader_ptr, needs_variable(), progname, and write_predicate_stmts().
Referenced by main().
|
static |
Write tm-preds.h. Unfortunately, it is impossible to forward-declare an enumeration in portable C, so we have to condition all these prototypes on HAVE_MACHINE_MODES.
References address_end, address_start, const_int_end, const_int_start, constraint_max_namelen, enum_order, FOR_ALL_PREDICATES, md_reader::get_top_level_filename(), have_const_int_constraints, have_register_constraints, MAX, md_reader_ptr, memory_end, memory_start, pred_data::name, num_constraints, print_type_tree(), progname, register_end, register_filters, register_start, relaxed_memory_end, relaxed_memory_start, satisfied_start, special_memory_end, special_memory_start, write_allows_reg_mem_function(), write_enum_constraint_num(), write_get_register_filter(), write_get_register_filter_id(), write_insn_constraint_len(), and write_range_function().
Referenced by main().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
Machine-independent code expects that constraints with these (initial) letters will allow only (a subset of all) CONST_DOUBLEs.
Referenced by add_constraint().
|
static |
Machine-independent code expects that constraints with these (initial) letters will allow only (a subset of all) CONST_INTs.
Referenced by add_constraint().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
Summary data used to decide whether to output various functions and macro definitions.
Referenced by add_constraint(), write_insn_preds_c(), and write_tm_preds_h().
|
static |
Overview of all constraints beginning with a given letter.
Referenced by add_constraint(), write_insn_constraint_len(), write_lookup_constraint_1(), and write_lookup_constraint_array().
|
static |
|
static |
For looking up all the constraints in the order that they appeared in the machine description.
|
static |
Referenced by main(), and parse_option().
|
static |
Argument parsing.
Referenced by main(), main(), and parse_option().
|
static |
Generate from machine description: - prototype declarations for operand predicates (tm-preds.h) - function definitions of operand predicates, if defined new-style (insn-preds.cc) Copyright (C) 2001-2024 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/>.
Referenced by add_constraint().
|
static |
Contraint letters that have a special meaning and that cannot be used in define*_constraints.
Referenced by add_constraint().
|
static |
Referenced by add_constraint().
|
static |
Referenced by add_constraint(), write_insn_preds_c(), and write_tm_preds_h().
|
static |
Referenced by add_constraint().
|
static |
Referenced by add_constraint().
|
static |
Referenced by add_constraint(), write_insn_preds_c(), and write_tm_preds_h().
|
static |
Referenced by add_constraint().
|
static |
Referenced by add_constraint().
|
static |
Referenced by add_constraint().
|
static |
Referenced by choose_enum_order(), and write_allows_reg_mem_function().
|
static |
Referenced by choose_enum_order(), and write_allows_reg_mem_function().
|
static |
Referenced by choose_enum_order(), and write_allows_reg_mem_function().
|
static |
Referenced by choose_enum_order(), and write_allows_reg_mem_function().
|
static |
Referenced by choose_enum_order(), and write_allows_reg_mem_function().
|
static |
Referenced by choose_enum_order(), and write_allows_reg_mem_function().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
Referenced by choose_enum_order(), write_constraint_satisfied_p_array(), and write_tm_preds_h().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().
|
static |
Referenced by choose_enum_order(), and write_tm_preds_h().