GCC Middle and Back End API Reference
gensupport.c File Reference
#include "bconfig.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "obstack.h"
#include "errors.h"
#include "hashtab.h"
#include "read-md.h"
#include "gensupport.h"
Include dependency graph for gensupport.c:

Data Structures

struct  queue_elem
struct  std_pred_table

Macros

#define MAX_OPERANDS   40
#define MNEMONIC_ATTR_NAME   "mnemonic"
#define MNEMONIC_HTAB_SIZE   1024
#define N   0
#define Y   1
#define I   2
#define TRISTATE_AND(a, b)
#define TRISTATE_OR(a, b)
#define TRISTATE_NOT(a)   ((a) == I ? I : !(a))
#define NUM_KNOWN_STD_PREDS   ARRAY_SIZE (std_preds)

Typedefs

typedef const char *(* constraints_handler_t )(const char *, int)

Functions

static struct queue_elemqueue_pattern (rtx, struct queue_elem ***, const char *, int)
static void remove_constraints (rtx)
static void process_rtx (rtx, int)
static int is_predicable (struct queue_elem *)
static void identify_predicable_attribute (void)
static int n_alternatives (const char *)
static void collect_insn_data (rtx, int *, int *)
static rtx alter_predicate_for_insn (rtx, int, int, int)
static const char * alter_test_for_insn (struct queue_elem *, struct queue_elem *)
static char * shift_output_template (char *, const char *, int)
static const char * alter_output_for_insn (struct queue_elem *, struct queue_elem *, int, int)
static void process_one_cond_exec (struct queue_elem *)
static void process_define_cond_exec (void)
static void init_predicate_table (void)
static void record_insn_name (int, const char *)
static bool has_subst_attribute (struct queue_elem *, struct queue_elem *)
static bool subst_pattern_match (rtx, rtx, int)
static int get_alternatives_number (rtx, int *, int)
static const char * alter_output_for_subst_insn (rtx, int)
static void alter_attrs_for_subst_insn (struct queue_elem *, int)
static void process_substs_on_one_elem (struct queue_elem *, struct queue_elem *)
static rtx subst_dup (rtx, int, int)
static void process_define_subst (void)
static const char * duplicate_alternatives (const char *, int)
static const char * duplicate_each_alternative (const char *str, int n_dup)
static rtx alter_constraints (rtx, int, constraints_handler_t)
static rtx adjust_operands_numbers (rtx)
static rtx replace_duplicating_operands_in_pattern (rtx)
rtx gen_rtx_CONST_INT (enum machine_mode ARG_UNUSED(mode), HOST_WIDE_INT arg)
static void compute_predicate_codes ()
static bool valid_predicate_name_p ()
static void process_define_predicate ()
static void remove_from_queue ()
static void add_define_attr ()
static void remove_constraints ()
static void process_rtx ()
static int is_predicable ()
static void change_subst_attribute (struct queue_elem *elem, struct queue_elem *subst_elem, const char *new_value)
static bool has_subst_attribute ()
static bool subst_pattern_match ()
static int n_alternatives ()
static int get_alternatives_number ()
static void collect_insn_data ()
static rtx alter_predicate_for_insn ()
static rtx alter_constraints ()
static rtx modify_attr_enabled_ce ()
static void alter_attrs_for_insn ()
static void alter_attrs_for_subst_insn ()
static char * shift_output_template ()
static const char * duplicate_alternatives ()
static const char * duplicate_each_alternative ()
static const char * alter_output_for_subst_insn ()
static void process_one_cond_exec ()
static void mark_operands_from_match_dup ()
static void mark_operands_used_in_match_dup ()
static int find_first_unused_number_of_operand ()
static void renumerate_operands_in_pattern ()
static rtx adjust_operands_numbers ()
static rtx generate_match_dup ()
static rtx replace_duplicating_operands_in_pattern ()
static rtx subst_dup ()
static void rtx_handle_directive ()
static int htab_eq_string ()
static void add_mnemonic_string ()
static void gen_mnemonic_setattr ()
static int mnemonic_htab_callback ()
static void gen_mnemonic_attr ()
static void check_define_attr_duplicates ()
bool init_rtx_reader_args_cb (int argc, char **argv, bool(*parse_opt)(const char *))
bool init_rtx_reader_args ()
rtx read_md_rtx ()
hashval_t hash_c_test ()
int cmp_c_test ()
int maybe_eval_c_test ()
void add_c_test ()
void traverse_c_tests ()
static hashval_t hash_struct_pred_data ()
static int eq_struct_pred_data ()
struct pred_datalookup_predicate ()
void add_predicate_code ()
void add_predicate ()
const char * get_insn_name ()
static void record_insn_name ()
static void get_pattern_stats_1 ()
void get_pattern_stats ()

