1 //===-- X86InstructionInfo.def - X86 Instruction Information ----*- C++ -*-===//
3 // This file describes all of the instructions that the X86 backend uses. It
4 // relys on an external 'I' macro being defined that takes the arguments
5 // specified below, and is used to make all of the information relevant to an
6 // instruction be in one place.
8 // Note that X86 Instructions always have the destination register listed as
9 // operand 0, unless it does not produce a value (in which case the TSFlags will
10 // include X86II::Void).
12 //===----------------------------------------------------------------------===//
14 // NOTE: No include guards desired
17 #errror "Must define I macro before including X86/X86InstructionInfo.def!"
20 // Arguments to be passed into the I macro
21 // #1: Enum name - This ends up being the opcode symbol in the X86 namespace
22 // #2: Opcode name, as used by the gnu assembler
23 // #3: Instruction Flags - This should be a field or'd together that contains
24 // constants from the MachineInstrInfo.h file.
25 // #4: Target Specific Flags - Another bitfield containing X86 specific flags
26 // that we are interested in for each instruction. These should be flags
27 // defined in X86InstrInfo.h in the X86II namespace.
30 // The first instruction must always be the PHI instruction:
33 // The second instruction must always be the noop instruction:
34 I(NOOP , "nop", 0, X86II::Void) // nop 90
36 // Flow control instructions
37 I(RET , "ret", M_RET_FLAG, X86II::Void) // ret CB
38 I(JMP , "jmp", M_BRANCH_FLAG, X86II::Void) // jmp foo EB|E9 cb|w
41 I(LEAVE , "leave", 0, 0) // leave C9
44 I(MOVrr8 , "movb", 0, 0) // R8 = R8 88/r
45 I(MOVrr16 , "movw", 0, 0) // R16 = R16 89/r
46 I(MOVrr32 , "movl", 0, 0) // R32 = R32 89/r
47 I(MOVir8 , "movb", 0, 0) // R8 = imm8 B0+ rb
48 I(MOVir16 , "movw", 0, 0) // R16 = imm16 B8+ rw
49 I(MOVir32 , "movl", 0, 0) // R32 = imm32 B8+ rd
50 I(MOVmr8 , "movb", 0, 0) // R8 = [mem] 8A/r
51 I(MOVmr16 , "movw", 0, 0) // R16 = [mem] 8B/r
52 I(MOVmr32 , "movl", 0, 0) // R32 = [mem] 8B/r
53 I(MOVrm8 , "movb", 0, X86II::Void) // [mem] = R8 88/r
54 I(MOVrm16 , "movw", 0, X86II::Void) // [mem] = R16 89/r
55 I(MOVrm32 , "movl", 0, X86II::Void) // [mem] = R32 89/r
57 // Arithmetic instructions
58 I(ADDrr8 , "addb", 0, 0) // R8 += R8 00/r
59 I(ADDrr16 , "addw", 0, 0) // R16 += R16 01/r
60 I(ADDrr32 , "addl", 0, 0) // R32 += R32 01/r
61 I(SUBrr8 , "subb", 0, 0) // R8 -= R8 2A/r
62 I(SUBrr16 , "subw", 0, 0) // R16 -= R16 2B/r
63 I(SUBrr32 , "subl", 0, 0) // R32 -= R32 2B/r
64 I(MULrr8 , "mulb", 0, 0) // AX = AL*R8 F6/4
65 I(MULrr16 , "mulw", 0, 0) // DX:AX= AX*R16 F7/4
66 I(MULrr32 , "mull", 0, 0) // ED:EA= EA*R32 F7/4
68 // unsigned division/remainder
69 I(DIVrr8 , "divb", 0, X86II::Void) // AX/r8= AL&AH F6/6
70 I(DIVrr16 , "divw", 0, X86II::Void) // DA/r16=AX&DX F7/6
71 I(DIVrr32 , "divl", 0, X86II::Void) // DA/r32=EAX&DX F7/6
73 // signed division/remainder
74 I(IDIVrr8 , "idivb", 0, X86II::Void) // AX/r8= AL&AH F6/6
75 I(IDIVrr16 , "idivw", 0, X86II::Void) // DA/r16=AX&DX F7/6
76 I(IDIVrr32 , "idivl", 0, X86II::Void) // DA/r32=EAX&DX F7/6
79 I(ANDrr8 , "andb", 0, 0) // R8 &= R8 20/r
80 I(ANDrr16 , "andw", 0, 0) // R16 &= R16 21/r
81 I(ANDrr32 , "andl", 0, 0) // R32 &= R32 21/r
82 I(ORrr8 , "orb", 0, 0) // R8 |= R8 08/r
83 I(ORrr16 , "orw", 0, 0) // R16 |= R16 09/r
84 I(ORrr32 , "orl", 0, 0) // R32 |= R32 09/r
85 I(XORrr8 , "xorb", 0, 0) // R8 ^= R8 30/r
86 I(XORrr16 , "xorw", 0, 0) // R16 ^= R16 31/r
87 I(XORrr32 , "xorl", 0, 0) // R32 ^= R32 31/r
90 I(SHLrr8 , "shlb", 0, 0) // R8 <<= cl D2/4
91 I(SHLir8 , "shlb", 0, 0) // R8 <<= imm8 C0/4 ib
92 I(SHLrr16 , "shlw", 0, 0) // R16 <<= cl D3/4
93 I(SHLir16 , "shlw", 0, 0) // R16 <<= imm8 C1/4 ib
94 I(SHLrr32 , "shll", 0, 0) // R32 <<= cl D3/4
95 I(SHLir32 , "shll", 0, 0) // R32 <<= imm8 C1/4 ib
96 I(SHRrr8 , "shrb", 0, 0) // R8 >>>= cl D2/5
97 I(SHRir8 , "shrb", 0, 0) // R8 >>>= imm8 C0/5 ib
98 I(SHRrr16 , "shrw", 0, 0) // R16 >>>= cl D3/5
99 I(SHRir16 , "shrw", 0, 0) // R16 >>>= imm8 C1/5 ib
100 I(SHRrr32 , "shrl", 0, 0) // R32 >>>= cl D3/5
101 I(SHRir32 , "shrl", 0, 0) // R32 >>>= imm8 C1/5 ib
102 I(SARrr8 , "sarb", 0, 0) // R8 >>= cl D2/7
103 I(SARir8 , "sarb", 0, 0) // R8 >>= imm8 C0/7 ib
104 I(SARrr16 , "sarw", 0, 0) // R16 >>= cl D3/7
105 I(SARir16 , "sarw", 0, 0) // R16 >>= imm8 C1/7 ib
106 I(SARrr32 , "sarl", 0, 0) // R32 >>= cl D3/7
107 I(SARir32 , "sarl", 0, 0) // R32 >>= imm8 C1/7 ib
109 // Floating point loads
110 I(FLDr4 , "flds", 0, X86II::Void) // push float D9/0
111 I(FLDr8 , "fldl ", 0, X86II::Void) // push double DD/0
113 // Floating point compares
114 I(FUCOMPP , "fucompp", 0, X86II::Void) // compare+pop2x DA E9
116 // Floating point flag ops
117 I(FNSTSWr8 , "fnstsw", 0, X86II::Void) // AX = fp flags DF E0
119 // Condition code ops, incl. set if equal/not equal/...
120 I(SAHF , "sahf", 0, 0) // flags = AH 9E
121 I(SETA , "seta", 0, 0) // R8 = > unsign 0F 97
122 I(SETAE , "setae", 0, 0) // R8 = >=unsign 0F 93
123 I(SETB , "setb", 0, 0) // R8 = < unsign 0F 92
124 I(SETBE , "setbe", 0, 0) // R8 = <=unsign 0F 96
125 I(SETE , "sete", 0, 0) // R8 = == 0F 94
126 I(SETG , "setg", 0, 0) // R8 = > signed 0F 9F
127 I(SETGE , "setge", 0, 0) // R8 = >=signed 0F 9D
128 I(SETL , "setl", 0, 0) // R8 = < signed 0F 9C
129 I(SETLE , "setle", 0, 0) // R8 = <=signed 0F 9E
130 I(SETNE , "setne", 0, 0) // R8 = != 0F 95
132 // Integer comparisons
133 I(CMPrr8 , "cmpb", 0, 0) // compare R8,R8 38/r
134 I(CMPrr16 , "cmpw", 0, 0) // compare R16,R16 39/r
135 I(CMPrr32 , "cmpl", 0, 0) // compare R32,R32 39/r
137 // Sign extenders (first 3 are good for DIV/IDIV; the others are more general)
138 I(CBW , "cbw", 0, 0) // AX = signext(AL) 98
139 I(CWD , "cwd", 0, 0) // DX:AX = signext(AX) 99
140 I(CDQ , "cdq", 0, 0) // EDX:EAX = signext(EAX) 99
141 I(MOVSXr16r8 , "movsx", 0, 0) // R32 = signext(R8) 0F BE /r
142 I(MOVSXr32r8 , "movsx", 0, 0) // R32 = signext(R8) 0F BE /r
143 I(MOVSXr32r16 , "movsx", 0, 0) // R32 = signext(R16) 0F BF /r
144 I(MOVZXr16r8 , "movzx", 0, 0) // R32 = zeroext(R8) 0F B6 /r
145 I(MOVZXr32r8 , "movzx", 0, 0) // R32 = zeroext(R8) 0F B6 /r
146 I(MOVZXr32r16 , "movzx", 0, 0) // R32 = zeroext(R16) 0F B7 /r
148 // At this point, I is dead, so undefine the macro