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 section 4.33.1 Simple Constraints), and
`I', usually the letter indicating the most common
immediate-constant format.
For each machine architecture, the `config/machine.h' file
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
interesting for asm. The constraints are defined through these
macros:
REG_CLASS_FROM_LETTER
Register class constraints (usually lower case).
CONST_OK_FOR_LETTER_P
Immediate constant constraints, for non-floating point constants of
word size or smaller precision (usually upper case).
CONST_DOUBLE_OK_FOR_LETTER_P
Immediate constant constraints, for all floating point constants and for
constants of greater than word size precision (usually upper case).
EXTRA_CONSTRAINT
Special cases of registers or memory. This macro is not required, and
is only defined for some machines.
Inspecting these macro definitions in the compiler source for your
machine is the best way to be certain you have the right constraints.
However, here is a summary of the machine-dependent constraints
available on some particular machines.
ARM family---`arm.h'
f
Floating-point register
F
One of the floating-point constants 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0
or 10.0
G
Floating-point constant that would satisfy the constraint `F' if it
were negated
I
Integer 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
J
Integer in the range -4095 to 4095
K
Integer that satisfies constraint `I' when inverted (ones complement)
L
Integer that satisfies constraint `I' when negated (twos complement)
M
Integer in the range 0 to 32
Q
A memory reference where the exact address is in a single register
(``m'' is preferable for asm statements)
R
An item in the constant pool
S
A symbol in the text segment of the current file
AMD 29000 family---`a29k.h'
l
Local register 0
b
Byte Pointer (`BP') register
q
`Q' register
h
Special purpose register
A
First accumulator register
a
Other accumulator register
f
Floating point register
I
Constant greater than 0, less than 0x100
J
Constant greater than 0, less than 0x10000
K
Constant whose high 24 bits are on (1)
L
16 bit constant whose high 8 bits are on (1)
M
32 bit constant whose high 16 bits are on (1)
N
32 bit negative constant that fits in 8 bits
O
The constant 0x80000000 or, on the 29050, any 32 bit constant
whose low 16 bits are 0.
P
16 bit negative constant that fits in 8 bits
G
H
A floating point constant (in asm statements, use the machine
independent `E' or `F' instead)
IBM RS6000---`rs6000.h'
b
Address base register
f
Floating point register
h
`MQ', `CTR', or `LINK' register
q
`MQ' register
c
`CTR' register
l
`LINK' register
x
`CR' register (condition register) number 0
y
`CR' register (condition register)
z
`FPMEM' stack memory for FPR-GPR transfers
I
Signed 16 bit constant
J
Constant whose low 16 bits are 0
K
Constant whose high 16 bits are 0
L
Constant suitable as a mask operand
M
Constant larger than 31
N
Exact power of 2
O
Zero
P
Constant whose negation is a signed 16 bit constant
G
Floating point constant that can be loaded into a register with one
instruction per word
Q
Memory operand that is an offset from a register (`m' is preferable
for asm statements)
R
AIX TOC entry
S
Constant suitable as a 64-bit mask operand
U
System V Release 4 small data area reference
Intel 386---`i386.h'
q
`a', b, c, or d register
A
`a', or d register (for 64-bit ints)
f
Floating point register
t
First (top of stack) floating point register
u
Second floating point register
a
`a' register
b
`b' register
c
`c' register
d
`d' register
D
`di' register
S
`si' register
I
Constant in range 0 to 31 (for 32 bit shifts)
J
Constant in range 0 to 63 (for 64 bit shifts)
K
`0xff'
L
`0xffff'
M
0, 1, 2, or 3 (shifts for lea instruction)
N
Constant in range 0 to 255 (for out instruction)
G
Standard 80387 floating point constant
Intel 960---`i960.h'
f
Floating point register (fp0 to fp3)
l
Local register (r0 to r15)
b
Global register (g0 to g15)
d
Any local or global register
I
Integers from 0 to 31
J
0
K
Integers from -31 to 0
G
Floating point 0
H
Floating point 1
MIPS---`mips.h'
d
General-purpose integer register
f
Floating-point register (if available)
h
`Hi' register
l
`Lo' register
x
`Hi' or `Lo' register
y
General-purpose integer register
z
Floating-point status register
I
Signed 16 bit constant (for arithmetic instructions)