Variables

static rtx operand_data [MAX_OPERANDS]
static rtx match_operand_entries_in_pattern [MAX_OPERANDS]
static char used_operands_numbers [MAX_OPERANDS]
int target_flags
int insn_elision = 1
static struct obstack obstack
struct obstackrtl_obstack = &obstack
static int sequence_num
static int predicable_default
static const char * predicable_true
static const char * predicable_false
static const char * subst_true = "yes"
static const char * subst_false = "no"
static htab_t condition_table
static struct queue_elemdefine_attr_queue
static struct queue_elem ** define_attr_tail = &define_attr_queue
static struct queue_elemdefine_pred_queue
static struct queue_elem ** define_pred_tail = &define_pred_queue
static struct queue_elemdefine_insn_queue
static struct queue_elem ** define_insn_tail = &define_insn_queue
static struct queue_elemdefine_cond_exec_queue
static struct queue_elem ** define_cond_exec_tail = &define_cond_exec_queue
static struct queue_elemdefine_subst_queue
static struct queue_elem ** define_subst_tail = &define_subst_queue
static struct queue_elemother_queue
static struct queue_elem ** other_tail = &other_queue
static struct queue_elemdefine_subst_attr_queue
static struct queue_elem ** define_subst_attr_tail = &define_subst_attr_queue
static char did_you_mean_codes [NUM_RTX_CODE]
static htab_t predicate_table
struct pred_datafirst_predicate
static struct pred_data ** last_predicate = &first_predicate
static struct std_pred_table std_preds []
static char ** insn_name_ptr = 0
static int insn_name_ptr_size = 0

Macro Definition Documentation

#define I   2
#define MAX_OPERANDS   40

Support routines for the various generation passes. Copyright (C) 2000-2013 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 subst_pattern_match().

#define MNEMONIC_ATTR_NAME   "mnemonic"

Referenced by gen_mnemonic_setattr().

#define MNEMONIC_HTAB_SIZE   1024

Referenced by gen_mnemonic_setattr().

#define N   0

Predicate handling.

We construct from the machine description a table mapping each predicate to a list of the rtl codes it can possibly match. The function 'maybe_both_true' uses it to deduce that there are no expressions that can be matches by certain pairs of tree nodes. Also, if a predicate can match only one code, we can hardwire that code into the node testing the predicate.

Some predicates are flagged as special. validate_pattern will not warn about modeless match_operand expressions if they have a special predicate. Predicates that allow only constants are also treated as special, for this purpose.

validate_pattern will warn about predicates that allow non-lvalues when they appear in destination operands.

Calculating the set of rtx codes that can possibly be accepted by a predicate expression EXP requires a three-state logic: any given subexpression may definitively accept a code C (Y), definitively reject a code C (N), or may have an indeterminate effect (I). N and I is N; Y or I is Y; Y and I, N or I are both I. Here are full truth tables.

a b a&b a|b Y Y Y Y N Y N Y N N N N I Y I Y I N N I I I I I

We represent Y with 1, N with 0, I with 2. If any code is left in an I state by the complete expression, we must assume that that code can be accepted.

#define NUM_KNOWN_STD_PREDS   ARRAY_SIZE (std_preds)

Referenced by add_c_test().

#define TRISTATE_AND (   a,
 
)
Value:
((a) == I ? ((b) == N ? N : I) : \
(b) == I ? ((a) == N ? N : I) : \
(a) && (b))
#define TRISTATE_NOT (   a)    ((a) == I ? I : !(a))
#define TRISTATE_OR (   a,
 
)
Value:
((a) == I ? ((b) == Y ? Y : I) : \
(b) == I ? ((a) == Y ? Y : I) : \
(a) || (b))
#define Y   1

