home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 1
/
FFMCD01.bin
/
useful
/
info
/
gcc.info-13
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1993-09-05
|
49KB
|
961 lines
This is Info file gcc.info, produced by Makeinfo-1.54 from the input
file gcc.texi.
This file documents the use and the internals of the GNU compiler.
Published by the Free Software Foundation 675 Massachusetts Avenue
Cambridge, MA 02139 USA
Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the sections entitled "GNU General Public License" and "Protect
Your Freedom--Fight `Look And Feel'" are included exactly as in the
original, and provided that the entire resulting derived work is
distributed under the terms of a permission notice identical to this
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the sections entitled "GNU General Public
License" and "Protect Your Freedom--Fight `Look And Feel'", and this
permission notice, may be included in translations approved by the Free
Software Foundation instead of in the original English.
File: gcc.info, Node: RTL Template, Next: Output Template, Prev: Example, Up: Machine Desc
RTL Template
============
The RTL template is used to define which insns match the particular
pattern and how to find their operands. For named patterns, the RTL
template also says how to construct an insn from specified operands.
Construction involves substituting specified operands into a copy of
the template. Matching involves determining the values that serve as
the operands in the insn being matched. Both of these activities are
controlled by special expression types that direct matching and
substitution of the operands.
`(match_operand:M N PREDICATE CONSTRAINT)'
This expression is a placeholder for operand number N of the insn.
When constructing an insn, operand number N will be substituted
at this point. When matching an insn, whatever appears at this
position in the insn will be taken as operand number N; but it
must satisfy PREDICATE or this instruction pattern will not match
at all.
Operand numbers must be chosen consecutively counting from zero in
each instruction pattern. There may be only one `match_operand'
expression in the pattern for each operand number. Usually
operands are numbered in the order of appearance in `match_operand'
expressions.
PREDICATE is a string that is the name of a C function that
accepts two arguments, an expression and a machine mode. During
matching, the function will be called with the putative operand as
the expression and M as the mode argument (if M is not specified,
`VOIDmode' will be used, which normally causes PREDICATE to accept
any mode). If it returns zero, this instruction pattern fails to
match. PREDICATE may be an empty string; then it means no test is
to be done on the operand, so anything which occurs in this
position is valid.
Most of the time, PREDICATE will reject modes other than M--but
not always. For example, the predicate `address_operand' uses M
as the mode of memory ref that the address should be valid for.
Many predicates accept `const_int' nodes even though their mode is
`VOIDmode'.
CONSTRAINT controls reloading and the choice of the best register
class to use for a value, as explained later (*note
Constraints::.).
People are often unclear on the difference between the constraint
and the predicate. The predicate helps decide whether a given
insn matches the pattern. The constraint plays no role in this
decision; instead, it controls various decisions in the case of an
insn which does match.
On CISC machines, the most common PREDICATE is
`"general_operand"'. This function checks that the putative
operand is either a constant, a register or a memory reference,
and that it is valid for mode M.
For an operand that must be a register, PREDICATE should be
`"register_operand"'. Using `"general_operand"' would be valid,
since the reload pass would copy any non-register operands through
registers, but this would make GNU CC do extra work, it would
prevent invariant operands (such as constant) from being removed
from loops, and it would prevent the register allocator from doing
the best possible job. On RISC machines, it is usually most
efficient to allow PREDICATE to accept only objects that the
constraints allow.
For an operand that must be a constant, you must be sure to either
use `"immediate_operand"' for PREDICATE, or make the instruction
pattern's extra condition require a constant, or both. You cannot
expect the constraints to do this work! If the constraints allow
only constants, but the predicate allows something else, the
compiler will crash when that case arises.
`(match_scratch:M N CONSTRAINT)'
This expression is also a placeholder for operand number N and
indicates that operand must be a `scratch' or `reg' expression.
When matching patterns, this is completely equivalent to
(match_operand:M N "scratch_operand" PRED)
but, when generating RTL, it produces a (`scratch':M) expression.
If the last few expressions in a `parallel' are `clobber'
expressions whose operands are either a hard register or
`match_scratch', the combiner can add them when necessary. *Note
Side Effects::.
`(match_dup N)'
This expression is also a placeholder for operand number N. It is
used when the operand needs to appear more than once in the insn.
In construction, `match_dup' acts just like `match_operand': the
operand is substituted into the insn being constructed. But in
matching, `match_dup' behaves differently. It assumes that operand
number N has already been determined by a `match_operand'
appearing earlier in the recognition template, and it matches only
an identical-looking expression.
`(match_operator:M N PREDICATE [OPERANDS...])'
This pattern is a kind of placeholder for a variable RTL expression
code.
When constructing an insn, it stands for an RTL expression whose
expression code is taken from that of operand N, and whose
operands are constructed from the patterns OPERANDS.
When matching an expression, it matches an expression if the
function PREDICATE returns nonzero on that expression *and* the
patterns OPERANDS match the operands of the expression.
Suppose that the function `commutative_operator' is defined as
follows, to match any expression whose operator is one of the
commutative arithmetic operators of RTL and whose mode is MODE:
int
commutative_operator (x, mode)
rtx x;
enum machine_mode mode;
{
enum rtx_code code = GET_CODE (x);
if (GET_MODE (x) != mode)
return 0;
return (GET_RTX_CLASS (code) == 'c'
|| code == EQ || code == NE);
}
Then the following pattern will match any RTL expression consisting
of a commutative operator applied to two general operands:
(match_operator:SI 3 "commutative_operator"
[(match_operand:SI 1 "general_operand" "g")
(match_operand:SI 2 "general_operand" "g")])
Here the vector `[OPERANDS...]' contains two patterns because the
expressions to be matched all contain two operands.
When this pattern does match, the two operands of the commutative
operator are recorded as operands 1 and 2 of the insn. (This is
done by the two instances of `match_operand'.) Operand 3 of the
insn will be the entire commutative expression: use `GET_CODE
(operands[3])' to see which commutative operator was used.
The machine mode M of `match_operator' works like that of