gccint: Multi-Alternative

1 
1 17.8.2 Multiple Alternative Constraints
1 ---------------------------------------
1 
1 Sometimes a single instruction has multiple alternative sets of possible
1 operands.  For example, on the 68000, a logical-or instruction can
1 combine register or an immediate value into memory, or it can combine
1 any kind of operand into a register; but it cannot combine one memory
1 location into another.
1 
1  These constraints are represented as multiple alternatives.  An
1 alternative can be described by a series of letters for each operand.
1 The overall constraint for an operand is made from the letters for this
1 operand from the first alternative, a comma, the letters for this
1 operand from the second alternative, a comma, and so on until the last
1 alternative.  All operands for a single instruction must have the same
1 number of alternatives.  Here is how it is done for fullword logical-or
1 on the 68000:
1 
1      (define_insn "iorsi3"
1        [(set (match_operand:SI 0 "general_operand" "=m,d")
1              (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
1                      (match_operand:SI 2 "general_operand" "dKs,dmKs")))]
1        ...)
1 
1  The first alternative has 'm' (memory) for operand 0, '0' for operand 1
1 (meaning it must match operand 0), and 'dKs' for operand 2.  The second
1 alternative has 'd' (data register) for operand 0, '0' for operand 1,
1 and 'dmKs' for operand 2.  The '=' and '%' in the constraints apply to
1 all the alternatives; their meaning is explained in the next section
1 (⇒Class Preferences).
1 
1  If all the operands fit any one alternative, the instruction is valid.
1 Otherwise, for each alternative, the compiler counts how many
1 instructions must be added to copy the operands so that that alternative
1 applies.  The alternative requiring the least copying is chosen.  If two
1 alternatives need the same amount of copying, the one that comes first
1 is chosen.  These choices can be altered with the '?' and '!'
1 characters:
1 
1 '?'
1      Disparage slightly the alternative that the '?' appears in, as a
1      choice when no alternative applies exactly.  The compiler regards
1      this alternative as one unit more costly for each '?' that appears
1      in it.
1 
1 '!'
1      Disparage severely the alternative that the '!' appears in.  This
1      alternative can still be used if it fits without reloading, but if
1      reloading is needed, some other alternative will be used.
1 
1 '^'
1      This constraint is analogous to '?' but it disparages slightly the
1      alternative only if the operand with the '^' needs a reload.
1 
1 '$'
1      This constraint is analogous to '!' but it disparages severely the
1      alternative only if the operand with the '$' needs a reload.
1 
1  When an insn pattern has multiple alternatives in its constraints,
1 often the appearance of the assembler code is determined mostly by which
1 alternative was matched.  When this is so, the C code for writing the
1 assembler code can use the variable 'which_alternative', which is the
1 ordinal number of the alternative that was actually satisfied (0 for the
1 first, 1 for the second alternative, etc.).  ⇒Output Statement.
1