Typedef Documentation

typedef const char*(* constraints_handler_t)(const char *, int)

Function Documentation

void add_c_test ( )

Record the C test expression EXPR in the condition_table, with value VAL. Duplicates clobber previous entries.

References eq_struct_pred_data(), hash_struct_pred_data(), pred_data::name, std_pred_table::name, NUM_KNOWN_STD_PREDS, pred_data::special, and std_pred_table::special.

static void add_define_attr ( )
static

Build a define_attr for an binary attribute with name NAME and possible values "yes" and "no", and queue it.

References GET_CODE, GET_RTX_FORMAT, GET_RTX_LENGTH, and XSTR.

static void add_mnemonic_string ( )
static

Add mnemonic STR with length LEN to the mnemonic hash table MNEMONIC_HTAB. A trailing zero end character is appendend to STR and a permanent heap copy of STR is created.

Not found; create a permanent copy and add it to the hash table.

Referenced by gen_mnemonic_setattr().

void add_predicate ( )
void add_predicate_code ( )

Record that predicate PRED can accept CODE.

static rtx adjust_operands_numbers ( rtx  )
static
static rtx adjust_operands_numbers ( )
static

If output pattern of define_subst contains MATCH_DUP, then this expression would be replaced with the pattern, matched with MATCH_OPERAND from input pattern. This pattern could contain any number of MATCH_OPERANDs, MATCH_OPERATORs etc., so it's possible that a MATCH_OPERAND from output_pattern (if any) would have the same number, as MATCH_OPERAND from copied pattern. To avoid such indexes overlapping, we assign new indexes to MATCH_OPERANDs, laying in the output pattern outside of MATCH_DUPs.

References GET_CODE, and XINT.

static void alter_attrs_for_insn ( )
static

Alter the attribute vector of INSN, which is a COND_EXEC variant created from a define_insn pattern. We must modify the "predicable" attribute to be named "ce_enabled", and also change any "enabled" attribute that's present so that it takes ce_enabled into account. We rely on the fact that INSN was created with copy_rtx, and modify data in-place.

We already give an error elsewhere.

               We already give an error elsewhere.   
static void alter_attrs_for_subst_insn ( struct queue_elem ,
int   
)
static
static void alter_attrs_for_subst_insn ( )
static

As number of constraints is changed after define_subst, we need to process attributes as well - we need to duplicate them the same way that we duplicated constraints in original pattern ELEM is a queue element, containing our rtl-template, N_DUP - multiplication factor.

static rtx alter_constraints ( rtx  ,
int  ,
constraints_handler_t   
)
static
static rtx alter_constraints ( )
static

Duplicate constraints in PATTERN. If pattern is from original rtl-template, we need to duplicate each alternative - for that we need to use duplicate_each_alternative () as a functor ALTER. If pattern is from output-pattern of define_subst, we need to duplicate constraints in another way - with duplicate_alternatives (). N_DUP is multiplication factor.

References queue_elem::data, join_c_conditions(), and XSTR.

static const char * alter_output_for_insn ( struct queue_elem ce_elem,
struct queue_elem insn_elem,
int  alt,
int  max_op 
)
static

??? Could coordinate with genoutput to not duplicate code here.

   You must take care of the predicate yourself.   
static const char* alter_output_for_subst_insn ( rtx  ,
int   
)
static
static const char* alter_output_for_subst_insn ( )
static

Alter the output of INSN whose pattern was modified by DEFINE_SUBST. We must replicate output strings according to the new number of alternatives ALT in substituted pattern. If ALT equals 1, output has one alternative or defined by C code, then output is returned without any changes.

static rtx alter_predicate_for_insn ( rtx  ,
int  ,
int  ,
int   
)
static
static rtx alter_predicate_for_insn ( )
static

Replicate C as needed to fill out ALT alternatives.

     Fall through.   

References alter_predicate_for_insn(), gcc_unreachable, NULL, XEXP, XVECEXP, and XVECLEN.

static const char * alter_test_for_insn ( struct queue_elem ce_elem,
struct queue_elem insn_elem 
)
static

References XSTR.

