gccint: Example

1 
1 17.3 Example of 'define_insn'
1 =============================
1 
1 Here is an example of an instruction pattern, taken from the machine
1 description for the 68000/68020.
1 
1      (define_insn "tstsi"
1        [(set (cc0)
1              (match_operand:SI 0 "general_operand" "rm"))]
1        ""
1        "*
1      {
1        if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
1          return \"tstl %0\";
1        return \"cmpl #0,%0\";
1      }")
1 
1 This can also be written using braced strings:
1 
1      (define_insn "tstsi"
1        [(set (cc0)
1              (match_operand:SI 0 "general_operand" "rm"))]
1        ""
1      {
1        if (TARGET_68020 || ! ADDRESS_REG_P (operands[0]))
1          return "tstl %0";
1        return "cmpl #0,%0";
1      })
1 
1  This describes an instruction which sets the condition codes based on
1 the value of a general operand.  It has no condition, so any insn with
1 an RTL description of the form shown may be matched to this pattern.
1 The name 'tstsi' means "test a 'SImode' value" and tells the RTL
1 generation pass that, when it is necessary to test such a value, an insn
1 to do so can be constructed using this pattern.
1 
1  The output control string is a piece of C code which chooses which
1 output template to return based on the kind of operand and the specific
1 type of CPU for which code is being generated.
1 
1  '"rm"' is an operand constraint.  Its meaning is explained below.
1