Using and Porting GNU CC
15.6.5: Constraints for Particular Machines
Whenever possible, you should use the generalpurpose 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
generalpurpose registers respectively; see Simple Constraints), and
`I
', usually the letter indicating the most common
immediateconstant 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 nonfloating 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 machinedependent constraints
available on some particular machines.
 ARM family`
arm.h
'

f

Floatingpoint register
F

One of the floatingpoint constants 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0
or 10.0
G

Floatingpoint 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)
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)
 Intel 386`
i386.h
'

q

`
a
', b
, c
, or d
register
A

`
a
', or d
register (for 64bit 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)
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

Generalpurpose integer register
f

Floatingpoint register (if available)
h

`
Hi
' register
l

`
Lo
' register
x

`
Hi
' or `Lo
' register
y

Generalpurpose integer register
z

Floatingpoint status register
I

Signed 16 bit constant (for arithmetic instructions)
J

Zero
K

Zeroextended 16bit constant (for logic instructions)
L

Constant with low 16 bits zero (can be loaded with
lui
)
M

32 bit constant which requires two instructions to load (a constant
which is not `
I
', `K
', or `L
')
N

Negative 16 bit constant
O

Exact power of two
P

Positive 16 bit constant
G

Floating point zero
Q

Memory reference that can be loaded with more than one instruction
(`
m
' is preferable for asm
statements)
R

Memory reference that can be loaded with one instruction
(`
m
' is preferable for asm
statements)
S

Memory reference in external OSF/rose PIC format
(`
m
' is preferable for asm
statements)
 Motorola 680x0`
m68k.h
'

a

Address register
d

Data register
f

68881 floatingpoint register, if available
x

Sun FPA (floatingpoint) register, if available
y

First 16 Sun FPA registers, if available
I

Integer in the range 1 to 8
J

16 bit signed number
K

Signed number whose magnitude is greater than 0x80
L

Integer in the range 8 to 1
G

Floating point constant that is not a 68881 constant
H

Floating point constant that can be used by Sun FPA
 SPARC`
sparc.h
'

f

Floatingpoint register
I

Signed 13 bit constant
J

Zero
K

32 bit constant with the low 12 bits clear (a constant that can be
loaded with the
sethi
instruction)
G

Floatingpoint zero
H

Signed 13 bit constant, signextended to 32 or 64 bits
Q

Memory reference that can be loaded with one instruction (`
m
' is
more appropriate for asm
statements)
S

Constant, or memory address
T

Memory address aligned to an 8byte boundary
U

Even register