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<0, 2, [SDTCisSameAs<0, 1>]>;
26 def SDTX86Cmov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
30 def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
33 def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
36 def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
38 def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39 def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
42 def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
44 def SDTX86FpGet : SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>;
45 def SDTX86FpSet : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
47 def SDTX86Fld : SDTypeProfile<1, 2, [SDTCisVT<0, f64>,
48 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
49 def SDTX86Fst : SDTypeProfile<0, 3, [SDTCisFP<0>,
50 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
51 def SDTX86Fild : SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisPtrTy<1>,
52 SDTCisVT<2, OtherVT>]>;
53 def SDTX86FpToIMem: SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisPtrTy<1>]>;
55 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
57 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
59 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
61 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
62 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
64 def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
65 [SDNPCommutative, SDNPAssociative]>;
66 def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
67 [SDNPCommutative, SDNPAssociative]>;
69 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
71 def X86test : SDNode<"X86ISD::TEST", SDTX86CmpTest,
74 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
75 [SDNPInFlag, SDNPOutFlag]>;
76 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
77 [SDNPHasChain, SDNPInFlag]>;
78 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
79 [SDNPInFlag, SDNPOutFlag]>;
81 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
82 [SDNPHasChain, SDNPOptInFlag]>;
84 def X86callseq_start :
85 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
88 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
91 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
92 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
94 def X86fpget : SDNode<"X86ISD::FP_GET_RESULT", SDTX86FpGet,
95 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
96 def X86fpset : SDNode<"X86ISD::FP_SET_RESULT", SDTX86FpSet,
97 [SDNPHasChain, SDNPOutFlag]>;
99 def X86fld : SDNode<"X86ISD::FLD", SDTX86Fld,
101 def X86fst : SDNode<"X86ISD::FST", SDTX86Fst,
102 [SDNPHasChain, SDNPInFlag]>;
103 def X86fild : SDNode<"X86ISD::FILD", SDTX86Fild,
105 def X86fildflag: SDNode<"X86ISD::FILD_FLAG",SDTX86Fild,
106 [SDNPHasChain, SDNPOutFlag]>;
107 def X86fp_to_i16mem : SDNode<"X86ISD::FP_TO_INT16_IN_MEM", SDTX86FpToIMem,
109 def X86fp_to_i32mem : SDNode<"X86ISD::FP_TO_INT32_IN_MEM", SDTX86FpToIMem,
111 def X86fp_to_i64mem : SDNode<"X86ISD::FP_TO_INT64_IN_MEM", SDTX86FpToIMem,
114 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
115 [SDNPHasChain, SDNPInFlag]>;
116 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
117 [SDNPHasChain, SDNPInFlag]>;
119 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
120 [SDNPHasChain, SDNPOutFlag]>;
122 def X86loadp : SDNode<"X86ISD::LOAD_PACK", SDTLoad,
125 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
127 //===----------------------------------------------------------------------===//
128 // X86 Operand Definitions.
131 // *mem - Operand definitions for the funky X86 addressing mode operands.
133 class X86MemOperand<string printMethod> : Operand<i32> {
134 let PrintMethod = printMethod;
135 let NumMIOperands = 4;
136 let MIOperandInfo = (ops R32, i8imm, R32, i32imm);
139 def i8mem : X86MemOperand<"printi8mem">;
140 def i16mem : X86MemOperand<"printi16mem">;
141 def i32mem : X86MemOperand<"printi32mem">;
142 def i64mem : X86MemOperand<"printi64mem">;
143 def i128mem : X86MemOperand<"printi128mem">;
144 def f32mem : X86MemOperand<"printf32mem">;
145 def f64mem : X86MemOperand<"printf64mem">;
146 def f128mem : X86MemOperand<"printf128mem">;
148 def SSECC : Operand<i8> {
149 let PrintMethod = "printSSECC";
152 def piclabel: Operand<i32> {
153 let PrintMethod = "printPICLabel";
156 // A couple of more descriptive operand definitions.
157 // 16-bits but only 8 bits are significant.
158 def i16i8imm : Operand<i16>;
159 // 32-bits but only 8 bits are significant.
160 def i32i8imm : Operand<i32>;
162 // Branch targets have OtherVT type.
163 def brtarget : Operand<OtherVT>;
165 //===----------------------------------------------------------------------===//
166 // X86 Complex Pattern Definitions.
169 // Define X86 specific addressing mode.
170 def addr : ComplexPattern<i32, 4, "SelectAddr", []>;
171 def leaaddr : ComplexPattern<i32, 4, "SelectLEAAddr",
172 [add, mul, shl, frameindex]>;
174 //===----------------------------------------------------------------------===//
175 // X86 Instruction Format Definitions.
178 // Format specifies the encoding used by the instruction. This is part of the
179 // ad-hoc solution used to emit machine instruction encodings by our machine
181 class Format<bits<6> val> {
185 def Pseudo : Format<0>; def RawFrm : Format<1>;
186 def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
187 def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
188 def MRMSrcMem : Format<6>;
189 def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
190 def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
191 def MRM6r : Format<22>; def MRM7r : Format<23>;
192 def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
193 def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
194 def MRM6m : Format<30>; def MRM7m : Format<31>;
195 def MRMInitReg : Format<32>;
197 //===----------------------------------------------------------------------===//
198 // X86 Instruction Predicate Definitions.
199 def HasMMX : Predicate<"Subtarget->hasMMX()">;
200 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
201 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
202 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
203 def FPStack : Predicate<"!Subtarget->hasSSE2()">;
205 //===----------------------------------------------------------------------===//
206 // X86 specific pattern fragments.
209 // ImmType - This specifies the immediate type used by an instruction. This is
210 // part of the ad-hoc solution used to emit machine instruction encodings by our
211 // machine code emitter.
212 class ImmType<bits<2> val> {
215 def NoImm : ImmType<0>;
216 def Imm8 : ImmType<1>;
217 def Imm16 : ImmType<2>;
218 def Imm32 : ImmType<3>;
220 // FPFormat - This specifies what form this FP instruction has. This is used by
221 // the Floating-Point stackifier pass.
222 class FPFormat<bits<3> val> {
225 def NotFP : FPFormat<0>;
226 def ZeroArgFP : FPFormat<1>;
227 def OneArgFP : FPFormat<2>;
228 def OneArgFPRW : FPFormat<3>;
229 def TwoArgFP : FPFormat<4>;
230 def CompareFP : FPFormat<5>;
231 def CondMovFP : FPFormat<6>;
232 def SpecialFP : FPFormat<7>;
235 class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
237 let Namespace = "X86";
239 bits<8> Opcode = opcod;
241 bits<6> FormBits = Form.Value;
243 bits<2> ImmTypeBits = ImmT.Value;
245 dag OperandList = ops;
246 string AsmString = AsmStr;
249 // Attributes specific to X86 instructions...
251 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
253 bits<4> Prefix = 0; // Which prefix byte does this inst have?
254 FPFormat FPForm; // What flavor of FP instruction is this?
255 bits<3> FPFormBits = 0;
258 class Imp<list<Register> uses, list<Register> defs> {
259 list<Register> Uses = uses;
260 list<Register> Defs = defs;
264 // Prefix byte classes which are used to indicate to the ad-hoc machine code
265 // emitter that various prefix bytes are required.
266 class OpSize { bit hasOpSizePrefix = 1; }
267 class TB { bits<4> Prefix = 1; }
268 class REP { bits<4> Prefix = 2; }
269 class D8 { bits<4> Prefix = 3; }
270 class D9 { bits<4> Prefix = 4; }
271 class DA { bits<4> Prefix = 5; }
272 class DB { bits<4> Prefix = 6; }
273 class DC { bits<4> Prefix = 7; }
274 class DD { bits<4> Prefix = 8; }
275 class DE { bits<4> Prefix = 9; }
276 class DF { bits<4> Prefix = 10; }
277 class XD { bits<4> Prefix = 11; }
278 class XS { bits<4> Prefix = 12; }
281 //===----------------------------------------------------------------------===//
282 // Pattern fragments...
285 // X86 specific condition code. These correspond to CondCode in
286 // X86ISelLowering.h. They must be kept in synch.
287 def X86_COND_A : PatLeaf<(i8 0)>;
288 def X86_COND_AE : PatLeaf<(i8 1)>;
289 def X86_COND_B : PatLeaf<(i8 2)>;
290 def X86_COND_BE : PatLeaf<(i8 3)>;
291 def X86_COND_E : PatLeaf<(i8 4)>;
292 def X86_COND_G : PatLeaf<(i8 5)>;
293 def X86_COND_GE : PatLeaf<(i8 6)>;
294 def X86_COND_L : PatLeaf<(i8 7)>;
295 def X86_COND_LE : PatLeaf<(i8 8)>;
296 def X86_COND_NE : PatLeaf<(i8 9)>;
297 def X86_COND_NO : PatLeaf<(i8 10)>;
298 def X86_COND_NP : PatLeaf<(i8 11)>;
299 def X86_COND_NS : PatLeaf<(i8 12)>;
300 def X86_COND_O : PatLeaf<(i8 13)>;
301 def X86_COND_P : PatLeaf<(i8 14)>;
302 def X86_COND_S : PatLeaf<(i8 15)>;
304 def i16immSExt8 : PatLeaf<(i16 imm), [{
305 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
306 // sign extended field.
307 return (int)N->getValue() == (signed char)N->getValue();
310 def i32immSExt8 : PatLeaf<(i32 imm), [{
311 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
312 // sign extended field.
313 return (int)N->getValue() == (signed char)N->getValue();
316 def i16immZExt8 : PatLeaf<(i16 imm), [{
317 // i16immZExt8 predicate - True if the 16-bit immediate fits in a 8-bit zero
319 return (unsigned)N->getValue() == (unsigned char)N->getValue();
322 def fp32imm0 : PatLeaf<(f32 fpimm), [{
323 return N->isExactlyValue(+0.0);
326 def fp64imm0 : PatLeaf<(f64 fpimm), [{
327 return N->isExactlyValue(+0.0);
330 def fp64immneg0 : PatLeaf<(f64 fpimm), [{
331 return N->isExactlyValue(-0.0);
334 def fp64imm1 : PatLeaf<(f64 fpimm), [{
335 return N->isExactlyValue(+1.0);
338 def fp64immneg1 : PatLeaf<(f64 fpimm), [{
339 return N->isExactlyValue(-1.0);
342 // Helper fragments for loads.
343 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
344 def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
345 def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
346 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
347 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
349 def X86loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
350 def X86loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
352 def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i1))>;
353 def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i1))>;
354 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i8))>;
355 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i8))>;
356 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i16))>;
358 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextload node:$ptr, i1))>;
359 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i1))>;
360 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i1))>;
361 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i8))>;
362 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i8))>;
363 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i16))>;
365 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extload node:$ptr, i1))>;
366 def extloadf64f32 : PatFrag<(ops node:$ptr), (f64 (extload node:$ptr, f32))>;
368 def X86loadpf32 : PatFrag<(ops node:$ptr), (f32 (X86loadp node:$ptr))>;
369 def X86loadpf64 : PatFrag<(ops node:$ptr), (f64 (X86loadp node:$ptr))>;
371 //===----------------------------------------------------------------------===//
372 // Instruction templates...
374 class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
375 : X86Inst<o, f, NoImm, ops, asm> {
376 let Pattern = pattern;
378 class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
379 : X86Inst<o, f, Imm8 , ops, asm> {
380 let Pattern = pattern;
382 class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
383 : X86Inst<o, f, Imm16, ops, asm> {
384 let Pattern = pattern;
386 class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
387 : X86Inst<o, f, Imm32, ops, asm> {
388 let Pattern = pattern;
391 //===----------------------------------------------------------------------===//
392 // Instruction list...
395 def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
396 [(X86callseq_start imm:$amt)]>;
397 def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
399 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
400 def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
401 def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
402 def IMPLICIT_DEF_R8 : I<0, Pseudo, (ops R8:$dst),
403 "#IMPLICIT_DEF $dst",
404 [(set R8:$dst, (undef))]>;
405 def IMPLICIT_DEF_R16 : I<0, Pseudo, (ops R16:$dst),
406 "#IMPLICIT_DEF $dst",
407 [(set R16:$dst, (undef))]>;
408 def IMPLICIT_DEF_R32 : I<0, Pseudo, (ops R32:$dst),
409 "#IMPLICIT_DEF $dst",
410 [(set R32:$dst, (undef))]>;
413 def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
415 //===----------------------------------------------------------------------===//
416 // Control Flow Instructions...
419 // Return instructions.
420 let isTerminator = 1, isReturn = 1, isBarrier = 1,
421 hasCtrlDep = 1, noResults = 1 in {
422 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
423 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
424 [(X86retflag imm:$amt)]>;
427 // All branches are RawFrm, Void, Branch, and Terminators
428 let isBranch = 1, isTerminator = 1, noResults = 1 in
429 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
430 I<opcode, RawFrm, ops, asm, pattern>;
432 // Conditional branches
434 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
436 def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
437 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
438 def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
439 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
440 def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
441 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
442 def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
443 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
444 def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
445 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
446 def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
447 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
449 def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
450 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
451 def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
452 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
453 def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
454 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
455 def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
456 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
458 def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
459 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
460 def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
461 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
462 def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
463 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
464 def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
465 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
466 def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
467 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
468 def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
469 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
471 //===----------------------------------------------------------------------===//
472 // Call Instructions...
474 let isCall = 1, noResults = 1 in
475 // All calls clobber the non-callee saved registers...
476 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
477 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
478 def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst), "call ${dst:call}",
480 def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst",
481 [(X86call R32:$dst)]>;
482 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst), "call {*}$dst",
483 [(X86call (loadi32 addr:$dst))]>;
487 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
488 def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call} # TAIL CALL", []>;
489 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
490 def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
491 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
492 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
493 "jmp {*}$dst # TAIL CALL", []>;
495 // ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
496 // way, except that it is marked as being a terminator. This causes the epilog
497 // inserter to insert reloads of callee saved registers BEFORE this. We need
498 // this until we have a more accurate way of tracking where the stack pointer is
499 // within a function.
500 let isTerminator = 1, isTwoAddress = 1 in
501 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
502 "add{l} {$src2, $dst|$dst, $src2}", []>;
504 //===----------------------------------------------------------------------===//
505 // Miscellaneous Instructions...
507 def LEAVE : I<0xC9, RawFrm,
508 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
509 def POP32r : I<0x58, AddRegFrm,
510 (ops R32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
512 def MovePCtoStack : I<0, Pseudo, (ops piclabel:$label),
515 let isTwoAddress = 1 in // R32 = bswap R32
516 def BSWAP32r : I<0xC8, AddRegFrm,
517 (ops R32:$dst, R32:$src),
519 [(set R32:$dst, (bswap R32:$src))]>, 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 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
683 // This probably ought to be moved to a def : Pat<> if the
684 // syntax can be accepted.
685 [(set AL, (mul AL, R8:$src))]>,
686 Imp<[AL],[AX]>; // AL,AH = AL*R8
687 def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul{w} $src", []>,
688 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
689 def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul{l} $src", []>,
690 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
691 def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
693 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
694 // This probably ought to be moved to a def : Pat<> if the
695 // syntax can be accepted.
696 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
697 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
698 def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
699 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
700 OpSize; // AX,DX = AX*[mem16]
701 def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
702 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
704 def IMUL8r : I<0xF6, MRM5r, (ops R8:$src), "imul{b} $src", []>,
705 Imp<[AL],[AX]>; // AL,AH = AL*R8
706 def IMUL16r : I<0xF7, MRM5r, (ops R16:$src), "imul{w} $src", []>,
707 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
708 def IMUL32r : I<0xF7, MRM5r, (ops R32:$src), "imul{l} $src", []>,
709 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
710 def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
711 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
712 def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
713 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
714 OpSize; // AX,DX = AX*[mem16]
715 def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
717 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
719 // unsigned division/remainder
720 def DIV8r : I<0xF6, MRM6r, (ops R8:$src), // AX/r8 = AL,AH
721 "div{b} $src", []>, Imp<[AX],[AX]>;
722 def DIV16r : I<0xF7, MRM6r, (ops R16:$src), // DX:AX/r16 = AX,DX
723 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
724 def DIV32r : I<0xF7, MRM6r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
725 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
726 def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
727 "div{b} $src", []>, Imp<[AX],[AX]>;
728 def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
729 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
730 def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
731 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
733 // Signed division/remainder.
734 def IDIV8r : I<0xF6, MRM7r, (ops R8:$src), // AX/r8 = AL,AH
735 "idiv{b} $src", []>, Imp<[AX],[AX]>;
736 def IDIV16r: I<0xF7, MRM7r, (ops R16:$src), // DX:AX/r16 = AX,DX
737 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
738 def IDIV32r: I<0xF7, MRM7r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
739 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
740 def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
741 "idiv{b} $src", []>, Imp<[AX],[AX]>;
742 def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
743 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
744 def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
745 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
747 // Sign-extenders for division.
748 def CBW : I<0x98, RawFrm, (ops),
749 "{cbtw|cbw}", []>, Imp<[AL],[AH]>; // AX = signext(AL)
750 def CWD : I<0x99, RawFrm, (ops),
751 "{cwtd|cwd}", []>, Imp<[AX],[DX]>; // DX:AX = signext(AX)
752 def CDQ : I<0x99, RawFrm, (ops),
753 "{cltd|cdq}", []>, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
756 //===----------------------------------------------------------------------===//
757 // Two address Instructions...
759 let isTwoAddress = 1 in {
762 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, R16 = R16
763 (ops R16:$dst, R16:$src1, R16:$src2),
764 "cmovb {$src2, $dst|$dst, $src2}",
765 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
768 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, R16 = [mem16]
769 (ops R16:$dst, R16:$src1, i16mem:$src2),
770 "cmovb {$src2, $dst|$dst, $src2}",
771 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
774 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, R32 = R32
775 (ops R32:$dst, R32:$src1, R32:$src2),
776 "cmovb {$src2, $dst|$dst, $src2}",
777 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
780 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, R32 = [mem32]
781 (ops R32:$dst, R32:$src1, i32mem:$src2),
782 "cmovb {$src2, $dst|$dst, $src2}",
783 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
787 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, R16 = R16
788 (ops R16:$dst, R16:$src1, R16:$src2),
789 "cmovae {$src2, $dst|$dst, $src2}",
790 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
793 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, R16 = [mem16]
794 (ops R16:$dst, R16:$src1, i16mem:$src2),
795 "cmovae {$src2, $dst|$dst, $src2}",
796 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
799 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, R32 = R32
800 (ops R32:$dst, R32:$src1, R32:$src2),
801 "cmovae {$src2, $dst|$dst, $src2}",
802 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
805 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, R32 = [mem32]
806 (ops R32:$dst, R32:$src1, i32mem:$src2),
807 "cmovae {$src2, $dst|$dst, $src2}",
808 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
812 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, R16 = R16
813 (ops R16:$dst, R16:$src1, R16:$src2),
814 "cmove {$src2, $dst|$dst, $src2}",
815 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
818 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, R16 = [mem16]
819 (ops R16:$dst, R16:$src1, i16mem:$src2),
820 "cmove {$src2, $dst|$dst, $src2}",
821 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
824 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, R32 = R32
825 (ops R32:$dst, R32:$src1, R32:$src2),
826 "cmove {$src2, $dst|$dst, $src2}",
827 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
830 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, R32 = [mem32]
831 (ops R32:$dst, R32:$src1, i32mem:$src2),
832 "cmove {$src2, $dst|$dst, $src2}",
833 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
837 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, R16 = R16
838 (ops R16:$dst, R16:$src1, R16:$src2),
839 "cmovne {$src2, $dst|$dst, $src2}",
840 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
843 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, R16 = [mem16]
844 (ops R16:$dst, R16:$src1, i16mem:$src2),
845 "cmovne {$src2, $dst|$dst, $src2}",
846 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
849 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, R32 = R32
850 (ops R32:$dst, R32:$src1, R32:$src2),
851 "cmovne {$src2, $dst|$dst, $src2}",
852 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
855 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, R32 = [mem32]
856 (ops R32:$dst, R32:$src1, i32mem:$src2),
857 "cmovne {$src2, $dst|$dst, $src2}",
858 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
862 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, R16 = R16
863 (ops R16:$dst, R16:$src1, R16:$src2),
864 "cmovbe {$src2, $dst|$dst, $src2}",
865 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
868 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, R16 = [mem16]
869 (ops R16:$dst, R16:$src1, i16mem:$src2),
870 "cmovbe {$src2, $dst|$dst, $src2}",
871 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
874 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, R32 = R32
875 (ops R32:$dst, R32:$src1, R32:$src2),
876 "cmovbe {$src2, $dst|$dst, $src2}",
877 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
880 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, R32 = [mem32]
881 (ops R32:$dst, R32:$src1, i32mem:$src2),
882 "cmovbe {$src2, $dst|$dst, $src2}",
883 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
887 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, R16 = R16
888 (ops R16:$dst, R16:$src1, R16:$src2),
889 "cmova {$src2, $dst|$dst, $src2}",
890 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
893 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, R16 = [mem16]
894 (ops R16:$dst, R16:$src1, i16mem:$src2),
895 "cmova {$src2, $dst|$dst, $src2}",
896 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
899 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, R32 = R32
900 (ops R32:$dst, R32:$src1, R32:$src2),
901 "cmova {$src2, $dst|$dst, $src2}",
902 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
905 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, R32 = [mem32]
906 (ops R32:$dst, R32:$src1, i32mem:$src2),
907 "cmova {$src2, $dst|$dst, $src2}",
908 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
912 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, R16 = R16
913 (ops R16:$dst, R16:$src1, R16:$src2),
914 "cmovl {$src2, $dst|$dst, $src2}",
915 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
918 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, R16 = [mem16]
919 (ops R16:$dst, R16:$src1, i16mem:$src2),
920 "cmovl {$src2, $dst|$dst, $src2}",
921 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
924 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, R32 = R32
925 (ops R32:$dst, R32:$src1, R32:$src2),
926 "cmovl {$src2, $dst|$dst, $src2}",
927 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
930 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, R32 = [mem32]
931 (ops R32:$dst, R32:$src1, i32mem:$src2),
932 "cmovl {$src2, $dst|$dst, $src2}",
933 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
937 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, R16 = R16
938 (ops R16:$dst, R16:$src1, R16:$src2),
939 "cmovge {$src2, $dst|$dst, $src2}",
940 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
943 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, R16 = [mem16]
944 (ops R16:$dst, R16:$src1, i16mem:$src2),
945 "cmovge {$src2, $dst|$dst, $src2}",
946 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
949 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, R32 = R32
950 (ops R32:$dst, R32:$src1, R32:$src2),
951 "cmovge {$src2, $dst|$dst, $src2}",
952 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
955 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, R32 = [mem32]
956 (ops R32:$dst, R32:$src1, i32mem:$src2),
957 "cmovge {$src2, $dst|$dst, $src2}",
958 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
962 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, R16 = R16
963 (ops R16:$dst, R16:$src1, R16:$src2),
964 "cmovle {$src2, $dst|$dst, $src2}",
965 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
968 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, R16 = [mem16]
969 (ops R16:$dst, R16:$src1, i16mem:$src2),
970 "cmovle {$src2, $dst|$dst, $src2}",
971 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
974 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, R32 = R32
975 (ops R32:$dst, R32:$src1, R32:$src2),
976 "cmovle {$src2, $dst|$dst, $src2}",
977 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
980 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, R32 = [mem32]
981 (ops R32:$dst, R32:$src1, i32mem:$src2),
982 "cmovle {$src2, $dst|$dst, $src2}",
983 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
987 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, R16 = R16
988 (ops R16:$dst, R16:$src1, R16:$src2),
989 "cmovg {$src2, $dst|$dst, $src2}",
990 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
993 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, R16 = [mem16]
994 (ops R16:$dst, R16:$src1, i16mem:$src2),
995 "cmovg {$src2, $dst|$dst, $src2}",
996 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
999 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, R32 = R32
1000 (ops R32:$dst, R32:$src1, R32:$src2),
1001 "cmovg {$src2, $dst|$dst, $src2}",
1002 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1005 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, R32 = [mem32]
1006 (ops R32:$dst, R32:$src1, i32mem:$src2),
1007 "cmovg {$src2, $dst|$dst, $src2}",
1008 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1012 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, R16 = R16
1013 (ops R16:$dst, R16:$src1, R16:$src2),
1014 "cmovs {$src2, $dst|$dst, $src2}",
1015 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1018 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, R16 = [mem16]
1019 (ops R16:$dst, R16:$src1, i16mem:$src2),
1020 "cmovs {$src2, $dst|$dst, $src2}",
1021 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1024 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, R32 = R32
1025 (ops R32:$dst, R32:$src1, R32:$src2),
1026 "cmovs {$src2, $dst|$dst, $src2}",
1027 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1030 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, R32 = [mem32]
1031 (ops R32:$dst, R32:$src1, i32mem:$src2),
1032 "cmovs {$src2, $dst|$dst, $src2}",
1033 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1037 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, R16 = R16
1038 (ops R16:$dst, R16:$src1, R16:$src2),
1039 "cmovns {$src2, $dst|$dst, $src2}",
1040 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1043 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, R16 = [mem16]
1044 (ops R16:$dst, R16:$src1, i16mem:$src2),
1045 "cmovns {$src2, $dst|$dst, $src2}",
1046 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1049 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, R32 = R32
1050 (ops R32:$dst, R32:$src1, R32:$src2),
1051 "cmovns {$src2, $dst|$dst, $src2}",
1052 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1055 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, R32 = [mem32]
1056 (ops R32:$dst, R32:$src1, i32mem:$src2),
1057 "cmovns {$src2, $dst|$dst, $src2}",
1058 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1062 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, R16 = R16
1063 (ops R16:$dst, R16:$src1, R16:$src2),
1064 "cmovp {$src2, $dst|$dst, $src2}",
1065 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1068 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, R16 = [mem16]
1069 (ops R16:$dst, R16:$src1, i16mem:$src2),
1070 "cmovp {$src2, $dst|$dst, $src2}",
1071 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1074 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, R32 = R32
1075 (ops R32:$dst, R32:$src1, R32:$src2),
1076 "cmovp {$src2, $dst|$dst, $src2}",
1077 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1080 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, R32 = [mem32]
1081 (ops R32:$dst, R32:$src1, i32mem:$src2),
1082 "cmovp {$src2, $dst|$dst, $src2}",
1083 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1087 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, R16 = R16
1088 (ops R16:$dst, R16:$src1, R16:$src2),
1089 "cmovnp {$src2, $dst|$dst, $src2}",
1090 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1093 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, R16 = [mem16]
1094 (ops R16:$dst, R16:$src1, i16mem:$src2),
1095 "cmovnp {$src2, $dst|$dst, $src2}",
1096 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1099 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, R32 = R32
1100 (ops R32:$dst, R32:$src1, R32:$src2),
1101 "cmovnp {$src2, $dst|$dst, $src2}",
1102 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1105 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, R32 = [mem32]
1106 (ops R32:$dst, R32:$src1, i32mem:$src2),
1107 "cmovnp {$src2, $dst|$dst, $src2}",
1108 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1113 // unary instructions
1114 def NEG8r : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg{b} $dst",
1115 [(set R8:$dst, (ineg R8:$src))]>;
1116 def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg{w} $dst",
1117 [(set R16:$dst, (ineg R16:$src))]>, OpSize;
1118 def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg{l} $dst",
1119 [(set R32:$dst, (ineg R32:$src))]>;
1120 let isTwoAddress = 0 in {
1121 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
1122 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1123 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
1124 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1125 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
1126 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1130 def NOT8r : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not{b} $dst",
1131 [(set R8:$dst, (not R8:$src))]>;
1132 def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not{w} $dst",
1133 [(set R16:$dst, (not R16:$src))]>, OpSize;
1134 def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not{l} $dst",
1135 [(set R32:$dst, (not R32:$src))]>;
1136 let isTwoAddress = 0 in {
1137 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
1138 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1139 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
1140 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1141 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
1142 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1145 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1146 def INC8r : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc{b} $dst",
1147 [(set R8:$dst, (add R8:$src, 1))]>;
1148 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1149 def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc{w} $dst",
1150 [(set R16:$dst, (add R16:$src, 1))]>, OpSize;
1151 def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc{l} $dst",
1152 [(set R32:$dst, (add R32:$src, 1))]>;
1154 let isTwoAddress = 0 in {
1155 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
1156 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1157 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
1158 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
1159 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
1160 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1163 def DEC8r : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec{b} $dst",
1164 [(set R8:$dst, (add R8:$src, -1))]>;
1165 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1166 def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec{w} $dst",
1167 [(set R16:$dst, (add R16:$src, -1))]>, OpSize;
1168 def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec{l} $dst",
1169 [(set R32:$dst, (add R32:$src, -1))]>;
1172 let isTwoAddress = 0 in {
1173 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
1174 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1175 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
1176 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
1177 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
1178 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1181 // Logical operators...
1182 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1183 def AND8rr : I<0x20, MRMDestReg,
1184 (ops R8 :$dst, R8 :$src1, R8 :$src2),
1185 "and{b} {$src2, $dst|$dst, $src2}",
1186 [(set R8:$dst, (and R8:$src1, R8:$src2))]>;
1187 def AND16rr : I<0x21, MRMDestReg,
1188 (ops R16:$dst, R16:$src1, R16:$src2),
1189 "and{w} {$src2, $dst|$dst, $src2}",
1190 [(set R16:$dst, (and R16:$src1, R16:$src2))]>, OpSize;
1191 def AND32rr : I<0x21, MRMDestReg,
1192 (ops R32:$dst, R32:$src1, R32:$src2),
1193 "and{l} {$src2, $dst|$dst, $src2}",
1194 [(set R32:$dst, (and R32:$src1, R32:$src2))]>;
1197 def AND8rm : I<0x22, MRMSrcMem,
1198 (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1199 "and{b} {$src2, $dst|$dst, $src2}",
1200 [(set R8:$dst, (and R8:$src1, (load addr:$src2)))]>;
1201 def AND16rm : I<0x23, MRMSrcMem,
1202 (ops R16:$dst, R16:$src1, i16mem:$src2),
1203 "and{w} {$src2, $dst|$dst, $src2}",
1204 [(set R16:$dst, (and R16:$src1, (load addr:$src2)))]>, OpSize;
1205 def AND32rm : I<0x23, MRMSrcMem,
1206 (ops R32:$dst, R32:$src1, i32mem:$src2),
1207 "and{l} {$src2, $dst|$dst, $src2}",
1208 [(set R32:$dst, (and R32:$src1, (load addr:$src2)))]>;
1210 def AND8ri : Ii8<0x80, MRM4r,
1211 (ops R8 :$dst, R8 :$src1, i8imm :$src2),
1212 "and{b} {$src2, $dst|$dst, $src2}",
1213 [(set R8:$dst, (and R8:$src1, imm:$src2))]>;
1214 def AND16ri : Ii16<0x81, MRM4r,
1215 (ops R16:$dst, R16:$src1, i16imm:$src2),
1216 "and{w} {$src2, $dst|$dst, $src2}",
1217 [(set R16:$dst, (and R16:$src1, imm:$src2))]>, OpSize;
1218 def AND32ri : Ii32<0x81, MRM4r,
1219 (ops R32:$dst, R32:$src1, i32imm:$src2),
1220 "and{l} {$src2, $dst|$dst, $src2}",
1221 [(set R32:$dst, (and R32:$src1, imm:$src2))]>;
1222 def AND16ri8 : Ii8<0x83, MRM4r,
1223 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1224 "and{w} {$src2, $dst|$dst, $src2}",
1225 [(set R16:$dst, (and R16:$src1, i16immSExt8:$src2))]>,
1227 def AND32ri8 : Ii8<0x83, MRM4r,
1228 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1229 "and{l} {$src2, $dst|$dst, $src2}",
1230 [(set R32:$dst, (and R32:$src1, i32immSExt8:$src2))]>;
1232 let isTwoAddress = 0 in {
1233 def AND8mr : I<0x20, MRMDestMem,
1234 (ops i8mem :$dst, R8 :$src),
1235 "and{b} {$src, $dst|$dst, $src}",
1236 [(store (and (load addr:$dst), R8:$src), addr:$dst)]>;
1237 def AND16mr : I<0x21, MRMDestMem,
1238 (ops i16mem:$dst, R16:$src),
1239 "and{w} {$src, $dst|$dst, $src}",
1240 [(store (and (load addr:$dst), R16:$src), addr:$dst)]>,
1242 def AND32mr : I<0x21, MRMDestMem,
1243 (ops i32mem:$dst, R32:$src),
1244 "and{l} {$src, $dst|$dst, $src}",
1245 [(store (and (load addr:$dst), R32:$src), addr:$dst)]>;
1246 def AND8mi : Ii8<0x80, MRM4m,
1247 (ops i8mem :$dst, i8imm :$src),
1248 "and{b} {$src, $dst|$dst, $src}",
1249 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1250 def AND16mi : Ii16<0x81, MRM4m,
1251 (ops i16mem:$dst, i16imm:$src),
1252 "and{w} {$src, $dst|$dst, $src}",
1253 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1255 def AND32mi : Ii32<0x81, MRM4m,
1256 (ops i32mem:$dst, i32imm:$src),
1257 "and{l} {$src, $dst|$dst, $src}",
1258 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1259 def AND16mi8 : Ii8<0x83, MRM4m,
1260 (ops i16mem:$dst, i16i8imm :$src),
1261 "and{w} {$src, $dst|$dst, $src}",
1262 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1264 def AND32mi8 : Ii8<0x83, MRM4m,
1265 (ops i32mem:$dst, i32i8imm :$src),
1266 "and{l} {$src, $dst|$dst, $src}",
1267 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1271 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1272 def OR8rr : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1273 "or{b} {$src2, $dst|$dst, $src2}",
1274 [(set R8:$dst, (or R8:$src1, R8:$src2))]>;
1275 def OR16rr : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1276 "or{w} {$src2, $dst|$dst, $src2}",
1277 [(set R16:$dst, (or R16:$src1, R16:$src2))]>, OpSize;
1278 def OR32rr : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1279 "or{l} {$src2, $dst|$dst, $src2}",
1280 [(set R32:$dst, (or R32:$src1, R32:$src2))]>;
1282 def OR8rm : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1283 "or{b} {$src2, $dst|$dst, $src2}",
1284 [(set R8:$dst, (or R8:$src1, (load addr:$src2)))]>;
1285 def OR16rm : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
1286 "or{w} {$src2, $dst|$dst, $src2}",
1287 [(set R16:$dst, (or R16:$src1, (load addr:$src2)))]>, OpSize;
1288 def OR32rm : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
1289 "or{l} {$src2, $dst|$dst, $src2}",
1290 [(set R32:$dst, (or R32:$src1, (load addr:$src2)))]>;
1292 def OR8ri : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1293 "or{b} {$src2, $dst|$dst, $src2}",
1294 [(set R8:$dst, (or R8:$src1, imm:$src2))]>;
1295 def OR16ri : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1296 "or{w} {$src2, $dst|$dst, $src2}",
1297 [(set R16:$dst, (or R16:$src1, imm:$src2))]>, OpSize;
1298 def OR32ri : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1299 "or{l} {$src2, $dst|$dst, $src2}",
1300 [(set R32:$dst, (or R32:$src1, imm:$src2))]>;
1302 def OR16ri8 : Ii8<0x83, MRM1r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1303 "or{w} {$src2, $dst|$dst, $src2}",
1304 [(set R16:$dst, (or R16:$src1, i16immSExt8:$src2))]>, OpSize;
1305 def OR32ri8 : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1306 "or{l} {$src2, $dst|$dst, $src2}",
1307 [(set R32:$dst, (or R32:$src1, i32immSExt8:$src2))]>;
1308 let isTwoAddress = 0 in {
1309 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
1310 "or{b} {$src, $dst|$dst, $src}",
1311 [(store (or (load addr:$dst), R8:$src), addr:$dst)]>;
1312 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
1313 "or{w} {$src, $dst|$dst, $src}",
1314 [(store (or (load addr:$dst), R16:$src), addr:$dst)]>, OpSize;
1315 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
1316 "or{l} {$src, $dst|$dst, $src}",
1317 [(store (or (load addr:$dst), R32:$src), addr:$dst)]>;
1318 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
1319 "or{b} {$src, $dst|$dst, $src}",
1320 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1321 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
1322 "or{w} {$src, $dst|$dst, $src}",
1323 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1325 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
1326 "or{l} {$src, $dst|$dst, $src}",
1327 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1328 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1329 "or{w} {$src, $dst|$dst, $src}",
1330 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1332 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1333 "or{l} {$src, $dst|$dst, $src}",
1334 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1338 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1339 def XOR8rr : I<0x30, MRMDestReg,
1340 (ops R8 :$dst, R8 :$src1, R8 :$src2),
1341 "xor{b} {$src2, $dst|$dst, $src2}",
1342 [(set R8:$dst, (xor R8:$src1, R8:$src2))]>;
1343 def XOR16rr : I<0x31, MRMDestReg,
1344 (ops R16:$dst, R16:$src1, R16:$src2),
1345 "xor{w} {$src2, $dst|$dst, $src2}",
1346 [(set R16:$dst, (xor R16:$src1, R16:$src2))]>, OpSize;
1347 def XOR32rr : I<0x31, MRMDestReg,
1348 (ops R32:$dst, R32:$src1, R32:$src2),
1349 "xor{l} {$src2, $dst|$dst, $src2}",
1350 [(set R32:$dst, (xor R32:$src1, R32:$src2))]>;
1353 def XOR8rm : I<0x32, MRMSrcMem ,
1354 (ops R8 :$dst, R8:$src1, i8mem :$src2),
1355 "xor{b} {$src2, $dst|$dst, $src2}",
1356 [(set R8:$dst, (xor R8:$src1, (load addr:$src2)))]>;
1357 def XOR16rm : I<0x33, MRMSrcMem ,
1358 (ops R16:$dst, R16:$src1, i16mem:$src2),
1359 "xor{w} {$src2, $dst|$dst, $src2}",
1360 [(set R16:$dst, (xor R16:$src1, (load addr:$src2)))]>, OpSize;
1361 def XOR32rm : I<0x33, MRMSrcMem ,
1362 (ops R32:$dst, R32:$src1, i32mem:$src2),
1363 "xor{l} {$src2, $dst|$dst, $src2}",
1364 [(set R32:$dst, (xor R32:$src1, (load addr:$src2)))]>;
1366 def XOR8ri : Ii8<0x80, MRM6r,
1367 (ops R8:$dst, R8:$src1, i8imm:$src2),
1368 "xor{b} {$src2, $dst|$dst, $src2}",
1369 [(set R8:$dst, (xor R8:$src1, imm:$src2))]>;
1370 def XOR16ri : Ii16<0x81, MRM6r,
1371 (ops R16:$dst, R16:$src1, i16imm:$src2),
1372 "xor{w} {$src2, $dst|$dst, $src2}",
1373 [(set R16:$dst, (xor R16:$src1, imm:$src2))]>, OpSize;
1374 def XOR32ri : Ii32<0x81, MRM6r,
1375 (ops R32:$dst, R32:$src1, i32imm:$src2),
1376 "xor{l} {$src2, $dst|$dst, $src2}",
1377 [(set R32:$dst, (xor R32:$src1, imm:$src2))]>;
1378 def XOR16ri8 : Ii8<0x83, MRM6r,
1379 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1380 "xor{w} {$src2, $dst|$dst, $src2}",
1381 [(set R16:$dst, (xor R16:$src1, i16immSExt8:$src2))]>,
1383 def XOR32ri8 : Ii8<0x83, MRM6r,
1384 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1385 "xor{l} {$src2, $dst|$dst, $src2}",
1386 [(set R32:$dst, (xor R32:$src1, i32immSExt8:$src2))]>;
1387 let isTwoAddress = 0 in {
1388 def XOR8mr : I<0x30, MRMDestMem,
1389 (ops i8mem :$dst, R8 :$src),
1390 "xor{b} {$src, $dst|$dst, $src}",
1391 [(store (xor (load addr:$dst), R8:$src), addr:$dst)]>;
1392 def XOR16mr : I<0x31, MRMDestMem,
1393 (ops i16mem:$dst, R16:$src),
1394 "xor{w} {$src, $dst|$dst, $src}",
1395 [(store (xor (load addr:$dst), R16:$src), addr:$dst)]>,
1397 def XOR32mr : I<0x31, MRMDestMem,
1398 (ops i32mem:$dst, R32:$src),
1399 "xor{l} {$src, $dst|$dst, $src}",
1400 [(store (xor (load addr:$dst), R32:$src), addr:$dst)]>;
1401 def XOR8mi : Ii8<0x80, MRM6m,
1402 (ops i8mem :$dst, i8imm :$src),
1403 "xor{b} {$src, $dst|$dst, $src}",
1404 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1405 def XOR16mi : Ii16<0x81, MRM6m,
1406 (ops i16mem:$dst, i16imm:$src),
1407 "xor{w} {$src, $dst|$dst, $src}",
1408 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1410 def XOR32mi : Ii32<0x81, MRM6m,
1411 (ops i32mem:$dst, i32imm:$src),
1412 "xor{l} {$src, $dst|$dst, $src}",
1413 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1414 def XOR16mi8 : Ii8<0x83, MRM6m,
1415 (ops i16mem:$dst, i16i8imm :$src),
1416 "xor{w} {$src, $dst|$dst, $src}",
1417 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1419 def XOR32mi8 : Ii8<0x83, MRM6m,
1420 (ops i32mem:$dst, i32i8imm :$src),
1421 "xor{l} {$src, $dst|$dst, $src}",
1422 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1425 // Shift instructions
1426 def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
1427 "shl{b} {%cl, $dst|$dst, %CL}",
1428 [(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
1429 def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src),
1430 "shl{w} {%cl, $dst|$dst, %CL}",
1431 [(set R16:$dst, (shl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1432 def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src),
1433 "shl{l} {%cl, $dst|$dst, %CL}",
1434 [(set R32:$dst, (shl R32:$src, CL))]>, Imp<[CL],[]>;
1436 def SHL8ri : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1437 "shl{b} {$src2, $dst|$dst, $src2}",
1438 [(set R8:$dst, (shl R8:$src1, (i8 imm:$src2)))]>;
1439 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1440 def SHL16ri : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1441 "shl{w} {$src2, $dst|$dst, $src2}",
1442 [(set R16:$dst, (shl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1443 def SHL32ri : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1444 "shl{l} {$src2, $dst|$dst, $src2}",
1445 [(set R32:$dst, (shl R32:$src1, (i8 imm:$src2)))]>;
1448 let isTwoAddress = 0 in {
1449 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
1450 "shl{b} {%cl, $dst|$dst, %CL}",
1451 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1453 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
1454 "shl{w} {%cl, $dst|$dst, %CL}",
1455 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1456 Imp<[CL],[]>, OpSize;
1457 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
1458 "shl{l} {%cl, $dst|$dst, %CL}",
1459 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1461 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
1462 "shl{b} {$src, $dst|$dst, $src}",
1463 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1464 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
1465 "shl{w} {$src, $dst|$dst, $src}",
1466 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1468 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
1469 "shl{l} {$src, $dst|$dst, $src}",
1470 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1473 def SHR8rCL : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src),
1474 "shr{b} {%cl, $dst|$dst, %CL}",
1475 [(set R8:$dst, (srl R8:$src, CL))]>, Imp<[CL],[]>;
1476 def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src),
1477 "shr{w} {%cl, $dst|$dst, %CL}",
1478 [(set R16:$dst, (srl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1479 def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src),
1480 "shr{l} {%cl, $dst|$dst, %CL}",
1481 [(set R32:$dst, (srl R32:$src, CL))]>, Imp<[CL],[]>;
1483 def SHR8ri : Ii8<0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1484 "shr{b} {$src2, $dst|$dst, $src2}",
1485 [(set R8:$dst, (srl R8:$src1, (i8 imm:$src2)))]>;
1486 def SHR16ri : Ii8<0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1487 "shr{w} {$src2, $dst|$dst, $src2}",
1488 [(set R16:$dst, (srl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1489 def SHR32ri : Ii8<0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1490 "shr{l} {$src2, $dst|$dst, $src2}",
1491 [(set R32:$dst, (srl R32:$src1, (i8 imm:$src2)))]>;
1493 let isTwoAddress = 0 in {
1494 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
1495 "shr{b} {%cl, $dst|$dst, %CL}",
1496 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1498 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
1499 "shr{w} {%cl, $dst|$dst, %CL}",
1500 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1501 Imp<[CL],[]>, OpSize;
1502 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
1503 "shr{l} {%cl, $dst|$dst, %CL}",
1504 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1506 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
1507 "shr{b} {$src, $dst|$dst, $src}",
1508 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1509 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
1510 "shr{w} {$src, $dst|$dst, $src}",
1511 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1513 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
1514 "shr{l} {$src, $dst|$dst, $src}",
1515 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1518 def SAR8rCL : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src),
1519 "sar{b} {%cl, $dst|$dst, %CL}",
1520 [(set R8:$dst, (sra R8:$src, CL))]>, Imp<[CL],[]>;
1521 def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src),
1522 "sar{w} {%cl, $dst|$dst, %CL}",
1523 [(set R16:$dst, (sra R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1524 def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src),
1525 "sar{l} {%cl, $dst|$dst, %CL}",
1526 [(set R32:$dst, (sra R32:$src, CL))]>, Imp<[CL],[]>;
1528 def SAR8ri : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1529 "sar{b} {$src2, $dst|$dst, $src2}",
1530 [(set R8:$dst, (sra R8:$src1, (i8 imm:$src2)))]>;
1531 def SAR16ri : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1532 "sar{w} {$src2, $dst|$dst, $src2}",
1533 [(set R16:$dst, (sra R16:$src1, (i8 imm:$src2)))]>,
1535 def SAR32ri : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1536 "sar{l} {$src2, $dst|$dst, $src2}",
1537 [(set R32:$dst, (sra R32:$src1, (i8 imm:$src2)))]>;
1538 let isTwoAddress = 0 in {
1539 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
1540 "sar{b} {%cl, $dst|$dst, %CL}",
1541 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1543 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
1544 "sar{w} {%cl, $dst|$dst, %CL}",
1545 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1546 Imp<[CL],[]>, OpSize;
1547 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
1548 "sar{l} {%cl, $dst|$dst, %CL}",
1549 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1551 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
1552 "sar{b} {$src, $dst|$dst, $src}",
1553 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1554 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
1555 "sar{w} {$src, $dst|$dst, $src}",
1556 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1558 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
1559 "sar{l} {$src, $dst|$dst, $src}",
1560 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1563 // Rotate instructions
1564 // FIXME: provide shorter instructions when imm8 == 1
1565 def ROL8rCL : I<0xD2, MRM0r, (ops R8 :$dst, R8 :$src),
1566 "rol{b} {%cl, $dst|$dst, %CL}",
1567 [(set R8:$dst, (rotl R8:$src, CL))]>, Imp<[CL],[]>;
1568 def ROL16rCL : I<0xD3, MRM0r, (ops R16:$dst, R16:$src),
1569 "rol{w} {%cl, $dst|$dst, %CL}",
1570 [(set R16:$dst, (rotl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1571 def ROL32rCL : I<0xD3, MRM0r, (ops R32:$dst, R32:$src),
1572 "rol{l} {%cl, $dst|$dst, %CL}",
1573 [(set R32:$dst, (rotl R32:$src, CL))]>, Imp<[CL],[]>;
1575 def ROL8ri : Ii8<0xC0, MRM0r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1576 "rol{b} {$src2, $dst|$dst, $src2}",
1577 [(set R8:$dst, (rotl R8:$src1, (i8 imm:$src2)))]>;
1578 def ROL16ri : Ii8<0xC1, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1579 "rol{w} {$src2, $dst|$dst, $src2}",
1580 [(set R16:$dst, (rotl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1581 def ROL32ri : Ii8<0xC1, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1582 "rol{l} {$src2, $dst|$dst, $src2}",
1583 [(set R32:$dst, (rotl R32:$src1, (i8 imm:$src2)))]>;
1585 let isTwoAddress = 0 in {
1586 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
1587 "rol{b} {%cl, $dst|$dst, %CL}",
1588 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1590 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
1591 "rol{w} {%cl, $dst|$dst, %CL}",
1592 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1593 Imp<[CL],[]>, OpSize;
1594 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
1595 "rol{l} {%cl, $dst|$dst, %CL}",
1596 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1598 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
1599 "rol{b} {$src, $dst|$dst, $src}",
1600 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1601 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
1602 "rol{w} {$src, $dst|$dst, $src}",
1603 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1605 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
1606 "rol{l} {$src, $dst|$dst, $src}",
1607 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1610 def ROR8rCL : I<0xD2, MRM1r, (ops R8 :$dst, R8 :$src),
1611 "ror{b} {%cl, $dst|$dst, %CL}",
1612 [(set R8:$dst, (rotr R8:$src, CL))]>, Imp<[CL],[]>;
1613 def ROR16rCL : I<0xD3, MRM1r, (ops R16:$dst, R16:$src),
1614 "ror{w} {%cl, $dst|$dst, %CL}",
1615 [(set R16:$dst, (rotr R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1616 def ROR32rCL : I<0xD3, MRM1r, (ops R32:$dst, R32:$src),
1617 "ror{l} {%cl, $dst|$dst, %CL}",
1618 [(set R32:$dst, (rotr R32:$src, CL))]>, Imp<[CL],[]>;
1620 def ROR8ri : Ii8<0xC0, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1621 "ror{b} {$src2, $dst|$dst, $src2}",
1622 [(set R8:$dst, (rotr R8:$src1, (i8 imm:$src2)))]>;
1623 def ROR16ri : Ii8<0xC1, MRM1r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1624 "ror{w} {$src2, $dst|$dst, $src2}",
1625 [(set R16:$dst, (rotr R16:$src1, (i8 imm:$src2)))]>, OpSize;
1626 def ROR32ri : Ii8<0xC1, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1627 "ror{l} {$src2, $dst|$dst, $src2}",
1628 [(set R32:$dst, (rotr R32:$src1, (i8 imm:$src2)))]>;
1629 let isTwoAddress = 0 in {
1630 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
1631 "ror{b} {%cl, $dst|$dst, %CL}",
1632 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1634 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
1635 "ror{w} {%cl, $dst|$dst, %CL}",
1636 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1637 Imp<[CL],[]>, OpSize;
1638 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
1639 "ror{l} {%cl, $dst|$dst, %CL}",
1640 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1642 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
1643 "ror{b} {$src, $dst|$dst, $src}",
1644 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1645 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
1646 "ror{w} {$src, $dst|$dst, $src}",
1647 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1649 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
1650 "ror{l} {$src, $dst|$dst, $src}",
1651 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1656 // Double shift instructions (generalizations of rotate)
1657 def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1658 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1659 [(set R32:$dst, (X86shld R32:$src1, R32:$src2, CL))]>,
1661 def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1662 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1663 [(set R32:$dst, (X86shrd R32:$src1, R32:$src2, CL))]>,
1665 def SHLD16rrCL : I<0xA5, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1666 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1667 [(set R16:$dst, (X86shld R16:$src1, R16:$src2, CL))]>,
1668 Imp<[CL],[]>, TB, OpSize;
1669 def SHRD16rrCL : I<0xAD, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1670 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1671 [(set R16:$dst, (X86shrd R16:$src1, R16:$src2, CL))]>,
1672 Imp<[CL],[]>, TB, OpSize;
1674 let isCommutable = 1 in { // These instructions commute to each other.
1675 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1676 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
1677 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1678 [(set R32:$dst, (X86shld R32:$src1, R32:$src2,
1681 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1682 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
1683 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1684 [(set R32:$dst, (X86shrd R32:$src1, R32:$src2,
1687 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1688 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
1689 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1690 [(set R16:$dst, (X86shld R16:$src1, R16:$src2,
1693 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1694 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
1695 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1696 [(set R16:$dst, (X86shrd R16:$src1, R16:$src2,
1701 let isTwoAddress = 0 in {
1702 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1703 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1704 [(store (X86shld (loadi32 addr:$dst), R32:$src2, CL),
1707 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1708 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1709 [(store (X86shrd (loadi32 addr:$dst), R32:$src2, CL),
1712 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1713 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
1714 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1715 [(store (X86shld (loadi32 addr:$dst), R32:$src2,
1716 (i8 imm:$src3)), addr:$dst)]>,
1718 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1719 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
1720 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1721 [(store (X86shrd (loadi32 addr:$dst), R32:$src2,
1722 (i8 imm:$src3)), addr:$dst)]>,
1725 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1726 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1727 [(store (X86shld (loadi16 addr:$dst), R16:$src2, CL),
1729 Imp<[CL],[]>, TB, OpSize;
1730 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1731 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1732 [(store (X86shrd (loadi16 addr:$dst), R16:$src2, CL),
1734 Imp<[CL],[]>, TB, OpSize;
1735 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1736 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
1737 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1738 [(store (X86shld (loadi16 addr:$dst), R16:$src2,
1739 (i8 imm:$src3)), addr:$dst)]>,
1741 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1742 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
1743 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1744 [(store (X86shrd (loadi16 addr:$dst), R16:$src2,
1745 (i8 imm:$src3)), addr:$dst)]>,
1751 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1752 def ADD8rr : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1753 "add{b} {$src2, $dst|$dst, $src2}",
1754 [(set R8:$dst, (add R8:$src1, R8:$src2))]>;
1755 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1756 def ADD16rr : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1757 "add{w} {$src2, $dst|$dst, $src2}",
1758 [(set R16:$dst, (add R16:$src1, R16:$src2))]>, OpSize;
1759 def ADD32rr : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1760 "add{l} {$src2, $dst|$dst, $src2}",
1761 [(set R32:$dst, (add R32:$src1, R32:$src2))]>;
1762 } // end isConvertibleToThreeAddress
1763 } // end isCommutable
1764 def ADD8rm : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1765 "add{b} {$src2, $dst|$dst, $src2}",
1766 [(set R8:$dst, (add R8:$src1, (load addr:$src2)))]>;
1767 def ADD16rm : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1768 "add{w} {$src2, $dst|$dst, $src2}",
1769 [(set R16:$dst, (add R16:$src1, (load addr:$src2)))]>, OpSize;
1770 def ADD32rm : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1771 "add{l} {$src2, $dst|$dst, $src2}",
1772 [(set R32:$dst, (add R32:$src1, (load addr:$src2)))]>;
1774 def ADD8ri : Ii8<0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1775 "add{b} {$src2, $dst|$dst, $src2}",
1776 [(set R8:$dst, (add R8:$src1, imm:$src2))]>;
1778 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1779 def ADD16ri : Ii16<0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1780 "add{w} {$src2, $dst|$dst, $src2}",
1781 [(set R16:$dst, (add R16:$src1, imm:$src2))]>, OpSize;
1782 def ADD32ri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1783 "add{l} {$src2, $dst|$dst, $src2}",
1784 [(set R32:$dst, (add R32:$src1, imm:$src2))]>;
1787 // FIXME: move ADD16ri8 above ADD16ri to optimize for space.
1788 def ADD16ri8 : Ii8<0x83, MRM0r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1789 "add{w} {$src2, $dst|$dst, $src2}",
1790 [(set R16:$dst, (add R16:$src1, i16immSExt8:$src2))]>,
1792 def ADD32ri8 : Ii8<0x83, MRM0r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1793 "add{l} {$src2, $dst|$dst, $src2}",
1794 [(set R32:$dst, (add R32:$src1, i32immSExt8:$src2))]>;
1796 let isTwoAddress = 0 in {
1797 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
1798 "add{b} {$src2, $dst|$dst, $src2}",
1799 [(store (add (load addr:$dst), R8:$src2), addr:$dst)]>;
1800 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1801 "add{w} {$src2, $dst|$dst, $src2}",
1802 [(store (add (load addr:$dst), R16:$src2), addr:$dst)]>,
1804 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1805 "add{l} {$src2, $dst|$dst, $src2}",
1806 [(store (add (load addr:$dst), R32:$src2), addr:$dst)]>;
1807 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
1808 "add{b} {$src2, $dst|$dst, $src2}",
1809 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1810 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
1811 "add{w} {$src2, $dst|$dst, $src2}",
1812 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1814 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
1815 "add{l} {$src2, $dst|$dst, $src2}",
1816 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1817 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1818 "add{w} {$src2, $dst|$dst, $src2}",
1819 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1821 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1822 "add{l} {$src2, $dst|$dst, $src2}",
1823 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1826 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1827 def ADC32rr : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1828 "adc{l} {$src2, $dst|$dst, $src2}",
1829 [(set R32:$dst, (adde R32:$src1, R32:$src2))]>;
1831 def ADC32rm : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
1832 "adc{l} {$src2, $dst|$dst, $src2}",
1833 [(set R32:$dst, (adde R32:$src1, (load addr:$src2)))]>;
1834 def ADC32ri : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1835 "adc{l} {$src2, $dst|$dst, $src2}",
1836 [(set R32:$dst, (adde R32:$src1, imm:$src2))]>;
1837 def ADC32ri8 : Ii8<0x83, MRM2r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1838 "adc{l} {$src2, $dst|$dst, $src2}",
1839 [(set R32:$dst, (adde R32:$src1, i32immSExt8:$src2))]>;
1841 let isTwoAddress = 0 in {
1842 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1843 "adc{l} {$src2, $dst|$dst, $src2}",
1844 [(store (adde (load addr:$dst), R32:$src2), addr:$dst)]>;
1845 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
1846 "adc{l} {$src2, $dst|$dst, $src2}",
1847 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1848 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1849 "adc{l} {$src2, $dst|$dst, $src2}",
1850 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1853 def SUB8rr : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1854 "sub{b} {$src2, $dst|$dst, $src2}",
1855 [(set R8:$dst, (sub R8:$src1, R8:$src2))]>;
1856 def SUB16rr : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1857 "sub{w} {$src2, $dst|$dst, $src2}",
1858 [(set R16:$dst, (sub R16:$src1, R16:$src2))]>, OpSize;
1859 def SUB32rr : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1860 "sub{l} {$src2, $dst|$dst, $src2}",
1861 [(set R32:$dst, (sub R32:$src1, R32:$src2))]>;
1862 def SUB8rm : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1863 "sub{b} {$src2, $dst|$dst, $src2}",
1864 [(set R8:$dst, (sub R8:$src1, (load addr:$src2)))]>;
1865 def SUB16rm : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1866 "sub{w} {$src2, $dst|$dst, $src2}",
1867 [(set R16:$dst, (sub R16:$src1, (load addr:$src2)))]>, OpSize;
1868 def SUB32rm : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1869 "sub{l} {$src2, $dst|$dst, $src2}",
1870 [(set R32:$dst, (sub R32:$src1, (load addr:$src2)))]>;
1872 def SUB8ri : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1873 "sub{b} {$src2, $dst|$dst, $src2}",
1874 [(set R8:$dst, (sub R8:$src1, imm:$src2))]>;
1875 def SUB16ri : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1876 "sub{w} {$src2, $dst|$dst, $src2}",
1877 [(set R16:$dst, (sub R16:$src1, imm:$src2))]>, OpSize;
1878 def SUB32ri : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1879 "sub{l} {$src2, $dst|$dst, $src2}",
1880 [(set R32:$dst, (sub R32:$src1, imm:$src2))]>;
1881 def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1882 "sub{w} {$src2, $dst|$dst, $src2}",
1883 [(set R16:$dst, (sub R16:$src1, i16immSExt8:$src2))]>,
1885 def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1886 "sub{l} {$src2, $dst|$dst, $src2}",
1887 [(set R32:$dst, (sub R32:$src1, i32immSExt8:$src2))]>;
1888 let isTwoAddress = 0 in {
1889 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
1890 "sub{b} {$src2, $dst|$dst, $src2}",
1891 [(store (sub (load addr:$dst), R8:$src2), addr:$dst)]>;
1892 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1893 "sub{w} {$src2, $dst|$dst, $src2}",
1894 [(store (sub (load addr:$dst), R16:$src2), addr:$dst)]>,
1896 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1897 "sub{l} {$src2, $dst|$dst, $src2}",
1898 [(store (sub (load addr:$dst), R32:$src2), addr:$dst)]>;
1899 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
1900 "sub{b} {$src2, $dst|$dst, $src2}",
1901 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1902 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
1903 "sub{w} {$src2, $dst|$dst, $src2}",
1904 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1906 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
1907 "sub{l} {$src2, $dst|$dst, $src2}",
1908 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1909 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1910 "sub{w} {$src2, $dst|$dst, $src2}",
1911 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1913 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1914 "sub{l} {$src2, $dst|$dst, $src2}",
1915 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1918 def SBB32rr : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1919 "sbb{l} {$src2, $dst|$dst, $src2}",
1920 [(set R32:$dst, (sube R32:$src1, R32:$src2))]>;
1922 let isTwoAddress = 0 in {
1923 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1924 "sbb{l} {$src2, $dst|$dst, $src2}",
1925 [(store (sube (load addr:$dst), R32:$src2), addr:$dst)]>;
1926 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
1927 "sbb{b} {$src2, $dst|$dst, $src2}",
1928 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1929 def SBB16mi : Ii32<0x81, MRM3m, (ops i16mem:$dst, i16imm:$src2),
1930 "sbb{w} {$src2, $dst|$dst, $src2}",
1931 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1933 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
1934 "sbb{l} {$src2, $dst|$dst, $src2}",
1935 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1936 def SBB16mi8 : Ii8<0x83, MRM3m, (ops i16mem:$dst, i16i8imm :$src2),
1937 "sbb{w} {$src2, $dst|$dst, $src2}",
1938 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1940 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
1941 "sbb{l} {$src2, $dst|$dst, $src2}",
1942 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1944 def SBB8ri : Ii8<0x80, MRM3r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1945 "sbb{b} {$src2, $dst|$dst, $src2}",
1946 [(set R8:$dst, (sube R8:$src1, imm:$src2))]>;
1947 def SBB16ri : Ii16<0x81, MRM3r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1948 "sbb{w} {$src2, $dst|$dst, $src2}",
1949 [(set R16:$dst, (sube R16:$src1, imm:$src2))]>, OpSize;
1951 def SBB32rm : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1952 "sbb{l} {$src2, $dst|$dst, $src2}",
1953 [(set R32:$dst, (sube R32:$src1, (load addr:$src2)))]>;
1954 def SBB32ri : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1955 "sbb{l} {$src2, $dst|$dst, $src2}",
1956 [(set R32:$dst, (sube R32:$src1, imm:$src2))]>;
1958 def SBB16ri8 : Ii8<0x83, MRM3r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1959 "sbb{w} {$src2, $dst|$dst, $src2}",
1960 [(set R16:$dst, (sube R16:$src1, i16immSExt8:$src2))]>,
1962 def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1963 "sbb{l} {$src2, $dst|$dst, $src2}",
1964 [(set R32:$dst, (sube R32:$src1, i32immSExt8:$src2))]>;
1966 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
1967 def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
1968 "imul{w} {$src2, $dst|$dst, $src2}",
1969 [(set R16:$dst, (mul R16:$src1, R16:$src2))]>, TB, OpSize;
1970 def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
1971 "imul{l} {$src2, $dst|$dst, $src2}",
1972 [(set R32:$dst, (mul R32:$src1, R32:$src2))]>, TB;
1974 def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1975 "imul{w} {$src2, $dst|$dst, $src2}",
1976 [(set R16:$dst, (mul R16:$src1, (load addr:$src2)))]>,
1978 def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1979 "imul{l} {$src2, $dst|$dst, $src2}",
1980 [(set R32:$dst, (mul R32:$src1, (load addr:$src2)))]>, TB;
1982 } // end Two Address instructions
1984 // Suprisingly enough, these are not two address instructions!
1985 def IMUL16rri : Ii16<0x69, MRMSrcReg, // R16 = R16*I16
1986 (ops R16:$dst, R16:$src1, i16imm:$src2),
1987 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1988 [(set R16:$dst, (mul R16:$src1, imm:$src2))]>, OpSize;
1989 def IMUL32rri : Ii32<0x69, MRMSrcReg, // R32 = R32*I32
1990 (ops R32:$dst, R32:$src1, i32imm:$src2),
1991 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1992 [(set R32:$dst, (mul R32:$src1, imm:$src2))]>;
1993 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // R16 = R16*I8
1994 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1995 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1996 [(set R16:$dst, (mul R16:$src1, i16immSExt8:$src2))]>,
1998 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // R32 = R32*I8
1999 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
2000 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2001 [(set R32:$dst, (mul R32:$src1, i32immSExt8:$src2))]>;
2003 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // R16 = [mem16]*I16
2004 (ops R16:$dst, i16mem:$src1, i16imm:$src2),
2005 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2006 [(set R16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2008 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // R32 = [mem32]*I32
2009 (ops R32:$dst, i32mem:$src1, i32imm:$src2),
2010 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2011 [(set R32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2012 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // R16 = [mem16]*I8
2013 (ops R16:$dst, i16mem:$src1, i16i8imm :$src2),
2014 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2015 [(set R16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2017 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // R32 = [mem32]*I8
2018 (ops R32:$dst, i32mem:$src1, i32i8imm: $src2),
2019 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2020 [(set R32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2022 //===----------------------------------------------------------------------===//
2023 // Test instructions are just like AND, except they don't generate a result.
2025 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2026 def TEST8rr : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
2027 "test{b} {$src2, $src1|$src1, $src2}",
2028 [(X86test R8:$src1, R8:$src2)]>;
2029 def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
2030 "test{w} {$src2, $src1|$src1, $src2}",
2031 [(X86test R16:$src1, R16:$src2)]>, OpSize;
2032 def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
2033 "test{l} {$src2, $src1|$src1, $src2}",
2034 [(X86test R32:$src1, R32:$src2)]>;
2036 def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
2037 "test{b} {$src2, $src1|$src1, $src2}",
2038 [(X86test (loadi8 addr:$src1), R8:$src2)]>;
2039 def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
2040 "test{w} {$src2, $src1|$src1, $src2}",
2041 [(X86test (loadi16 addr:$src1), R16:$src2)]>,
2043 def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
2044 "test{l} {$src2, $src1|$src1, $src2}",
2045 [(X86test (loadi32 addr:$src1), R32:$src2)]>;
2046 def TEST8rm : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
2047 "test{b} {$src2, $src1|$src1, $src2}",
2048 [(X86test R8:$src1, (loadi8 addr:$src2))]>;
2049 def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
2050 "test{w} {$src2, $src1|$src1, $src2}",
2051 [(X86test R16:$src1, (loadi16 addr:$src2))]>,
2053 def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
2054 "test{l} {$src2, $src1|$src1, $src2}",
2055 [(X86test R32:$src1, (loadi32 addr:$src2))]>;
2057 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = R8 & imm8
2058 (ops R8:$src1, i8imm:$src2),
2059 "test{b} {$src2, $src1|$src1, $src2}",
2060 [(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 [(X86test R16:$src1, imm:$src2)]>, OpSize;
2065 def TEST32ri : Ii32<0xF7, MRM0r, // flags = R32 & imm32
2066 (ops R32:$src1, i32imm:$src2),
2067 "test{l} {$src2, $src1|$src1, $src2}",
2068 [(X86test R32:$src1, imm:$src2)]>;
2069 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2070 (ops i8mem:$src1, i8imm:$src2),
2071 "test{b} {$src2, $src1|$src1, $src2}",
2072 [(X86test (loadi8 addr:$src1), imm:$src2)]>;
2073 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2074 (ops i16mem:$src1, i16imm:$src2),
2075 "test{w} {$src2, $src1|$src1, $src2}",
2076 [(X86test (loadi16 addr:$src1), imm:$src2)]>,
2078 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2079 (ops i32mem:$src1, i32imm:$src2),
2080 "test{l} {$src2, $src1|$src1, $src2}",
2081 [(X86test (loadi32 addr:$src1), imm:$src2)]>;
2084 // Condition code ops, incl. set if equal/not equal/...
2085 def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2086 def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
2088 def SETEr : I<0x94, MRM0r,
2091 [(set R8:$dst, (X86setcc X86_COND_E))]>,
2093 def SETEm : I<0x94, MRM0m,
2096 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2098 def SETNEr : I<0x95, MRM0r,
2101 [(set R8:$dst, (X86setcc X86_COND_NE))]>,
2103 def SETNEm : I<0x95, MRM0m,
2106 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2108 def SETLr : I<0x9C, MRM0r,
2111 [(set R8:$dst, (X86setcc X86_COND_L))]>,
2112 TB; // R8 = < signed
2113 def SETLm : I<0x9C, MRM0m,
2116 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2117 TB; // [mem8] = < signed
2118 def SETGEr : I<0x9D, MRM0r,
2121 [(set R8:$dst, (X86setcc X86_COND_GE))]>,
2122 TB; // R8 = >= signed
2123 def SETGEm : I<0x9D, MRM0m,
2126 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2127 TB; // [mem8] = >= signed
2128 def SETLEr : I<0x9E, MRM0r,
2131 [(set R8:$dst, (X86setcc X86_COND_LE))]>,
2132 TB; // R8 = <= signed
2133 def SETLEm : I<0x9E, MRM0m,
2136 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2137 TB; // [mem8] = <= signed
2138 def SETGr : I<0x9F, MRM0r,
2141 [(set R8:$dst, (X86setcc X86_COND_G))]>,
2142 TB; // R8 = > signed
2143 def SETGm : I<0x9F, MRM0m,
2146 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2147 TB; // [mem8] = > signed
2149 def SETBr : I<0x92, MRM0r,
2152 [(set R8:$dst, (X86setcc X86_COND_B))]>,
2153 TB; // R8 = < unsign
2154 def SETBm : I<0x92, MRM0m,
2157 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2158 TB; // [mem8] = < unsign
2159 def SETAEr : I<0x93, MRM0r,
2162 [(set R8:$dst, (X86setcc X86_COND_AE))]>,
2163 TB; // R8 = >= unsign
2164 def SETAEm : I<0x93, MRM0m,
2167 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2168 TB; // [mem8] = >= unsign
2169 def SETBEr : I<0x96, MRM0r,
2172 [(set R8:$dst, (X86setcc X86_COND_BE))]>,
2173 TB; // R8 = <= unsign
2174 def SETBEm : I<0x96, MRM0m,
2177 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2178 TB; // [mem8] = <= unsign
2179 def SETAr : I<0x97, MRM0r,
2182 [(set R8:$dst, (X86setcc X86_COND_A))]>,
2183 TB; // R8 = > signed
2184 def SETAm : I<0x97, MRM0m,
2187 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2188 TB; // [mem8] = > signed
2190 def SETSr : I<0x98, MRM0r,
2193 [(set R8:$dst, (X86setcc X86_COND_S))]>,
2194 TB; // R8 = <sign bit>
2195 def SETSm : I<0x98, MRM0m,
2198 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2199 TB; // [mem8] = <sign bit>
2200 def SETNSr : I<0x99, MRM0r,
2203 [(set R8:$dst, (X86setcc X86_COND_NS))]>,
2204 TB; // R8 = !<sign bit>
2205 def SETNSm : I<0x99, MRM0m,
2208 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2209 TB; // [mem8] = !<sign bit>
2210 def SETPr : I<0x9A, MRM0r,
2213 [(set R8:$dst, (X86setcc X86_COND_P))]>,
2215 def SETPm : I<0x9A, MRM0m,
2218 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2219 TB; // [mem8] = parity
2220 def SETNPr : I<0x9B, MRM0r,
2223 [(set R8:$dst, (X86setcc X86_COND_NP))]>,
2224 TB; // R8 = not parity
2225 def SETNPm : I<0x9B, MRM0m,
2228 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2229 TB; // [mem8] = not parity
2231 // Integer comparisons
2232 def CMP8rr : I<0x38, MRMDestReg,
2233 (ops R8 :$src1, R8 :$src2),
2234 "cmp{b} {$src2, $src1|$src1, $src2}",
2235 [(X86cmp R8:$src1, R8:$src2)]>;
2236 def CMP16rr : I<0x39, MRMDestReg,
2237 (ops R16:$src1, R16:$src2),
2238 "cmp{w} {$src2, $src1|$src1, $src2}",
2239 [(X86cmp R16:$src1, R16:$src2)]>, OpSize;
2240 def CMP32rr : I<0x39, MRMDestReg,
2241 (ops R32:$src1, R32:$src2),
2242 "cmp{l} {$src2, $src1|$src1, $src2}",
2243 [(X86cmp R32:$src1, R32:$src2)]>;
2244 def CMP8mr : I<0x38, MRMDestMem,
2245 (ops i8mem :$src1, R8 :$src2),
2246 "cmp{b} {$src2, $src1|$src1, $src2}",
2247 [(X86cmp (loadi8 addr:$src1), R8:$src2)]>;
2248 def CMP16mr : I<0x39, MRMDestMem,
2249 (ops i16mem:$src1, R16:$src2),
2250 "cmp{w} {$src2, $src1|$src1, $src2}",
2251 [(X86cmp (loadi16 addr:$src1), R16:$src2)]>, OpSize;
2252 def CMP32mr : I<0x39, MRMDestMem,
2253 (ops i32mem:$src1, R32:$src2),
2254 "cmp{l} {$src2, $src1|$src1, $src2}",
2255 [(X86cmp (loadi32 addr:$src1), R32:$src2)]>;
2256 def CMP8rm : I<0x3A, MRMSrcMem,
2257 (ops R8 :$src1, i8mem :$src2),
2258 "cmp{b} {$src2, $src1|$src1, $src2}",
2259 [(X86cmp R8:$src1, (loadi8 addr:$src2))]>;
2260 def CMP16rm : I<0x3B, MRMSrcMem,
2261 (ops R16:$src1, i16mem:$src2),
2262 "cmp{w} {$src2, $src1|$src1, $src2}",
2263 [(X86cmp R16:$src1, (loadi16 addr:$src2))]>, OpSize;
2264 def CMP32rm : I<0x3B, MRMSrcMem,
2265 (ops R32:$src1, i32mem:$src2),
2266 "cmp{l} {$src2, $src1|$src1, $src2}",
2267 [(X86cmp R32:$src1, (loadi32 addr:$src2))]>;
2268 def CMP8ri : Ii8<0x80, MRM7r,
2269 (ops R8:$src1, i8imm:$src2),
2270 "cmp{b} {$src2, $src1|$src1, $src2}",
2271 [(X86cmp R8:$src1, imm:$src2)]>;
2272 def CMP16ri : Ii16<0x81, MRM7r,
2273 (ops R16:$src1, i16imm:$src2),
2274 "cmp{w} {$src2, $src1|$src1, $src2}",
2275 [(X86cmp R16:$src1, imm:$src2)]>, OpSize;
2276 def CMP32ri : Ii32<0x81, MRM7r,
2277 (ops R32:$src1, i32imm:$src2),
2278 "cmp{l} {$src2, $src1|$src1, $src2}",
2279 [(X86cmp R32:$src1, imm:$src2)]>;
2280 def CMP8mi : Ii8 <0x80, MRM7m,
2281 (ops i8mem :$src1, i8imm :$src2),
2282 "cmp{b} {$src2, $src1|$src1, $src2}",
2283 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2284 def CMP16mi : Ii16<0x81, MRM7m,
2285 (ops i16mem:$src1, i16imm:$src2),
2286 "cmp{w} {$src2, $src1|$src1, $src2}",
2287 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2288 def CMP32mi : Ii32<0x81, MRM7m,
2289 (ops i32mem:$src1, i32imm:$src2),
2290 "cmp{l} {$src2, $src1|$src1, $src2}",
2291 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2293 // Sign/Zero extenders
2294 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src),
2295 "movs{bw|x} {$src, $dst|$dst, $src}",
2296 [(set R16:$dst, (sext R8:$src))]>, TB, OpSize;
2297 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src),
2298 "movs{bw|x} {$src, $dst|$dst, $src}",
2299 [(set R16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2300 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src),
2301 "movs{bl|x} {$src, $dst|$dst, $src}",
2302 [(set R32:$dst, (sext R8:$src))]>, TB;
2303 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src),
2304 "movs{bl|x} {$src, $dst|$dst, $src}",
2305 [(set R32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2306 def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src),
2307 "movs{wl|x} {$src, $dst|$dst, $src}",
2308 [(set R32:$dst, (sext R16:$src))]>, TB;
2309 def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src),
2310 "movs{wl|x} {$src, $dst|$dst, $src}",
2311 [(set R32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2313 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src),
2314 "movz{bw|x} {$src, $dst|$dst, $src}",
2315 [(set R16:$dst, (zext R8:$src))]>, TB, OpSize;
2316 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src),
2317 "movz{bw|x} {$src, $dst|$dst, $src}",
2318 [(set R16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2319 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src),
2320 "movz{bl|x} {$src, $dst|$dst, $src}",
2321 [(set R32:$dst, (zext R8:$src))]>, TB;
2322 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src),
2323 "movz{bl|x} {$src, $dst|$dst, $src}",
2324 [(set R32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2325 def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src),
2326 "movz{wl|x} {$src, $dst|$dst, $src}",
2327 [(set R32:$dst, (zext R16:$src))]>, TB;
2328 def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src),
2329 "movz{wl|x} {$src, $dst|$dst, $src}",
2330 [(set R32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2332 //===----------------------------------------------------------------------===//
2333 // Miscellaneous Instructions
2334 //===----------------------------------------------------------------------===//
2336 def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
2337 TB, Imp<[],[EAX,EDX]>;
2339 //===----------------------------------------------------------------------===//
2340 // Alias Instructions
2341 //===----------------------------------------------------------------------===//
2343 // Alias instructions that map movr0 to xor.
2344 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2345 def MOV8r0 : I<0x30, MRMInitReg, (ops R8 :$dst),
2346 "xor{b} $dst, $dst",
2347 [(set R8:$dst, 0)]>;
2348 def MOV16r0 : I<0x31, MRMInitReg, (ops R16:$dst),
2349 "xor{w} $dst, $dst",
2350 [(set R16:$dst, 0)]>, OpSize;
2351 def MOV32r0 : I<0x31, MRMInitReg, (ops R32:$dst),
2352 "xor{l} $dst, $dst",
2353 [(set R32:$dst, 0)]>;
2355 //===----------------------------------------------------------------------===//
2356 // Non-Instruction Patterns
2357 //===----------------------------------------------------------------------===//
2359 // ConstantPool GlobalAddress, ExternalSymbol
2360 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2361 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2362 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2364 def : Pat<(add R32:$src1, (X86Wrapper tconstpool:$src2)),
2365 (ADD32ri R32:$src1, tconstpool:$src2)>;
2366 def : Pat<(add R32:$src1, (X86Wrapper tglobaladdr :$src2)),
2367 (ADD32ri R32:$src1, tglobaladdr:$src2)>;
2368 def : Pat<(add R32:$src1, (X86Wrapper texternalsym:$src2)),
2369 (ADD32ri R32:$src1, texternalsym:$src2)>;
2371 def : Pat<(store (X86Wrapper tconstpool:$src), addr:$dst),
2372 (MOV32mi addr:$dst, tconstpool:$src)>;
2373 def : Pat<(store (X86Wrapper tglobaladdr:$src), addr:$dst),
2374 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2375 def : Pat<(store (X86Wrapper texternalsym:$src), addr:$dst),
2376 (MOV32mi addr:$dst, texternalsym:$src)>;
2379 def : Pat<(X86call tglobaladdr:$dst),
2380 (CALLpcrel32 tglobaladdr:$dst)>;
2381 def : Pat<(X86call texternalsym:$dst),
2382 (CALLpcrel32 texternalsym:$dst)>;
2384 // X86 specific add which produces a flag.
2385 def : Pat<(addc R32:$src1, R32:$src2),
2386 (ADD32rr R32:$src1, R32:$src2)>;
2387 def : Pat<(addc R32:$src1, (load addr:$src2)),
2388 (ADD32rm R32:$src1, addr:$src2)>;
2389 def : Pat<(addc R32:$src1, imm:$src2),
2390 (ADD32ri R32:$src1, imm:$src2)>;
2391 def : Pat<(addc R32:$src1, i32immSExt8:$src2),
2392 (ADD32ri8 R32:$src1, i32immSExt8:$src2)>;
2394 def : Pat<(subc R32:$src1, R32:$src2),
2395 (SUB32rr R32:$src1, R32:$src2)>;
2396 def : Pat<(subc R32:$src1, (load addr:$src2)),
2397 (SUB32rm R32:$src1, addr:$src2)>;
2398 def : Pat<(subc R32:$src1, imm:$src2),
2399 (SUB32ri R32:$src1, imm:$src2)>;
2400 def : Pat<(subc R32:$src1, i32immSExt8:$src2),
2401 (SUB32ri8 R32:$src1, i32immSExt8:$src2)>;
2403 def : Pat<(truncstore (i8 imm:$src), addr:$dst, i1),
2404 (MOV8mi addr:$dst, imm:$src)>;
2405 def : Pat<(truncstore R8:$src, addr:$dst, i1),
2406 (MOV8mr addr:$dst, R8:$src)>;
2408 // {s|z}extload bool -> {s|z}extload byte
2409 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2410 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2411 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2412 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2413 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2415 // extload bool -> extload byte
2416 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2419 def : Pat<(i16 (anyext R8 :$src)), (MOVZX16rr8 R8 :$src)>;
2420 def : Pat<(i32 (anyext R8 :$src)), (MOVZX32rr8 R8 :$src)>;
2421 def : Pat<(i32 (anyext R16:$src)), (MOVZX32rr16 R16:$src)>;
2423 //===----------------------------------------------------------------------===//
2425 //===----------------------------------------------------------------------===//
2427 // (shl x, 1) ==> (add x, x)
2428 def : Pat<(shl R8 :$src1, (i8 1)), (ADD8rr R8 :$src1, R8 :$src1)>;
2429 def : Pat<(shl R16:$src1, (i8 1)), (ADD16rr R16:$src1, R16:$src1)>;
2430 def : Pat<(shl R32:$src1, (i8 1)), (ADD32rr R32:$src1, R32:$src1)>;
2432 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2433 def : Pat<(or (srl R32:$src1, CL:$amt),
2434 (shl R32:$src2, (sub 32, CL:$amt))),
2435 (SHRD32rrCL R32:$src1, R32:$src2)>;
2437 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2438 (shl R32:$src2, (sub 32, CL:$amt))), addr:$dst),
2439 (SHRD32mrCL addr:$dst, R32:$src2)>;
2441 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2442 def : Pat<(or (shl R32:$src1, CL:$amt),
2443 (srl R32:$src2, (sub 32, CL:$amt))),
2444 (SHLD32rrCL R32:$src1, R32:$src2)>;
2446 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2447 (srl R32:$src2, (sub 32, CL:$amt))), addr:$dst),
2448 (SHLD32mrCL addr:$dst, R32:$src2)>;
2450 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2451 def : Pat<(or (srl R16:$src1, CL:$amt),
2452 (shl R16:$src2, (sub 16, CL:$amt))),
2453 (SHRD16rrCL R16:$src1, R16:$src2)>;
2455 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2456 (shl R16:$src2, (sub 16, CL:$amt))), addr:$dst),
2457 (SHRD16mrCL addr:$dst, R16:$src2)>;
2459 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2460 def : Pat<(or (shl R16:$src1, CL:$amt),
2461 (srl R16:$src2, (sub 16, CL:$amt))),
2462 (SHLD16rrCL R16:$src1, R16:$src2)>;
2464 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2465 (srl R16:$src2, (sub 16, CL:$amt))), addr:$dst),
2466 (SHLD16mrCL addr:$dst, R16:$src2)>;
2469 //===----------------------------------------------------------------------===//
2470 // Floating Point Stack Support
2471 //===----------------------------------------------------------------------===//
2473 include "X86InstrFPStack.td"
2475 //===----------------------------------------------------------------------===//
2476 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2477 //===----------------------------------------------------------------------===//
2479 include "X86InstrMMX.td"
2481 //===----------------------------------------------------------------------===//
2482 // XMM Floating point support (requires SSE / SSE2)
2483 //===----------------------------------------------------------------------===//
2485 include "X86InstrSSE.td"