static void change_subst_attribute ( struct queue_elem elem,
struct queue_elem subst_elem,
const char *  new_value 
)
static

Find attribute SUBST in ELEM and assign NEW_VALUE to it.

References queue_elem::data, GET_CODE, GET_NUM_ELEM, RTVEC_ELT, SET, SET_DEST, SET_SRC, XSTR, and XVEC.

static void check_define_attr_duplicates ( )
static

Check if there are DEFINE_ATTRs with the same name.

Duplicate.

Referenced by gen_mnemonic_attr().

int cmp_c_test ( )
static void collect_insn_data ( rtx  ,
int *  ,
int *   
)
static
static void collect_insn_data ( )
static

Determine how many alternatives there are in INSN, and how many operands.

Fall through.

         Fall through.   
static void compute_predicate_codes ( )
static

Recursively calculate the set of rtx codes accepted by the predicate expression EXP, writing the result to CODES. LINENO is the line number on which the directive containing EXP appeared.

     a ? b : c  accepts the same codes as (a & b) | (!a & c).   
     MATCH_CODE allows a specified list of codes.  However, if it
     does not apply to the top level of the expression, it does not
     constrain the set of codes for the top level.   
     MATCH_OPERAND disallows the set of codes that the named predicate
     disallows, and is indeterminate for the codes that it does allow.   
     (match_test WHATEVER) is completely indeterminate.   
static const char* duplicate_alternatives ( const char *  ,
int   
)
static
static const char* duplicate_alternatives ( )
static

From string STR "a,b,c" produce "a,b,c,a,b,c,a,b,c", i.e. original string, duplicated N_DUP times.

Global modifier characters mustn't be duplicated: skip if found.

 Copy original constraints N_DUP times.   

References NULL.

static const char* duplicate_each_alternative ( const char *  str,
int  n_dup 
)
static
static const char* duplicate_each_alternative ( )
static

From string STR "a,b,c" produce "a,a,a,b,b,b,c,c,c", i.e. string where each alternative from the original string is duplicated N_DUP times.

Global modifier characters mustn't be duplicated: skip if found.

     Copy a constraint N_DUP times.   
static int eq_struct_pred_data ( )
static

References NULL.

Referenced by add_c_test().

static int find_first_unused_number_of_operand ( )
static

This is subroutine of renumerate_operands_in_pattern. It finds first not-occupied operand-index.

References gcc_assert, NULL, XINT, and XSTR.

Referenced by mark_operands_from_match_dup().

static void gen_mnemonic_attr ( )
static

