Previous: Define Subst Pattern Matching, Up: Define Subst [Contents][Index]
define_subst
If all necessary checks for define_subst
application pass, a new
RTL-pattern, based on the output-template, is created to replace the old
template. Like in input-patterns, meanings of some RTL expressions are
changed when they are used in output-patterns of a define_subst
.
Thus, match_dup
is used for copying the whole expression from the
original pattern, which matched corresponding match_operand
from
the input pattern.
match_dup N
is used in the output template to be replaced with
the expression from the original pattern, which matched
match_operand N
from the input pattern. As a consequence,
match_dup
cannot be used to point to match_operand
s from
the output pattern, it should always refer to a match_operand
from the input pattern. If a match_dup N
occurs more than once
in the output template, its first occurrence is replaced with the
expression from the original pattern, and the subsequent expressions
are replaced with match_dup N
, i.e., a reference to the first
expression.
In the output template one can refer to the expressions from the
original pattern and create new ones. For instance, some operands could
be added by means of standard match_operand
.
After replacing match_dup
with some RTL-subtree from the original
pattern, it could happen that several match_operand
s in the
output pattern have the same indexes. It is unknown, how many and what
indexes would be used in the expression which would replace
match_dup
, so such conflicts in indexes are inevitable. To
overcome this issue, match_operands
and match_operators
,
which were introduced into the output pattern, are renumerated when all
match_dup
s are replaced.
Number of alternatives in match_operand
s introduced into the
output template M
could differ from the number of alternatives in
the original pattern N
, so in the resultant pattern there would
be N*M
alternatives. Thus, constraints from the original pattern
would be duplicated N
times, constraints from the output pattern
would be duplicated M
times, producing all possible combinations.
Previous: Define Subst Pattern Matching, Up: Define Subst [Contents][Index]