1 //===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86 instruction set, defining the instructions, and
11 // properties of the instructions which are needed for code generation, machine
12 // code emission, and analysis.
14 //===----------------------------------------------------------------------===//
16 // *mem - Operand definitions for the funky X86 addressing mode operands.
19 class X86MemOperand<ValueType Ty> : Operand<Ty> {
20 let NumMIOperands = 4;
21 let PrintMethod = "printMemoryOperand";
24 def i8mem : X86MemOperand<i8>;
25 def i16mem : X86MemOperand<i16>;
26 def i32mem : X86MemOperand<i32>;
27 def i64mem : X86MemOperand<i64>;
28 def f32mem : X86MemOperand<f32>;
29 def f64mem : X86MemOperand<f64>;
30 def f80mem : X86MemOperand<f80>;
32 // Format specifies the encoding used by the instruction. This is part of the
33 // ad-hoc solution used to emit machine instruction encodings by our machine
35 class Format<bits<5> val> {
39 def Pseudo : Format<0>; def RawFrm : Format<1>;
40 def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
41 def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
42 def MRMSrcMem : Format<6>;
43 def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
44 def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
45 def MRM6r : Format<22>; def MRM7r : Format<23>;
46 def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
47 def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
48 def MRM6m : Format<30>; def MRM7m : Format<31>;
50 // ImmType - This specifies the immediate type used by an instruction. This is
51 // part of the ad-hoc solution used to emit machine instruction encodings by our
52 // machine code emitter.
53 class ImmType<bits<2> val> {
56 def NoImm : ImmType<0>;
57 def Imm8 : ImmType<1>;
58 def Imm16 : ImmType<2>;
59 def Imm32 : ImmType<3>;
61 // MemType - This specifies the immediate type used by an instruction. This is
62 // part of the ad-hoc solution used to emit machine instruction encodings by our
63 // machine code emitter.
64 class MemType<bits<3> val> {
67 def NoMem : MemType<0>;
68 def Mem16 : MemType<2>;
69 def Mem32 : MemType<3>;
70 def Mem64 : MemType<4>;
71 def Mem80 : MemType<5>;
73 // FPFormat - This specifies what form this FP instruction has. This is used by
74 // the Floating-Point stackifier pass.
75 class FPFormat<bits<3> val> {
78 def NotFP : FPFormat<0>;
79 def ZeroArgFP : FPFormat<1>;
80 def OneArgFP : FPFormat<2>;
81 def OneArgFPRW : FPFormat<3>;
82 def TwoArgFP : FPFormat<4>;
83 def CompareFP : FPFormat<5>;
84 def CondMovFP : FPFormat<6>;
85 def SpecialFP : FPFormat<7>;
88 class X86Inst<string nam, bits<8> opcod, Format f, MemType m, ImmType i> : Instruction {
89 let Namespace = "X86";
92 bits<8> Opcode = opcod;
94 bits<5> FormBits = Form.Value;
96 bits<3> MemTypeBits = MemT.Value;
98 bits<2> ImmTypeBits = ImmT.Value;
101 // Attributes specific to X86 instructions...
103 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
105 // Flag whether implicit register usage is printed after the instruction.
106 bit printImplicitUsesAfter = 0;
108 bits<4> Prefix = 0; // Which prefix byte does this inst have?
109 FPFormat FPForm; // What flavor of FP instruction is this?
110 bits<3> FPFormBits = 0;
113 class Imp<list<Register> uses, list<Register> defs> {
114 list<Register> Uses = uses;
115 list<Register> Defs = defs;
118 // II - InstructionInfo - this will eventually replace the I class.
119 class II<dag ops, string AsmStr> {
120 dag OperandList = ops;
121 string AsmString = AsmStr;
125 // Prefix byte classes which are used to indicate to the ad-hoc machine code
126 // emitter that various prefix bytes are required.
127 class OpSize { bit hasOpSizePrefix = 1; }
128 class TB { bits<4> Prefix = 1; }
129 class REP { bits<4> Prefix = 2; }
130 class D8 { bits<4> Prefix = 3; }
131 class D9 { bits<4> Prefix = 4; }
132 class DA { bits<4> Prefix = 5; }
133 class DB { bits<4> Prefix = 6; }
134 class DC { bits<4> Prefix = 7; }
135 class DD { bits<4> Prefix = 8; }
136 class DE { bits<4> Prefix = 9; }
137 class DF { bits<4> Prefix = 10; }
140 //===----------------------------------------------------------------------===//
141 // Instruction templates...
143 class I<bits<8> o, Format f, dag ops, string asm> : X86Inst<"", o, f, NoMem, NoImm>, II<ops, asm>;
145 class Ii<bits<8> o, Format f, ImmType i> : X86Inst<"", o, f, NoMem, i>;
146 class Ii8 <bits<8> o, Format f, dag ops, string asm> : Ii<o, f, Imm8 >, II<ops, asm>;
147 class Ii16<bits<8> o, Format f, dag ops, string asm> : Ii<o, f, Imm16>, II<ops, asm>;
148 class Ii32<bits<8> o, Format f, dag ops, string asm> : Ii<o, f, Imm32>, II<ops, asm>;
150 //===----------------------------------------------------------------------===//
151 // Instruction list...
154 def PHI : I<0, Pseudo, (ops), "PHINODE">; // PHI node.
155 def NOOP : I<0x90, RawFrm, (ops), "nop">; // nop
157 def ADJCALLSTACKDOWN : I<0, Pseudo, (ops), "#ADJCALLSTACKDOWN">;
158 def ADJCALLSTACKUP : I<0, Pseudo, (ops), "#ADJCALLSTACKUP">;
159 def IMPLICIT_USE : I<0, Pseudo, (ops), "#IMPLICIT_USE">;
160 def IMPLICIT_DEF : I<0, Pseudo, (ops), "#IMPLICIT_DEF">;
161 let isTerminator = 1 in
162 let Defs = [FP0, FP1, FP2, FP3, FP4, FP5, FP6] in
163 def FP_REG_KILL : I<0, Pseudo, (ops), "#FP_REG_KILL">;
165 //===----------------------------------------------------------------------===//
166 // Control Flow Instructions...
169 // Return instruction...
170 let isTerminator = 1, isReturn = 1, isBarrier = 1 in
171 def RET : I<0xC3, RawFrm, (ops), "ret">;
173 // All branches are RawFrm, Void, Branch, and Terminators
174 let isBranch = 1, isTerminator = 1 in
175 class IBr<bits<8> opcode, dag ops, string asm> : I<opcode, RawFrm, ops, asm>;
178 def JMP : IBr<0xE9, (ops i32imm:$dst), "jmp $dst">;
179 def JB : IBr<0x82, (ops i32imm:$dst), "jb $dst">, TB;
180 def JAE : IBr<0x83, (ops i32imm:$dst), "jae $dst">, TB;
181 def JE : IBr<0x84, (ops i32imm:$dst), "je $dst">, TB;
182 def JNE : IBr<0x85, (ops i32imm:$dst), "jne $dst">, TB;
183 def JBE : IBr<0x86, (ops i32imm:$dst), "jbe $dst">, TB;
184 def JA : IBr<0x87, (ops i32imm:$dst), "ja $dst">, TB;
185 def JS : IBr<0x88, (ops i32imm:$dst), "js $dst">, TB;
186 def JNS : IBr<0x89, (ops i32imm:$dst), "jns $dst">, TB;
187 def JL : IBr<0x8C, (ops i32imm:$dst), "jl $dst">, TB;
188 def JGE : IBr<0x8D, (ops i32imm:$dst), "jge $dst">, TB;
189 def JLE : IBr<0x8E, (ops i32imm:$dst), "jle $dst">, TB;
190 def JG : IBr<0x8F, (ops i32imm:$dst), "jg $dst">, TB;
193 //===----------------------------------------------------------------------===//
194 // Call Instructions...
197 // All calls clobber the non-callee saved registers...
198 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6] in {
199 def CALLpcrel32 : X86Inst<"call", 0xE8, RawFrm, NoMem, NoImm>; // FIXME: 'call' doesn't allow 'OFFSET'
200 def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call $dst">;
201 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst), "call $dst">;
205 //===----------------------------------------------------------------------===//
206 // Miscellaneous Instructions...
208 def LEAVE : I<0xC9, RawFrm,
209 (ops), "leave">, Imp<[EBP,ESP],[EBP,ESP]>;
210 def POP32r : I<0x58, AddRegFrm,
211 (ops R32:$reg), "pop $reg">, Imp<[ESP],[ESP]>;
213 let isTwoAddress = 1 in // R32 = bswap R32
214 def BSWAP32r : I<0xC8, AddRegFrm,
215 (ops R32:$dst, R32:$src), "bswap $dst">, TB;
217 def XCHG8rr : I<0x86, MRMDestReg, // xchg R8, R8
218 (ops R8:$src1, R8:$src2), "xchg $src1, $src2">;
219 def XCHG16rr : I<0x87, MRMDestReg, // xchg R16, R16
220 (ops R16:$src1, R16:$src2), "xchg $src1, $src2">, OpSize;
221 def XCHG32rr : I<0x87, MRMDestReg, // xchg R32, R32
222 (ops R32:$src1, R32:$src2), "xchg $src1, $src2">;
224 def XCHG8mr : I<0x86, MRMDestMem, (ops i8mem:$src1, R8:$src2), "xchg $src1, $src2">;
225 def XCHG16mr : I<0x87, MRMDestMem, (ops i16mem:$src1, R16:$src2), "xchg $src1, $src2">, OpSize;
226 def XCHG32mr : I<0x87, MRMDestMem, (ops i32mem:$src1, R32:$src2), "xchg $src1, $src2">;
227 def XCHG8rm : I<0x86, MRMSrcMem , (ops R8:$src1, i8mem:$src2), "xchg $src1, $src2">;
228 def XCHG16rm : I<0x87, MRMSrcMem , (ops R16:$src1, i16mem:$src2), "xchg $src1, $src2">, OpSize;
229 def XCHG32rm : I<0x87, MRMSrcMem , (ops R32:$src1, i32mem:$src2), "xchg $src1, $src2">;
231 def LEA16r : I<0x8D, MRMSrcMem, (ops R16:$dst, i32mem:$src), "lea $dst, $src">, OpSize;
232 def LEA32r : I<0x8D, MRMSrcMem, (ops R32:$dst, i32mem:$src), "lea $dst, $src">;
235 def REP_MOVSB : I<0xA4, RawFrm, (ops), "rep movsb">,
236 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
237 def REP_MOVSW : I<0xA5, RawFrm, (ops), "rep movsw">,
238 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
239 def REP_MOVSD : I<0xA5, RawFrm, (ops), "rep movsd">,
240 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
242 def REP_STOSB : I<0xAA, RawFrm, (ops), "rep stosb">,
243 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
244 def REP_STOSW : I<0xAB, RawFrm, (ops), "rep stosw">,
245 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
246 def REP_STOSD : I<0xAB, RawFrm, (ops), "rep stosd">,
247 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
250 //===----------------------------------------------------------------------===//
251 // Input/Output Instructions...
253 def IN8rr : I<0xEC, RawFrm, (ops),
254 "in %AL, %DX">, Imp<[DX], [AL]>;
255 def IN16rr : I<0xED, RawFrm, (ops),
256 "in %AX, %DX">, Imp<[DX], [AX]>, OpSize;
257 def IN32rr : I<0xED, RawFrm, (ops),
258 "in %EAX, %DX">, Imp<[DX],[EAX]>;
260 def IN8ri : Ii16<0xE4, RawFrm, (ops i16imm:$port),
261 "in %AL, $port">, Imp<[], [AL]>;
262 def IN16ri : Ii16<0xE5, RawFrm, (ops i16imm:$port),
263 "in %AX, $port">, Imp<[], [AX]>, OpSize;
264 def IN32ri : Ii16<0xE5, RawFrm, (ops i16imm:$port),
265 "in %EAX, $port">, Imp<[],[EAX]>;
267 def OUT8rr : I<0xEE, RawFrm, (ops),
268 "out %DX, %AL">, Imp<[DX, AL], []>;
269 def OUT16rr : I<0xEF, RawFrm, (ops),
270 "out %DX, %AX">, Imp<[DX, AX], []>, OpSize;
271 def OUT32rr : I<0xEF, RawFrm, (ops),
272 "out %DX, %EAX">, Imp<[DX, EAX], []>;
274 def OUT8ir : Ii16<0xE6, RawFrm, (ops i16imm:$port),
275 "out $port, %AL">, Imp<[AL], []>;
276 def OUT16ir : Ii16<0xE7, RawFrm, (ops i16imm:$port),
277 "out $port, %AX">, Imp<[AX], []>, OpSize;
278 def OUT32ir : Ii16<0xE7, RawFrm, (ops i16imm:$port),
279 "out $port, %EAX">, Imp<[EAX], []>;
281 //===----------------------------------------------------------------------===//
282 // Move Instructions...
284 def MOV8rr : I<0x88, MRMDestReg, (ops R8 :$dst, R8 :$src), "mov $dst, $src">;
285 def MOV16rr : I<0x89, MRMDestReg, (ops R16:$dst, R16:$src), "mov $dst, $src">, OpSize;
286 def MOV32rr : I<0x89, MRMDestReg, (ops R32:$dst, R32:$src), "mov $dst, $src">;
287 def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops R8 :$dst, i8imm :$src), "mov $dst, $src">;
288 def MOV16ri : Ii16<0xB8, AddRegFrm, (ops R16:$dst, i16imm:$src), "mov $dst, $src">, OpSize;
289 def MOV32ri : Ii32<0xB8, AddRegFrm, (ops R32:$dst, i32imm:$src), "mov $dst, $src">;
290 def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src), "mov $dst, $src">;
291 def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src), "mov $dst, $src">, OpSize;
292 def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src), "mov $dst, $src">;
294 def MOV8rm : I<0x8A, MRMSrcMem, (ops R8 :$dst, i8mem :$src), "mov $dst, $src">;
295 def MOV16rm : I<0x8B, MRMSrcMem, (ops R16:$dst, i16mem:$src), "mov $dst, $src">, OpSize;
296 def MOV32rm : I<0x8B, MRMSrcMem, (ops R32:$dst, i32mem:$src), "mov $dst, $src">;
298 def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, R8 :$src), "mov $dst, $src">;
299 def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, R16:$src), "mov $dst, $src">, OpSize;
300 def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, R32:$src), "mov $dst, $src">;
302 //===----------------------------------------------------------------------===//
303 // Fixed-Register Multiplication and Division Instructions...
306 // Extra precision multiplication
307 def MUL8r : I<0xF6, MRM4r, (ops R8:$src), "mul $src">,
308 Imp<[AL],[AX]>; // AL,AH = AL*R8
309 def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul $src">,
310 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
311 def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul $src">,
312 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
313 def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
314 "mul $src">, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
315 def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
316 "mul $src">, Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*[mem16]
317 def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
318 "mul $src">, Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
320 // unsigned division/remainder
321 def DIV8r : I<0xF6, MRM6r, (ops R8:$src), "div $src">,
322 Imp<[AX],[AX]>; // AX/r8 = AL,AH
323 def DIV16r : I<0xF7, MRM6r, (ops R16:$src), "div $src">,
324 Imp<[AX,DX],[AX,DX]>, OpSize; // DX:AX/r16 = AX,DX
325 def DIV32r : I<0xF7, MRM6r, (ops R32:$src), "div $src">,
326 Imp<[EAX,EDX],[EAX,EDX]>; // EDX:EAX/r32 = EAX,EDX
327 def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), "div $src">, Imp<[AX],[AX]>; // AX/[mem8] = AL,AH
328 def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), "div $src">, Imp<[AX,DX],[AX,DX]>, OpSize; // DX:AX/[mem16] = AX,DX
329 def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), "div $src">, Imp<[EAX,EDX],[EAX,EDX]>; // EDX:EAX/[mem32] = EAX,EDX
331 // Signed division/remainder.
332 def IDIV8r : I<0xF6, MRM7r, (ops R8:$src), "idiv $src">,
333 Imp<[AX],[AX]>; // AX/r8 = AL,AH
334 def IDIV16r: I<0xF7, MRM7r, (ops R16:$src), "idiv $src">,
335 Imp<[AX,DX],[AX,DX]>, OpSize; // DX:AX/r16 = AX,DX
336 def IDIV32r: I<0xF7, MRM7r, (ops R32:$src), "idiv $src">,
337 Imp<[EAX,EDX],[EAX,EDX]>; // EDX:EAX/r32 = EAX,EDX
338 def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), "idiv $src">, Imp<[AX],[AX]>; // AX/[mem8] = AL,AH
339 def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), "idiv $src">, Imp<[AX,DX],[AX,DX]>, OpSize; // DX:AX/[mem16] = AX,DX
340 def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), "idiv $src">, Imp<[EAX,EDX],[EAX,EDX]>; // EDX:EAX/[mem32] = EAX,EDX
342 // Sign-extenders for division.
343 def CBW : I<0x98, RawFrm, (ops), "cbw">, Imp<[AL],[AH]>; // AX = signext(AL)
344 def CWD : I<0x99, RawFrm, (ops), "cwd">, Imp<[AX],[DX]>; // DX:AX = signext(AX)
345 def CDQ : I<0x99, RawFrm, (ops), "cdq">, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
348 //===----------------------------------------------------------------------===//
349 // Two address Instructions...
351 let isTwoAddress = 1 in {
354 def CMOVB16rr : I<0x42, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
355 "cmovb $dst, $src2">, TB, OpSize; // if <u, R16 = R16
356 def CMOVB16rm : I<0x42, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
357 "cmovb $dst, $src2">, TB, OpSize; // if <u, R16 = [mem16]
358 def CMOVB32rr : I<0x42, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
359 "cmovb $dst, $src2">, TB; // if <u, R32 = R32
360 def CMOVB32rm : I<0x42, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
361 "cmovb $dst, $src2">, TB; // if <u, R32 = [mem32]
363 def CMOVAE16rr: I<0x43, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
364 "cmovae $dst, $src2">, TB, OpSize; // if >=u, R16 = R16
365 def CMOVAE16rm: I<0x43, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
366 "cmovae $dst, $src2">, TB, OpSize; // if >=u, R16 = [mem16]
367 def CMOVAE32rr: I<0x43, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
368 "cmovae $dst, $src2">, TB; // if >=u, R32 = R32
369 def CMOVAE32rm: I<0x43, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
370 "cmovae $dst, $src2">, TB; // if >=u, R32 = [mem32]
372 def CMOVE16rr : I<0x44, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
373 "cmove $dst, $src2">, TB, OpSize; // if ==, R16 = R16
374 def CMOVE16rm : I<0x44, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
375 "cmove $dst, $src2">, TB, OpSize; // if ==, R16 = [mem16]
376 def CMOVE32rr : I<0x44, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
377 "cmove $dst, $src2">, TB; // if ==, R32 = R32
378 def CMOVE32rm : I<0x44, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
379 "cmove $dst, $src2">, TB; // if ==, R32 = [mem32]
381 def CMOVNE16rr: I<0x45, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
382 "cmovne $dst, $src2">, TB, OpSize; // if !=, R16 = R16
383 def CMOVNE16rm: I<0x45, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
384 "cmovne $dst, $src2">, TB, OpSize; // if !=, R16 = [mem16]
385 def CMOVNE32rr: I<0x45, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
386 "cmovne $dst, $src2">, TB; // if !=, R32 = R32
387 def CMOVNE32rm: I<0x45, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
388 "cmovne $dst, $src2">, TB; // if !=, R32 = [mem32]
390 def CMOVBE16rr: I<0x46, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
391 "cmovbe $dst, $src2">, TB, OpSize; // if <=u, R16 = R16
392 def CMOVBE16rm: I<0x46, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
393 "cmovbe $dst, $src2">, TB, OpSize; // if <=u, R16 = [mem16]
394 def CMOVBE32rr: I<0x46, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
395 "cmovbe $dst, $src2">, TB; // if <=u, R32 = R32
396 def CMOVBE32rm: I<0x46, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
397 "cmovbe $dst, $src2">, TB; // if <=u, R32 = [mem32]
399 def CMOVA16rr : I<0x47, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
400 "cmova $dst, $src2">, TB, OpSize; // if >u, R16 = R16
401 def CMOVA16rm : I<0x47, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
402 "cmova $dst, $src2">, TB, OpSize; // if >u, R16 = [mem16]
403 def CMOVA32rr : I<0x47, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
404 "cmova $dst, $src2">, TB; // if >u, R32 = R32
405 def CMOVA32rm : I<0x47, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
406 "cmova $dst, $src2">, TB; // if >u, R32 = [mem32]
408 def CMOVS16rr : I<0x48, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
409 "cmovs $dst, $src2">, TB, OpSize; // if signed, R16 = R16
410 def CMOVS16rm : I<0x48, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
411 "cmovs $dst, $src2">, TB, OpSize; // if signed, R16 = [mem16]
412 def CMOVS32rr : I<0x48, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
413 "cmovs $dst, $src2">, TB; // if signed, R32 = R32
414 def CMOVS32rm : I<0x48, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
415 "cmovs $dst, $src2">, TB; // if signed, R32 = [mem32]
417 def CMOVNS16rr: I<0x49, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
418 "cmovns $dst, $src2">, TB, OpSize; // if !signed, R16 = R16
419 def CMOVNS16rm: I<0x49, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
420 "cmovns $dst, $src2">, TB, OpSize; // if !signed, R16 = [mem16]
421 def CMOVNS32rr: I<0x49, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
422 "cmovns $dst, $src2">, TB; // if !signed, R32 = R32
423 def CMOVNS32rm: I<0x49, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
424 "cmovns $dst, $src2">, TB; // if !signed, R32 = [mem32]
426 def CMOVL16rr : I<0x4C, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
427 "cmovl $dst, $src2">, TB, OpSize; // if <s, R16 = R16
428 def CMOVL16rm : I<0x4C, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
429 "cmovl $dst, $src2">, TB, OpSize; // if <s, R16 = [mem16]
430 def CMOVL32rr : I<0x4C, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
431 "cmovl $dst, $src2">, TB; // if <s, R32 = R32
432 def CMOVL32rm : I<0x4C, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
433 "cmovl $dst, $src2">, TB; // if <s, R32 = [mem32]
435 def CMOVGE16rr: I<0x4D, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
436 "cmovge $dst, $src2">, TB, OpSize; // if >=s, R16 = R16
437 def CMOVGE16rm: I<0x4D, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
438 "cmovge $dst, $src2">, TB, OpSize; // if >=s, R16 = [mem16]
439 def CMOVGE32rr: I<0x4D, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
440 "cmovge $dst, $src2">, TB; // if >=s, R32 = R32
441 def CMOVGE32rm: I<0x4D, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
442 "cmovge $dst, $src2">, TB; // if >=s, R32 = [mem32]
444 def CMOVLE16rr: I<0x4E, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
445 "cmovle $dst, $src2">, TB, OpSize; // if <=s, R16 = R16
446 def CMOVLE16rm: I<0x4E, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
447 "cmovle $dst, $src2">, TB, OpSize; // if <=s, R16 = [mem16]
448 def CMOVLE32rr: I<0x4E, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
449 "cmovle $dst, $src2">, TB; // if <=s, R32 = R32
450 def CMOVLE32rm: I<0x4E, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
451 "cmovle $dst, $src2">, TB; // if <=s, R32 = [mem32]
453 def CMOVG16rr : I<0x4F, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
454 "cmovg $dst, $src2">, TB, OpSize; // if >s, R16 = R16
455 def CMOVG16rm : I<0x4F, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
456 "cmovg $dst, $src2">, TB, OpSize; // if >s, R16 = [mem16]
457 def CMOVG32rr : I<0x4F, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
458 "cmovg $dst, $src2">, TB; // if >s, R32 = R32
459 def CMOVG32rm : I<0x4F, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
460 "cmovg $dst, $src2">, TB; // if >s, R32 = [mem32]
462 // unary instructions
463 def NEG8r : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg $dst">;
464 def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg $dst">, OpSize;
465 def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg $dst">;
466 let isTwoAddress = 0 in {
467 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg $dst">;
468 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg $dst">, OpSize;
469 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg $dst">;
472 def NOT8r : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not $dst">;
473 def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not $dst">, OpSize;
474 def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not $dst">;
475 let isTwoAddress = 0 in {
476 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not $dst">;
477 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not $dst">, OpSize;
478 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not $dst">;
481 def INC8r : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc $dst">;
482 def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc $dst">, OpSize;
483 def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc $dst">;
484 let isTwoAddress = 0 in {
485 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc $dst">;
486 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc $dst">, OpSize;
487 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc $dst">;
490 def DEC8r : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec $dst">;
491 def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec $dst">, OpSize;
492 def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec $dst">;
494 let isTwoAddress = 0 in {
495 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec $dst">;
496 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec $dst">, OpSize;
497 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec $dst">;
500 // Logical operators...
501 def AND8rr : I<0x20, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2), "and $dst, $src2">;
502 def AND16rr : I<0x21, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2), "and $dst, $src2">, OpSize;
503 def AND32rr : I<0x21, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2), "and $dst, $src2">;
505 def AND8rm : I<0x22, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2), "and $dst, $src2">;
506 def AND16rm : I<0x23, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2), "and $dst, $src2">, OpSize;
507 def AND32rm : I<0x23, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2), "and $dst, $src2">;
509 def AND8ri : Ii8 <0x80, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm :$src2),
511 def AND16ri : Ii16<0x81, MRM4r, (ops R16:$dst, R16:$src1, i16imm:$src2),
512 "and $dst, $src2">, OpSize;
513 def AND32ri : Ii32<0x81, MRM4r, (ops R32:$dst, R32:$src1, i32imm:$src2),
515 def AND16ri8 : Ii8<0x83, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
516 "and $dst, $src2" >, OpSize;
517 def AND32ri8 : Ii8<0x83, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
520 let isTwoAddress = 0 in {
521 def AND8mr : I<0x20, MRMDestMem, (ops i8mem :$dst, R8 :$src), "and $dst, $src">;
522 def AND16mr : I<0x21, MRMDestMem, (ops i16mem:$dst, R16:$src), "and $dst, $src">, OpSize;
523 def AND32mr : I<0x21, MRMDestMem, (ops i32mem:$dst, R32:$src), "and $dst, $src">;
524 def AND8mi : Ii8 <0x80, MRM4m, (ops i8mem :$dst, i8imm :$src), "and $dst, $src">;
525 def AND16mi : Ii16<0x81, MRM4m, (ops i16mem:$dst, i16imm:$src), "and $dst, $src">, OpSize;
526 def AND32mi : Ii32<0x81, MRM4m, (ops i32mem:$dst, i32imm:$src), "and $dst, $src">;
527 def AND16mi8 : Ii8 <0x83, MRM4m, (ops i16mem:$dst, i8imm :$src), "and $dst, $src">, OpSize;
528 def AND32mi8 : Ii8 <0x83, MRM4m, (ops i32mem:$dst, i8imm :$src), "and $dst, $src">;
532 def OR8rr : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
534 def OR16rr : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
535 "or $dst, $src2">, OpSize;
536 def OR32rr : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
538 def OR8rm : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
540 def OR16rm : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
541 "or $dst, $src2">, OpSize;
542 def OR32rm : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
545 def OR8ri : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
547 def OR16ri : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
548 "or $dst, $src2">, OpSize;
549 def OR32ri : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
552 def OR16ri8 : Ii8<0x83, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
553 "or $dst, $src2">, OpSize;
554 def OR32ri8 : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
556 let isTwoAddress = 0 in {
557 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
559 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
560 "or $dst, $src">, OpSize;
561 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
563 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
565 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
566 "or $dst, $src">, OpSize;
567 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
569 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i8imm:$src),
570 "or $dst, $src">, OpSize;
571 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i8imm:$src),
576 def XOR8rr : I<0x30, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2), "xor $dst, $src2">;
577 def XOR16rr : I<0x31, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2), "xor $dst, $src2">, OpSize;
578 def XOR32rr : I<0x31, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2), "xor $dst, $src2">;
579 def XOR8rm : I<0x32, MRMSrcMem , (ops R8 :$dst, R8:$src1, i8mem :$src2), "xor $dst, $src2">;
580 def XOR16rm : I<0x33, MRMSrcMem , (ops R16:$dst, R8:$src1, i16mem:$src2), "xor $dst, $src2">, OpSize;
581 def XOR32rm : I<0x33, MRMSrcMem , (ops R32:$dst, R8:$src1, i32mem:$src2), "xor $dst, $src2">;
583 def XOR8ri : Ii8 <0x80, MRM6r, (ops R8:$dst, R8:$src1, i8imm:$src2), "xor $dst, $src2">;
584 def XOR16ri : Ii16 <0x81, MRM6r, (ops R16:$dst, R16:$src1, i16imm:$src2), "xor $dst, $src2">, OpSize;
585 def XOR32ri : Ii32 <0x81, MRM6r, (ops R32:$dst, R32:$src1, i32imm:$src2), "xor $dst, $src2">;
586 def XOR16ri8 : Ii8<0x83, MRM6r, (ops R16:$dst, R16:$src1, i8imm:$src2),
587 "xor $dst, $src2">, OpSize;
588 def XOR32ri8 : Ii8<0x83, MRM6r, (ops R32:$dst, R32:$src1, i8imm:$src2),
590 let isTwoAddress = 0 in {
591 def XOR8mr : I<0x30, MRMDestMem, (ops i8mem :$dst, R8 :$src), "xor $dst, $src">;
592 def XOR16mr : I<0x31, MRMDestMem, (ops i16mem:$dst, R16:$src), "xor $dst, $src">, OpSize;
593 def XOR32mr : I<0x31, MRMDestMem, (ops i32mem:$dst, R32:$src), "xor $dst, $src">;
594 def XOR8mi : Ii8 <0x80, MRM6m, (ops i8mem :$dst, i8imm :$src), "xor $dst, $src">;
595 def XOR16mi : Ii16<0x81, MRM6m, (ops i16mem:$dst, i16imm:$src), "xor $dst, $src">, OpSize;
596 def XOR32mi : Ii32<0x81, MRM6m, (ops i32mem:$dst, i32imm:$src), "xor $dst, $src">;
597 def XOR16mi8 : Ii8 <0x83, MRM6m, (ops i16mem:$dst, i8imm :$src), "xor $dst, $src">, OpSize;
598 def XOR32mi8 : Ii8 <0x83, MRM6m, (ops i32mem:$dst, i8imm :$src), "xor $dst, $src">;
601 // Shift instructions
602 // FIXME: provide shorter instructions when imm8 == 1
603 def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src), "shl $dst, %CL">, Imp<[CL],[]>;
604 def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src), "shl $dst, %CL">, Imp<[CL],[]>, OpSize;
605 def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src), "shl $dst, %CL">, Imp<[CL],[]>;
606 def SHL8ri : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
608 def SHL16ri : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
609 "shl $dst, $src2">, OpSize;
610 def SHL32ri : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
613 let isTwoAddress = 0 in {
614 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst), "shl $dst, %CL">, Imp<[CL],[]>;
615 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst), "shl $dst, %CL">, Imp<[CL],[]>, OpSize;
616 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst), "shl $dst, %CL">, Imp<[CL],[]>;
617 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src), "shl $dst, $src">;
618 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src), "shl $dst, $src">, OpSize;
619 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src), "shl $dst, $src">;
622 def SHR8rCL : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src), "shr $dst, %CL">, Imp<[CL],[]>;
623 def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src), "shr $dst, %CL">, Imp<[CL],[]>, OpSize;
624 def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src), "shr $dst, %CL">, Imp<[CL],[]>;
626 def SHR8ri : Ii8 <0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2), "shr $dst, $src2">;
627 def SHR16ri : Ii8 <0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2), "shr $dst, $src2">, OpSize;
628 def SHR32ri : Ii8 <0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2), "shr $dst, $src2">;
630 let isTwoAddress = 0 in {
631 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst), "shr $dst, %CL">, Imp<[CL],[]>;
632 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst), "shr $dst, %CL">, Imp<[CL],[]>, OpSize;
633 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst), "shr $dst, %CL">, Imp<[CL],[]>;
634 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src), "shr $dst, $src">;
635 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src), "shr $dst, $src">, OpSize;
636 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src), "shr $dst, $src">;
639 def SAR8rCL : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src), "sar $dst, %CL">, Imp<[CL],[]>;
640 def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src), "sar $dst, %CL">, Imp<[CL],[]>, OpSize;
641 def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src), "sar $dst, %CL">, Imp<[CL],[]>;
643 def SAR8ri : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
645 def SAR16ri : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
646 "sar $dst, $src2">, OpSize;
647 def SAR32ri : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
649 let isTwoAddress = 0 in {
650 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst), "sar $dst, %CL">, Imp<[CL],[]>;
651 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst), "sar $dst, %CL">, Imp<[CL],[]>, OpSize;
652 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst), "sar $dst, %CL">, Imp<[CL],[]>;
653 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src), "sar $dst, $src">;
654 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src), "sar $dst, $src">, OpSize;
655 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src), "sar $dst, $src">;
658 def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
659 "shld $dst, $src2, %CL">, Imp<[CL],[]>, TB;
660 def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
661 "shrd $dst, $src2, %CL">, Imp<[CL],[]>, TB;
662 def SHLD32rri8 : Ii8<0xA4, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
663 "shld $dst, $src2, $src3">, TB;
664 def SHRD32rri8 : Ii8<0xAC, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
665 "shrd $dst, $src2, $src3">, TB;
667 let isTwoAddress = 0 in {
668 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
669 "shld $dst, $src2, %CL">, Imp<[CL],[]>, TB;
670 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
671 "shrd $dst, $src2, %CL">, Imp<[CL],[]>, TB;
672 def SHLD32mri8 : Ii8<0xA4, MRMDestMem, (ops i32mem:$dst, R32:$src2, i8imm:$src3),
673 "shld $dst, $src2, $src3">, TB;
674 def SHRD32mri8 : Ii8<0xAC, MRMDestMem, (ops i32mem:$dst, R32:$src2, i8imm:$src3),
675 "shrd $dst, $src2, $src3">, TB;
680 def ADD8rr : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2), "add $dst, $src2">;
681 def ADD16rr : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2), "add $dst, $src2">, OpSize;
682 def ADD32rr : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2), "add $dst, $src2">;
683 def ADD8rm : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2), "add $dst, $src2">;
684 def ADD16rm : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2), "add $dst, $src2">, OpSize;
685 def ADD32rm : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2), "add $dst, $src2">;
687 def ADD8ri : Ii8 <0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2), "add $dst, $src2">;
688 def ADD16ri : Ii16 <0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2), "add $dst, $src2">, OpSize;
689 def ADD32ri : Ii32 <0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2), "add $dst, $src2">;
691 def ADD16ri8 : Ii8 <0x83, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2), "add $dst, $src2">, OpSize;
692 def ADD32ri8 : Ii8 <0x83, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2), "add $dst, $src2">;
694 let isTwoAddress = 0 in {
695 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2), "add $dst, $src2">;
696 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2), "add $dst, $src2">, OpSize;
697 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2), "add $dst, $src2">;
698 def ADD8mi : Ii8 <0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2), "add $dst, $src2">;
699 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2), "add $dst, $src2">, OpSize;
700 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2), "add $dst, $src2">;
701 def ADD16mi8 : Ii8 <0x83, MRM0m, (ops i16mem:$dst, i8imm :$src2), "add $dst, $src2">, OpSize;
702 def ADD32mi8 : Ii8 <0x83, MRM0m, (ops i32mem:$dst, i8imm :$src2), "add $dst, $src2">;
705 def ADC32rr : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2), "adc $dst, $src2">;
706 def ADC32rm : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2), "adc $dst, $src2">;
707 def ADC32ri : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2), "adc $dst, $src2">;
708 def ADC32ri8 : Ii8 <0x83, MRM2r, (ops R32:$dst, R32:$src1, i8imm:$src2), "adc $dst, $src2">;
710 let isTwoAddress = 0 in {
711 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2), "adc $dst, $src2">;
712 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2), "adc $dst, $src2">;
713 def ADC32mi8 : Ii8 <0x83, MRM2m, (ops i32mem:$dst, i8imm :$src2), "adc $dst, $src2">;
716 def SUB8rr : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2), "sub $dst, $src2">;
717 def SUB16rr : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2), "sub $dst, $src2">, OpSize;
718 def SUB32rr : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2), "sub $dst, $src2">;
719 def SUB8rm : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2), "sub $dst, $src2">;
720 def SUB16rm : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2), "sub $dst, $src2">, OpSize;
721 def SUB32rm : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2), "sub $dst, $src2">;
723 def SUB8ri : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
725 def SUB16ri : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
726 "sub $dst, $src2">, OpSize;
727 def SUB32ri : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
729 def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
730 "sub $dst, $src2">, OpSize;
731 def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
733 let isTwoAddress = 0 in {
734 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2), "sub $dst, $src2">;
735 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2), "sub $dst, $src2">, OpSize;
736 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2), "sub $dst, $src2">;
737 def SUB8mi : Ii8 <0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2), "sub $dst, $src2">;
738 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2), "sub $dst, $src2">, OpSize;
739 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2), "sub $dst, $src2">;
740 def SUB16mi8 : Ii8 <0x83, MRM5m, (ops i16mem:$dst, i8imm :$src2), "sub $dst, $src2">, OpSize;
741 def SUB32mi8 : Ii8 <0x83, MRM5m, (ops i32mem:$dst, i8imm :$src2), "sub $dst, $src2">;
744 def SBB32rr : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
746 let isTwoAddress = 0 in {
747 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2), "sbb $dst, $src2">;
748 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2), "sbb $dst, $src2">;
749 def SBB32mi8 : Ii8 <0x83, MRM3m, (ops i32mem:$dst, i8imm :$src2), "sbb $dst, $src2">;
751 def SBB32rm : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
753 def SBB32ri : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
755 def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i8imm:$src2),
758 def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2), "imul $dst, $src2">, TB, OpSize;
759 def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2), "imul $dst, $src2">, TB;
760 def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2), "imul $dst, $src2">, TB, OpSize;
761 def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2), "imul $dst, $src2">, TB ;
763 } // end Two Address instructions
765 // Suprisingly enough, these are not two address instructions!
766 def IMUL16rri : Ii16<0x69, MRMSrcReg, (ops R16:$dst, R16:$src1, i16imm:$src2),
767 "imul $dst, $src1, $src2">, OpSize; // R16 = R16*I16
768 def IMUL32rri : Ii32<0x69, MRMSrcReg, (ops R32:$dst, R32:$src1, i32imm:$src2),
769 "imul $dst, $src1, $src2">; // R32 = R32*I32
770 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, (ops R16:$dst, R16:$src1, i8imm:$src2),
771 "imul $dst, $src1, $src2">, OpSize; // R16 = R16*I8
772 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, (ops R32:$dst, R32:$src1, i8imm:$src2),
773 "imul $dst, $src1, $src2">; // R32 = R32*I8
775 def IMUL16rmi : Ii16<0x69, MRMSrcMem, (ops R32:$dst, i16mem:$src1, i16imm:$src2),
776 "imul $dst, $src1, $src2">, OpSize; // R16 = [mem16]*I16
777 def IMUL32rmi : Ii32<0x69, MRMSrcMem, (ops R32:$dst, i32mem:$src1, i32imm:$src2),
778 "imul $dst, $src1, $src2">; // R32 = [mem32]*I32
779 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, (ops R32:$dst, i16mem:$src1, i8imm :$src2),
780 "imul $dst, $src1, $src2">, OpSize; // R16 = [mem16]*I8
781 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, (ops R32:$dst, i32mem:$src1, i8imm: $src2),
782 "imul $dst, $src1, $src2">; // R32 = [mem32]*I8
784 //===----------------------------------------------------------------------===//
785 // Test instructions are just like AND, except they don't generate a result.
786 def TEST8rr : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
787 "test $src1, $src2">;
788 def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
789 "test $src1, $src2">, OpSize;
790 def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
791 "test $src1, $src2">;
792 def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
793 "test $src1, $src2">;
794 def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
795 "test $src1, $src2">, OpSize;
796 def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
797 "test $src1, $src2">;
798 def TEST8rm : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
799 "test $src1, $src2">;
800 def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
801 "test $src1, $src2">, OpSize;
802 def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
803 "test $src1, $src2">;
805 def TEST8ri : Ii8 <0xF6, MRM0r, (ops R8:$dst, i8imm:$src),
806 "test $dst, $src">; // flags = R8 & imm8
807 def TEST16ri : Ii16<0xF7, MRM0r, (ops R16:$dst, i16imm:$src),
808 "test $dst, $src">, OpSize; // flags = R16 & imm16
809 def TEST32ri : Ii32<0xF7, MRM0r, (ops R32:$dst, i32imm:$src),
810 "test $dst, $src">; // flags = R32 & imm32
811 def TEST8mi : Ii8 <0xF6, MRM0m, (ops i32mem:$dst, i8imm:$src),
812 "test $dst, $src">; // flags = [mem8] & imm8
813 def TEST16mi : Ii16<0xF7, MRM0m, (ops i16mem:$dst, i16imm:$src),
814 "test $dst, $src">, OpSize; // flags = [mem16] & imm16
815 def TEST32mi : Ii32<0xF7, MRM0m, (ops i32mem:$dst, i32imm:$src),
816 "test $dst, $src">; // flags = [mem32] & imm32
820 // Condition code ops, incl. set if equal/not equal/...
821 def SAHF : I<0x9E, RawFrm, (ops), "sahf">, Imp<[AH],[]>; // flags = AH
822 def LAHF : I<0x9F, RawFrm, (ops), "lahf">, Imp<[],[AH]>; // AH = flags
824 def SETBr : I<0x92, MRM0r, (ops R8 :$dst), "setb $dst">, TB; // R8 = < unsign
825 def SETBm : I<0x92, MRM0m, (ops i8mem:$dst), "setb $dst">, TB; // [mem8] = < unsign
826 def SETAEr : I<0x93, MRM0r, (ops R8 :$dst), "setae $dst">, TB; // R8 = >= unsign
827 def SETAEm : I<0x93, MRM0m, (ops i8mem:$dst), "setae $dst">, TB; // [mem8] = >= unsign
828 def SETEr : I<0x94, MRM0r, (ops R8 :$dst), "sete $dst">, TB; // R8 = ==
829 def SETEm : I<0x94, MRM0m, (ops i8mem:$dst), "sete $dst">, TB; // [mem8] = ==
830 def SETNEr : I<0x95, MRM0r, (ops R8 :$dst), "setne $dst">, TB; // R8 = !=
831 def SETNEm : I<0x95, MRM0m, (ops i8mem:$dst), "setne $dst">, TB; // [mem8] = !=
832 def SETBEr : I<0x96, MRM0r, (ops R8 :$dst), "setbe $dst">, TB; // R8 = <= unsign
833 def SETBEm : I<0x96, MRM0m, (ops i8mem:$dst), "setbe $dst">, TB; // [mem8] = <= unsign
834 def SETAr : I<0x97, MRM0r, (ops R8 :$dst), "seta $dst">, TB; // R8 = > signed
835 def SETAm : I<0x97, MRM0m, (ops i8mem:$dst), "seta $dst">, TB; // [mem8] = > signed
836 def SETSr : I<0x98, MRM0r, (ops R8 :$dst), "sets $dst">, TB; // R8 = <sign bit>
837 def SETSm : I<0x98, MRM0m, (ops i8mem:$dst), "sets $dst">, TB; // [mem8] = <sign bit>
838 def SETNSr : I<0x99, MRM0r, (ops R8 :$dst), "setns $dst">, TB; // R8 = !<sign bit>
839 def SETNSm : I<0x99, MRM0m, (ops i8mem:$dst), "setns $dst">, TB; // [mem8] = !<sign bit>
840 def SETPr : I<0x9A, MRM0r, (ops R8 :$dst), "setp $dst">, TB; // R8 = parity
841 def SETPm : I<0x9A, MRM0m, (ops i8mem:$dst), "setp $dst">, TB; // [mem8] = parity
842 def SETLr : I<0x9C, MRM0r, (ops R8 :$dst), "setl $dst">, TB; // R8 = < signed
843 def SETLm : I<0x9C, MRM0m, (ops i8mem:$dst), "setl $dst">, TB; // [mem8] = < signed
844 def SETGEr : I<0x9D, MRM0r, (ops R8 :$dst), "setge $dst">, TB; // R8 = >= signed
845 def SETGEm : I<0x9D, MRM0m, (ops i8mem:$dst), "setge $dst">, TB; // [mem8] = >= signed
846 def SETLEr : I<0x9E, MRM0r, (ops R8 :$dst), "setle $dst">, TB; // R8 = <= signed
847 def SETLEm : I<0x9E, MRM0m, (ops i8mem:$dst), "setle $dst">, TB; // [mem8] = <= signed
848 def SETGr : I<0x9F, MRM0r, (ops R8 :$dst), "setg $dst">, TB; // R8 = < signed
849 def SETGm : I<0x9F, MRM0m, (ops i8mem:$dst), "setg $dst">, TB; // [mem8] = < signed
851 // Integer comparisons
852 def CMP8rr : I<0x38, MRMDestReg, (ops R8 :$src1, R8 :$src2), "cmp $src1, $src2">;
853 def CMP16rr : I<0x39, MRMDestReg, (ops R16:$src1, R16:$src2), "cmp $src1, $src2">, OpSize;
854 def CMP32rr : I<0x39, MRMDestReg, (ops R32:$src1, R32:$src2), "cmp $src1, $src2">;
855 def CMP8mr : I<0x38, MRMDestMem, (ops i8mem :$src1, R8 :$src2), "cmp $src1, $src2">;
856 def CMP16mr : I<0x39, MRMDestMem, (ops i16mem:$src1, R16:$src2), "cmp $src1, $src2">, OpSize;
857 def CMP32mr : I<0x39, MRMDestMem, (ops i32mem:$src1, R32:$src2), "cmp $src1, $src2">;
858 def CMP8rm : I<0x3A, MRMSrcMem , (ops R8 :$src1, i8mem :$src2), "cmp $src1, $src2">;
859 def CMP16rm : I<0x3B, MRMSrcMem , (ops R16:$src1, i16mem:$src2), "cmp $src1, $src2">, OpSize;
860 def CMP32rm : I<0x3B, MRMSrcMem , (ops R32:$src1, i32mem:$src2), "cmp $src1, $src2">;
861 def CMP8ri : Ii8 <0x80, MRM7r, (ops R16:$dst, i8imm:$src), "cmp $dst, $src">;
862 def CMP16ri : Ii16<0x81, MRM7r, (ops R16:$dst, i16imm:$src), "cmp $dst, $src">, OpSize;
863 def CMP32ri : Ii32<0x81, MRM7r, (ops R32:$dst, i32imm:$src), "cmp $dst, $src">;
864 def CMP8mi : Ii8 <0x80, MRM7m, (ops i8mem :$dst, i8imm :$src), "cmp $dst, $src">;
865 def CMP16mi : Ii16<0x81, MRM7m, (ops i16mem:$dst, i16imm:$src), "cmp $dst, $src">, OpSize;
866 def CMP32mi : Ii32<0x81, MRM7m, (ops i32mem:$dst, i32imm:$src), "cmp $dst, $src">;
868 // Sign/Zero extenders
869 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src), "movsx $dst, $src">, TB, OpSize;
870 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src), "movsx $dst, $src">, TB;
871 def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src), "movsx $dst, $src">, TB;
872 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src), "movsx $dst, $src">, TB, OpSize;
873 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src), "movsx $dst, $src">, TB;
874 def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src), "movsx $dst, $src">, TB;
876 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src), "movzx $dst, $src">, TB, OpSize;
877 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src), "movzx $dst, $src">, TB;
878 def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src), "movzx $dst, $src">, TB;
879 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src), "movzx $dst, $src">, TB, OpSize;
880 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src), "movzx $dst, $src">, TB;
881 def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src), "movzx $dst, $src">, TB;
884 //===----------------------------------------------------------------------===//
885 // Floating point support
886 //===----------------------------------------------------------------------===//
888 // FIXME: These need to indicate mod/ref sets for FP regs... & FP 'TOP'
890 // Floating point instruction template
891 class FPI<bits<8> o, Format F, FPFormat fp, dag ops, string asm>
892 : X86Inst<"", o, F, NoMem, NoImm>, II<ops, asm> {
893 let FPForm = fp; let FPFormBits = FPForm.Value;
896 // Pseudo instructions for floating point. We use these pseudo instructions
897 // because they can be expanded by the fp spackifier into one of many different
898 // forms of instructions for doing these operations. Until the stackifier runs,
899 // we prefer to be abstract.
900 def FpMOV : FPI<0, Pseudo, SpecialFP, (ops RFP, RFP), "">; // f1 = fmov f2
901 def FpADD : FPI<0, Pseudo, TwoArgFP , (ops RFP, RFP, RFP), "">; // f1 = fadd f2, f3
902 def FpSUB : FPI<0, Pseudo, TwoArgFP , (ops RFP, RFP, RFP), "">; // f1 = fsub f2, f3
903 def FpMUL : FPI<0, Pseudo, TwoArgFP , (ops RFP, RFP, RFP), "">; // f1 = fmul f2, f3
904 def FpDIV : FPI<0, Pseudo, TwoArgFP , (ops RFP, RFP, RFP), "">; // f1 = fdiv f2, f3
906 def FpGETRESULT : FPI<0, Pseudo, SpecialFP, (ops RFP), "">; // FPR = ST(0)
907 def FpSETRESULT : FPI<0, Pseudo, SpecialFP, (ops RFP), "">; // ST(0) = FPR
909 // FADD reg, mem: Before stackification, these are represented by: R1 = FADD* R2, [mem]
910 def FADD32m : FPI<0xD8, MRM0m, OneArgFPRW, (ops f32mem:$src), "fadd $src">; // ST(0) = ST(0) + [mem32real]
911 def FADD64m : FPI<0xDC, MRM0m, OneArgFPRW, (ops f64mem:$src), "fadd $src">; // ST(0) = ST(0) + [mem64real]
913 def FIADD16m : FPI<0xDE, MRM0m, OneArgFPRW, (ops i16mem:$src), // ST(0) = ST(0) + [mem16int]
915 def FIADD32m : FPI<0xDA, MRM0m, OneArgFPRW, (ops i32mem:$src), // ST(0) = ST(0) + [mem32int]
919 // FMUL reg, mem: Before stackification, these are represented by: R1 = FMUL* R2, [mem]
920 def FMUL32m : FPI<0xD8, MRM1m, OneArgFPRW, (ops f32mem:$src), "fmul $src">; // ST(0) = ST(0) * [mem32real]
921 def FMUL64m : FPI<0xDC, MRM1m, OneArgFPRW, (ops f64mem:$src), "fmul $src">; // ST(0) = ST(0) * [mem64real]
922 //def FIMUL16m : FPI16m<"fimul", 0xDE, MRM1m, OneArgFPRW>; // ST(0) = ST(0) * [mem16int]
923 //def FIMUL32m : FPI32m<"fimul", 0xDA, MRM1m, OneArgFPRW>; // ST(0) = ST(0) * [mem32int]
925 // FSUB reg, mem: Before stackification, these are represented by: R1 = FSUB* R2, [mem]
926 def FSUB32m : FPI<0xD8, MRM4m, OneArgFPRW, (ops f32mem:$src), "fsub $src">; // ST(0) = ST(0) - [mem32real]
927 def FSUB64m : FPI<0xDC, MRM4m, OneArgFPRW, (ops f64mem:$src), "fsub $src">; // ST(0) = ST(0) - [mem64real]
928 //def FISUB16m : FPI16m<"fisub", 0xDE, MRM4m, OneArgFPRW>; // ST(0) = ST(0) - [mem16int]
929 //def FISUB32m : FPI32m<"fisub", 0xDA, MRM4m, OneArgFPRW>; // ST(0) = ST(0) - [mem32int]
931 // FSUBR reg, mem: Before stackification, these are represented by: R1 = FSUBR* R2, [mem]
932 // Note that the order of operands does not reflect the operation being performed.
933 def FSUBR32m : FPI<0xD8, MRM5m, OneArgFPRW, (ops f32mem:$src), "fsubr $src">; // ST(0) = [mem32real] - ST(0)
934 def FSUBR64m : FPI<0xDC, MRM5m, OneArgFPRW, (ops f64mem:$src), "fsubr $src">; // ST(0) = [mem64real] - ST(0)
935 //def FISUBR16m : FPI16m<"fisubr", 0xDE, MRM5m, OneArgFPRW>; // ST(0) = [mem16int] - ST(0)
936 //def FISUBR32m : FPI32m<"fisubr", 0xDA, MRM5m, OneArgFPRW>; // ST(0) = [mem32int] - ST(0)
938 // FDIV reg, mem: Before stackification, these are represented by: R1 = FDIV* R2, [mem]
939 def FDIV32m : FPI<0xD8, MRM6m, OneArgFPRW, (ops f32mem:$src), "fdiv $src">; // ST(0) = ST(0) / [mem32real]
940 def FDIV64m : FPI<0xDC, MRM6m, OneArgFPRW, (ops f64mem:$src), "fdiv $src">; // ST(0) = ST(0) / [mem64real]
941 //def FIDIV16m : FPI16m<"fidiv", 0xDE, MRM6m, OneArgFPRW>; // ST(0) = ST(0) / [mem16int]
942 //def FIDIV32m : FPI32m<"fidiv", 0xDA, MRM6m, OneArgFPRW>; // ST(0) = ST(0) / [mem32int]
944 // FDIVR reg, mem: Before stackification, these are represented by: R1 = FDIVR* R2, [mem]
945 // Note that the order of operands does not reflect the operation being performed.
946 def FDIVR32m : FPI<0xD8, MRM7m, OneArgFPRW, (ops f32mem:$src), "fdivr $src">; // ST(0) = [mem32real] / ST(0)
947 def FDIVR64m : FPI<0xDC, MRM7m, OneArgFPRW, (ops f64mem:$src), "fdivr $src">; // ST(0) = [mem64real] / ST(0)
948 //def FIDIVR16m : FPI16m<"fidivr", 0xDE, MRM7m, OneArgFPRW>; // ST(0) = [mem16int] / ST(0)
949 //def FIDIVR32m : FPI32m<"fidivr", 0xDA, MRM7m, OneArgFPRW>; // ST(0) = [mem32int] / ST(0)
952 // Floating point cmovs...
953 let isTwoAddress = 1, Uses = [ST0], Defs = [ST0] in {
954 def FCMOVB : FPI<0xC0, AddRegFrm, CondMovFP,
955 (ops RST:$op), "fcmovb %ST(0), $op">, DA;
956 def FCMOVBE : FPI<0xD0, AddRegFrm, CondMovFP,
957 (ops RST:$op), "fcmovbe %ST(0), $op">, DA;
958 def FCMOVE : FPI<0xC8, AddRegFrm, CondMovFP,
959 (ops RST:$op), "fcmove %ST(0), $op">, DA;
960 def FCMOVAE : FPI<0xC0, AddRegFrm, CondMovFP,
961 (ops RST:$op), "fcmovae %ST(0), $op">, DB;
962 def FCMOVA : FPI<0xD0, AddRegFrm, CondMovFP,
963 (ops RST:$op), "fcmova %ST(0), $op">, DB;
964 def FCMOVNE : FPI<0xC8, AddRegFrm, CondMovFP,
965 (ops RST:$op), "fcmovne %ST(0), $op">, DB;
968 // Floating point loads & stores...
969 def FLDrr : FPI<0xC0, AddRegFrm, NotFP, (ops RST:$src), "fld $src">, D9;
970 def FLD32m : FPI<0xD9, MRM0m, ZeroArgFP, (ops f32mem:$src), "fld $src">;
971 def FLD64m : FPI<0xDD, MRM0m, ZeroArgFP, (ops f64mem:$src), "fld $src">;
972 def FLD80m : FPI<0xDB, MRM5m, ZeroArgFP, (ops f80mem:$src), "fld $src">;
973 def FILD16m : FPI<0xDF, MRM0m, ZeroArgFP, (ops i16mem:$src), "fild $src">;
974 def FILD32m : FPI<0xDB, MRM0m, ZeroArgFP, (ops i32mem:$src), "fild $src">;
975 def FILD64m : FPI<0xDF, MRM5m, ZeroArgFP, (ops i64mem:$src), "fild $src">;
977 def FSTrr : FPI<0xD0, AddRegFrm, NotFP, (ops RST:$op), "fst $op">, DD;
978 def FSTPrr : FPI<0xD8, AddRegFrm, NotFP, (ops RST:$op), "fstp $op">, DD;
979 def FST32m : FPI<0xD9, MRM2m, OneArgFP, (ops f32mem:$op), "fst $op">;
980 def FST64m : FPI<0xDD, MRM2m, OneArgFP, (ops f64mem:$op), "fst $op">;
981 def FSTP32m : FPI<0xD9, MRM3m, OneArgFP, (ops f32mem:$op), "fstp $op">;
982 def FSTP64m : FPI<0xDD, MRM3m, OneArgFP, (ops f64mem:$op), "fstp $op">;
983 def FSTP80m : FPI<0xDB, MRM7m, OneArgFP, (ops f80mem:$op), "fstp $op">;
985 def FIST16m : FPI<0xDF, MRM2m , OneArgFP, (ops i16mem:$op), "fist $op">;
986 def FIST32m : FPI<0xDB, MRM2m , OneArgFP, (ops i32mem:$op), "fist $op">;
987 def FISTP16m : FPI<0xDF, MRM3m , NotFP , (ops i16mem:$op), "fistp $op">;
988 def FISTP32m : FPI<0xDB, MRM3m , NotFP , (ops i32mem:$op), "fistp $op">;
989 def FISTP64m : FPI<0xDF, MRM7m , OneArgFP, (ops i64mem:$op), "fistpll $op">;
991 def FXCH : FPI<0xC8, AddRegFrm, NotFP, (ops RST:$op), "fxch $op">, D9; // fxch ST(i), ST(0)
993 // Floating point constant loads...
994 def FLD0 : FPI<0xEE, RawFrm, ZeroArgFP, (ops), "fldz">, D9;
995 def FLD1 : FPI<0xE8, RawFrm, ZeroArgFP, (ops), "fld1">, D9;
998 // Unary operations...
999 def FCHS : FPI<0xE0, RawFrm, OneArgFPRW, (ops), "fchs">, D9; // f1 = fchs f2
1000 def FTST : FPI<0xE4, RawFrm, OneArgFP, (ops), "ftst">, D9; // ftst ST(0)
1002 // Binary arithmetic operations...
1003 class FPST0rInst<bits<8> o, dag ops, string asm> : I<o, AddRegFrm, ops, asm>, D8 {
1004 list<Register> Uses = [ST0];
1005 list<Register> Defs = [ST0];
1007 class FPrST0Inst<bits<8> o, dag ops, string asm> : I<o, AddRegFrm, ops, asm>, DC {
1008 list<Register> Uses = [ST0];
1010 class FPrST0PInst<bits<8> o, dag ops, string asm> : I<o, AddRegFrm, ops, asm>, DE {
1011 list<Register> Uses = [ST0];
1014 def FADDST0r : FPST0rInst <0xC0, (ops RST:$op), "fadd $op">;
1015 def FADDrST0 : FPrST0Inst <0xC0, (ops RST:$op), "fadd $op, %ST(0)">;
1016 def FADDPrST0 : FPrST0PInst<0xC0, (ops RST:$op), "faddp $op">;
1018 def FSUBRST0r : FPST0rInst <0xE8, (ops RST:$op), "fsubr $op">;
1019 def FSUBrST0 : FPrST0Inst <0xE8, (ops RST:$op), "fsub $op, %ST(0)">;
1020 def FSUBPrST0 : FPrST0PInst<0xE8, (ops RST:$op), "fsubp $op">;
1022 def FSUBST0r : FPST0rInst <0xE0, (ops RST:$op), "fsub $op">;
1023 def FSUBRrST0 : FPrST0Inst <0xE0, (ops RST:$op), "fsubr $op, %ST(0)">;
1024 def FSUBRPrST0 : FPrST0PInst<0xE0, (ops RST:$op), "fsubrp $op">;
1026 def FMULST0r : FPST0rInst <0xC8, (ops RST:$op), "fmul $op">;
1027 def FMULrST0 : FPrST0Inst <0xC8, (ops RST:$op), "fmul $op, %ST(0)">;
1028 def FMULPrST0 : FPrST0PInst<0xC8, (ops RST:$op), "fmulp $op">;
1030 def FDIVRST0r : FPST0rInst <0xF8, (ops RST:$op), "fdivr $op">;
1031 def FDIVrST0 : FPrST0Inst <0xF8, (ops RST:$op), "fdiv $op, %ST(0)">;
1032 def FDIVPrST0 : FPrST0PInst<0xF8, (ops RST:$op), "fdivp $op">;
1034 def FDIVST0r : FPST0rInst <0xF0, (ops RST:$op), "fdiv $op">; // ST(0) = ST(0) / ST(i)
1035 def FDIVRrST0 : FPrST0Inst <0xF0, (ops RST:$op), "fdivr $op, %ST(0)">; // ST(i) = ST(0) / ST(i)
1036 def FDIVRPrST0 : FPrST0PInst<0xF0, (ops RST:$op), "fdivrp $op">; // ST(i) = ST(0) / ST(i), pop
1038 // Floating point compares
1039 def FUCOMr : FPI<0xE0, AddRegFrm, CompareFP, (ops RST:$reg),
1040 "fucom $reg">, DD, Imp<[ST0],[]>; // FPSW = compare ST(0) with ST(i)
1041 def FUCOMPr : I<0xE8, AddRegFrm, (ops RST:$reg),
1042 "fucomp $reg">, DD, Imp<[ST0],[]>; // FPSW = compare ST(0) with ST(i), pop
1043 def FUCOMPPr : I<0xE9, RawFrm, (ops),
1044 "fucompp">, DA, Imp<[ST0],[]>; // compare ST(0) with ST(1), pop, pop
1046 def FUCOMIr : FPI<0xE8, AddRegFrm, CompareFP, (ops RST:$reg),
1047 "fucomi %ST(0), $reg">, DB, Imp<[ST0],[]>; // CC = compare ST(0) with ST(i)
1048 def FUCOMIPr : I<0xE8, AddRegFrm, (ops RST:$reg),
1049 "fucomip %ST(0), $reg">, DF, Imp<[ST0],[]>; // CC = compare ST(0) with ST(i), pop
1052 // Floating point flag ops
1053 def FNSTSW8r : I<0xE0, RawFrm, (ops), "fnstsw">, DF, Imp<[],[AX]>; // AX = fp flags
1055 def FNSTCW16m : I<0xD9, MRM7m, (ops i16mem:$dst), "fnstcw $dst">; // [mem16] = X87 control world
1056 def FLDCW16m : I<0xD9, MRM5m, (ops i16mem:$dst), "fldcw $dst">; // X87 control world = [mem16]