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 SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
24 def SDTX86CmpTest : SDTypeProfile<1, 2, [SDTCisVT<0, FlagVT>, SDTCisSameAs<1, 2>]>;
26 def SDTX86Cmov : SDTypeProfile<1, 4,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, FlagVT>]>;
30 def SDTX86BrCond : SDTypeProfile<0, 3,
31 [SDTCisVT<0, OtherVT>,
32 SDTCisVT<1, i8>, SDTCisVT<2, FlagVT>]>;
34 def SDTX86SetCC : SDTypeProfile<1, 2,
35 [SDTCisVT<0, i8>, SDTCisVT<1, i8>,
36 SDTCisVT<2, FlagVT>]>;
38 def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
40 def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
41 def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
44 def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
46 def SDTX86FpGet : SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>;
47 def SDTX86FpSet : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
49 def SDTX86Fld : SDTypeProfile<1, 2, [SDTCisVT<0, f64>,
50 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
51 def SDTX86Fst : SDTypeProfile<0, 3, [SDTCisFP<0>,
52 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
53 def SDTX86Fild64m : SDTypeProfile<1, 1, [SDTCisVT<0, f64>, SDTCisPtrTy<1>]>;
55 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
57 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
59 def X86addflag : SDNode<"X86ISD::ADD_FLAG", SDTIntBinOp ,
60 [SDNPCommutative, SDNPAssociative, SDNPOutFlag]>;
61 def X86subflag : SDNode<"X86ISD::SUB_FLAG", SDTIntBinOp,
63 def X86adc : SDNode<"X86ISD::ADC" , SDTIntBinOp ,
64 [SDNPCommutative, SDNPAssociative]>;
65 def X86sbb : SDNode<"X86ISD::SBB" , SDTIntBinOp>;
67 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
68 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
70 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest, []>;
71 def X86test : SDNode<"X86ISD::TEST", SDTX86CmpTest, []>;
73 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
75 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
77 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC, []>;
79 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
80 [SDNPHasChain, SDNPOptInFlag]>;
82 def X86callseq_start :
83 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
86 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
89 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
90 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
92 def X86fpget : SDNode<"X86ISD::FP_GET_RESULT", SDTX86FpGet,
93 [SDNPHasChain, SDNPInFlag]>;
94 def X86fpset : SDNode<"X86ISD::FP_SET_RESULT", SDTX86FpSet,
95 [SDNPHasChain, SDNPOutFlag]>;
97 def X86fld : SDNode<"X86ISD::FLD", SDTX86Fld,
99 def X86fst : SDNode<"X86ISD::FST", SDTX86Fst,
101 def X86fild64m : SDNode<"X86ISD::FILD64m", SDTX86Fild64m,
104 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
105 [SDNPHasChain, SDNPInFlag]>;
106 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
107 [SDNPHasChain, SDNPInFlag]>;
109 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
110 [SDNPHasChain, SDNPOutFlag]>;
112 //===----------------------------------------------------------------------===//
113 // X86 Operand Definitions.
116 // *mem - Operand definitions for the funky X86 addressing mode operands.
118 class X86MemOperand<string printMethod> : Operand<i32> {
119 let PrintMethod = printMethod;
120 let NumMIOperands = 4;
121 let MIOperandInfo = (ops R32, i8imm, R32, i32imm);
124 def i8mem : X86MemOperand<"printi8mem">;
125 def i16mem : X86MemOperand<"printi16mem">;
126 def i32mem : X86MemOperand<"printi32mem">;
127 def i64mem : X86MemOperand<"printi64mem">;
128 def f32mem : X86MemOperand<"printf32mem">;
129 def f64mem : X86MemOperand<"printf64mem">;
130 def f80mem : X86MemOperand<"printf80mem">;
132 def SSECC : Operand<i8> {
133 let PrintMethod = "printSSECC";
136 // A couple of more descriptive operand definitions.
137 // 16-bits but only 8 bits are significant.
138 def i16i8imm : Operand<i16>;
139 // 32-bits but only 8 bits are significant.
140 def i32i8imm : Operand<i32>;
142 // PCRelative calls need special operand formatting.
143 let PrintMethod = "printCallOperand" in
144 def calltarget : Operand<i32>;
146 // Branch targets have OtherVT type.
147 def brtarget : Operand<OtherVT>;
149 //===----------------------------------------------------------------------===//
150 // X86 Complex Pattern Definitions.
153 // Define X86 specific addressing mode.
154 def addr : ComplexPattern<i32, 4, "SelectAddr", []>;
155 def leaaddr : ComplexPattern<i32, 4, "SelectLEAAddr",
156 [add, frameindex, constpool]>;
158 //===----------------------------------------------------------------------===//
159 // X86 Instruction Format Definitions.
162 // Format specifies the encoding used by the instruction. This is part of the
163 // ad-hoc solution used to emit machine instruction encodings by our machine
165 class Format<bits<5> val> {
169 def Pseudo : Format<0>; def RawFrm : Format<1>;
170 def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
171 def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
172 def MRMSrcMem : Format<6>;
173 def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
174 def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
175 def MRM6r : Format<22>; def MRM7r : Format<23>;
176 def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
177 def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
178 def MRM6m : Format<30>; def MRM7m : Format<31>;
180 //===----------------------------------------------------------------------===//
181 // X86 Instruction Predicate Definitions.
182 def HasSSE1 : Predicate<"X86Vector >= SSE">;
183 def HasSSE2 : Predicate<"X86Vector >= SSE2">;
184 def HasSSE3 : Predicate<"X86Vector >= SSE3">;
185 def FPStack : Predicate<"X86Vector < SSE2">;
187 //===----------------------------------------------------------------------===//
188 // X86 specific pattern fragments.
191 // ImmType - This specifies the immediate type used by an instruction. This is
192 // part of the ad-hoc solution used to emit machine instruction encodings by our
193 // machine code emitter.
194 class ImmType<bits<2> val> {
197 def NoImm : ImmType<0>;
198 def Imm8 : ImmType<1>;
199 def Imm16 : ImmType<2>;
200 def Imm32 : ImmType<3>;
202 // FPFormat - This specifies what form this FP instruction has. This is used by
203 // the Floating-Point stackifier pass.
204 class FPFormat<bits<3> val> {
207 def NotFP : FPFormat<0>;
208 def ZeroArgFP : FPFormat<1>;
209 def OneArgFP : FPFormat<2>;
210 def OneArgFPRW : FPFormat<3>;
211 def TwoArgFP : FPFormat<4>;
212 def CompareFP : FPFormat<5>;
213 def CondMovFP : FPFormat<6>;
214 def SpecialFP : FPFormat<7>;
217 class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
219 let Namespace = "X86";
221 bits<8> Opcode = opcod;
223 bits<5> FormBits = Form.Value;
225 bits<2> ImmTypeBits = ImmT.Value;
227 dag OperandList = ops;
228 string AsmString = AsmStr;
231 // Attributes specific to X86 instructions...
233 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
235 bits<4> Prefix = 0; // Which prefix byte does this inst have?
236 FPFormat FPForm; // What flavor of FP instruction is this?
237 bits<3> FPFormBits = 0;
240 class Imp<list<Register> uses, list<Register> defs> {
241 list<Register> Uses = uses;
242 list<Register> Defs = defs;
246 // Prefix byte classes which are used to indicate to the ad-hoc machine code
247 // emitter that various prefix bytes are required.
248 class OpSize { bit hasOpSizePrefix = 1; }
249 class TB { bits<4> Prefix = 1; }
250 class REP { bits<4> Prefix = 2; }
251 class D8 { bits<4> Prefix = 3; }
252 class D9 { bits<4> Prefix = 4; }
253 class DA { bits<4> Prefix = 5; }
254 class DB { bits<4> Prefix = 6; }
255 class DC { bits<4> Prefix = 7; }
256 class DD { bits<4> Prefix = 8; }
257 class DE { bits<4> Prefix = 9; }
258 class DF { bits<4> Prefix = 10; }
259 class XD { bits<4> Prefix = 11; }
260 class XS { bits<4> Prefix = 12; }
263 //===----------------------------------------------------------------------===//
264 // Pattern fragments...
267 // X86 specific condition code. These correspond to CondCode in
268 // X86ISelLowering.h. They must be kept in synch.
269 def X86_COND_A : PatLeaf<(i8 0)>;
270 def X86_COND_AE : PatLeaf<(i8 1)>;
271 def X86_COND_B : PatLeaf<(i8 2)>;
272 def X86_COND_BE : PatLeaf<(i8 3)>;
273 def X86_COND_E : PatLeaf<(i8 4)>;
274 def X86_COND_G : PatLeaf<(i8 5)>;
275 def X86_COND_GE : PatLeaf<(i8 6)>;
276 def X86_COND_L : PatLeaf<(i8 7)>;
277 def X86_COND_LE : PatLeaf<(i8 8)>;
278 def X86_COND_NE : PatLeaf<(i8 9)>;
279 def X86_COND_NO : PatLeaf<(i8 10)>;
280 def X86_COND_NP : PatLeaf<(i8 11)>;
281 def X86_COND_NS : PatLeaf<(i8 12)>;
282 def X86_COND_O : PatLeaf<(i8 13)>;
283 def X86_COND_P : PatLeaf<(i8 14)>;
284 def X86_COND_S : PatLeaf<(i8 15)>;
286 def i16immSExt8 : PatLeaf<(i16 imm), [{
287 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
288 // sign extended field.
289 return (int)N->getValue() == (signed char)N->getValue();
292 def i32immSExt8 : PatLeaf<(i32 imm), [{
293 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
294 // sign extended field.
295 return (int)N->getValue() == (signed char)N->getValue();
298 def i16immZExt8 : PatLeaf<(i16 imm), [{
299 // i16immZExt8 predicate - True if the 16-bit immediate fits in a 8-bit zero
301 return (unsigned)N->getValue() == (unsigned char)N->getValue();
304 def fp32imm0 : PatLeaf<(f32 fpimm), [{
305 return N->isExactlyValue(+0.0);
308 def fp64imm0 : PatLeaf<(f64 fpimm), [{
309 return N->isExactlyValue(+0.0);
312 def fp64immneg0 : PatLeaf<(f64 fpimm), [{
313 return N->isExactlyValue(-0.0);
316 def fp64imm1 : PatLeaf<(f64 fpimm), [{
317 return N->isExactlyValue(+1.0);
320 def fp64immneg1 : PatLeaf<(f64 fpimm), [{
321 return N->isExactlyValue(-1.0);
324 // Helper fragments for loads.
325 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
326 def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
327 def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
328 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
329 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
331 def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i1))>;
332 def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i1))>;
333 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i8))>;
334 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i8))>;
335 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i16))>;
337 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i1))>;
338 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i1))>;
339 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i8))>;
340 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i8))>;
341 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i16))>;
343 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extload node:$ptr, i1))>;
344 def extloadf64f32 : PatFrag<(ops node:$ptr), (f64 (extload node:$ptr, f32))>;
346 //===----------------------------------------------------------------------===//
347 // Instruction templates...
349 class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
350 : X86Inst<o, f, NoImm, ops, asm> {
351 let Pattern = pattern;
353 class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
354 : X86Inst<o, f, Imm8 , ops, asm> {
355 let Pattern = pattern;
357 class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
358 : X86Inst<o, f, Imm16, ops, asm> {
359 let Pattern = pattern;
361 class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
362 : X86Inst<o, f, Imm32, ops, asm> {
363 let Pattern = pattern;
366 //===----------------------------------------------------------------------===//
367 // Instruction list...
370 // Pseudo-instructions:
371 def PHI : I<0, Pseudo, (ops variable_ops), "PHINODE", []>; // PHI node.
373 def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
374 [(X86callseq_start imm:$amt)]>;
375 def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
377 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
378 def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
379 def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
380 def IMPLICIT_DEF_R8 : I<0, Pseudo, (ops R8:$dst),
381 "#IMPLICIT_DEF $dst",
382 [(set R8:$dst, (undef))]>;
383 def IMPLICIT_DEF_R16 : I<0, Pseudo, (ops R16:$dst),
384 "#IMPLICIT_DEF $dst",
385 [(set R16:$dst, (undef))]>;
386 def IMPLICIT_DEF_R32 : I<0, Pseudo, (ops R32:$dst),
387 "#IMPLICIT_DEF $dst",
388 [(set R32:$dst, (undef))]>;
389 def IMPLICIT_DEF_FR32 : I<0, Pseudo, (ops FR32:$dst),
390 "#IMPLICIT_DEF $dst",
391 [(set FR32:$dst, (undef))]>, Requires<[HasSSE2]>;
392 def IMPLICIT_DEF_FR64 : I<0, Pseudo, (ops FR64:$dst),
393 "#IMPLICIT_DEF $dst",
394 [(set FR64:$dst, (undef))]>, Requires<[HasSSE2]>;
397 // CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
398 // scheduler into a branch sequence.
399 let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
400 def CMOV_FR32 : I<0, Pseudo,
401 (ops FR32:$dst, FR32:$t, FR32:$f, i8imm:$cond),
403 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
405 def CMOV_FR64 : I<0, Pseudo,
406 (ops FR64:$dst, FR64:$t, FR64:$f, i8imm:$cond),
408 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
412 let isTerminator = 1 in
413 let Defs = [FP0, FP1, FP2, FP3, FP4, FP5, FP6] in
414 def FP_REG_KILL : I<0, Pseudo, (ops), "#FP_REG_KILL", []>;
418 def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
420 //===----------------------------------------------------------------------===//
421 // Control Flow Instructions...
424 // Return instructions.
425 let isTerminator = 1, isReturn = 1, isBarrier = 1,
426 hasCtrlDep = 1, noResults = 1 in {
427 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
428 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
429 [(X86retflag imm:$amt)]>;
432 // All branches are RawFrm, Void, Branch, and Terminators
433 let isBranch = 1, isTerminator = 1, noResults = 1 in
434 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
435 I<opcode, RawFrm, ops, asm, pattern>;
437 // Conditional branches
439 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
441 def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
442 [(X86brcond bb:$dst, X86_COND_E, STATUS)]>, Imp<[STATUS],[]>, TB;
443 def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
444 [(X86brcond bb:$dst, X86_COND_NE, STATUS)]>, Imp<[STATUS],[]>, TB;
445 def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
446 [(X86brcond bb:$dst, X86_COND_L, STATUS)]>, Imp<[STATUS],[]>, TB;
447 def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
448 [(X86brcond bb:$dst, X86_COND_LE, STATUS)]>, Imp<[STATUS],[]>, TB;
449 def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
450 [(X86brcond bb:$dst, X86_COND_G, STATUS)]>, Imp<[STATUS],[]>, TB;
451 def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
452 [(X86brcond bb:$dst, X86_COND_GE, STATUS)]>, Imp<[STATUS],[]>, TB;
454 def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
455 [(X86brcond bb:$dst, X86_COND_B, STATUS)]>, Imp<[STATUS],[]>, TB;
456 def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
457 [(X86brcond bb:$dst, X86_COND_BE, STATUS)]>, Imp<[STATUS],[]>, TB;
458 def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
459 [(X86brcond bb:$dst, X86_COND_A, STATUS)]>, Imp<[STATUS],[]>, TB;
460 def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
461 [(X86brcond bb:$dst, X86_COND_AE, STATUS)]>, Imp<[STATUS],[]>, TB;
463 def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
464 [(X86brcond bb:$dst, X86_COND_S, STATUS)]>, Imp<[STATUS],[]>, TB;
465 def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
466 [(X86brcond bb:$dst, X86_COND_NS, STATUS)]>, Imp<[STATUS],[]>, TB;
467 def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
468 [(X86brcond bb:$dst, X86_COND_P, STATUS)]>, Imp<[STATUS],[]>, TB;
469 def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
470 [(X86brcond bb:$dst, X86_COND_NP, STATUS)]>, Imp<[STATUS],[]>, TB;
471 def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
472 [(X86brcond bb:$dst, X86_COND_O, STATUS)]>, Imp<[STATUS],[]>, TB;
473 def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
474 [(X86brcond bb:$dst, X86_COND_NO, STATUS)]>, Imp<[STATUS],[]>, TB;
476 //===----------------------------------------------------------------------===//
477 // Call Instructions...
479 let isCall = 1, noResults = 1 in
480 // All calls clobber the non-callee saved registers...
481 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
482 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
483 def CALLpcrel32 : I<0xE8, RawFrm, (ops calltarget:$dst), "call $dst",
485 def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst",
486 [(X86call R32:$dst)]>;
487 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst), "call {*}$dst",
488 [(X86call (loadi32 addr:$dst))]>;
492 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
493 def TAILJMPd : IBr<0xE9, (ops calltarget:$dst), "jmp $dst # TAIL CALL", []>;
494 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
495 def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
496 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
497 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
498 "jmp {*}$dst # TAIL CALL", []>;
500 // ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
501 // way, except that it is marked as being a terminator. This causes the epilog
502 // inserter to insert reloads of callee saved registers BEFORE this. We need
503 // this until we have a more accurate way of tracking where the stack pointer is
504 // within a function.
505 let isTerminator = 1, isTwoAddress = 1 in
506 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
507 "add{l} {$src2, $dst|$dst, $src2}", []>;
509 //===----------------------------------------------------------------------===//
510 // Miscellaneous Instructions...
512 def LEAVE : I<0xC9, RawFrm,
513 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
514 def POP32r : I<0x58, AddRegFrm,
515 (ops R32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
517 let isTwoAddress = 1 in // R32 = bswap R32
518 def BSWAP32r : I<0xC8, AddRegFrm,
519 (ops R32:$dst, R32:$src), "bswap{l} $dst", []>, TB;
521 def XCHG8rr : I<0x86, MRMDestReg, // xchg R8, R8
522 (ops R8:$src1, R8:$src2),
523 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
524 def XCHG16rr : I<0x87, MRMDestReg, // xchg R16, R16
525 (ops R16:$src1, R16:$src2),
526 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
527 def XCHG32rr : I<0x87, MRMDestReg, // xchg R32, R32
528 (ops R32:$src1, R32:$src2),
529 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
531 def XCHG8mr : I<0x86, MRMDestMem,
532 (ops i8mem:$src1, R8:$src2),
533 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
534 def XCHG16mr : I<0x87, MRMDestMem,
535 (ops i16mem:$src1, R16:$src2),
536 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
537 def XCHG32mr : I<0x87, MRMDestMem,
538 (ops i32mem:$src1, R32:$src2),
539 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
540 def XCHG8rm : I<0x86, MRMSrcMem,
541 (ops R8:$src1, i8mem:$src2),
542 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
543 def XCHG16rm : I<0x87, MRMSrcMem,
544 (ops R16:$src1, i16mem:$src2),
545 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
546 def XCHG32rm : I<0x87, MRMSrcMem,
547 (ops R32:$src1, i32mem:$src2),
548 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
550 def LEA16r : I<0x8D, MRMSrcMem,
551 (ops R16:$dst, i32mem:$src),
552 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
553 def LEA32r : I<0x8D, MRMSrcMem,
554 (ops R32:$dst, i32mem:$src),
555 "lea{l} {$src|$dst}, {$dst|$src}",
556 [(set R32:$dst, leaaddr:$src)]>;
558 def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
560 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
561 def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
562 [(X86rep_movs i16)]>,
563 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
564 def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsd|rep movsd}",
565 [(X86rep_movs i32)]>,
566 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
568 def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
570 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
571 def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
572 [(X86rep_stos i16)]>,
573 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
574 def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
575 [(X86rep_stos i32)]>,
576 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
579 //===----------------------------------------------------------------------===//
580 // Input/Output Instructions...
582 def IN8rr : I<0xEC, RawFrm, (ops),
583 "in{b} {%dx, %al|%AL, %DX}",
584 [(set AL, (readport DX))]>, Imp<[DX], [AL]>;
585 def IN16rr : I<0xED, RawFrm, (ops),
586 "in{w} {%dx, %ax|%AX, %DX}",
587 [(set AX, (readport DX))]>, Imp<[DX], [AX]>, OpSize;
588 def IN32rr : I<0xED, RawFrm, (ops),
589 "in{l} {%dx, %eax|%EAX, %DX}",
590 [(set EAX, (readport DX))]>, Imp<[DX],[EAX]>;
592 def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
593 "in{b} {$port, %al|%AL, $port}",
594 [(set AL, (readport i16immZExt8:$port))]>,
596 def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
597 "in{w} {$port, %ax|%AX, $port}",
598 [(set AX, (readport i16immZExt8:$port))]>,
599 Imp<[], [AX]>, OpSize;
600 def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
601 "in{l} {$port, %eax|%EAX, $port}",
602 [(set EAX, (readport i16immZExt8:$port))]>,
605 def OUT8rr : I<0xEE, RawFrm, (ops),
606 "out{b} {%al, %dx|%DX, %AL}",
607 [(writeport AL, DX)]>, Imp<[DX, AL], []>;
608 def OUT16rr : I<0xEF, RawFrm, (ops),
609 "out{w} {%ax, %dx|%DX, %AX}",
610 [(writeport AX, DX)]>, Imp<[DX, AX], []>, OpSize;
611 def OUT32rr : I<0xEF, RawFrm, (ops),
612 "out{l} {%eax, %dx|%DX, %EAX}",
613 [(writeport EAX, DX)]>, Imp<[DX, EAX], []>;
615 def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
616 "out{b} {%al, $port|$port, %AL}",
617 [(writeport AL, i16immZExt8:$port)]>,
619 def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
620 "out{w} {%ax, $port|$port, %AX}",
621 [(writeport AX, i16immZExt8:$port)]>,
622 Imp<[AX], []>, OpSize;
623 def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
624 "out{l} {%eax, $port|$port, %EAX}",
625 [(writeport EAX, i16immZExt8:$port)]>,
628 //===----------------------------------------------------------------------===//
629 // Move Instructions...
631 def MOV8rr : I<0x88, MRMDestReg, (ops R8 :$dst, R8 :$src),
632 "mov{b} {$src, $dst|$dst, $src}", []>;
633 def MOV16rr : I<0x89, MRMDestReg, (ops R16:$dst, R16:$src),
634 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
635 def MOV32rr : I<0x89, MRMDestReg, (ops R32:$dst, R32:$src),
636 "mov{l} {$src, $dst|$dst, $src}", []>;
637 def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops R8 :$dst, i8imm :$src),
638 "mov{b} {$src, $dst|$dst, $src}",
639 [(set R8:$dst, imm:$src)]>;
640 def MOV16ri : Ii16<0xB8, AddRegFrm, (ops R16:$dst, i16imm:$src),
641 "mov{w} {$src, $dst|$dst, $src}",
642 [(set R16:$dst, imm:$src)]>, OpSize;
643 def MOV32ri : Ii32<0xB8, AddRegFrm, (ops R32:$dst, i32imm:$src),
644 "mov{l} {$src, $dst|$dst, $src}",
645 [(set R32:$dst, imm:$src)]>;
646 def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
647 "mov{b} {$src, $dst|$dst, $src}",
648 [(store (i8 imm:$src), addr:$dst)]>;
649 def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
650 "mov{w} {$src, $dst|$dst, $src}",
651 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
652 def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
653 "mov{l} {$src, $dst|$dst, $src}",
654 [(store (i32 imm:$src), addr:$dst)]>;
656 def MOV8rm : I<0x8A, MRMSrcMem, (ops R8 :$dst, i8mem :$src),
657 "mov{b} {$src, $dst|$dst, $src}",
658 [(set R8:$dst, (load addr:$src))]>;
659 def MOV16rm : I<0x8B, MRMSrcMem, (ops R16:$dst, i16mem:$src),
660 "mov{w} {$src, $dst|$dst, $src}",
661 [(set R16:$dst, (load addr:$src))]>, OpSize;
662 def MOV32rm : I<0x8B, MRMSrcMem, (ops R32:$dst, i32mem:$src),
663 "mov{l} {$src, $dst|$dst, $src}",
664 [(set R32:$dst, (load addr:$src))]>;
666 def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, R8 :$src),
667 "mov{b} {$src, $dst|$dst, $src}",
668 [(store R8:$src, addr:$dst)]>;
669 def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, R16:$src),
670 "mov{w} {$src, $dst|$dst, $src}",
671 [(store R16:$src, addr:$dst)]>, OpSize;
672 def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, R32:$src),
673 "mov{l} {$src, $dst|$dst, $src}",
674 [(store R32:$src, addr:$dst)]>;
676 //===----------------------------------------------------------------------===//
677 // Fixed-Register Multiplication and Division Instructions...
680 // Extra precision multiplication
681 def MUL8r : I<0xF6, MRM4r, (ops R8:$src), "mul{b} $src", []>,
682 Imp<[AL],[AX]>; // AL,AH = AL*R8
683 def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul{w} $src", []>,
684 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
685 def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul{l} $src", []>,
686 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
687 def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
688 "mul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
689 def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
690 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
691 OpSize; // AX,DX = AX*[mem16]
692 def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
693 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
695 def IMUL8r : I<0xF6, MRM5r, (ops R8:$src), "imul{b} $src", []>,
696 Imp<[AL],[AX]>; // AL,AH = AL*R8
697 def IMUL16r : I<0xF7, MRM5r, (ops R16:$src), "imul{w} $src", []>,
698 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
699 def IMUL32r : I<0xF7, MRM5r, (ops R32:$src), "imul{l} $src", []>,
700 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
701 def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
702 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
703 def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
704 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
705 OpSize; // AX,DX = AX*[mem16]
706 def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
708 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
710 // unsigned division/remainder
711 def DIV8r : I<0xF6, MRM6r, (ops R8:$src), // AX/r8 = AL,AH
712 "div{b} $src", []>, Imp<[AX],[AX]>;
713 def DIV16r : I<0xF7, MRM6r, (ops R16:$src), // DX:AX/r16 = AX,DX
714 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
715 def DIV32r : I<0xF7, MRM6r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
716 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
717 def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
718 "div{b} $src", []>, Imp<[AX],[AX]>;
719 def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
720 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
721 def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
722 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
724 // Signed division/remainder.
725 def IDIV8r : I<0xF6, MRM7r, (ops R8:$src), // AX/r8 = AL,AH
726 "idiv{b} $src", []>, Imp<[AX],[AX]>;
727 def IDIV16r: I<0xF7, MRM7r, (ops R16:$src), // DX:AX/r16 = AX,DX
728 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
729 def IDIV32r: I<0xF7, MRM7r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
730 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
731 def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
732 "idiv{b} $src", []>, Imp<[AX],[AX]>;
733 def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
734 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
735 def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
736 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
738 // Sign-extenders for division.
739 def CBW : I<0x98, RawFrm, (ops),
740 "{cbtw|cbw}", []>, Imp<[AL],[AH]>; // AX = signext(AL)
741 def CWD : I<0x99, RawFrm, (ops),
742 "{cwtd|cwd}", []>, Imp<[AX],[DX]>; // DX:AX = signext(AX)
743 def CDQ : I<0x99, RawFrm, (ops),
744 "{cltd|cdq}", []>, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
747 //===----------------------------------------------------------------------===//
748 // Two address Instructions...
750 let isTwoAddress = 1 in {
753 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, R16 = R16
754 (ops R16:$dst, R16:$src1, R16:$src2),
755 "cmovb {$src2, $dst|$dst, $src2}",
756 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
757 X86_COND_B, STATUS))]>,
758 Imp<[STATUS],[]>, TB, OpSize;
759 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, R16 = [mem16]
760 (ops R16:$dst, R16:$src1, i16mem:$src2),
761 "cmovb {$src2, $dst|$dst, $src2}",
762 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
763 X86_COND_B, STATUS))]>,
764 Imp<[STATUS],[]>, TB, OpSize;
765 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, R32 = R32
766 (ops R32:$dst, R32:$src1, R32:$src2),
767 "cmovb {$src2, $dst|$dst, $src2}",
768 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
769 X86_COND_B, STATUS))]>,
770 Imp<[STATUS],[]>, TB;
771 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, R32 = [mem32]
772 (ops R32:$dst, R32:$src1, i32mem:$src2),
773 "cmovb {$src2, $dst|$dst, $src2}",
774 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
775 X86_COND_B, STATUS))]>,
776 Imp<[STATUS],[]>, TB;
778 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, R16 = R16
779 (ops R16:$dst, R16:$src1, R16:$src2),
780 "cmovae {$src2, $dst|$dst, $src2}",
781 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
782 X86_COND_AE, STATUS))]>,
783 Imp<[STATUS],[]>, TB, OpSize;
784 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, R16 = [mem16]
785 (ops R16:$dst, R16:$src1, i16mem:$src2),
786 "cmovae {$src2, $dst|$dst, $src2}",
787 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
788 X86_COND_AE, STATUS))]>,
789 Imp<[STATUS],[]>, TB, OpSize;
790 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, R32 = R32
791 (ops R32:$dst, R32:$src1, R32:$src2),
792 "cmovae {$src2, $dst|$dst, $src2}",
793 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
794 X86_COND_AE, STATUS))]>,
795 Imp<[STATUS],[]>, TB;
796 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, R32 = [mem32]
797 (ops R32:$dst, R32:$src1, i32mem:$src2),
798 "cmovae {$src2, $dst|$dst, $src2}",
799 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
800 X86_COND_AE, STATUS))]>,
801 Imp<[STATUS],[]>, TB;
803 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, R16 = R16
804 (ops R16:$dst, R16:$src1, R16:$src2),
805 "cmove {$src2, $dst|$dst, $src2}",
806 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
807 X86_COND_E, STATUS))]>,
808 Imp<[STATUS],[]>, TB, OpSize;
809 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, R16 = [mem16]
810 (ops R16:$dst, R16:$src1, i16mem:$src2),
811 "cmove {$src2, $dst|$dst, $src2}",
812 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
813 X86_COND_E, STATUS))]>,
814 Imp<[STATUS],[]>, TB, OpSize;
815 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, R32 = R32
816 (ops R32:$dst, R32:$src1, R32:$src2),
817 "cmove {$src2, $dst|$dst, $src2}",
818 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
819 X86_COND_E, STATUS))]>,
820 Imp<[STATUS],[]>, TB;
821 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, R32 = [mem32]
822 (ops R32:$dst, R32:$src1, i32mem:$src2),
823 "cmove {$src2, $dst|$dst, $src2}",
824 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
825 X86_COND_E, STATUS))]>,
826 Imp<[STATUS],[]>, TB;
828 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, R16 = R16
829 (ops R16:$dst, R16:$src1, R16:$src2),
830 "cmovne {$src2, $dst|$dst, $src2}",
831 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
832 X86_COND_NE, STATUS))]>,
833 Imp<[STATUS],[]>, TB, OpSize;
834 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, R16 = [mem16]
835 (ops R16:$dst, R16:$src1, i16mem:$src2),
836 "cmovne {$src2, $dst|$dst, $src2}",
837 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
838 X86_COND_NE, STATUS))]>,
839 Imp<[STATUS],[]>, TB, OpSize;
840 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, R32 = R32
841 (ops R32:$dst, R32:$src1, R32:$src2),
842 "cmovne {$src2, $dst|$dst, $src2}",
843 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
844 X86_COND_NE, STATUS))]>,
845 Imp<[STATUS],[]>, TB;
846 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, R32 = [mem32]
847 (ops R32:$dst, R32:$src1, i32mem:$src2),
848 "cmovne {$src2, $dst|$dst, $src2}",
849 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
850 X86_COND_NE, STATUS))]>,
851 Imp<[STATUS],[]>, TB;
853 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, R16 = R16
854 (ops R16:$dst, R16:$src1, R16:$src2),
855 "cmovbe {$src2, $dst|$dst, $src2}",
856 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
857 X86_COND_BE, STATUS))]>,
858 Imp<[STATUS],[]>, TB, OpSize;
859 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, R16 = [mem16]
860 (ops R16:$dst, R16:$src1, i16mem:$src2),
861 "cmovbe {$src2, $dst|$dst, $src2}",
862 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
863 X86_COND_BE, STATUS))]>,
864 Imp<[STATUS],[]>, TB, OpSize;
865 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, R32 = R32
866 (ops R32:$dst, R32:$src1, R32:$src2),
867 "cmovbe {$src2, $dst|$dst, $src2}",
868 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
869 X86_COND_BE, STATUS))]>,
870 Imp<[STATUS],[]>, TB;
871 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, R32 = [mem32]
872 (ops R32:$dst, R32:$src1, i32mem:$src2),
873 "cmovbe {$src2, $dst|$dst, $src2}",
874 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
875 X86_COND_BE, STATUS))]>,
876 Imp<[STATUS],[]>, TB;
878 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, R16 = R16
879 (ops R16:$dst, R16:$src1, R16:$src2),
880 "cmova {$src2, $dst|$dst, $src2}",
881 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
882 X86_COND_A, STATUS))]>,
883 Imp<[STATUS],[]>, TB, OpSize;
884 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, R16 = [mem16]
885 (ops R16:$dst, R16:$src1, i16mem:$src2),
886 "cmova {$src2, $dst|$dst, $src2}",
887 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
888 X86_COND_A, STATUS))]>,
889 Imp<[STATUS],[]>, TB, OpSize;
890 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, R32 = R32
891 (ops R32:$dst, R32:$src1, R32:$src2),
892 "cmova {$src2, $dst|$dst, $src2}",
893 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
894 X86_COND_A, STATUS))]>,
895 Imp<[STATUS],[]>, TB;
896 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, R32 = [mem32]
897 (ops R32:$dst, R32:$src1, i32mem:$src2),
898 "cmova {$src2, $dst|$dst, $src2}",
899 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
900 X86_COND_A, STATUS))]>,
901 Imp<[STATUS],[]>, TB;
903 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, R16 = R16
904 (ops R16:$dst, R16:$src1, R16:$src2),
905 "cmovl {$src2, $dst|$dst, $src2}",
906 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
907 X86_COND_L, STATUS))]>,
908 Imp<[STATUS],[]>, TB, OpSize;
909 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, R16 = [mem16]
910 (ops R16:$dst, R16:$src1, i16mem:$src2),
911 "cmovl {$src2, $dst|$dst, $src2}",
912 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
913 X86_COND_L, STATUS))]>,
914 Imp<[STATUS],[]>, TB, OpSize;
915 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, R32 = R32
916 (ops R32:$dst, R32:$src1, R32:$src2),
917 "cmovl {$src2, $dst|$dst, $src2}",
918 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
919 X86_COND_L, STATUS))]>,
920 Imp<[STATUS],[]>, TB;
921 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, R32 = [mem32]
922 (ops R32:$dst, R32:$src1, i32mem:$src2),
923 "cmovl {$src2, $dst|$dst, $src2}",
924 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
925 X86_COND_L, STATUS))]>,
926 Imp<[STATUS],[]>, TB;
928 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, R16 = R16
929 (ops R16:$dst, R16:$src1, R16:$src2),
930 "cmovge {$src2, $dst|$dst, $src2}",
931 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
932 X86_COND_GE, STATUS))]>,
933 Imp<[STATUS],[]>, TB, OpSize;
934 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, R16 = [mem16]
935 (ops R16:$dst, R16:$src1, i16mem:$src2),
936 "cmovge {$src2, $dst|$dst, $src2}",
937 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
938 X86_COND_GE, STATUS))]>,
939 Imp<[STATUS],[]>, TB, OpSize;
940 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, R32 = R32
941 (ops R32:$dst, R32:$src1, R32:$src2),
942 "cmovge {$src2, $dst|$dst, $src2}",
943 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
944 X86_COND_GE, STATUS))]>,
945 Imp<[STATUS],[]>, TB;
946 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, R32 = [mem32]
947 (ops R32:$dst, R32:$src1, i32mem:$src2),
948 "cmovge {$src2, $dst|$dst, $src2}",
949 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
950 X86_COND_GE, STATUS))]>,
951 Imp<[STATUS],[]>, TB;
953 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, R16 = R16
954 (ops R16:$dst, R16:$src1, R16:$src2),
955 "cmovle {$src2, $dst|$dst, $src2}",
956 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
957 X86_COND_LE, STATUS))]>,
958 Imp<[STATUS],[]>, TB, OpSize;
959 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, R16 = [mem16]
960 (ops R16:$dst, R16:$src1, i16mem:$src2),
961 "cmovle {$src2, $dst|$dst, $src2}",
962 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
963 X86_COND_LE, STATUS))]>,
964 Imp<[STATUS],[]>, TB, OpSize;
965 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, R32 = R32
966 (ops R32:$dst, R32:$src1, R32:$src2),
967 "cmovle {$src2, $dst|$dst, $src2}",
968 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
969 X86_COND_LE, STATUS))]>,
970 Imp<[STATUS],[]>, TB;
971 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, R32 = [mem32]
972 (ops R32:$dst, R32:$src1, i32mem:$src2),
973 "cmovle {$src2, $dst|$dst, $src2}",
974 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
975 X86_COND_LE, STATUS))]>,
976 Imp<[STATUS],[]>, TB;
978 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, R16 = R16
979 (ops R16:$dst, R16:$src1, R16:$src2),
980 "cmovg {$src2, $dst|$dst, $src2}",
981 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
982 X86_COND_G, STATUS))]>,
983 Imp<[STATUS],[]>, TB, OpSize;
984 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, R16 = [mem16]
985 (ops R16:$dst, R16:$src1, i16mem:$src2),
986 "cmovg {$src2, $dst|$dst, $src2}",
987 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
988 X86_COND_G, STATUS))]>,
989 Imp<[STATUS],[]>, TB, OpSize;
990 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, R32 = R32
991 (ops R32:$dst, R32:$src1, R32:$src2),
992 "cmovg {$src2, $dst|$dst, $src2}",
993 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
994 X86_COND_G, STATUS))]>,
995 Imp<[STATUS],[]>, TB;
996 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, R32 = [mem32]
997 (ops R32:$dst, R32:$src1, i32mem:$src2),
998 "cmovg {$src2, $dst|$dst, $src2}",
999 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1000 X86_COND_G, STATUS))]>,
1001 Imp<[STATUS],[]>, TB;
1003 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, R16 = R16
1004 (ops R16:$dst, R16:$src1, R16:$src2),
1005 "cmovs {$src2, $dst|$dst, $src2}",
1006 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1007 X86_COND_S, STATUS))]>,
1008 Imp<[STATUS],[]>, TB, OpSize;
1009 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, R16 = [mem16]
1010 (ops R16:$dst, R16:$src1, i16mem:$src2),
1011 "cmovs {$src2, $dst|$dst, $src2}",
1012 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1013 X86_COND_S, STATUS))]>,
1014 Imp<[STATUS],[]>, TB, OpSize;
1015 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, R32 = R32
1016 (ops R32:$dst, R32:$src1, R32:$src2),
1017 "cmovs {$src2, $dst|$dst, $src2}",
1018 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1019 X86_COND_S, STATUS))]>,
1020 Imp<[STATUS],[]>, TB;
1021 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, R32 = [mem32]
1022 (ops R32:$dst, R32:$src1, i32mem:$src2),
1023 "cmovs {$src2, $dst|$dst, $src2}",
1024 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1025 X86_COND_S, STATUS))]>,
1026 Imp<[STATUS],[]>, TB;
1028 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, R16 = R16
1029 (ops R16:$dst, R16:$src1, R16:$src2),
1030 "cmovns {$src2, $dst|$dst, $src2}",
1031 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1032 X86_COND_NS, STATUS))]>,
1033 Imp<[STATUS],[]>, TB, OpSize;
1034 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, R16 = [mem16]
1035 (ops R16:$dst, R16:$src1, i16mem:$src2),
1036 "cmovns {$src2, $dst|$dst, $src2}",
1037 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1038 X86_COND_NS, STATUS))]>,
1039 Imp<[STATUS],[]>, TB, OpSize;
1040 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, R32 = R32
1041 (ops R32:$dst, R32:$src1, R32:$src2),
1042 "cmovns {$src2, $dst|$dst, $src2}",
1043 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1044 X86_COND_NS, STATUS))]>,
1045 Imp<[STATUS],[]>, TB;
1046 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, R32 = [mem32]
1047 (ops R32:$dst, R32:$src1, i32mem:$src2),
1048 "cmovns {$src2, $dst|$dst, $src2}",
1049 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1050 X86_COND_NS, STATUS))]>,
1051 Imp<[STATUS],[]>, TB;
1053 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, R16 = R16
1054 (ops R16:$dst, R16:$src1, R16:$src2),
1055 "cmovp {$src2, $dst|$dst, $src2}",
1056 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1057 X86_COND_P, STATUS))]>,
1058 Imp<[STATUS],[]>, TB, OpSize;
1059 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, R16 = [mem16]
1060 (ops R16:$dst, R16:$src1, i16mem:$src2),
1061 "cmovp {$src2, $dst|$dst, $src2}",
1062 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1063 X86_COND_P, STATUS))]>,
1064 Imp<[STATUS],[]>, TB, OpSize;
1065 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, R32 = R32
1066 (ops R32:$dst, R32:$src1, R32:$src2),
1067 "cmovp {$src2, $dst|$dst, $src2}",
1068 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1069 X86_COND_P, STATUS))]>,
1070 Imp<[STATUS],[]>, TB;
1071 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, R32 = [mem32]
1072 (ops R32:$dst, R32:$src1, i32mem:$src2),
1073 "cmovp {$src2, $dst|$dst, $src2}",
1074 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1075 X86_COND_P, STATUS))]>,
1076 Imp<[STATUS],[]>, TB;
1078 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, R16 = R16
1079 (ops R16:$dst, R16:$src1, R16:$src2),
1080 "cmovnp {$src2, $dst|$dst, $src2}",
1081 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1082 X86_COND_NP, STATUS))]>,
1083 Imp<[STATUS],[]>, TB, OpSize;
1084 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, R16 = [mem16]
1085 (ops R16:$dst, R16:$src1, i16mem:$src2),
1086 "cmovnp {$src2, $dst|$dst, $src2}",
1087 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1088 X86_COND_NP, STATUS))]>,
1089 Imp<[STATUS],[]>, TB, OpSize;
1090 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, R32 = R32
1091 (ops R32:$dst, R32:$src1, R32:$src2),
1092 "cmovnp {$src2, $dst|$dst, $src2}",
1093 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1094 X86_COND_NP, STATUS))]>,
1095 Imp<[STATUS],[]>, TB;
1096 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, R32 = [mem32]
1097 (ops R32:$dst, R32:$src1, i32mem:$src2),
1098 "cmovnp {$src2, $dst|$dst, $src2}",
1099 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1100 X86_COND_NP, STATUS))]>,
1101 Imp<[STATUS],[]>, TB;
1104 // unary instructions
1105 def NEG8r : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg{b} $dst",
1106 [(set R8:$dst, (ineg R8:$src))]>;
1107 def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg{w} $dst",
1108 [(set R16:$dst, (ineg R16:$src))]>, OpSize;
1109 def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg{l} $dst",
1110 [(set R32:$dst, (ineg R32:$src))]>;
1111 let isTwoAddress = 0 in {
1112 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
1113 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1114 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
1115 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1116 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
1117 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1121 def NOT8r : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not{b} $dst",
1122 [(set R8:$dst, (not R8:$src))]>;
1123 def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not{w} $dst",
1124 [(set R16:$dst, (not R16:$src))]>, OpSize;
1125 def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not{l} $dst",
1126 [(set R32:$dst, (not R32:$src))]>;
1127 let isTwoAddress = 0 in {
1128 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
1129 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1130 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
1131 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1132 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
1133 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1136 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1137 def INC8r : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc{b} $dst",
1138 [(set R8:$dst, (add R8:$src, 1))]>;
1139 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1140 def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc{w} $dst",
1141 [(set R16:$dst, (add R16:$src, 1))]>, OpSize;
1142 def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc{l} $dst",
1143 [(set R32:$dst, (add R32:$src, 1))]>;
1145 let isTwoAddress = 0 in {
1146 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
1147 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1148 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
1149 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
1150 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
1151 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1154 def DEC8r : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec{b} $dst",
1155 [(set R8:$dst, (add R8:$src, -1))]>;
1156 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1157 def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec{w} $dst",
1158 [(set R16:$dst, (add R16:$src, -1))]>, OpSize;
1159 def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec{l} $dst",
1160 [(set R32:$dst, (add R32:$src, -1))]>;
1163 let isTwoAddress = 0 in {
1164 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
1165 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1166 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
1167 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
1168 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
1169 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1172 // Logical operators...
1173 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1174 def AND8rr : I<0x20, MRMDestReg,
1175 (ops R8 :$dst, R8 :$src1, R8 :$src2),
1176 "and{b} {$src2, $dst|$dst, $src2}",
1177 [(set R8:$dst, (and R8:$src1, R8:$src2))]>;
1178 def AND16rr : I<0x21, MRMDestReg,
1179 (ops R16:$dst, R16:$src1, R16:$src2),
1180 "and{w} {$src2, $dst|$dst, $src2}",
1181 [(set R16:$dst, (and R16:$src1, R16:$src2))]>, OpSize;
1182 def AND32rr : I<0x21, MRMDestReg,
1183 (ops R32:$dst, R32:$src1, R32:$src2),
1184 "and{l} {$src2, $dst|$dst, $src2}",
1185 [(set R32:$dst, (and R32:$src1, R32:$src2))]>;
1188 def AND8rm : I<0x22, MRMSrcMem,
1189 (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1190 "and{b} {$src2, $dst|$dst, $src2}",
1191 [(set R8:$dst, (and R8:$src1, (load addr:$src2)))]>;
1192 def AND16rm : I<0x23, MRMSrcMem,
1193 (ops R16:$dst, R16:$src1, i16mem:$src2),
1194 "and{w} {$src2, $dst|$dst, $src2}",
1195 [(set R16:$dst, (and R16:$src1, (load addr:$src2)))]>, OpSize;
1196 def AND32rm : I<0x23, MRMSrcMem,
1197 (ops R32:$dst, R32:$src1, i32mem:$src2),
1198 "and{l} {$src2, $dst|$dst, $src2}",
1199 [(set R32:$dst, (and R32:$src1, (load addr:$src2)))]>;
1201 def AND8ri : Ii8<0x80, MRM4r,
1202 (ops R8 :$dst, R8 :$src1, i8imm :$src2),
1203 "and{b} {$src2, $dst|$dst, $src2}",
1204 [(set R8:$dst, (and R8:$src1, imm:$src2))]>;
1205 def AND16ri : Ii16<0x81, MRM4r,
1206 (ops R16:$dst, R16:$src1, i16imm:$src2),
1207 "and{w} {$src2, $dst|$dst, $src2}",
1208 [(set R16:$dst, (and R16:$src1, imm:$src2))]>, OpSize;
1209 def AND32ri : Ii32<0x81, MRM4r,
1210 (ops R32:$dst, R32:$src1, i32imm:$src2),
1211 "and{l} {$src2, $dst|$dst, $src2}",
1212 [(set R32:$dst, (and R32:$src1, imm:$src2))]>;
1213 def AND16ri8 : Ii8<0x83, MRM4r,
1214 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1215 "and{w} {$src2, $dst|$dst, $src2}",
1216 [(set R16:$dst, (and R16:$src1, i16immSExt8:$src2))]>,
1218 def AND32ri8 : Ii8<0x83, MRM4r,
1219 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1220 "and{l} {$src2, $dst|$dst, $src2}",
1221 [(set R32:$dst, (and R32:$src1, i32immSExt8:$src2))]>;
1223 let isTwoAddress = 0 in {
1224 def AND8mr : I<0x20, MRMDestMem,
1225 (ops i8mem :$dst, R8 :$src),
1226 "and{b} {$src, $dst|$dst, $src}",
1227 [(store (and (load addr:$dst), R8:$src), addr:$dst)]>;
1228 def AND16mr : I<0x21, MRMDestMem,
1229 (ops i16mem:$dst, R16:$src),
1230 "and{w} {$src, $dst|$dst, $src}",
1231 [(store (and (load addr:$dst), R16:$src), addr:$dst)]>,
1233 def AND32mr : I<0x21, MRMDestMem,
1234 (ops i32mem:$dst, R32:$src),
1235 "and{l} {$src, $dst|$dst, $src}",
1236 [(store (and (load addr:$dst), R32:$src), addr:$dst)]>;
1237 def AND8mi : Ii8<0x80, MRM4m,
1238 (ops i8mem :$dst, i8imm :$src),
1239 "and{b} {$src, $dst|$dst, $src}",
1240 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1241 def AND16mi : Ii16<0x81, MRM4m,
1242 (ops i16mem:$dst, i16imm:$src),
1243 "and{w} {$src, $dst|$dst, $src}",
1244 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1246 def AND32mi : Ii32<0x81, MRM4m,
1247 (ops i32mem:$dst, i32imm:$src),
1248 "and{l} {$src, $dst|$dst, $src}",
1249 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1250 def AND16mi8 : Ii8<0x83, MRM4m,
1251 (ops i16mem:$dst, i16i8imm :$src),
1252 "and{w} {$src, $dst|$dst, $src}",
1253 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1255 def AND32mi8 : Ii8<0x83, MRM4m,
1256 (ops i32mem:$dst, i32i8imm :$src),
1257 "and{l} {$src, $dst|$dst, $src}",
1258 [(store (add (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1262 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1263 def OR8rr : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1264 "or{b} {$src2, $dst|$dst, $src2}",
1265 [(set R8:$dst, (or R8:$src1, R8:$src2))]>;
1266 def OR16rr : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1267 "or{w} {$src2, $dst|$dst, $src2}",
1268 [(set R16:$dst, (or R16:$src1, R16:$src2))]>, OpSize;
1269 def OR32rr : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1270 "or{l} {$src2, $dst|$dst, $src2}",
1271 [(set R32:$dst, (or R32:$src1, R32:$src2))]>;
1273 def OR8rm : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1274 "or{b} {$src2, $dst|$dst, $src2}",
1275 [(set R8:$dst, (or R8:$src1, (load addr:$src2)))]>;
1276 def OR16rm : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
1277 "or{w} {$src2, $dst|$dst, $src2}",
1278 [(set R16:$dst, (or R16:$src1, (load addr:$src2)))]>, OpSize;
1279 def OR32rm : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
1280 "or{l} {$src2, $dst|$dst, $src2}",
1281 [(set R32:$dst, (or R32:$src1, (load addr:$src2)))]>;
1283 def OR8ri : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1284 "or{b} {$src2, $dst|$dst, $src2}",
1285 [(set R8:$dst, (or R8:$src1, imm:$src2))]>;
1286 def OR16ri : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1287 "or{w} {$src2, $dst|$dst, $src2}",
1288 [(set R16:$dst, (or R16:$src1, imm:$src2))]>, OpSize;
1289 def OR32ri : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1290 "or{l} {$src2, $dst|$dst, $src2}",
1291 [(set R32:$dst, (or R32:$src1, imm:$src2))]>;
1293 def OR16ri8 : Ii8<0x83, MRM1r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1294 "or{w} {$src2, $dst|$dst, $src2}",
1295 [(set R16:$dst, (or R16:$src1, i16immSExt8:$src2))]>, OpSize;
1296 def OR32ri8 : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1297 "or{l} {$src2, $dst|$dst, $src2}",
1298 [(set R32:$dst, (or R32:$src1, i32immSExt8:$src2))]>;
1299 let isTwoAddress = 0 in {
1300 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
1301 "or{b} {$src, $dst|$dst, $src}",
1302 [(store (or (load addr:$dst), R8:$src), addr:$dst)]>;
1303 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
1304 "or{w} {$src, $dst|$dst, $src}",
1305 [(store (or (load addr:$dst), R16:$src), addr:$dst)]>, OpSize;
1306 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
1307 "or{l} {$src, $dst|$dst, $src}",
1308 [(store (or (load addr:$dst), R32:$src), addr:$dst)]>;
1309 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
1310 "or{b} {$src, $dst|$dst, $src}",
1311 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1312 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
1313 "or{w} {$src, $dst|$dst, $src}",
1314 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1316 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
1317 "or{l} {$src, $dst|$dst, $src}",
1318 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1319 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1320 "or{w} {$src, $dst|$dst, $src}",
1321 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1323 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1324 "or{l} {$src, $dst|$dst, $src}",
1325 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1329 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1330 def XOR8rr : I<0x30, MRMDestReg,
1331 (ops R8 :$dst, R8 :$src1, R8 :$src2),
1332 "xor{b} {$src2, $dst|$dst, $src2}",
1333 [(set R8:$dst, (xor R8:$src1, R8:$src2))]>;
1334 def XOR16rr : I<0x31, MRMDestReg,
1335 (ops R16:$dst, R16:$src1, R16:$src2),
1336 "xor{w} {$src2, $dst|$dst, $src2}",
1337 [(set R16:$dst, (xor R16:$src1, R16:$src2))]>, OpSize;
1338 def XOR32rr : I<0x31, MRMDestReg,
1339 (ops R32:$dst, R32:$src1, R32:$src2),
1340 "xor{l} {$src2, $dst|$dst, $src2}",
1341 [(set R32:$dst, (xor R32:$src1, R32:$src2))]>;
1344 def XOR8rm : I<0x32, MRMSrcMem ,
1345 (ops R8 :$dst, R8:$src1, i8mem :$src2),
1346 "xor{b} {$src2, $dst|$dst, $src2}",
1347 [(set R8:$dst, (xor R8:$src1, (load addr:$src2)))]>;
1348 def XOR16rm : I<0x33, MRMSrcMem ,
1349 (ops R16:$dst, R16:$src1, i16mem:$src2),
1350 "xor{w} {$src2, $dst|$dst, $src2}",
1351 [(set R16:$dst, (xor R16:$src1, (load addr:$src2)))]>, OpSize;
1352 def XOR32rm : I<0x33, MRMSrcMem ,
1353 (ops R32:$dst, R32:$src1, i32mem:$src2),
1354 "xor{l} {$src2, $dst|$dst, $src2}",
1355 [(set R32:$dst, (xor R32:$src1, (load addr:$src2)))]>;
1357 def XOR8ri : Ii8<0x80, MRM6r,
1358 (ops R8:$dst, R8:$src1, i8imm:$src2),
1359 "xor{b} {$src2, $dst|$dst, $src2}",
1360 [(set R8:$dst, (xor R8:$src1, imm:$src2))]>;
1361 def XOR16ri : Ii16<0x81, MRM6r,
1362 (ops R16:$dst, R16:$src1, i16imm:$src2),
1363 "xor{w} {$src2, $dst|$dst, $src2}",
1364 [(set R16:$dst, (xor R16:$src1, imm:$src2))]>, OpSize;
1365 def XOR32ri : Ii32<0x81, MRM6r,
1366 (ops R32:$dst, R32:$src1, i32imm:$src2),
1367 "xor{l} {$src2, $dst|$dst, $src2}",
1368 [(set R32:$dst, (xor R32:$src1, imm:$src2))]>;
1369 def XOR16ri8 : Ii8<0x83, MRM6r,
1370 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1371 "xor{w} {$src2, $dst|$dst, $src2}",
1372 [(set R16:$dst, (xor R16:$src1, i16immSExt8:$src2))]>,
1374 def XOR32ri8 : Ii8<0x83, MRM6r,
1375 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1376 "xor{l} {$src2, $dst|$dst, $src2}",
1377 [(set R32:$dst, (xor R32:$src1, i32immSExt8:$src2))]>;
1378 let isTwoAddress = 0 in {
1379 def XOR8mr : I<0x30, MRMDestMem,
1380 (ops i8mem :$dst, R8 :$src),
1381 "xor{b} {$src, $dst|$dst, $src}",
1382 [(store (xor (load addr:$dst), R8:$src), addr:$dst)]>;
1383 def XOR16mr : I<0x31, MRMDestMem,
1384 (ops i16mem:$dst, R16:$src),
1385 "xor{w} {$src, $dst|$dst, $src}",
1386 [(store (xor (load addr:$dst), R16:$src), addr:$dst)]>,
1388 def XOR32mr : I<0x31, MRMDestMem,
1389 (ops i32mem:$dst, R32:$src),
1390 "xor{l} {$src, $dst|$dst, $src}",
1391 [(store (xor (load addr:$dst), R32:$src), addr:$dst)]>;
1392 def XOR8mi : Ii8<0x80, MRM6m,
1393 (ops i8mem :$dst, i8imm :$src),
1394 "xor{b} {$src, $dst|$dst, $src}",
1395 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1396 def XOR16mi : Ii16<0x81, MRM6m,
1397 (ops i16mem:$dst, i16imm:$src),
1398 "xor{w} {$src, $dst|$dst, $src}",
1399 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1401 def XOR32mi : Ii32<0x81, MRM6m,
1402 (ops i32mem:$dst, i32imm:$src),
1403 "xor{l} {$src, $dst|$dst, $src}",
1404 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1405 def XOR16mi8 : Ii8<0x83, MRM6m,
1406 (ops i16mem:$dst, i16i8imm :$src),
1407 "xor{w} {$src, $dst|$dst, $src}",
1408 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1410 def XOR32mi8 : Ii8<0x83, MRM6m,
1411 (ops i32mem:$dst, i32i8imm :$src),
1412 "xor{l} {$src, $dst|$dst, $src}",
1413 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1416 // Shift instructions
1417 def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
1418 "shl{b} {%cl, $dst|$dst, %CL}",
1419 [(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
1420 def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src),
1421 "shl{w} {%cl, $dst|$dst, %CL}",
1422 [(set R16:$dst, (shl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1423 def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src),
1424 "shl{l} {%cl, $dst|$dst, %CL}",
1425 [(set R32:$dst, (shl R32:$src, CL))]>, Imp<[CL],[]>;
1427 def SHL8ri : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1428 "shl{b} {$src2, $dst|$dst, $src2}",
1429 [(set R8:$dst, (shl R8:$src1, (i8 imm:$src2)))]>;
1430 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1431 def SHL16ri : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1432 "shl{w} {$src2, $dst|$dst, $src2}",
1433 [(set R16:$dst, (shl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1434 def SHL32ri : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1435 "shl{l} {$src2, $dst|$dst, $src2}",
1436 [(set R32:$dst, (shl R32:$src1, (i8 imm:$src2)))]>;
1439 let isTwoAddress = 0 in {
1440 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
1441 "shl{b} {%cl, $dst|$dst, %CL}",
1442 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1444 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
1445 "shl{w} {%cl, $dst|$dst, %CL}",
1446 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1447 Imp<[CL],[]>, OpSize;
1448 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
1449 "shl{l} {%cl, $dst|$dst, %CL}",
1450 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1452 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
1453 "shl{b} {$src, $dst|$dst, $src}",
1454 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1455 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
1456 "shl{w} {$src, $dst|$dst, $src}",
1457 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1459 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
1460 "shl{l} {$src, $dst|$dst, $src}",
1461 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1464 def SHR8rCL : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src),
1465 "shr{b} {%cl, $dst|$dst, %CL}",
1466 [(set R8:$dst, (srl R8:$src, CL))]>, Imp<[CL],[]>;
1467 def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src),
1468 "shr{w} {%cl, $dst|$dst, %CL}",
1469 [(set R16:$dst, (srl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1470 def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src),
1471 "shr{l} {%cl, $dst|$dst, %CL}",
1472 [(set R32:$dst, (srl R32:$src, CL))]>, Imp<[CL],[]>;
1474 def SHR8ri : Ii8<0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1475 "shr{b} {$src2, $dst|$dst, $src2}",
1476 [(set R8:$dst, (srl R8:$src1, (i8 imm:$src2)))]>;
1477 def SHR16ri : Ii8<0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1478 "shr{w} {$src2, $dst|$dst, $src2}",
1479 [(set R16:$dst, (srl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1480 def SHR32ri : Ii8<0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1481 "shr{l} {$src2, $dst|$dst, $src2}",
1482 [(set R32:$dst, (srl R32:$src1, (i8 imm:$src2)))]>;
1484 let isTwoAddress = 0 in {
1485 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
1486 "shr{b} {%cl, $dst|$dst, %CL}",
1487 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1489 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
1490 "shr{w} {%cl, $dst|$dst, %CL}",
1491 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1492 Imp<[CL],[]>, OpSize;
1493 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
1494 "shr{l} {%cl, $dst|$dst, %CL}",
1495 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1497 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
1498 "shr{b} {$src, $dst|$dst, $src}",
1499 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1500 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
1501 "shr{w} {$src, $dst|$dst, $src}",
1502 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1504 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
1505 "shr{l} {$src, $dst|$dst, $src}",
1506 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1509 def SAR8rCL : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src),
1510 "sar{b} {%cl, $dst|$dst, %CL}",
1511 [(set R8:$dst, (sra R8:$src, CL))]>, Imp<[CL],[]>;
1512 def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src),
1513 "sar{w} {%cl, $dst|$dst, %CL}",
1514 [(set R16:$dst, (sra R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1515 def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src),
1516 "sar{l} {%cl, $dst|$dst, %CL}",
1517 [(set R32:$dst, (sra R32:$src, CL))]>, Imp<[CL],[]>;
1519 def SAR8ri : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1520 "sar{b} {$src2, $dst|$dst, $src2}",
1521 [(set R8:$dst, (sra R8:$src1, (i8 imm:$src2)))]>;
1522 def SAR16ri : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1523 "sar{w} {$src2, $dst|$dst, $src2}",
1524 [(set R16:$dst, (sra R16:$src1, (i8 imm:$src2)))]>,
1526 def SAR32ri : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1527 "sar{l} {$src2, $dst|$dst, $src2}",
1528 [(set R32:$dst, (sra R32:$src1, (i8 imm:$src2)))]>;
1529 let isTwoAddress = 0 in {
1530 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
1531 "sar{b} {%cl, $dst|$dst, %CL}",
1532 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1534 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
1535 "sar{w} {%cl, $dst|$dst, %CL}",
1536 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1537 Imp<[CL],[]>, OpSize;
1538 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
1539 "sar{l} {%cl, $dst|$dst, %CL}",
1540 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1542 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
1543 "sar{b} {$src, $dst|$dst, $src}",
1544 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1545 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
1546 "sar{w} {$src, $dst|$dst, $src}",
1547 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1549 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
1550 "sar{l} {$src, $dst|$dst, $src}",
1551 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1554 // Rotate instructions
1555 // FIXME: provide shorter instructions when imm8 == 1
1556 def ROL8rCL : I<0xD2, MRM0r, (ops R8 :$dst, R8 :$src),
1557 "rol{b} {%cl, $dst|$dst, %CL}",
1558 [(set R8:$dst, (rotl R8:$src, CL))]>, Imp<[CL],[]>;
1559 def ROL16rCL : I<0xD3, MRM0r, (ops R16:$dst, R16:$src),
1560 "rol{w} {%cl, $dst|$dst, %CL}",
1561 [(set R16:$dst, (rotl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1562 def ROL32rCL : I<0xD3, MRM0r, (ops R32:$dst, R32:$src),
1563 "rol{l} {%cl, $dst|$dst, %CL}",
1564 [(set R32:$dst, (rotl R32:$src, CL))]>, Imp<[CL],[]>;
1566 def ROL8ri : Ii8<0xC0, MRM0r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1567 "rol{b} {$src2, $dst|$dst, $src2}",
1568 [(set R8:$dst, (rotl R8:$src1, (i8 imm:$src2)))]>;
1569 def ROL16ri : Ii8<0xC1, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1570 "rol{w} {$src2, $dst|$dst, $src2}",
1571 [(set R16:$dst, (rotl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1572 def ROL32ri : Ii8<0xC1, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1573 "rol{l} {$src2, $dst|$dst, $src2}",
1574 [(set R32:$dst, (rotl R32:$src1, (i8 imm:$src2)))]>;
1576 let isTwoAddress = 0 in {
1577 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
1578 "rol{b} {%cl, $dst|$dst, %CL}",
1579 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1581 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
1582 "rol{w} {%cl, $dst|$dst, %CL}",
1583 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1584 Imp<[CL],[]>, OpSize;
1585 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
1586 "rol{l} {%cl, $dst|$dst, %CL}",
1587 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1589 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
1590 "rol{b} {$src, $dst|$dst, $src}",
1591 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1592 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
1593 "rol{w} {$src, $dst|$dst, $src}",
1594 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1596 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
1597 "rol{l} {$src, $dst|$dst, $src}",
1598 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1601 def ROR8rCL : I<0xD2, MRM1r, (ops R8 :$dst, R8 :$src),
1602 "ror{b} {%cl, $dst|$dst, %CL}",
1603 [(set R8:$dst, (rotr R8:$src, CL))]>, Imp<[CL],[]>;
1604 def ROR16rCL : I<0xD3, MRM1r, (ops R16:$dst, R16:$src),
1605 "ror{w} {%cl, $dst|$dst, %CL}",
1606 [(set R16:$dst, (rotr R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1607 def ROR32rCL : I<0xD3, MRM1r, (ops R32:$dst, R32:$src),
1608 "ror{l} {%cl, $dst|$dst, %CL}",
1609 [(set R32:$dst, (rotr R32:$src, CL))]>, Imp<[CL],[]>;
1611 def ROR8ri : Ii8<0xC0, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1612 "ror{b} {$src2, $dst|$dst, $src2}",
1613 [(set R8:$dst, (rotr R8:$src1, (i8 imm:$src2)))]>;
1614 def ROR16ri : Ii8<0xC1, MRM1r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1615 "ror{w} {$src2, $dst|$dst, $src2}",
1616 [(set R16:$dst, (rotr R16:$src1, (i8 imm:$src2)))]>, OpSize;
1617 def ROR32ri : Ii8<0xC1, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1618 "ror{l} {$src2, $dst|$dst, $src2}",
1619 [(set R32:$dst, (rotr R32:$src1, (i8 imm:$src2)))]>;
1620 let isTwoAddress = 0 in {
1621 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
1622 "ror{b} {%cl, $dst|$dst, %CL}",
1623 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1625 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
1626 "ror{w} {%cl, $dst|$dst, %CL}",
1627 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1628 Imp<[CL],[]>, OpSize;
1629 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
1630 "ror{l} {%cl, $dst|$dst, %CL}",
1631 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1633 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
1634 "ror{b} {$src, $dst|$dst, $src}",
1635 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1636 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
1637 "ror{w} {$src, $dst|$dst, $src}",
1638 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1640 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
1641 "ror{l} {$src, $dst|$dst, $src}",
1642 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1647 // Double shift instructions (generalizations of rotate)
1649 def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1650 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1651 [(set R32:$dst, (X86shld R32:$src1, R32:$src2, CL))]>,
1653 def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1654 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1655 [(set R32:$dst, (X86shrd R32:$src1, R32:$src2, CL))]>,
1657 def SHLD16rrCL : I<0xA5, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1658 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1659 [(set R16:$dst, (X86shld R16:$src1, R16:$src2, CL))]>,
1660 Imp<[CL],[]>, TB, OpSize;
1661 def SHRD16rrCL : I<0xAD, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1662 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1663 [(set R16:$dst, (X86shrd R16:$src1, R16:$src2, CL))]>,
1664 Imp<[CL],[]>, TB, OpSize;
1666 let isCommutable = 1 in { // These instructions commute to each other.
1667 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1668 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
1669 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1670 [(set R32:$dst, (X86shld R32:$src1, R32:$src2,
1673 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1674 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
1675 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1676 [(set R32:$dst, (X86shrd R32:$src1, R32:$src2,
1679 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1680 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
1681 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1682 [(set R16:$dst, (X86shld R16:$src1, R16:$src2,
1685 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1686 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
1687 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1688 [(set R16:$dst, (X86shrd R16:$src1, R16:$src2,
1693 let isTwoAddress = 0 in {
1694 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1695 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1696 [(store (X86shld (loadi32 addr:$dst), R32:$src2, CL),
1699 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1700 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1701 [(store (X86shrd (loadi32 addr:$dst), R32:$src2, CL),
1704 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1705 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
1706 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1707 [(store (X86shld (loadi32 addr:$dst), R32:$src2,
1708 (i8 imm:$src3)), addr:$dst)]>,
1710 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1711 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
1712 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1713 [(store (X86shrd (loadi32 addr:$dst), R32:$src2,
1714 (i8 imm:$src3)), addr:$dst)]>,
1717 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1718 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1719 [(store (X86shld (loadi16 addr:$dst), R16:$src2, CL),
1721 Imp<[CL],[]>, TB, OpSize;
1722 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1723 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1724 [(store (X86shrd (loadi16 addr:$dst), R16:$src2, CL),
1726 Imp<[CL],[]>, TB, OpSize;
1727 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1728 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
1729 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1730 [(store (X86shld (loadi16 addr:$dst), R16:$src2,
1731 (i8 imm:$src3)), addr:$dst)]>,
1733 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1734 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
1735 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1736 [(store (X86shrd (loadi16 addr:$dst), R16:$src2,
1737 (i8 imm:$src3)), addr:$dst)]>,
1743 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1744 def ADD8rr : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1745 "add{b} {$src2, $dst|$dst, $src2}",
1746 [(set R8:$dst, (add R8:$src1, R8:$src2))]>;
1747 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1748 def ADD16rr : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1749 "add{w} {$src2, $dst|$dst, $src2}",
1750 [(set R16:$dst, (add R16:$src1, R16:$src2))]>, OpSize;
1751 def ADD32rr : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1752 "add{l} {$src2, $dst|$dst, $src2}",
1753 [(set R32:$dst, (add R32:$src1, R32:$src2))]>;
1754 } // end isConvertibleToThreeAddress
1755 } // end isCommutable
1756 def ADD8rm : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1757 "add{b} {$src2, $dst|$dst, $src2}",
1758 [(set R8:$dst, (add R8:$src1, (load addr:$src2)))]>;
1759 def ADD16rm : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1760 "add{w} {$src2, $dst|$dst, $src2}",
1761 [(set R16:$dst, (add R16:$src1, (load addr:$src2)))]>, OpSize;
1762 def ADD32rm : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1763 "add{l} {$src2, $dst|$dst, $src2}",
1764 [(set R32:$dst, (add R32:$src1, (load addr:$src2)))]>;
1766 def ADD8ri : Ii8<0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1767 "add{b} {$src2, $dst|$dst, $src2}",
1768 [(set R8:$dst, (add R8:$src1, imm:$src2))]>;
1770 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1771 def ADD16ri : Ii16<0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1772 "add{w} {$src2, $dst|$dst, $src2}",
1773 [(set R16:$dst, (add R16:$src1, imm:$src2))]>, OpSize;
1774 def ADD32ri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1775 "add{l} {$src2, $dst|$dst, $src2}",
1776 [(set R32:$dst, (add R32:$src1, imm:$src2))]>;
1779 // FIXME: move ADD16ri8 above ADD16ri to optimize for space.
1780 def ADD16ri8 : Ii8<0x83, MRM0r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1781 "add{w} {$src2, $dst|$dst, $src2}",
1782 [(set R16:$dst, (add R16:$src1, i16immSExt8:$src2))]>,
1784 def ADD32ri8 : Ii8<0x83, MRM0r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1785 "add{l} {$src2, $dst|$dst, $src2}",
1786 [(set R32:$dst, (add R32:$src1, i32immSExt8:$src2))]>;
1788 let isTwoAddress = 0 in {
1789 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
1790 "add{b} {$src2, $dst|$dst, $src2}",
1791 [(store (add (load addr:$dst), R8:$src2), addr:$dst)]>;
1792 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1793 "add{w} {$src2, $dst|$dst, $src2}",
1794 [(store (add (load addr:$dst), R16:$src2), addr:$dst)]>,
1796 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1797 "add{l} {$src2, $dst|$dst, $src2}",
1798 [(store (add (load addr:$dst), R32:$src2), addr:$dst)]>;
1799 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
1800 "add{b} {$src2, $dst|$dst, $src2}",
1801 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1802 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
1803 "add{w} {$src2, $dst|$dst, $src2}",
1804 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1806 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
1807 "add{l} {$src2, $dst|$dst, $src2}",
1808 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1809 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1810 "add{w} {$src2, $dst|$dst, $src2}",
1811 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1813 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1814 "add{l} {$src2, $dst|$dst, $src2}",
1815 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1818 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1819 def ADC32rr : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1820 "adc{l} {$src2, $dst|$dst, $src2}",
1821 [(set R32:$dst, (X86adc R32:$src1, R32:$src2))]>;
1823 def ADC32rm : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
1824 "adc{l} {$src2, $dst|$dst, $src2}",
1825 [(set R32:$dst, (X86adc R32:$src1, (load addr:$src2)))]>;
1826 def ADC32ri : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1827 "adc{l} {$src2, $dst|$dst, $src2}",
1828 [(set R32:$dst, (X86adc R32:$src1, imm:$src2))]>;
1829 def ADC32ri8 : Ii8<0x83, MRM2r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1830 "adc{l} {$src2, $dst|$dst, $src2}",
1831 [(set R32:$dst, (X86adc R32:$src1, i32immSExt8:$src2))]>;
1833 let isTwoAddress = 0 in {
1834 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1835 "adc{l} {$src2, $dst|$dst, $src2}",
1836 [(store (X86adc (load addr:$dst), R32:$src2), addr:$dst)]>;
1837 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
1838 "adc{l} {$src2, $dst|$dst, $src2}",
1839 [(store (X86adc (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1840 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1841 "adc{l} {$src2, $dst|$dst, $src2}",
1842 [(store (X86adc (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1845 def SUB8rr : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1846 "sub{b} {$src2, $dst|$dst, $src2}",
1847 [(set R8:$dst, (sub R8:$src1, R8:$src2))]>;
1848 def SUB16rr : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1849 "sub{w} {$src2, $dst|$dst, $src2}",
1850 [(set R16:$dst, (sub R16:$src1, R16:$src2))]>, OpSize;
1851 def SUB32rr : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1852 "sub{l} {$src2, $dst|$dst, $src2}",
1853 [(set R32:$dst, (sub R32:$src1, R32:$src2))]>;
1854 def SUB8rm : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1855 "sub{b} {$src2, $dst|$dst, $src2}",
1856 [(set R8:$dst, (sub R8:$src1, (load addr:$src2)))]>;
1857 def SUB16rm : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1858 "sub{w} {$src2, $dst|$dst, $src2}",
1859 [(set R16:$dst, (sub R16:$src1, (load addr:$src2)))]>, OpSize;
1860 def SUB32rm : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1861 "sub{l} {$src2, $dst|$dst, $src2}",
1862 [(set R32:$dst, (sub R32:$src1, (load addr:$src2)))]>;
1864 def SUB8ri : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1865 "sub{b} {$src2, $dst|$dst, $src2}",
1866 [(set R8:$dst, (sub R8:$src1, imm:$src2))]>;
1867 def SUB16ri : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1868 "sub{w} {$src2, $dst|$dst, $src2}",
1869 [(set R16:$dst, (sub R16:$src1, imm:$src2))]>, OpSize;
1870 def SUB32ri : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1871 "sub{l} {$src2, $dst|$dst, $src2}",
1872 [(set R32:$dst, (sub R32:$src1, imm:$src2))]>;
1873 def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1874 "sub{w} {$src2, $dst|$dst, $src2}",
1875 [(set R16:$dst, (sub R16:$src1, i16immSExt8:$src2))]>,
1877 def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1878 "sub{l} {$src2, $dst|$dst, $src2}",
1879 [(set R32:$dst, (sub R32:$src1, i32immSExt8:$src2))]>;
1880 let isTwoAddress = 0 in {
1881 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
1882 "sub{b} {$src2, $dst|$dst, $src2}",
1883 [(store (sub (load addr:$dst), R8:$src2), addr:$dst)]>;
1884 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1885 "sub{w} {$src2, $dst|$dst, $src2}",
1886 [(store (sub (load addr:$dst), R16:$src2), addr:$dst)]>,
1888 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1889 "sub{l} {$src2, $dst|$dst, $src2}",
1890 [(store (sub (load addr:$dst), R32:$src2), addr:$dst)]>;
1891 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
1892 "sub{b} {$src2, $dst|$dst, $src2}",
1893 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1894 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
1895 "sub{w} {$src2, $dst|$dst, $src2}",
1896 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1898 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
1899 "sub{l} {$src2, $dst|$dst, $src2}",
1900 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1901 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1902 "sub{w} {$src2, $dst|$dst, $src2}",
1903 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1905 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1906 "sub{l} {$src2, $dst|$dst, $src2}",
1907 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1910 def SBB32rr : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1911 "sbb{l} {$src2, $dst|$dst, $src2}",
1912 [(set R32:$dst, (X86sbb R32:$src1, R32:$src2))]>;
1914 let isTwoAddress = 0 in {
1915 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1916 "sbb{l} {$src2, $dst|$dst, $src2}",
1917 [(store (X86sbb (load addr:$dst), R32:$src2), addr:$dst)]>;
1918 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
1919 "sbb{b} {$src2, $dst|$dst, $src2}",
1920 [(store (X86sbb (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1921 def SBB16mi : Ii32<0x81, MRM3m, (ops i16mem:$dst, i16imm:$src2),
1922 "sbb{w} {$src2, $dst|$dst, $src2}",
1923 [(store (X86sbb (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1925 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
1926 "sbb{l} {$src2, $dst|$dst, $src2}",
1927 [(store (X86sbb (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1928 def SBB16mi8 : Ii8<0x83, MRM3m, (ops i16mem:$dst, i16i8imm :$src2),
1929 "sbb{w} {$src2, $dst|$dst, $src2}",
1930 [(store (X86sbb (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1932 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
1933 "sbb{l} {$src2, $dst|$dst, $src2}",
1934 [(store (X86sbb (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1936 def SBB8ri : Ii8<0x80, MRM3r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1937 "sbb{b} {$src2, $dst|$dst, $src2}",
1938 [(set R8:$dst, (X86sbb R8:$src1, imm:$src2))]>;
1939 def SBB16ri : Ii16<0x81, MRM3r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1940 "sbb{w} {$src2, $dst|$dst, $src2}",
1941 [(set R16:$dst, (X86sbb R16:$src1, imm:$src2))]>, OpSize;
1943 def SBB32rm : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1944 "sbb{l} {$src2, $dst|$dst, $src2}",
1945 [(set R32:$dst, (X86sbb R32:$src1, (load addr:$src2)))]>;
1946 def SBB32ri : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1947 "sbb{l} {$src2, $dst|$dst, $src2}",
1948 [(set R32:$dst, (X86sbb R32:$src1, imm:$src2))]>;
1950 def SBB16ri8 : Ii8<0x83, MRM3r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1951 "sbb{w} {$src2, $dst|$dst, $src2}",
1952 [(set R16:$dst, (X86sbb R16:$src1, i16immSExt8:$src2))]>,
1954 def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1955 "sbb{l} {$src2, $dst|$dst, $src2}",
1956 [(set R32:$dst, (X86sbb R32:$src1, i32immSExt8:$src2))]>;
1958 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
1959 def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
1960 "imul{w} {$src2, $dst|$dst, $src2}",
1961 [(set R16:$dst, (mul R16:$src1, R16:$src2))]>, TB, OpSize;
1962 def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
1963 "imul{l} {$src2, $dst|$dst, $src2}",
1964 [(set R32:$dst, (mul R32:$src1, R32:$src2))]>, TB;
1966 def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1967 "imul{w} {$src2, $dst|$dst, $src2}",
1968 [(set R16:$dst, (mul R16:$src1, (load addr:$src2)))]>,
1970 def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1971 "imul{l} {$src2, $dst|$dst, $src2}",
1972 [(set R32:$dst, (mul R32:$src1, (load addr:$src2)))]>, TB;
1974 } // end Two Address instructions
1976 // Suprisingly enough, these are not two address instructions!
1977 def IMUL16rri : Ii16<0x69, MRMSrcReg, // R16 = R16*I16
1978 (ops R16:$dst, R16:$src1, i16imm:$src2),
1979 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1980 [(set R16:$dst, (mul R16:$src1, imm:$src2))]>, OpSize;
1981 def IMUL32rri : Ii32<0x69, MRMSrcReg, // R32 = R32*I32
1982 (ops R32:$dst, R32:$src1, i32imm:$src2),
1983 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1984 [(set R32:$dst, (mul R32:$src1, imm:$src2))]>;
1985 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // R16 = R16*I8
1986 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1987 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1988 [(set R16:$dst, (mul R16:$src1, i16immSExt8:$src2))]>,
1990 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // R32 = R32*I8
1991 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1992 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1993 [(set R32:$dst, (mul R32:$src1, i32immSExt8:$src2))]>;
1995 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // R16 = [mem16]*I16
1996 (ops R16:$dst, i16mem:$src1, i16imm:$src2),
1997 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1998 [(set R16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2000 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // R32 = [mem32]*I32
2001 (ops R32:$dst, i32mem:$src1, i32imm:$src2),
2002 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2003 [(set R32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2004 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // R16 = [mem16]*I8
2005 (ops R16:$dst, i16mem:$src1, i16i8imm :$src2),
2006 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2007 [(set R16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2009 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // R32 = [mem32]*I8
2010 (ops R32:$dst, i32mem:$src1, i32i8imm: $src2),
2011 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2012 [(set R32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2014 //===----------------------------------------------------------------------===//
2015 // Test instructions are just like AND, except they don't generate a result.
2017 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2018 def TEST8rr : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
2019 "test{b} {$src2, $src1|$src1, $src2}",
2020 [(set STATUS, (X86test R8:$src1, R8:$src2))]>,
2022 def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
2023 "test{w} {$src2, $src1|$src1, $src2}",
2024 [(set STATUS, (X86test R16:$src1, R16:$src2))]>,
2025 Imp<[],[STATUS]>, OpSize;
2026 def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
2027 "test{l} {$src2, $src1|$src1, $src2}",
2028 [(set STATUS, (X86test R32:$src1, R32:$src2))]>,
2031 def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
2032 "test{b} {$src2, $src1|$src1, $src2}",
2033 [(set STATUS, (X86test (loadi8 addr:$src1), R8:$src2))]>,
2035 def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
2036 "test{w} {$src2, $src1|$src1, $src2}",
2037 [(set STATUS, (X86test (loadi16 addr:$src1), R16:$src2))]>,
2038 Imp<[],[STATUS]>, OpSize;
2039 def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
2040 "test{l} {$src2, $src1|$src1, $src2}",
2041 [(set STATUS, (X86test (loadi32 addr:$src1), R32:$src2))]>,
2043 def TEST8rm : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
2044 "test{b} {$src2, $src1|$src1, $src2}",
2045 [(set STATUS, (X86test R8:$src1, (loadi8 addr:$src2)))]>,
2047 def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
2048 "test{w} {$src2, $src1|$src1, $src2}",
2049 [(set STATUS, (X86test R16:$src1, (loadi16 addr:$src2)))]>,
2050 Imp<[],[STATUS]>, OpSize;
2051 def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
2052 "test{l} {$src2, $src1|$src1, $src2}",
2053 [(set STATUS, (X86test R32:$src1, (loadi32 addr:$src2)))]>,
2056 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = R8 & imm8
2057 (ops R8:$src1, i8imm:$src2),
2058 "test{b} {$src2, $src1|$src1, $src2}",
2059 [(set STATUS, (X86test R8:$src1, imm:$src2))]>,
2061 def TEST16ri : Ii16<0xF7, MRM0r, // flags = R16 & imm16
2062 (ops R16:$src1, i16imm:$src2),
2063 "test{w} {$src2, $src1|$src1, $src2}",
2064 [(set STATUS, (X86test R16:$src1, imm:$src2))]>,
2065 Imp<[],[STATUS]>, OpSize;
2066 def TEST32ri : Ii32<0xF7, MRM0r, // flags = R32 & imm32
2067 (ops R32:$src1, i32imm:$src2),
2068 "test{l} {$src2, $src1|$src1, $src2}",
2069 [(set STATUS, (X86test R32:$src1, imm:$src2))]>,
2071 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2072 (ops i8mem:$src1, i8imm:$src2),
2073 "test{b} {$src2, $src1|$src1, $src2}",
2074 [(set STATUS, (X86test (loadi8 addr:$src1), imm:$src2))]>,
2076 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2077 (ops i16mem:$src1, i16imm:$src2),
2078 "test{w} {$src2, $src1|$src1, $src2}",
2079 [(set STATUS, (X86test (loadi16 addr:$src1), imm:$src2))]>,
2080 Imp<[],[STATUS]>, OpSize;
2081 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2082 (ops i32mem:$src1, i32imm:$src2),
2083 "test{l} {$src2, $src1|$src1, $src2}",
2084 [(set STATUS, (X86test (loadi32 addr:$src1), imm:$src2))]>,
2088 // Condition code ops, incl. set if equal/not equal/...
2089 def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2090 def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
2092 def SETEr : I<0x94, MRM0r,
2095 [(set R8:$dst, (X86setcc X86_COND_E, STATUS))]>,
2097 def SETEm : I<0x94, MRM0m,
2100 [(store (X86setcc X86_COND_E, STATUS), addr:$dst)]>,
2102 def SETNEr : I<0x95, MRM0r,
2105 [(set R8:$dst, (X86setcc X86_COND_NE, STATUS))]>,
2107 def SETNEm : I<0x95, MRM0m,
2110 [(store (X86setcc X86_COND_NE, STATUS), addr:$dst)]>,
2112 def SETLr : I<0x9C, MRM0r,
2115 [(set R8:$dst, (X86setcc X86_COND_L, STATUS))]>,
2116 TB; // R8 = < signed
2117 def SETLm : I<0x9C, MRM0m,
2120 [(store (X86setcc X86_COND_L, STATUS), addr:$dst)]>,
2121 TB; // [mem8] = < signed
2122 def SETGEr : I<0x9D, MRM0r,
2125 [(set R8:$dst, (X86setcc X86_COND_GE, STATUS))]>,
2126 TB; // R8 = >= signed
2127 def SETGEm : I<0x9D, MRM0m,
2130 [(store (X86setcc X86_COND_GE, STATUS), addr:$dst)]>,
2131 TB; // [mem8] = >= signed
2132 def SETLEr : I<0x9E, MRM0r,
2135 [(set R8:$dst, (X86setcc X86_COND_LE, STATUS))]>,
2136 TB; // R8 = <= signed
2137 def SETLEm : I<0x9E, MRM0m,
2140 [(store (X86setcc X86_COND_LE, STATUS), addr:$dst)]>,
2141 TB; // [mem8] = <= signed
2142 def SETGr : I<0x9F, MRM0r,
2145 [(set R8:$dst, (X86setcc X86_COND_G, STATUS))]>,
2146 TB; // R8 = > signed
2147 def SETGm : I<0x9F, MRM0m,
2150 [(store (X86setcc X86_COND_G, STATUS), addr:$dst)]>,
2151 TB; // [mem8] = > signed
2153 def SETBr : I<0x92, MRM0r,
2156 [(set R8:$dst, (X86setcc X86_COND_B, STATUS))]>,
2157 TB; // R8 = < unsign
2158 def SETBm : I<0x92, MRM0m,
2161 [(store (X86setcc X86_COND_B, STATUS), addr:$dst)]>,
2162 TB; // [mem8] = < unsign
2163 def SETAEr : I<0x93, MRM0r,
2166 [(set R8:$dst, (X86setcc X86_COND_AE, STATUS))]>,
2167 TB; // R8 = >= unsign
2168 def SETAEm : I<0x93, MRM0m,
2171 [(store (X86setcc X86_COND_AE, STATUS), addr:$dst)]>,
2172 TB; // [mem8] = >= unsign
2173 def SETBEr : I<0x96, MRM0r,
2176 [(set R8:$dst, (X86setcc X86_COND_BE, STATUS))]>,
2177 TB; // R8 = <= unsign
2178 def SETBEm : I<0x96, MRM0m,
2181 [(store (X86setcc X86_COND_BE, STATUS), addr:$dst)]>,
2182 TB; // [mem8] = <= unsign
2183 def SETAr : I<0x97, MRM0r,
2186 [(set R8:$dst, (X86setcc X86_COND_A, STATUS))]>,
2187 TB; // R8 = > signed
2188 def SETAm : I<0x97, MRM0m,
2191 [(store (X86setcc X86_COND_A, STATUS), addr:$dst)]>,
2192 TB; // [mem8] = > signed
2194 def SETSr : I<0x98, MRM0r,
2197 [(set R8:$dst, (X86setcc X86_COND_S, STATUS))]>,
2198 TB; // R8 = <sign bit>
2199 def SETSm : I<0x98, MRM0m,
2202 [(store (X86setcc X86_COND_S, STATUS), addr:$dst)]>,
2203 TB; // [mem8] = <sign bit>
2204 def SETNSr : I<0x99, MRM0r,
2207 [(set R8:$dst, (X86setcc X86_COND_NS, STATUS))]>,
2208 TB; // R8 = !<sign bit>
2209 def SETNSm : I<0x99, MRM0m,
2212 [(store (X86setcc X86_COND_NS, STATUS), addr:$dst)]>,
2213 TB; // [mem8] = !<sign bit>
2214 def SETPr : I<0x9A, MRM0r,
2217 [(set R8:$dst, (X86setcc X86_COND_P, STATUS))]>,
2219 def SETPm : I<0x9A, MRM0m,
2222 [(store (X86setcc X86_COND_P, STATUS), addr:$dst)]>,
2223 TB; // [mem8] = parity
2224 def SETNPr : I<0x9B, MRM0r,
2227 [(set R8:$dst, (X86setcc X86_COND_NP, STATUS))]>,
2228 TB; // R8 = not parity
2229 def SETNPm : I<0x9B, MRM0m,
2232 [(store (X86setcc X86_COND_NP, STATUS), addr:$dst)]>,
2233 TB; // [mem8] = not parity
2235 // Integer comparisons
2236 def CMP8rr : I<0x38, MRMDestReg,
2237 (ops R8 :$src1, R8 :$src2),
2238 "cmp{b} {$src2, $src1|$src1, $src2}",
2239 [(set STATUS, (X86cmp R8:$src1, R8:$src2))]>,
2241 def CMP16rr : I<0x39, MRMDestReg,
2242 (ops R16:$src1, R16:$src2),
2243 "cmp{w} {$src2, $src1|$src1, $src2}",
2244 [(set STATUS, (X86cmp R16:$src1, R16:$src2))]>,
2245 Imp<[],[STATUS]>, OpSize;
2246 def CMP32rr : I<0x39, MRMDestReg,
2247 (ops R32:$src1, R32:$src2),
2248 "cmp{l} {$src2, $src1|$src1, $src2}",
2249 [(set STATUS, (X86cmp R32:$src1, R32:$src2))]>,
2251 def CMP8mr : I<0x38, MRMDestMem,
2252 (ops i8mem :$src1, R8 :$src2),
2253 "cmp{b} {$src2, $src1|$src1, $src2}",
2254 [(set STATUS, (X86cmp (loadi8 addr:$src1), R8:$src2))]>,
2256 def CMP16mr : I<0x39, MRMDestMem,
2257 (ops i16mem:$src1, R16:$src2),
2258 "cmp{w} {$src2, $src1|$src1, $src2}",
2259 [(set STATUS, (X86cmp (loadi16 addr:$src1), R16:$src2))]>,
2260 Imp<[],[STATUS]>, OpSize;
2261 def CMP32mr : I<0x39, MRMDestMem,
2262 (ops i32mem:$src1, R32:$src2),
2263 "cmp{l} {$src2, $src1|$src1, $src2}",
2264 [(set STATUS, (X86cmp (loadi32 addr:$src1), R32:$src2))]>,
2266 def CMP8rm : I<0x3A, MRMSrcMem,
2267 (ops R8 :$src1, i8mem :$src2),
2268 "cmp{b} {$src2, $src1|$src1, $src2}",
2269 [(set STATUS, (X86cmp R8:$src1, (loadi8 addr:$src2)))]>,
2271 def CMP16rm : I<0x3B, MRMSrcMem,
2272 (ops R16:$src1, i16mem:$src2),
2273 "cmp{w} {$src2, $src1|$src1, $src2}",
2274 [(set STATUS, (X86cmp R16:$src1, (loadi16 addr:$src2)))]>,
2275 Imp<[],[STATUS]>, OpSize;
2276 def CMP32rm : I<0x3B, MRMSrcMem,
2277 (ops R32:$src1, i32mem:$src2),
2278 "cmp{l} {$src2, $src1|$src1, $src2}",
2279 [(set STATUS, (X86cmp R32:$src1, (loadi32 addr:$src2)))]>,
2281 def CMP8ri : Ii8<0x80, MRM7r,
2282 (ops R8:$src1, i8imm:$src2),
2283 "cmp{b} {$src2, $src1|$src1, $src2}",
2284 [(set STATUS, (X86cmp R8:$src1, imm:$src2))]>,
2286 def CMP16ri : Ii16<0x81, MRM7r,
2287 (ops R16:$src1, i16imm:$src2),
2288 "cmp{w} {$src2, $src1|$src1, $src2}",
2289 [(set STATUS, (X86cmp R16:$src1, imm:$src2))]>,
2290 Imp<[],[STATUS]>, OpSize;
2291 def CMP32ri : Ii32<0x81, MRM7r,
2292 (ops R32:$src1, i32imm:$src2),
2293 "cmp{l} {$src2, $src1|$src1, $src2}",
2294 [(set STATUS, (X86cmp R32:$src1, imm:$src2))]>,
2296 def CMP8mi : Ii8 <0x80, MRM7m,
2297 (ops i8mem :$src1, i8imm :$src2),
2298 "cmp{b} {$src2, $src1|$src1, $src2}",
2299 [(set STATUS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>,
2301 def CMP16mi : Ii16<0x81, MRM7m,
2302 (ops i16mem:$src1, i16imm:$src2),
2303 "cmp{w} {$src2, $src1|$src1, $src2}",
2304 [(set STATUS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
2305 Imp<[],[STATUS]>, OpSize;
2306 def CMP32mi : Ii32<0x81, MRM7m,
2307 (ops i32mem:$src1, i32imm:$src2),
2308 "cmp{l} {$src2, $src1|$src1, $src2}",
2309 [(set STATUS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>,
2312 // Sign/Zero extenders
2313 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src),
2314 "movs{bw|x} {$src, $dst|$dst, $src}",
2315 [(set R16:$dst, (sext R8:$src))]>, TB, OpSize;
2316 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src),
2317 "movs{bw|x} {$src, $dst|$dst, $src}",
2318 [(set R16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2319 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src),
2320 "movs{bl|x} {$src, $dst|$dst, $src}",
2321 [(set R32:$dst, (sext R8:$src))]>, TB;
2322 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src),
2323 "movs{bl|x} {$src, $dst|$dst, $src}",
2324 [(set R32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2325 def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src),
2326 "movs{wl|x} {$src, $dst|$dst, $src}",
2327 [(set R32:$dst, (sext R16:$src))]>, TB;
2328 def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src),
2329 "movs{wl|x} {$src, $dst|$dst, $src}",
2330 [(set R32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2332 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src),
2333 "movz{bw|x} {$src, $dst|$dst, $src}",
2334 [(set R16:$dst, (zext R8:$src))]>, TB, OpSize;
2335 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src),
2336 "movz{bw|x} {$src, $dst|$dst, $src}",
2337 [(set R16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2338 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src),
2339 "movz{bl|x} {$src, $dst|$dst, $src}",
2340 [(set R32:$dst, (zext R8:$src))]>, TB;
2341 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src),
2342 "movz{bl|x} {$src, $dst|$dst, $src}",
2343 [(set R32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2344 def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src),
2345 "movz{wl|x} {$src, $dst|$dst, $src}",
2346 [(set R32:$dst, (zext R16:$src))]>, TB;
2347 def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src),
2348 "movz{wl|x} {$src, $dst|$dst, $src}",
2349 [(set R32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2351 //===----------------------------------------------------------------------===//
2352 // XMM Floating point support (requires SSE / SSE2)
2353 //===----------------------------------------------------------------------===//
2355 def MOVSSrr : I<0x10, MRMSrcReg, (ops FR32:$dst, FR32:$src),
2356 "movss {$src, $dst|$dst, $src}", []>,
2357 Requires<[HasSSE1]>, XS;
2358 def MOVSDrr : I<0x10, MRMSrcReg, (ops FR64:$dst, FR64:$src),
2359 "movsd {$src, $dst|$dst, $src}", []>,
2360 Requires<[HasSSE2]>, XD;
2362 def MOVSSrm : I<0x10, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
2363 "movss {$src, $dst|$dst, $src}",
2364 [(set FR32:$dst, (loadf32 addr:$src))]>,
2365 Requires<[HasSSE1]>, XS;
2366 def MOVSSmr : I<0x11, MRMDestMem, (ops f32mem:$dst, FR32:$src),
2367 "movss {$src, $dst|$dst, $src}",
2368 [(store FR32:$src, addr:$dst)]>,
2369 Requires<[HasSSE1]>, XS;
2370 def MOVSDrm : I<0x10, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
2371 "movsd {$src, $dst|$dst, $src}",
2372 [(set FR64:$dst, (loadf64 addr:$src))]>,
2373 Requires<[HasSSE2]>, XD;
2374 def MOVSDmr : I<0x11, MRMDestMem, (ops f64mem:$dst, FR64:$src),
2375 "movsd {$src, $dst|$dst, $src}",
2376 [(store FR64:$src, addr:$dst)]>,
2377 Requires<[HasSSE2]>, XD;
2379 def CVTTSD2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, FR64:$src),
2380 "cvttsd2si {$src, $dst|$dst, $src}",
2381 [(set R32:$dst, (fp_to_sint FR64:$src))]>,
2382 Requires<[HasSSE2]>, XD;
2383 def CVTTSD2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f64mem:$src),
2384 "cvttsd2si {$src, $dst|$dst, $src}",
2385 [(set R32:$dst, (fp_to_sint (loadf64 addr:$src)))]>,
2386 Requires<[HasSSE2]>, XD;
2387 def CVTTSS2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, FR32:$src),
2388 "cvttss2si {$src, $dst|$dst, $src}",
2389 [(set R32:$dst, (fp_to_sint FR32:$src))]>,
2390 Requires<[HasSSE1]>, XS;
2391 def CVTTSS2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f32mem:$src),
2392 "cvttss2si {$src, $dst|$dst, $src}",
2393 [(set R32:$dst, (fp_to_sint (loadf32 addr:$src)))]>,
2394 Requires<[HasSSE1]>, XS;
2395 def CVTSD2SSrr: I<0x5A, MRMSrcReg, (ops FR32:$dst, FR64:$src),
2396 "cvtsd2ss {$src, $dst|$dst, $src}",
2397 [(set FR32:$dst, (fround FR64:$src))]>,
2398 Requires<[HasSSE2]>, XS;
2399 def CVTSD2SSrm: I<0x5A, MRMSrcMem, (ops FR32:$dst, f64mem:$src),
2400 "cvtsd2ss {$src, $dst|$dst, $src}",
2401 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>,
2402 Requires<[HasSSE2]>, XS;
2403 def CVTSS2SDrr: I<0x5A, MRMSrcReg, (ops FR64:$dst, FR32:$src),
2404 "cvtss2sd {$src, $dst|$dst, $src}",
2405 [(set FR64:$dst, (fextend FR32:$src))]>,
2406 Requires<[HasSSE2]>, XD;
2407 def CVTSS2SDrm: I<0x5A, MRMSrcMem, (ops FR64:$dst, f32mem:$src),
2408 "cvtss2sd {$src, $dst|$dst, $src}",
2409 [(set FR64:$dst, (fextend (loadf32 addr:$src)))]>,
2410 Requires<[HasSSE2]>, XD;
2411 def CVTSI2SSrr: I<0x2A, MRMSrcReg, (ops FR32:$dst, R32:$src),
2412 "cvtsi2ss {$src, $dst|$dst, $src}",
2413 [(set FR32:$dst, (sint_to_fp R32:$src))]>,
2414 Requires<[HasSSE2]>, XS;
2415 def CVTSI2SSrm: I<0x2A, MRMSrcMem, (ops FR32:$dst, i32mem:$src),
2416 "cvtsi2ss {$src, $dst|$dst, $src}",
2417 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>,
2418 Requires<[HasSSE2]>, XS;
2419 def CVTSI2SDrr: I<0x2A, MRMSrcReg, (ops FR64:$dst, R32:$src),
2420 "cvtsi2sd {$src, $dst|$dst, $src}",
2421 [(set FR64:$dst, (sint_to_fp R32:$src))]>,
2422 Requires<[HasSSE2]>, XD;
2423 def CVTSI2SDrm: I<0x2A, MRMSrcMem, (ops FR64:$dst, i32mem:$src),
2424 "cvtsi2sd {$src, $dst|$dst, $src}",
2425 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>,
2426 Requires<[HasSSE2]>, XD;
2428 def SQRTSSrm : I<0x51, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
2429 "sqrtss {$src, $dst|$dst, $src}",
2430 [(set FR32:$dst, (fsqrt (loadf32 addr:$src)))]>,
2431 Requires<[HasSSE1]>, XS;
2432 def SQRTSSrr : I<0x51, MRMSrcReg, (ops FR32:$dst, FR32:$src),
2433 "sqrtss {$src, $dst|$dst, $src}",
2434 [(set FR32:$dst, (fsqrt FR32:$src))]>,
2435 Requires<[HasSSE1]>, XS;
2436 def SQRTSDrm : I<0x51, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
2437 "sqrtsd {$src, $dst|$dst, $src}",
2438 [(set FR64:$dst, (fsqrt (loadf64 addr:$src)))]>,
2439 Requires<[HasSSE2]>, XD;
2440 def SQRTSDrr : I<0x51, MRMSrcReg, (ops FR64:$dst, FR64:$src),
2441 "sqrtsd {$src, $dst|$dst, $src}",
2442 [(set FR64:$dst, (fsqrt FR64:$src))]>,
2443 Requires<[HasSSE2]>, XD;
2445 def UCOMISDrr: I<0x2E, MRMSrcReg, (ops FR64:$src1, FR64:$src2),
2446 "ucomisd {$src2, $src1|$src1, $src2}",
2447 [(set STATUS, (X86cmp FR64:$src1, FR64:$src2))]>,
2448 Requires<[HasSSE2]>, TB, OpSize;
2449 def UCOMISDrm: I<0x2E, MRMSrcMem, (ops FR64:$src1, f64mem:$src2),
2450 "ucomisd {$src2, $src1|$src1, $src2}",
2451 [(set STATUS, (X86cmp FR64:$src1, (loadf64 addr:$src2)))]>,
2452 Imp<[],[STATUS]>, Requires<[HasSSE2]>, TB, OpSize;
2453 def UCOMISSrr: I<0x2E, MRMSrcReg, (ops FR32:$src1, FR32:$src2),
2454 "ucomiss {$src2, $src1|$src1, $src2}",
2455 [(set STATUS, (X86cmp FR32:$src1, FR32:$src2))]>,
2456 Imp<[],[STATUS]>, Requires<[HasSSE1]>, TB;
2457 def UCOMISSrm: I<0x2E, MRMSrcMem, (ops FR32:$src1, f32mem:$src2),
2458 "ucomiss {$src2, $src1|$src1, $src2}",
2459 [(set STATUS, (X86cmp FR32:$src1, (loadf32 addr:$src2)))]>,
2460 Imp<[],[STATUS]>, Requires<[HasSSE1]>, TB;
2462 // Pseudo-instructions that map fld0 to xorps/xorpd for sse.
2463 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2464 def FLD0SS : I<0x57, MRMSrcReg, (ops FR32:$dst),
2465 "xorps $dst, $dst", [(set FR32:$dst, fp32imm0)]>,
2466 Requires<[HasSSE1]>, TB;
2467 def FLD0SD : I<0x57, MRMSrcReg, (ops FR64:$dst),
2468 "xorpd $dst, $dst", [(set FR64:$dst, fp64imm0)]>,
2469 Requires<[HasSSE2]>, TB, OpSize;
2471 let isTwoAddress = 1 in {
2472 // SSE Scalar Arithmetic
2473 let isCommutable = 1 in {
2474 def ADDSSrr : I<0x58, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2475 "addss {$src2, $dst|$dst, $src2}",
2476 [(set FR32:$dst, (fadd FR32:$src1, FR32:$src2))]>,
2477 Requires<[HasSSE1]>, XS;
2478 def ADDSDrr : I<0x58, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2479 "addsd {$src2, $dst|$dst, $src2}",
2480 [(set FR64:$dst, (fadd FR64:$src1, FR64:$src2))]>,
2481 Requires<[HasSSE2]>, XD;
2482 def MULSSrr : I<0x59, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2483 "mulss {$src2, $dst|$dst, $src2}",
2484 [(set FR32:$dst, (fmul FR32:$src1, FR32:$src2))]>,
2485 Requires<[HasSSE1]>, XS;
2486 def MULSDrr : I<0x59, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2487 "mulsd {$src2, $dst|$dst, $src2}",
2488 [(set FR64:$dst, (fmul FR64:$src1, FR64:$src2))]>,
2489 Requires<[HasSSE2]>, XD;
2492 def ADDSSrm : I<0x58, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2493 "addss {$src2, $dst|$dst, $src2}",
2494 [(set FR32:$dst, (fadd FR32:$src1, (loadf32 addr:$src2)))]>,
2495 Requires<[HasSSE1]>, XS;
2496 def ADDSDrm : I<0x58, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2497 "addsd {$src2, $dst|$dst, $src2}",
2498 [(set FR64:$dst, (fadd FR64:$src1, (loadf64 addr:$src2)))]>,
2499 Requires<[HasSSE2]>, XD;
2500 def MULSSrm : I<0x59, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2501 "mulss {$src2, $dst|$dst, $src2}",
2502 [(set FR32:$dst, (fmul FR32:$src1, (loadf32 addr:$src2)))]>,
2503 Requires<[HasSSE1]>, XS;
2504 def MULSDrm : I<0x59, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2505 "mulsd {$src2, $dst|$dst, $src2}",
2506 [(set FR64:$dst, (fmul FR64:$src1, (loadf64 addr:$src2)))]>,
2507 Requires<[HasSSE2]>, XD;
2509 def DIVSSrr : I<0x5E, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2510 "divss {$src2, $dst|$dst, $src2}",
2511 [(set FR32:$dst, (fdiv FR32:$src1, FR32:$src2))]>,
2512 Requires<[HasSSE1]>, XS;
2513 def DIVSSrm : I<0x5E, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2514 "divss {$src2, $dst|$dst, $src2}",
2515 [(set FR32:$dst, (fdiv FR32:$src1, (loadf32 addr:$src2)))]>,
2516 Requires<[HasSSE1]>, XS;
2517 def DIVSDrr : I<0x5E, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2518 "divsd {$src2, $dst|$dst, $src2}",
2519 [(set FR64:$dst, (fdiv FR64:$src1, FR64:$src2))]>,
2520 Requires<[HasSSE2]>, XD;
2521 def DIVSDrm : I<0x5E, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2522 "divsd {$src2, $dst|$dst, $src2}",
2523 [(set FR64:$dst, (fdiv FR64:$src1, (loadf64 addr:$src2)))]>,
2524 Requires<[HasSSE2]>, XD;
2526 def SUBSSrr : I<0x5C, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2527 "subss {$src2, $dst|$dst, $src2}",
2528 [(set FR32:$dst, (fsub FR32:$src1, FR32:$src2))]>,
2529 Requires<[HasSSE1]>, XS;
2530 def SUBSSrm : I<0x5C, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2531 "subss {$src2, $dst|$dst, $src2}",
2532 [(set FR32:$dst, (fsub FR32:$src1, (loadf32 addr:$src2)))]>,
2533 Requires<[HasSSE1]>, XS;
2534 def SUBSDrr : I<0x5C, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2535 "subsd {$src2, $dst|$dst, $src2}",
2536 [(set FR64:$dst, (fsub FR64:$src1, FR64:$src2))]>,
2537 Requires<[HasSSE2]>, XD;
2538 def SUBSDrm : I<0x5C, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2539 "subsd {$src2, $dst|$dst, $src2}",
2540 [(set FR64:$dst, (fsub FR64:$src1, (loadf64 addr:$src2)))]>,
2541 Requires<[HasSSE2]>, XD;
2544 let isCommutable = 1 in {
2545 def ANDPSrr : I<0x54, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2546 "andps {$src2, $dst|$dst, $src2}", []>,
2547 Requires<[HasSSE1]>, TB;
2548 def ANDPDrr : I<0x54, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2549 "andpd {$src2, $dst|$dst, $src2}", []>,
2550 Requires<[HasSSE2]>, TB, OpSize;
2551 def ORPSrr : I<0x56, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2552 "orps {$src2, $dst|$dst, $src2}", []>,
2553 Requires<[HasSSE1]>, TB;
2554 def ORPDrr : I<0x56, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2555 "orpd {$src2, $dst|$dst, $src2}", []>,
2556 Requires<[HasSSE2]>, TB, OpSize;
2557 def XORPSrr : I<0x57, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2558 "xorps {$src2, $dst|$dst, $src2}", []>,
2559 Requires<[HasSSE1]>, TB;
2560 def XORPDrr : I<0x57, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2561 "xorpd {$src2, $dst|$dst, $src2}", []>,
2562 Requires<[HasSSE2]>, TB, OpSize;
2564 def ANDNPSrr : I<0x55, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2565 "andnps {$src2, $dst|$dst, $src2}", []>,
2566 Requires<[HasSSE1]>, TB;
2567 def ANDNPDrr : I<0x55, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2568 "andnpd {$src2, $dst|$dst, $src2}", []>,
2569 Requires<[HasSSE2]>, TB, OpSize;
2571 def CMPSSrr : I<0xC2, MRMSrcReg,
2572 (ops FR32:$dst, FR32:$src1, FR32:$src, SSECC:$cc),
2573 "cmp${cc}ss {$src, $dst|$dst, $src}", []>,
2574 Requires<[HasSSE1]>, XS;
2575 def CMPSSrm : I<0xC2, MRMSrcMem,
2576 (ops FR32:$dst, FR32:$src1, f32mem:$src, SSECC:$cc),
2577 "cmp${cc}ss {$src, $dst|$dst, $src}", []>,
2578 Requires<[HasSSE1]>, XS;
2579 def CMPSDrr : I<0xC2, MRMSrcReg,
2580 (ops FR64:$dst, FR64:$src1, FR64:$src, SSECC:$cc),
2581 "cmp${cc}sd {$src, $dst|$dst, $src}", []>,
2582 Requires<[HasSSE1]>, XD;
2583 def CMPSDrm : I<0xC2, MRMSrcMem,
2584 (ops FR64:$dst, FR64:$src1, f64mem:$src, SSECC:$cc),
2585 "cmp${cc}sd {$src, $dst|$dst, $src}", []>,
2586 Requires<[HasSSE2]>, XD;
2589 //===----------------------------------------------------------------------===//
2590 // Floating Point Stack Support
2591 //===----------------------------------------------------------------------===//
2593 // Floating point support. All FP Stack operations are represented with two
2594 // instructions here. The first instruction, generated by the instruction
2595 // selector, uses "RFP" registers: a traditional register file to reference
2596 // floating point values. These instructions are all psuedo instructions and
2597 // use the "Fp" prefix. The second instruction is defined with FPI, which is
2598 // the actual instruction emitted by the assembler. The FP stackifier pass
2599 // converts one to the other after register allocation occurs.
2601 // Note that the FpI instruction should have instruction selection info (e.g.
2602 // a pattern) and the FPI instruction should have emission info (e.g. opcode
2603 // encoding and asm printing info).
2605 // FPI - Floating Point Instruction template.
2606 class FPI<bits<8> o, Format F, dag ops, string asm> : I<o, F, ops, asm, []> {}
2608 // FpI_ - Floating Point Psuedo Instruction template. Not Predicated.
2609 class FpI_<dag ops, FPFormat fp, list<dag> pattern>
2610 : X86Inst<0, Pseudo, NoImm, ops, ""> {
2611 let FPForm = fp; let FPFormBits = FPForm.Value;
2612 let Pattern = pattern;
2615 // Random Pseudo Instructions.
2616 def FpGETRESULT : FpI_<(ops RFP:$dst), SpecialFP,
2617 [(set RFP:$dst, X86fpget)]>; // FPR = ST(0)
2619 let noResults = 1 in
2620 def FpSETRESULT : FpI_<(ops RFP:$src), SpecialFP,
2621 [(X86fpset RFP:$src)]>, Imp<[], [ST0]>; // ST(0) = FPR
2623 // FpI - Floating Point Psuedo Instruction template. Predicated on FPStack.
2624 class FpI<dag ops, FPFormat fp, list<dag> pattern> :
2625 FpI_<ops, fp, pattern>, Requires<[FPStack]>;
2628 def FpMOV : FpI<(ops RFP:$dst, RFP:$src), SpecialFP, []>; // f1 = fmov f2
2631 // Add, Sub, Mul, Div.
2632 def FpADD : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2633 [(set RFP:$dst, (fadd RFP:$src1, RFP:$src2))]>;
2634 def FpSUB : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2635 [(set RFP:$dst, (fsub RFP:$src1, RFP:$src2))]>;
2636 def FpMUL : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2637 [(set RFP:$dst, (fmul RFP:$src1, RFP:$src2))]>;
2638 def FpDIV : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2639 [(set RFP:$dst, (fdiv RFP:$src1, RFP:$src2))]>;
2641 class FPST0rInst<bits<8> o, string asm>
2642 : FPI<o, AddRegFrm, (ops RST:$op), asm>, D8;
2643 class FPrST0Inst<bits<8> o, string asm>
2644 : FPI<o, AddRegFrm, (ops RST:$op), asm>, DC;
2645 class FPrST0PInst<bits<8> o, string asm>
2646 : FPI<o, AddRegFrm, (ops RST:$op), asm>, DE;
2648 // Binary Ops with a memory source.
2649 def FpADD32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2650 [(set RFP:$dst, (fadd RFP:$src1,
2651 (extloadf64f32 addr:$src2)))]>;
2652 // ST(0) = ST(0) + [mem32]
2653 def FpADD64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2654 [(set RFP:$dst, (fadd RFP:$src1, (loadf64 addr:$src2)))]>;
2655 // ST(0) = ST(0) + [mem64]
2656 def FpMUL32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2657 [(set RFP:$dst, (fmul RFP:$src1,
2658 (extloadf64f32 addr:$src2)))]>;
2659 // ST(0) = ST(0) * [mem32]
2660 def FpMUL64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2661 [(set RFP:$dst, (fmul RFP:$src1, (loadf64 addr:$src2)))]>;
2662 // ST(0) = ST(0) * [mem64]
2663 def FpSUB32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2664 [(set RFP:$dst, (fsub RFP:$src1,
2665 (extloadf64f32 addr:$src2)))]>;
2666 // ST(0) = ST(0) - [mem32]
2667 def FpSUB64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2668 [(set RFP:$dst, (fsub RFP:$src1, (loadf64 addr:$src2)))]>;
2669 // ST(0) = ST(0) - [mem64]
2670 def FpSUBR32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2671 [(set RFP:$dst, (fsub (extloadf64f32 addr:$src2),
2673 // ST(0) = [mem32] - ST(0)
2674 def FpSUBR64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2675 [(set RFP:$dst, (fsub (loadf64 addr:$src2), RFP:$src1))]>;
2676 // ST(0) = [mem64] - ST(0)
2677 def FpDIV32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2678 [(set RFP:$dst, (fdiv RFP:$src1,
2679 (extloadf64f32 addr:$src2)))]>;
2680 // ST(0) = ST(0) / [mem32]
2681 def FpDIV64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2682 [(set RFP:$dst, (fdiv RFP:$src1, (loadf64 addr:$src2)))]>;
2683 // ST(0) = ST(0) / [mem64]
2684 def FpDIVR32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2685 [(set RFP:$dst, (fdiv (extloadf64f32 addr:$src2),
2687 // ST(0) = [mem32] / ST(0)
2688 def FpDIVR64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2689 [(set RFP:$dst, (fdiv (loadf64 addr:$src2), RFP:$src1))]>;
2690 // ST(0) = [mem64] / ST(0)
2693 def FADD32m : FPI<0xD8, MRM0m, (ops f32mem:$src), "fadd{s} $src">;
2694 def FADD64m : FPI<0xDC, MRM0m, (ops f64mem:$src), "fadd{l} $src">;
2695 def FMUL32m : FPI<0xD8, MRM1m, (ops f32mem:$src), "fmul{s} $src">;
2696 def FMUL64m : FPI<0xDC, MRM1m, (ops f64mem:$src), "fmul{l} $src">;
2697 def FSUB32m : FPI<0xD8, MRM4m, (ops f32mem:$src), "fsub{s} $src">;
2698 def FSUB64m : FPI<0xDC, MRM4m, (ops f64mem:$src), "fsub{l} $src">;
2699 def FSUBR32m : FPI<0xD8, MRM5m, (ops f32mem:$src), "fsubr{s} $src">;
2700 def FSUBR64m : FPI<0xDC, MRM5m, (ops f64mem:$src), "fsubr{l} $src">;
2701 def FDIV32m : FPI<0xD8, MRM6m, (ops f32mem:$src), "fdiv{s} $src">;
2702 def FDIV64m : FPI<0xDC, MRM6m, (ops f64mem:$src), "fdiv{l} $src">;
2703 def FDIVR32m : FPI<0xD8, MRM7m, (ops f32mem:$src), "fdivr{s} $src">;
2704 def FDIVR64m : FPI<0xDC, MRM7m, (ops f64mem:$src), "fdivr{l} $src">;
2706 // FIXME: Implement these when we have a dag-dag isel!
2707 def FpIADD16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2708 [(set RFP:$dst, (fadd RFP:$src1,
2709 (sint_to_fp (loadi16 addr:$src2))))]>;
2710 // ST(0) = ST(0) + [mem16int]
2711 def FpIADD32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2712 [(set RFP:$dst, (fadd RFP:$src1,
2713 (sint_to_fp (loadi32 addr:$src2))))]>;
2714 // ST(0) = ST(0) + [mem32int]
2715 def FpIMUL16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2716 [(set RFP:$dst, (fmul RFP:$src1,
2717 (sint_to_fp (loadi16 addr:$src2))))]>;
2718 // ST(0) = ST(0) * [mem16int]
2719 def FpIMUL32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2720 [(set RFP:$dst, (fmul RFP:$src1,
2721 (sint_to_fp (loadi32 addr:$src2))))]>;
2722 // ST(0) = ST(0) * [mem32int]
2723 def FpISUB16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2724 [(set RFP:$dst, (fsub RFP:$src1,
2725 (sint_to_fp (loadi16 addr:$src2))))]>;
2726 // ST(0) = ST(0) - [mem16int]
2727 def FpISUB32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2728 [(set RFP:$dst, (fsub RFP:$src1,
2729 (sint_to_fp (loadi32 addr:$src2))))]>;
2730 // ST(0) = ST(0) - [mem32int]
2731 def FpISUBR16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2732 [(set RFP:$dst, (fsub (sint_to_fp (loadi16 addr:$src2)),
2734 // ST(0) = [mem16int] - ST(0)
2735 def FpISUBR32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2736 [(set RFP:$dst, (fsub (sint_to_fp (loadi32 addr:$src2)),
2738 // ST(0) = [mem32int] - ST(0)
2739 def FpIDIV16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2740 [(set RFP:$dst, (fdiv RFP:$src1,
2741 (sint_to_fp (loadi16 addr:$src2))))]>;
2742 // ST(0) = ST(0) / [mem16int]
2743 def FpIDIV32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2744 [(set RFP:$dst, (fdiv RFP:$src1,
2745 (sint_to_fp (loadi32 addr:$src2))))]>;
2746 // ST(0) = ST(0) / [mem32int]
2747 def FpIDIVR16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2748 [(set RFP:$dst, (fdiv (sint_to_fp (loadi16 addr:$src2)),
2750 // ST(0) = [mem16int] / ST(0)
2751 def FpIDIVR32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2752 [(set RFP:$dst, (fdiv (sint_to_fp (loadi32 addr:$src2)),
2754 // ST(0) = [mem32int] / ST(0)
2756 def FIADD16m : FPI<0xDE, MRM0m, (ops i16mem:$src), "fiadd{s} $src">;
2757 def FIADD32m : FPI<0xDA, MRM0m, (ops i32mem:$src), "fiadd{l} $src">;
2758 def FIMUL16m : FPI<0xDE, MRM1m, (ops i16mem:$src), "fimul{s} $src">;
2759 def FIMUL32m : FPI<0xDA, MRM1m, (ops i32mem:$src), "fimul{l} $src">;
2760 def FISUB16m : FPI<0xDE, MRM4m, (ops i16mem:$src), "fisub{s} $src">;
2761 def FISUB32m : FPI<0xDA, MRM4m, (ops i32mem:$src), "fisub{l} $src">;
2762 def FISUBR16m : FPI<0xDE, MRM5m, (ops i16mem:$src), "fisubr{s} $src">;
2763 def FISUBR32m : FPI<0xDA, MRM5m, (ops i32mem:$src), "fisubr{l} $src">;
2764 def FIDIV16m : FPI<0xDE, MRM6m, (ops i16mem:$src), "fidiv{s} $src">;
2765 def FIDIV32m : FPI<0xDA, MRM6m, (ops i32mem:$src), "fidiv{s} $src">;
2766 def FIDIVR16m : FPI<0xDE, MRM7m, (ops i16mem:$src), "fidivr{s} $src">;
2767 def FIDIVR32m : FPI<0xDA, MRM7m, (ops i32mem:$src), "fidivr{s} $src">;
2769 // NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
2770 // of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
2771 // we have to put some 'r's in and take them out of weird places.
2772 def FADDST0r : FPST0rInst <0xC0, "fadd $op">;
2773 def FADDrST0 : FPrST0Inst <0xC0, "fadd {%ST(0), $op|$op, %ST(0)}">;
2774 def FADDPrST0 : FPrST0PInst<0xC0, "faddp $op">;
2775 def FSUBRST0r : FPST0rInst <0xE8, "fsubr $op">;
2776 def FSUBrST0 : FPrST0Inst <0xE8, "fsub{r} {%ST(0), $op|$op, %ST(0)}">;
2777 def FSUBPrST0 : FPrST0PInst<0xE8, "fsub{r}p $op">;
2778 def FSUBST0r : FPST0rInst <0xE0, "fsub $op">;
2779 def FSUBRrST0 : FPrST0Inst <0xE0, "fsub{|r} {%ST(0), $op|$op, %ST(0)}">;
2780 def FSUBRPrST0 : FPrST0PInst<0xE0, "fsub{|r}p $op">;
2781 def FMULST0r : FPST0rInst <0xC8, "fmul $op">;
2782 def FMULrST0 : FPrST0Inst <0xC8, "fmul {%ST(0), $op|$op, %ST(0)}">;
2783 def FMULPrST0 : FPrST0PInst<0xC8, "fmulp $op">;
2784 def FDIVRST0r : FPST0rInst <0xF8, "fdivr $op">;
2785 def FDIVrST0 : FPrST0Inst <0xF8, "fdiv{r} {%ST(0), $op|$op, %ST(0)}">;
2786 def FDIVPrST0 : FPrST0PInst<0xF8, "fdiv{r}p $op">;
2787 def FDIVST0r : FPST0rInst <0xF0, "fdiv $op">;
2788 def FDIVRrST0 : FPrST0Inst <0xF0, "fdiv{|r} {%ST(0), $op|$op, %ST(0)}">;
2789 def FDIVRPrST0 : FPrST0PInst<0xF0, "fdiv{|r}p $op">;
2792 // Unary operations.
2793 def FpCHS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2794 [(set RFP:$dst, (fneg RFP:$src))]>;
2795 def FpABS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2796 [(set RFP:$dst, (fabs RFP:$src))]>;
2797 def FpSQRT : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2798 [(set RFP:$dst, (fsqrt RFP:$src))]>;
2799 def FpSIN : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2800 [(set RFP:$dst, (fsin RFP:$src))]>;
2801 def FpCOS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2802 [(set RFP:$dst, (fcos RFP:$src))]>;
2803 def FpTST : FpI<(ops RFP:$src), OneArgFP,
2806 def FCHS : FPI<0xE0, RawFrm, (ops), "fchs">, D9;
2807 def FABS : FPI<0xE1, RawFrm, (ops), "fabs">, D9;
2808 def FSQRT : FPI<0xFA, RawFrm, (ops), "fsqrt">, D9;
2809 def FSIN : FPI<0xFE, RawFrm, (ops), "fsin">, D9;
2810 def FCOS : FPI<0xFF, RawFrm, (ops), "fcos">, D9;
2811 def FTST : FPI<0xE4, RawFrm, (ops), "ftst">, D9;
2814 // Floating point cmovs.
2815 let isTwoAddress = 1 in {
2816 def FpCMOVB : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2817 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2818 X86_COND_B, STATUS))]>;
2819 def FpCMOVBE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2820 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2821 X86_COND_BE, STATUS))]>;
2822 def FpCMOVE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2823 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2824 X86_COND_E, STATUS))]>;
2825 def FpCMOVP : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2826 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2827 X86_COND_P, STATUS))]>;
2828 def FpCMOVAE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2829 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2830 X86_COND_AE, STATUS))]>;
2831 def FpCMOVA : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2832 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2833 X86_COND_A, STATUS))]>;
2834 def FpCMOVNE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2835 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2836 X86_COND_NE, STATUS))]>;
2837 def FpCMOVNP : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2838 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2839 X86_COND_NP, STATUS))]>;
2842 def FCMOVB : FPI<0xC0, AddRegFrm, (ops RST:$op),
2843 "fcmovb {$op, %ST(0)|%ST(0), $op}">, DA;
2844 def FCMOVBE : FPI<0xD0, AddRegFrm, (ops RST:$op),
2845 "fcmovbe {$op, %ST(0)|%ST(0), $op}">, DA;
2846 def FCMOVE : FPI<0xC8, AddRegFrm, (ops RST:$op),
2847 "fcmove {$op, %ST(0)|%ST(0), $op}">, DA;
2848 def FCMOVP : FPI<0xD8, AddRegFrm, (ops RST:$op),
2849 "fcmovu {$op, %ST(0)|%ST(0), $op}">, DA;
2850 def FCMOVAE : FPI<0xC0, AddRegFrm, (ops RST:$op),
2851 "fcmovae {$op, %ST(0)|%ST(0), $op}">, DB;
2852 def FCMOVA : FPI<0xD0, AddRegFrm, (ops RST:$op),
2853 "fcmova {$op, %ST(0)|%ST(0), $op}">, DB;
2854 def FCMOVNE : FPI<0xC8, AddRegFrm, (ops RST:$op),
2855 "fcmovne {$op, %ST(0)|%ST(0), $op}">, DB;
2856 def FCMOVNP : FPI<0xD8, AddRegFrm, (ops RST:$op),
2857 "fcmovnu {$op, %ST(0)|%ST(0), $op}">, DB;
2859 // Floating point loads & stores.
2860 def FpLD32m : FpI<(ops RFP:$dst, f32mem:$src), ZeroArgFP,
2861 [(set RFP:$dst, (extloadf64f32 addr:$src))]>;
2862 def FpLD64m : FpI<(ops RFP:$dst, f64mem:$src), ZeroArgFP,
2863 [(set RFP:$dst, (loadf64 addr:$src))]>;
2864 def FpILD16m : FpI<(ops RFP:$dst, i16mem:$src), ZeroArgFP,
2865 [(set RFP:$dst, (sint_to_fp (loadi16 addr:$src)))]>;
2866 def FpILD32m : FpI<(ops RFP:$dst, i32mem:$src), ZeroArgFP,
2867 [(set RFP:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
2868 def FpILD64m : FpI<(ops RFP:$dst, i64mem:$src), ZeroArgFP,
2869 [(set RFP:$dst, (X86fild64m addr:$src))]>;
2871 def FpST32m : FpI<(ops f32mem:$op, RFP:$src), OneArgFP,
2872 [(truncstore RFP:$src, addr:$op, f32)]>;
2873 def FpST64m : FpI<(ops f64mem:$op, RFP:$src), OneArgFP,
2874 [(store RFP:$src, addr:$op)]>;
2876 def FpSTP32m : FpI<(ops f32mem:$op, RFP:$src), OneArgFP, []>;
2877 def FpSTP64m : FpI<(ops f64mem:$op, RFP:$src), OneArgFP, []>;
2878 def FpIST16m : FpI<(ops i16mem:$op, RFP:$src), OneArgFP, []>;
2879 def FpIST32m : FpI<(ops i32mem:$op, RFP:$src), OneArgFP, []>;
2880 def FpIST64m : FpI<(ops i64mem:$op, RFP:$src), OneArgFP, []>;
2882 def FLD32m : FPI<0xD9, MRM0m, (ops f32mem:$src), "fld{s} $src">;
2883 def FLD64m : FPI<0xDD, MRM0m, (ops f64mem:$src), "fld{l} $src">;
2884 def FILD16m : FPI<0xDF, MRM0m, (ops i16mem:$src), "fild{s} $src">;
2885 def FILD32m : FPI<0xDB, MRM0m, (ops i32mem:$src), "fild{l} $src">;
2886 def FILD64m : FPI<0xDF, MRM5m, (ops i64mem:$src), "fild{ll} $src">;
2887 def FST32m : FPI<0xD9, MRM2m, (ops f32mem:$dst), "fst{s} $dst">;
2888 def FST64m : FPI<0xDD, MRM2m, (ops f64mem:$dst), "fst{l} $dst">;
2889 def FSTP32m : FPI<0xD9, MRM3m, (ops f32mem:$dst), "fstp{s} $dst">;
2890 def FSTP64m : FPI<0xDD, MRM3m, (ops f64mem:$dst), "fstp{l} $dst">;
2891 def FIST16m : FPI<0xDF, MRM2m, (ops i16mem:$dst), "fist{s} $dst">;
2892 def FIST32m : FPI<0xDB, MRM2m, (ops i32mem:$dst), "fist{l} $dst">;
2893 def FISTP16m : FPI<0xDF, MRM3m, (ops i16mem:$dst), "fistp{s} $dst">;
2894 def FISTP32m : FPI<0xDB, MRM3m, (ops i32mem:$dst), "fistp{l} $dst">;
2895 def FISTP64m : FPI<0xDF, MRM7m, (ops i64mem:$dst), "fistp{ll} $dst">;
2897 // FP Stack manipulation instructions.
2898 def FLDrr : FPI<0xC0, AddRegFrm, (ops RST:$op), "fld $op">, D9;
2899 def FSTrr : FPI<0xD0, AddRegFrm, (ops RST:$op), "fst $op">, DD;
2900 def FSTPrr : FPI<0xD8, AddRegFrm, (ops RST:$op), "fstp $op">, DD;
2901 def FXCH : FPI<0xC8, AddRegFrm, (ops RST:$op), "fxch $op">, D9;
2903 // Floating point constant loads.
2904 def FpLD0 : FpI<(ops RFP:$dst), ZeroArgFP,
2905 [(set RFP:$dst, fp64imm0)]>;
2906 def FpLD1 : FpI<(ops RFP:$dst), ZeroArgFP,
2907 [(set RFP:$dst, fp64imm1)]>;
2909 def FLD0 : FPI<0xEE, RawFrm, (ops), "fldz">, D9;
2910 def FLD1 : FPI<0xE8, RawFrm, (ops), "fld1">, D9;
2913 // Floating point compares.
2914 def FpUCOMr : FpI<(ops RFP:$lhs, RFP:$rhs), CompareFP,
2915 []>; // FPSW = cmp ST(0) with ST(i)
2916 def FpUCOMIr : FpI<(ops RFP:$lhs, RFP:$rhs), CompareFP,
2917 [(set STATUS, (X86cmp RFP:$lhs, RFP:$rhs))]>,
2918 Imp<[],[STATUS]>; // CC = cmp ST(0) with ST(i)
2920 def FUCOMr : FPI<0xE0, AddRegFrm, // FPSW = cmp ST(0) with ST(i)
2922 "fucom $reg">, DD, Imp<[ST0],[]>;
2923 def FUCOMPr : FPI<0xE8, AddRegFrm, // FPSW = cmp ST(0) with ST(i), pop
2925 "fucomp $reg">, DD, Imp<[ST0],[]>;
2926 def FUCOMPPr : FPI<0xE9, RawFrm, // cmp ST(0) with ST(1), pop, pop
2928 "fucompp">, DA, Imp<[ST0],[]>;
2930 def FUCOMIr : FPI<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i)
2932 "fucomi {$reg, %ST(0)|%ST(0), $reg}">, DB, Imp<[ST0],[]>;
2933 def FUCOMIPr : FPI<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i), pop
2935 "fucomip {$reg, %ST(0)|%ST(0), $reg}">, DF, Imp<[ST0],[]>;
2938 // Floating point flag ops.
2939 def FNSTSW8r : I<0xE0, RawFrm, // AX = fp flags
2940 (ops), "fnstsw", []>, DF, Imp<[],[AX]>;
2942 def FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world
2943 (ops i16mem:$dst), "fnstcw $dst", []>;
2944 def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
2945 (ops i16mem:$dst), "fldcw $dst", []>;
2948 //===----------------------------------------------------------------------===//
2949 // Miscellaneous Instructions
2950 //===----------------------------------------------------------------------===//
2952 def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
2953 TB, Imp<[],[EAX,EDX]>;
2956 //===----------------------------------------------------------------------===//
2957 // Non-Instruction Patterns
2958 //===----------------------------------------------------------------------===//
2960 // GlobalAddress and ExternalSymbol
2961 def : Pat<(i32 globaladdr:$dst), (MOV32ri globaladdr:$dst)>;
2962 def : Pat<(i32 externalsym:$dst), (MOV32ri externalsym:$dst)>;
2965 def : Pat<(X86call tglobaladdr:$dst),
2966 (CALLpcrel32 tglobaladdr:$dst)>;
2967 def : Pat<(X86call texternalsym:$dst),
2968 (CALLpcrel32 texternalsym:$dst)>;
2970 // X86 specific add which produces a flag.
2971 def : Pat<(X86addflag R32:$src1, R32:$src2),
2972 (ADD32rr R32:$src1, R32:$src2)>;
2973 def : Pat<(X86addflag R32:$src1, (load addr:$src2)),
2974 (ADD32rm R32:$src1, addr:$src2)>;
2975 def : Pat<(X86addflag R32:$src1, imm:$src2),
2976 (ADD32ri R32:$src1, imm:$src2)>;
2977 def : Pat<(X86addflag R32:$src1, i32immSExt8:$src2),
2978 (ADD32ri8 R32:$src1, i32immSExt8:$src2)>;
2980 def : Pat<(X86subflag R32:$src1, R32:$src2),
2981 (SUB32rr R32:$src1, R32:$src2)>;
2982 def : Pat<(X86subflag R32:$src1, (load addr:$src2)),
2983 (SUB32rm R32:$src1, addr:$src2)>;
2984 def : Pat<(X86subflag R32:$src1, imm:$src2),
2985 (SUB32ri R32:$src1, imm:$src2)>;
2986 def : Pat<(X86subflag R32:$src1, i32immSExt8:$src2),
2987 (SUB32ri8 R32:$src1, i32immSExt8:$src2)>;
2989 // {s|z}extload bool -> {s|z}extload byte
2990 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2991 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2992 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2993 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2995 // extload bool -> extload byte
2996 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2999 def : Pat<(i16 (anyext R8 :$src)), (MOVZX16rr8 R8 :$src)>;
3000 def : Pat<(i32 (anyext R8 :$src)), (MOVZX32rr8 R8 :$src)>;
3001 def : Pat<(i32 (anyext R16:$src)), (MOVZX32rr16 R16:$src)>;
3003 // Required for RET of f32 / f64 values.
3004 def : Pat<(X86fld addr:$src, f32), (FpLD32m addr:$src)>;
3005 def : Pat<(X86fld addr:$src, f64), (FpLD64m addr:$src)>;
3007 // Required for CALL which return f32 / f64 values.
3008 def : Pat<(X86fst RFP:$src, addr:$op, f32), (FpST32m addr:$op, RFP:$src)>;
3009 def : Pat<(X86fst RFP:$src, addr:$op, f64), (FpST64m addr:$op, RFP:$src)>;
3011 // Floatin point constant -0.0 and -1.0
3012 def : Pat<(f64 fp64immneg0), (FpCHS (FpLD0))>, Requires<[FPStack]>;
3013 def : Pat<(f64 fp64immneg1), (FpCHS (FpLD1))>, Requires<[FPStack]>;
3016 def : Pat<(f64 (undef)), (FpLD0)>, Requires<[FPStack]>;
3019 //===----------------------------------------------------------------------===//
3021 //===----------------------------------------------------------------------===//
3023 // (shl x, 1) ==> (add x, x)
3024 def : Pat<(shl R8 :$src1, (i8 1)), (ADD8rr R8 :$src1, R8 :$src1)>;
3025 def : Pat<(shl R16:$src1, (i8 1)), (ADD16rr R16:$src1, R16:$src1)>;
3026 def : Pat<(shl R32:$src1, (i8 1)), (ADD32rr R32:$src1, R32:$src1)>;