gccint: Patterns

1 
1 17.2 Everything about Instruction Patterns
1 ==========================================
1 
1 A 'define_insn' expression is used to define instruction patterns to
1 which insns may be matched.  A 'define_insn' expression contains an
1 incomplete RTL expression, with pieces to be filled in later, operand
1 constraints that restrict how the pieces can be filled in, and an output
1 template or C code to generate the assembler output.
1 
1  A 'define_insn' is an RTL expression containing four or five operands:
1 
1   1. An optional name.  The presence of a name indicates that this
1      instruction pattern can perform a certain standard job for the
1      RTL-generation pass of the compiler.  This pass knows certain names
1      and will use the instruction patterns with those names, if the
1      names are defined in the machine description.
1 
1      The absence of a name is indicated by writing an empty string where
1      the name should go.  Nameless instruction patterns are never used
1      for generating RTL code, but they may permit several simpler insns
1      to be combined later on.
1 
1      Names that are not thus known and used in RTL-generation have no
1      effect; they are equivalent to no name at all.
1 
1      For the purpose of debugging the compiler, you may also specify a
1      name beginning with the '*' character.  Such a name is used only
1      for identifying the instruction in RTL dumps; it is equivalent to
1      having a nameless pattern for all other purposes.  Names beginning
1      with the '*' character are not required to be unique.
1 
1   2. The "RTL template": This is a vector of incomplete RTL expressions
11      which describe the semantics of the instruction (⇒RTL
      Template).  It is incomplete because it may contain
1      'match_operand', 'match_operator', and 'match_dup' expressions that
1      stand for operands of the instruction.
1 
1      If the vector has multiple elements, the RTL template is treated as
1      a 'parallel' expression.
1 
1   3. The condition: This is a string which contains a C expression.
1      When the compiler attempts to match RTL against a pattern, the
1      condition is evaluated.  If the condition evaluates to 'true', the
1      match is permitted.  The condition may be an empty string, which is
1      treated as always 'true'.
1 
1      For a named pattern, the condition may not depend on the data in
1      the insn being matched, but only the target-machine-type flags.
1      The compiler needs to test these conditions during initialization
1      in order to learn exactly which named instructions are available in
1      a particular run.
1 
1      For nameless patterns, the condition is applied only when matching
1      an individual insn, and only after the insn has matched the
1      pattern's recognition template.  The insn's operands may be found
1      in the vector 'operands'.
1 
1      An instruction condition cannot become more restrictive as
1      compilation progresses.  If the condition accepts a particular RTL
1      instruction at one stage of compilation, it must continue to accept
1      that instruction until the final pass.  For example,
1      '!reload_completed' and 'can_create_pseudo_p ()' are both invalid
1      instruction conditions, because they are true during the earlier
1      RTL passes and false during the later ones.  For the same reason,
1      if a condition accepts an instruction before register allocation,
1      it cannot later try to control register allocation by excluding
1      certain register or value combinations.
1 
1      Although a condition cannot become more restrictive as compilation
1      progresses, the condition for a nameless pattern _can_ become more
1      permissive.  For example, a nameless instruction can require
1      'reload_completed' to be true, in which case it only matches after
1      register allocation.
1 
1   4. The "output template" or "output statement": This is either a
1      string, or a fragment of C code which returns a string.
1 
1      When simple substitution isn't general enough, you can specify a
1      piece of C code to compute the output.  ⇒Output Statement.
1 
1   5. The "insn attributes": This is an optional vector containing the
11      values of attributes for insns matching this pattern (⇒Insn
      Attributes).
1