Generate (set_attr "mnemonic" "..") RTXs and append them to every insn definition in case the back end requests it by defining the mnemonic attribute. The values for the attribute will be extracted from the output patterns of the insn definitions as far as possible.

 Look for the DEFINE_ATTR for `mnemonic'.   
 A (define_attr "mnemonic" "...") indicates that the back-end
 wants a mnemonic attribute to be generated.   
     Check if the insn definition already has
     (set_attr "mnemonic" ...) or (set (attr "mnemonic") ...).   
 Add the user defined values to the hash table.   
 Replace the last ',' with the zero end character.   

References check_define_attr_duplicates(), cmp_c_test(), condition_table, hash_c_test(), have_error, init_predicate_table(), NULL, process_define_cond_exec(), process_define_subst(), read_md_files(), rtl_obstack, rtx_handle_directive(), and sequence_num.

static void gen_mnemonic_setattr ( )
static

Scan INSN for mnemonic strings and add them to the mnemonic hash table in MNEMONIC_HTAB.

The mnemonics cannot be found if they are emitted using C code.

If a mnemonic string contains ';' or a newline the string assumed to consist of more than a single instruction. The attribute value will then be set to the user defined default value.

 Skip patterns which use C code to emit the template.   
             Don't set a value if there are more than one
             instruction in the string.   
 An insn definition might emit an empty string.   

References add_mnemonic_string(), queue_elem::data, define_attr_tail, GET_CODE, have_error, htab_eq_string(), MNEMONIC_ATTR_NAME, mnemonic_htab_callback(), MNEMONIC_HTAB_SIZE, queue_elem::next, NULL, scan_comma_elt(), SET, SET_DEST, string_obstack, XSTR, XVEC, XVECEXP, and XVECLEN.

rtx gen_rtx_CONST_INT ( enum machine_mode   ARG_UNUSEDmode,
HOST_WIDE_INT  arg 
)

Make a version of gen_rtx_CONST_INT so that GEN_INT can be used in the gensupport programs.

static rtx generate_match_dup ( )
static

Generate RTL expression (match_dup OPNO)

static int get_alternatives_number ( rtx  ,
int *  ,
int   
)
static
static int get_alternatives_number ( )
static

The routine scans rtl PATTERN, find match_operand in it and counts number of alternatives. If PATTERN contains several match_operands with different number of alternatives, error is emitted, and the routine returns 0. If all match_operands in PATTERN have the same number of alternatives, it's stored in N_ALT, and the routine returns 1. Argument LINENO is used in when the error is emitted.

n_alternatives returns 1 if constraint string is empty - here we fix it up.

const char* get_insn_name ( )

Referenced by nodes_identical_1().

void get_pattern_stats ( )

Make STATS describe the operands that appear in instruction pattern PATTERN.

static void get_pattern_stats_1 ( )
static

Make STATS describe the operands that appear in rtx X.

static bool has_subst_attribute ( struct queue_elem ,
struct queue_elem  
)
static
static bool has_subst_attribute ( )
static

Return true if ELEM has the attribute with the name of DEFINE_SUBST represented by SUBST_ELEM and this attribute has value SUBST_TRUE. DEFINE_SUBST isn't applied to patterns without such attribute. In other words, we suppose the default value of the attribute to be 'no' since it is always generated automaticaly in read-rtl.c.

Only (set_attr "subst" "yes/no") and (set (attr "subst" (const_string "yes/no"))) are currently allowed.

hashval_t hash_c_test ( )

Helper functions for insn elision. Compute a hash function of a c_test structure, which is keyed by its ->expr field.

Referenced by gen_mnemonic_attr().

static hashval_t hash_struct_pred_data ( )
static

Referenced by add_c_test().

static int htab_eq_string ( )
static

Comparison function for the mnemonic hash table.

Referenced by gen_mnemonic_setattr().

static void identify_predicable_attribute ( )
static

Examine the attribute "predicable"; discover its boolean values and its default.

Look for the DEFINE_ATTR for `predicable', which must exist.

static void init_predicate_table ( )
static

Initialize the table of predicate definitions, starting with the information we have on generic predicates.

Referenced by gen_mnemonic_attr().

bool init_rtx_reader_args ( )

Programs that don't have their own options can use this entry point instead.

Referenced by main().

bool init_rtx_reader_args_cb ( int  argc,
char **  argv,
bool(*)(const char *)  parse_opt 
)

The entry point for initializing the reader.

 Prepare to read input.   
 Start at 1, to make 0 available for CODE_FOR_nothing.   
 Process define_cond_exec patterns.   
 Process define_subst patterns.   
static int is_predicable ( struct queue_elem )
static
static int is_predicable ( )
static

Return true if attribute PREDICABLE is true for ELEM, which holds a DEFINE_INSN.

    ??? It would be possible to handle this if we really tried.
    It's not easy though, and I'm not going to bother until it
    really proves necessary.   

Find out which value we're looking at. Multiple alternatives means at least one is predicable.

struct pred_data* lookup_predicate ( )
read

Referenced by subst_pattern_match().

static void mark_operands_from_match_dup ( )
static

This is a subroutine of mark_operands_used_in_match_dup. This routine is marks all MATCH_OPERANDs inside PATTERN as occupied.

References find_first_unused_number_of_operand(), gcc_assert, used_operands_numbers, and XINT.

static void mark_operands_used_in_match_dup ( )
static

This is a subroutine of adjust_operands_numbers. It goes through all expressions in PATTERN and when MATCH_DUP is met, all MATCH_OPERANDs inside it is marked as occupied. The process of marking is done by routin mark_operands_from_match_dup.

References renumerate_operands_in_pattern().

int maybe_eval_c_test ( )

Given a string representing a C test expression, look it up in the condition_table and report whether or not its value is known at compile time. Returns a tristate: 1 for known true, 0 for known false, -1 for unknown.

