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 "hash-table.h"
Data Structures | |
struct | operand_data |
class | data |
class | constraint_data |
struct | operand_data_hasher |
Macros | |
#define | MAX_MAX_OPERANDS 40 |
#define | INSN_OUTPUT_FORMAT_NONE 0 /* abort @endverbatim */ |
#define | INSN_OUTPUT_FORMAT_SINGLE 1 /* const char * @endverbatim */ |
#define | INSN_OUTPUT_FORMAT_MULTI 2 /* const char * const * @endverbatim */ |
#define | INSN_OUTPUT_FORMAT_FUNCTION 3 /* const char * (*)(...) @endverbatim */ |
Functions | |
static int | n_occurrences (int, const char *) |
static const char * | strip_whitespace (const char *) |
static void | output_prologue (void) |
static void | output_operand_data (void) |
static void | output_insn_data (void) |
static void | output_get_insn_name (void) |
static void | scan_operands (class data *, rtx, int, int) |
static int | compare_operands (const struct operand_data *, const struct operand_data *) |
static void | place_operands (class data *) |
static void | process_template (class data *, const char *) |
static void | validate_insn_alternatives (class data *) |
static void | validate_insn_operands (class data *) |
static int | mdep_constraint_len (const char *, file_location, int) |
static void | note_constraint (md_rtx_info *) |
static void | validate_optab_operands (class data *d) |
static void | gen_insn (md_rtx_info *info) |
static void | gen_peephole (md_rtx_info *info) |
static void | gen_expand (md_rtx_info *info) |
static void | init_insn_for_nothing (void) |
int | main (int, const char **) |
Variables | |
static char | general_mem [] = { TARGET_MEM_CONSTRAINT, 0 } |
static int | next_operand_number = 1 |
static struct operand_data | null_operand |
static struct operand_data * | odata = &null_operand |
static struct operand_data ** | odata_end = &null_operand.next |
static class data * | idata |
static class data ** | idata_end |
static const char | indep_constraints [] = ",=+%*?!^$#&g" |
static class constraint_data * | constraints_by_letter_table [1<< CHAR_BIT] |
static hash_table< operand_data_hasher > * | operand_datas |
#define INSN_OUTPUT_FORMAT_FUNCTION 3 /* const char * (*)(...) @endverbatim */ |
Referenced by get_insn_template(), output_insn_data(), and process_template().
#define INSN_OUTPUT_FORMAT_MULTI 2 /* const char * const * @endverbatim */ |
Referenced by get_insn_template(), output_insn_data(), and process_template().
#define INSN_OUTPUT_FORMAT_NONE 0 /* abort @endverbatim */ |
Must match the constants in recog.h.
Referenced by gen_expand(), and output_insn_data().
#define INSN_OUTPUT_FORMAT_SINGLE 1 /* const char * @endverbatim */ |
Referenced by get_insn_template(), output_insn_data(), and process_template().
#define MAX_MAX_OPERANDS 40 |
Generate code from to output assembler insns as recognized from rtl. Copyright (C) 1987-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/>.
This program reads the machine description for the compiler target machine and produces a file containing these things: 1. An array of `struct insn_data_d', which is indexed by insn code number, which contains: a. `name' is the name for that pattern. Nameless patterns are given a name. b. `output' hold either the output template, an array of output templates, or an output function. c. `genfun' is the function to generate a body for that pattern, given operands as arguments. d. `n_operands' is the number of distinct operands in the pattern for that insn, e. `n_dups' is the number of match_dup's that appear in the insn's pattern. This says how many elements of `recog_data.dup_loc' are significant after an insn has been recognized. f. `n_alternatives' is the number of alternatives in the constraints of each pattern. g. `output_format' tells what type of thing `output' is. h. `operand' is the base of an array of operand data for the insn. 2. An array of `struct insn_operand data', used by `operand' above. a. `predicate', an int-valued function, is the match_operand predicate for this operand. b. `constraint' is the constraint for this operand. c. `address_p' indicates that the operand appears within ADDRESS rtx's. d. `mode' is the machine mode that that operand is supposed to have. e. `strict_low', is nonzero for operands contained in a STRICT_LOW_PART. f. `eliminable', is nonzero for operands that are matched normally by MATCH_OPERAND; it is zero for operands that should not be changed during register elimination such as MATCH_OPERATORs. g. `allows_mem', is true for operands that accept MEM rtxes. The code number of an insn is simply its position in the machine description; code numbers are assigned sequentially to entries in the description, starting with code number 0. Thus, the following entry in the machine description (define_insn "clrdf" [(set (match_operand:DF 0 "general_operand" "") (const_int 0))] "" "clrd %0") assuming it is the 25th entry present, would cause insn_data[24].template to be "clrd %0", and insn_data[24].n_operands to be 1.
No instruction can have more operands than this. Sorry for this arbitrary limit, but what machine will have an instruction with this many operands?
Referenced by scan_operands().
|
static |
Compare two operands for content equality.
References operand_data::constraint, d1, operand_data::eliminable, operand_data::mode, operand_data::predicate, and operand_data::strict_low.
Referenced by operand_data_hasher::equal(), and place_operands().
|
static |
Process a define_expand just read. Assign its code number, only for the purposes of `insn_gen_function'.
References data::code_number, md_rtx_info::def, get_pattern_stats(), i, idata_end, md_rtx_info::index, INSN_OUTPUT_FORMAT_NONE, data::loc, md_rtx_info::loc, data::n_dups, data::n_generator_args, data::n_operands, data::name, data::next, data::operand, data::output_format, place_operands(), scan_operands(), data::template_code, validate_insn_alternatives(), validate_optab_operands(), XSTR, XVEC, XVECEXP, and XVECLEN.
Referenced by main().
|
static |
Look at a define_insn just read. Assign its code number. Record on idata the template and the number of arguments. If the insn has a hairy output action, output a function for now.
References data::code_number, compact_syntax, data::compact_syntax_p, md_rtx_info::def, get_pattern_stats(), i, idata_end, md_rtx_info::index, data::loc, md_rtx_info::loc, data::n_dups, data::n_generator_args, data::n_operands, data::name, data::next, data::operand, place_operands(), process_template(), scan_operands(), validate_insn_alternatives(), validate_insn_operands(), validate_optab_operands(), XSTR, XTMPL, XVEC, XVECEXP, and XVECLEN.
Referenced by main().
|
static |
Look at a define_peephole just read. Assign its code number. Record on idata the template and the number of arguments. If the insn has a hairy output action, output it now.
References data::code_number, md_rtx_info::def, get_pattern_stats(), i, idata_end, md_rtx_info::index, md_rtx_info::loc, data::next, place_operands(), process_template(), scan_operands(), validate_insn_alternatives(), XTMPL, XVEC, XVECEXP, and XVECLEN.
Referenced by main().
|
static |
References idata, idata_end, data::loc, data::name, and data::next.
Referenced by main().
|
extern |
References md_rtx_info::def, FATAL_EXIT_CODE, gen_expand(), gen_insn(), gen_peephole(), GET_CODE, have_error, init_insn_for_nothing(), init_rtx_reader_args(), note_constraint(), operand_datas, output_get_insn_name(), output_insn_data(), output_operand_data(), output_prologue(), progname, read_md_rtx(), and SUCCESS_EXIT_CODE.
|
static |
Return the length of the constraint name beginning at position S of an operand constraint string, or issue an error message if there is no such constraint. Does not expect to be called for generic constraints.
References constraints_by_letter_table, error_at(), constraint_data::loc, message_at(), constraint_data::name, constraint_data::namelen, and constraint_data::next_this_letter.
Referenced by validate_insn_alternatives().
|
static |
Return the number of occurrences of character C in string S or -1 if S is the null string.
|
static |
Record just enough information about the constraint in *INFO to allow checking of operand constraint strings above, in validate_insn_alternatives. Does not validate most properties of the constraint itself; does enforce no duplicate names, no overlap with MI constraints, and no prefixes.
References CONST_CAST, constraints_by_letter_table, md_rtx_info::def, error_at(), exp(), general_mem, indep_constraints, constraint_data::loc, md_rtx_info::loc, message_at(), constraint_data::name, constraint_data::namelen, constraint_data::next_this_letter, and XSTR.
Referenced by main().
|
static |
Referenced by main().
|
static |
References data::code_number, file_location::filename, gcc_unreachable, idata, INSN_OUTPUT_FORMAT_FUNCTION, INSN_OUTPUT_FORMAT_MULTI, INSN_OUTPUT_FORMAT_NONE, INSN_OUTPUT_FORMAT_SINGLE, file_location::lineno, data::loc, data::n_alternatives, data::n_dups, data::n_generator_args, data::n_operands, data::name, data::next, data::operand_number, data::output_format, and data::template_code.
Referenced by main().
|
static |
References pred_data::codes, operand_data::constraint, operand_data::eliminable, GET_MODE_NAME, lookup_predicate(), operand_data::mode, operand_data::next, NULL, odata, operand_data::predicate, and operand_data::strict_low.
Referenced by main().
|
static |
Referenced by main().
|
static |
Scan the list of operands we've already committed to output and either find a subsequence that is the same, or allocate a new one at the end.
References compare_operands(), operand_data::eq_next, i, operand_data::index, last, data::n_operands, operand_data::next, next_operand_number, NULL, odata_end, data::operand, operand_datas, and data::operand_number.
Referenced by gen_expand(), gen_insn(), and gen_peephole().
|
static |
Process an assembler template from a define_insn or a define_peephole. It is either the assembler code template, a list of assembler code templates, or C code to generate the assembler code template.
References data::code_number, data::compact_syntax_p, error_at(), fatal_at(), i, INSN_OUTPUT_FORMAT_FUNCTION, INSN_OUTPUT_FORMAT_MULTI, INSN_OUTPUT_FORMAT_SINGLE, data::loc, message_at(), data::n_alternatives, data::output_format, md_reader::print_md_ptr_loc(), rtx_reader_ptr, and data::template_code.
Referenced by gen_insn(), and gen_peephole().
|
static |
Stores the operand data into `d->operand[i]'. THIS_ADDRESS_P is nonzero if the containing rtx was an ADDRESS. THIS_STRICT_LOW is nonzero if the containing rtx was a STRICT_LOW_PART.
References operand_data::address_p, operand_data::constraint, operand_data::eliminable, error_at(), GET_CODE, GET_MODE, GET_RTX_FORMAT, GET_RTX_LENGTH, i, data::loc, MAX_MAX_OPERANDS, operand_data::mode, operand_data::n_alternatives, n_occurrences, NULL, data::operand, operand_data::predicate, scan_operands(), operand_data::seen, operand_data::strict_low, strip_whitespace(), XEXP, XINT, XSTR, XVEC, XVECEXP, and XVECLEN.
Referenced by gen_expand(), gen_insn(), gen_peephole(), and scan_operands().
|
static |
Remove whitespace in `s' by moving up characters until the end. Return a new string.
Referenced by scan_operands().
|
static |
Check insn D for consistency in number of constraint alternatives.
References operand_data::constraint, error_at(), i, indep_constraints, data::loc, mdep_constraint_len(), data::n_alternatives, operand_data::n_alternatives, data::n_operands, data::operand, and which_alternative.
Referenced by gen_expand(), gen_insn(), and gen_peephole().
|
static |
Verify that there are no gaps in operand numbers for INSNs.
References error_at(), i, data::loc, data::n_operands, data::operand, and operand_data::seen.
Referenced by gen_insn().
|
static |
References have_error, data::loc, message_at(), operand_data::mode, data::name, data::operand, and startswith().
Referenced by gen_expand(), and gen_insn().
|
static |
Referenced by mdep_constraint_len(), and note_constraint().
|
static |
Referenced by note_constraint().
|
static |
This variable points to the first link in the insn chain.
Referenced by find_inv_vars_cb(), init_insn_for_nothing(), and output_insn_data().
|
static |
This variable points to the end of the insn chain. This is where everything relevant from the machien description is appended to.
Referenced by gen_expand(), gen_insn(), gen_peephole(), and init_insn_for_nothing().
|
static |
All machine-independent constraint characters (except digits) that are handled outside the define*_constraint mechanism.
Referenced by note_constraint(), and validate_insn_alternatives().
|
static |
This counts all operands used in the md file. The first is null.
Referenced by place_operands().
|
static |
Begin with a null operand at index 0.
|
static |
Referenced by output_operand_data(), and fibonacci_heap< K, V >::replace_key_data().
|
static |
Referenced by place_operands().
|
static |
Hashtable of konwn pattern operands.
Referenced by main(), and place_operands().