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

Data Structures

struct  map_value
struct  mapping
struct  iterator_group
struct  iterator_use
struct  attribute_use
struct  subst_attr_to_iter_mapping

Typedefs

typedef struct mappingmapping_ptr
typedef struct iterator_use iterator_use
typedef struct attribute_use attribute_use

Functions

static void validate_const_int (const char *)
static rtx read_rtx_code (const char *)
static rtx read_nested_rtx (void)
static rtx read_rtx_variadic (rtx)
static int find_mode ()
static void apply_mode_iterator ()
static int find_code ()
static void apply_code_iterator ()
static int find_int ()
static void apply_int_iterator ()
static void apply_subst_iterator ()
static void bind_subst_iter_and_attr ()
static char * find_subst_iter_by_attr ()
static struct map_valuemap_attr_string ()
static const char * apply_iterator_to_string ()
static rtx copy_rtx_for_iterators ()
static const char * add_condition_to_string ()
static void add_condition_to_rtx ()
static void apply_attribute_uses ()
static int add_current_iterators ()
static void apply_iterators ()
static struct mappingadd_mapping ()
static struct map_value ** add_map_value ()
static void initialize_iterators ()
static void read_conditions ()
static void validate_const_int ()
static void record_iterator_use ()
static void record_attribute_use (struct iterator_group *group, void *ptr, const char *value)
static void record_potential_iterator_use (struct iterator_group *group, void *ptr, const char *name)
static struct mappingread_mapping ()
static void add_define_attr_for_define_subst ()
static void add_define_subst_attr ()
static void read_subst_mapping (htab_t subst_iters_table, htab_t subst_attrs_table, rtx *queue)
static void check_code_iterator ()
bool read_rtx ()
static rtx read_rtx_code ()
static rtx read_rtx_variadic ()

Variables

htab_t subst_attr_to_iter_map = NULL
const char * current_iterator_name
static struct iterator_group
modes codes ints 
substs
static vec< mapping_ptrcurrent_iterators
static vec< iterator_useiterator_uses
static vec< attribute_useattribute_uses

Typedef Documentation

typedef struct attribute_use attribute_use

Vector definitions for the above.

typedef struct iterator_use iterator_use

Vector definitions for the above.

typedef struct mapping* mapping_ptr

Vector definitions for the above.


Function Documentation

static void add_condition_to_rtx ( )
static

Like add_condition, but applied to all conditions in rtx X.

References current_iterators, and mapping::current_value.

static const char* add_condition_to_string ( )
static

Return a condition that must satisfy both ORIGINAL and EXTRA. If ORIGINAL has the form "&& ..." (as used in define_insn_and_splits), assume that EXTRA is already satisfied. Empty strings are treated like "true".

static int add_current_iterators ( )
static

A htab_traverse callback for iterators. Add all used iterators to current_iterators.

References iterator_group::apply_iterator, mapping::current_value, mapping::group, iterator_use::iterator, join_c_conditions(), map_value::number, iterator_use::ptr, map_value::string, and substs.

static void add_define_attr_for_define_subst ( )
static

For iterator with name ATTR_NAME generate define_attr with values 'yes' and 'no'. This attribute is used to mark templates to which define_subst ATTR_NAME should be applied. This attribute is set and defined implicitly and automatically.

static void add_define_subst_attr ( )
static

This routine generates DEFINE_SUBST_ATTR expression with operands ATTR_OPERANDS and places it to QUEUE.

References initialize_iterators(), modes, read_conditions(), read_mapping(), and rtx_alloc.

static struct map_value** add_map_value ( )
staticread

Add the pair (NUMBER, STRING) to a list of map_value structures. END_PTR points to the current null terminator for the list; return a pointer the new null terminator.

References GET_RTX_NAME.

static struct mapping* add_mapping ( )
staticread

Add a new "mapping" structure to hashtable TABLE. NAME is the name of the mapping and GROUP is the group to which it belongs.

static void apply_attribute_uses ( )
static

Apply the current iterator values to all attribute_uses.

static void apply_code_iterator ( )
static

References gcc_assert, GET_CODE, and XVEC.

static void apply_int_iterator ( )
static
static const char* apply_iterator_to_string ( )
static

Apply the current iterator values to STRING. Return the new string if any changes were needed, otherwise return STRING itself.

Add everything between the last copied byte and the '<', then add in the attribute value.

static void apply_iterators ( )
static

Expand all iterators in the current rtx, which is given as ORIGINAL. Build a list of expanded rtxes in the EXPR_LIST pointed to by QUEUE.

