GCC constraints for the i386 architecture
1) x86 constraints:
1.1) Classes of registers:
NO_REGS
AREG /* %eax */
DREG /* %edx */
CREG /* %ecx */
BREG /* %edx */
AD_REGS /* %eax/%edx for DImode */
Q_REGS /* %eax %ebx %ecx %edx */
SIREG /* %esi */
DIREG /* %edi */
INDEX_REGS /* %eax %ebx %ecx %edx %esi %edi %ebp */
GENERAL_REGS /* %eax %ebx %ecx %edx %esi %edi %ebp %esp */
FP_TOP_REG /* %st(0) */
FP_SECOND_REG /* %st(1) */
FLOAT_REGS
ALL_REGS
LIM_REG_CLASSES
1.2) Then the architecture constraints are:
'r' GENERAL_REGS
'q' Q_REGS
'f' FLOAT_REGS
't' FP_TOP_REG
'u' FP_SECOND_REG
'a' AREG
'b' BREG
'c' CREG
'd' DREG
'A' AD_REGS
'D' DIREG
'S' SIREG
2) The inmediate constraint:
This constraint is named 'i' but some times you can't use any inmediate value because you are restricted to a range. If the number is outside the range you must use a register. For this reason the following are defined for x86:
'I' VALUE >= 0 && (VALUE) <= 31
'J' VALUE >= 0 && (VALUE) <= 63
'K' VALUE == 0xff
'L' VALUE == 0xffff
'M' VALUE >= 0 && (VALUE) <= 3
'N' VALUE >= 0 && (VALUE) <= 255
'O' VALUE >= 0 && (VALUE) <= 32
As it could look unclear here is an example:
Then if value is in [0..31] we will get:
If value is outside:
The comments say that the use is:
I is for non-DImode shifts.
J is for DImode shifts.
K and L are for an `andsi' optimization.
M is for shifts that can be executed by the "lea" opcode.
3) General notes:
* You can use a list of constraints, the first match will be used.
* The 'm' constraint means memory if you don't use it gcc will force the use of a register, so if the value comes from a variable and goes to a register you'll want to use 'm' to avoid loading a register and then moving it to other. Example:
Example:
Will generate
Generates
Visited since April 9,1997: times, According to GeoCities: , Tracker:
LinkExchange Member | Free Home Pages at GeoCities |