Operand Constraints#
Each match_operand in an instruction pattern can specify
constraints for the operands allowed. The constraints allow you to
fine-tune matching within the set of operands allowed by the
predicate.
Constraints can say whether
an operand may be in a register, and which kinds of register; whether the
operand can be a memory reference, and which kinds of address; whether the
operand may be an immediate constant, and which possible values it may
have. Constraints can also require two operands to match.
Side-effects aren’t allowed in operands of inline asm, unless
< or > constraints are used, because there is no guarantee
that the side effects will happen exactly once in an instruction that can update
the addressing register.
Simple Constraints#
The simplest kind of constraint is a string full of letters, each of which describes one kind of operand that is permitted. Here are the letters that are allowed:
- whitespace
Whitespace characters are ignored and can be inserted at any position except the first. This enables each alternative for different operands to be visually aligned in the machine description even if they have different number of constraints and modifiers.
- m
A memory operand is allowed, with any kind of address that the machine supports in general. Note that the letter used for the general memory constraint can be re-defined by a back end using the
TARGET_MEM_CONSTRAINTmacro.- o
A memory operand is allowed, but only if the address is offsettable. This means that adding a small integer (actually, the width in bytes of the operand, as determined by its machine mode) may be added to the address and the result is also a valid memory address.
For example, an address which is constant is offsettable; so is an address that is the sum of a register and a constant (as long as a slightly larger constant is also within the range of address-offsets supported by the machine); but an autoincrement or autodecrement address is not offsettable. More complicated indirect/indexed addresses may or may not be offsettable depending on the other addressing modes that the machine supports.
Note that in an output operand which can be matched by another operand, the constraint letter
ois valid only when accompanied by both<(if the target machine has predecrement addressing) and>(if the target machine has preincrement addressing).- V
A memory operand that is not offsettable. In other words, anything that would fit the
mconstraint but not theoconstraint.
- <
A memory operand with autodecrement addressing (either predecrement or postdecrement) is allowed. In inline
asmthis constraint is only allowed if the operand is used exactly once in an instruction that can handle the side effects. Not using an operand with<in constraint string in the inlineasmpattern at all or using it in multiple instructions isn’t valid, because the side effects wouldn’t be performed or would be performed more than once. Furthermore, on some targets the operand with<in constraint string must be accompanied by special instruction suffixes like%U0instruction suffix on PowerPC or%P0on IA-64.
- >
A memory operand with autoincrement addressing (either preincrement or postincrement) is allowed. In inline
asmthe same restrictions as for<apply.- r
A register operand is allowed provided that it is in a general register.
- i
An immediate integer operand (one with constant value) is allowed. This includes symbolic constants whose values will be known only at assembly time or later.
- n
An immediate integer operand with a known numeric value is allowed. Many systems cannot support assembly-time constants for operands less than a word wide. Constraints for these operands should use
nrather thani.I, J, K, ... POther letters in the range
IthroughPmay be defined in a machine-dependent fashion to permit immediate integer operands with explicit integer values in specified ranges. For example, on the 68000,Iis defined to stand for the range of values 1 to 8. This is the range permitted as a shift count in the shift instructions.- E
An immediate floating operand (expression code
const_double) is allowed, but only if the target floating point format is the same as that of the host machine (on which the compiler is running).- F
An immediate floating operand (expression code
const_doubleorconst_vector) is allowed.G, HGandHmay be defined in a machine-dependent fashion to permit immediate floating operands in particular ranges of values.- s
An immediate integer operand whose value is not an explicit integer is allowed.
This might appear strange; if an insn allows a constant operand with a value not known at compile time, it certainly must allow any known value. So why use
sinstead ofi? Sometimes it allows better code to be generated.For example, on the 68000 in a fullword instruction it is possible to use an immediate operand; but if the immediate value is between -128 and 127, better code results from loading the value into a register and using the register. This is because the load into the register can be done with a
moveqinstruction. We arrange for this to happen by defining the letterKto mean ‘any integer outside the range -128 to 127’, and then specifyingKsin the operand constraints.- g
Any register, memory or immediate integer operand is allowed, except for registers that are not general registers.
X
Any operand whatsoever is allowed, even if it does not satisfy
general_operand. This is normally used in the constraint of amatch_scratchwhen certain alternatives will not actually require a scratch register.
0, 1, 2, ... 9An operand that matches the specified operand number is allowed. If a digit is used together with letters within the same alternative, the digit should come last.
This number is allowed to be more than a single digit. If multiple digits are encountered consecutively, they are interpreted as a single decimal integer. There is scant chance for ambiguity, since to-date it has never been desirable that
10be interpreted as matching either operand 1 or operand 0. Should this be desired, one can use multiple alternatives instead.This is called a matching constraint and what it really means is that the assembler has only a single operand that fills two roles
considered separate in the RTL insn. For example, an add insn has two input operands and one output operand in the RTL, but on most CISC
machines an add instruction really has only two operands, one of them an input-output operand:
addl #35,r12
Matching constraints are used in these circumstances. More precisely, the two operands that match must include one input-only operand and one output-only operand. Moreover, the digit must be a smaller number than the number of the operand that uses it in the constraint.
For operands to match in a particular case usually means that they are identical-looking RTL expressions. But in a few special cases specific kinds of dissimilarity are allowed. For example,
*xas an input operand will match*x++as an output operand. For proper results in such cases, the output template should always use the output-operand’s number when printing the operand.- p
An operand that is a valid memory address is allowed. This is for ‘load address’ and ‘push address’ instructions.
pin the constraint must be accompanied byaddress_operandas the predicate in thematch_operand. This predicate interprets the mode specified in thematch_operandas the mode of the memory reference for which the address would be valid.- other-letters
Other letters can be defined in machine-dependent fashion to stand for particular classes of registers or other arbitrary operand types.
d,aandfare defined on the 68000/68020 to stand for data, address and floating point registers.
In order to have valid assembler code, each operand must satisfy its constraint. But a failure to do so does not prevent the pattern from applying to an insn. Instead, it directs the compiler to modify the code so that the constraint will be satisfied. Usually this is done by copying an operand into a register.
Contrast, therefore, the two instruction patterns that follow:
(define_insn ""
[(set (match_operand:SI 0 "general_operand" "=r")
(plus:SI (match_dup 0)
(match_operand:SI 1 "general_operand" "r")))]
""
"...")
which has two operands, one of which must appear in two places, and
(define_insn ""
[(set (match_operand:SI 0 "general_operand" "=r")
(plus:SI (match_operand:SI 1 "general_operand" "0")
(match_operand:SI 2 "general_operand" "r")))]
""
"...")
which has three operands, two of which are required by a constraint to be identical. If we are considering an insn of the form
(insn n prev next
(set (reg:SI 3)
(plus:SI (reg:SI 6) (reg:SI 109)))
...)
the first pattern would not apply at all, because this insn does not contain two identical subexpressions in the right place. The pattern would say, ‘That does not look like an add instruction; try other patterns’. The second pattern would say, ‘Yes, that’s an add instruction, but there is something wrong with it’. It would direct the reload pass of the compiler to generate additional insns to make the constraint true. The results might look like this:
(insn n2 prev n
(set (reg:SI 3) (reg:SI 6))
...)
(insn n n2 next
(set (reg:SI 3)
(plus:SI (reg:SI 3) (reg:SI 109)))
...)
It is up to you to make sure that each operand, in each pattern, has constraints that can handle any RTL expression that could be present for that operand. (When multiple alternatives are in use, each pattern must, for each possible combination of operand expressions, have at least one alternative which can handle that combination of operands.) The constraints don’t need to allow any possible operand—when this is the case, they do not constrain—but they must at least point the way to reloading any possible operand so that it will fit.
If the constraint accepts whatever operands the predicate permits, there is no problem: reloading is never necessary for this operand.
For example, an operand whose constraints permit everything except registers is safe provided its predicate rejects registers.
An operand whose predicate accepts only constant values is safe provided its constraints include the letter
i. If any possible constant value is accepted, then nothing less thaniwill do; if the predicate is more selective, then the constraints may also be more selective.Any operand expression can be reloaded by copying it into a register. So if an operand’s constraints allow some kind of register, it is certain to be safe. It need not permit all classes of registers; the compiler knows how to copy a register into another register of the proper class in order to make an instruction valid.
A nonoffsettable memory reference can be reloaded by copying the address into a register. So if the constraint uses the letter
o, all memory references are taken care of.A constant operand can be reloaded by allocating space in memory to hold it as preinitialized data. Then the memory reference can be used in place of the constant. So if the constraint uses the letters
oorm, constant operands are not a problem.If the constraint permits a constant and a pseudo register used in an insn was not allocated to a hard register and is equivalent to a constant, the register will be replaced with the constant. If the predicate does not permit a constant and the insn is re-recognized for some reason, the compiler will crash. Thus the predicate must always recognize any objects allowed by the constraint.
If the operand’s predicate can recognize registers, but the constraint does not permit them, it can make the compiler crash. When this operand happens to be a register, the reload pass will be stymied, because it does not know how to copy a register temporarily into memory.
If the predicate accepts a unary operator, the constraint applies to the
operand. For example, the MIPS processor at ISA level 3 supports an
instruction which adds two registers in SImode to produce a
DImode result, but only if the registers are correctly sign
extended. This predicate for the input operands accepts a
sign_extend of an SImode register. Write the constraint
to indicate the type of register that is required for the operand of the
sign_extend.
Multiple Alternative Constraints#
Sometimes a single instruction has multiple alternative sets of possible operands. For example, on the 68000, a logical-or instruction can combine register or an immediate value into memory, or it can combine any kind of operand into a register; but it cannot combine one memory location into another.
These constraints are represented as multiple alternatives. An alternative can be described by a series of letters for each operand. The overall constraint for an operand is made from the letters for this operand from the first alternative, a comma, the letters for this operand from the second alternative, a comma, and so on until the last alternative. All operands for a single instruction must have the same number of alternatives.
Here is how it is done for fullword logical-or on the 68000:
(define_insn "iorsi3"
[(set (match_operand:SI 0 "general_operand" "=m,d")
(ior:SI (match_operand:SI 1 "general_operand" "%0,0")
(match_operand:SI 2 "general_operand" "dKs,dmKs")))]
...)
The first alternative has m (memory) for operand 0, 0 for
operand 1 (meaning it must match operand 0), and dKs for operand
2. The second alternative has d (data register) for operand 0,
0 for operand 1, and dmKs for operand 2. The = and
% in the constraints apply to all the alternatives; their
meaning is explained in the next section (see Register Class Preferences).
If all the operands fit any one alternative, the instruction is valid.
Otherwise, for each alternative, the compiler counts how many instructions
must be added to copy the operands so that that alternative applies.
The alternative requiring the least copying is chosen. If two alternatives
need the same amount of copying, the one that comes first is chosen.
These choices can be altered with the ? and ! characters:
?Disparage slightly the alternative that the
?appears in, as a choice when no alternative applies exactly. The compiler regards this alternative as one unit more costly for each?that appears in it.!Disparage severely the alternative that the
!appears in. This alternative can still be used if it fits without reloading, but if reloading is needed, some other alternative will be used.^This constraint is analogous to
?but it disparages slightly the alternative only if the operand with the^needs a reload.$This constraint is analogous to
!but it disparages severely the alternative only if the operand with the$needs a reload.
When an insn pattern has multiple alternatives in its constraints, often
the appearance of the assembler code is determined mostly by which
alternative was matched. When this is so, the C code for writing the
assembler code can use the variable which_alternative, which is
the ordinal number of the alternative that was actually satisfied (0 for
the first, 1 for the second alternative, etc.). See C Statements for Assembler Output.
Register Class Preferences#
The operand constraints have another function: they enable the compiler
to decide which kind of hardware register a pseudo register is best
allocated to. The compiler examines the constraints that apply to the
insns that use the pseudo register, looking for the machine-dependent
letters such as d and a that specify classes of registers.
The pseudo register is put in whichever class gets the most ‘votes’.
The constraint letters g and r also vote: they vote in
favor of a general register. The machine description says which registers
are considered general.
Of course, on some machines all registers are equivalent, and no register classes are defined. Then none of this complexity is relevant.
Constraint Modifier Characters#
Here are constraint modifier characters.
=Means that this operand is written to by this instruction: the previous value is discarded and replaced by new data.
+Means that this operand is both read and written by the instruction.
When the compiler fixes up the operands to satisfy the constraints, it needs to know which operands are read by the instruction and which are written by it.
=identifies an operand which is only written;+identifies an operand that is both read and written; all other operands are assumed to only be read.If you specify
=or+in a constraint, you put it in the first character of the constraint string.&Means (in a particular alternative) that this operand is an earlyclobber operand, which is written before the instruction is finished using the input operands. Therefore, this operand may not lie in a register that is read by the instruction or as part of any memory address.
&applies only to the alternative in which it is written. In constraints with multiple alternatives, sometimes one alternative requires&while others do not. See, for example, themovdfinsn of the 68000.An operand which is read by the instruction can be tied to an earlyclobber operand if its only use as an input occurs before the early result is written. Adding alternatives of this form often allows GCC to produce better code when only some of the read operands can be affected by the earlyclobber. See, for example, the
mulsi3insn of the ARM.Furthermore, if the earlyclobber operand is also a read/write operand, then that operand is written only after it’s used.
&does not obviate the need to write=or+. As earlyclobber operands are always written, a read-only earlyclobber operand is ill-formed and will be rejected by the compiler.%Declares the instruction to be commutative for this operand and the following operand. This means that the compiler may interchange the two operands if that is the cheapest way to make all operands fit the constraints.
%applies to all alternatives and must appear as the first character in the constraint. Only read-only operands can use%.This is often used in patterns for addition instructions that really have only two operands: the result must go in one of the arguments. Here for example, is how the 68000 halfword-add instruction is defined:
(define_insn "addhi3" [(set (match_operand:HI 0 "general_operand" "=m,r") (plus:HI (match_operand:HI 1 "general_operand" "%0,0") (match_operand:HI 2 "general_operand" "di,g")))] ...)
GCC can only handle one commutative pair in an asm; if you use more, the compiler may fail. Note that you need not use the modifier if the two alternatives are strictly identical; this would only waste time in the reload pass.
The modifier is not operational after register allocation, so the result of
define_peephole2anddefine_splits performed after reload cannot rely on%to make the intended insn match.#Says that all following characters, up to the next comma, are to be ignored as a constraint. They are significant only for choosing register preferences.
*Says that the following character should be ignored when choosing register preferences.
*has no effect on the meaning of the constraint as a constraint, and no effect on reloading. For LRA*additionally disparages slightly the alternative if the following character matches the operand.Here is an example: the 68000 has an instruction to sign-extend a halfword in a data register, and can also sign-extend a value by copying it into an address register. While either kind of register is acceptable, the constraints on an address-register destination are less strict, so it is best if register allocation makes an address register its goal. Therefore,
*is used so that thedconstraint letter (for data register) is ignored when computing register preferences.(define_insn "extendhisi2" [(set (match_operand:SI 0 "general_operand" "=*d,a") (sign_extend:SI (match_operand:HI 1 "general_operand" "0,g")))] ...)
Constraints for Particular Machines#
Whenever possible, you should use the general-purpose constraint letters
in asm arguments, since they will convey meaning more readily to
people reading your code. Failing that, use the constraint letters
that usually have very similar meanings across architectures. The most
commonly used constraints are m and r (for memory and
general-purpose registers respectively; see Simple Constraints), and
I, usually the letter indicating the most common
immediate-constant format.
Each architecture defines additional constraints. These constraints
are used by the compiler itself for instruction generation, as well as
for asm statements; therefore, some of the constraints are not
particularly useful for asm. Here is a summary of some of the
machine-dependent constraints available on some particular machines;
it includes both constraints that are useful for asm and
constraints that aren’t. The compiler source file mentioned in the
table heading for each architecture is the definitive reference for
the meanings of that architecture’s constraints.
AArch64 family—config/aarch64/constraints.md#
kThe stack pointer register (
SP)wFloating point register, Advanced SIMD vector register or SVE vector register
xLike
w, but restricted to registers 0 to 15 inclusive.yLike
w, but restricted to registers 0 to 7 inclusive.UplOne of the low eight SVE predicate registers (
P0toP7)UpaAny of the SVE predicate registers (
P0toP15)IInteger constant that is valid as an immediate operand in an
ADDinstructionJInteger constant that is valid as an immediate operand in a
SUBinstruction (once negated)KInteger constant that can be used with a 32-bit logical instruction
LInteger constant that can be used with a 64-bit logical instruction
MInteger constant that is valid as an immediate operand in a 32-bit
MOVpseudo instruction. TheMOVmay be assembled to one of several different machine instructions depending on the valueNInteger constant that is valid as an immediate operand in a 64-bit
MOVpseudo instructionSAn absolute symbolic address or a label reference
YFloating point constant zero
ZInteger constant zero
UshThe high part (bits 12 and upwards) of the pc-relative address of a symbol within 4GB of the instruction
QA memory address which uses a single base register with no offset
UmpA memory address suitable for a load/store pair instruction in SI, DI, SF and DF modes
AMD GCN —config/gcn/constraints.md#
IImmediate integer in the range -16 to 64
JImmediate 16-bit signed integer
KfImmediate constant -1
LImmediate 15-bit unsigned integer
AImmediate constant that can be inlined in an instruction encoding: integer -16..64, or float 0.0, +/-0.5, +/-1.0, +/-2.0, +/-4.0, 1.0/(2.0*PI)
BImmediate 32-bit signed integer that can be attached to an instruction encoding
CImmediate 32-bit integer in range -16..4294967295 (i.e. 32-bit unsigned integer or
Aconstraint)DAImmediate 64-bit constant that can be split into two
AconstantsDBImmediate 64-bit constant that can be split into two
BconstantsUAny
unspecYAny
symbol_reforlabel_refvVGPR register
SgSGPR register
SDSGPR registers valid for instruction destinations, including VCC, M0 and EXEC
SSSGPR registers valid for instruction sources, including VCC, M0, EXEC and SCC
SmSGPR registers valid as a source for scalar memory instructions (excludes M0 and EXEC)
SvSGPR registers valid as a source or destination for vector instructions (excludes EXEC)
caAll condition registers: SCC, VCCZ, EXECZ
csScalar condition register: SCC
cVVector condition register: VCC, VCC_LO, VCC_HI
eEXEC register (EXEC_LO and EXEC_HI)
RBMemory operand with address space suitable for
buffer_*instructionsRFMemory operand with address space suitable for
flat_*instructionsRSMemory operand with address space suitable for
s_*instructionsRLMemory operand with address space suitable for
ds_*LDS instructionsRGMemory operand with address space suitable for
ds_*GDS instructionsRDMemory operand with address space suitable for any
ds_*instructionsRMMemory operand with address space suitable for
global_*instructions
ARC —config/arc/constraints.md#
qRegisters usable in ARCompact 16-bit instructions:
r0-r3,r12-r15. This constraint can only match when the-mqoption is in effect.eRegisters usable as base-regs of memory addresses in ARCompact 16-bit memory instructions:
r0-r3,r12-r15,sp. This constraint can only match when the-mqoption is in effect.DARC FPX (dpfp) 64-bit registers.
D0,D1.IA signed 12-bit integer constant.
Calconstant for arithmetic/logical operations. This might be any constant that can be put into a long immediate by the assmbler or linker without involving a PIC relocation.
KA 3-bit unsigned integer constant.
LA 6-bit unsigned integer constant.
CnLOne’s complement of a 6-bit unsigned integer constant.
CmLTwo’s complement of a 6-bit unsigned integer constant.
MA 5-bit unsigned integer constant.
OA 7-bit unsigned integer constant.
PA 8-bit unsigned integer constant.
HAny const_double value.
ARM family—config/arm/constraints.md#
hIn Thumb state, the core registers
r8-r15.kThe stack pointer register.
lIn Thumb State the core registers
r0-r7. In ARM state this is an alias for therconstraint.tVFP floating-point registers
s0-s31. Used for 32 bit values.wVFP floating-point registers
d0-d31and the appropriate subsetd0-d15based on command line options. Used for 64 bit values only. Not valid for Thumb1.yThe iWMMX co-processor registers.
zThe iWMMX GR registers.
GThe floating-point constant 0.0
IInteger that is valid as an immediate operand in a data processing instruction. That is, an integer in the range 0 to 255 rotated by a multiple of 2
JInteger in the range -4095 to 4095
KInteger that satisfies constraint
Iwhen inverted (ones complement)LInteger that satisfies constraint
Iwhen negated (twos complement)MInteger in the range 0 to 32
QA memory reference where the exact address is in a single register (’
m’ is preferable forasmstatements)RAn item in the constant pool
SA symbol in the text segment of the current file
UvA memory reference suitable for VFP load/store insns (reg+constant offset)
UyA memory reference suitable for iWMMXt load/store instructions.
UqA memory reference suitable for the ARMv4 ldrsb instruction.
AVR family—config/avr/constraints.md#
lRegisters from r0 to r15
aRegisters from r16 to r23
dRegisters from r16 to r31
wRegisters from r24 to r31. These registers can be used in
adiwcommandePointer register (r26–r31)
bBase pointer register (r28–r31)
qStack pointer register (SPH:SPL)
tTemporary register r0
xRegister pair X (r27:r26)
yRegister pair Y (r29:r28)
zRegister pair Z (r31:r30)
IConstant greater than -1, less than 64
JConstant greater than -64, less than 1
KConstant integer 2
LConstant integer 0
MConstant that fits in 8 bits
NConstant integer -1
OConstant integer 8, 16, or 24
PConstant integer 1
GA floating point constant 0.0
QA memory address based on Y or Z pointer with displacement.
Blackfin family—config/bfin/constraints.md#
aP register
dD register
zA call clobbered P register.
qnA single register. If
nis in the range 0 to 7, the corresponding D register. If it isA, then the register P0.DEven-numbered D register
WOdd-numbered D register
eAccumulator register.
AEven-numbered accumulator register.
BOdd-numbered accumulator register.
bI register
vB register
fM register
cRegisters used for circular buffering, i.e. I, B, or L registers.
CThe CC register.
tLT0 or LT1.
kLC0 or LC1.
uLB0 or LB1.
xAny D, P, B, M, I or L register.
yAdditional registers typically used only in prologues and epilogues: RETS, RETN, RETI, RETX, RETE, ASTAT, SEQSTAT and USP.
wAny register except accumulators or CC.
KshSigned 16 bit integer (in the range -32768 to 32767)
KuhUnsigned 16 bit integer (in the range 0 to 65535)
Ks7Signed 7 bit integer (in the range -64 to 63)
Ku7Unsigned 7 bit integer (in the range 0 to 127)
Ku5Unsigned 5 bit integer (in the range 0 to 31)
Ks4Signed 4 bit integer (in the range -8 to 7)
Ks3Signed 3 bit integer (in the range -3 to 4)
Ku3Unsigned 3 bit integer (in the range 0 to 7)
PnConstant
n, wherenis a single-digit constant in the range 0 to 4.PAAn integer equal to one of the MACFLAG_XXX constants that is suitable for use with either accumulator.
PBAn integer equal to one of the MACFLAG_XXX constants that is suitable for use only with accumulator A1.
M1Constant 255.
M2Constant 65535.
JAn integer constant with exactly a single bit set.
LAn integer constant with all bits set except exactly one.
H, Q
Any SYMBOL_REF.
C-SKY—config/csky/constraints.md
aThe mini registers r0 - r7.
bThe low registers r0 - r15.
cC register.
yHI and LO registers.
lLO register.
hHI register.
vVector registers.
zStack pointer register (SP).
QA memory address which uses a base register with a short offset or with a index register with its scale.
WA memory address which uses a base register with a index register with its scale.
The C-SKY back end supports a large set of additional constraints that are only useful for instruction selection or splitting rather than inline asm, such as constraints representing constant integer ranges accepted by particular instruction encodings. Refer to the source code for details.
Epiphany—config/epiphany/constraints.md#
U16An unsigned 16-bit constant.
KAn unsigned 5-bit constant.
LA signed 11-bit constant.
Cm1A signed 11-bit constant added to -1. Can only match when the
-m1reg-regoption is active.Cl1Left-shift of -1, i.e., a bit mask with a block of leading ones, the rest being a block of trailing zeroes. Can only match when the
-m1reg-regoption is active.Cr1Right-shift of -1, i.e., a bit mask with a trailing block of ones, the rest being zeroes. Or to put it another way, one less than a power of two. Can only match when the
-m1reg-regoption is active.CalConstant for arithmetic/logical operations. This is like
i, except that for position independent code, no symbols / expressions needing relocations are allowed.CsySymbolic constant for call/jump instruction.
RcsThe register class usable in short insns. This is a register class constraint, and can thus drive register allocation. This constraint won’t match unless
-mprefer-short-insn-regsis in effect.RscThe register class of registers that can be used to hold a sibcall call address. I.e., a caller-saved register.
RctCore control register class.
RgsThe register group usable in short insns. This constraint does not use a register class, so that it only passively matches suitable registers, and doesn’t drive register allocation.
CarConstant suitable for the addsi3_r pattern. This is a valid offset For byte, halfword, or word addressing.
RraMatches the return address if it can be replaced with the link register.
RccMatches the integer condition code register.
SraMatches the return address if it is in a stack slot.
CfmMatches control register values to switch fp mode, which are encapsulated in
UNSPEC_FP_MODE.
FRV—config/frv/frv.h#
aRegister in the class
ACC_REGS(acc0toacc7).bRegister in the class
EVEN_ACC_REGS(acc0toacc7).cRegister in the class
CC_REGS(fcc0tofcc3andicc0toicc3).dRegister in the class
GPR_REGS(gr0togr63).eRegister in the class
EVEN_REGS(gr0togr63). Odd registers are excluded not in the class but through the use of a machine mode larger than 4 bytes.fRegister in the class
FPR_REGS(fr0tofr63).hRegister in the class
FEVEN_REGS(fr0tofr63). Odd registers are excluded not in the class but through the use of a machine mode larger than 4 bytes.lRegister in the class
LR_REG(thelrregister).qRegister in the class
QUAD_REGS(gr2togr63). Register numbers not divisible by 4 are excluded not in the class but through the use of a machine mode larger than 8 bytes.tRegister in the class
ICC_REGS(icc0toicc3).uRegister in the class
FCC_REGS(fcc0tofcc3).vRegister in the class
ICR_REGS(cc4tocc7).wRegister in the class
FCR_REGS(cc0tocc3).xRegister in the class
QUAD_FPR_REGS(fr0tofr63). Register numbers not divisible by 4 are excluded not in the class but through the use of a machine mode larger than 8 bytes.zRegister in the class
SPR_REGS(lcrandlr).ARegister in the class
QUAD_ACC_REGS(acc0toacc7).BRegister in the class
ACCG_REGS(accg0toaccg7).CRegister in the class
CR_REGS(cc0tocc7).GFloating point constant zero
I6-bit signed integer constant
J10-bit signed integer constant
L16-bit signed integer constant
M16-bit unsigned integer constant
N12-bit signed integer constant that is negative—i.e. in the range of -2048 to -1
OConstant zero
P12-bit signed integer constant that is greater than zero—i.e. in the range of 1 to 2047.
FT32—config/ft32/constraints.md#
AAn absolute address
BAn offset address
WA register indirect memory operand
eAn offset address.
fAn offset address.
OThe constant zero or one
IA 16-bit signed constant (-32768 … 32767)
wA bitfield mask suitable for bext or bins
xAn inverted bitfield mask suitable for bext or bins
LA 16-bit unsigned constant, multiple of 4 (0 … 65532)
SA 20-bit signed constant (-524288 … 524287)
bA constant for a bitfield width (1 … 16)
KAA 10-bit signed constant (-512 … 511)
Hewlett-Packard PA-RISC—config/pa/pa.h#
aGeneral register 1
fFloating point register
qShift amount register
xFloating point register (deprecated)
yUpper floating point register (32-bit), floating point register (64-bit)
ZAny register
ISigned 11-bit integer constant
JSigned 14-bit integer constant
KInteger constant that can be deposited with a
zdepiinstructionLSigned 5-bit integer constant
MInteger constant 0
NInteger constant that can be loaded with a
ldilinstructionOInteger constant whose value plus one is a power of 2
PInteger constant that can be used for
andoperations indepiandextruinstructionsSInteger constant 31
UInteger constant 63
GFloating-point constant 0.0
AA
lo_sumdata-linkage-table memory operandQA memory operand that can be used as the destination operand of an integer store instruction
RA scaled or unscaled indexed memory operand
TA memory operand for floating-point loads and stores
WA register indirect memory operand
Intel IA-64—config/ia64/ia64.h#
aGeneral register
r0tor3foraddlinstructionbBranch register
cPredicate register (
cas in ‘conditional’)dApplication register residing in M-unit
eApplication register residing in I-unit
fFloating-point register
mMemory operand. If used together with
<or>, the operand can have postincrement and postdecrement which require printing with%Pnon IA-64.GFloating-point constant 0.0 or 1.0
I14-bit signed integer constant
J22-bit signed integer constant
K8-bit signed integer constant for logical instructions
L8-bit adjusted signed integer constant for compare pseudo-ops
M6-bit unsigned integer constant for shift counts
N9-bit signed integer constant for load and store postincrements
OThe constant zero
P0 or -1 for
depinstructionQNon-volatile memory for floating-point loads and stores
RInteger constant in the range 1 to 4 for
shladdinstructionSMemory operand except postincrement and postdecrement. This is now roughly the same as
mwhen not used together with<or>.
M32C—config/m32c/m32c.cc#
RspRfbRsb$sp,$fb,$sb.RcrAny control register, when they’re 16 bits wide (nothing if control registers are 24 bits wide)
RclAny control register, when they’re 24 bits wide.
R0wR1wR2wR3w$r0, $r1, $r2, $r3.
R02$r0 or $r2, or $r2r0 for 32 bit values.
R13$r1 or $r3, or $r3r1 for 32 bit values.
RdiA register that can hold a 64 bit value.
Rhl$r0 or $r1 (registers with addressable high/low bytes)
R23$r2 or $r3
RaaAddress registers
RawAddress registers when they’re 16 bits wide.
RalAddress registers when they’re 24 bits wide.
RqiRegisters that can hold QI values.
RadRegisters that can be used with displacements ($a0, $a1, $sb).
RsiRegisters that can hold 32 bit values.
RhiRegisters that can hold 16 bit values.
RhcRegisters chat can hold 16 bit values, including all control registers.
Rra$r0 through R1, plus $a0 and $a1.
RflThe flags register.
RmmThe memory-based pseudo-registers $mem0 through $mem15.
RpiRegisters that can hold pointers (16 bit registers for r8c, m16c; 24 bit registers for m32cm, m32c).
RpaMatches multiple registers in a PARALLEL to form a larger register. Used to match function return values.
Is3-8 … 7
IS1-128 … 127
IS2-32768 … 32767
IU20 … 65535
In4-8 … -1 or 1 … 8
In5-16 … -1 or 1 … 16
In6-32 … -1 or 1 … 32
IM2-65536 … -1
IlbAn 8 bit value with exactly one bit set.
IlwA 16 bit value with exactly one bit set.
SdThe common src/dest memory addressing modes.
SaMemory addressed using $a0 or $a1.
SiMemory addressed with immediate addresses.
SsMemory addressed using the stack pointer ($sp).
SfMemory addressed using the frame base register ($fb).
SsMemory addressed using the small base register ($sb).
S1$r1h
LoongArch—config/loongarch/constraints.md#
fA floating-point register (if available).
kA memory operand whose address is formed by a base register and (optionally scaled) index register.
lA signed 16-bit constant.
mA memory operand whose address is formed by a base register and offset that is suitable for use in instructions with the same addressing mode as
st.wandld.w.IA signed 12-bit constant (for arithmetic instructions).
KAn unsigned 12-bit constant (for logic instructions).
ZBAn address that is held in a general-purpose register. The offset is zero.
ZCA memory operand whose address is formed by a base register and offset that is suitable for use in instructions with the same addressing mode as
ll.wandsc.w.
MicroBlaze—config/microblaze/constraints.md#
dA general register (
r0tor31).zA status register (
rmsr,$fcc1to$fcc7).
MIPS—config/mips/constraints.md#
dA general-purpose register. This is equivalent to
runless generating MIPS16 code, in which case the MIPS16 register set is used.fA floating-point register (if available).
hFormerly the
hiregister. This constraint is no longer supported.lThe
loregister. Use this register to store values that are no bigger than a word.xThe concatenated
hiandloregisters. Use this register to store doubleword values.cA register suitable for use in an indirect jump. This will always be
$25for-mabicalls.vRegister
$3. Do not use this constraint in new code; it is retained only for compatibility with glibc.yEquivalent to
r; retained for backwards compatibility.zA floating-point condition code register.
IA signed 16-bit constant (for arithmetic instructions).
JInteger zero.
KAn unsigned 16-bit constant (for logic instructions).
LA signed 32-bit constant in which the lower 16 bits are zero. Such constants can be loaded using
lui.MA constant that cannot be loaded using
lui,addiuorori.NA constant in the range -65535 to -1 (inclusive).
OA signed 15-bit constant.
PA constant in the range 1 to 65535 (inclusive).
GFloating-point zero.
RAn address that can be used in a non-macro load or store.
ZCA memory operand whose address is formed by a base register and offset that is suitable for use in instructions with the same addressing mode as
llandsc.ZDAn address suitable for a
prefetchinstruction, or for any other instruction with the same addressing mode asprefetch.
Motorola 680x0—config/m68k/constraints.md#
aAddress register
dData register
f68881 floating-point register, if available
IInteger in the range 1 to 8
J16-bit signed number
KSigned number whose magnitude is greater than 0x80
LInteger in the range -8 to -1
MSigned number whose magnitude is greater than 0x100
NRange 24 to 31, rotatert:SI 8 to 1 expressed as rotate
O16 (for rotate using swap)
PRange 8 to 15, rotatert:HI 8 to 1 expressed as rotate
RNumbers that mov3q can handle
GFloating point constant that is not a 68881 constant
SOperands that satisfy ‘m’ when -mpcrel is in effect
TOperands that satisfy ‘s’ when -mpcrel is not in effect
QAddress register indirect addressing mode
URegister offset addressing
Wconst_call_operand
Cssymbol_ref or const
Ciconst_int
C0const_int 0
CjRange of signed numbers that don’t fit in 16 bits
CmvqIntegers valid for mvq
CapswIntegers valid for a moveq followed by a swap
CmvzIntegers valid for mvz
CmvsIntegers valid for mvs
Appush_operand
AcNon-register operands allowed in clr
Moxie—config/moxie/constraints.md#
AAn absolute address
BAn offset address
WA register indirect memory operand
IA constant in the range of 0 to 255.
NA constant in the range of 0 to -255.
MSP430—config/msp430/constraints.md#
R12Register R12.
R13Register R13.
KInteger constant 1.
LInteger constant -1^20..1^19.
MInteger constant 1-4.
YaMemory references which do not require an extended MOVX instruction.
YlMemory reference, labels only.
YsMemory reference, stack only.
NDS32—config/nds32/constraints.md#
wLOW register class $r0 to $r7 constraint for V3/V3M ISA.
lLOW register class $r0 to $r7.
dMIDDLE register class $r0 to $r11, $r16 to $r19.
hHIGH register class $r12 to $r14, $r20 to $r31.
tTemporary assist register $ta (i.e. $r15).
kStack register $sp.
Iu03Unsigned immediate 3-bit value.
In03Negative immediate 3-bit value in the range of -7–0.
Iu04Unsigned immediate 4-bit value.
Is05Signed immediate 5-bit value.
Iu05Unsigned immediate 5-bit value.
In05Negative immediate 5-bit value in the range of -31–0.
Ip05Unsigned immediate 5-bit value for movpi45 instruction with range 16–47.
Iu06Unsigned immediate 6-bit value constraint for addri36.sp instruction.
Iu08Unsigned immediate 8-bit value.
Iu09Unsigned immediate 9-bit value.
Is10Signed immediate 10-bit value.
Is11Signed immediate 11-bit value.
Is15Signed immediate 15-bit value.
Iu15Unsigned immediate 15-bit value.
Ic15A constant which is not in the range of imm15u but ok for bclr instruction.
Ie15A constant which is not in the range of imm15u but ok for bset instruction.
It15A constant which is not in the range of imm15u but ok for btgl instruction.
Ii15A constant whose compliment value is in the range of imm15u and ok for bitci instruction.
Is16Signed immediate 16-bit value.
Is17Signed immediate 17-bit value.
Is19Signed immediate 19-bit value.
Is20Signed immediate 20-bit value.
IhigThe immediate value that can be simply set high 20-bit.
IzebThe immediate value 0xff.
IzehThe immediate value 0xffff.
IxlsThe immediate value 0x01.
Ix11The immediate value 0x7ff.
IbmsThe immediate value with power of 2.
IfexThe immediate value with power of 2 minus 1.
U33Memory constraint for 333 format.
U45Memory constraint for 45 format.
U37Memory constraint for 37 format.
Nios II family—config/nios2/constraints.md#
IInteger that is valid as an immediate operand in an instruction taking a signed 16-bit number. Range -32768 to 32767.
JInteger that is valid as an immediate operand in an instruction taking an unsigned 16-bit number. Range 0 to 65535.
KInteger that is valid as an immediate operand in an instruction taking only the upper 16-bits of a 32-bit number. Range 32-bit numbers with the lower 16-bits being 0.
LInteger that is valid as an immediate operand for a shift instruction. Range 0 to 31.
MInteger that is valid as an immediate operand for only the value 0. Can be used in conjunction with the format modifier
zto user0instead of0in the assembly output.NInteger that is valid as an immediate operand for a custom instruction opcode. Range 0 to 255.
PAn immediate operand for R2 andchi/andci instructions.
SMatches immediates which are addresses in the small data section and therefore can be added to
gpas a 16-bit immediate to re-create their 32-bit value.UMatches constants suitable as an operand for the rdprs and cache instructions.
vA memory operand suitable for Nios II R2 load/store exclusive instructions.
wA memory operand suitable for load/store IO and cache instructions.
TA
constwrappedUNSPECexpression, representing a supported PIC or TLS relocation.
OpenRISC—config/or1k/constraints.md#
IInteger that is valid as an immediate operand in an instruction taking a signed 16-bit number. Range -32768 to 32767.
KInteger that is valid as an immediate operand in an instruction taking an unsigned 16-bit number. Range 0 to 65535.
MSigned 16-bit constant shifted left 16 bits. (Used with
l.movhi)OZero
cRegister usable for sibcalls.
PDP-11—config/pdp11/constraints.md#
aFloating point registers AC0 through AC3. These can be loaded from/to memory with a single instruction.
dOdd numbered general registers (R1, R3, R5). These are used for 16-bit multiply operations.
DA memory reference that is encoded within the opcode, but not auto-increment or auto-decrement.
fAny of the floating point registers (AC0 through AC5).
GFloating point constant 0.
hFloating point registers AC4 and AC5. These cannot be loaded from/to memory with a single instruction.
IAn integer constant that fits in 16 bits.
JAn integer constant whose low order 16 bits are zero.
KAn integer constant that does not meet the constraints for codes
IorJ.LThe integer constant 1.
MThe integer constant -1.
NThe integer constant 0.
OInteger constants 0 through 3; shifts by these amounts are handled as multiple single-bit shifts rather than a single variable-length shift.
QA memory reference which requires an additional word (address or offset) after the opcode.
RA memory reference that is encoded within the opcode.
PowerPC and IBM RS6000—config/rs6000/constraints.md#
rA general purpose register (GPR),
r0…r31.bA base register. Like
r, butr0is not allowed, sor1…r31.fA floating point register (FPR),
f0…f31.dA floating point register. This is the same as
fnowadays; historicallyfwas for single-precision anddwas for double-precision floating point.vAn Altivec vector register (VR),
v0…v31.waA VSX register (VSR),
vs0…vs63. This is either an FPR (vs0…vs31aref0…f31) or a VR (vs32…vs63arev0…v31).When using
wa, you should use the%xoutput modifier, so that the correct register number is printed. For example:asm ("xvadddp %x0,%x1,%x2" : "=wa" (v1) : "wa" (v2), "wa" (v3));
You should not use
%xforvoperands:asm ("xsaddqp %0,%1,%2" : "=v" (v1) : "v" (v2), "v" (v3));
hA special register (
vrsave,ctr, orlr).
cThe count register,
ctr.lThe link register,
lr.xCondition register field 0,
cr0.yAny condition register field,
cr0…cr7.
zThe carry bit,
XER[CA].weLike
wa, if-mpower9-vectorand-m64are used; otherwise,NO_REGS.wnNo register (
NO_REGS).wrLike
r, if-mpowerpc64is used; otherwise,NO_REGS.wxLike
d, if-mpowerpc-gfxoptis used; otherwise,NO_REGS.wALike
b, if-mpowerpc64is used; otherwise,NO_REGS.wBSigned 5-bit constant integer that can be loaded into an Altivec register.
wEVector constant that can be loaded with the XXSPLTIB instruction.
wFMemory operand suitable for power8 GPR load fusion.
wLInt constant that is the element number mfvsrld accesses in a vector.
wMMatch vector constant with all 1’s if the XXLORC instruction is available.
wOMemory operand suitable for the ISA 3.0 vector d-form instructions.
wQMemory operand suitable for the load/store quad instructions.
wSVector constant that can be loaded with XXSPLTIB & sign extension.
wYA memory operand for a DS-form instruction.
wZAn indexed or indirect memory operand, ignoring the bottom 4 bits.
IA signed 16-bit constant.
JAn unsigned 16-bit constant shifted left 16 bits (use
Linstead forSImodeconstants).KAn unsigned 16-bit constant.
LA signed 16-bit constant shifted left 16 bits.
MAn integer constant greater than 31.
NAn exact power of 2.
OThe integer constant zero.
PA constant whose negation is a signed 16-bit constant.
eIA signed 34-bit integer constant if prefixed instructions are supported.
eQAn IEEE 128-bit constant that can be loaded into a VSX register with the
lxvkqinstruction.
GA floating point constant that can be loaded into a register with one instruction per word.
HA floating point constant that can be loaded into a register using three instructions.
mA memory operand. Normally,
mdoes not allow addresses that update the base register. If the<or>constraint is also used, they are allowed and therefore on PowerPC targets in that case it is only safe to usem<>in anasmstatement if thatasmstatement accesses the operand exactly once. Theasmstatement must also use%U<opno>as a placeholder for the ‘update’ flag in the corresponding load or store instruction. For example:asm ("st%U0 %1,%0" : "=m<>" (mem) : "r" (val));
is correct but:
asm ("st %1,%0" : "=m<>" (mem) : "r" (val));
is not.
esA ‘stable’ memory operand; that is, one which does not include any automodification of the base register. This used to be useful when
mallowed automodification of the base register, but as those are now only allowed when<or>is used,esis basically the same asmwithout<and>.
QA memory operand addressed by just a base register.
YA memory operand for a DQ-form instruction.
ZA memory operand accessed with indexed or indirect addressing.
RAn AIX TOC entry.
aAn indexed or indirect address.
UA V.4 small data reference.
WA vector constant that does not require memory.
jThe zero vector constant.
PRU—config/pru/constraints.md#
IAn unsigned 8-bit integer constant.
JAn unsigned 16-bit integer constant.
LAn unsigned 5-bit integer constant (for shift counts).
TA text segment (program memory) constant label.
ZInteger constant zero.
RL78—config/rl78/constraints.md#
Int3An integer constant in the range 1 … 7.
Int8An integer constant in the range 0 … 255.
JAn integer constant in the range -255 … 0
KThe integer constant 1.
LThe integer constant -1.
MThe integer constant 0.
NThe integer constant 2.
OThe integer constant -2.
PAn integer constant in the range 1 … 15.
QbiThe built-in compare types–eq, ne, gtu, ltu, geu, and leu.
QscThe synthetic compare types–gt, lt, ge, and le.
WabA memory reference with an absolute address.
WbcA memory reference using
BCas a base register, with an optional offset.WcaA memory reference using
AX,BC,DE, orHLfor the address, for calls.WcvA memory reference using any 16-bit register pair for the address, for calls.
Wd2A memory reference using
DEas a base register, with an optional offset.WdeA memory reference using
DEas a base register, without any offset.WfrAny memory reference to an address in the far address space.
Wh1A memory reference using
HLas a base register, with an optional one-byte offset.WhbA memory reference using
HLas a base register, withBorCas the index register.WhlA memory reference using
HLas a base register, without any offset.Ws1A memory reference using
SPas a base register, with an optional one-byte offset.YAny memory reference to an address in the near address space.
AThe
AXregister.BThe
BCregister.DThe
DEregister.RAthroughLregisters.SThe
SPregister.TThe
HLregister.Z08WThe 16-bit
R8register.Z10WThe 16-bit
R10register.ZintThe registers reserved for interrupts (
R24toR31).aThe
Aregister.bThe
Bregister.cThe
Cregister.dThe
Dregister.eThe
Eregister.hThe
Hregister.lThe
Lregister.vThe virtual registers.
wThe
PSWregister.xThe
Xregister.
RISC-V—config/riscv/constraints.md#
fA floating-point register (if available).
IAn I-type 12-bit signed immediate.
JInteger zero.
KA 5-bit unsigned immediate for CSR access instructions.
AAn address that is held in a general-purpose register.
SA constraint that matches an absolute symbolic address.
RX—config/rx/constraints.md#
QAn address which does not involve register indirect addressing or pre/post increment/decrement addressing.
SymbolA symbol reference.
Int08A constant in the range -256 to 255, inclusive.
Sint08A constant in the range -128 to 127, inclusive.
Sint16A constant in the range -32768 to 32767, inclusive.
Sint24A constant in the range -8388608 to 8388607, inclusive.
Uint04A constant in the range 0 to 15, inclusive.
S/390 and zSeries—config/s390/s390.h#
aAddress register (general purpose register except r0)
cCondition code register
dData register (arbitrary general purpose register)
fFloating-point register
IUnsigned 8-bit constant (0–255)
JUnsigned 12-bit constant (0–4095)
KSigned 16-bit constant (-32768–32767)
LValue appropriate as displacement.
(0..4095)for short displacement
(-524288..524287)for long displacement
MConstant integer with a value of 0x7fffffff.
NMultiple letter constraint followed by 4 parameter letters.
0..9:number of the part counting from most to least significant
H,Q:mode of the part
D,S,H:mode of the containing operand
0,F:value of the other parts (F—all bits set)
The constraint matches if the specified part of a constant has a value different from its other parts.
QMemory reference without index register and with short displacement.
RMemory reference with index register and short displacement.
SMemory reference without index register but with long displacement.
TMemory reference with index register and long displacement.
UPointer with short displacement.
WPointer with long displacement.
YShift count operand.
SPARC—config/sparc/sparc.h#
fFloating-point register on the SPARC-V8 architecture and lower floating-point register on the SPARC-V9 architecture.
eFloating-point register. It is equivalent to
fon the SPARC-V8 architecture and contains both lower and upper floating-point registers on the SPARC-V9 architecture.cFloating-point condition code register.
dLower floating-point register. It is only valid on the SPARC-V9 architecture when the Visual Instruction Set is available.
bFloating-point register. It is only valid on the SPARC-V9 architecture when the Visual Instruction Set is available.
h64-bit global or out register for the SPARC-V8+ architecture.
CThe constant all-ones, for floating-point.
ASigned 5-bit constant
DA vector constant
ISigned 13-bit constant
JZero
K32-bit constant with the low 12 bits clear (a constant that can be loaded with the
sethiinstruction)LA constant in the range supported by
movccinstructions (11-bit signed immediate)MA constant in the range supported by
movrccinstructions (10-bit signed immediate)NSame as
K, except that it verifies that bits that are not in the lower 32-bit range are all zero. Must be used instead ofKfor modes wider thanSImodeOThe constant 4096
GFloating-point zero
HSigned 13-bit constant, sign-extended to 32 or 64 bits
PThe constant -1
QFloating-point constant whose integral representation can be moved into an integer register using a single sethi instruction
RFloating-point constant whose integral representation can be moved into an integer register using a single mov instruction
SFloating-point constant whose integral representation can be moved into an integer register using a high/lo_sum instruction sequence
TMemory address aligned to an 8-byte boundary
UEven register
WMemory address for
econstraint registerswMemory address with only a base register
YVector zero
TI C6X family—config/c6x/constraints.md#
aRegister file A (A0–A31).
bRegister file B (B0–B31).
APredicate registers in register file A (A0–A2 on C64X and higher, A1 and A2 otherwise).
BPredicate registers in register file B (B0–B2).
CA call-used register in register file B (B0–B9, B16–B31).
DaRegister file A, excluding predicate registers (A3–A31, plus A0 if not C64X or higher).
DbRegister file B, excluding predicate registers (B3–B31).
Iu4Integer constant in the range 0 … 15.
Iu5Integer constant in the range 0 … 31.
In5Integer constant in the range -31 … 0.
Is5Integer constant in the range -16 … 15.
I5xInteger constant that can be the operand of an ADDA or a SUBA insn.
IuBInteger constant in the range 0 … 65535.
IsBInteger constant in the range -32768 … 32767.
IsCInteger constant in the range -2^{20} … 2^{20} - 1.
JcInteger constant that is a valid mask for the clr instruction.
JsInteger constant that is a valid mask for the set instruction.
QMemory location with A base register.
RMemory location with B base register.
S0On C64x+ targets, a GP-relative small data reference.
S1Any kind of
SYMBOL_REF, for use in a call address.SiAny kind of immediate operand, unless it matches the S0 constraint.
TMemory location with B base register, but not using a long offset.
WA memory operand with an address that cannot be used in an unaligned access.
ZRegister B14 (aka DP).
Visium—config/visium/constraints.md#
bEAM register
mdbcEAM register
mdcfFloating point register
kRegister for sibcall optimization
lGeneral register, but not
r29,r30andr31tRegister
r1uRegister
r2vRegister
r3GFloating-point constant 0.0
JInteger constant in the range 0 .. 65535 (16-bit immediate)
KInteger constant in the range 1 .. 31 (5-bit immediate)
LInteger constant in the range -65535 .. -1 (16-bit negative immediate)
MInteger constant -1
OInteger constant 0
PInteger constant 32
x86 family—config/i386/constraints.md#
RLegacy register—the eight integer registers available on all i386 processors (
a,b,c,d,si,di,bp,sp).qAny register accessible as
rl. In 32-bit mode,a,b,c, andd; in 64-bit mode, any integer register.QAny register accessible as
rh:a,b,c, andd.
lAny register that can be used as the index in a base+index memory access: that is, any general register except the stack pointer.
aThe
aregister.bThe
bregister.cThe
cregister.dThe
dregister.SThe
siregister.DThe
diregister.AThe
aanddregisters. This class is used for instructions that return double word results in theax:dxregister pair. Single word values will be allocated either inaxordx. For example on i386 the following implementsrdtsc:unsigned long long rdtsc (void) { unsigned long long tick; __asm__ __volatile__("rdtsc":"=A"(tick)); return tick; }
This is not correct on x86-64 as it would allocate tick in either
axordx. You have to use the following variant instead:unsigned long long rdtsc (void) { unsigned int tickl, tickh; __asm__ __volatile__("rdtsc":"=a"(tickl),"=d"(tickh)); return ((unsigned long long)tickh << 32)|tickl; }
UThe call-clobbered integer registers.
fAny 80387 floating-point (stack) register.
tTop of 80387 floating-point stack (
%st(0)).uSecond from top of 80387 floating-point stack (
%st(1)).
YkAny mask register that can be used as a predicate, i.e.
k1-k7.kAny mask register.
yAny MMX register.
xAny SSE register.
vAny EVEX encodable SSE register (
%xmm0-%xmm31).
wAny bound register.
YzFirst SSE register (
%xmm0).
YiAny SSE register, when SSE2 and inter-unit moves are enabled.
YjAny SSE register, when SSE2 and inter-unit moves from vector registers are enabled.
YmAny MMX register, when inter-unit moves are enabled.
YnAny MMX register, when inter-unit moves from vector registers are enabled.
YpAny integer register when
TARGET_PARTIAL_REG_STALLis disabled.YaAny integer register when zero extensions with
ANDare disabled.YbAny register that can be used as the GOT base when calling
___tls_get_addr: that is, any general register exceptaandspregisters, for-fno-pltif linker supports it. Otherwise,bregister.YfAny x87 register when 80387 floating-point arithmetic is enabled.
YrLower SSE register when avoiding REX prefix and all SSE registers otherwise.
YvFor AVX512VL, any EVEX-encodable SSE register (
%xmm0-%xmm31), otherwise any SSE register.YhAny EVEX-encodable SSE register, that has number factor of four.
BfFlags register operand.
BgGOT memory operand.
BmVector memory operand.
BcConstant memory operand.
BnMemory operand without REX prefix.
BsSibcall memory operand.
BwCall memory operand.
BzConstant call address operand.
BCSSE constant -1 operand.
IInteger constant in the range 0 … 31, for 32-bit shifts.
JInteger constant in the range 0 … 63, for 64-bit shifts.
KSigned 8-bit integer constant.
L0xFFor0xFFFF, for andsi as a zero-extending move.M0, 1, 2, or 3 (shifts for the
leainstruction).NUnsigned 8-bit integer constant (for
inandoutinstructions).
OInteger constant in the range 0 … 127, for 128-bit shifts.
GStandard 80387 floating point constant.
CSSE constant zero operand.
e32-bit signed integer constant, or a symbolic reference known to fit that range (for immediate operands in sign-extending x86-64 instructions).
We32-bit signed integer constant, or a symbolic reference known to fit that range (for sign-extending conversion operations that require non-
VOIDmodeimmediate operands).Wz32-bit unsigned integer constant, or a symbolic reference known to fit that range (for zero-extending conversion operations that require non-
VOIDmodeimmediate operands).Wd128-bit integer constant where both the high and low 64-bit word satisfy the
econstraint.Z32-bit unsigned integer constant, or a symbolic reference known to fit that range (for immediate operands in zero-extending x86-64 instructions).
TvVSIB address operand.
TsAddress operand without segment register.
Xstormy16—config/stormy16/stormy16.h#
aRegister r0.
bRegister r1.
cRegister r2.
dRegister r8.
eRegisters r0 through r7.
tRegisters r0 and r1.
yThe carry register.
zRegisters r8 and r9.
IA constant between 0 and 3 inclusive.
JA constant that has exactly one bit set.
KA constant that has exactly one bit clear.
LA constant between 0 and 255 inclusive.
MA constant between -255 and 0 inclusive.
NA constant between -3 and 0 inclusive.
OA constant between 1 and 4 inclusive.
PA constant between -4 and -1 inclusive.
QA memory reference that is a stack push.
RA memory reference that is a stack pop.
SA memory reference that refers to a constant address of known value.
TThe register indicated by Rx (not implemented yet).
UA constant that is not between 2 and 15 inclusive.
ZThe constant 0.
Xtensa—config/xtensa/constraints.md#
aGeneral-purpose 32-bit register
bOne-bit boolean register
AMAC16 40-bit accumulator register
ISigned 12-bit integer constant, for use in MOVI instructions
JSigned 8-bit integer constant, for use in ADDI instructions
KInteger constant valid for BccI instructions
LUnsigned constant valid for BccUI instructions
Disable insn alternatives using the enabled attribute#
There are three insn attributes that may be used to selectively disable instruction alternatives:
enabledSays whether an alternative is available on the current subtarget.
preferred_for_sizeSays whether an enabled alternative should be used in code that is optimized for size.
preferred_for_speedSays whether an enabled alternative should be used in code that is optimized for speed.
All these attributes should use (const_int 1) to allow an alternative
or (const_int 0) to disallow it. The attributes must be a static
property of the subtarget; they cannot for example depend on the
current operands, on the current optimization level, on the location
of the insn within the body of a loop, on whether register allocation
has finished, or on the current compiler pass.
The enabled attribute is a correctness property. It tells GCC to act
as though the disabled alternatives were never defined in the first place.
This is useful when adding new instructions to an existing pattern in
cases where the new instructions are only available for certain cpu
architecture levels (typically mapped to the -march= command-line
option).
In contrast, the preferred_for_size and preferred_for_speed
attributes are strong optimization hints rather than correctness properties.
preferred_for_size tells GCC which alternatives to consider when
adding or modifying an instruction that GCC wants to optimize for size.
preferred_for_speed does the same thing for speed. Note that things
like code motion can lead to cases where code optimized for size uses
alternatives that are not preferred for size, and similarly for speed.
Although define_insn s can in principle specify the enabled
attribute directly, it is often clearer to have subsiduary attributes
for each architectural feature of interest. The define_insn s
can then use these subsiduary attributes to say which alternatives
require which features. The example below does this for cpu_facility.
E.g. the following two patterns could easily be merged using the enabled
attribute:
(define_insn "*movdi_old"
[(set (match_operand:DI 0 "register_operand" "=d")
(match_operand:DI 1 "register_operand" " d"))]
"!TARGET_NEW"
"lgr %0,%1")
(define_insn "*movdi_new"
[(set (match_operand:DI 0 "register_operand" "=d,f,d")
(match_operand:DI 1 "register_operand" " d,d,f"))]
"TARGET_NEW"
"@
lgr %0,%1
ldgr %0,%1
lgdr %0,%1")
to:
(define_insn "*movdi_combined"
[(set (match_operand:DI 0 "register_operand" "=d,f,d")
(match_operand:DI 1 "register_operand" " d,d,f"))]
""
"@
lgr %0,%1
ldgr %0,%1
lgdr %0,%1"
[(set_attr "cpu_facility" "*,new,new")])
with the enabled attribute defined like this:
(define_attr "cpu_facility" "standard,new" (const_string "standard"))
(define_attr "enabled" ""
(cond [(eq_attr "cpu_facility" "standard") (const_int 1)
(and (eq_attr "cpu_facility" "new")
(ne (symbol_ref "TARGET_NEW") (const_int 0)))
(const_int 1)]
(const_int 0)))
Defining Machine-Specific Constraints#
Machine-specific constraints fall into two categories: register and
non-register constraints. Within the latter category, constraints
which allow subsets of all possible memory or address operands should
be specially marked, to give reload more information.
Machine-specific constraints can be given names of arbitrary length,
but they must be entirely composed of letters, digits, underscores
(_), and angle brackets (< >). Like C identifiers, they
must begin with a letter or underscore.
In order to avoid ambiguity in operand constraint strings, no
constraint can have a name that begins with any other constraint’s
name. For example, if x is defined as a constraint name,
xy may not be, and vice versa. As a consequence of this rule,
no constraint may begin with one of the generic constraint letters:
E F V X g i m n o p r s.
Register constraints correspond directly to register classes. See Register Classes. There is thus not much flexibility in their definitions.
MD Expression define_register_constraint name regclass docstringAll three arguments are string constants.
name is the name of the constraint, as it will appear in
match_operand expressions. If name is a multi-letter
constraint its length shall be the same for all constraints starting
with the same letter. regclass can be either the
name of the corresponding register class (see Register Classes),
or a C expression which evaluates to the appropriate register class.
If it is an expression, it must have no side effects, and it cannot
look at the operand. The usual use of expressions is to map some
register constraints to NO_REGS when the register class
is not available on a given subarchitecture.
docstring is a sentence documenting the meaning of the
constraint. Docstrings are explained further below.
Non-register constraints are more like predicates: the constraint definition gives a boolean expression which indicates whether the constraint matches.
MD Expression define_constraint name docstring expThe name and docstring arguments are the same as for
define_register_constraint, but note that the docstring comes
immediately after the name for these expressions. exp is an RTL
expression, obeying the same rules as the RTL expressions in predicate
definitions. See Defining Machine-Specific Predicates, for details. If it
evaluates true, the constraint matches; if it evaluates false, it
doesn’t. Constraint expressions should indicate which RTL codes they
might match, just like predicate expressions.
match_test C expressions have access to the
following variables:
opThe RTL object defining the operand.
modeThe machine mode of
op.ivalINTVAL (op), ifopis aconst_int.hvalCONST_DOUBLE_HIGH (op), ifopis an integerconst_double.lvalCONST_DOUBLE_LOW (op), ifopis an integerconst_double.rvalCONST_DOUBLE_REAL_VALUE (op), ifopis a floating-pointconst_double.
The *val variables should only be used once another piece of the
expression has verified that op is the appropriate kind of RTL
object.
Most non-register constraints should be defined with
define_constraint. The remaining two definition expressions
are only appropriate for constraints that should be handled specially
by reload if they fail to match.
MD Expression define_memory_constraint name docstring expUse this expression for constraints that match a subset of all memory
operands: that is, reload can make them match by converting the
operand to the form (mem (reg X )), where X is a
base register (from the register class specified by
BASE_REG_CLASS, see Register Classes).
For example, on the S/390, some instructions do not accept arbitrary
memory references, but only those that do not make use of an index
register. The constraint letter Q is defined to represent a
memory address of this type. If Q is defined with
define_memory_constraint, a Q constraint can handle any
memory operand, because reload knows it can simply copy the
memory address into a base register if required. This is analogous to
the way an o constraint can handle any memory operand.
The syntax and semantics are otherwise identical to
define_constraint.
MD Expression define_special_memory_constraint name docstring expUse this expression for constraints that match a subset of all memory
operands: that is, reload cannot make them match by reloading
the address as it is described for define_memory_constraint or
such address reload is undesirable with the performance point of view.
For example, define_special_memory_constraint can be useful if
specifically aligned memory is necessary or desirable for some insn
operand.
The syntax and semantics are otherwise identical to
define_memory_constraint.
MD Expression define_relaxed_memory_constraint name docstring expThe test expression in a define_memory_constraint can assume
that TARGET_LEGITIMATE_ADDRESS_P holds for the address inside
a mem rtx and so it does not need to test this condition itself.
In other words, a define_memory_constraint test of the form:
(match_test "mem")
is enough to test whether an rtx is a mem and whether
its address satisfies TARGET_MEM_CONSTRAINT (which is usually
'm'). Thus the conditions imposed by a define_memory_constraint
always apply on top of the conditions imposed by TARGET_MEM_CONSTRAINT.
However, it is sometimes useful to define memory constraints that allow
addresses beyond those accepted by TARGET_LEGITIMATE_ADDRESS_P.
define_relaxed_memory_constraint exists for this case.
The test expression in a define_relaxed_memory_constraint is
applied with no preconditions, so that the expression can determine
‘from scratch’ exactly which addresses are valid and which are not.
The syntax and semantics are otherwise identical to
define_memory_constraint.
MD Expression define_address_constraint name docstring expUse this expression for constraints that match a subset of all address
operands: that is, reload can make the constraint match by
converting the operand to the form (reg X ), again
with X a base register.
Constraints defined with define_address_constraint can only be
used with the address_operand predicate, or machine-specific
predicates that work the same way. They are treated analogously to
the generic p constraint.
The syntax and semantics are otherwise identical to
define_constraint.
For historical reasons, names beginning with the letters G H
are reserved for constraints that match only const_double s, and
names beginning with the letters I J K L M N O P are reserved
for constraints that match only const_int s. This may change in
the future. For the time being, constraints with these names must be
written in a stylized form, so that genpreds can tell you did
it correctly:
(define_constraint "[GHIJKLMNOP]..."
"doc..."
(and (match_code "const_int") ; const_double for G/H
condition...)) ; usually a match_test
It is fine to use names beginning with other letters for constraints
that match const_double s or const_int s.
Each docstring in a constraint definition should be one or more complete
sentences, marked up in Texinfo format. They are currently unused.
In the future they will be copied into the GCC manual, in Constraints for Particular Machines, replacing the hand-maintained tables currently found in
that section. Also, in the future the compiler may use this to give
more helpful diagnostics when poor choice of asm constraints
causes a reload failure.
If you put the pseudo-Texinfo directive @internal at the
beginning of a docstring, then (in the future) it will appear only in
the internals manual’s version of the machine-specific constraint tables.
Use this for constraints that should not appear in asm statements.
Testing constraints from C#
It is occasionally useful to test a constraint from C code rather than
implicitly via the constraint string in a match_operand. The
generated file tm_p.h declares a few interfaces for working
with constraints. At present these are defined for all constraints
except g (which is equivalent to general_operand).
Some valid constraint names are not valid C identifiers, so there is a
mangling scheme for referring to them from C. Constraint names that
do not contain angle brackets or underscores are left unchanged.
Underscores are doubled, each < is replaced with _l, and
each > with _g. Here are some examples:
Original |
Mangled .. c |
|
|
|
|
|
|
|
|
|
|
|
|
Throughout this section, the variable c is either a constraint
in the abstract sense, or a constant from enum constraint_num ;
the variable m is a mangled constraint name (usually as part of
a larger identifier).
Enum constraint_numFor each constraint except g, there is a corresponding
enumeration constant: CONSTRAINT_ plus the mangled name of the
constraint. Functions that take an enum constraint_num as an
argument expect one of these constants.
-
inline bool satisfies_constraint_m(rtx exp)#
For each non-register constraint
mexceptg, there is one of these functions; it returnstrueifexpsatisfies the constraint. These functions are only visible ifrtl.hwas included beforetm_p.h.
-
bool constraint_satisfied_p(rtx exp, enum constraint_num c)#
Like the
satisfies_constraint_mfunctions, but the constraint to test is given as an argument,c. Ifcspecifies a register constraint, this function will always returnfalse.
-
enum reg_class reg_class_for_constraint(enum constraint_num c)#
Returns the register class associated with
c. Ifcis not a register constraint, or those registers are not available for the currently selected subtarget, returnsNO_REGS.
Here is an example use of satisfies_constraint_m. In
peephole optimizations (see Machine-Specific Peephole Optimizers), operand
constraint strings are ignored, so if there are relevant constraints,
they must be tested in the C condition. In the example, the
optimization is applied if operand 2 does not satisfy the
K constraint. (This is a simplified version of a peephole
definition from the i386 machine description.)
(define_peephole2
[(match_scratch:SI 3 "r")
(set (match_operand:SI 0 "register_operand" "")
(mult:SI (match_operand:SI 1 "memory_operand" "")
(match_operand:SI 2 "immediate_operand" "")))]
"!satisfies_constraint_K (operands[2])"
[(set (match_dup 3) (match_dup 1))
(set (match_dup 0) (mult:SI (match_dup 3) (match_dup 2)))]
"")