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, iPTR>]>;
44 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
46 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
48 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
50 def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
52 def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
54 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
56 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
57 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
59 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
60 [SDNPHasChain, SDNPOutFlag]>;
62 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
63 [SDNPInFlag, SDNPOutFlag]>;
64 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
65 [SDNPHasChain, SDNPInFlag]>;
66 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
67 [SDNPInFlag, SDNPOutFlag]>;
69 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
70 [SDNPHasChain, SDNPOptInFlag]>;
72 def X86callseq_start :
73 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
74 [SDNPHasChain, SDNPOutFlag]>;
76 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
77 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
79 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
80 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
82 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
83 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
85 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
86 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
87 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
90 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
91 [SDNPHasChain, SDNPOutFlag]>;
93 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
94 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
96 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
97 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
98 def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
100 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
104 //===----------------------------------------------------------------------===//
105 // X86 Operand Definitions.
108 // *mem - Operand definitions for the funky X86 addressing mode operands.
110 class X86MemOperand<string printMethod> : Operand<iPTR> {
111 let PrintMethod = printMethod;
112 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
115 def i8mem : X86MemOperand<"printi8mem">;
116 def i16mem : X86MemOperand<"printi16mem">;
117 def i32mem : X86MemOperand<"printi32mem">;
118 def i64mem : X86MemOperand<"printi64mem">;
119 def i128mem : X86MemOperand<"printi128mem">;
120 def f32mem : X86MemOperand<"printf32mem">;
121 def f64mem : X86MemOperand<"printf64mem">;
122 def f128mem : X86MemOperand<"printf128mem">;
124 def lea32mem : Operand<i32> {
125 let PrintMethod = "printi32mem";
126 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
129 def SSECC : Operand<i8> {
130 let PrintMethod = "printSSECC";
133 def piclabel: Operand<i32> {
134 let PrintMethod = "printPICLabel";
137 // A couple of more descriptive operand definitions.
138 // 16-bits but only 8 bits are significant.
139 def i16i8imm : Operand<i16>;
140 // 32-bits but only 8 bits are significant.
141 def i32i8imm : Operand<i32>;
143 // Branch targets have OtherVT type.
144 def brtarget : Operand<OtherVT>;
146 //===----------------------------------------------------------------------===//
147 // X86 Complex Pattern Definitions.
150 // Define X86 specific addressing mode.
151 def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
152 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
153 [add, mul, shl, or, frameindex], []>;
155 //===----------------------------------------------------------------------===//
156 // X86 Instruction Format Definitions.
159 // Format specifies the encoding used by the instruction. This is part of the
160 // ad-hoc solution used to emit machine instruction encodings by our machine
162 class Format<bits<6> val> {
166 def Pseudo : Format<0>; def RawFrm : Format<1>;
167 def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
168 def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
169 def MRMSrcMem : Format<6>;
170 def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
171 def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
172 def MRM6r : Format<22>; def MRM7r : Format<23>;
173 def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
174 def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
175 def MRM6m : Format<30>; def MRM7m : Format<31>;
176 def MRMInitReg : Format<32>;
178 //===----------------------------------------------------------------------===//
179 // X86 Instruction Predicate Definitions.
180 def HasMMX : Predicate<"Subtarget->hasMMX()">;
181 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
182 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
183 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
184 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
185 def FPStack : Predicate<"!Subtarget->hasSSE2()">;
186 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
187 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
188 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
189 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
190 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
192 //===----------------------------------------------------------------------===//
193 // X86 specific pattern fragments.
196 // ImmType - This specifies the immediate type used by an instruction. This is
197 // part of the ad-hoc solution used to emit machine instruction encodings by our
198 // machine code emitter.
199 class ImmType<bits<3> val> {
202 def NoImm : ImmType<0>;
203 def Imm8 : ImmType<1>;
204 def Imm16 : ImmType<2>;
205 def Imm32 : ImmType<3>;
206 def Imm64 : ImmType<4>;
208 // FPFormat - This specifies what form this FP instruction has. This is used by
209 // the Floating-Point stackifier pass.
210 class FPFormat<bits<3> val> {
213 def NotFP : FPFormat<0>;
214 def ZeroArgFP : FPFormat<1>;
215 def OneArgFP : FPFormat<2>;
216 def OneArgFPRW : FPFormat<3>;
217 def TwoArgFP : FPFormat<4>;
218 def CompareFP : FPFormat<5>;
219 def CondMovFP : FPFormat<6>;
220 def SpecialFP : FPFormat<7>;
223 class X86Inst<bits<8> opcod, Format f, ImmType i, dag outs, dag ins,
226 let Namespace = "X86";
228 bits<8> Opcode = opcod;
230 bits<6> FormBits = Form.Value;
232 bits<3> ImmTypeBits = ImmT.Value;
234 dag OutOperandList = outs;
235 dag InOperandList = ins;
236 string AsmString = AsmStr;
239 // Attributes specific to X86 instructions...
241 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
242 bit hasAdSizePrefix = 0; // Does this inst have a 0x67 prefix?
244 bits<4> Prefix = 0; // Which prefix byte does this inst have?
245 bit hasREX_WPrefix = 0; // Does this inst requires the REX.W prefix?
246 FPFormat FPForm; // What flavor of FP instruction is this?
247 bits<3> FPFormBits = 0;
251 // Prefix byte classes which are used to indicate to the ad-hoc machine code
252 // emitter that various prefix bytes are required.
253 class OpSize { bit hasOpSizePrefix = 1; }
254 class AdSize { bit hasAdSizePrefix = 1; }
255 class REX_W { bit hasREX_WPrefix = 1; }
256 class TB { bits<4> Prefix = 1; }
257 class REP { bits<4> Prefix = 2; }
258 class D8 { bits<4> Prefix = 3; }
259 class D9 { bits<4> Prefix = 4; }
260 class DA { bits<4> Prefix = 5; }
261 class DB { bits<4> Prefix = 6; }
262 class DC { bits<4> Prefix = 7; }
263 class DD { bits<4> Prefix = 8; }
264 class DE { bits<4> Prefix = 9; }
265 class DF { bits<4> Prefix = 10; }
266 class XD { bits<4> Prefix = 11; }
267 class XS { bits<4> Prefix = 12; }
268 class T8 { bits<4> Prefix = 13; }
269 class TA { bits<4> Prefix = 14; }
272 //===----------------------------------------------------------------------===//
273 // Pattern fragments...
276 // X86 specific condition code. These correspond to CondCode in
277 // X86InstrInfo.h. They must be kept in synch.
278 def X86_COND_A : PatLeaf<(i8 0)>;
279 def X86_COND_AE : PatLeaf<(i8 1)>;
280 def X86_COND_B : PatLeaf<(i8 2)>;
281 def X86_COND_BE : PatLeaf<(i8 3)>;
282 def X86_COND_E : PatLeaf<(i8 4)>;
283 def X86_COND_G : PatLeaf<(i8 5)>;
284 def X86_COND_GE : PatLeaf<(i8 6)>;
285 def X86_COND_L : PatLeaf<(i8 7)>;
286 def X86_COND_LE : PatLeaf<(i8 8)>;
287 def X86_COND_NE : PatLeaf<(i8 9)>;
288 def X86_COND_NO : PatLeaf<(i8 10)>;
289 def X86_COND_NP : PatLeaf<(i8 11)>;
290 def X86_COND_NS : PatLeaf<(i8 12)>;
291 def X86_COND_O : PatLeaf<(i8 13)>;
292 def X86_COND_P : PatLeaf<(i8 14)>;
293 def X86_COND_S : PatLeaf<(i8 15)>;
295 def i16immSExt8 : PatLeaf<(i16 imm), [{
296 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
297 // sign extended field.
298 return (int16_t)N->getValue() == (int8_t)N->getValue();
301 def i32immSExt8 : PatLeaf<(i32 imm), [{
302 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
303 // sign extended field.
304 return (int32_t)N->getValue() == (int8_t)N->getValue();
307 // Helper fragments for loads.
308 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
309 def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
310 def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
311 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
313 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
314 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
316 def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
317 def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
318 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
319 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
320 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
322 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
323 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
324 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
325 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
326 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
327 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
329 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
330 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
331 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
332 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
333 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
334 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
336 //===----------------------------------------------------------------------===//
337 // Instruction templates...
340 class I<bits<8> o, Format f, dag outs, dag ins, string asm, list<dag> pattern>
341 : X86Inst<o, f, NoImm, outs, ins, asm> {
342 let Pattern = pattern;
345 class Ii8 <bits<8> o, Format f, dag outs, dag ins, string asm, list<dag> pattern>
346 : X86Inst<o, f, Imm8 , outs, ins, asm> {
347 let Pattern = pattern;
350 class Ii16<bits<8> o, Format f, dag outs, dag ins, string asm, list<dag> pattern>
351 : X86Inst<o, f, Imm16, outs, ins, asm> {
352 let Pattern = pattern;
355 class Ii32<bits<8> o, Format f, dag outs, dag ins, string asm, list<dag> pattern>
356 : X86Inst<o, f, Imm32, outs, ins, asm> {
357 let Pattern = pattern;
361 //===----------------------------------------------------------------------===//
362 // Instruction list...
365 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
366 // a stack adjustment and the codegen must know that they may modify the stack
367 // pointer before prolog-epilog rewriting occurs.
368 def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt), "#ADJCALLSTACKDOWN",
369 [(X86callseq_start imm:$amt)]>, Imp<[ESP],[ESP]>;
370 def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
372 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
374 def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
375 "#IMPLICIT_USE", []>;
376 def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
377 "#IMPLICIT_DEF", []>;
378 def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
379 "#IMPLICIT_DEF $dst",
380 [(set GR8:$dst, (undef))]>;
381 def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
382 "#IMPLICIT_DEF $dst",
383 [(set GR16:$dst, (undef))]>;
384 def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
385 "#IMPLICIT_DEF $dst",
386 [(set GR32:$dst, (undef))]>;
389 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
392 //===----------------------------------------------------------------------===//
393 // Control Flow Instructions...
396 // Return instructions.
397 let isTerminator = 1, isReturn = 1, isBarrier = 1,
399 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
400 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret $amt",
401 [(X86retflag imm:$amt)]>;
404 // All branches are RawFrm, Void, Branch, and Terminators
405 let isBranch = 1, isTerminator = 1 in
406 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
407 I<opcode, RawFrm, (outs), ins, asm, pattern>;
410 let isBranch = 1, isBarrier = 1 in
411 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
413 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
414 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l} {*}$dst",
415 [(brind GR32:$dst)]>;
416 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l} {*}$dst",
417 [(brind (loadi32 addr:$dst))]>;
420 // Conditional branches
421 def JE : IBr<0x84, (ins brtarget:$dst), "je $dst",
422 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
423 def JNE : IBr<0x85, (ins brtarget:$dst), "jne $dst",
424 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
425 def JL : IBr<0x8C, (ins brtarget:$dst), "jl $dst",
426 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
427 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle $dst",
428 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
429 def JG : IBr<0x8F, (ins brtarget:$dst), "jg $dst",
430 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
431 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge $dst",
432 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
434 def JB : IBr<0x82, (ins brtarget:$dst), "jb $dst",
435 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
436 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe $dst",
437 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
438 def JA : IBr<0x87, (ins brtarget:$dst), "ja $dst",
439 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
440 def JAE : IBr<0x83, (ins brtarget:$dst), "jae $dst",
441 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
443 def JS : IBr<0x88, (ins brtarget:$dst), "js $dst",
444 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
445 def JNS : IBr<0x89, (ins brtarget:$dst), "jns $dst",
446 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
447 def JP : IBr<0x8A, (ins brtarget:$dst), "jp $dst",
448 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
449 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp $dst",
450 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
451 def JO : IBr<0x80, (ins brtarget:$dst), "jo $dst",
452 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
453 def JNO : IBr<0x81, (ins brtarget:$dst), "jno $dst",
454 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
456 //===----------------------------------------------------------------------===//
457 // Call Instructions...
460 // All calls clobber the non-callee saved registers...
461 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
462 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
463 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
464 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
465 "call ${dst:call}", []>;
466 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
467 "call {*}$dst", [(X86call GR32:$dst)]>;
468 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
473 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
474 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp ${dst:call} # TAIL CALL",
476 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
477 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp {*}$dst # TAIL CALL",
479 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
480 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
481 "jmp {*}$dst # TAIL CALL", []>;
483 //===----------------------------------------------------------------------===//
484 // Miscellaneous Instructions...
486 def LEAVE : I<0xC9, RawFrm,
487 (outs), (ins), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
488 def POP32r : I<0x58, AddRegFrm,
489 (outs GR32:$reg), (ins), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
491 def PUSH32r : I<0x50, AddRegFrm,
492 (outs), (ins GR32:$reg), "push{l} $reg", []>, Imp<[ESP],[ESP]>;
494 def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
497 let isTwoAddress = 1 in // GR32 = bswap GR32
498 def BSWAP32r : I<0xC8, AddRegFrm,
499 (outs GR32:$dst), (ins GR32:$src),
501 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
503 // FIXME: Model xchg* as two address instructions?
504 def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
505 (outs), (ins GR8:$src1, GR8:$src2),
506 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
507 def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
508 (outs), (ins GR16:$src1, GR16:$src2),
509 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
510 def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
511 (outs), (ins GR32:$src1, GR32:$src2),
512 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
514 def XCHG8mr : I<0x86, MRMDestMem,
515 (outs), (ins i8mem:$src1, GR8:$src2),
516 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
517 def XCHG16mr : I<0x87, MRMDestMem,
518 (outs), (ins i16mem:$src1, GR16:$src2),
519 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
520 def XCHG32mr : I<0x87, MRMDestMem,
521 (outs), (ins i32mem:$src1, GR32:$src2),
522 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
523 def XCHG8rm : I<0x86, MRMSrcMem,
524 (outs), (ins GR8:$src1, i8mem:$src2),
525 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
526 def XCHG16rm : I<0x87, MRMSrcMem,
527 (outs), (ins GR16:$src1, i16mem:$src2),
528 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
529 def XCHG32rm : I<0x87, MRMSrcMem,
530 (outs), (ins GR32:$src1, i32mem:$src2),
531 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
533 def LEA16r : I<0x8D, MRMSrcMem,
534 (outs GR16:$dst), (ins i32mem:$src),
535 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
536 def LEA32r : I<0x8D, MRMSrcMem,
537 (outs GR32:$dst), (ins lea32mem:$src),
538 "lea{l} {$src|$dst}, {$dst|$src}",
539 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
541 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
543 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
544 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
545 [(X86rep_movs i16)]>,
546 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
547 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
548 [(X86rep_movs i32)]>,
549 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
551 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
553 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
554 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
555 [(X86rep_stos i16)]>,
556 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
557 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
558 [(X86rep_stos i32)]>,
559 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
561 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
562 TB, Imp<[],[RAX,RDX]>;
564 //===----------------------------------------------------------------------===//
565 // Input/Output Instructions...
567 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
568 "in{b} {%dx, %al|%AL, %DX}",
569 []>, Imp<[DX], [AL]>;
570 def IN16rr : I<0xED, RawFrm, (outs), (ins),
571 "in{w} {%dx, %ax|%AX, %DX}",
572 []>, Imp<[DX], [AX]>, OpSize;
573 def IN32rr : I<0xED, RawFrm, (outs), (ins),
574 "in{l} {%dx, %eax|%EAX, %DX}",
575 []>, Imp<[DX],[EAX]>;
577 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
578 "in{b} {$port, %al|%AL, $port}",
581 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
582 "in{w} {$port, %ax|%AX, $port}",
584 Imp<[], [AX]>, OpSize;
585 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
586 "in{l} {$port, %eax|%EAX, $port}",
590 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
591 "out{b} {%al, %dx|%DX, %AL}",
592 []>, Imp<[DX, AL], []>;
593 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
594 "out{w} {%ax, %dx|%DX, %AX}",
595 []>, Imp<[DX, AX], []>, OpSize;
596 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
597 "out{l} {%eax, %dx|%DX, %EAX}",
598 []>, Imp<[DX, EAX], []>;
600 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
601 "out{b} {%al, $port|$port, %AL}",
604 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
605 "out{w} {%ax, $port|$port, %AX}",
607 Imp<[AX], []>, OpSize;
608 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
609 "out{l} {%eax, $port|$port, %EAX}",
613 //===----------------------------------------------------------------------===//
614 // Move Instructions...
616 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
617 "mov{b} {$src, $dst|$dst, $src}", []>;
618 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
619 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
620 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
621 "mov{l} {$src, $dst|$dst, $src}", []>;
622 let isReMaterializable = 1 in {
623 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
624 "mov{b} {$src, $dst|$dst, $src}",
625 [(set GR8:$dst, imm:$src)]>;
626 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
627 "mov{w} {$src, $dst|$dst, $src}",
628 [(set GR16:$dst, imm:$src)]>, OpSize;
629 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
630 "mov{l} {$src, $dst|$dst, $src}",
631 [(set GR32:$dst, imm:$src)]>;
633 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
634 "mov{b} {$src, $dst|$dst, $src}",
635 [(store (i8 imm:$src), addr:$dst)]>;
636 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
637 "mov{w} {$src, $dst|$dst, $src}",
638 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
639 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
640 "mov{l} {$src, $dst|$dst, $src}",
641 [(store (i32 imm:$src), addr:$dst)]>;
643 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
644 "mov{b} {$src, $dst|$dst, $src}",
645 [(set GR8:$dst, (load addr:$src))]>;
646 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
647 "mov{w} {$src, $dst|$dst, $src}",
648 [(set GR16:$dst, (load addr:$src))]>, OpSize;
649 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
650 "mov{l} {$src, $dst|$dst, $src}",
651 [(set GR32:$dst, (load addr:$src))]>;
653 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
654 "mov{b} {$src, $dst|$dst, $src}",
655 [(store GR8:$src, addr:$dst)]>;
656 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
657 "mov{w} {$src, $dst|$dst, $src}",
658 [(store GR16:$src, addr:$dst)]>, OpSize;
659 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
660 "mov{l} {$src, $dst|$dst, $src}",
661 [(store GR32:$src, addr:$dst)]>;
663 //===----------------------------------------------------------------------===//
664 // Fixed-Register Multiplication and Division Instructions...
667 // Extra precision multiplication
668 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b} $src",
669 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
670 // This probably ought to be moved to a def : Pat<> if the
671 // syntax can be accepted.
672 [(set AL, (mul AL, GR8:$src))]>,
673 Imp<[AL],[AX]>; // AL,AH = AL*GR8
674 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w} $src", []>,
675 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
676 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l} $src", []>,
677 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
678 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
680 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
681 // This probably ought to be moved to a def : Pat<> if the
682 // syntax can be accepted.
683 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
684 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
685 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
686 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
687 OpSize; // AX,DX = AX*[mem16]
688 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
689 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
691 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b} $src", []>,
692 Imp<[AL],[AX]>; // AL,AH = AL*GR8
693 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w} $src", []>,
694 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
695 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l} $src", []>,
696 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
697 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
698 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
699 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
700 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
701 OpSize; // AX,DX = AX*[mem16]
702 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
704 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
706 // unsigned division/remainder
707 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
708 "div{b} $src", []>, Imp<[AX],[AX]>;
709 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
710 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
711 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
712 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
713 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
714 "div{b} $src", []>, Imp<[AX],[AX]>;
715 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
716 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
717 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
718 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
720 // Signed division/remainder.
721 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
722 "idiv{b} $src", []>, Imp<[AX],[AX]>;
723 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
724 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
725 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
726 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
727 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
728 "idiv{b} $src", []>, Imp<[AX],[AX]>;
729 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
730 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
731 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
732 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
735 //===----------------------------------------------------------------------===//
736 // Two address Instructions...
738 let isTwoAddress = 1 in {
741 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
742 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
743 "cmovb {$src2, $dst|$dst, $src2}",
744 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
747 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
748 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
749 "cmovb {$src2, $dst|$dst, $src2}",
750 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
753 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
754 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
755 "cmovb {$src2, $dst|$dst, $src2}",
756 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
759 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
760 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
761 "cmovb {$src2, $dst|$dst, $src2}",
762 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
766 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
767 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
768 "cmovae {$src2, $dst|$dst, $src2}",
769 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
772 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
773 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
774 "cmovae {$src2, $dst|$dst, $src2}",
775 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
778 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
779 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
780 "cmovae {$src2, $dst|$dst, $src2}",
781 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
784 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
785 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
786 "cmovae {$src2, $dst|$dst, $src2}",
787 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
791 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
792 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
793 "cmove {$src2, $dst|$dst, $src2}",
794 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
797 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
798 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
799 "cmove {$src2, $dst|$dst, $src2}",
800 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
803 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
804 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
805 "cmove {$src2, $dst|$dst, $src2}",
806 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
809 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
810 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
811 "cmove {$src2, $dst|$dst, $src2}",
812 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
816 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
817 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
818 "cmovne {$src2, $dst|$dst, $src2}",
819 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
822 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
823 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
824 "cmovne {$src2, $dst|$dst, $src2}",
825 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
828 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
829 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
830 "cmovne {$src2, $dst|$dst, $src2}",
831 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
834 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
835 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
836 "cmovne {$src2, $dst|$dst, $src2}",
837 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
841 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
842 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
843 "cmovbe {$src2, $dst|$dst, $src2}",
844 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
847 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
848 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
849 "cmovbe {$src2, $dst|$dst, $src2}",
850 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
853 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
854 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
855 "cmovbe {$src2, $dst|$dst, $src2}",
856 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
859 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
860 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
861 "cmovbe {$src2, $dst|$dst, $src2}",
862 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
866 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
867 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
868 "cmova {$src2, $dst|$dst, $src2}",
869 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
872 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
873 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
874 "cmova {$src2, $dst|$dst, $src2}",
875 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
878 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
879 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
880 "cmova {$src2, $dst|$dst, $src2}",
881 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
884 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
885 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
886 "cmova {$src2, $dst|$dst, $src2}",
887 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
891 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
892 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
893 "cmovl {$src2, $dst|$dst, $src2}",
894 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
897 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
898 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
899 "cmovl {$src2, $dst|$dst, $src2}",
900 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
903 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
904 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
905 "cmovl {$src2, $dst|$dst, $src2}",
906 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
909 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
910 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
911 "cmovl {$src2, $dst|$dst, $src2}",
912 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
916 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
917 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
918 "cmovge {$src2, $dst|$dst, $src2}",
919 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
922 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
923 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
924 "cmovge {$src2, $dst|$dst, $src2}",
925 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
928 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
929 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
930 "cmovge {$src2, $dst|$dst, $src2}",
931 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
934 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
935 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
936 "cmovge {$src2, $dst|$dst, $src2}",
937 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
941 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
942 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
943 "cmovle {$src2, $dst|$dst, $src2}",
944 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
947 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
948 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
949 "cmovle {$src2, $dst|$dst, $src2}",
950 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
953 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
954 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
955 "cmovle {$src2, $dst|$dst, $src2}",
956 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
959 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
960 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
961 "cmovle {$src2, $dst|$dst, $src2}",
962 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
966 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
967 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
968 "cmovg {$src2, $dst|$dst, $src2}",
969 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
972 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
973 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
974 "cmovg {$src2, $dst|$dst, $src2}",
975 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
978 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
979 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
980 "cmovg {$src2, $dst|$dst, $src2}",
981 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
984 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
985 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
986 "cmovg {$src2, $dst|$dst, $src2}",
987 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
991 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
992 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
993 "cmovs {$src2, $dst|$dst, $src2}",
994 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
997 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
998 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
999 "cmovs {$src2, $dst|$dst, $src2}",
1000 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1003 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1004 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1005 "cmovs {$src2, $dst|$dst, $src2}",
1006 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1009 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1010 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1011 "cmovs {$src2, $dst|$dst, $src2}",
1012 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1016 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1017 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1018 "cmovns {$src2, $dst|$dst, $src2}",
1019 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1022 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1023 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1024 "cmovns {$src2, $dst|$dst, $src2}",
1025 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1028 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1029 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1030 "cmovns {$src2, $dst|$dst, $src2}",
1031 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1034 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1035 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1036 "cmovns {$src2, $dst|$dst, $src2}",
1037 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1041 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1042 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1043 "cmovp {$src2, $dst|$dst, $src2}",
1044 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1047 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1048 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1049 "cmovp {$src2, $dst|$dst, $src2}",
1050 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1053 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1054 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1055 "cmovp {$src2, $dst|$dst, $src2}",
1056 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1059 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1060 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1061 "cmovp {$src2, $dst|$dst, $src2}",
1062 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1066 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1067 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1068 "cmovnp {$src2, $dst|$dst, $src2}",
1069 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1072 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1073 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1074 "cmovnp {$src2, $dst|$dst, $src2}",
1075 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1078 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1079 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1080 "cmovnp {$src2, $dst|$dst, $src2}",
1081 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1084 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1085 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1086 "cmovnp {$src2, $dst|$dst, $src2}",
1087 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1092 // unary instructions
1093 let CodeSize = 2 in {
1094 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b} $dst",
1095 [(set GR8:$dst, (ineg GR8:$src))]>;
1096 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w} $dst",
1097 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1098 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l} $dst",
1099 [(set GR32:$dst, (ineg GR32:$src))]>;
1100 let isTwoAddress = 0 in {
1101 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b} $dst",
1102 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1103 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w} $dst",
1104 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1105 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l} $dst",
1106 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1110 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b} $dst",
1111 [(set GR8:$dst, (not GR8:$src))]>;
1112 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w} $dst",
1113 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1114 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l} $dst",
1115 [(set GR32:$dst, (not GR32:$src))]>;
1116 let isTwoAddress = 0 in {
1117 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b} $dst",
1118 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1119 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w} $dst",
1120 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1121 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l} $dst",
1122 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1126 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1128 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b} $dst",
1129 [(set GR8:$dst, (add GR8:$src, 1))]>;
1130 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1131 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w} $dst",
1132 [(set GR16:$dst, (add GR16:$src, 1))]>,
1133 OpSize, Requires<[In32BitMode]>;
1134 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l} $dst",
1135 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1137 let isTwoAddress = 0, CodeSize = 2 in {
1138 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b} $dst",
1139 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1140 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w} $dst",
1141 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
1142 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l} $dst",
1143 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1147 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b} $dst",
1148 [(set GR8:$dst, (add GR8:$src, -1))]>;
1149 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1150 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w} $dst",
1151 [(set GR16:$dst, (add GR16:$src, -1))]>,
1152 OpSize, Requires<[In32BitMode]>;
1153 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l} $dst",
1154 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1157 let isTwoAddress = 0, CodeSize = 2 in {
1158 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b} $dst",
1159 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1160 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w} $dst",
1161 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
1162 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l} $dst",
1163 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1166 // Logical operators...
1167 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1168 def AND8rr : I<0x20, MRMDestReg,
1169 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1170 "and{b} {$src2, $dst|$dst, $src2}",
1171 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1172 def AND16rr : I<0x21, MRMDestReg,
1173 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1174 "and{w} {$src2, $dst|$dst, $src2}",
1175 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1176 def AND32rr : I<0x21, MRMDestReg,
1177 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1178 "and{l} {$src2, $dst|$dst, $src2}",
1179 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1182 def AND8rm : I<0x22, MRMSrcMem,
1183 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1184 "and{b} {$src2, $dst|$dst, $src2}",
1185 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1186 def AND16rm : I<0x23, MRMSrcMem,
1187 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1188 "and{w} {$src2, $dst|$dst, $src2}",
1189 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1190 def AND32rm : I<0x23, MRMSrcMem,
1191 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1192 "and{l} {$src2, $dst|$dst, $src2}",
1193 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1195 def AND8ri : Ii8<0x80, MRM4r,
1196 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1197 "and{b} {$src2, $dst|$dst, $src2}",
1198 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1199 def AND16ri : Ii16<0x81, MRM4r,
1200 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1201 "and{w} {$src2, $dst|$dst, $src2}",
1202 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1203 def AND32ri : Ii32<0x81, MRM4r,
1204 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1205 "and{l} {$src2, $dst|$dst, $src2}",
1206 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1207 def AND16ri8 : Ii8<0x83, MRM4r,
1208 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1209 "and{w} {$src2, $dst|$dst, $src2}",
1210 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1212 def AND32ri8 : Ii8<0x83, MRM4r,
1213 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1214 "and{l} {$src2, $dst|$dst, $src2}",
1215 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1217 let isTwoAddress = 0 in {
1218 def AND8mr : I<0x20, MRMDestMem,
1219 (outs), (ins i8mem :$dst, GR8 :$src),
1220 "and{b} {$src, $dst|$dst, $src}",
1221 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1222 def AND16mr : I<0x21, MRMDestMem,
1223 (outs), (ins i16mem:$dst, GR16:$src),
1224 "and{w} {$src, $dst|$dst, $src}",
1225 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1227 def AND32mr : I<0x21, MRMDestMem,
1228 (outs), (ins i32mem:$dst, GR32:$src),
1229 "and{l} {$src, $dst|$dst, $src}",
1230 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1231 def AND8mi : Ii8<0x80, MRM4m,
1232 (outs), (ins i8mem :$dst, i8imm :$src),
1233 "and{b} {$src, $dst|$dst, $src}",
1234 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1235 def AND16mi : Ii16<0x81, MRM4m,
1236 (outs), (ins i16mem:$dst, i16imm:$src),
1237 "and{w} {$src, $dst|$dst, $src}",
1238 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1240 def AND32mi : Ii32<0x81, MRM4m,
1241 (outs), (ins i32mem:$dst, i32imm:$src),
1242 "and{l} {$src, $dst|$dst, $src}",
1243 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1244 def AND16mi8 : Ii8<0x83, MRM4m,
1245 (outs), (ins i16mem:$dst, i16i8imm :$src),
1246 "and{w} {$src, $dst|$dst, $src}",
1247 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1249 def AND32mi8 : Ii8<0x83, MRM4m,
1250 (outs), (ins i32mem:$dst, i32i8imm :$src),
1251 "and{l} {$src, $dst|$dst, $src}",
1252 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1256 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1257 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1258 "or{b} {$src2, $dst|$dst, $src2}",
1259 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1260 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1261 "or{w} {$src2, $dst|$dst, $src2}",
1262 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1263 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1264 "or{l} {$src2, $dst|$dst, $src2}",
1265 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1267 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1268 "or{b} {$src2, $dst|$dst, $src2}",
1269 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1270 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1271 "or{w} {$src2, $dst|$dst, $src2}",
1272 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1273 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1274 "or{l} {$src2, $dst|$dst, $src2}",
1275 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1277 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1278 "or{b} {$src2, $dst|$dst, $src2}",
1279 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1280 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1281 "or{w} {$src2, $dst|$dst, $src2}",
1282 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1283 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1284 "or{l} {$src2, $dst|$dst, $src2}",
1285 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1287 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1288 "or{w} {$src2, $dst|$dst, $src2}",
1289 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1290 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1291 "or{l} {$src2, $dst|$dst, $src2}",
1292 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1293 let isTwoAddress = 0 in {
1294 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1295 "or{b} {$src, $dst|$dst, $src}",
1296 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1297 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1298 "or{w} {$src, $dst|$dst, $src}",
1299 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1300 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1301 "or{l} {$src, $dst|$dst, $src}",
1302 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
1303 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1304 "or{b} {$src, $dst|$dst, $src}",
1305 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1306 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1307 "or{w} {$src, $dst|$dst, $src}",
1308 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1310 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1311 "or{l} {$src, $dst|$dst, $src}",
1312 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1313 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1314 "or{w} {$src, $dst|$dst, $src}",
1315 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1317 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1318 "or{l} {$src, $dst|$dst, $src}",
1319 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1323 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1324 def XOR8rr : I<0x30, MRMDestReg,
1325 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1326 "xor{b} {$src2, $dst|$dst, $src2}",
1327 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1328 def XOR16rr : I<0x31, MRMDestReg,
1329 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1330 "xor{w} {$src2, $dst|$dst, $src2}",
1331 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1332 def XOR32rr : I<0x31, MRMDestReg,
1333 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1334 "xor{l} {$src2, $dst|$dst, $src2}",
1335 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1338 def XOR8rm : I<0x32, MRMSrcMem ,
1339 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1340 "xor{b} {$src2, $dst|$dst, $src2}",
1341 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1342 def XOR16rm : I<0x33, MRMSrcMem ,
1343 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1344 "xor{w} {$src2, $dst|$dst, $src2}",
1345 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1346 def XOR32rm : I<0x33, MRMSrcMem ,
1347 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1348 "xor{l} {$src2, $dst|$dst, $src2}",
1349 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1351 def XOR8ri : Ii8<0x80, MRM6r,
1352 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1353 "xor{b} {$src2, $dst|$dst, $src2}",
1354 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1355 def XOR16ri : Ii16<0x81, MRM6r,
1356 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1357 "xor{w} {$src2, $dst|$dst, $src2}",
1358 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1359 def XOR32ri : Ii32<0x81, MRM6r,
1360 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1361 "xor{l} {$src2, $dst|$dst, $src2}",
1362 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1363 def XOR16ri8 : Ii8<0x83, MRM6r,
1364 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1365 "xor{w} {$src2, $dst|$dst, $src2}",
1366 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1368 def XOR32ri8 : Ii8<0x83, MRM6r,
1369 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1370 "xor{l} {$src2, $dst|$dst, $src2}",
1371 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1372 let isTwoAddress = 0 in {
1373 def XOR8mr : I<0x30, MRMDestMem,
1374 (outs), (ins i8mem :$dst, GR8 :$src),
1375 "xor{b} {$src, $dst|$dst, $src}",
1376 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1377 def XOR16mr : I<0x31, MRMDestMem,
1378 (outs), (ins i16mem:$dst, GR16:$src),
1379 "xor{w} {$src, $dst|$dst, $src}",
1380 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1382 def XOR32mr : I<0x31, MRMDestMem,
1383 (outs), (ins i32mem:$dst, GR32:$src),
1384 "xor{l} {$src, $dst|$dst, $src}",
1385 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1386 def XOR8mi : Ii8<0x80, MRM6m,
1387 (outs), (ins i8mem :$dst, i8imm :$src),
1388 "xor{b} {$src, $dst|$dst, $src}",
1389 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1390 def XOR16mi : Ii16<0x81, MRM6m,
1391 (outs), (ins i16mem:$dst, i16imm:$src),
1392 "xor{w} {$src, $dst|$dst, $src}",
1393 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1395 def XOR32mi : Ii32<0x81, MRM6m,
1396 (outs), (ins i32mem:$dst, i32imm:$src),
1397 "xor{l} {$src, $dst|$dst, $src}",
1398 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1399 def XOR16mi8 : Ii8<0x83, MRM6m,
1400 (outs), (ins i16mem:$dst, i16i8imm :$src),
1401 "xor{w} {$src, $dst|$dst, $src}",
1402 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1404 def XOR32mi8 : Ii8<0x83, MRM6m,
1405 (outs), (ins i32mem:$dst, i32i8imm :$src),
1406 "xor{l} {$src, $dst|$dst, $src}",
1407 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1410 // Shift instructions
1411 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1412 "shl{b} {%cl, $dst|$dst, %CL}",
1413 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
1414 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1415 "shl{w} {%cl, $dst|$dst, %CL}",
1416 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1417 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1418 "shl{l} {%cl, $dst|$dst, %CL}",
1419 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
1421 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1422 "shl{b} {$src2, $dst|$dst, $src2}",
1423 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1424 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1425 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1426 "shl{w} {$src2, $dst|$dst, $src2}",
1427 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1428 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1429 "shl{l} {$src2, $dst|$dst, $src2}",
1430 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1433 // Shift left by one. Not used because (add x, x) is slightly cheaper.
1434 def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
1436 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1437 "shl{w} $dst", []>, OpSize;
1438 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1441 let isTwoAddress = 0 in {
1442 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1443 "shl{b} {%cl, $dst|$dst, %CL}",
1444 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1446 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1447 "shl{w} {%cl, $dst|$dst, %CL}",
1448 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1449 Imp<[CL],[]>, OpSize;
1450 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1451 "shl{l} {%cl, $dst|$dst, %CL}",
1452 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1454 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1455 "shl{b} {$src, $dst|$dst, $src}",
1456 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1457 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1458 "shl{w} {$src, $dst|$dst, $src}",
1459 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1461 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1462 "shl{l} {$src, $dst|$dst, $src}",
1463 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1466 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1468 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1469 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1471 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1473 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1475 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1478 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1479 "shr{b} {%cl, $dst|$dst, %CL}",
1480 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
1481 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1482 "shr{w} {%cl, $dst|$dst, %CL}",
1483 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1484 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1485 "shr{l} {%cl, $dst|$dst, %CL}",
1486 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
1488 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1489 "shr{b} {$src2, $dst|$dst, $src2}",
1490 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1491 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1492 "shr{w} {$src2, $dst|$dst, $src2}",
1493 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1494 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1495 "shr{l} {$src2, $dst|$dst, $src2}",
1496 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1499 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1501 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1502 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1504 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1505 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1507 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1509 let isTwoAddress = 0 in {
1510 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1511 "shr{b} {%cl, $dst|$dst, %CL}",
1512 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1514 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1515 "shr{w} {%cl, $dst|$dst, %CL}",
1516 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1517 Imp<[CL],[]>, OpSize;
1518 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1519 "shr{l} {%cl, $dst|$dst, %CL}",
1520 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1522 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1523 "shr{b} {$src, $dst|$dst, $src}",
1524 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1525 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1526 "shr{w} {$src, $dst|$dst, $src}",
1527 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1529 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1530 "shr{l} {$src, $dst|$dst, $src}",
1531 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1534 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1536 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1537 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1539 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1540 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1542 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1545 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1546 "sar{b} {%cl, $dst|$dst, %CL}",
1547 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
1548 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1549 "sar{w} {%cl, $dst|$dst, %CL}",
1550 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1551 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1552 "sar{l} {%cl, $dst|$dst, %CL}",
1553 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
1555 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1556 "sar{b} {$src2, $dst|$dst, $src2}",
1557 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1558 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1559 "sar{w} {$src2, $dst|$dst, $src2}",
1560 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1562 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1563 "sar{l} {$src2, $dst|$dst, $src2}",
1564 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1567 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1569 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1570 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1572 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1573 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1575 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1577 let isTwoAddress = 0 in {
1578 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1579 "sar{b} {%cl, $dst|$dst, %CL}",
1580 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1582 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1583 "sar{w} {%cl, $dst|$dst, %CL}",
1584 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1585 Imp<[CL],[]>, OpSize;
1586 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1587 "sar{l} {%cl, $dst|$dst, %CL}",
1588 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1590 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1591 "sar{b} {$src, $dst|$dst, $src}",
1592 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1593 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1594 "sar{w} {$src, $dst|$dst, $src}",
1595 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1597 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1598 "sar{l} {$src, $dst|$dst, $src}",
1599 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1602 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1604 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1605 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1607 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1609 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1611 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1614 // Rotate instructions
1615 // FIXME: provide shorter instructions when imm8 == 1
1616 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1617 "rol{b} {%cl, $dst|$dst, %CL}",
1618 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
1619 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1620 "rol{w} {%cl, $dst|$dst, %CL}",
1621 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1622 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1623 "rol{l} {%cl, $dst|$dst, %CL}",
1624 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
1626 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1627 "rol{b} {$src2, $dst|$dst, $src2}",
1628 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1629 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1630 "rol{w} {$src2, $dst|$dst, $src2}",
1631 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1632 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1633 "rol{l} {$src2, $dst|$dst, $src2}",
1634 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1637 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1639 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1640 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1642 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1643 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1645 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1647 let isTwoAddress = 0 in {
1648 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1649 "rol{b} {%cl, $dst|$dst, %CL}",
1650 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1652 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1653 "rol{w} {%cl, $dst|$dst, %CL}",
1654 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1655 Imp<[CL],[]>, OpSize;
1656 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1657 "rol{l} {%cl, $dst|$dst, %CL}",
1658 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1660 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
1661 "rol{b} {$src, $dst|$dst, $src}",
1662 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1663 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
1664 "rol{w} {$src, $dst|$dst, $src}",
1665 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1667 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
1668 "rol{l} {$src, $dst|$dst, $src}",
1669 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1672 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
1674 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1675 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
1677 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1679 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
1681 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1684 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
1685 "ror{b} {%cl, $dst|$dst, %CL}",
1686 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
1687 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
1688 "ror{w} {%cl, $dst|$dst, %CL}",
1689 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1690 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
1691 "ror{l} {%cl, $dst|$dst, %CL}",
1692 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
1694 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1695 "ror{b} {$src2, $dst|$dst, $src2}",
1696 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1697 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1698 "ror{w} {$src2, $dst|$dst, $src2}",
1699 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1700 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1701 "ror{l} {$src2, $dst|$dst, $src2}",
1702 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1705 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1707 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1708 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
1710 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1711 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
1713 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1715 let isTwoAddress = 0 in {
1716 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
1717 "ror{b} {%cl, $dst|$dst, %CL}",
1718 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1720 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
1721 "ror{w} {%cl, $dst|$dst, %CL}",
1722 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1723 Imp<[CL],[]>, OpSize;
1724 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
1725 "ror{l} {%cl, $dst|$dst, %CL}",
1726 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1728 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1729 "ror{b} {$src, $dst|$dst, $src}",
1730 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1731 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
1732 "ror{w} {$src, $dst|$dst, $src}",
1733 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1735 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
1736 "ror{l} {$src, $dst|$dst, $src}",
1737 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1740 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
1742 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1743 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
1745 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1747 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
1749 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1754 // Double shift instructions (generalizations of rotate)
1755 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1756 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1757 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
1759 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1760 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1761 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
1763 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1764 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1765 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1766 Imp<[CL],[]>, TB, OpSize;
1767 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1768 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1769 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1770 Imp<[CL],[]>, TB, OpSize;
1772 let isCommutable = 1 in { // These instructions commute to each other.
1773 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1774 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1775 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1776 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1779 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1780 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1781 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1782 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1785 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1786 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1787 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1788 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1791 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1792 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1793 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1794 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1799 let isTwoAddress = 0 in {
1800 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1801 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1802 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1805 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1806 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1807 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1810 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1811 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1812 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1813 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1814 (i8 imm:$src3)), addr:$dst)]>,
1816 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1817 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1818 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1819 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1820 (i8 imm:$src3)), addr:$dst)]>,
1823 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1824 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1825 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1827 Imp<[CL],[]>, TB, OpSize;
1828 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1829 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1830 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1832 Imp<[CL],[]>, TB, OpSize;
1833 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1834 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1835 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1836 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1837 (i8 imm:$src3)), addr:$dst)]>,
1839 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1840 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1841 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1842 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1843 (i8 imm:$src3)), addr:$dst)]>,
1849 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1850 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1851 "add{b} {$src2, $dst|$dst, $src2}",
1852 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1853 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1854 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1855 "add{w} {$src2, $dst|$dst, $src2}",
1856 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1857 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1858 "add{l} {$src2, $dst|$dst, $src2}",
1859 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1860 } // end isConvertibleToThreeAddress
1861 } // end isCommutable
1862 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1863 "add{b} {$src2, $dst|$dst, $src2}",
1864 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1865 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1866 "add{w} {$src2, $dst|$dst, $src2}",
1867 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
1868 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1869 "add{l} {$src2, $dst|$dst, $src2}",
1870 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1872 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1873 "add{b} {$src2, $dst|$dst, $src2}",
1874 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1876 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1877 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1878 "add{w} {$src2, $dst|$dst, $src2}",
1879 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1880 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1881 "add{l} {$src2, $dst|$dst, $src2}",
1882 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
1883 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1884 "add{w} {$src2, $dst|$dst, $src2}",
1885 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
1887 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1888 "add{l} {$src2, $dst|$dst, $src2}",
1889 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1892 let isTwoAddress = 0 in {
1893 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
1894 "add{b} {$src2, $dst|$dst, $src2}",
1895 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1896 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1897 "add{w} {$src2, $dst|$dst, $src2}",
1898 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1900 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1901 "add{l} {$src2, $dst|$dst, $src2}",
1902 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
1903 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
1904 "add{b} {$src2, $dst|$dst, $src2}",
1905 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1906 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
1907 "add{w} {$src2, $dst|$dst, $src2}",
1908 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1910 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
1911 "add{l} {$src2, $dst|$dst, $src2}",
1912 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1913 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
1914 "add{w} {$src2, $dst|$dst, $src2}",
1915 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1917 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1918 "add{l} {$src2, $dst|$dst, $src2}",
1919 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1922 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1923 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1924 "adc{l} {$src2, $dst|$dst, $src2}",
1925 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1927 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1928 "adc{l} {$src2, $dst|$dst, $src2}",
1929 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1930 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1931 "adc{l} {$src2, $dst|$dst, $src2}",
1932 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1933 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1934 "adc{l} {$src2, $dst|$dst, $src2}",
1935 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1937 let isTwoAddress = 0 in {
1938 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1939 "adc{l} {$src2, $dst|$dst, $src2}",
1940 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
1941 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
1942 "adc{l} {$src2, $dst|$dst, $src2}",
1943 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1944 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1945 "adc{l} {$src2, $dst|$dst, $src2}",
1946 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1949 def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1950 "sub{b} {$src2, $dst|$dst, $src2}",
1951 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1952 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1953 "sub{w} {$src2, $dst|$dst, $src2}",
1954 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1955 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1956 "sub{l} {$src2, $dst|$dst, $src2}",
1957 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1958 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1959 "sub{b} {$src2, $dst|$dst, $src2}",
1960 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1961 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1962 "sub{w} {$src2, $dst|$dst, $src2}",
1963 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1964 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1965 "sub{l} {$src2, $dst|$dst, $src2}",
1966 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1968 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1969 "sub{b} {$src2, $dst|$dst, $src2}",
1970 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1971 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1972 "sub{w} {$src2, $dst|$dst, $src2}",
1973 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1974 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1975 "sub{l} {$src2, $dst|$dst, $src2}",
1976 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1977 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1978 "sub{w} {$src2, $dst|$dst, $src2}",
1979 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
1981 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1982 "sub{l} {$src2, $dst|$dst, $src2}",
1983 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1984 let isTwoAddress = 0 in {
1985 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
1986 "sub{b} {$src2, $dst|$dst, $src2}",
1987 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
1988 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1989 "sub{w} {$src2, $dst|$dst, $src2}",
1990 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
1992 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1993 "sub{l} {$src2, $dst|$dst, $src2}",
1994 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
1995 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
1996 "sub{b} {$src2, $dst|$dst, $src2}",
1997 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1998 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
1999 "sub{w} {$src2, $dst|$dst, $src2}",
2000 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2002 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2003 "sub{l} {$src2, $dst|$dst, $src2}",
2004 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2005 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2006 "sub{w} {$src2, $dst|$dst, $src2}",
2007 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2009 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2010 "sub{l} {$src2, $dst|$dst, $src2}",
2011 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2014 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2015 "sbb{l} {$src2, $dst|$dst, $src2}",
2016 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2018 let isTwoAddress = 0 in {
2019 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2020 "sbb{l} {$src2, $dst|$dst, $src2}",
2021 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2022 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2023 "sbb{b} {$src2, $dst|$dst, $src2}",
2024 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2025 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2026 "sbb{l} {$src2, $dst|$dst, $src2}",
2027 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2028 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2029 "sbb{l} {$src2, $dst|$dst, $src2}",
2030 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2032 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2033 "sbb{l} {$src2, $dst|$dst, $src2}",
2034 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2035 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2036 "sbb{l} {$src2, $dst|$dst, $src2}",
2037 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2038 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2039 "sbb{l} {$src2, $dst|$dst, $src2}",
2040 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2042 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2043 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2044 "imul{w} {$src2, $dst|$dst, $src2}",
2045 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2046 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2047 "imul{l} {$src2, $dst|$dst, $src2}",
2048 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2050 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
2051 "imul{w} {$src2, $dst|$dst, $src2}",
2052 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2054 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2055 "imul{l} {$src2, $dst|$dst, $src2}",
2056 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
2058 } // end Two Address instructions
2060 // Suprisingly enough, these are not two address instructions!
2061 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2062 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2063 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2064 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2065 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2066 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2067 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2068 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2069 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2070 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2071 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2072 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2074 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2075 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2076 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2077 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2079 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2080 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2081 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2082 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2084 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2085 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2086 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2087 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2088 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2089 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2090 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2091 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2093 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2094 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2095 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2096 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2098 //===----------------------------------------------------------------------===//
2099 // Test instructions are just like AND, except they don't generate a result.
2101 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2102 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2103 "test{b} {$src2, $src1|$src1, $src2}",
2104 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
2105 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2106 "test{w} {$src2, $src1|$src1, $src2}",
2107 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
2108 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2109 "test{l} {$src2, $src1|$src1, $src2}",
2110 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
2113 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2114 "test{b} {$src2, $src1|$src1, $src2}",
2115 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
2116 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2117 "test{w} {$src2, $src1|$src1, $src2}",
2118 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
2120 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2121 "test{l} {$src2, $src1|$src1, $src2}",
2122 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
2124 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2125 (outs), (ins GR8:$src1, i8imm:$src2),
2126 "test{b} {$src2, $src1|$src1, $src2}",
2127 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
2128 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2129 (outs), (ins GR16:$src1, i16imm:$src2),
2130 "test{w} {$src2, $src1|$src1, $src2}",
2131 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
2132 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2133 (outs), (ins GR32:$src1, i32imm:$src2),
2134 "test{l} {$src2, $src1|$src1, $src2}",
2135 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
2137 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2138 (outs), (ins i8mem:$src1, i8imm:$src2),
2139 "test{b} {$src2, $src1|$src1, $src2}",
2140 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
2141 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2142 (outs), (ins i16mem:$src1, i16imm:$src2),
2143 "test{w} {$src2, $src1|$src1, $src2}",
2144 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
2146 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2147 (outs), (ins i32mem:$src1, i32imm:$src2),
2148 "test{l} {$src2, $src1|$src1, $src2}",
2149 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
2152 // Condition code ops, incl. set if equal/not equal/...
2153 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>, Imp<[AH],[]>; // flags = AH
2154 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>, Imp<[],[AH]>; // AH = flags
2156 def SETEr : I<0x94, MRM0r,
2157 (outs GR8 :$dst), (ins),
2159 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2161 def SETEm : I<0x94, MRM0m,
2162 (outs), (ins i8mem:$dst),
2164 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2166 def SETNEr : I<0x95, MRM0r,
2167 (outs GR8 :$dst), (ins),
2169 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2171 def SETNEm : I<0x95, MRM0m,
2172 (outs), (ins i8mem:$dst),
2174 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2176 def SETLr : I<0x9C, MRM0r,
2177 (outs GR8 :$dst), (ins),
2179 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2180 TB; // GR8 = < signed
2181 def SETLm : I<0x9C, MRM0m,
2182 (outs), (ins i8mem:$dst),
2184 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2185 TB; // [mem8] = < signed
2186 def SETGEr : I<0x9D, MRM0r,
2187 (outs GR8 :$dst), (ins),
2189 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2190 TB; // GR8 = >= signed
2191 def SETGEm : I<0x9D, MRM0m,
2192 (outs), (ins i8mem:$dst),
2194 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2195 TB; // [mem8] = >= signed
2196 def SETLEr : I<0x9E, MRM0r,
2197 (outs GR8 :$dst), (ins),
2199 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2200 TB; // GR8 = <= signed
2201 def SETLEm : I<0x9E, MRM0m,
2202 (outs), (ins i8mem:$dst),
2204 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2205 TB; // [mem8] = <= signed
2206 def SETGr : I<0x9F, MRM0r,
2207 (outs GR8 :$dst), (ins),
2209 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2210 TB; // GR8 = > signed
2211 def SETGm : I<0x9F, MRM0m,
2212 (outs), (ins i8mem:$dst),
2214 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2215 TB; // [mem8] = > signed
2217 def SETBr : I<0x92, MRM0r,
2218 (outs GR8 :$dst), (ins),
2220 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2221 TB; // GR8 = < unsign
2222 def SETBm : I<0x92, MRM0m,
2223 (outs), (ins i8mem:$dst),
2225 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2226 TB; // [mem8] = < unsign
2227 def SETAEr : I<0x93, MRM0r,
2228 (outs GR8 :$dst), (ins),
2230 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2231 TB; // GR8 = >= unsign
2232 def SETAEm : I<0x93, MRM0m,
2233 (outs), (ins i8mem:$dst),
2235 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2236 TB; // [mem8] = >= unsign
2237 def SETBEr : I<0x96, MRM0r,
2238 (outs GR8 :$dst), (ins),
2240 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2241 TB; // GR8 = <= unsign
2242 def SETBEm : I<0x96, MRM0m,
2243 (outs), (ins i8mem:$dst),
2245 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2246 TB; // [mem8] = <= unsign
2247 def SETAr : I<0x97, MRM0r,
2248 (outs GR8 :$dst), (ins),
2250 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2251 TB; // GR8 = > signed
2252 def SETAm : I<0x97, MRM0m,
2253 (outs), (ins i8mem:$dst),
2255 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2256 TB; // [mem8] = > signed
2258 def SETSr : I<0x98, MRM0r,
2259 (outs GR8 :$dst), (ins),
2261 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2262 TB; // GR8 = <sign bit>
2263 def SETSm : I<0x98, MRM0m,
2264 (outs), (ins i8mem:$dst),
2266 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2267 TB; // [mem8] = <sign bit>
2268 def SETNSr : I<0x99, MRM0r,
2269 (outs GR8 :$dst), (ins),
2271 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2272 TB; // GR8 = !<sign bit>
2273 def SETNSm : I<0x99, MRM0m,
2274 (outs), (ins i8mem:$dst),
2276 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2277 TB; // [mem8] = !<sign bit>
2278 def SETPr : I<0x9A, MRM0r,
2279 (outs GR8 :$dst), (ins),
2281 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2283 def SETPm : I<0x9A, MRM0m,
2284 (outs), (ins i8mem:$dst),
2286 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2287 TB; // [mem8] = parity
2288 def SETNPr : I<0x9B, MRM0r,
2289 (outs GR8 :$dst), (ins),
2291 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2292 TB; // GR8 = not parity
2293 def SETNPm : I<0x9B, MRM0m,
2294 (outs), (ins i8mem:$dst),
2296 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2297 TB; // [mem8] = not parity
2299 // Integer comparisons
2300 def CMP8rr : I<0x38, MRMDestReg,
2301 (outs), (ins GR8 :$src1, GR8 :$src2),
2302 "cmp{b} {$src2, $src1|$src1, $src2}",
2303 [(X86cmp GR8:$src1, GR8:$src2)]>;
2304 def CMP16rr : I<0x39, MRMDestReg,
2305 (outs), (ins GR16:$src1, GR16:$src2),
2306 "cmp{w} {$src2, $src1|$src1, $src2}",
2307 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
2308 def CMP32rr : I<0x39, MRMDestReg,
2309 (outs), (ins GR32:$src1, GR32:$src2),
2310 "cmp{l} {$src2, $src1|$src1, $src2}",
2311 [(X86cmp GR32:$src1, GR32:$src2)]>;
2312 def CMP8mr : I<0x38, MRMDestMem,
2313 (outs), (ins i8mem :$src1, GR8 :$src2),
2314 "cmp{b} {$src2, $src1|$src1, $src2}",
2315 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
2316 def CMP16mr : I<0x39, MRMDestMem,
2317 (outs), (ins i16mem:$src1, GR16:$src2),
2318 "cmp{w} {$src2, $src1|$src1, $src2}",
2319 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
2320 def CMP32mr : I<0x39, MRMDestMem,
2321 (outs), (ins i32mem:$src1, GR32:$src2),
2322 "cmp{l} {$src2, $src1|$src1, $src2}",
2323 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
2324 def CMP8rm : I<0x3A, MRMSrcMem,
2325 (outs), (ins GR8 :$src1, i8mem :$src2),
2326 "cmp{b} {$src2, $src1|$src1, $src2}",
2327 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
2328 def CMP16rm : I<0x3B, MRMSrcMem,
2329 (outs), (ins GR16:$src1, i16mem:$src2),
2330 "cmp{w} {$src2, $src1|$src1, $src2}",
2331 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
2332 def CMP32rm : I<0x3B, MRMSrcMem,
2333 (outs), (ins GR32:$src1, i32mem:$src2),
2334 "cmp{l} {$src2, $src1|$src1, $src2}",
2335 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
2336 def CMP8ri : Ii8<0x80, MRM7r,
2337 (outs), (ins GR8:$src1, i8imm:$src2),
2338 "cmp{b} {$src2, $src1|$src1, $src2}",
2339 [(X86cmp GR8:$src1, imm:$src2)]>;
2340 def CMP16ri : Ii16<0x81, MRM7r,
2341 (outs), (ins GR16:$src1, i16imm:$src2),
2342 "cmp{w} {$src2, $src1|$src1, $src2}",
2343 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
2344 def CMP32ri : Ii32<0x81, MRM7r,
2345 (outs), (ins GR32:$src1, i32imm:$src2),
2346 "cmp{l} {$src2, $src1|$src1, $src2}",
2347 [(X86cmp GR32:$src1, imm:$src2)]>;
2348 def CMP8mi : Ii8 <0x80, MRM7m,
2349 (outs), (ins i8mem :$src1, i8imm :$src2),
2350 "cmp{b} {$src2, $src1|$src1, $src2}",
2351 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2352 def CMP16mi : Ii16<0x81, MRM7m,
2353 (outs), (ins i16mem:$src1, i16imm:$src2),
2354 "cmp{w} {$src2, $src1|$src1, $src2}",
2355 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2356 def CMP32mi : Ii32<0x81, MRM7m,
2357 (outs), (ins i32mem:$src1, i32imm:$src2),
2358 "cmp{l} {$src2, $src1|$src1, $src2}",
2359 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2360 def CMP16ri8 : Ii8<0x83, MRM7r,
2361 (outs), (ins GR16:$src1, i16i8imm:$src2),
2362 "cmp{w} {$src2, $src1|$src1, $src2}",
2363 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
2364 def CMP16mi8 : Ii8<0x83, MRM7m,
2365 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2366 "cmp{w} {$src2, $src1|$src1, $src2}",
2367 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
2368 def CMP32mi8 : Ii8<0x83, MRM7m,
2369 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2370 "cmp{l} {$src2, $src1|$src1, $src2}",
2371 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
2372 def CMP32ri8 : Ii8<0x83, MRM7r,
2373 (outs), (ins GR32:$src1, i32i8imm:$src2),
2374 "cmp{l} {$src2, $src1|$src1, $src2}",
2375 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
2377 // Sign/Zero extenders
2378 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2379 "movs{bw|x} {$src, $dst|$dst, $src}",
2380 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
2381 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2382 "movs{bw|x} {$src, $dst|$dst, $src}",
2383 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2384 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2385 "movs{bl|x} {$src, $dst|$dst, $src}",
2386 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2387 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2388 "movs{bl|x} {$src, $dst|$dst, $src}",
2389 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2390 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2391 "movs{wl|x} {$src, $dst|$dst, $src}",
2392 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2393 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2394 "movs{wl|x} {$src, $dst|$dst, $src}",
2395 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2397 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2398 "movz{bw|x} {$src, $dst|$dst, $src}",
2399 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
2400 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2401 "movz{bw|x} {$src, $dst|$dst, $src}",
2402 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2403 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2404 "movz{bl|x} {$src, $dst|$dst, $src}",
2405 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2406 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2407 "movz{bl|x} {$src, $dst|$dst, $src}",
2408 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2409 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2410 "movz{wl|x} {$src, $dst|$dst, $src}",
2411 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2412 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2413 "movz{wl|x} {$src, $dst|$dst, $src}",
2414 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2416 def CBW : I<0x98, RawFrm, (outs), (ins),
2417 "{cbtw|cbw}", []>, Imp<[AL],[AX]>, OpSize; // AX = signext(AL)
2418 def CWDE : I<0x98, RawFrm, (outs), (ins),
2419 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2421 def CWD : I<0x99, RawFrm, (outs), (ins),
2422 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>, OpSize; // DX:AX = signext(AX)
2423 def CDQ : I<0x99, RawFrm, (outs), (ins),
2424 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2427 //===----------------------------------------------------------------------===//
2428 // Alias Instructions
2429 //===----------------------------------------------------------------------===//
2431 // Alias instructions that map movr0 to xor.
2432 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2433 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
2434 "xor{b} $dst, $dst",
2435 [(set GR8:$dst, 0)]>;
2436 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
2437 "xor{w} $dst, $dst",
2438 [(set GR16:$dst, 0)]>, OpSize;
2439 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
2440 "xor{l} $dst, $dst",
2441 [(set GR32:$dst, 0)]>;
2443 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2444 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2445 def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
2446 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2447 def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
2448 "mov{l} {$src, $dst|$dst, $src}", []>;
2450 def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
2451 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2452 def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
2453 "mov{l} {$src, $dst|$dst, $src}", []>;
2454 def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
2455 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2456 def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
2457 "mov{l} {$src, $dst|$dst, $src}", []>;
2458 def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
2459 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2460 def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
2461 "mov{l} {$src, $dst|$dst, $src}", []>;
2463 //===----------------------------------------------------------------------===//
2464 // Thread Local Storage Instructions
2467 def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2468 "leal ${sym:mem}(,%ebx,1), $dst",
2469 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>,
2472 let AddedComplexity = 10 in
2473 def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
2474 "movl %gs:($src), $dst",
2475 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2477 let AddedComplexity = 15 in
2478 def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2479 "movl %gs:${src:mem}, $dst",
2481 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2483 def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
2485 [(set GR32:$dst, X86TLStp)]>;
2487 //===----------------------------------------------------------------------===//
2488 // DWARF Pseudo Instructions
2491 def DWARF_LOC : I<0, Pseudo, (outs),
2492 (ins i32imm:$line, i32imm:$col, i32imm:$file),
2493 "; .loc ${file:debug}, ${line:debug}, ${col:debug}",
2494 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2497 //===----------------------------------------------------------------------===//
2498 // EH Pseudo Instructions
2500 let isTerminator = 1, isReturn = 1, isBarrier = 1,
2502 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
2503 "ret #eh_return, addr: $addr",
2504 [(X86ehret GR32:$addr)]>;
2508 //===----------------------------------------------------------------------===//
2509 // Non-Instruction Patterns
2510 //===----------------------------------------------------------------------===//
2512 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2513 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2514 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2515 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2516 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2517 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2519 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2520 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2521 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2522 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2523 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2524 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2525 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2526 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2528 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2529 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2530 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2531 (MOV32mi addr:$dst, texternalsym:$src)>;
2534 def : Pat<(X86tailcall GR32:$dst),
2535 (CALL32r GR32:$dst)>;
2537 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2538 (CALLpcrel32 tglobaladdr:$dst)>;
2539 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2540 (CALLpcrel32 texternalsym:$dst)>;
2542 def : Pat<(X86call (i32 tglobaladdr:$dst)),
2543 (CALLpcrel32 tglobaladdr:$dst)>;
2544 def : Pat<(X86call (i32 texternalsym:$dst)),
2545 (CALLpcrel32 texternalsym:$dst)>;
2547 // X86 specific add which produces a flag.
2548 def : Pat<(addc GR32:$src1, GR32:$src2),
2549 (ADD32rr GR32:$src1, GR32:$src2)>;
2550 def : Pat<(addc GR32:$src1, (load addr:$src2)),
2551 (ADD32rm GR32:$src1, addr:$src2)>;
2552 def : Pat<(addc GR32:$src1, imm:$src2),
2553 (ADD32ri GR32:$src1, imm:$src2)>;
2554 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2555 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2557 def : Pat<(subc GR32:$src1, GR32:$src2),
2558 (SUB32rr GR32:$src1, GR32:$src2)>;
2559 def : Pat<(subc GR32:$src1, (load addr:$src2)),
2560 (SUB32rm GR32:$src1, addr:$src2)>;
2561 def : Pat<(subc GR32:$src1, imm:$src2),
2562 (SUB32ri GR32:$src1, imm:$src2)>;
2563 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2564 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2566 def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2567 (MOV8mi addr:$dst, imm:$src)>;
2568 def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2569 (MOV8mr addr:$dst, GR8:$src)>;
2573 // TEST R,R is smaller than CMP R,0
2574 def : Pat<(X86cmp GR8:$src1, 0),
2575 (TEST8rr GR8:$src1, GR8:$src1)>;
2576 def : Pat<(X86cmp GR16:$src1, 0),
2577 (TEST16rr GR16:$src1, GR16:$src1)>;
2578 def : Pat<(X86cmp GR32:$src1, 0),
2579 (TEST32rr GR32:$src1, GR32:$src1)>;
2581 // {s|z}extload bool -> {s|z}extload byte
2582 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2583 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2584 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2585 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2586 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2588 // extload bool -> extload byte
2589 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2590 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2591 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2592 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2593 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2594 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2597 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2598 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2599 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2600 def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2601 def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2602 def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2604 //===----------------------------------------------------------------------===//
2606 //===----------------------------------------------------------------------===//
2608 // (shl x, 1) ==> (add x, x)
2609 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2610 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2611 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2613 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2614 def : Pat<(or (srl GR32:$src1, CL:$amt),
2615 (shl GR32:$src2, (sub 32, CL:$amt))),
2616 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2618 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2619 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2620 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2622 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2623 def : Pat<(or (shl GR32:$src1, CL:$amt),
2624 (srl GR32:$src2, (sub 32, CL:$amt))),
2625 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2627 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2628 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2629 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2631 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2632 def : Pat<(or (srl GR16:$src1, CL:$amt),
2633 (shl GR16:$src2, (sub 16, CL:$amt))),
2634 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2636 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2637 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2638 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2640 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2641 def : Pat<(or (shl GR16:$src1, CL:$amt),
2642 (srl GR16:$src2, (sub 16, CL:$amt))),
2643 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2645 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2646 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2647 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2650 //===----------------------------------------------------------------------===//
2651 // Floating Point Stack Support
2652 //===----------------------------------------------------------------------===//
2654 include "X86InstrFPStack.td"
2656 //===----------------------------------------------------------------------===//
2657 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2658 //===----------------------------------------------------------------------===//
2660 include "X86InstrMMX.td"
2662 //===----------------------------------------------------------------------===//
2663 // XMM Floating point support (requires SSE / SSE2)
2664 //===----------------------------------------------------------------------===//
2666 include "X86InstrSSE.td"
2668 //===----------------------------------------------------------------------===//
2670 //===----------------------------------------------------------------------===//
2672 include "X86InstrX86-64.td"