Referenced by gen_insn().

static int mnemonic_htab_callback ( )
static

This function is called for the elements in the mnemonic hashtable and generates a comma separated list of the mnemonics.

Referenced by gen_mnemonic_setattr().

static rtx modify_attr_enabled_ce ( )
static

Modify VAL, which is an attribute expression for the "enabled" attribute, to take "ce_enabled" into account. Return the new expression.

static int n_alternatives ( const char *  )
static
static int n_alternatives ( )
static

Return the number of alternatives in constraint S.

static void process_define_cond_exec ( )
static

If we have any DEFINE_COND_EXEC patterns, expand the DEFINE_INSN patterns appropriately.

References XTMPL.

Referenced by gen_mnemonic_attr().

static void process_define_predicate ( )
static

Process define_predicate directive DESC, which appears on line number LINENO. Compute the set of codes that can be matched, and record this as a known predicate.

static void process_define_subst ( )
static

If we have any DEFINE_SUBST patterns, expand DEFINE_INSN and DEFINE_EXPAND patterns appropriately.

Check if each define_subst has corresponding define_subst_attr.

References string_obstack.

Referenced by gen_mnemonic_attr().

static void process_one_cond_exec ( struct queue_elem )
static
static void process_one_cond_exec ( )
static

Replicate insns as appropriate for the given DEFINE_COND_EXEC.

     Construct a new pattern for the new insn.   
     Put the new pattern on the `other' list so that it
     (a) is not reprocessed by other define_cond_exec patterns
     (b) appears after all normal define_insn patterns.

     ??? B is debatable.  If one has normal insns that match
     cond_exec patterns, they will be preferred over these
     generated patterns.  Whether this matters in practice, or if
     it's a good thing, or whether we should thread these new
     patterns into the define_insn chain just after their generator
     is something we'll have to experiment with.   
     If the original insn came from a define_insn_and_split,
     generate a new split to handle the predicated insn.   
     Predicate the pattern matched by the split.   
     Predicate all of the insns generated by the split.   
     Add the new split to the queue.   
static void process_rtx ( rtx  ,
int   
)
static
static void process_rtx ( )
static

Process a top level rtx in some way, queuing as appropriate.

     Fall through.   
       Create a split with values from the insn_and_split.   
       If the split condition starts with "&&", append it to the
       insn condition to create the new split condition.   
       Fix up the DEFINE_INSN.   
       Queue them.   
static void process_substs_on_one_elem ( struct queue_elem elem,
struct queue_elem queue 
)
static

Try to apply define_substs to the given ELEM. Only define_substs, specified via attributes would be applied. If attribute, requiring define_subst, is set, but no define_subst was applied, ELEM would be deleted.

     Compare original rtl-pattern from define_insn with input
     pattern from define_subst.
     Also, check if numbers of alternatives are the same in all
     match_operands.   
     Check if numbers of alternatives are the same in all
     match_operands in output template of define_subst.   
     Clear array in which we save occupied indexes of operands.   
     Create a pattern, based on the output one from define_subst.   
         Duplicate constraints in substitute-pattern.   
         Substitute match_dup and match_op_dup in the new pattern and
         duplicate constraints.   
         We don't need any constraints in DEFINE_EXPAND.   
     Recalculate condition, joining conditions from original and
     DEFINE_SUBST input patterns.   
     Mark that subst was applied by changing attribute from "yes"
     to "no".   
 If ELEM contains a subst attribute with value "yes", then we
 expected that a subst would be applied, but it wasn't - so,
 we need to remove that elementto avoid duplicating.   
static struct queue_elem * queue_pattern ( rtx  pattern,
struct queue_elem ***  list_tail,
const char *  filename,
int  lineno 
)
staticread

Queue PATTERN on LIST_TAIL. Return the address of the new queue element.

References queue_elem::next, and NULL.

rtx read_md_rtx ( )

The entry point for reading a single rtx from an md file. Return the rtx, or NULL if the md file has been fully processed. Return the line where the rtx was found in LINENO. Return the number of code generating rtx'en read since the start of the md file in SEQNR.

 Read all patterns from a given queue before moving on to the next.   
 Discard insn patterns which we know can never match (because
 their C test is provably always false).  If insn_elision is
 false, our caller needs to see all the patterns.  Note that the
 elided patterns are never counted by the sequence numbering; it
 is the caller's responsibility, when insn_elision is false, not
 to use elided pattern numbers for anything.   
     *seqnr is used here so the name table will match caller's
     idea of insn numbering, whether or not elision is active.   

References condition_table, c_test::expr, and c_test::value.

Referenced by main().

static void record_insn_name ( int  ,
const char *   
)
static
static void record_insn_name ( )
static
static void remove_constraints ( rtx  )
static
static void remove_constraints ( )
static

Recursively remove constraints from an rtx.

static void remove_from_queue ( )
static

Remove element ELEM from QUEUE.

static void renumerate_operands_in_pattern ( )
static

This is subroutine of adjust_operands_numbers. It visits all expressions in PATTERN and assigns not-occupied operand indexes to MATCH_OPERANDs and MATCH_OPERATORs of this PATTERN.

References error(), and NULL.

Referenced by mark_operands_used_in_match_dup().

static rtx replace_duplicating_operands_in_pattern ( rtx  )
static
static rtx replace_duplicating_operands_in_pattern ( )
static

This routine checks all match_operands in PATTERN and if some of have the same index, it replaces all of them except the first one to match_dup. Usually, match_operands with the same indexes are forbidden, but after define_subst copy an RTL-expression from original template, indexes of existed and just-copied match_operands could coincide. To fix it, we replace one of them with match_dup.

Compare predicates before replacing with match_dup.

static void rtx_handle_directive ( )
static

A read_md_files callback for reading an rtx.

Referenced by gen_mnemonic_attr().

static char* shift_output_template ( char *  ,
const char *  ,
int   
)
static
static char* shift_output_template ( )
static

Adjust all of the operand numbers in SRC to match the shift they'll get from an operand displacement of DISP. Return a pointer after the adjusted string.

static rtx subst_dup ( rtx  ,
int  ,
int   
)
static
static rtx subst_dup ( )
static

The routine modifies given input PATTERN of define_subst, replacing MATCH_DUP and MATCH_OP_DUP with operands from define_insn original pattern, whose operands are stored in OPERAND_DATA array. It also duplicates constraints in operands - constraints from define_insn operands are duplicated N_SUBST_ALT times, constraints from define_subst operands are duplicated N_ALT times. After the duplication, returned output rtl-pattern contains every combination of input constraints Vs constraints from define_subst output.

Duplicate constraints.

static bool subst_pattern_match ( rtx  ,
rtx  ,
int   
)
static

Referenced by subst_pattern_match().

static bool subst_pattern_match ( )
static

Compare RTL-template of original define_insn X to input RTL-template of define_subst PT. Return 1 if the templates match, 0 otherwise. During the comparison, the routine also fills global_array OPERAND_DATA.

     MATCH_DUP, and MATCH_OP_DUP don't have a specified mode, so we
     always accept them.   
     Compare modes.   
     In case X is also match_operator, compare predicates.   
     Compare operands.
     MATCH_OPERATOR in input template could match in original template
     either 1) MATCH_OPERAND, 2) UNSPEC, 3) ordinary operation (like PLUS).
     In the first case operands are at (XVECEXP (x, 2, j)), in the second
     - at (XVECEXP (x, 0, j)), in the last one - (XEXP (x, j)).
     X_VECEXP_POS variable shows, where to look for these operands.   
     MATCH_OPERATOR or UNSPEC case.   
         Compare operands number in X and PT.   
     Ordinary operator.   
         Compare operands number in X and PT.
         We count operands differently for X and PT since we compare
         an operator (with operands directly in RTX) and MATCH_OPERATOR
         (that has a vector with operands).   
     Store the operand to OPERAND_DATA array.   
     Currently interface for these constructions isn't defined -
     probably they aren't needed in input template of define_subst at all.
     So, for now their usage in define_subst is forbidden.   
 If PT is none of the handled above, then we match only expressions with
 the same code in X.   

References gcc_assert, GET_MODE, lookup_predicate(), MAX_OPERANDS, subst_pattern_match(), XEXP, XINT, XSTR, XVECEXP, and XVECLEN.

void traverse_c_tests ( )

For every C test, call CALLBACK with two arguments: a pointer to the condition structure and INFO. Stops when CALLBACK returns zero.

static bool valid_predicate_name_p ( )
static

Return true if NAME is a valid predicate name.

References pred_data::codes, error_with_line(), NUM_RTX_CODE, and XSTR.


Variable Documentation

htab_t condition_table
static

Referenced by gen_mnemonic_attr(), and read_md_rtx().

struct queue_elem* define_attr_queue
static
struct queue_elem** define_attr_tail = &define_attr_queue
static

Referenced by gen_mnemonic_setattr().

struct queue_elem* define_cond_exec_queue
static
struct queue_elem** define_cond_exec_tail = &define_cond_exec_queue
static
struct queue_elem* define_insn_queue
static
struct queue_elem** define_insn_tail = &define_insn_queue
static
struct queue_elem* define_pred_queue
static
struct queue_elem** define_pred_tail = &define_pred_queue
static
struct queue_elem* define_subst_attr_queue
static
struct queue_elem** define_subst_attr_tail = &define_subst_attr_queue
static
struct queue_elem* define_subst_queue
static
struct queue_elem** define_subst_tail = &define_subst_queue
static
char did_you_mean_codes[NUM_RTX_CODE]
static

0 means no warning about that code yet, 1 means warned.

struct pred_data* first_predicate
int insn_elision = 1

Set this to 0 to disable automatic elision of insn patterns which can never be used in this configuration. See genconditions.c. Must be set before calling init_md_reader.

char** insn_name_ptr = 0
static

These functions allow linkage with print-rtl.c. Also, some generators like to annotate their output with insn names. Holds an array of names indexed by insn_code_number.

int insn_name_ptr_size = 0
static
struct pred_data** last_predicate = &first_predicate
static
rtx match_operand_entries_in_pattern[MAX_OPERANDS]
static
struct obstack obstack
static
struct queue_elem* other_queue
static
struct queue_elem** other_tail = &other_queue
static
int predicable_default
static
const char* predicable_false
static
const char* predicable_true
static
htab_t predicate_table
static

Helper functions for define_predicate and define_special_predicate processing. Shared between genrecog.c and genpreds.c.

int sequence_num
static

Counter for patterns that generate code: define_insn, define_expand, define_split, define_peephole, and define_peephole2. See read_md_rtx(). Any define_insn_and_splits are already in separate queues so that the insn and the splitter get a unique number also.

Referenced by gen_mnemonic_attr().

struct std_pred_table std_preds[]
static
Initial value:
{
{"general_operand", false, true, {SUBREG, REG, MEM}},
{"address_operand", true, true, {SUBREG, REG, MEM, PLUS, MINUS, MULT}},
{"register_operand", false, false, {SUBREG, REG}},
{"pmode_register_operand", true, false, {SUBREG, REG}},
{"scratch_operand", false, false, {SCRATCH, REG}},
{"immediate_operand", false, true, {UNKNOWN}},
{"const_int_operand", false, false, {CONST_INT}},
{"const_double_operand", false, false, {CONST_INT, CONST_DOUBLE}},
{"nonimmediate_operand", false, false, {SUBREG, REG, MEM}},
{"nonmemory_operand", false, true, {SUBREG, REG}},
{"push_operand", false, false, {MEM}},
{"pop_operand", false, false, {MEM}},
{"memory_operand", false, false, {SUBREG, MEM}},
{"indirect_operand", false, false, {SUBREG, MEM}},
{"ordered_comparison_operator", false, false, {EQ, NE,
LE, LT, GE, GT,
LEU, LTU, GEU, GTU}},
{"comparison_operator", false, false, {EQ, NE,
LE, LT, GE, GT,
LEU, LTU, GEU, GTU,
UNORDERED, ORDERED,
UNEQ, UNGE, UNGT,
UNLE, UNLT, LTGT}}
}
const char* subst_false = "no"
static
const char* subst_true = "yes"
static
int target_flags

In case some macros used by files we include need it, define this here.

Referenced by default_class_max_nregs().

char used_operands_numbers[MAX_OPERANDS]
static