Raise an error if any attributes were used.   
 Clear out the iterators from the previous run.   


 Mark the iterators that we need this time.   
 Get the list of iterators that are in use, preserving the
 definition order within each group.   
     Apply the current iterator values.  Accumulate a condition to
     say when the resulting rtx can be used.   
     We apply subst iterator after RTL-template is copied, as during
     subst-iterator processing, we could add an attribute to the
     RTL-template, and we don't want to do it in the original one.   
     Add the new rtx to the end of the queue.   
     Lexicographically increment the iterator value sequence.
     That is, cycle through iterator values, starting from the right,
     and stopping when one of them doesn't wrap around.   
     At least one more rtx to go.  Allocate room for it.   

References iterator_group::apply_iterator, current_iterator_name, mapping::current_value, mapping::group, iterator_use::iterator, mapping::name, map_value::number, iterator_use::ptr, and substs.

static void apply_mode_iterator ( )
static

References validate_const_int().

static void apply_subst_iterator ( )
static

This routine adds attribute or does nothing depending on VALUE. When VALUE is 1, it does nothing - the first duplicate of original template is kept untouched when it's subjected to a define_subst. When VALUE isn't 1, the routine modifies RTL-template LOC, adding attribute, named exactly as define_subst, which later will be applied. If such attribute has already been added, then no the routine has no effect.

If we've already added attribute 'current_iterator_name', then we have nothing to do now.

 Add attribute with subst name - it serves as a mark for
 define_subst which later would be applied to this pattern.   
static void bind_subst_iter_and_attr ( )
static

Map subst-attribute ATTR to subst iterator ITER.

static void check_code_iterator ( )
static

Check newly-created code iterator ITERATOR to see whether every code has the same format.

References HOST_WIDE_INT, and RTX_CODE.

static rtx copy_rtx_for_iterators ( )
static

Return a deep copy of X, substituting the current iterator values into any strings.

Create a shallow copy of ORIGINAL.

 Change each string and recursively change each rtx.   
static int find_code ( )
static

Implementations of the iterator_group callbacks for codes.

static int find_int ( )
static

Implementations of the iterator_group callbacks for ints. Since GCC does not construct a table of valid constants, we have to accept any int as valid. No cross-checking can be done.

References current_iterator_name, rtvec_def::elem, GET_NUM_ELEM, and XSTR.

static int find_mode ( )
static

Implementations of the iterator_group callbacks for modes.

References PUT_CODE.

static char* find_subst_iter_by_attr ( )
static

Return name of a subst-iterator, corresponding to subst-attribute ATTR.

References iterator_group::attrs, mapping::group, and mapping::name.

Referenced by map_attr_string().

static void initialize_iterators ( )
static

Do one-time initialization of the mode and code attributes.

References HOST_WIDE_INT.

Referenced by add_define_subst_attr().

static struct map_value* map_attr_string ( )
staticread

Map attribute string P to its current value. Return null if the attribute isn't known.

 Peel off any "iterator:" prefix.  Set ATTR to the start of the
 attribute name.   
     If an iterator name was specified, check that it matches.   
     Find the attribute specification.   
         In contrast to code/mode/int iterators, attributes of subst
         iterators are linked to one specific subst-iterator.  So, if
         we are dealing with subst-iterator, we should check if it's
         the one which linked with the given attribute.   
         Find the attribute value associated with the current
         iterator value.   

References find_subst_iter_by_attr(), and mapping::name.

static void read_conditions ( )
static

Provide a version of a function to read a long long if the system does not provide one. Process a define_conditions directive, starting with the optional space after the "define_conditions". The directive looks like this:

(define_conditions [ (number "string") (number "string") ... ])

It's not intended to appear in machine descriptions. It is generated by (the program generated by) genconditions.c, and slipped in at the beginning of the sequence of MD files read by most of the other generators.

References attribute_use::group, and attribute_use::value.

Referenced by add_define_subst_attr().

static struct mapping* read_mapping ( )
staticread

Finish reading a declaration of the form:

(define... <name> [<value1> ... <valuen>])

from the MD file, where each <valuei> is either a bare symbol name or a "(<name> <string>)" pair. The "(define..." part has already been read.

Represent the declaration as a "mapping" structure; add it to TABLE (which belongs to GROUP) and return it.

 Read the mapping name and create a structure for it.   
 Read each value.   
         A bare symbol name that is implicitly paired to an
         empty string.   
         A "(name string)" pair.   

References NULL_RTX, PUT_CODE, rtx_alloc, XEXP, and XSTR.

Referenced by add_define_subst_attr().

static rtx read_nested_rtx ( )
static

