Commit 2f9d3709 by James Greenhalgh Committed by James Greenhalgh

[Patch Docs] Copy edit the text in "Everything about patterns"

	* doc/md.texi (Instruction Patterns): Copy edit text for
	clarity and correctness.
	(Example): Likewise.

From-SVN: r219432
parent 5c0ba546
2015-01-11 James Greenhalgh <james.greenhalgh@arm.com>
* doc/md.texi (Instruction Patterns): Rewrite text for
clarity.
(Example): Likewise.
2015-01-10 Sandra Loosemore <sandra@codesourcery.com> 2015-01-10 Sandra Loosemore <sandra@codesourcery.com>
* doc/invoke.texi (Option Summary): Break long lines. * doc/invoke.texi (Option Summary): Break long lines.
......
...@@ -105,10 +105,11 @@ acts like it's unnamed, since the names are ignored. ...@@ -105,10 +105,11 @@ acts like it's unnamed, since the names are ignored.
@cindex instruction patterns @cindex instruction patterns
@findex define_insn @findex define_insn
Each instruction pattern contains an incomplete RTL expression, with pieces A @code{define_insn} expression is used to define instruction patterns
to be filled in later, operand constraints that restrict how the pieces can to which insns may be matched. A @code{define_insn} expression contains
be filled in, and an output pattern or C code to generate the assembler an incomplete RTL expression, with pieces to be filled in later, operand
output, all wrapped up in a @code{define_insn} expression. constraints that restrict how the pieces can be filled in, and an output
template or C code to generate the assembler output.
A @code{define_insn} is an RTL expression containing four or five operands: A @code{define_insn} is an RTL expression containing four or five operands:
...@@ -130,60 +131,63 @@ effect; they are equivalent to no name at all. ...@@ -130,60 +131,63 @@ effect; they are equivalent to no name at all.
For the purpose of debugging the compiler, you may also specify a For the purpose of debugging the compiler, you may also specify a
name beginning with the @samp{*} character. Such a name is used only name beginning with the @samp{*} character. Such a name is used only
for identifying the instruction in RTL dumps; it is entirely equivalent for identifying the instruction in RTL dumps; it is equivalent to having
to having a nameless pattern for all other purposes. a nameless pattern for all other purposes. Names beginning with the
@samp{*} character are not required to be unique.
@item @item
The @dfn{RTL template} (@pxref{RTL Template}) is a vector of incomplete The @dfn{RTL template}: This is a vector of incomplete RTL expressions
RTL expressions which show what the instruction should look like. It is which describe the semantics of the instruction (@pxref{RTL Template}).
incomplete because it may contain @code{match_operand}, It is incomplete because it may contain @code{match_operand},
@code{match_operator}, and @code{match_dup} expressions that stand for @code{match_operator}, and @code{match_dup} expressions that stand for
operands of the instruction. operands of the instruction.
If the vector has only one element, that element is the template for the If the vector has multiple elements, the RTL template is treated as a
instruction pattern. If the vector has multiple elements, then the @code{parallel} expression.
instruction pattern is a @code{parallel} expression containing the
elements described.
@item @item
@cindex pattern conditions @cindex pattern conditions
@cindex conditions, in patterns @cindex conditions, in patterns
A condition. This is a string which contains a C expression that is The condition: This is a string which contains a C expression. When the
the final test to decide whether an insn body matches this pattern. compiler attempts to match RTL against a pattern, the condition is
evaluated. If the condition evaluates to @code{true}, the match is
permitted. The condition may be an empty string, which is treated
as always @code{true}.
@cindex named patterns and conditions @cindex named patterns and conditions
For a named pattern, the condition (if present) may not depend on For a named pattern, the condition may not depend on the data in the
the data in the insn being matched, but only the target-machine-type insn being matched, but only the target-machine-type flags. The compiler
flags. The compiler needs to test these conditions during needs to test these conditions during initialization in order to learn
initialization in order to learn exactly which named instructions are exactly which named instructions are available in a particular run.
available in a particular run.
@findex operands @findex operands
For nameless patterns, the condition is applied only when matching an For nameless patterns, the condition is applied only when matching an
individual insn, and only after the insn has matched the pattern's individual insn, and only after the insn has matched the pattern's
recognition template. The insn's operands may be found in the vector recognition template. The insn's operands may be found in the vector
@code{operands}. For an insn where the condition has once matched, it @code{operands}.
can't be used to control register allocation, for example by excluding
certain hard registers or hard register combinations. For an insn where the condition has once matched, it
cannot later be used to control register allocation by excluding
certain register or value combinations.
@item @item
The @dfn{output template}: a string that says how to output matching The @dfn{output template} or @dfn{output statement}: This is either
insns as assembler code. @samp{%} in this string specifies where a string, or a fragment of C code which returns a string.
to substitute the value of an operand. @xref{Output Template}.
When simple substitution isn't general enough, you can specify a piece When simple substitution isn't general enough, you can specify a piece
of C code to compute the output. @xref{Output Statement}. of C code to compute the output. @xref{Output Statement}.
@item @item
Optionally, a vector containing the values of attributes for insns matching The @dfn{insn attributes}: This is an optional vector containing the values of
this pattern. @xref{Insn Attributes}. attributes for insns matching this pattern (@pxref{Insn Attributes}).
@end enumerate @end enumerate
@node Example @node Example
@section Example of @code{define_insn} @section Example of @code{define_insn}
@cindex @code{define_insn} example @cindex @code{define_insn} example
Here is an actual example of an instruction pattern, for the 68000/68020. Here is an example of an instruction pattern, taken from the machine
description for the 68000/68020.
@smallexample @smallexample
(define_insn "tstsi" (define_insn "tstsi"
...@@ -213,12 +217,12 @@ This can also be written using braced strings: ...@@ -213,12 +217,12 @@ This can also be written using braced strings:
@}) @})
@end smallexample @end smallexample
This is an instruction that sets the condition codes based on the value of This describes an instruction which sets the condition codes based on the
a general operand. It has no condition, so any insn whose RTL description value of a general operand. It has no condition, so any insn with an RTL
has the form shown may be handled according to this pattern. The name description of the form shown may be matched to this pattern. The name
@samp{tstsi} means ``test a @code{SImode} value'' and tells the RTL generation @samp{tstsi} means ``test a @code{SImode} value'' and tells the RTL
pass that, when it is necessary to test such a value, an insn to do so generation pass that, when it is necessary to test such a value, an insn
can be constructed using this pattern. to do so can be constructed using this pattern.
The output control string is a piece of C code which chooses which The output control string is a piece of C code which chooses which
output template to return based on the kind of operand and the specific output template to return based on the kind of operand and the specific
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment