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 //===----------------------------------------------------------------------===//
17 // X86 specific DAG Nodes.
20 def SDTX86CmpTest : SDTypeProfile<1, 2, [SDTCisVT<0, FlagVT>, SDTCisInt<1>,
23 def SDTX86Cmov : SDTypeProfile<1, 4,
24 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
25 SDTCisVT<3, OtherVT>, SDTCisVT<4, FlagVT>]>;
27 def SDTX86BrCond : SDTypeProfile<0, 3,
28 [SDTCisVT<0, OtherVT>,
29 SDTCisVT<1, OtherVT>, SDTCisVT<2, FlagVT>]>;
31 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest, []>;
32 def X86test : SDNode<"X86ISD::TEST", SDTX86CmpTest, []>;
34 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov, []>;
35 def X86Brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond, [SDNPHasChain]>;
37 //===----------------------------------------------------------------------===//
38 // X86 Operand Definitions.
41 // *mem - Operand definitions for the funky X86 addressing mode operands.
43 class X86MemOperand<string printMethod> : Operand<i32> {
44 let PrintMethod = printMethod;
45 let NumMIOperands = 4;
46 let MIOperandInfo = (ops R32, i8imm, R32, i32imm);
49 def i8mem : X86MemOperand<"printi8mem">;
50 def i16mem : X86MemOperand<"printi16mem">;
51 def i32mem : X86MemOperand<"printi32mem">;
52 def i64mem : X86MemOperand<"printi64mem">;
53 def f32mem : X86MemOperand<"printf32mem">;
54 def f64mem : X86MemOperand<"printf64mem">;
55 def f80mem : X86MemOperand<"printf80mem">;
57 def SSECC : Operand<i8> {
58 let PrintMethod = "printSSECC";
61 // A couple of more descriptive operand definitions.
62 // 16-bits but only 8 bits are significant.
63 def i16i8imm : Operand<i16>;
64 // 32-bits but only 8 bits are significant.
65 def i32i8imm : Operand<i32>;
67 // PCRelative calls need special operand formatting.
68 let PrintMethod = "printCallOperand" in
69 def calltarget : Operand<i32>;
71 // Branch targets have OtherVT type.
72 def brtarget : Operand<OtherVT>;
74 //===----------------------------------------------------------------------===//
75 // X86 Complex Pattern Definitions.
78 // Define X86 specific addressing mode.
79 def addr : ComplexPattern<i32, 4, "SelectAddr", []>;
80 def leaaddr : ComplexPattern<i32, 4, "SelectLEAAddr",
82 frameindex, constpool, globaladdr, externalsym]>;
84 //===----------------------------------------------------------------------===//
85 // X86 Instruction Format Definitions.
88 // Format specifies the encoding used by the instruction. This is part of the
89 // ad-hoc solution used to emit machine instruction encodings by our machine
91 class Format<bits<5> val> {
95 def Pseudo : Format<0>; def RawFrm : Format<1>;
96 def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
97 def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
98 def MRMSrcMem : Format<6>;
99 def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
100 def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
101 def MRM6r : Format<22>; def MRM7r : Format<23>;
102 def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
103 def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
104 def MRM6m : Format<30>; def MRM7m : Format<31>;
106 //===----------------------------------------------------------------------===//
107 // X86 specific pattern fragments.
110 // ImmType - This specifies the immediate type used by an instruction. This is
111 // part of the ad-hoc solution used to emit machine instruction encodings by our
112 // machine code emitter.
113 class ImmType<bits<2> val> {
116 def NoImm : ImmType<0>;
117 def Imm8 : ImmType<1>;
118 def Imm16 : ImmType<2>;
119 def Imm32 : ImmType<3>;
121 // FPFormat - This specifies what form this FP instruction has. This is used by
122 // the Floating-Point stackifier pass.
123 class FPFormat<bits<3> val> {
126 def NotFP : FPFormat<0>;
127 def ZeroArgFP : FPFormat<1>;
128 def OneArgFP : FPFormat<2>;
129 def OneArgFPRW : FPFormat<3>;
130 def TwoArgFP : FPFormat<4>;
131 def CompareFP : FPFormat<5>;
132 def CondMovFP : FPFormat<6>;
133 def SpecialFP : FPFormat<7>;
136 class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
138 let Namespace = "X86";
140 bits<8> Opcode = opcod;
142 bits<5> FormBits = Form.Value;
144 bits<2> ImmTypeBits = ImmT.Value;
146 dag OperandList = ops;
147 string AsmString = AsmStr;
150 // Attributes specific to X86 instructions...
152 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
154 bits<4> Prefix = 0; // Which prefix byte does this inst have?
155 FPFormat FPForm; // What flavor of FP instruction is this?
156 bits<3> FPFormBits = 0;
159 class Imp<list<Register> uses, list<Register> defs> {
160 list<Register> Uses = uses;
161 list<Register> Defs = defs;
165 // Prefix byte classes which are used to indicate to the ad-hoc machine code
166 // emitter that various prefix bytes are required.
167 class OpSize { bit hasOpSizePrefix = 1; }
168 class TB { bits<4> Prefix = 1; }
169 class REP { bits<4> Prefix = 2; }
170 class D8 { bits<4> Prefix = 3; }
171 class D9 { bits<4> Prefix = 4; }
172 class DA { bits<4> Prefix = 5; }
173 class DB { bits<4> Prefix = 6; }
174 class DC { bits<4> Prefix = 7; }
175 class DD { bits<4> Prefix = 8; }
176 class DE { bits<4> Prefix = 9; }
177 class DF { bits<4> Prefix = 10; }
178 class XD { bits<4> Prefix = 11; }
179 class XS { bits<4> Prefix = 12; }
182 //===----------------------------------------------------------------------===//
183 // Pattern fragments...
185 def i16immSExt8 : PatLeaf<(i16 imm), [{
186 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
187 // sign extended field.
188 return (int)N->getValue() == (signed char)N->getValue();
191 def i32immSExt8 : PatLeaf<(i32 imm), [{
192 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
193 // sign extended field.
194 return (int)N->getValue() == (signed char)N->getValue();
197 def i16immZExt8 : PatLeaf<(i16 imm), [{
198 // i16immZExt8 predicate - True if the 16-bit immediate fits in a 8-bit zero
200 return (unsigned)N->getValue() == (unsigned char)N->getValue();
203 // Helper fragments for loads.
204 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
205 def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
206 def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
208 def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i1))>;
209 def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i1))>;
210 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i8))>;
211 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i8))>;
212 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i16))>;
214 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i1))>;
215 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i1))>;
216 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i8))>;
217 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i8))>;
218 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i16))>;
220 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extload node:$ptr, i1))>;
223 //===----------------------------------------------------------------------===//
224 // Instruction templates...
226 class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
227 : X86Inst<o, f, NoImm, ops, asm> {
228 let Pattern = pattern;
230 class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
231 : X86Inst<o, f, Imm8 , ops, asm> {
232 let Pattern = pattern;
234 class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
235 : X86Inst<o, f, Imm16, ops, asm> {
236 let Pattern = pattern;
238 class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
239 : X86Inst<o, f, Imm32, ops, asm> {
240 let Pattern = pattern;
243 //===----------------------------------------------------------------------===//
244 // Instruction list...
247 def PHI : I<0, Pseudo, (ops variable_ops), "PHINODE", []>; // PHI node.
248 def NOOP : I<0x90, RawFrm, (ops), "nop", []>; // nop
250 def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN", []>;
251 def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
252 "#ADJCALLSTACKUP", []>;
253 def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
254 def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
255 let isTerminator = 1 in
256 let Defs = [FP0, FP1, FP2, FP3, FP4, FP5, FP6] in
257 def FP_REG_KILL : I<0, Pseudo, (ops), "#FP_REG_KILL", []>;
259 //===----------------------------------------------------------------------===//
260 // Control Flow Instructions...
263 // Return instructions.
264 let isTerminator = 1, isReturn = 1, isBarrier = 1 in
265 def RET : I<0xC3, RawFrm, (ops), "ret", [(ret)]>;
266 let isTerminator = 1, isReturn = 1, isBarrier = 1 in
267 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt", []>;
269 // All branches are RawFrm, Void, Branch, and Terminators
270 let isBranch = 1, isTerminator = 1 in
271 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
272 I<opcode, RawFrm, ops, asm, pattern>;
275 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
277 def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
278 [(X86Brcond bb:$dst, SETEQ, STATUS)]>, Imp<[STATUS],[]>, TB;
279 def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
280 [(X86Brcond bb:$dst, SETNE, STATUS)]>, Imp<[STATUS],[]>, TB;
281 def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
282 [(X86Brcond bb:$dst, SETLT, STATUS)]>, Imp<[STATUS],[]>, TB;
283 def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
284 [(X86Brcond bb:$dst, SETLE, STATUS)]>, Imp<[STATUS],[]>, TB;
285 def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
286 [(X86Brcond bb:$dst, SETGT, STATUS)]>, Imp<[STATUS],[]>, TB;
287 def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
288 [(X86Brcond bb:$dst, SETGE, STATUS)]>, Imp<[STATUS],[]>, TB;
290 def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
291 [(X86Brcond bb:$dst, SETULT, STATUS)]>, Imp<[STATUS],[]>, TB;
292 def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
293 [(X86Brcond bb:$dst, SETULE, STATUS)]>, Imp<[STATUS],[]>, TB;
294 def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
295 [(X86Brcond bb:$dst, SETUGT, STATUS)]>, Imp<[STATUS],[]>, TB;
296 def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
297 [(X86Brcond bb:$dst, SETUGE, STATUS)]>, Imp<[STATUS],[]>, TB;
299 def JS : IBr<0x88, (ops brtarget:$dst), "js $dst", []>, TB;
300 def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst", []>, TB;
301 def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst", []>, TB;
302 def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst", []>, TB;
304 //===----------------------------------------------------------------------===//
305 // Call Instructions...
308 // All calls clobber the non-callee saved registers...
309 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
310 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
311 def CALLpcrel32 : I<0xE8, RawFrm, (ops calltarget:$dst), "call $dst", []>;
312 def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst", []>;
313 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst), "call {*}$dst", []>;
317 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
318 def TAILJMPd : IBr<0xE9, (ops calltarget:$dst), "jmp $dst # TAIL CALL", []>;
319 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
320 def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
321 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
322 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
323 "jmp {*}$dst # TAIL CALL", []>;
325 // ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
326 // way, except that it is marked as being a terminator. This causes the epilog
327 // inserter to insert reloads of callee saved registers BEFORE this. We need
328 // this until we have a more accurate way of tracking where the stack pointer is
329 // within a function.
330 let isTerminator = 1, isTwoAddress = 1 in
331 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
332 "add{l} {$src2, $dst|$dst, $src2}", []>;
334 //===----------------------------------------------------------------------===//
335 // Miscellaneous Instructions...
337 def LEAVE : I<0xC9, RawFrm,
338 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
339 def POP32r : I<0x58, AddRegFrm,
340 (ops R32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
342 let isTwoAddress = 1 in // R32 = bswap R32
343 def BSWAP32r : I<0xC8, AddRegFrm,
344 (ops R32:$dst, R32:$src), "bswap{l} $dst", []>, TB;
346 def XCHG8rr : I<0x86, MRMDestReg, // xchg R8, R8
347 (ops R8:$src1, R8:$src2),
348 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
349 def XCHG16rr : I<0x87, MRMDestReg, // xchg R16, R16
350 (ops R16:$src1, R16:$src2),
351 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
352 def XCHG32rr : I<0x87, MRMDestReg, // xchg R32, R32
353 (ops R32:$src1, R32:$src2),
354 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
356 def XCHG8mr : I<0x86, MRMDestMem,
357 (ops i8mem:$src1, R8:$src2),
358 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
359 def XCHG16mr : I<0x87, MRMDestMem,
360 (ops i16mem:$src1, R16:$src2),
361 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
362 def XCHG32mr : I<0x87, MRMDestMem,
363 (ops i32mem:$src1, R32:$src2),
364 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
365 def XCHG8rm : I<0x86, MRMSrcMem,
366 (ops R8:$src1, i8mem:$src2),
367 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
368 def XCHG16rm : I<0x87, MRMSrcMem,
369 (ops R16:$src1, i16mem:$src2),
370 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
371 def XCHG32rm : I<0x87, MRMSrcMem,
372 (ops R32:$src1, i32mem:$src2),
373 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
375 def LEA16r : I<0x8D, MRMSrcMem,
376 (ops R16:$dst, i32mem:$src),
377 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
378 def LEA32r : I<0x8D, MRMSrcMem,
379 (ops R32:$dst, i32mem:$src),
380 "lea{l} {$src|$dst}, {$dst|$src}",
381 [(set R32:$dst, leaaddr:$src)]>;
383 def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}", []>,
384 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
385 def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}", []>,
386 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
387 def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsd|rep movsd}", []>,
388 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
390 def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}", []>,
391 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
392 def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}", []>,
393 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
394 def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}", []>,
395 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
398 //===----------------------------------------------------------------------===//
399 // Input/Output Instructions...
401 def IN8rr : I<0xEC, RawFrm, (ops),
402 "in{b} {%dx, %al|%AL, %DX}",
403 [(set AL, (readport DX))]>, Imp<[DX], [AL]>;
404 def IN16rr : I<0xED, RawFrm, (ops),
405 "in{w} {%dx, %ax|%AX, %DX}",
406 [(set AX, (readport DX))]>, Imp<[DX], [AX]>, OpSize;
407 def IN32rr : I<0xED, RawFrm, (ops),
408 "in{l} {%dx, %eax|%EAX, %DX}",
409 [(set EAX, (readport DX))]>, Imp<[DX],[EAX]>;
411 def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
412 "in{b} {$port, %al|%AL, $port}",
413 [(set AL, (readport i16immZExt8:$port))]>,
415 def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
416 "in{w} {$port, %ax|%AX, $port}",
417 [(set AX, (readport i16immZExt8:$port))]>,
418 Imp<[], [AX]>, OpSize;
419 def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
420 "in{l} {$port, %eax|%EAX, $port}",
421 [(set EAX, (readport i16immZExt8:$port))]>,
424 def OUT8rr : I<0xEE, RawFrm, (ops),
425 "out{b} {%al, %dx|%DX, %AL}",
426 [(writeport AL, DX)]>, Imp<[DX, AL], []>;
427 def OUT16rr : I<0xEF, RawFrm, (ops),
428 "out{w} {%ax, %dx|%DX, %AX}",
429 [(writeport AX, DX)]>, Imp<[DX, AX], []>, OpSize;
430 def OUT32rr : I<0xEF, RawFrm, (ops),
431 "out{l} {%eax, %dx|%DX, %EAX}",
432 [(writeport EAX, DX)]>, Imp<[DX, EAX], []>;
434 def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
435 "out{b} {%al, $port|$port, %AL}",
436 [(writeport AL, i16immZExt8:$port)]>,
438 def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
439 "out{w} {%ax, $port|$port, %AX}",
440 [(writeport AX, i16immZExt8:$port)]>,
441 Imp<[AX], []>, OpSize;
442 def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
443 "out{l} {%eax, $port|$port, %EAX}",
444 [(writeport EAX, i16immZExt8:$port)]>,
447 //===----------------------------------------------------------------------===//
448 // Move Instructions...
450 def MOV8rr : I<0x88, MRMDestReg, (ops R8 :$dst, R8 :$src),
451 "mov{b} {$src, $dst|$dst, $src}", []>;
452 def MOV16rr : I<0x89, MRMDestReg, (ops R16:$dst, R16:$src),
453 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
454 def MOV32rr : I<0x89, MRMDestReg, (ops R32:$dst, R32:$src),
455 "mov{l} {$src, $dst|$dst, $src}", []>;
456 def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops R8 :$dst, i8imm :$src),
457 "mov{b} {$src, $dst|$dst, $src}",
458 [(set R8:$dst, imm:$src)]>;
459 def MOV16ri : Ii16<0xB8, AddRegFrm, (ops R16:$dst, i16imm:$src),
460 "mov{w} {$src, $dst|$dst, $src}",
461 [(set R16:$dst, imm:$src)]>, OpSize;
462 def MOV32ri : Ii32<0xB8, AddRegFrm, (ops R32:$dst, i32imm:$src),
463 "mov{l} {$src, $dst|$dst, $src}",
464 [(set R32:$dst, imm:$src)]>;
465 def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
466 "mov{b} {$src, $dst|$dst, $src}",
467 [(store (i8 imm:$src), addr:$dst)]>;
468 def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
469 "mov{w} {$src, $dst|$dst, $src}",
470 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
471 def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
472 "mov{l} {$src, $dst|$dst, $src}",
473 [(store (i32 imm:$src), addr:$dst)]>;
475 def MOV8rm : I<0x8A, MRMSrcMem, (ops R8 :$dst, i8mem :$src),
476 "mov{b} {$src, $dst|$dst, $src}",
477 [(set R8:$dst, (load addr:$src))]>;
478 def MOV16rm : I<0x8B, MRMSrcMem, (ops R16:$dst, i16mem:$src),
479 "mov{w} {$src, $dst|$dst, $src}",
480 [(set R16:$dst, (load addr:$src))]>, OpSize;
481 def MOV32rm : I<0x8B, MRMSrcMem, (ops R32:$dst, i32mem:$src),
482 "mov{l} {$src, $dst|$dst, $src}",
483 [(set R32:$dst, (load addr:$src))]>;
485 def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, R8 :$src),
486 "mov{b} {$src, $dst|$dst, $src}",
487 [(store R8:$src, addr:$dst)]>;
488 def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, R16:$src),
489 "mov{w} {$src, $dst|$dst, $src}",
490 [(store R16:$src, addr:$dst)]>, OpSize;
491 def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, R32:$src),
492 "mov{l} {$src, $dst|$dst, $src}",
493 [(store R32:$src, addr:$dst)]>;
495 //===----------------------------------------------------------------------===//
496 // Fixed-Register Multiplication and Division Instructions...
499 // Extra precision multiplication
500 def MUL8r : I<0xF6, MRM4r, (ops R8:$src), "mul{b} $src", []>,
501 Imp<[AL],[AX]>; // AL,AH = AL*R8
502 def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul{w} $src", []>,
503 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
504 def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul{l} $src", []>,
505 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
506 def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
507 "mul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
508 def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
509 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
510 OpSize; // AX,DX = AX*[mem16]
511 def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
512 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
514 def IMUL8r : I<0xF6, MRM5r, (ops R8:$src), "imul{b} $src", []>,
515 Imp<[AL],[AX]>; // AL,AH = AL*R8
516 def IMUL16r : I<0xF7, MRM5r, (ops R16:$src), "imul{w} $src", []>,
517 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
518 def IMUL32r : I<0xF7, MRM5r, (ops R32:$src), "imul{l} $src", []>,
519 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
520 def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
521 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
522 def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
523 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
524 OpSize; // AX,DX = AX*[mem16]
525 def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
527 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
529 // unsigned division/remainder
530 def DIV8r : I<0xF6, MRM6r, (ops R8:$src), // AX/r8 = AL,AH
531 "div{b} $src", []>, Imp<[AX],[AX]>;
532 def DIV16r : I<0xF7, MRM6r, (ops R16:$src), // DX:AX/r16 = AX,DX
533 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
534 def DIV32r : I<0xF7, MRM6r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
535 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
536 def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
537 "div{b} $src", []>, Imp<[AX],[AX]>;
538 def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
539 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
540 def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
541 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
543 // Signed division/remainder.
544 def IDIV8r : I<0xF6, MRM7r, (ops R8:$src), // AX/r8 = AL,AH
545 "idiv{b} $src", []>, Imp<[AX],[AX]>;
546 def IDIV16r: I<0xF7, MRM7r, (ops R16:$src), // DX:AX/r16 = AX,DX
547 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
548 def IDIV32r: I<0xF7, MRM7r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
549 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
550 def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
551 "idiv{b} $src", []>, Imp<[AX],[AX]>;
552 def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
553 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
554 def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
555 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
557 // Sign-extenders for division.
558 def CBW : I<0x98, RawFrm, (ops),
559 "{cbtw|cbw}", []>, Imp<[AL],[AH]>; // AX = signext(AL)
560 def CWD : I<0x99, RawFrm, (ops),
561 "{cwtd|cwd}", []>, Imp<[AX],[DX]>; // DX:AX = signext(AX)
562 def CDQ : I<0x99, RawFrm, (ops),
563 "{cltd|cdq}", []>, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
566 //===----------------------------------------------------------------------===//
567 // Two address Instructions...
569 let isTwoAddress = 1 in {
572 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, R16 = R16
573 (ops R16:$dst, R16:$src1, R16:$src2),
574 "cmovb {$src2, $dst|$dst, $src2}",
575 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
577 Imp<[STATUS],[]>, TB, OpSize;
578 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, R16 = [mem16]
579 (ops R16:$dst, R16:$src1, i16mem:$src2),
580 "cmovb {$src2, $dst|$dst, $src2}",
581 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
583 Imp<[STATUS],[]>, TB, OpSize;
584 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, R32 = R32
585 (ops R32:$dst, R32:$src1, R32:$src2),
586 "cmovb {$src2, $dst|$dst, $src2}",
587 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
589 Imp<[STATUS],[]>, TB;
590 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, R32 = [mem32]
591 (ops R32:$dst, R32:$src1, i32mem:$src2),
592 "cmovb {$src2, $dst|$dst, $src2}",
593 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
595 Imp<[STATUS],[]>, TB;
597 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, R16 = R16
598 (ops R16:$dst, R16:$src1, R16:$src2),
599 "cmovae {$src2, $dst|$dst, $src2}",
600 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
602 Imp<[STATUS],[]>, TB, OpSize;
603 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, R16 = [mem16]
604 (ops R16:$dst, R16:$src1, i16mem:$src2),
605 "cmovae {$src2, $dst|$dst, $src2}",
606 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
608 Imp<[STATUS],[]>, TB, OpSize;
609 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, R32 = R32
610 (ops R32:$dst, R32:$src1, R32:$src2),
611 "cmovae {$src2, $dst|$dst, $src2}",
612 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
614 Imp<[STATUS],[]>, TB;
615 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, R32 = [mem32]
616 (ops R32:$dst, R32:$src1, i32mem:$src2),
617 "cmovae {$src2, $dst|$dst, $src2}",
618 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
620 Imp<[STATUS],[]>, TB;
622 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, R16 = R16
623 (ops R16:$dst, R16:$src1, R16:$src2),
624 "cmove {$src2, $dst|$dst, $src2}",
625 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
627 Imp<[STATUS],[]>, TB, OpSize;
628 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, R16 = [mem16]
629 (ops R16:$dst, R16:$src1, i16mem:$src2),
630 "cmove {$src2, $dst|$dst, $src2}",
631 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
633 Imp<[STATUS],[]>, TB, OpSize;
634 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, R32 = R32
635 (ops R32:$dst, R32:$src1, R32:$src2),
636 "cmove {$src2, $dst|$dst, $src2}",
637 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
639 Imp<[STATUS],[]>, TB;
640 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, R32 = [mem32]
641 (ops R32:$dst, R32:$src1, i32mem:$src2),
642 "cmove {$src2, $dst|$dst, $src2}",
643 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
645 Imp<[STATUS],[]>, TB;
647 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, R16 = R16
648 (ops R16:$dst, R16:$src1, R16:$src2),
649 "cmovne {$src2, $dst|$dst, $src2}",
650 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
652 Imp<[STATUS],[]>, TB, OpSize;
653 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, R16 = [mem16]
654 (ops R16:$dst, R16:$src1, i16mem:$src2),
655 "cmovne {$src2, $dst|$dst, $src2}",
656 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
658 Imp<[STATUS],[]>, TB, OpSize;
659 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, R32 = R32
660 (ops R32:$dst, R32:$src1, R32:$src2),
661 "cmovne {$src2, $dst|$dst, $src2}",
662 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
664 Imp<[STATUS],[]>, TB;
665 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, R32 = [mem32]
666 (ops R32:$dst, R32:$src1, i32mem:$src2),
667 "cmovne {$src2, $dst|$dst, $src2}",
668 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
670 Imp<[STATUS],[]>, TB;
672 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, R16 = R16
673 (ops R16:$dst, R16:$src1, R16:$src2),
674 "cmovbe {$src2, $dst|$dst, $src2}",
675 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
677 Imp<[STATUS],[]>, TB, OpSize;
678 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, R16 = [mem16]
679 (ops R16:$dst, R16:$src1, i16mem:$src2),
680 "cmovbe {$src2, $dst|$dst, $src2}",
681 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
683 Imp<[STATUS],[]>, TB, OpSize;
684 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, R32 = R32
685 (ops R32:$dst, R32:$src1, R32:$src2),
686 "cmovbe {$src2, $dst|$dst, $src2}",
687 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
689 Imp<[STATUS],[]>, TB;
690 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, R32 = [mem32]
691 (ops R32:$dst, R32:$src1, i32mem:$src2),
692 "cmovbe {$src2, $dst|$dst, $src2}",
693 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
695 Imp<[STATUS],[]>, TB;
697 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, R16 = R16
698 (ops R16:$dst, R16:$src1, R16:$src2),
699 "cmova {$src2, $dst|$dst, $src2}",
700 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
702 Imp<[STATUS],[]>, TB, OpSize;
703 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, R16 = [mem16]
704 (ops R16:$dst, R16:$src1, i16mem:$src2),
705 "cmova {$src2, $dst|$dst, $src2}",
706 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
708 Imp<[STATUS],[]>, TB, OpSize;
709 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, R32 = R32
710 (ops R32:$dst, R32:$src1, R32:$src2),
711 "cmova {$src2, $dst|$dst, $src2}",
712 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
714 Imp<[STATUS],[]>, TB;
715 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, R32 = [mem32]
716 (ops R32:$dst, R32:$src1, i32mem:$src2),
717 "cmova {$src2, $dst|$dst, $src2}",
718 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
720 Imp<[STATUS],[]>, TB;
722 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, R16 = R16
723 (ops R16:$dst, R16:$src1, R16:$src2),
724 "cmovl {$src2, $dst|$dst, $src2}",
725 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
727 Imp<[STATUS],[]>, TB, OpSize;
728 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, R16 = [mem16]
729 (ops R16:$dst, R16:$src1, i16mem:$src2),
730 "cmovl {$src2, $dst|$dst, $src2}",
731 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
733 Imp<[STATUS],[]>, TB, OpSize;
734 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, R32 = R32
735 (ops R32:$dst, R32:$src1, R32:$src2),
736 "cmovl {$src2, $dst|$dst, $src2}",
737 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
739 Imp<[STATUS],[]>, TB;
740 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, R32 = [mem32]
741 (ops R32:$dst, R32:$src1, i32mem:$src2),
742 "cmovl {$src2, $dst|$dst, $src2}",
743 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
745 Imp<[STATUS],[]>, TB;
747 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, R16 = R16
748 (ops R16:$dst, R16:$src1, R16:$src2),
749 "cmovge {$src2, $dst|$dst, $src2}",
750 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
752 Imp<[STATUS],[]>, TB, OpSize;
753 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, R16 = [mem16]
754 (ops R16:$dst, R16:$src1, i16mem:$src2),
755 "cmovge {$src2, $dst|$dst, $src2}",
756 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
758 Imp<[STATUS],[]>, TB, OpSize;
759 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, R32 = R32
760 (ops R32:$dst, R32:$src1, R32:$src2),
761 "cmovge {$src2, $dst|$dst, $src2}",
762 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
764 Imp<[STATUS],[]>, TB;
765 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, R32 = [mem32]
766 (ops R32:$dst, R32:$src1, i32mem:$src2),
767 "cmovge {$src2, $dst|$dst, $src2}",
768 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
770 Imp<[STATUS],[]>, TB;
772 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, R16 = R16
773 (ops R16:$dst, R16:$src1, R16:$src2),
774 "cmovle {$src2, $dst|$dst, $src2}",
775 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
777 Imp<[STATUS],[]>, TB, OpSize;
778 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, R16 = [mem16]
779 (ops R16:$dst, R16:$src1, i16mem:$src2),
780 "cmovle {$src2, $dst|$dst, $src2}",
781 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
783 Imp<[STATUS],[]>, TB, OpSize;
784 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, R32 = R32
785 (ops R32:$dst, R32:$src1, R32:$src2),
786 "cmovle {$src2, $dst|$dst, $src2}",
787 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
789 Imp<[STATUS],[]>, TB;
790 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, R32 = [mem32]
791 (ops R32:$dst, R32:$src1, i32mem:$src2),
792 "cmovle {$src2, $dst|$dst, $src2}",
793 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
795 Imp<[STATUS],[]>, TB;
797 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, R16 = R16
798 (ops R16:$dst, R16:$src1, R16:$src2),
799 "cmovg {$src2, $dst|$dst, $src2}",
800 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
802 Imp<[STATUS],[]>, TB, OpSize;
803 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, R16 = [mem16]
804 (ops R16:$dst, R16:$src1, i16mem:$src2),
805 "cmovg {$src2, $dst|$dst, $src2}",
806 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
808 Imp<[STATUS],[]>, TB, OpSize;
809 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, R32 = R32
810 (ops R32:$dst, R32:$src1, R32:$src2),
811 "cmovg {$src2, $dst|$dst, $src2}",
812 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
814 Imp<[STATUS],[]>, TB;
815 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, R32 = [mem32]
816 (ops R32:$dst, R32:$src1, i32mem:$src2),
817 "cmovg {$src2, $dst|$dst, $src2}",
818 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
820 Imp<[STATUS],[]>, TB;
822 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, R16 = R16
823 (ops R16:$dst, R16:$src1, R16:$src2),
824 "cmovs {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
825 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, R16 = [mem16]
826 (ops R16:$dst, R16:$src1, i16mem:$src2),
827 "cmovs {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
828 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, R32 = R32
829 (ops R32:$dst, R32:$src1, R32:$src2),
830 "cmovs {$src2, $dst|$dst, $src2}", []>, TB;
831 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, R32 = [mem32]
832 (ops R32:$dst, R32:$src1, i32mem:$src2),
833 "cmovs {$src2, $dst|$dst, $src2}", []>, TB;
835 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, R16 = R16
836 (ops R16:$dst, R16:$src1, R16:$src2),
837 "cmovns {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
838 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, R16 = [mem16]
839 (ops R16:$dst, R16:$src1, i16mem:$src2),
840 "cmovns {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
841 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, R32 = R32
842 (ops R32:$dst, R32:$src1, R32:$src2),
843 "cmovns {$src2, $dst|$dst, $src2}", []>, TB;
844 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, R32 = [mem32]
845 (ops R32:$dst, R32:$src1, i32mem:$src2),
846 "cmovns {$src2, $dst|$dst, $src2}", []>, TB;
848 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, R16 = R16
849 (ops R16:$dst, R16:$src1, R16:$src2),
850 "cmovp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
851 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, R16 = [mem16]
852 (ops R16:$dst, R16:$src1, i16mem:$src2),
853 "cmovp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
854 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, R32 = R32
855 (ops R32:$dst, R32:$src1, R32:$src2),
856 "cmovp {$src2, $dst|$dst, $src2}", []>, TB;
857 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, R32 = [mem32]
858 (ops R32:$dst, R32:$src1, i32mem:$src2),
859 "cmovp {$src2, $dst|$dst, $src2}", []>, TB;
861 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, R16 = R16
862 (ops R16:$dst, R16:$src1, R16:$src2),
863 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
864 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, R16 = [mem16]
865 (ops R16:$dst, R16:$src1, i16mem:$src2),
866 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
867 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, R32 = R32
868 (ops R32:$dst, R32:$src1, R32:$src2),
869 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB;
870 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, R32 = [mem32]
871 (ops R32:$dst, R32:$src1, i32mem:$src2),
872 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB;
875 // unary instructions
876 def NEG8r : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg{b} $dst",
877 [(set R8:$dst, (ineg R8:$src))]>;
878 def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg{w} $dst",
879 [(set R16:$dst, (ineg R16:$src))]>, OpSize;
880 def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg{l} $dst",
881 [(set R32:$dst, (ineg R32:$src))]>;
882 let isTwoAddress = 0 in {
883 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
884 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
885 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
886 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
887 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
888 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
892 def NOT8r : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not{b} $dst",
893 [(set R8:$dst, (not R8:$src))]>;
894 def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not{w} $dst",
895 [(set R16:$dst, (not R16:$src))]>, OpSize;
896 def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not{l} $dst",
897 [(set R32:$dst, (not R32:$src))]>;
898 let isTwoAddress = 0 in {
899 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
900 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
901 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
902 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
903 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
904 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
907 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
908 def INC8r : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc{b} $dst",
909 [(set R8:$dst, (add R8:$src, 1))]>;
910 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
911 def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc{w} $dst",
912 [(set R16:$dst, (add R16:$src, 1))]>, OpSize;
913 def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc{l} $dst",
914 [(set R32:$dst, (add R32:$src, 1))]>;
916 let isTwoAddress = 0 in {
917 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
918 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
919 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
920 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
921 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
922 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
925 def DEC8r : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec{b} $dst",
926 [(set R8:$dst, (add R8:$src, -1))]>;
927 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
928 def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec{w} $dst",
929 [(set R16:$dst, (add R16:$src, -1))]>, OpSize;
930 def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec{l} $dst",
931 [(set R32:$dst, (add R32:$src, -1))]>;
934 let isTwoAddress = 0 in {
935 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
936 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
937 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
938 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
939 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
940 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
943 // Logical operators...
944 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
945 def AND8rr : I<0x20, MRMDestReg,
946 (ops R8 :$dst, R8 :$src1, R8 :$src2),
947 "and{b} {$src2, $dst|$dst, $src2}",
948 [(set R8:$dst, (and R8:$src1, R8:$src2))]>;
949 def AND16rr : I<0x21, MRMDestReg,
950 (ops R16:$dst, R16:$src1, R16:$src2),
951 "and{w} {$src2, $dst|$dst, $src2}",
952 [(set R16:$dst, (and R16:$src1, R16:$src2))]>, OpSize;
953 def AND32rr : I<0x21, MRMDestReg,
954 (ops R32:$dst, R32:$src1, R32:$src2),
955 "and{l} {$src2, $dst|$dst, $src2}",
956 [(set R32:$dst, (and R32:$src1, R32:$src2))]>;
959 def AND8rm : I<0x22, MRMSrcMem,
960 (ops R8 :$dst, R8 :$src1, i8mem :$src2),
961 "and{b} {$src2, $dst|$dst, $src2}",
962 [(set R8:$dst, (and R8:$src1, (load addr:$src2)))]>;
963 def AND16rm : I<0x23, MRMSrcMem,
964 (ops R16:$dst, R16:$src1, i16mem:$src2),
965 "and{w} {$src2, $dst|$dst, $src2}",
966 [(set R16:$dst, (and R16:$src1, (load addr:$src2)))]>, OpSize;
967 def AND32rm : I<0x23, MRMSrcMem,
968 (ops R32:$dst, R32:$src1, i32mem:$src2),
969 "and{l} {$src2, $dst|$dst, $src2}",
970 [(set R32:$dst, (and R32:$src1, (load addr:$src2)))]>;
972 def AND8ri : Ii8<0x80, MRM4r,
973 (ops R8 :$dst, R8 :$src1, i8imm :$src2),
974 "and{b} {$src2, $dst|$dst, $src2}",
975 [(set R8:$dst, (and R8:$src1, imm:$src2))]>;
976 def AND16ri : Ii16<0x81, MRM4r,
977 (ops R16:$dst, R16:$src1, i16imm:$src2),
978 "and{w} {$src2, $dst|$dst, $src2}",
979 [(set R16:$dst, (and R16:$src1, imm:$src2))]>, OpSize;
980 def AND32ri : Ii32<0x81, MRM4r,
981 (ops R32:$dst, R32:$src1, i32imm:$src2),
982 "and{l} {$src2, $dst|$dst, $src2}",
983 [(set R32:$dst, (and R32:$src1, imm:$src2))]>;
984 def AND16ri8 : Ii8<0x83, MRM4r,
985 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
986 "and{w} {$src2, $dst|$dst, $src2}",
987 [(set R16:$dst, (and R16:$src1, i16immSExt8:$src2))]>,
989 def AND32ri8 : Ii8<0x83, MRM4r,
990 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
991 "and{l} {$src2, $dst|$dst, $src2}",
992 [(set R32:$dst, (and R32:$src1, i32immSExt8:$src2))]>;
994 let isTwoAddress = 0 in {
995 def AND8mr : I<0x20, MRMDestMem,
996 (ops i8mem :$dst, R8 :$src),
997 "and{b} {$src, $dst|$dst, $src}",
998 [(store (and (load addr:$dst), R8:$src), addr:$dst)]>;
999 def AND16mr : I<0x21, MRMDestMem,
1000 (ops i16mem:$dst, R16:$src),
1001 "and{w} {$src, $dst|$dst, $src}",
1002 [(store (and (load addr:$dst), R16:$src), addr:$dst)]>,
1004 def AND32mr : I<0x21, MRMDestMem,
1005 (ops i32mem:$dst, R32:$src),
1006 "and{l} {$src, $dst|$dst, $src}",
1007 [(store (and (load addr:$dst), R32:$src), addr:$dst)]>;
1008 def AND8mi : Ii8<0x80, MRM4m,
1009 (ops i8mem :$dst, i8imm :$src),
1010 "and{b} {$src, $dst|$dst, $src}",
1011 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1012 def AND16mi : Ii16<0x81, MRM4m,
1013 (ops i16mem:$dst, i16imm:$src),
1014 "and{w} {$src, $dst|$dst, $src}",
1015 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1017 def AND32mi : Ii32<0x81, MRM4m,
1018 (ops i32mem:$dst, i32imm:$src),
1019 "and{l} {$src, $dst|$dst, $src}",
1020 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1021 def AND16mi8 : Ii8<0x83, MRM4m,
1022 (ops i16mem:$dst, i16i8imm :$src),
1023 "and{w} {$src, $dst|$dst, $src}",
1024 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1026 def AND32mi8 : Ii8<0x83, MRM4m,
1027 (ops i32mem:$dst, i32i8imm :$src),
1028 "and{l} {$src, $dst|$dst, $src}",
1029 [(store (add (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1033 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1034 def OR8rr : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1035 "or{b} {$src2, $dst|$dst, $src2}",
1036 [(set R8:$dst, (or R8:$src1, R8:$src2))]>;
1037 def OR16rr : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1038 "or{w} {$src2, $dst|$dst, $src2}",
1039 [(set R16:$dst, (or R16:$src1, R16:$src2))]>, OpSize;
1040 def OR32rr : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1041 "or{l} {$src2, $dst|$dst, $src2}",
1042 [(set R32:$dst, (or R32:$src1, R32:$src2))]>;
1044 def OR8rm : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1045 "or{b} {$src2, $dst|$dst, $src2}",
1046 [(set R8:$dst, (or R8:$src1, (load addr:$src2)))]>;
1047 def OR16rm : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
1048 "or{w} {$src2, $dst|$dst, $src2}",
1049 [(set R16:$dst, (or R16:$src1, (load addr:$src2)))]>, OpSize;
1050 def OR32rm : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
1051 "or{l} {$src2, $dst|$dst, $src2}",
1052 [(set R32:$dst, (or R32:$src1, (load addr:$src2)))]>;
1054 def OR8ri : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1055 "or{b} {$src2, $dst|$dst, $src2}",
1056 [(set R8:$dst, (or R8:$src1, imm:$src2))]>;
1057 def OR16ri : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1058 "or{w} {$src2, $dst|$dst, $src2}",
1059 [(set R16:$dst, (or R16:$src1, imm:$src2))]>, OpSize;
1060 def OR32ri : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1061 "or{l} {$src2, $dst|$dst, $src2}",
1062 [(set R32:$dst, (or R32:$src1, imm:$src2))]>;
1064 def OR16ri8 : Ii8<0x83, MRM1r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1065 "or{w} {$src2, $dst|$dst, $src2}",
1066 [(set R16:$dst, (or R16:$src1, i16immSExt8:$src2))]>, OpSize;
1067 def OR32ri8 : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1068 "or{l} {$src2, $dst|$dst, $src2}",
1069 [(set R32:$dst, (or R32:$src1, i32immSExt8:$src2))]>;
1070 let isTwoAddress = 0 in {
1071 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
1072 "or{b} {$src, $dst|$dst, $src}",
1073 [(store (or (load addr:$dst), R8:$src), addr:$dst)]>;
1074 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
1075 "or{w} {$src, $dst|$dst, $src}",
1076 [(store (or (load addr:$dst), R16:$src), addr:$dst)]>, OpSize;
1077 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
1078 "or{l} {$src, $dst|$dst, $src}",
1079 [(store (or (load addr:$dst), R32:$src), addr:$dst)]>;
1080 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
1081 "or{b} {$src, $dst|$dst, $src}",
1082 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1083 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
1084 "or{w} {$src, $dst|$dst, $src}",
1085 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1087 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
1088 "or{l} {$src, $dst|$dst, $src}",
1089 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1090 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1091 "or{w} {$src, $dst|$dst, $src}",
1092 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1094 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1095 "or{l} {$src, $dst|$dst, $src}",
1096 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1100 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1101 def XOR8rr : I<0x30, MRMDestReg,
1102 (ops R8 :$dst, R8 :$src1, R8 :$src2),
1103 "xor{b} {$src2, $dst|$dst, $src2}",
1104 [(set R8:$dst, (xor R8:$src1, R8:$src2))]>;
1105 def XOR16rr : I<0x31, MRMDestReg,
1106 (ops R16:$dst, R16:$src1, R16:$src2),
1107 "xor{w} {$src2, $dst|$dst, $src2}",
1108 [(set R16:$dst, (xor R16:$src1, R16:$src2))]>, OpSize;
1109 def XOR32rr : I<0x31, MRMDestReg,
1110 (ops R32:$dst, R32:$src1, R32:$src2),
1111 "xor{l} {$src2, $dst|$dst, $src2}",
1112 [(set R32:$dst, (xor R32:$src1, R32:$src2))]>;
1115 def XOR8rm : I<0x32, MRMSrcMem ,
1116 (ops R8 :$dst, R8:$src1, i8mem :$src2),
1117 "xor{b} {$src2, $dst|$dst, $src2}",
1118 [(set R8:$dst, (xor R8:$src1, (load addr:$src2)))]>;
1119 def XOR16rm : I<0x33, MRMSrcMem ,
1120 (ops R16:$dst, R16:$src1, i16mem:$src2),
1121 "xor{w} {$src2, $dst|$dst, $src2}",
1122 [(set R16:$dst, (xor R16:$src1, (load addr:$src2)))]>, OpSize;
1123 def XOR32rm : I<0x33, MRMSrcMem ,
1124 (ops R32:$dst, R32:$src1, i32mem:$src2),
1125 "xor{l} {$src2, $dst|$dst, $src2}",
1126 [(set R32:$dst, (xor R32:$src1, (load addr:$src2)))]>;
1128 def XOR8ri : Ii8<0x80, MRM6r,
1129 (ops R8:$dst, R8:$src1, i8imm:$src2),
1130 "xor{b} {$src2, $dst|$dst, $src2}",
1131 [(set R8:$dst, (xor R8:$src1, imm:$src2))]>;
1132 def XOR16ri : Ii16<0x81, MRM6r,
1133 (ops R16:$dst, R16:$src1, i16imm:$src2),
1134 "xor{w} {$src2, $dst|$dst, $src2}",
1135 [(set R16:$dst, (xor R16:$src1, imm:$src2))]>, OpSize;
1136 def XOR32ri : Ii32<0x81, MRM6r,
1137 (ops R32:$dst, R32:$src1, i32imm:$src2),
1138 "xor{l} {$src2, $dst|$dst, $src2}",
1139 [(set R32:$dst, (xor R32:$src1, imm:$src2))]>;
1140 def XOR16ri8 : Ii8<0x83, MRM6r,
1141 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1142 "xor{w} {$src2, $dst|$dst, $src2}",
1143 [(set R16:$dst, (xor R16:$src1, i16immSExt8:$src2))]>,
1145 def XOR32ri8 : Ii8<0x83, MRM6r,
1146 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1147 "xor{l} {$src2, $dst|$dst, $src2}",
1148 [(set R32:$dst, (xor R32:$src1, i32immSExt8:$src2))]>;
1149 let isTwoAddress = 0 in {
1150 def XOR8mr : I<0x30, MRMDestMem,
1151 (ops i8mem :$dst, R8 :$src),
1152 "xor{b} {$src, $dst|$dst, $src}",
1153 [(store (xor (load addr:$dst), R8:$src), addr:$dst)]>;
1154 def XOR16mr : I<0x31, MRMDestMem,
1155 (ops i16mem:$dst, R16:$src),
1156 "xor{w} {$src, $dst|$dst, $src}",
1157 [(store (xor (load addr:$dst), R16:$src), addr:$dst)]>,
1159 def XOR32mr : I<0x31, MRMDestMem,
1160 (ops i32mem:$dst, R32:$src),
1161 "xor{l} {$src, $dst|$dst, $src}",
1162 [(store (xor (load addr:$dst), R32:$src), addr:$dst)]>;
1163 def XOR8mi : Ii8<0x80, MRM6m,
1164 (ops i8mem :$dst, i8imm :$src),
1165 "xor{b} {$src, $dst|$dst, $src}",
1166 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1167 def XOR16mi : Ii16<0x81, MRM6m,
1168 (ops i16mem:$dst, i16imm:$src),
1169 "xor{w} {$src, $dst|$dst, $src}",
1170 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1172 def XOR32mi : Ii32<0x81, MRM6m,
1173 (ops i32mem:$dst, i32imm:$src),
1174 "xor{l} {$src, $dst|$dst, $src}",
1175 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1176 def XOR16mi8 : Ii8<0x83, MRM6m,
1177 (ops i16mem:$dst, i16i8imm :$src),
1178 "xor{w} {$src, $dst|$dst, $src}",
1179 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1181 def XOR32mi8 : Ii8<0x83, MRM6m,
1182 (ops i32mem:$dst, i32i8imm :$src),
1183 "xor{l} {$src, $dst|$dst, $src}",
1184 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1187 // Shift instructions
1188 // FIXME: provide shorter instructions when imm8 == 1
1189 def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
1190 "shl{b} {%cl, $dst|$dst, %CL}",
1191 [(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
1192 def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src),
1193 "shl{w} {%cl, $dst|$dst, %CL}",
1194 [(set R16:$dst, (shl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1195 def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src),
1196 "shl{l} {%cl, $dst|$dst, %CL}",
1197 [(set R32:$dst, (shl R32:$src, CL))]>, Imp<[CL],[]>;
1199 def SHL8ri : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1200 "shl{b} {$src2, $dst|$dst, $src2}",
1201 [(set R8:$dst, (shl R8:$src1, (i8 imm:$src2)))]>;
1202 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1203 def SHL16ri : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1204 "shl{w} {$src2, $dst|$dst, $src2}",
1205 [(set R16:$dst, (shl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1206 def SHL32ri : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1207 "shl{l} {$src2, $dst|$dst, $src2}",
1208 [(set R32:$dst, (shl R32:$src1, (i8 imm:$src2)))]>;
1211 let isTwoAddress = 0 in {
1212 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
1213 "shl{b} {%cl, $dst|$dst, %CL}",
1214 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1216 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
1217 "shl{w} {%cl, $dst|$dst, %CL}",
1218 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1219 Imp<[CL],[]>, OpSize;
1220 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
1221 "shl{l} {%cl, $dst|$dst, %CL}",
1222 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1224 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
1225 "shl{b} {$src, $dst|$dst, $src}",
1226 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1227 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
1228 "shl{w} {$src, $dst|$dst, $src}",
1229 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1231 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
1232 "shl{l} {$src, $dst|$dst, $src}",
1233 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1236 def SHR8rCL : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src),
1237 "shr{b} {%cl, $dst|$dst, %CL}",
1238 [(set R8:$dst, (srl R8:$src, CL))]>, Imp<[CL],[]>;
1239 def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src),
1240 "shr{w} {%cl, $dst|$dst, %CL}",
1241 [(set R16:$dst, (srl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1242 def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src),
1243 "shr{l} {%cl, $dst|$dst, %CL}",
1244 [(set R32:$dst, (srl R32:$src, CL))]>, Imp<[CL],[]>;
1246 def SHR8ri : Ii8<0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1247 "shr{b} {$src2, $dst|$dst, $src2}",
1248 [(set R8:$dst, (srl R8:$src1, (i8 imm:$src2)))]>;
1249 def SHR16ri : Ii8<0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1250 "shr{w} {$src2, $dst|$dst, $src2}",
1251 [(set R16:$dst, (srl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1252 def SHR32ri : Ii8<0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1253 "shr{l} {$src2, $dst|$dst, $src2}",
1254 [(set R32:$dst, (srl R32:$src1, (i8 imm:$src2)))]>;
1256 let isTwoAddress = 0 in {
1257 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
1258 "shr{b} {%cl, $dst|$dst, %CL}",
1259 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1261 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
1262 "shr{w} {%cl, $dst|$dst, %CL}",
1263 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1264 Imp<[CL],[]>, OpSize;
1265 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
1266 "shr{l} {%cl, $dst|$dst, %CL}",
1267 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1269 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
1270 "shr{b} {$src, $dst|$dst, $src}",
1271 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1272 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
1273 "shr{w} {$src, $dst|$dst, $src}",
1274 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1276 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
1277 "shr{l} {$src, $dst|$dst, $src}",
1278 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1281 def SAR8rCL : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src),
1282 "sar{b} {%cl, $dst|$dst, %CL}",
1283 [(set R8:$dst, (sra R8:$src, CL))]>, Imp<[CL],[]>;
1284 def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src),
1285 "sar{w} {%cl, $dst|$dst, %CL}",
1286 [(set R16:$dst, (sra R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1287 def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src),
1288 "sar{l} {%cl, $dst|$dst, %CL}",
1289 [(set R32:$dst, (sra R32:$src, CL))]>, Imp<[CL],[]>;
1291 def SAR8ri : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1292 "sar{b} {$src2, $dst|$dst, $src2}",
1293 [(set R8:$dst, (sra R8:$src1, (i8 imm:$src2)))]>;
1294 def SAR16ri : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1295 "sar{w} {$src2, $dst|$dst, $src2}",
1296 [(set R16:$dst, (sra R16:$src1, (i8 imm:$src2)))]>,
1298 def SAR32ri : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1299 "sar{l} {$src2, $dst|$dst, $src2}",
1300 [(set R32:$dst, (sra R32:$src1, (i8 imm:$src2)))]>;
1301 let isTwoAddress = 0 in {
1302 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
1303 "sar{b} {%cl, $dst|$dst, %CL}",
1304 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1306 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
1307 "sar{w} {%cl, $dst|$dst, %CL}",
1308 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1309 Imp<[CL],[]>, OpSize;
1310 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
1311 "sar{l} {%cl, $dst|$dst, %CL}",
1312 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1314 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
1315 "sar{b} {$src, $dst|$dst, $src}",
1316 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1317 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
1318 "sar{w} {$src, $dst|$dst, $src}",
1319 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1321 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
1322 "sar{l} {$src, $dst|$dst, $src}",
1323 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1326 // Rotate instructions
1327 // FIXME: provide shorter instructions when imm8 == 1
1328 def ROL8rCL : I<0xD2, MRM0r, (ops R8 :$dst, R8 :$src),
1329 "rol{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1330 def ROL16rCL : I<0xD3, MRM0r, (ops R16:$dst, R16:$src),
1331 "rol{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
1332 def ROL32rCL : I<0xD3, MRM0r, (ops R32:$dst, R32:$src),
1333 "rol{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1335 def ROL8ri : Ii8<0xC0, MRM0r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1336 "rol{b} {$src2, $dst|$dst, $src2}", []>;
1337 def ROL16ri : Ii8<0xC1, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1338 "rol{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1339 def ROL32ri : Ii8<0xC1, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1340 "rol{l} {$src2, $dst|$dst, $src2}", []>;
1342 let isTwoAddress = 0 in {
1343 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
1344 "rol{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1345 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
1346 "rol{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
1347 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
1348 "rol{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1349 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
1350 "rol{b} {$src, $dst|$dst, $src}", []>;
1351 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
1352 "rol{w} {$src, $dst|$dst, $src}", []>, OpSize;
1353 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
1354 "rol{l} {$src, $dst|$dst, $src}", []>;
1357 def ROR8rCL : I<0xD2, MRM1r, (ops R8 :$dst, R8 :$src),
1358 "ror{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1359 def ROR16rCL : I<0xD3, MRM1r, (ops R16:$dst, R16:$src),
1360 "ror{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
1361 def ROR32rCL : I<0xD3, MRM1r, (ops R32:$dst, R32:$src),
1362 "ror{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1364 def ROR8ri : Ii8<0xC0, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1365 "ror{b} {$src2, $dst|$dst, $src2}", []>;
1366 def ROR16ri : Ii8<0xC1, MRM1r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1367 "ror{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1368 def ROR32ri : Ii8<0xC1, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1369 "ror{l} {$src2, $dst|$dst, $src2}", []>;
1370 let isTwoAddress = 0 in {
1371 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
1372 "ror{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1373 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
1374 "ror{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
1375 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
1376 "ror{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
1377 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
1378 "ror{b} {$src, $dst|$dst, $src}", []>;
1379 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
1380 "ror{w} {$src, $dst|$dst, $src}", []>, OpSize;
1381 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
1382 "ror{l} {$src, $dst|$dst, $src}", []>;
1387 // Double shift instructions (generalizations of rotate)
1389 def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1390 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1392 def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1393 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1395 def SHLD16rrCL : I<0xA5, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1396 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1397 Imp<[CL],[]>, TB, OpSize;
1398 def SHRD16rrCL : I<0xAD, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1399 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1400 Imp<[CL],[]>, TB, OpSize;
1402 let isCommutable = 1 in { // These instructions commute to each other.
1403 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1404 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
1405 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>, TB;
1406 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1407 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
1408 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>, TB;
1409 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1410 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
1411 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1413 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1414 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
1415 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1419 let isTwoAddress = 0 in {
1420 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1421 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1423 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1424 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1426 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1427 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
1428 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1430 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1431 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
1432 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1435 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1436 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1437 Imp<[CL],[]>, TB, OpSize;
1438 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1439 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
1440 Imp<[CL],[]>, TB, OpSize;
1441 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1442 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
1443 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1445 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1446 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
1447 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1453 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1454 def ADD8rr : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1455 "add{b} {$src2, $dst|$dst, $src2}",
1456 [(set R8:$dst, (add R8:$src1, R8:$src2))]>;
1457 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1458 def ADD16rr : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1459 "add{w} {$src2, $dst|$dst, $src2}",
1460 [(set R16:$dst, (add R16:$src1, R16:$src2))]>, OpSize;
1461 def ADD32rr : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1462 "add{l} {$src2, $dst|$dst, $src2}",
1463 [(set R32:$dst, (add R32:$src1, R32:$src2))]>;
1464 } // end isConvertibleToThreeAddress
1465 } // end isCommutable
1466 def ADD8rm : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1467 "add{b} {$src2, $dst|$dst, $src2}",
1468 [(set R8:$dst, (add R8:$src1, (load addr:$src2)))]>;
1469 def ADD16rm : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1470 "add{w} {$src2, $dst|$dst, $src2}",
1471 [(set R16:$dst, (add R16:$src1, (load addr:$src2)))]>, OpSize;
1472 def ADD32rm : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1473 "add{l} {$src2, $dst|$dst, $src2}",
1474 [(set R32:$dst, (add R32:$src1, (load addr:$src2)))]>;
1476 def ADD8ri : Ii8<0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1477 "add{b} {$src2, $dst|$dst, $src2}",
1478 [(set R8:$dst, (add R8:$src1, imm:$src2))]>;
1480 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1481 def ADD16ri : Ii16<0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1482 "add{w} {$src2, $dst|$dst, $src2}",
1483 [(set R16:$dst, (add R16:$src1, imm:$src2))]>, OpSize;
1484 def ADD32ri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1485 "add{l} {$src2, $dst|$dst, $src2}",
1486 [(set R32:$dst, (add R32:$src1, imm:$src2))]>;
1489 // FIXME: move ADD16ri8 above ADD16ri to optimize for space.
1490 def ADD16ri8 : Ii8<0x83, MRM0r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1491 "add{w} {$src2, $dst|$dst, $src2}",
1492 [(set R16:$dst, (add R16:$src1, i16immSExt8:$src2))]>,
1494 def ADD32ri8 : Ii8<0x83, MRM0r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1495 "add{l} {$src2, $dst|$dst, $src2}",
1496 [(set R32:$dst, (add R32:$src1, i32immSExt8:$src2))]>;
1498 let isTwoAddress = 0 in {
1499 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
1500 "add{b} {$src2, $dst|$dst, $src2}",
1501 [(store (add (load addr:$dst), R8:$src2), addr:$dst)]>;
1502 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1503 "add{w} {$src2, $dst|$dst, $src2}",
1504 [(store (add (load addr:$dst), R16:$src2), addr:$dst)]>,
1506 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1507 "add{l} {$src2, $dst|$dst, $src2}",
1508 [(store (add (load addr:$dst), R32:$src2), addr:$dst)]>;
1509 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
1510 "add{b} {$src2, $dst|$dst, $src2}",
1511 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1512 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
1513 "add{w} {$src2, $dst|$dst, $src2}",
1514 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1516 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
1517 "add{l} {$src2, $dst|$dst, $src2}",
1518 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1519 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1520 "add{w} {$src2, $dst|$dst, $src2}",
1521 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1523 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1524 "add{l} {$src2, $dst|$dst, $src2}",
1525 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1528 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1529 def ADC32rr : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1530 "adc{l} {$src2, $dst|$dst, $src2}", []>;
1532 def ADC32rm : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
1533 "adc{l} {$src2, $dst|$dst, $src2}", []>;
1534 def ADC32ri : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1535 "adc{l} {$src2, $dst|$dst, $src2}", []>;
1536 def ADC32ri8 : Ii8<0x83, MRM2r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1537 "adc{l} {$src2, $dst|$dst, $src2}", []>;
1539 let isTwoAddress = 0 in {
1540 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1541 "adc{l} {$src2, $dst|$dst, $src2}", []>;
1542 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
1543 "adc{l} {$src2, $dst|$dst, $src2}", []>;
1544 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i8imm :$src2),
1545 "adc{l} {$src2, $dst|$dst, $src2}", []>;
1548 def SUB8rr : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1549 "sub{b} {$src2, $dst|$dst, $src2}",
1550 [(set R8:$dst, (sub R8:$src1, R8:$src2))]>;
1551 def SUB16rr : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1552 "sub{w} {$src2, $dst|$dst, $src2}",
1553 [(set R16:$dst, (sub R16:$src1, R16:$src2))]>, OpSize;
1554 def SUB32rr : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1555 "sub{l} {$src2, $dst|$dst, $src2}",
1556 [(set R32:$dst, (sub R32:$src1, R32:$src2))]>;
1557 def SUB8rm : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1558 "sub{b} {$src2, $dst|$dst, $src2}",
1559 [(set R8:$dst, (sub R8:$src1, (load addr:$src2)))]>;
1560 def SUB16rm : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1561 "sub{w} {$src2, $dst|$dst, $src2}",
1562 [(set R16:$dst, (sub R16:$src1, (load addr:$src2)))]>, OpSize;
1563 def SUB32rm : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1564 "sub{l} {$src2, $dst|$dst, $src2}",
1565 [(set R32:$dst, (sub R32:$src1, (load addr:$src2)))]>;
1567 def SUB8ri : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1568 "sub{b} {$src2, $dst|$dst, $src2}",
1569 [(set R8:$dst, (sub R8:$src1, imm:$src2))]>;
1570 def SUB16ri : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1571 "sub{w} {$src2, $dst|$dst, $src2}",
1572 [(set R16:$dst, (sub R16:$src1, imm:$src2))]>, OpSize;
1573 def SUB32ri : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1574 "sub{l} {$src2, $dst|$dst, $src2}",
1575 [(set R32:$dst, (sub R32:$src1, imm:$src2))]>;
1576 def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1577 "sub{w} {$src2, $dst|$dst, $src2}",
1578 [(set R16:$dst, (sub R16:$src1, i16immSExt8:$src2))]>,
1580 def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1581 "sub{l} {$src2, $dst|$dst, $src2}",
1582 [(set R32:$dst, (sub R32:$src1, i32immSExt8:$src2))]>;
1583 let isTwoAddress = 0 in {
1584 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
1585 "sub{b} {$src2, $dst|$dst, $src2}",
1586 [(store (sub (load addr:$dst), R8:$src2), addr:$dst)]>;
1587 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1588 "sub{w} {$src2, $dst|$dst, $src2}",
1589 [(store (sub (load addr:$dst), R16:$src2), addr:$dst)]>,
1591 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1592 "sub{l} {$src2, $dst|$dst, $src2}",
1593 [(store (sub (load addr:$dst), R32:$src2), addr:$dst)]>;
1594 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
1595 "sub{b} {$src2, $dst|$dst, $src2}",
1596 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1597 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
1598 "sub{w} {$src2, $dst|$dst, $src2}",
1599 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1601 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
1602 "sub{l} {$src2, $dst|$dst, $src2}",
1603 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1604 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1605 "sub{w} {$src2, $dst|$dst, $src2}",
1606 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1608 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1609 "sub{l} {$src2, $dst|$dst, $src2}",
1610 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1613 def SBB32rr : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1614 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1616 let isTwoAddress = 0 in {
1617 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1618 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1619 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
1620 "sbb{b} {$src2, $dst|$dst, $src2}", []>;
1621 def SBB16mi : Ii32<0x81, MRM3m, (ops i16mem:$dst, i16imm:$src2),
1622 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1623 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
1624 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1625 def SBB16mi8 : Ii8<0x83, MRM3m, (ops i16mem:$dst, i8imm :$src2),
1626 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1627 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i8imm :$src2),
1628 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1630 def SBB8ri : Ii8<0x80, MRM3r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1631 "sbb{b} {$src2, $dst|$dst, $src2}", []>;
1632 def SBB16ri : Ii16<0x81, MRM3r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1633 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1635 def SBB32rm : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1636 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1637 def SBB32ri : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1638 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1640 def SBB16ri8 : Ii8<0x83, MRM3r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1641 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
1642 def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1643 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
1645 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
1646 def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
1647 "imul{w} {$src2, $dst|$dst, $src2}",
1648 [(set R16:$dst, (mul R16:$src1, R16:$src2))]>, TB, OpSize;
1649 def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
1650 "imul{l} {$src2, $dst|$dst, $src2}",
1651 [(set R32:$dst, (mul R32:$src1, R32:$src2))]>, TB;
1653 def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1654 "imul{w} {$src2, $dst|$dst, $src2}",
1655 [(set R16:$dst, (mul R16:$src1, (load addr:$src2)))]>,
1657 def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1658 "imul{l} {$src2, $dst|$dst, $src2}",
1659 [(set R32:$dst, (mul R32:$src1, (load addr:$src2)))]>, TB;
1661 } // end Two Address instructions
1663 // Suprisingly enough, these are not two address instructions!
1664 def IMUL16rri : Ii16<0x69, MRMSrcReg, // R16 = R16*I16
1665 (ops R16:$dst, R16:$src1, i16imm:$src2),
1666 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1667 [(set R16:$dst, (mul R16:$src1, imm:$src2))]>, OpSize;
1668 def IMUL32rri : Ii32<0x69, MRMSrcReg, // R32 = R32*I32
1669 (ops R32:$dst, R32:$src1, i32imm:$src2),
1670 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1671 [(set R32:$dst, (mul R32:$src1, imm:$src2))]>;
1672 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // R16 = R16*I8
1673 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1674 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1675 [(set R16:$dst, (mul R16:$src1, i16immSExt8:$src2))]>,
1677 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // R32 = R32*I8
1678 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1679 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1680 [(set R32:$dst, (mul R32:$src1, i32immSExt8:$src2))]>;
1682 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // R16 = [mem16]*I16
1683 (ops R16:$dst, i16mem:$src1, i16imm:$src2),
1684 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1685 [(set R16:$dst, (mul (load addr:$src1), imm:$src2))]>,
1687 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // R32 = [mem32]*I32
1688 (ops R32:$dst, i32mem:$src1, i32imm:$src2),
1689 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1690 [(set R32:$dst, (mul (load addr:$src1), imm:$src2))]>;
1691 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // R16 = [mem16]*I8
1692 (ops R16:$dst, i16mem:$src1, i16i8imm :$src2),
1693 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1694 [(set R16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
1696 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // R32 = [mem32]*I8
1697 (ops R32:$dst, i32mem:$src1, i32i8imm: $src2),
1698 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1699 [(set R32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
1701 //===----------------------------------------------------------------------===//
1702 // Test instructions are just like AND, except they don't generate a result.
1704 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
1705 def TEST8rr : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
1706 "test{b} {$src2, $src1|$src1, $src2}",
1707 [(set STATUS, (X86test R8:$src1, R8:$src2))]>,
1709 def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
1710 "test{w} {$src2, $src1|$src1, $src2}",
1711 [(set STATUS, (X86test R16:$src1, R16:$src2))]>,
1712 Imp<[],[STATUS]>, OpSize;
1713 def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
1714 "test{l} {$src2, $src1|$src1, $src2}",
1715 [(set STATUS, (X86test R32:$src1, R32:$src2))]>,
1718 def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
1719 "test{b} {$src2, $src1|$src1, $src2}",
1720 [(set STATUS, (X86test (loadi8 addr:$src1), R8:$src2))]>,
1722 def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
1723 "test{w} {$src2, $src1|$src1, $src2}",
1724 [(set STATUS, (X86test (loadi16 addr:$src1), R16:$src2))]>,
1725 Imp<[],[STATUS]>, OpSize;
1726 def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
1727 "test{l} {$src2, $src1|$src1, $src2}",
1728 [(set STATUS, (X86test (loadi32 addr:$src1), R32:$src2))]>,
1730 def TEST8rm : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
1731 "test{b} {$src2, $src1|$src1, $src2}",
1732 [(set STATUS, (X86test R8:$src1, (loadi8 addr:$src2)))]>,
1734 def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
1735 "test{w} {$src2, $src1|$src1, $src2}",
1736 [(set STATUS, (X86test R16:$src1, (loadi16 addr:$src2)))]>,
1737 Imp<[],[STATUS]>, OpSize;
1738 def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
1739 "test{l} {$src2, $src1|$src1, $src2}",
1740 [(set STATUS, (X86test R32:$src1, (loadi32 addr:$src2)))]>,
1743 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = R8 & imm8
1744 (ops R8:$src1, i8imm:$src2),
1745 "test{b} {$src2, $src1|$src1, $src2}",
1746 [(set STATUS, (X86test R8:$src1, imm:$src2))]>,
1748 def TEST16ri : Ii16<0xF7, MRM0r, // flags = R16 & imm16
1749 (ops R16:$src1, i16imm:$src2),
1750 "test{w} {$src2, $src1|$src1, $src2}",
1751 [(set STATUS, (X86test R16:$src1, imm:$src2))]>,
1752 Imp<[],[STATUS]>, OpSize;
1753 def TEST32ri : Ii32<0xF7, MRM0r, // flags = R32 & imm32
1754 (ops R32:$src1, i32imm:$src2),
1755 "test{l} {$src2, $src1|$src1, $src2}",
1756 [(set STATUS, (X86test R32:$src1, imm:$src2))]>,
1758 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
1759 (ops i8mem:$src1, i8imm:$src2),
1760 "test{b} {$src2, $src1|$src1, $src2}",
1761 [(set STATUS, (X86test (loadi8 addr:$src1), imm:$src2))]>,
1763 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
1764 (ops i16mem:$src1, i16imm:$src2),
1765 "test{w} {$src2, $src1|$src1, $src2}",
1766 [(set STATUS, (X86test (loadi16 addr:$src1), imm:$src2))]>,
1767 Imp<[],[STATUS]>, OpSize;
1768 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
1769 (ops i32mem:$src1, i32imm:$src2),
1770 "test{l} {$src2, $src1|$src1, $src2}",
1771 [(set STATUS, (X86test (loadi32 addr:$src1), imm:$src2))]>,
1775 // Condition code ops, incl. set if equal/not equal/...
1776 def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
1777 def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
1779 def SETBr : I<0x92, MRM0r,
1780 (ops R8 :$dst), "setb $dst", []>, TB; // R8 = < unsign
1781 def SETBm : I<0x92, MRM0m,
1782 (ops i8mem:$dst), "setb $dst", []>, TB; // [mem8] = < unsign
1783 def SETAEr : I<0x93, MRM0r,
1784 (ops R8 :$dst), "setae $dst", []>, TB; // R8 = >= unsign
1785 def SETAEm : I<0x93, MRM0m,
1786 (ops i8mem:$dst), "setae $dst", []>, TB; // [mem8] = >= unsign
1787 def SETEr : I<0x94, MRM0r,
1788 (ops R8 :$dst), "sete $dst", []>, TB; // R8 = ==
1789 def SETEm : I<0x94, MRM0m,
1790 (ops i8mem:$dst), "sete $dst", []>, TB; // [mem8] = ==
1791 def SETNEr : I<0x95, MRM0r,
1792 (ops R8 :$dst), "setne $dst", []>, TB; // R8 = !=
1793 def SETNEm : I<0x95, MRM0m,
1794 (ops i8mem:$dst), "setne $dst", []>, TB; // [mem8] = !=
1795 def SETBEr : I<0x96, MRM0r,
1796 (ops R8 :$dst), "setbe $dst", []>, TB; // R8 = <= unsign
1797 def SETBEm : I<0x96, MRM0m,
1798 (ops i8mem:$dst), "setbe $dst", []>, TB; // [mem8] = <= unsign
1799 def SETAr : I<0x97, MRM0r,
1800 (ops R8 :$dst), "seta $dst", []>, TB; // R8 = > signed
1801 def SETAm : I<0x97, MRM0m,
1802 (ops i8mem:$dst), "seta $dst", []>, TB; // [mem8] = > signed
1803 def SETSr : I<0x98, MRM0r,
1804 (ops R8 :$dst), "sets $dst", []>, TB; // R8 = <sign bit>
1805 def SETSm : I<0x98, MRM0m,
1806 (ops i8mem:$dst), "sets $dst", []>, TB; // [mem8] = <sign bit>
1807 def SETNSr : I<0x99, MRM0r,
1808 (ops R8 :$dst), "setns $dst", []>, TB; // R8 = !<sign bit>
1809 def SETNSm : I<0x99, MRM0m,
1810 (ops i8mem:$dst), "setns $dst", []>, TB; // [mem8] = !<sign bit>
1811 def SETPr : I<0x9A, MRM0r,
1812 (ops R8 :$dst), "setp $dst", []>, TB; // R8 = parity
1813 def SETPm : I<0x9A, MRM0m,
1814 (ops i8mem:$dst), "setp $dst", []>, TB; // [mem8] = parity
1815 def SETNPr : I<0x9B, MRM0r,
1816 (ops R8 :$dst), "setnp $dst", []>, TB; // R8 = not parity
1817 def SETNPm : I<0x9B, MRM0m,
1818 (ops i8mem:$dst), "setnp $dst", []>, TB; // [mem8] = not parity
1819 def SETLr : I<0x9C, MRM0r,
1820 (ops R8 :$dst), "setl $dst", []>, TB; // R8 = < signed
1821 def SETLm : I<0x9C, MRM0m,
1822 (ops i8mem:$dst), "setl $dst", []>, TB; // [mem8] = < signed
1823 def SETGEr : I<0x9D, MRM0r,
1824 (ops R8 :$dst), "setge $dst", []>, TB; // R8 = >= signed
1825 def SETGEm : I<0x9D, MRM0m,
1826 (ops i8mem:$dst), "setge $dst", []>, TB; // [mem8] = >= signed
1827 def SETLEr : I<0x9E, MRM0r,
1828 (ops R8 :$dst), "setle $dst", []>, TB; // R8 = <= signed
1829 def SETLEm : I<0x9E, MRM0m,
1830 (ops i8mem:$dst), "setle $dst", []>, TB; // [mem8] = <= signed
1831 def SETGr : I<0x9F, MRM0r,
1832 (ops R8 :$dst), "setg $dst", []>, TB; // R8 = < signed
1833 def SETGm : I<0x9F, MRM0m,
1834 (ops i8mem:$dst), "setg $dst", []>, TB; // [mem8] = < signed
1836 // Integer comparisons
1837 def CMP8rr : I<0x38, MRMDestReg,
1838 (ops R8 :$src1, R8 :$src2),
1839 "cmp{b} {$src2, $src1|$src1, $src2}",
1840 [(set STATUS, (X86cmp R8:$src1, R8:$src2))]>,
1842 def CMP16rr : I<0x39, MRMDestReg,
1843 (ops R16:$src1, R16:$src2),
1844 "cmp{w} {$src2, $src1|$src1, $src2}",
1845 [(set STATUS, (X86cmp R16:$src1, R16:$src2))]>,
1846 Imp<[],[STATUS]>, OpSize;
1847 def CMP32rr : I<0x39, MRMDestReg,
1848 (ops R32:$src1, R32:$src2),
1849 "cmp{l} {$src2, $src1|$src1, $src2}",
1850 [(set STATUS, (X86cmp R32:$src1, R32:$src2))]>,
1852 def CMP8mr : I<0x38, MRMDestMem,
1853 (ops i8mem :$src1, R8 :$src2),
1854 "cmp{b} {$src2, $src1|$src1, $src2}",
1855 [(set STATUS, (X86cmp (loadi8 addr:$src1), R8:$src2))]>,
1857 def CMP16mr : I<0x39, MRMDestMem,
1858 (ops i16mem:$src1, R16:$src2),
1859 "cmp{w} {$src2, $src1|$src1, $src2}",
1860 [(set STATUS, (X86cmp (loadi16 addr:$src1), R16:$src2))]>,
1861 Imp<[],[STATUS]>, OpSize;
1862 def CMP32mr : I<0x39, MRMDestMem,
1863 (ops i32mem:$src1, R32:$src2),
1864 "cmp{l} {$src2, $src1|$src1, $src2}",
1865 [(set STATUS, (X86cmp (loadi32 addr:$src1), R32:$src2))]>,
1867 def CMP8rm : I<0x3A, MRMSrcMem,
1868 (ops R8 :$src1, i8mem :$src2),
1869 "cmp{b} {$src2, $src1|$src1, $src2}",
1870 [(set STATUS, (X86cmp R8:$src1, (loadi8 addr:$src2)))]>,
1872 def CMP16rm : I<0x3B, MRMSrcMem,
1873 (ops R16:$src1, i16mem:$src2),
1874 "cmp{w} {$src2, $src1|$src1, $src2}",
1875 [(set STATUS, (X86cmp R16:$src1, (loadi16 addr:$src2)))]>,
1876 Imp<[],[STATUS]>, OpSize;
1877 def CMP32rm : I<0x3B, MRMSrcMem,
1878 (ops R32:$src1, i32mem:$src2),
1879 "cmp{l} {$src2, $src1|$src1, $src2}",
1880 [(set STATUS, (X86cmp R32:$src1, (loadi32 addr:$src2)))]>,
1882 def CMP8ri : Ii8<0x80, MRM7r,
1883 (ops R8:$src1, i8imm:$src2),
1884 "cmp{b} {$src2, $src1|$src1, $src2}",
1885 [(set STATUS, (X86cmp R8:$src1, imm:$src2))]>,
1887 def CMP16ri : Ii16<0x81, MRM7r,
1888 (ops R16:$src1, i16imm:$src2),
1889 "cmp{w} {$src2, $src1|$src1, $src2}",
1890 [(set STATUS, (X86cmp R16:$src1, imm:$src2))]>,
1891 Imp<[],[STATUS]>, OpSize;
1892 def CMP32ri : Ii32<0x81, MRM7r,
1893 (ops R32:$src1, i32imm:$src2),
1894 "cmp{l} {$src2, $src1|$src1, $src2}",
1895 [(set STATUS, (X86cmp R32:$src1, imm:$src2))]>,
1897 def CMP8mi : Ii8 <0x80, MRM7m,
1898 (ops i8mem :$src1, i8imm :$src2),
1899 "cmp{b} {$src2, $src1|$src1, $src2}",
1900 [(set STATUS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>,
1902 def CMP16mi : Ii16<0x81, MRM7m,
1903 (ops i16mem:$src1, i16imm:$src2),
1904 "cmp{w} {$src2, $src1|$src1, $src2}",
1905 [(set STATUS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
1906 Imp<[],[STATUS]>, OpSize;
1907 def CMP32mi : Ii32<0x81, MRM7m,
1908 (ops i32mem:$src1, i32imm:$src2),
1909 "cmp{l} {$src2, $src1|$src1, $src2}",
1910 [(set STATUS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>,
1913 // Sign/Zero extenders
1914 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src),
1915 "movs{bw|x} {$src, $dst|$dst, $src}",
1916 [(set R16:$dst, (sext R8:$src))]>, TB, OpSize;
1917 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src),
1918 "movs{bw|x} {$src, $dst|$dst, $src}",
1919 [(set R16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
1920 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src),
1921 "movs{bl|x} {$src, $dst|$dst, $src}",
1922 [(set R32:$dst, (sext R8:$src))]>, TB;
1923 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src),
1924 "movs{bl|x} {$src, $dst|$dst, $src}",
1925 [(set R32:$dst, (sextloadi32i8 addr:$src))]>, TB;
1926 def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src),
1927 "movs{wl|x} {$src, $dst|$dst, $src}",
1928 [(set R32:$dst, (sext R16:$src))]>, TB;
1929 def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src),
1930 "movs{wl|x} {$src, $dst|$dst, $src}",
1931 [(set R32:$dst, (sextloadi32i16 addr:$src))]>, TB;
1933 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src),
1934 "movz{bw|x} {$src, $dst|$dst, $src}",
1935 [(set R16:$dst, (zext R8:$src))]>, TB, OpSize;
1936 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src),
1937 "movz{bw|x} {$src, $dst|$dst, $src}",
1938 [(set R16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
1939 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src),
1940 "movz{bl|x} {$src, $dst|$dst, $src}",
1941 [(set R32:$dst, (zext R8:$src))]>, TB;
1942 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src),
1943 "movz{bl|x} {$src, $dst|$dst, $src}",
1944 [(set R32:$dst, (zextloadi32i8 addr:$src))]>, TB;
1945 def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src),
1946 "movz{wl|x} {$src, $dst|$dst, $src}",
1947 [(set R32:$dst, (zext R16:$src))]>, TB;
1948 def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src),
1949 "movz{wl|x} {$src, $dst|$dst, $src}",
1950 [(set R32:$dst, (zextloadi32i16 addr:$src))]>, TB;
1952 // Handling 1 bit zextload and sextload
1953 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
1954 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
1955 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
1956 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
1958 // Handling 1 bit extload
1959 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
1961 // Modeling anyext as zext
1962 def : Pat<(i16 (anyext R8 :$src)), (MOVZX16rr8 R8 :$src)>;
1963 def : Pat<(i32 (anyext R8 :$src)), (MOVZX32rr8 R8 :$src)>;
1964 def : Pat<(i32 (anyext R16:$src)), (MOVZX32rr16 R16:$src)>;
1966 //===----------------------------------------------------------------------===//
1967 // XMM Floating point support (requires SSE2)
1968 //===----------------------------------------------------------------------===//
1970 def MOVSSrr : I<0x10, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
1971 "movss {$src, $dst|$dst, $src}", []>, XS;
1972 def MOVSSrm : I<0x10, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
1973 "movss {$src, $dst|$dst, $src}", []>, XS;
1974 def MOVSSmr : I<0x11, MRMDestMem, (ops f32mem:$dst, V4F4:$src),
1975 "movss {$src, $dst|$dst, $src}", []>, XS;
1976 def MOVSDrr : I<0x10, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
1977 "movsd {$src, $dst|$dst, $src}", []>, XD;
1978 def MOVSDrm : I<0x10, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
1979 "movsd {$src, $dst|$dst, $src}", []>, XD;
1980 def MOVSDmr : I<0x11, MRMDestMem, (ops f64mem:$dst, V2F8:$src),
1981 "movsd {$src, $dst|$dst, $src}", []>, XD;
1983 def CVTTSD2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, V2F8:$src),
1984 "cvttsd2si {$src, $dst|$dst, $src}",
1985 [(set R32:$dst, (fp_to_sint V2F8:$src))]>, XD;
1986 def CVTTSD2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f64mem:$src),
1987 "cvttsd2si {$src, $dst|$dst, $src}", []>, XD;
1988 def CVTTSS2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, V4F4:$src),
1989 "cvttss2si {$src, $dst|$dst, $src}",
1990 [(set R32:$dst, (fp_to_sint V4F4:$src))]>, XS;
1991 def CVTTSS2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f32mem:$src),
1992 "cvttss2si {$src, $dst|$dst, $src}", []>, XS;
1993 def CVTSD2SSrr: I<0x5A, MRMSrcReg, (ops V4F4:$dst, V2F8:$src),
1994 "cvtsd2ss {$src, $dst|$dst, $src}",
1995 [(set V4F4:$dst, (fround V2F8:$src))]>, XS;
1996 def CVTSD2SSrm: I<0x5A, MRMSrcMem, (ops V4F4:$dst, f64mem:$src),
1997 "cvtsd2ss {$src, $dst|$dst, $src}", []>, XS;
1998 def CVTSS2SDrr: I<0x5A, MRMSrcReg, (ops V2F8:$dst, V4F4:$src),
1999 "cvtss2sd {$src, $dst|$dst, $src}",
2000 [(set V2F8:$dst, (fextend V4F4:$src))]>, XD;
2001 def CVTSS2SDrm: I<0x5A, MRMSrcMem, (ops V2F8:$dst, f32mem:$src),
2002 "cvtss2sd {$src, $dst|$dst, $src}", []>, XD;
2003 def CVTSI2SSrr: I<0x2A, MRMSrcReg, (ops V4F4:$dst, R32:$src),
2004 "cvtsi2ss {$src, $dst|$dst, $src}",
2005 [(set V4F4:$dst, (sint_to_fp R32:$src))]>, XS;
2006 def CVTSI2SSrm: I<0x2A, MRMSrcMem, (ops V4F4:$dst, i32mem:$src),
2007 "cvtsi2ss {$src, $dst|$dst, $src}", []>, XS;
2008 def CVTSI2SDrr: I<0x2A, MRMSrcReg, (ops V2F8:$dst, R32:$src),
2009 "cvtsi2sd {$src, $dst|$dst, $src}",
2010 [(set V2F8:$dst, (sint_to_fp R32:$src))]>, XD;
2011 def CVTSI2SDrm: I<0x2A, MRMSrcMem, (ops V2F8:$dst, i32mem:$src),
2012 "cvtsi2sd {$src, $dst|$dst, $src}", []>, XD;
2014 def SQRTSSrm : I<0x51, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
2015 "sqrtss {$src, $dst|$dst, $src}", []>, XS;
2016 def SQRTSSrr : I<0x51, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
2017 "sqrtss {$src, $dst|$dst, $src}",
2018 [(set V4F4:$dst, (fsqrt V4F4:$src))]>, XS;
2019 def SQRTSDrm : I<0x51, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
2020 "sqrtsd {$src, $dst|$dst, $src}", []>, XD;
2021 def SQRTSDrr : I<0x51, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
2022 "sqrtsd {$src, $dst|$dst, $src}",
2023 [(set V2F8:$dst, (fsqrt V2F8:$src))]>, XD;
2025 def UCOMISDrr: I<0x2E, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
2026 "ucomisd {$src, $dst|$dst, $src}", []>, TB, OpSize;
2027 def UCOMISDrm: I<0x2E, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
2028 "ucomisd {$src, $dst|$dst, $src}", []>, TB, OpSize;
2029 def UCOMISSrr: I<0x2E, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
2030 "ucomiss {$src, $dst|$dst, $src}", []>, TB;
2031 def UCOMISSrm: I<0x2E, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
2032 "ucomiss {$src, $dst|$dst, $src}", []>, TB;
2034 // Pseudo-instructions that map fld0 to xorps/xorpd for sse.
2035 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2036 def FLD0SS : I<0x57, MRMSrcReg, (ops V4F4:$dst),
2037 "xorps $dst, $dst", []>, TB;
2038 def FLD0SD : I<0x57, MRMSrcReg, (ops V2F8:$dst),
2039 "xorpd $dst, $dst", []>, TB, OpSize;
2041 let isTwoAddress = 1 in {
2042 let isCommutable = 1 in {
2043 def ADDSSrr : I<0x58, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
2044 "addss {$src2, $dst|$dst, $src2}",
2045 [(set V4F4:$dst, (fadd V4F4:$src1, V4F4:$src2))]>, XS;
2046 def ADDSDrr : I<0x58, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
2047 "addsd {$src2, $dst|$dst, $src2}",
2048 [(set V2F8:$dst, (fadd V2F8:$src1, V2F8:$src2))]>, XD;
2049 def ANDPSrr : I<0x54, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
2050 "andps {$src2, $dst|$dst, $src2}", []>, TB;
2051 def ANDPDrr : I<0x54, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
2052 "andpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
2053 def MULSSrr : I<0x59, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
2054 "mulss {$src2, $dst|$dst, $src2}",
2055 [(set V4F4:$dst, (fmul V4F4:$src1, V4F4:$src2))]>, XS;
2056 def MULSDrr : I<0x59, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
2057 "mulsd {$src2, $dst|$dst, $src2}",
2058 [(set V2F8:$dst, (fmul V2F8:$src1, V2F8:$src2))]>, XD;
2059 def ORPSrr : I<0x56, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
2060 "orps {$src2, $dst|$dst, $src2}", []>, TB;
2061 def ORPDrr : I<0x56, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
2062 "orpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
2063 def XORPSrr : I<0x57, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
2064 "xorps {$src2, $dst|$dst, $src2}", []>, TB;
2065 def XORPDrr : I<0x57, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
2066 "xorpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
2068 def ANDNPSrr : I<0x55, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
2069 "andnps {$src2, $dst|$dst, $src2}", []>, TB;
2070 def ANDNPDrr : I<0x55, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
2071 "andnpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
2072 def ADDSSrm : I<0x58, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
2073 "addss {$src2, $dst|$dst, $src2}", []>, XS;
2074 def ADDSDrm : I<0x58, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
2075 "addsd {$src2, $dst|$dst, $src2}", []>, XD;
2076 def MULSSrm : I<0x59, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
2077 "mulss {$src2, $dst|$dst, $src2}", []>, XS;
2078 def MULSDrm : I<0x59, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
2079 "mulsd {$src2, $dst|$dst, $src2}", []>, XD;
2081 def DIVSSrm : I<0x5E, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
2082 "divss {$src2, $dst|$dst, $src2}", []>, XS;
2083 def DIVSSrr : I<0x5E, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
2084 "divss {$src2, $dst|$dst, $src2}",
2085 [(set V4F4:$dst, (fdiv V4F4:$src1, V4F4:$src2))]>, XS;
2086 def DIVSDrm : I<0x5E, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
2087 "divsd {$src2, $dst|$dst, $src2}", []>, XD;
2088 def DIVSDrr : I<0x5E, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
2089 "divsd {$src2, $dst|$dst, $src2}",
2090 [(set V2F8:$dst, (fdiv V2F8:$src1, V2F8:$src2))]>, XD;
2092 def SUBSSrm : I<0x5C, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
2093 "subss {$src2, $dst|$dst, $src2}", []>, XS;
2094 def SUBSSrr : I<0x5C, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
2095 "subss {$src2, $dst|$dst, $src2}",
2096 [(set V4F4:$dst, (fsub V4F4:$src1, V4F4:$src2))]>, XS;
2097 def SUBSDrm : I<0x5C, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
2098 "subsd {$src2, $dst|$dst, $src2}", []>, XD;
2099 def SUBSDrr : I<0x5C, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
2100 "subsd {$src2, $dst|$dst, $src2}",
2101 [(set V2F8:$dst, (fsub V2F8:$src1, V2F8:$src2))]>, XD;
2103 def CMPSSrr : I<0xC2, MRMSrcReg,
2104 (ops V4F4:$dst, V4F4:$src1, V4F4:$src, SSECC:$cc),
2105 "cmp${cc}ss {$src, $dst|$dst, $src}", []>, XS;
2106 def CMPSSrm : I<0xC2, MRMSrcMem,
2107 (ops V4F4:$dst, V4F4:$src1, f32mem:$src, SSECC:$cc),
2108 "cmp${cc}ss {$src, $dst|$dst, $src}", []>, XS;
2109 def CMPSDrr : I<0xC2, MRMSrcReg,
2110 (ops V2F8:$dst, V2F8:$src1, V2F8:$src, SSECC:$cc),
2111 "cmp${cc}sd {$src, $dst|$dst, $src}", []>, XD;
2112 def CMPSDrm : I<0xC2, MRMSrcMem,
2113 (ops V2F8:$dst, V2F8:$src1, f64mem:$src, SSECC:$cc),
2114 "cmp${cc}sd {$src, $dst|$dst, $src}", []>, XD;
2117 //===----------------------------------------------------------------------===//
2118 // Miscellaneous Instructions
2119 //===----------------------------------------------------------------------===//
2121 def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", []>, TB, Imp<[],[EAX,EDX]>;
2124 //===----------------------------------------------------------------------===//
2125 // Stack-based Floating point support
2126 //===----------------------------------------------------------------------===//
2128 // FIXME: These need to indicate mod/ref sets for FP regs... & FP 'TOP'
2130 // Floating point instruction template
2131 class FPI<bits<8> o, Format F, FPFormat fp, dag ops, string asm>
2132 : X86Inst<o, F, NoImm, ops, asm> {
2133 let FPForm = fp; let FPFormBits = FPForm.Value;
2136 // Pseudo instructions for floating point. We use these pseudo instructions
2137 // because they can be expanded by the fp spackifier into one of many different
2138 // forms of instructions for doing these operations. Until the stackifier runs,
2139 // we prefer to be abstract.
2140 def FpMOV : FPI<0, Pseudo, SpecialFP,
2141 (ops RFP:$dst, RFP:$src), "">; // f1 = fmov f2
2142 def FpADD : FPI<0, Pseudo, TwoArgFP ,
2143 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fadd f2, f3
2144 def FpSUB : FPI<0, Pseudo, TwoArgFP ,
2145 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fsub f2, f3
2146 def FpMUL : FPI<0, Pseudo, TwoArgFP ,
2147 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fmul f2, f3
2148 def FpDIV : FPI<0, Pseudo, TwoArgFP ,
2149 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fdiv f2, f3
2151 def FpGETRESULT : FPI<0, Pseudo, SpecialFP, (ops RFP:$dst), "">,
2152 Imp<[ST0], []>; // FPR = ST(0)
2154 def FpSETRESULT : FPI<0, Pseudo, SpecialFP, (ops RFP:$src), "">,
2155 Imp<[], [ST0]>; // ST(0) = FPR
2157 // FADD reg, mem: Before stackification, these are represented by:
2158 // R1 = FADD* R2, [mem]
2159 def FADD32m : FPI<0xD8, MRM0m, OneArgFPRW, // ST(0) = ST(0) + [mem32real]
2160 (ops f32mem:$src, variable_ops),
2162 def FADD64m : FPI<0xDC, MRM0m, OneArgFPRW, // ST(0) = ST(0) + [mem64real]
2163 (ops f64mem:$src, variable_ops),
2165 //def FIADD16m : FPI<0xDE, MRM0m, OneArgFPRW>; // ST(0) = ST(0) + [mem16int]
2166 //def FIADD32m : FPI<0xDA, MRM0m, OneArgFPRW>; // ST(0) = ST(0) + [mem32int]
2168 // FMUL reg, mem: Before stackification, these are represented by:
2169 // R1 = FMUL* R2, [mem]
2170 def FMUL32m : FPI<0xD8, MRM1m, OneArgFPRW, // ST(0) = ST(0) * [mem32real]
2171 (ops f32mem:$src, variable_ops),
2173 def FMUL64m : FPI<0xDC, MRM1m, OneArgFPRW, // ST(0) = ST(0) * [mem64real]
2174 (ops f64mem:$src, variable_ops),
2176 // ST(0) = ST(0) * [mem16int]
2177 //def FIMUL16m : FPI16m<"fimul", 0xDE, MRM1m, OneArgFPRW>;
2178 // ST(0) = ST(0) * [mem32int]
2179 //def FIMUL32m : FPI32m<"fimul", 0xDA, MRM1m, OneArgFPRW>;
2181 // FSUB reg, mem: Before stackification, these are represented by:
2182 // R1 = FSUB* R2, [mem]
2183 def FSUB32m : FPI<0xD8, MRM4m, OneArgFPRW, // ST(0) = ST(0) - [mem32real]
2184 (ops f32mem:$src, variable_ops),
2186 def FSUB64m : FPI<0xDC, MRM4m, OneArgFPRW, // ST(0) = ST(0) - [mem64real]
2187 (ops f64mem:$src, variable_ops),
2189 // ST(0) = ST(0) - [mem16int]
2190 //def FISUB16m : FPI16m<"fisub", 0xDE, MRM4m, OneArgFPRW>;
2191 // ST(0) = ST(0) - [mem32int]
2192 //def FISUB32m : FPI32m<"fisub", 0xDA, MRM4m, OneArgFPRW>;
2194 // FSUBR reg, mem: Before stackification, these are represented by:
2195 // R1 = FSUBR* R2, [mem]
2197 // Note that the order of operands does not reflect the operation being
2199 def FSUBR32m : FPI<0xD8, MRM5m, OneArgFPRW, // ST(0) = [mem32real] - ST(0)
2200 (ops f32mem:$src, variable_ops),
2202 def FSUBR64m : FPI<0xDC, MRM5m, OneArgFPRW, // ST(0) = [mem64real] - ST(0)
2203 (ops f64mem:$src, variable_ops),
2205 // ST(0) = [mem16int] - ST(0)
2206 //def FISUBR16m : FPI16m<"fisubr", 0xDE, MRM5m, OneArgFPRW>;
2207 // ST(0) = [mem32int] - ST(0)
2208 //def FISUBR32m : FPI32m<"fisubr", 0xDA, MRM5m, OneArgFPRW>;
2210 // FDIV reg, mem: Before stackification, these are represented by:
2211 // R1 = FDIV* R2, [mem]
2212 def FDIV32m : FPI<0xD8, MRM6m, OneArgFPRW, // ST(0) = ST(0) / [mem32real]
2213 (ops f32mem:$src, variable_ops),
2215 def FDIV64m : FPI<0xDC, MRM6m, OneArgFPRW, // ST(0) = ST(0) / [mem64real]
2216 (ops f64mem:$src, variable_ops),
2218 // ST(0) = ST(0) / [mem16int]
2219 //def FIDIV16m : FPI16m<"fidiv", 0xDE, MRM6m, OneArgFPRW>;
2220 // ST(0) = ST(0) / [mem32int]
2221 //def FIDIV32m : FPI32m<"fidiv", 0xDA, MRM6m, OneArgFPRW>;
2223 // FDIVR reg, mem: Before stackification, these are represented by:
2224 // R1 = FDIVR* R2, [mem]
2225 // Note that the order of operands does not reflect the operation being
2227 def FDIVR32m : FPI<0xD8, MRM7m, OneArgFPRW, // ST(0) = [mem32real] / ST(0)
2228 (ops f32mem:$src, variable_ops),
2230 def FDIVR64m : FPI<0xDC, MRM7m, OneArgFPRW, // ST(0) = [mem64real] / ST(0)
2231 (ops f64mem:$src, variable_ops),
2233 // ST(0) = [mem16int] / ST(0)
2234 //def FIDIVR16m : FPI16m<"fidivr", 0xDE, MRM7m, OneArgFPRW>;
2235 // ST(0) = [mem32int] / ST(0)
2236 //def FIDIVR32m : FPI32m<"fidivr", 0xDA, MRM7m, OneArgFPRW>;
2239 // Floating point cmovs...
2240 let isTwoAddress = 1, Uses = [ST0], Defs = [ST0] in {
2241 def FCMOVB : FPI<0xC0, AddRegFrm, CondMovFP,
2242 (ops RST:$op, variable_ops),
2243 "fcmovb {$op, %ST(0)|%ST(0), $op}">, DA;
2244 def FCMOVBE : FPI<0xD0, AddRegFrm, CondMovFP,
2245 (ops RST:$op, variable_ops),
2246 "fcmovbe {$op, %ST(0)|%ST(0), $op}">, DA;
2247 def FCMOVE : FPI<0xC8, AddRegFrm, CondMovFP,
2248 (ops RST:$op, variable_ops),
2249 "fcmove {$op, %ST(0)|%ST(0), $op}">, DA;
2250 def FCMOVP : FPI<0xD8, AddRegFrm, CondMovFP,
2251 (ops RST:$op, variable_ops),
2252 "fcmovu {$op, %ST(0)|%ST(0), $op}">, DA;
2253 def FCMOVAE : FPI<0xC0, AddRegFrm, CondMovFP,
2254 (ops RST:$op, variable_ops),
2255 "fcmovae {$op, %ST(0)|%ST(0), $op}">, DB;
2256 def FCMOVA : FPI<0xD0, AddRegFrm, CondMovFP,
2257 (ops RST:$op, variable_ops),
2258 "fcmova {$op, %ST(0)|%ST(0), $op}">, DB;
2259 def FCMOVNE : FPI<0xC8, AddRegFrm, CondMovFP,
2260 (ops RST:$op, variable_ops),
2261 "fcmovne {$op, %ST(0)|%ST(0), $op}">, DB;
2262 def FCMOVNP : FPI<0xD8, AddRegFrm, CondMovFP,
2263 (ops RST:$op, variable_ops),
2264 "fcmovnu {$op, %ST(0)|%ST(0), $op}">, DB;
2267 // Floating point loads & stores...
2268 // FIXME: these are all marked variable_ops because they have an implicit
2269 // destination. Instructions like FILD* that are generated by the instruction
2270 // selector (not the fp stackifier) need more accurate operand accounting.
2271 def FLDrr : FPI<0xC0, AddRegFrm, NotFP,
2272 (ops RST:$src, variable_ops),
2274 def FLD32m : FPI<0xD9, MRM0m, ZeroArgFP,
2275 (ops f32mem:$src, variable_ops),
2277 def FLD64m : FPI<0xDD, MRM0m, ZeroArgFP,
2278 (ops f64mem:$src, variable_ops),
2280 def FLD80m : FPI<0xDB, MRM5m, ZeroArgFP,
2281 (ops f80mem:$src, variable_ops),
2283 def FILD16m : FPI<0xDF, MRM0m, ZeroArgFP,
2284 (ops i16mem:$src, variable_ops),
2286 def FILD32m : FPI<0xDB, MRM0m, ZeroArgFP,
2287 (ops i32mem:$src, variable_ops),
2289 def FILD64m : FPI<0xDF, MRM5m, ZeroArgFP,
2290 (ops i64mem:$src, variable_ops),
2293 def FSTrr : FPI<0xD0, AddRegFrm, NotFP,
2294 (ops RST:$op, variable_ops),
2296 def FSTPrr : FPI<0xD8, AddRegFrm, NotFP,
2297 (ops RST:$op, variable_ops),
2299 def FST32m : FPI<0xD9, MRM2m, OneArgFP,
2300 (ops f32mem:$op, variable_ops),
2302 def FST64m : FPI<0xDD, MRM2m, OneArgFP,
2303 (ops f64mem:$op, variable_ops),
2305 def FSTP32m : FPI<0xD9, MRM3m, OneArgFP,
2306 (ops f32mem:$op, variable_ops),
2308 def FSTP64m : FPI<0xDD, MRM3m, OneArgFP,
2309 (ops f64mem:$op, variable_ops),
2311 def FSTP80m : FPI<0xDB, MRM7m, OneArgFP,
2312 (ops f80mem:$op, variable_ops),
2315 def FIST16m : FPI<0xDF, MRM2m , OneArgFP,
2316 (ops i16mem:$op, variable_ops),
2318 def FIST32m : FPI<0xDB, MRM2m , OneArgFP,
2319 (ops i32mem:$op, variable_ops),
2321 def FISTP16m : FPI<0xDF, MRM3m , NotFP ,
2322 (ops i16mem:$op, variable_ops),
2324 def FISTP32m : FPI<0xDB, MRM3m , NotFP ,
2325 (ops i32mem:$op, variable_ops),
2327 def FISTP64m : FPI<0xDF, MRM7m , OneArgFP,
2328 (ops i64mem:$op, variable_ops),
2331 def FXCH : FPI<0xC8, AddRegFrm, NotFP,
2332 (ops RST:$op), "fxch $op">, D9; // fxch ST(i), ST(0)
2334 // Floating point constant loads...
2335 def FLD0 : FPI<0xEE, RawFrm, ZeroArgFP, (ops variable_ops), "fldz">, D9;
2336 def FLD1 : FPI<0xE8, RawFrm, ZeroArgFP, (ops variable_ops), "fld1">, D9;
2339 // Unary operations...
2340 def FCHS : FPI<0xE0, RawFrm, OneArgFPRW, // f1 = fchs f2
2343 def FABS : FPI<0xE1, RawFrm, OneArgFPRW, // f1 = fabs f2
2346 def FSQRT : FPI<0xFA, RawFrm, OneArgFPRW, // fsqrt ST(0)
2349 def FSIN : FPI<0xFE, RawFrm, OneArgFPRW, // fsin ST(0)
2352 def FCOS : FPI<0xFF, RawFrm, OneArgFPRW, // fcos ST(0)
2355 def FTST : FPI<0xE4, RawFrm, OneArgFP , // ftst ST(0)
2359 // Binary arithmetic operations...
2360 class FPST0rInst<bits<8> o, dag ops, string asm>
2361 : I<o, AddRegFrm, ops, asm, []>, D8 {
2362 list<Register> Uses = [ST0];
2363 list<Register> Defs = [ST0];
2365 class FPrST0Inst<bits<8> o, dag ops, string asm>
2366 : I<o, AddRegFrm, ops, asm, []>, DC {
2367 list<Register> Uses = [ST0];
2369 class FPrST0PInst<bits<8> o, dag ops, string asm>
2370 : I<o, AddRegFrm, ops, asm, []>, DE {
2371 list<Register> Uses = [ST0];
2374 def FADDST0r : FPST0rInst <0xC0, (ops RST:$op),
2376 def FADDrST0 : FPrST0Inst <0xC0, (ops RST:$op),
2377 "fadd {%ST(0), $op|$op, %ST(0)}">;
2378 def FADDPrST0 : FPrST0PInst<0xC0, (ops RST:$op),
2381 // NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
2382 // of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
2383 // we have to put some 'r's in and take them out of weird places.
2384 def FSUBRST0r : FPST0rInst <0xE8, (ops RST:$op),
2386 def FSUBrST0 : FPrST0Inst <0xE8, (ops RST:$op),
2387 "fsub{r} {%ST(0), $op|$op, %ST(0)}">;
2388 def FSUBPrST0 : FPrST0PInst<0xE8, (ops RST:$op),
2391 def FSUBST0r : FPST0rInst <0xE0, (ops RST:$op),
2393 def FSUBRrST0 : FPrST0Inst <0xE0, (ops RST:$op),
2394 "fsub{|r} {%ST(0), $op|$op, %ST(0)}">;
2395 def FSUBRPrST0 : FPrST0PInst<0xE0, (ops RST:$op),
2398 def FMULST0r : FPST0rInst <0xC8, (ops RST:$op),
2400 def FMULrST0 : FPrST0Inst <0xC8, (ops RST:$op),
2401 "fmul {%ST(0), $op|$op, %ST(0)}">;
2402 def FMULPrST0 : FPrST0PInst<0xC8, (ops RST:$op),
2405 def FDIVRST0r : FPST0rInst <0xF8, (ops RST:$op),
2407 def FDIVrST0 : FPrST0Inst <0xF8, (ops RST:$op),
2408 "fdiv{r} {%ST(0), $op|$op, %ST(0)}">;
2409 def FDIVPrST0 : FPrST0PInst<0xF8, (ops RST:$op),
2412 def FDIVST0r : FPST0rInst <0xF0, (ops RST:$op), // ST(0) = ST(0) / ST(i)
2414 def FDIVRrST0 : FPrST0Inst <0xF0, (ops RST:$op), // ST(i) = ST(0) / ST(i)
2415 "fdiv{|r} {%ST(0), $op|$op, %ST(0)}">;
2416 def FDIVRPrST0 : FPrST0PInst<0xF0, (ops RST:$op), // ST(i) = ST(0) / ST(i), pop
2419 // Floating point compares
2420 def FUCOMr : FPI<0xE0, AddRegFrm, CompareFP, // FPSW = cmp ST(0) with ST(i)
2421 (ops RST:$reg, variable_ops),
2422 "fucom $reg">, DD, Imp<[ST0],[]>;
2423 def FUCOMPr : I<0xE8, AddRegFrm, // FPSW = cmp ST(0) with ST(i), pop
2424 (ops RST:$reg, variable_ops),
2425 "fucomp $reg", []>, DD, Imp<[ST0],[]>;
2426 def FUCOMPPr : I<0xE9, RawFrm, // cmp ST(0) with ST(1), pop, pop
2428 "fucompp", []>, DA, Imp<[ST0],[]>;
2430 def FUCOMIr : FPI<0xE8, AddRegFrm, CompareFP, // CC = cmp ST(0) with ST(i)
2431 (ops RST:$reg, variable_ops),
2432 "fucomi {$reg, %ST(0)|%ST(0), $reg}">, DB, Imp<[ST0],[]>;
2433 def FUCOMIPr : I<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i), pop
2434 (ops RST:$reg, variable_ops),
2435 "fucomip {$reg, %ST(0)|%ST(0), $reg}", []>, DF, Imp<[ST0],[]>;
2438 // Floating point flag ops
2439 def FNSTSW8r : I<0xE0, RawFrm, // AX = fp flags
2440 (ops), "fnstsw", []>, DF, Imp<[],[AX]>;
2442 def FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world
2443 (ops i16mem:$dst), "fnstcw $dst", []>;
2444 def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
2445 (ops i16mem:$dst), "fldcw $dst", []>;