Read a nested rtx construct from the MD file and return it.

Referenced by read_rtx_code().

bool read_rtx ( )

Read an rtx-related declaration from the MD file, given that it starts with directive name RTX_NAME. Return true if it expands to one or more rtxes (as defined by rtx.def). When returning true, store the list of rtxes as an EXPR_LIST in *X.

 Do one-time initialization.   
 Handle various rtx-related declarations that aren't themselves
 encoded as rtxes.   
     READ_SUBST_MAPPING could generate a new DEFINE_ATTR.  Return
     TRUE to process it.   
static rtx read_rtx_code ( const char *  )
static
static rtx read_rtx_code ( )
static

Subroutine of read_rtx and read_nested_rtx. CODE_NAME is the name of either an rtx code or a code iterator. Parse the rest of the rtx and return it.

 Linked list structure for making RTXs:  
 If this code is an iterator, build the rtx using the iterator's
 first value.   
 If we end up with an insn expression then we free this space below.   
 If what follows is `: mode ', read it and
 store the mode in the rtx.   
       0 means a field for internal use only.
       Don't expect it to be present in the input.   
       'V' is an optional vector: if a closeparen follows,
       just store NULL for this element.   
       Now process the vector.   
         Obstack to store scratch vector in.   
         Add expressions to a list, while keeping a count.   
         close bracket gotten  
             'S' fields are optional and should be NULL if no string
             was given.  Also allow normal 's' and 'T' strings to be
             omitted, treating them in the same way as empty strings.   
         The output template slot of a DEFINE_INSN,
         DEFINE_INSN_AND_SPLIT, or DEFINE_PEEPHOLE automatically
         gets a star inserted as its first character, if it is
         written with a brace block instead of a string constant.   
         For insn patterns, we want to provide a default name
         based on the file and line, like "*foo.md:12", if the
         given name is blank.  These are only for define_insn and
         define_insn_and_split, to aid debugging.   
         Find attr-names in the string.   
                 Here we should find linked subst-iter.   
       Can be an iterator or an integer constant.   
 Syntactic sugar for AND and IOR, allowing Lisp-like
 arbitrary number of arguments for them.   

References fatal_expected_char(), read_nested_rtx(), and unread_char().

static rtx read_rtx_variadic ( rtx  )
static
static rtx read_rtx_variadic ( )
static

Mutually recursive subroutine of read_rtx which reads (thing x1 x2 x3 ...) and produces RTL as if (thing x1 (thing x2 (thing x3 ...))) had been written. When called, FORM is (thing x1 x2), and the file position is just past the leading parenthesis of x3. Only works for THINGs which are dyadic expressions, e.g. AND, IOR.

static void read_subst_mapping ( htab_t  subst_iters_table,
htab_t  subst_attrs_table,
rtx queue 
)
static

Read define_subst_attribute construction. It has next form: (define_subst_attribute <attribute_name> <iterator_name> <value1> <value2>) Attribute is substituted with value1 when no subst is applied and with value2 in the opposite case. Attributes are added to SUBST_ATTRS_TABLE. In case the iterator is encountered for the first time, it's added to SUBST_ITERS_TABLE. Also, implicit define_attr is generated.

Add element to the queue.

static void record_attribute_use ( struct iterator_group group,
void *  ptr,
const char *  value 
)
static

Record that PTR uses attribute VALUE, which must match a built-in value from group GROUP.

static void record_iterator_use ( )
static

Record that PTR uses iterator ITERATOR.

static void record_potential_iterator_use ( struct iterator_group group,
void *  ptr,
const char *  name 
)
static

Interpret NAME as either a built-in value, iterator or attribute for group GROUP. PTR is the value to pass to GROUP's apply_iterator callback.

Copy the attribute string into permanent storage, without the angle brackets around it.

static void validate_const_int ( const char *  )
static

Referenced by apply_mode_iterator().

static void validate_const_int ( )
static

Variable Documentation

vec<attribute_use> attribute_uses
static

The list of all attribute uses in the current rtx.

const char* current_iterator_name

This global stores name of subst-iterator which is currently being processed.

Referenced by apply_iterators(), and find_int().

vec<mapping_ptr> current_iterators
static

All iterators used in the current rtx.

Referenced by add_condition_to_rtx().

vec<iterator_use> iterator_uses
static

The list of all iterator uses in the current rtx.

htab_t subst_attr_to_iter_map = NULL

Hash-table to store links between subst-attributes and define_substs.

struct iterator_group modes codes ints substs
static

The mode and code iterator structures.

Referenced by add_current_iterators(), and apply_iterators().