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 X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
51 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
53 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
54 [SDNPHasChain, SDNPOutFlag]>;
56 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
57 [SDNPInFlag, SDNPOutFlag]>;
58 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
59 [SDNPHasChain, SDNPInFlag]>;
60 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
61 [SDNPInFlag, SDNPOutFlag]>;
63 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
64 [SDNPHasChain, SDNPOptInFlag]>;
66 def X86callseq_start :
67 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
68 [SDNPHasChain, SDNPOutFlag]>;
70 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
71 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
73 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
74 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
76 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
77 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
79 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
80 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
81 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
82 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
84 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
85 [SDNPHasChain, SDNPOutFlag]>;
87 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
88 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
90 //===----------------------------------------------------------------------===//
91 // X86 Operand Definitions.
94 // *mem - Operand definitions for the funky X86 addressing mode operands.
96 class X86MemOperand<string printMethod> : Operand<iPTR> {
97 let PrintMethod = printMethod;
98 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
101 def i8mem : X86MemOperand<"printi8mem">;
102 def i16mem : X86MemOperand<"printi16mem">;
103 def i32mem : X86MemOperand<"printi32mem">;
104 def i64mem : X86MemOperand<"printi64mem">;
105 def i128mem : X86MemOperand<"printi128mem">;
106 def f32mem : X86MemOperand<"printf32mem">;
107 def f64mem : X86MemOperand<"printf64mem">;
108 def f128mem : X86MemOperand<"printf128mem">;
110 def lea32mem : Operand<i32> {
111 let PrintMethod = "printi32mem";
112 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
115 def SSECC : Operand<i8> {
116 let PrintMethod = "printSSECC";
119 def piclabel: Operand<i32> {
120 let PrintMethod = "printPICLabel";
123 // A couple of more descriptive operand definitions.
124 // 16-bits but only 8 bits are significant.
125 def i16i8imm : Operand<i16>;
126 // 32-bits but only 8 bits are significant.
127 def i32i8imm : Operand<i32>;
129 // Branch targets have OtherVT type.
130 def brtarget : Operand<OtherVT>;
132 //===----------------------------------------------------------------------===//
133 // X86 Complex Pattern Definitions.
136 // Define X86 specific addressing mode.
137 def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
138 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
139 [add, mul, shl, or, frameindex], []>;
141 //===----------------------------------------------------------------------===//
142 // X86 Instruction Format Definitions.
145 // Format specifies the encoding used by the instruction. This is part of the
146 // ad-hoc solution used to emit machine instruction encodings by our machine
148 class Format<bits<6> val> {
152 def Pseudo : Format<0>; def RawFrm : Format<1>;
153 def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
154 def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
155 def MRMSrcMem : Format<6>;
156 def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
157 def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
158 def MRM6r : Format<22>; def MRM7r : Format<23>;
159 def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
160 def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
161 def MRM6m : Format<30>; def MRM7m : Format<31>;
162 def MRMInitReg : Format<32>;
164 //===----------------------------------------------------------------------===//
165 // X86 Instruction Predicate Definitions.
166 def HasMMX : Predicate<"Subtarget->hasMMX()">;
167 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
168 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
169 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
170 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
171 def FPStack : Predicate<"!Subtarget->hasSSE2()">;
172 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
173 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
174 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
175 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
176 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
178 //===----------------------------------------------------------------------===//
179 // X86 specific pattern fragments.
182 // ImmType - This specifies the immediate type used by an instruction. This is
183 // part of the ad-hoc solution used to emit machine instruction encodings by our
184 // machine code emitter.
185 class ImmType<bits<3> val> {
188 def NoImm : ImmType<0>;
189 def Imm8 : ImmType<1>;
190 def Imm16 : ImmType<2>;
191 def Imm32 : ImmType<3>;
192 def Imm64 : ImmType<4>;
194 // FPFormat - This specifies what form this FP instruction has. This is used by
195 // the Floating-Point stackifier pass.
196 class FPFormat<bits<3> val> {
199 def NotFP : FPFormat<0>;
200 def ZeroArgFP : FPFormat<1>;
201 def OneArgFP : FPFormat<2>;
202 def OneArgFPRW : FPFormat<3>;
203 def TwoArgFP : FPFormat<4>;
204 def CompareFP : FPFormat<5>;
205 def CondMovFP : FPFormat<6>;
206 def SpecialFP : FPFormat<7>;
209 class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
211 let Namespace = "X86";
213 bits<8> Opcode = opcod;
215 bits<6> FormBits = Form.Value;
217 bits<3> ImmTypeBits = ImmT.Value;
219 dag OperandList = ops;
220 string AsmString = AsmStr;
223 // Attributes specific to X86 instructions...
225 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
226 bit hasAdSizePrefix = 0; // Does this inst have a 0x67 prefix?
228 bits<4> Prefix = 0; // Which prefix byte does this inst have?
229 bit hasREX_WPrefix = 0; // Does this inst requires the REX.W prefix?
230 FPFormat FPForm; // What flavor of FP instruction is this?
231 bits<3> FPFormBits = 0;
235 // Prefix byte classes which are used to indicate to the ad-hoc machine code
236 // emitter that various prefix bytes are required.
237 class OpSize { bit hasOpSizePrefix = 1; }
238 class AdSize { bit hasAdSizePrefix = 1; }
239 class REX_W { bit hasREX_WPrefix = 1; }
240 class TB { bits<4> Prefix = 1; }
241 class REP { bits<4> Prefix = 2; }
242 class D8 { bits<4> Prefix = 3; }
243 class D9 { bits<4> Prefix = 4; }
244 class DA { bits<4> Prefix = 5; }
245 class DB { bits<4> Prefix = 6; }
246 class DC { bits<4> Prefix = 7; }
247 class DD { bits<4> Prefix = 8; }
248 class DE { bits<4> Prefix = 9; }
249 class DF { bits<4> Prefix = 10; }
250 class XD { bits<4> Prefix = 11; }
251 class XS { bits<4> Prefix = 12; }
252 class T8 { bits<4> Prefix = 13; }
253 class TA { bits<4> Prefix = 14; }
256 //===----------------------------------------------------------------------===//
257 // Pattern fragments...
260 // X86 specific condition code. These correspond to CondCode in
261 // X86ISelLowering.h. They must be kept in synch.
262 def X86_COND_A : PatLeaf<(i8 0)>;
263 def X86_COND_AE : PatLeaf<(i8 1)>;
264 def X86_COND_B : PatLeaf<(i8 2)>;
265 def X86_COND_BE : PatLeaf<(i8 3)>;
266 def X86_COND_E : PatLeaf<(i8 4)>;
267 def X86_COND_G : PatLeaf<(i8 5)>;
268 def X86_COND_GE : PatLeaf<(i8 6)>;
269 def X86_COND_L : PatLeaf<(i8 7)>;
270 def X86_COND_LE : PatLeaf<(i8 8)>;
271 def X86_COND_NE : PatLeaf<(i8 9)>;
272 def X86_COND_NO : PatLeaf<(i8 10)>;
273 def X86_COND_NP : PatLeaf<(i8 11)>;
274 def X86_COND_NS : PatLeaf<(i8 12)>;
275 def X86_COND_O : PatLeaf<(i8 13)>;
276 def X86_COND_P : PatLeaf<(i8 14)>;
277 def X86_COND_S : PatLeaf<(i8 15)>;
279 def i16immSExt8 : PatLeaf<(i16 imm), [{
280 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
281 // sign extended field.
282 return (int16_t)N->getValue() == (int8_t)N->getValue();
285 def i32immSExt8 : PatLeaf<(i32 imm), [{
286 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
287 // sign extended field.
288 return (int32_t)N->getValue() == (int8_t)N->getValue();
291 // Helper fragments for loads.
292 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
293 def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
294 def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
295 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
297 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
298 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
300 def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
301 def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
302 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
303 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
304 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
306 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
307 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
308 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
309 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
310 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
311 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
313 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
314 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
315 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
316 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
317 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
318 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
320 //===----------------------------------------------------------------------===//
321 // Instruction templates...
324 class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
325 : X86Inst<o, f, NoImm, ops, asm> {
326 let Pattern = pattern;
329 class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
330 : X86Inst<o, f, Imm8 , ops, asm> {
331 let Pattern = pattern;
334 class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
335 : X86Inst<o, f, Imm16, ops, asm> {
336 let Pattern = pattern;
339 class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
340 : X86Inst<o, f, Imm32, ops, asm> {
341 let Pattern = pattern;
345 //===----------------------------------------------------------------------===//
346 // Instruction list...
349 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
350 // a stack adjustment and the codegen must know that they may modify the stack
351 // pointer before prolog-epilog rewriting occurs.
352 def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
353 [(X86callseq_start imm:$amt)]>, Imp<[ESP],[ESP]>;
354 def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
356 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
358 def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
359 def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
360 def IMPLICIT_DEF_GR8 : I<0, Pseudo, (ops GR8:$dst),
361 "#IMPLICIT_DEF $dst",
362 [(set GR8:$dst, (undef))]>;
363 def IMPLICIT_DEF_GR16 : I<0, Pseudo, (ops GR16:$dst),
364 "#IMPLICIT_DEF $dst",
365 [(set GR16:$dst, (undef))]>;
366 def IMPLICIT_DEF_GR32 : I<0, Pseudo, (ops GR32:$dst),
367 "#IMPLICIT_DEF $dst",
368 [(set GR32:$dst, (undef))]>;
371 def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
374 def TRUNC_32_to8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR32_:$src),
375 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}", []>;
376 def TRUNC_16_to8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR16_:$src),
377 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}}", []>;
378 def TRUNC_32to16 : I<0x89, MRMDestReg, (ops GR16:$dst, GR32:$src),
379 "mov{w} {${src:subreg16}, $dst|$dst, ${src:subreg16}}",
380 [(set GR16:$dst, (trunc GR32:$src))]>;
382 //===----------------------------------------------------------------------===//
383 // Control Flow Instructions...
386 // Return instructions.
387 let isTerminator = 1, isReturn = 1, isBarrier = 1,
388 hasCtrlDep = 1, noResults = 1 in {
389 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
390 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
391 [(X86retflag imm:$amt)]>;
394 // All branches are RawFrm, Void, Branch, and Terminators
395 let isBranch = 1, isTerminator = 1, noResults = 1 in
396 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
397 I<opcode, RawFrm, ops, asm, pattern>;
400 let isBranch = 1, isBarrier = 1 in
401 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
403 let isBranch = 1, isTerminator = 1, noResults = 1, isBarrier = 1 in {
404 def JMP32r : I<0xFF, MRM4r, (ops GR32:$dst), "jmp{l} {*}$dst",
405 [(brind GR32:$dst)]>;
406 def JMP32m : I<0xFF, MRM4m, (ops i32mem:$dst), "jmp{l} {*}$dst",
407 [(brind (loadi32 addr:$dst))]>;
410 // Conditional branches
411 def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
412 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
413 def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
414 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
415 def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
416 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
417 def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
418 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
419 def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
420 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
421 def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
422 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
424 def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
425 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
426 def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
427 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
428 def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
429 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
430 def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
431 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
433 def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
434 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
435 def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
436 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
437 def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
438 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
439 def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
440 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
441 def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
442 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
443 def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
444 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
446 //===----------------------------------------------------------------------===//
447 // Call Instructions...
449 let isCall = 1, noResults = 1 in
450 // All calls clobber the non-callee saved registers...
451 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
452 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
453 def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst, variable_ops),
454 "call ${dst:call}", []>;
455 def CALL32r : I<0xFF, MRM2r, (ops GR32:$dst, variable_ops),
456 "call {*}$dst", [(X86call GR32:$dst)]>;
457 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst, variable_ops),
462 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
463 def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call} # TAIL CALL",
465 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
466 def TAILJMPr : I<0xFF, MRM4r, (ops GR32:$dst), "jmp {*}$dst # TAIL CALL",
468 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
469 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
470 "jmp {*}$dst # TAIL CALL", []>;
472 //===----------------------------------------------------------------------===//
473 // Miscellaneous Instructions...
475 def LEAVE : I<0xC9, RawFrm,
476 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
477 def POP32r : I<0x58, AddRegFrm,
478 (ops GR32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
480 def PUSH32r : I<0x50, AddRegFrm,
481 (ops GR32:$reg), "push{l} $reg", []>, Imp<[ESP],[ESP]>;
483 def MovePCtoStack : I<0, Pseudo, (ops piclabel:$label),
486 let isTwoAddress = 1 in // GR32 = bswap GR32
487 def BSWAP32r : I<0xC8, AddRegFrm,
488 (ops GR32:$dst, GR32:$src),
490 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
492 def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
493 (ops GR8:$src1, GR8:$src2),
494 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
495 def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
496 (ops GR16:$src1, GR16:$src2),
497 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
498 def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
499 (ops GR32:$src1, GR32:$src2),
500 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
502 def XCHG8mr : I<0x86, MRMDestMem,
503 (ops i8mem:$src1, GR8:$src2),
504 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
505 def XCHG16mr : I<0x87, MRMDestMem,
506 (ops i16mem:$src1, GR16:$src2),
507 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
508 def XCHG32mr : I<0x87, MRMDestMem,
509 (ops i32mem:$src1, GR32:$src2),
510 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
511 def XCHG8rm : I<0x86, MRMSrcMem,
512 (ops GR8:$src1, i8mem:$src2),
513 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
514 def XCHG16rm : I<0x87, MRMSrcMem,
515 (ops GR16:$src1, i16mem:$src2),
516 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
517 def XCHG32rm : I<0x87, MRMSrcMem,
518 (ops GR32:$src1, i32mem:$src2),
519 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
521 def LEA16r : I<0x8D, MRMSrcMem,
522 (ops GR16:$dst, i32mem:$src),
523 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
524 def LEA32r : I<0x8D, MRMSrcMem,
525 (ops GR32:$dst, lea32mem:$src),
526 "lea{l} {$src|$dst}, {$dst|$src}",
527 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
529 def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
531 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
532 def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
533 [(X86rep_movs i16)]>,
534 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
535 def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsl|rep movsd}",
536 [(X86rep_movs i32)]>,
537 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
539 def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
541 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
542 def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
543 [(X86rep_stos i16)]>,
544 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
545 def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
546 [(X86rep_stos i32)]>,
547 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
549 def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
550 TB, Imp<[],[RAX,RDX]>;
552 //===----------------------------------------------------------------------===//
553 // Input/Output Instructions...
555 def IN8rr : I<0xEC, RawFrm, (ops),
556 "in{b} {%dx, %al|%AL, %DX}",
557 []>, Imp<[DX], [AL]>;
558 def IN16rr : I<0xED, RawFrm, (ops),
559 "in{w} {%dx, %ax|%AX, %DX}",
560 []>, Imp<[DX], [AX]>, OpSize;
561 def IN32rr : I<0xED, RawFrm, (ops),
562 "in{l} {%dx, %eax|%EAX, %DX}",
563 []>, Imp<[DX],[EAX]>;
565 def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
566 "in{b} {$port, %al|%AL, $port}",
569 def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
570 "in{w} {$port, %ax|%AX, $port}",
572 Imp<[], [AX]>, OpSize;
573 def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
574 "in{l} {$port, %eax|%EAX, $port}",
578 def OUT8rr : I<0xEE, RawFrm, (ops),
579 "out{b} {%al, %dx|%DX, %AL}",
580 []>, Imp<[DX, AL], []>;
581 def OUT16rr : I<0xEF, RawFrm, (ops),
582 "out{w} {%ax, %dx|%DX, %AX}",
583 []>, Imp<[DX, AX], []>, OpSize;
584 def OUT32rr : I<0xEF, RawFrm, (ops),
585 "out{l} {%eax, %dx|%DX, %EAX}",
586 []>, Imp<[DX, EAX], []>;
588 def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
589 "out{b} {%al, $port|$port, %AL}",
592 def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
593 "out{w} {%ax, $port|$port, %AX}",
595 Imp<[AX], []>, OpSize;
596 def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
597 "out{l} {%eax, $port|$port, %EAX}",
601 //===----------------------------------------------------------------------===//
602 // Move Instructions...
604 def MOV8rr : I<0x88, MRMDestReg, (ops GR8 :$dst, GR8 :$src),
605 "mov{b} {$src, $dst|$dst, $src}", []>;
606 def MOV16rr : I<0x89, MRMDestReg, (ops GR16:$dst, GR16:$src),
607 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
608 def MOV32rr : I<0x89, MRMDestReg, (ops GR32:$dst, GR32:$src),
609 "mov{l} {$src, $dst|$dst, $src}", []>;
610 let isReMaterializable = 1 in {
611 def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops GR8 :$dst, i8imm :$src),
612 "mov{b} {$src, $dst|$dst, $src}",
613 [(set GR8:$dst, imm:$src)]>;
614 def MOV16ri : Ii16<0xB8, AddRegFrm, (ops GR16:$dst, i16imm:$src),
615 "mov{w} {$src, $dst|$dst, $src}",
616 [(set GR16:$dst, imm:$src)]>, OpSize;
617 def MOV32ri : Ii32<0xB8, AddRegFrm, (ops GR32:$dst, i32imm:$src),
618 "mov{l} {$src, $dst|$dst, $src}",
619 [(set GR32:$dst, imm:$src)]>;
621 def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
622 "mov{b} {$src, $dst|$dst, $src}",
623 [(store (i8 imm:$src), addr:$dst)]>;
624 def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
625 "mov{w} {$src, $dst|$dst, $src}",
626 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
627 def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
628 "mov{l} {$src, $dst|$dst, $src}",
629 [(store (i32 imm:$src), addr:$dst)]>;
631 def MOV8rm : I<0x8A, MRMSrcMem, (ops GR8 :$dst, i8mem :$src),
632 "mov{b} {$src, $dst|$dst, $src}",
633 [(set GR8:$dst, (load addr:$src))]>;
634 def MOV16rm : I<0x8B, MRMSrcMem, (ops GR16:$dst, i16mem:$src),
635 "mov{w} {$src, $dst|$dst, $src}",
636 [(set GR16:$dst, (load addr:$src))]>, OpSize;
637 def MOV32rm : I<0x8B, MRMSrcMem, (ops GR32:$dst, i32mem:$src),
638 "mov{l} {$src, $dst|$dst, $src}",
639 [(set GR32:$dst, (load addr:$src))]>;
641 def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, GR8 :$src),
642 "mov{b} {$src, $dst|$dst, $src}",
643 [(store GR8:$src, addr:$dst)]>;
644 def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16:$src),
645 "mov{w} {$src, $dst|$dst, $src}",
646 [(store GR16:$src, addr:$dst)]>, OpSize;
647 def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32:$src),
648 "mov{l} {$src, $dst|$dst, $src}",
649 [(store GR32:$src, addr:$dst)]>;
651 //===----------------------------------------------------------------------===//
652 // Fixed-Register Multiplication and Division Instructions...
655 // Extra precision multiplication
656 def MUL8r : I<0xF6, MRM4r, (ops GR8:$src), "mul{b} $src",
657 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
658 // This probably ought to be moved to a def : Pat<> if the
659 // syntax can be accepted.
660 [(set AL, (mul AL, GR8:$src))]>,
661 Imp<[AL],[AX]>; // AL,AH = AL*GR8
662 def MUL16r : I<0xF7, MRM4r, (ops GR16:$src), "mul{w} $src", []>,
663 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
664 def MUL32r : I<0xF7, MRM4r, (ops GR32:$src), "mul{l} $src", []>,
665 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
666 def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
668 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
669 // This probably ought to be moved to a def : Pat<> if the
670 // syntax can be accepted.
671 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
672 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
673 def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
674 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
675 OpSize; // AX,DX = AX*[mem16]
676 def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
677 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
679 def IMUL8r : I<0xF6, MRM5r, (ops GR8:$src), "imul{b} $src", []>,
680 Imp<[AL],[AX]>; // AL,AH = AL*GR8
681 def IMUL16r : I<0xF7, MRM5r, (ops GR16:$src), "imul{w} $src", []>,
682 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
683 def IMUL32r : I<0xF7, MRM5r, (ops GR32:$src), "imul{l} $src", []>,
684 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
685 def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
686 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
687 def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
688 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
689 OpSize; // AX,DX = AX*[mem16]
690 def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
692 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
694 // unsigned division/remainder
695 def DIV8r : I<0xF6, MRM6r, (ops GR8:$src), // AX/r8 = AL,AH
696 "div{b} $src", []>, Imp<[AX],[AX]>;
697 def DIV16r : I<0xF7, MRM6r, (ops GR16:$src), // DX:AX/r16 = AX,DX
698 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
699 def DIV32r : I<0xF7, MRM6r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
700 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
701 def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
702 "div{b} $src", []>, Imp<[AX],[AX]>;
703 def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
704 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
705 def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
706 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
708 // Signed division/remainder.
709 def IDIV8r : I<0xF6, MRM7r, (ops GR8:$src), // AX/r8 = AL,AH
710 "idiv{b} $src", []>, Imp<[AX],[AX]>;
711 def IDIV16r: I<0xF7, MRM7r, (ops GR16:$src), // DX:AX/r16 = AX,DX
712 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
713 def IDIV32r: I<0xF7, MRM7r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
714 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
715 def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
716 "idiv{b} $src", []>, Imp<[AX],[AX]>;
717 def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
718 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
719 def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
720 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
723 //===----------------------------------------------------------------------===//
724 // Two address Instructions...
726 let isTwoAddress = 1 in {
729 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
730 (ops GR16:$dst, GR16:$src1, GR16:$src2),
731 "cmovb {$src2, $dst|$dst, $src2}",
732 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
735 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
736 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
737 "cmovb {$src2, $dst|$dst, $src2}",
738 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
741 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
742 (ops GR32:$dst, GR32:$src1, GR32:$src2),
743 "cmovb {$src2, $dst|$dst, $src2}",
744 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
747 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
748 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
749 "cmovb {$src2, $dst|$dst, $src2}",
750 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
754 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
755 (ops GR16:$dst, GR16:$src1, GR16:$src2),
756 "cmovae {$src2, $dst|$dst, $src2}",
757 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
760 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
761 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
762 "cmovae {$src2, $dst|$dst, $src2}",
763 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
766 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
767 (ops GR32:$dst, GR32:$src1, GR32:$src2),
768 "cmovae {$src2, $dst|$dst, $src2}",
769 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
772 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
773 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
774 "cmovae {$src2, $dst|$dst, $src2}",
775 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
779 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
780 (ops GR16:$dst, GR16:$src1, GR16:$src2),
781 "cmove {$src2, $dst|$dst, $src2}",
782 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
785 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
786 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
787 "cmove {$src2, $dst|$dst, $src2}",
788 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
791 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
792 (ops GR32:$dst, GR32:$src1, GR32:$src2),
793 "cmove {$src2, $dst|$dst, $src2}",
794 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
797 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
798 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
799 "cmove {$src2, $dst|$dst, $src2}",
800 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
804 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
805 (ops GR16:$dst, GR16:$src1, GR16:$src2),
806 "cmovne {$src2, $dst|$dst, $src2}",
807 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
810 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
811 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
812 "cmovne {$src2, $dst|$dst, $src2}",
813 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
816 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
817 (ops GR32:$dst, GR32:$src1, GR32:$src2),
818 "cmovne {$src2, $dst|$dst, $src2}",
819 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
822 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
823 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
824 "cmovne {$src2, $dst|$dst, $src2}",
825 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
829 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
830 (ops GR16:$dst, GR16:$src1, GR16:$src2),
831 "cmovbe {$src2, $dst|$dst, $src2}",
832 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
835 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
836 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
837 "cmovbe {$src2, $dst|$dst, $src2}",
838 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
841 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
842 (ops GR32:$dst, GR32:$src1, GR32:$src2),
843 "cmovbe {$src2, $dst|$dst, $src2}",
844 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
847 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
848 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
849 "cmovbe {$src2, $dst|$dst, $src2}",
850 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
854 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
855 (ops GR16:$dst, GR16:$src1, GR16:$src2),
856 "cmova {$src2, $dst|$dst, $src2}",
857 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
860 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
861 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
862 "cmova {$src2, $dst|$dst, $src2}",
863 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
866 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
867 (ops GR32:$dst, GR32:$src1, GR32:$src2),
868 "cmova {$src2, $dst|$dst, $src2}",
869 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
872 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
873 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
874 "cmova {$src2, $dst|$dst, $src2}",
875 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
879 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
880 (ops GR16:$dst, GR16:$src1, GR16:$src2),
881 "cmovl {$src2, $dst|$dst, $src2}",
882 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
885 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
886 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
887 "cmovl {$src2, $dst|$dst, $src2}",
888 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
891 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
892 (ops GR32:$dst, GR32:$src1, GR32:$src2),
893 "cmovl {$src2, $dst|$dst, $src2}",
894 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
897 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
898 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
899 "cmovl {$src2, $dst|$dst, $src2}",
900 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
904 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
905 (ops GR16:$dst, GR16:$src1, GR16:$src2),
906 "cmovge {$src2, $dst|$dst, $src2}",
907 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
910 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
911 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
912 "cmovge {$src2, $dst|$dst, $src2}",
913 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
916 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
917 (ops GR32:$dst, GR32:$src1, GR32:$src2),
918 "cmovge {$src2, $dst|$dst, $src2}",
919 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
922 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
923 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
924 "cmovge {$src2, $dst|$dst, $src2}",
925 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
929 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
930 (ops GR16:$dst, GR16:$src1, GR16:$src2),
931 "cmovle {$src2, $dst|$dst, $src2}",
932 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
935 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
936 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
937 "cmovle {$src2, $dst|$dst, $src2}",
938 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
941 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
942 (ops GR32:$dst, GR32:$src1, GR32:$src2),
943 "cmovle {$src2, $dst|$dst, $src2}",
944 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
947 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
948 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
949 "cmovle {$src2, $dst|$dst, $src2}",
950 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
954 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
955 (ops GR16:$dst, GR16:$src1, GR16:$src2),
956 "cmovg {$src2, $dst|$dst, $src2}",
957 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
960 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
961 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
962 "cmovg {$src2, $dst|$dst, $src2}",
963 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
966 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
967 (ops GR32:$dst, GR32:$src1, GR32:$src2),
968 "cmovg {$src2, $dst|$dst, $src2}",
969 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
972 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
973 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
974 "cmovg {$src2, $dst|$dst, $src2}",
975 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
979 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
980 (ops GR16:$dst, GR16:$src1, GR16:$src2),
981 "cmovs {$src2, $dst|$dst, $src2}",
982 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
985 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
986 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
987 "cmovs {$src2, $dst|$dst, $src2}",
988 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
991 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
992 (ops GR32:$dst, GR32:$src1, GR32:$src2),
993 "cmovs {$src2, $dst|$dst, $src2}",
994 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
997 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
998 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
999 "cmovs {$src2, $dst|$dst, $src2}",
1000 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1004 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1005 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1006 "cmovns {$src2, $dst|$dst, $src2}",
1007 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1010 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1011 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1012 "cmovns {$src2, $dst|$dst, $src2}",
1013 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1016 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1017 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1018 "cmovns {$src2, $dst|$dst, $src2}",
1019 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1022 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1023 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1024 "cmovns {$src2, $dst|$dst, $src2}",
1025 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1029 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1030 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1031 "cmovp {$src2, $dst|$dst, $src2}",
1032 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1035 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1036 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1037 "cmovp {$src2, $dst|$dst, $src2}",
1038 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1041 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1042 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1043 "cmovp {$src2, $dst|$dst, $src2}",
1044 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1047 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1048 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1049 "cmovp {$src2, $dst|$dst, $src2}",
1050 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1054 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1055 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1056 "cmovnp {$src2, $dst|$dst, $src2}",
1057 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1060 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1061 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1062 "cmovnp {$src2, $dst|$dst, $src2}",
1063 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1066 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1067 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1068 "cmovnp {$src2, $dst|$dst, $src2}",
1069 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1072 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1073 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1074 "cmovnp {$src2, $dst|$dst, $src2}",
1075 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1080 // unary instructions
1081 let CodeSize = 2 in {
1082 def NEG8r : I<0xF6, MRM3r, (ops GR8 :$dst, GR8 :$src), "neg{b} $dst",
1083 [(set GR8:$dst, (ineg GR8:$src))]>;
1084 def NEG16r : I<0xF7, MRM3r, (ops GR16:$dst, GR16:$src), "neg{w} $dst",
1085 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1086 def NEG32r : I<0xF7, MRM3r, (ops GR32:$dst, GR32:$src), "neg{l} $dst",
1087 [(set GR32:$dst, (ineg GR32:$src))]>;
1088 let isTwoAddress = 0 in {
1089 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
1090 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1091 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
1092 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1093 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
1094 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1098 def NOT8r : I<0xF6, MRM2r, (ops GR8 :$dst, GR8 :$src), "not{b} $dst",
1099 [(set GR8:$dst, (not GR8:$src))]>;
1100 def NOT16r : I<0xF7, MRM2r, (ops GR16:$dst, GR16:$src), "not{w} $dst",
1101 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1102 def NOT32r : I<0xF7, MRM2r, (ops GR32:$dst, GR32:$src), "not{l} $dst",
1103 [(set GR32:$dst, (not GR32:$src))]>;
1104 let isTwoAddress = 0 in {
1105 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
1106 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1107 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
1108 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1109 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
1110 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1114 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1116 def INC8r : I<0xFE, MRM0r, (ops GR8 :$dst, GR8 :$src), "inc{b} $dst",
1117 [(set GR8:$dst, (add GR8:$src, 1))]>;
1118 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1119 def INC16r : I<0x40, AddRegFrm, (ops GR16:$dst, GR16:$src), "inc{w} $dst",
1120 [(set GR16:$dst, (add GR16:$src, 1))]>,
1121 OpSize, Requires<[In32BitMode]>;
1122 def INC32r : I<0x40, AddRegFrm, (ops GR32:$dst, GR32:$src), "inc{l} $dst",
1123 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1125 let isTwoAddress = 0, CodeSize = 2 in {
1126 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
1127 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1128 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
1129 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
1130 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
1131 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1135 def DEC8r : I<0xFE, MRM1r, (ops GR8 :$dst, GR8 :$src), "dec{b} $dst",
1136 [(set GR8:$dst, (add GR8:$src, -1))]>;
1137 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1138 def DEC16r : I<0x48, AddRegFrm, (ops GR16:$dst, GR16:$src), "dec{w} $dst",
1139 [(set GR16:$dst, (add GR16:$src, -1))]>,
1140 OpSize, Requires<[In32BitMode]>;
1141 def DEC32r : I<0x48, AddRegFrm, (ops GR32:$dst, GR32:$src), "dec{l} $dst",
1142 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1145 let isTwoAddress = 0, CodeSize = 2 in {
1146 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
1147 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1148 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
1149 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
1150 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
1151 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1154 // Logical operators...
1155 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1156 def AND8rr : I<0x20, MRMDestReg,
1157 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1158 "and{b} {$src2, $dst|$dst, $src2}",
1159 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1160 def AND16rr : I<0x21, MRMDestReg,
1161 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1162 "and{w} {$src2, $dst|$dst, $src2}",
1163 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1164 def AND32rr : I<0x21, MRMDestReg,
1165 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1166 "and{l} {$src2, $dst|$dst, $src2}",
1167 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1170 def AND8rm : I<0x22, MRMSrcMem,
1171 (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1172 "and{b} {$src2, $dst|$dst, $src2}",
1173 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1174 def AND16rm : I<0x23, MRMSrcMem,
1175 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1176 "and{w} {$src2, $dst|$dst, $src2}",
1177 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1178 def AND32rm : I<0x23, MRMSrcMem,
1179 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1180 "and{l} {$src2, $dst|$dst, $src2}",
1181 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1183 def AND8ri : Ii8<0x80, MRM4r,
1184 (ops GR8 :$dst, GR8 :$src1, i8imm :$src2),
1185 "and{b} {$src2, $dst|$dst, $src2}",
1186 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1187 def AND16ri : Ii16<0x81, MRM4r,
1188 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1189 "and{w} {$src2, $dst|$dst, $src2}",
1190 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1191 def AND32ri : Ii32<0x81, MRM4r,
1192 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1193 "and{l} {$src2, $dst|$dst, $src2}",
1194 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1195 def AND16ri8 : Ii8<0x83, MRM4r,
1196 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1197 "and{w} {$src2, $dst|$dst, $src2}",
1198 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1200 def AND32ri8 : Ii8<0x83, MRM4r,
1201 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1202 "and{l} {$src2, $dst|$dst, $src2}",
1203 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1205 let isTwoAddress = 0 in {
1206 def AND8mr : I<0x20, MRMDestMem,
1207 (ops i8mem :$dst, GR8 :$src),
1208 "and{b} {$src, $dst|$dst, $src}",
1209 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1210 def AND16mr : I<0x21, MRMDestMem,
1211 (ops i16mem:$dst, GR16:$src),
1212 "and{w} {$src, $dst|$dst, $src}",
1213 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1215 def AND32mr : I<0x21, MRMDestMem,
1216 (ops i32mem:$dst, GR32:$src),
1217 "and{l} {$src, $dst|$dst, $src}",
1218 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1219 def AND8mi : Ii8<0x80, MRM4m,
1220 (ops i8mem :$dst, i8imm :$src),
1221 "and{b} {$src, $dst|$dst, $src}",
1222 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1223 def AND16mi : Ii16<0x81, MRM4m,
1224 (ops i16mem:$dst, i16imm:$src),
1225 "and{w} {$src, $dst|$dst, $src}",
1226 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1228 def AND32mi : Ii32<0x81, MRM4m,
1229 (ops i32mem:$dst, i32imm:$src),
1230 "and{l} {$src, $dst|$dst, $src}",
1231 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1232 def AND16mi8 : Ii8<0x83, MRM4m,
1233 (ops i16mem:$dst, i16i8imm :$src),
1234 "and{w} {$src, $dst|$dst, $src}",
1235 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1237 def AND32mi8 : Ii8<0x83, MRM4m,
1238 (ops i32mem:$dst, i32i8imm :$src),
1239 "and{l} {$src, $dst|$dst, $src}",
1240 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1244 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1245 def OR8rr : I<0x08, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1246 "or{b} {$src2, $dst|$dst, $src2}",
1247 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1248 def OR16rr : I<0x09, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1249 "or{w} {$src2, $dst|$dst, $src2}",
1250 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1251 def OR32rr : I<0x09, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1252 "or{l} {$src2, $dst|$dst, $src2}",
1253 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1255 def OR8rm : I<0x0A, MRMSrcMem , (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1256 "or{b} {$src2, $dst|$dst, $src2}",
1257 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1258 def OR16rm : I<0x0B, MRMSrcMem , (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1259 "or{w} {$src2, $dst|$dst, $src2}",
1260 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1261 def OR32rm : I<0x0B, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1262 "or{l} {$src2, $dst|$dst, $src2}",
1263 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1265 def OR8ri : Ii8 <0x80, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1266 "or{b} {$src2, $dst|$dst, $src2}",
1267 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1268 def OR16ri : Ii16<0x81, MRM1r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1269 "or{w} {$src2, $dst|$dst, $src2}",
1270 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1271 def OR32ri : Ii32<0x81, MRM1r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1272 "or{l} {$src2, $dst|$dst, $src2}",
1273 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1275 def OR16ri8 : Ii8<0x83, MRM1r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1276 "or{w} {$src2, $dst|$dst, $src2}",
1277 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1278 def OR32ri8 : Ii8<0x83, MRM1r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1279 "or{l} {$src2, $dst|$dst, $src2}",
1280 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1281 let isTwoAddress = 0 in {
1282 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, GR8:$src),
1283 "or{b} {$src, $dst|$dst, $src}",
1284 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1285 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, GR16:$src),
1286 "or{w} {$src, $dst|$dst, $src}",
1287 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1288 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, GR32:$src),
1289 "or{l} {$src, $dst|$dst, $src}",
1290 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
1291 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
1292 "or{b} {$src, $dst|$dst, $src}",
1293 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1294 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
1295 "or{w} {$src, $dst|$dst, $src}",
1296 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1298 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
1299 "or{l} {$src, $dst|$dst, $src}",
1300 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1301 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1302 "or{w} {$src, $dst|$dst, $src}",
1303 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1305 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1306 "or{l} {$src, $dst|$dst, $src}",
1307 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1311 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1312 def XOR8rr : I<0x30, MRMDestReg,
1313 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1314 "xor{b} {$src2, $dst|$dst, $src2}",
1315 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1316 def XOR16rr : I<0x31, MRMDestReg,
1317 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1318 "xor{w} {$src2, $dst|$dst, $src2}",
1319 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1320 def XOR32rr : I<0x31, MRMDestReg,
1321 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1322 "xor{l} {$src2, $dst|$dst, $src2}",
1323 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1326 def XOR8rm : I<0x32, MRMSrcMem ,
1327 (ops GR8 :$dst, GR8:$src1, i8mem :$src2),
1328 "xor{b} {$src2, $dst|$dst, $src2}",
1329 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1330 def XOR16rm : I<0x33, MRMSrcMem ,
1331 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1332 "xor{w} {$src2, $dst|$dst, $src2}",
1333 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1334 def XOR32rm : I<0x33, MRMSrcMem ,
1335 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1336 "xor{l} {$src2, $dst|$dst, $src2}",
1337 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1339 def XOR8ri : Ii8<0x80, MRM6r,
1340 (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1341 "xor{b} {$src2, $dst|$dst, $src2}",
1342 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1343 def XOR16ri : Ii16<0x81, MRM6r,
1344 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1345 "xor{w} {$src2, $dst|$dst, $src2}",
1346 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1347 def XOR32ri : Ii32<0x81, MRM6r,
1348 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1349 "xor{l} {$src2, $dst|$dst, $src2}",
1350 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1351 def XOR16ri8 : Ii8<0x83, MRM6r,
1352 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1353 "xor{w} {$src2, $dst|$dst, $src2}",
1354 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1356 def XOR32ri8 : Ii8<0x83, MRM6r,
1357 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1358 "xor{l} {$src2, $dst|$dst, $src2}",
1359 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1360 let isTwoAddress = 0 in {
1361 def XOR8mr : I<0x30, MRMDestMem,
1362 (ops i8mem :$dst, GR8 :$src),
1363 "xor{b} {$src, $dst|$dst, $src}",
1364 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1365 def XOR16mr : I<0x31, MRMDestMem,
1366 (ops i16mem:$dst, GR16:$src),
1367 "xor{w} {$src, $dst|$dst, $src}",
1368 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1370 def XOR32mr : I<0x31, MRMDestMem,
1371 (ops i32mem:$dst, GR32:$src),
1372 "xor{l} {$src, $dst|$dst, $src}",
1373 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1374 def XOR8mi : Ii8<0x80, MRM6m,
1375 (ops i8mem :$dst, i8imm :$src),
1376 "xor{b} {$src, $dst|$dst, $src}",
1377 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1378 def XOR16mi : Ii16<0x81, MRM6m,
1379 (ops i16mem:$dst, i16imm:$src),
1380 "xor{w} {$src, $dst|$dst, $src}",
1381 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1383 def XOR32mi : Ii32<0x81, MRM6m,
1384 (ops i32mem:$dst, i32imm:$src),
1385 "xor{l} {$src, $dst|$dst, $src}",
1386 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1387 def XOR16mi8 : Ii8<0x83, MRM6m,
1388 (ops i16mem:$dst, i16i8imm :$src),
1389 "xor{w} {$src, $dst|$dst, $src}",
1390 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1392 def XOR32mi8 : Ii8<0x83, MRM6m,
1393 (ops i32mem:$dst, i32i8imm :$src),
1394 "xor{l} {$src, $dst|$dst, $src}",
1395 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1398 // Shift instructions
1399 def SHL8rCL : I<0xD2, MRM4r, (ops GR8 :$dst, GR8 :$src),
1400 "shl{b} {%cl, $dst|$dst, %CL}",
1401 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
1402 def SHL16rCL : I<0xD3, MRM4r, (ops GR16:$dst, GR16:$src),
1403 "shl{w} {%cl, $dst|$dst, %CL}",
1404 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1405 def SHL32rCL : I<0xD3, MRM4r, (ops GR32:$dst, GR32:$src),
1406 "shl{l} {%cl, $dst|$dst, %CL}",
1407 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
1409 def SHL8ri : Ii8<0xC0, MRM4r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1410 "shl{b} {$src2, $dst|$dst, $src2}",
1411 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1412 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1413 def SHL16ri : Ii8<0xC1, MRM4r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1414 "shl{w} {$src2, $dst|$dst, $src2}",
1415 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1416 def SHL32ri : Ii8<0xC1, MRM4r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1417 "shl{l} {$src2, $dst|$dst, $src2}",
1418 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1421 // Shift left by one. Not used because (add x, x) is slightly cheaper.
1422 def SHL8r1 : I<0xD0, MRM4r, (ops GR8 :$dst, GR8 :$src1),
1424 def SHL16r1 : I<0xD1, MRM4r, (ops GR16:$dst, GR16:$src1),
1425 "shl{w} $dst", []>, OpSize;
1426 def SHL32r1 : I<0xD1, MRM4r, (ops GR32:$dst, GR32:$src1),
1429 let isTwoAddress = 0 in {
1430 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
1431 "shl{b} {%cl, $dst|$dst, %CL}",
1432 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1434 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
1435 "shl{w} {%cl, $dst|$dst, %CL}",
1436 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1437 Imp<[CL],[]>, OpSize;
1438 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
1439 "shl{l} {%cl, $dst|$dst, %CL}",
1440 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1442 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
1443 "shl{b} {$src, $dst|$dst, $src}",
1444 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1445 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
1446 "shl{w} {$src, $dst|$dst, $src}",
1447 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1449 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
1450 "shl{l} {$src, $dst|$dst, $src}",
1451 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1454 def SHL8m1 : I<0xD0, MRM4m, (ops i8mem :$dst),
1456 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1457 def SHL16m1 : I<0xD1, MRM4m, (ops i16mem:$dst),
1459 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1461 def SHL32m1 : I<0xD1, MRM4m, (ops i32mem:$dst),
1463 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1466 def SHR8rCL : I<0xD2, MRM5r, (ops GR8 :$dst, GR8 :$src),
1467 "shr{b} {%cl, $dst|$dst, %CL}",
1468 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
1469 def SHR16rCL : I<0xD3, MRM5r, (ops GR16:$dst, GR16:$src),
1470 "shr{w} {%cl, $dst|$dst, %CL}",
1471 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1472 def SHR32rCL : I<0xD3, MRM5r, (ops GR32:$dst, GR32:$src),
1473 "shr{l} {%cl, $dst|$dst, %CL}",
1474 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
1476 def SHR8ri : Ii8<0xC0, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1477 "shr{b} {$src2, $dst|$dst, $src2}",
1478 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1479 def SHR16ri : Ii8<0xC1, MRM5r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1480 "shr{w} {$src2, $dst|$dst, $src2}",
1481 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1482 def SHR32ri : Ii8<0xC1, MRM5r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1483 "shr{l} {$src2, $dst|$dst, $src2}",
1484 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1487 def SHR8r1 : I<0xD0, MRM5r, (ops GR8:$dst, GR8:$src1),
1489 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1490 def SHR16r1 : I<0xD1, MRM5r, (ops GR16:$dst, GR16:$src1),
1492 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1493 def SHR32r1 : I<0xD1, MRM5r, (ops GR32:$dst, GR32:$src1),
1495 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1497 let isTwoAddress = 0 in {
1498 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
1499 "shr{b} {%cl, $dst|$dst, %CL}",
1500 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1502 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
1503 "shr{w} {%cl, $dst|$dst, %CL}",
1504 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1505 Imp<[CL],[]>, OpSize;
1506 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
1507 "shr{l} {%cl, $dst|$dst, %CL}",
1508 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1510 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
1511 "shr{b} {$src, $dst|$dst, $src}",
1512 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1513 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
1514 "shr{w} {$src, $dst|$dst, $src}",
1515 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1517 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
1518 "shr{l} {$src, $dst|$dst, $src}",
1519 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1522 def SHR8m1 : I<0xD0, MRM5m, (ops i8mem :$dst),
1524 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1525 def SHR16m1 : I<0xD1, MRM5m, (ops i16mem:$dst),
1527 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1528 def SHR32m1 : I<0xD1, MRM5m, (ops i32mem:$dst),
1530 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1533 def SAR8rCL : I<0xD2, MRM7r, (ops GR8 :$dst, GR8 :$src),
1534 "sar{b} {%cl, $dst|$dst, %CL}",
1535 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
1536 def SAR16rCL : I<0xD3, MRM7r, (ops GR16:$dst, GR16:$src),
1537 "sar{w} {%cl, $dst|$dst, %CL}",
1538 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1539 def SAR32rCL : I<0xD3, MRM7r, (ops GR32:$dst, GR32:$src),
1540 "sar{l} {%cl, $dst|$dst, %CL}",
1541 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
1543 def SAR8ri : Ii8<0xC0, MRM7r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1544 "sar{b} {$src2, $dst|$dst, $src2}",
1545 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1546 def SAR16ri : Ii8<0xC1, MRM7r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1547 "sar{w} {$src2, $dst|$dst, $src2}",
1548 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1550 def SAR32ri : Ii8<0xC1, MRM7r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1551 "sar{l} {$src2, $dst|$dst, $src2}",
1552 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1555 def SAR8r1 : I<0xD0, MRM7r, (ops GR8 :$dst, GR8 :$src1),
1557 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1558 def SAR16r1 : I<0xD1, MRM7r, (ops GR16:$dst, GR16:$src1),
1560 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1561 def SAR32r1 : I<0xD1, MRM7r, (ops GR32:$dst, GR32:$src1),
1563 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1565 let isTwoAddress = 0 in {
1566 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
1567 "sar{b} {%cl, $dst|$dst, %CL}",
1568 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1570 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
1571 "sar{w} {%cl, $dst|$dst, %CL}",
1572 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1573 Imp<[CL],[]>, OpSize;
1574 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
1575 "sar{l} {%cl, $dst|$dst, %CL}",
1576 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1578 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
1579 "sar{b} {$src, $dst|$dst, $src}",
1580 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1581 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
1582 "sar{w} {$src, $dst|$dst, $src}",
1583 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1585 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
1586 "sar{l} {$src, $dst|$dst, $src}",
1587 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1590 def SAR8m1 : I<0xD0, MRM7m, (ops i8mem :$dst),
1592 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1593 def SAR16m1 : I<0xD1, MRM7m, (ops i16mem:$dst),
1595 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1597 def SAR32m1 : I<0xD1, MRM7m, (ops i32mem:$dst),
1599 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1602 // Rotate instructions
1603 // FIXME: provide shorter instructions when imm8 == 1
1604 def ROL8rCL : I<0xD2, MRM0r, (ops GR8 :$dst, GR8 :$src),
1605 "rol{b} {%cl, $dst|$dst, %CL}",
1606 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
1607 def ROL16rCL : I<0xD3, MRM0r, (ops GR16:$dst, GR16:$src),
1608 "rol{w} {%cl, $dst|$dst, %CL}",
1609 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1610 def ROL32rCL : I<0xD3, MRM0r, (ops GR32:$dst, GR32:$src),
1611 "rol{l} {%cl, $dst|$dst, %CL}",
1612 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
1614 def ROL8ri : Ii8<0xC0, MRM0r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1615 "rol{b} {$src2, $dst|$dst, $src2}",
1616 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1617 def ROL16ri : Ii8<0xC1, MRM0r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1618 "rol{w} {$src2, $dst|$dst, $src2}",
1619 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1620 def ROL32ri : Ii8<0xC1, MRM0r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1621 "rol{l} {$src2, $dst|$dst, $src2}",
1622 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1625 def ROL8r1 : I<0xD0, MRM0r, (ops GR8 :$dst, GR8 :$src1),
1627 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1628 def ROL16r1 : I<0xD1, MRM0r, (ops GR16:$dst, GR16:$src1),
1630 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1631 def ROL32r1 : I<0xD1, MRM0r, (ops GR32:$dst, GR32:$src1),
1633 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1635 let isTwoAddress = 0 in {
1636 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
1637 "rol{b} {%cl, $dst|$dst, %CL}",
1638 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1640 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
1641 "rol{w} {%cl, $dst|$dst, %CL}",
1642 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1643 Imp<[CL],[]>, OpSize;
1644 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
1645 "rol{l} {%cl, $dst|$dst, %CL}",
1646 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1648 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
1649 "rol{b} {$src, $dst|$dst, $src}",
1650 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1651 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
1652 "rol{w} {$src, $dst|$dst, $src}",
1653 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1655 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
1656 "rol{l} {$src, $dst|$dst, $src}",
1657 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1660 def ROL8m1 : I<0xD0, MRM0m, (ops i8mem :$dst),
1662 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1663 def ROL16m1 : I<0xD1, MRM0m, (ops i16mem:$dst),
1665 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1667 def ROL32m1 : I<0xD1, MRM0m, (ops i32mem:$dst),
1669 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1672 def ROR8rCL : I<0xD2, MRM1r, (ops GR8 :$dst, GR8 :$src),
1673 "ror{b} {%cl, $dst|$dst, %CL}",
1674 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
1675 def ROR16rCL : I<0xD3, MRM1r, (ops GR16:$dst, GR16:$src),
1676 "ror{w} {%cl, $dst|$dst, %CL}",
1677 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1678 def ROR32rCL : I<0xD3, MRM1r, (ops GR32:$dst, GR32:$src),
1679 "ror{l} {%cl, $dst|$dst, %CL}",
1680 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
1682 def ROR8ri : Ii8<0xC0, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1683 "ror{b} {$src2, $dst|$dst, $src2}",
1684 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1685 def ROR16ri : Ii8<0xC1, MRM1r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1686 "ror{w} {$src2, $dst|$dst, $src2}",
1687 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1688 def ROR32ri : Ii8<0xC1, MRM1r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1689 "ror{l} {$src2, $dst|$dst, $src2}",
1690 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1693 def ROR8r1 : I<0xD0, MRM1r, (ops GR8 :$dst, GR8 :$src1),
1695 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1696 def ROR16r1 : I<0xD1, MRM1r, (ops GR16:$dst, GR16:$src1),
1698 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1699 def ROR32r1 : I<0xD1, MRM1r, (ops GR32:$dst, GR32:$src1),
1701 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1703 let isTwoAddress = 0 in {
1704 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
1705 "ror{b} {%cl, $dst|$dst, %CL}",
1706 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1708 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
1709 "ror{w} {%cl, $dst|$dst, %CL}",
1710 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1711 Imp<[CL],[]>, OpSize;
1712 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
1713 "ror{l} {%cl, $dst|$dst, %CL}",
1714 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1716 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
1717 "ror{b} {$src, $dst|$dst, $src}",
1718 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1719 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
1720 "ror{w} {$src, $dst|$dst, $src}",
1721 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1723 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
1724 "ror{l} {$src, $dst|$dst, $src}",
1725 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1728 def ROR8m1 : I<0xD0, MRM1m, (ops i8mem :$dst),
1730 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1731 def ROR16m1 : I<0xD1, MRM1m, (ops i16mem:$dst),
1733 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1735 def ROR32m1 : I<0xD1, MRM1m, (ops i32mem:$dst),
1737 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1742 // Double shift instructions (generalizations of rotate)
1743 def SHLD32rrCL : I<0xA5, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1744 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1745 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
1747 def SHRD32rrCL : I<0xAD, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1748 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1749 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
1751 def SHLD16rrCL : I<0xA5, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1752 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1753 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1754 Imp<[CL],[]>, TB, OpSize;
1755 def SHRD16rrCL : I<0xAD, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1756 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1757 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1758 Imp<[CL],[]>, TB, OpSize;
1760 let isCommutable = 1 in { // These instructions commute to each other.
1761 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1762 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
1763 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1764 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1767 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1768 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
1769 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1770 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1773 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1774 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
1775 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1776 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1779 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1780 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
1781 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1782 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1787 let isTwoAddress = 0 in {
1788 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1789 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1790 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1793 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1794 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1795 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1798 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1799 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
1800 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1801 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1802 (i8 imm:$src3)), addr:$dst)]>,
1804 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1805 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
1806 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1807 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1808 (i8 imm:$src3)), addr:$dst)]>,
1811 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1812 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1813 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1815 Imp<[CL],[]>, TB, OpSize;
1816 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1817 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1818 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1820 Imp<[CL],[]>, TB, OpSize;
1821 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1822 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
1823 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1824 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1825 (i8 imm:$src3)), addr:$dst)]>,
1827 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1828 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
1829 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1830 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1831 (i8 imm:$src3)), addr:$dst)]>,
1837 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1838 def ADD8rr : I<0x00, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1839 "add{b} {$src2, $dst|$dst, $src2}",
1840 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1841 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1842 def ADD16rr : I<0x01, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1843 "add{w} {$src2, $dst|$dst, $src2}",
1844 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1845 def ADD32rr : I<0x01, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1846 "add{l} {$src2, $dst|$dst, $src2}",
1847 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1848 } // end isConvertibleToThreeAddress
1849 } // end isCommutable
1850 def ADD8rm : I<0x02, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1851 "add{b} {$src2, $dst|$dst, $src2}",
1852 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1853 def ADD16rm : I<0x03, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1854 "add{w} {$src2, $dst|$dst, $src2}",
1855 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
1856 def ADD32rm : I<0x03, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1857 "add{l} {$src2, $dst|$dst, $src2}",
1858 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1860 def ADD8ri : Ii8<0x80, MRM0r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1861 "add{b} {$src2, $dst|$dst, $src2}",
1862 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1864 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1865 def ADD16ri : Ii16<0x81, MRM0r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1866 "add{w} {$src2, $dst|$dst, $src2}",
1867 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1868 def ADD32ri : Ii32<0x81, MRM0r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1869 "add{l} {$src2, $dst|$dst, $src2}",
1870 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
1871 def ADD16ri8 : Ii8<0x83, MRM0r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1872 "add{w} {$src2, $dst|$dst, $src2}",
1873 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
1875 def ADD32ri8 : Ii8<0x83, MRM0r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1876 "add{l} {$src2, $dst|$dst, $src2}",
1877 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1880 let isTwoAddress = 0 in {
1881 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
1882 "add{b} {$src2, $dst|$dst, $src2}",
1883 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1884 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1885 "add{w} {$src2, $dst|$dst, $src2}",
1886 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1888 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1889 "add{l} {$src2, $dst|$dst, $src2}",
1890 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
1891 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
1892 "add{b} {$src2, $dst|$dst, $src2}",
1893 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1894 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
1895 "add{w} {$src2, $dst|$dst, $src2}",
1896 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1898 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
1899 "add{l} {$src2, $dst|$dst, $src2}",
1900 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1901 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1902 "add{w} {$src2, $dst|$dst, $src2}",
1903 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1905 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1906 "add{l} {$src2, $dst|$dst, $src2}",
1907 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1910 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1911 def ADC32rr : I<0x11, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1912 "adc{l} {$src2, $dst|$dst, $src2}",
1913 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1915 def ADC32rm : I<0x13, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1916 "adc{l} {$src2, $dst|$dst, $src2}",
1917 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1918 def ADC32ri : Ii32<0x81, MRM2r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1919 "adc{l} {$src2, $dst|$dst, $src2}",
1920 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1921 def ADC32ri8 : Ii8<0x83, MRM2r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1922 "adc{l} {$src2, $dst|$dst, $src2}",
1923 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1925 let isTwoAddress = 0 in {
1926 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1927 "adc{l} {$src2, $dst|$dst, $src2}",
1928 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
1929 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
1930 "adc{l} {$src2, $dst|$dst, $src2}",
1931 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1932 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1933 "adc{l} {$src2, $dst|$dst, $src2}",
1934 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1937 def SUB8rr : I<0x28, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1938 "sub{b} {$src2, $dst|$dst, $src2}",
1939 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1940 def SUB16rr : I<0x29, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1941 "sub{w} {$src2, $dst|$dst, $src2}",
1942 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1943 def SUB32rr : I<0x29, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1944 "sub{l} {$src2, $dst|$dst, $src2}",
1945 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1946 def SUB8rm : I<0x2A, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1947 "sub{b} {$src2, $dst|$dst, $src2}",
1948 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1949 def SUB16rm : I<0x2B, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1950 "sub{w} {$src2, $dst|$dst, $src2}",
1951 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1952 def SUB32rm : I<0x2B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1953 "sub{l} {$src2, $dst|$dst, $src2}",
1954 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1956 def SUB8ri : Ii8 <0x80, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1957 "sub{b} {$src2, $dst|$dst, $src2}",
1958 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1959 def SUB16ri : Ii16<0x81, MRM5r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1960 "sub{w} {$src2, $dst|$dst, $src2}",
1961 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1962 def SUB32ri : Ii32<0x81, MRM5r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1963 "sub{l} {$src2, $dst|$dst, $src2}",
1964 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1965 def SUB16ri8 : Ii8<0x83, MRM5r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1966 "sub{w} {$src2, $dst|$dst, $src2}",
1967 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
1969 def SUB32ri8 : Ii8<0x83, MRM5r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1970 "sub{l} {$src2, $dst|$dst, $src2}",
1971 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1972 let isTwoAddress = 0 in {
1973 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
1974 "sub{b} {$src2, $dst|$dst, $src2}",
1975 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
1976 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1977 "sub{w} {$src2, $dst|$dst, $src2}",
1978 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
1980 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1981 "sub{l} {$src2, $dst|$dst, $src2}",
1982 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
1983 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
1984 "sub{b} {$src2, $dst|$dst, $src2}",
1985 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1986 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
1987 "sub{w} {$src2, $dst|$dst, $src2}",
1988 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1990 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
1991 "sub{l} {$src2, $dst|$dst, $src2}",
1992 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1993 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1994 "sub{w} {$src2, $dst|$dst, $src2}",
1995 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1997 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1998 "sub{l} {$src2, $dst|$dst, $src2}",
1999 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2002 def SBB32rr : I<0x19, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
2003 "sbb{l} {$src2, $dst|$dst, $src2}",
2004 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2006 let isTwoAddress = 0 in {
2007 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
2008 "sbb{l} {$src2, $dst|$dst, $src2}",
2009 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2010 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
2011 "sbb{b} {$src2, $dst|$dst, $src2}",
2012 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2013 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
2014 "sbb{l} {$src2, $dst|$dst, $src2}",
2015 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2016 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
2017 "sbb{l} {$src2, $dst|$dst, $src2}",
2018 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2020 def SBB32rm : I<0x1B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
2021 "sbb{l} {$src2, $dst|$dst, $src2}",
2022 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2023 def SBB32ri : Ii32<0x81, MRM3r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
2024 "sbb{l} {$src2, $dst|$dst, $src2}",
2025 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2026 def SBB32ri8 : Ii8<0x83, MRM3r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
2027 "sbb{l} {$src2, $dst|$dst, $src2}",
2028 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2030 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2031 def IMUL16rr : I<0xAF, MRMSrcReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
2032 "imul{w} {$src2, $dst|$dst, $src2}",
2033 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2034 def IMUL32rr : I<0xAF, MRMSrcReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
2035 "imul{l} {$src2, $dst|$dst, $src2}",
2036 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2038 def IMUL16rm : I<0xAF, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
2039 "imul{w} {$src2, $dst|$dst, $src2}",
2040 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2042 def IMUL32rm : I<0xAF, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
2043 "imul{l} {$src2, $dst|$dst, $src2}",
2044 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
2046 } // end Two Address instructions
2048 // Suprisingly enough, these are not two address instructions!
2049 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2050 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
2051 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2052 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2053 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2054 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
2055 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2056 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2057 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2058 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
2059 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2060 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2062 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2063 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
2064 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2065 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2067 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2068 (ops GR16:$dst, i16mem:$src1, i16imm:$src2),
2069 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2070 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2072 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2073 (ops GR32:$dst, i32mem:$src1, i32imm:$src2),
2074 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2075 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2076 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2077 (ops GR16:$dst, i16mem:$src1, i16i8imm :$src2),
2078 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2079 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2081 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2082 (ops GR32:$dst, i32mem:$src1, i32i8imm: $src2),
2083 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2084 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2086 //===----------------------------------------------------------------------===//
2087 // Test instructions are just like AND, except they don't generate a result.
2089 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2090 def TEST8rr : I<0x84, MRMDestReg, (ops GR8:$src1, GR8:$src2),
2091 "test{b} {$src2, $src1|$src1, $src2}",
2092 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
2093 def TEST16rr : I<0x85, MRMDestReg, (ops GR16:$src1, GR16:$src2),
2094 "test{w} {$src2, $src1|$src1, $src2}",
2095 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
2096 def TEST32rr : I<0x85, MRMDestReg, (ops GR32:$src1, GR32:$src2),
2097 "test{l} {$src2, $src1|$src1, $src2}",
2098 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
2101 def TEST8rm : I<0x84, MRMSrcMem, (ops GR8 :$src1, i8mem :$src2),
2102 "test{b} {$src2, $src1|$src1, $src2}",
2103 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
2104 def TEST16rm : I<0x85, MRMSrcMem, (ops GR16:$src1, i16mem:$src2),
2105 "test{w} {$src2, $src1|$src1, $src2}",
2106 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
2108 def TEST32rm : I<0x85, MRMSrcMem, (ops GR32:$src1, i32mem:$src2),
2109 "test{l} {$src2, $src1|$src1, $src2}",
2110 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
2112 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2113 (ops GR8:$src1, i8imm:$src2),
2114 "test{b} {$src2, $src1|$src1, $src2}",
2115 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
2116 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2117 (ops GR16:$src1, i16imm:$src2),
2118 "test{w} {$src2, $src1|$src1, $src2}",
2119 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
2120 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2121 (ops GR32:$src1, i32imm:$src2),
2122 "test{l} {$src2, $src1|$src1, $src2}",
2123 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
2125 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2126 (ops i8mem:$src1, i8imm:$src2),
2127 "test{b} {$src2, $src1|$src1, $src2}",
2128 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
2129 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2130 (ops i16mem:$src1, i16imm:$src2),
2131 "test{w} {$src2, $src1|$src1, $src2}",
2132 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
2134 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2135 (ops i32mem:$src1, i32imm:$src2),
2136 "test{l} {$src2, $src1|$src1, $src2}",
2137 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
2140 // Condition code ops, incl. set if equal/not equal/...
2141 def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2142 def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
2144 def SETEr : I<0x94, MRM0r,
2147 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2149 def SETEm : I<0x94, MRM0m,
2152 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2154 def SETNEr : I<0x95, MRM0r,
2157 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2159 def SETNEm : I<0x95, MRM0m,
2162 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2164 def SETLr : I<0x9C, MRM0r,
2167 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2168 TB; // GR8 = < signed
2169 def SETLm : I<0x9C, MRM0m,
2172 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2173 TB; // [mem8] = < signed
2174 def SETGEr : I<0x9D, MRM0r,
2177 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2178 TB; // GR8 = >= signed
2179 def SETGEm : I<0x9D, MRM0m,
2182 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2183 TB; // [mem8] = >= signed
2184 def SETLEr : I<0x9E, MRM0r,
2187 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2188 TB; // GR8 = <= signed
2189 def SETLEm : I<0x9E, MRM0m,
2192 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2193 TB; // [mem8] = <= signed
2194 def SETGr : I<0x9F, MRM0r,
2197 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2198 TB; // GR8 = > signed
2199 def SETGm : I<0x9F, MRM0m,
2202 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2203 TB; // [mem8] = > signed
2205 def SETBr : I<0x92, MRM0r,
2208 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2209 TB; // GR8 = < unsign
2210 def SETBm : I<0x92, MRM0m,
2213 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2214 TB; // [mem8] = < unsign
2215 def SETAEr : I<0x93, MRM0r,
2218 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2219 TB; // GR8 = >= unsign
2220 def SETAEm : I<0x93, MRM0m,
2223 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2224 TB; // [mem8] = >= unsign
2225 def SETBEr : I<0x96, MRM0r,
2228 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2229 TB; // GR8 = <= unsign
2230 def SETBEm : I<0x96, MRM0m,
2233 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2234 TB; // [mem8] = <= unsign
2235 def SETAr : I<0x97, MRM0r,
2238 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2239 TB; // GR8 = > signed
2240 def SETAm : I<0x97, MRM0m,
2243 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2244 TB; // [mem8] = > signed
2246 def SETSr : I<0x98, MRM0r,
2249 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2250 TB; // GR8 = <sign bit>
2251 def SETSm : I<0x98, MRM0m,
2254 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2255 TB; // [mem8] = <sign bit>
2256 def SETNSr : I<0x99, MRM0r,
2259 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2260 TB; // GR8 = !<sign bit>
2261 def SETNSm : I<0x99, MRM0m,
2264 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2265 TB; // [mem8] = !<sign bit>
2266 def SETPr : I<0x9A, MRM0r,
2269 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2271 def SETPm : I<0x9A, MRM0m,
2274 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2275 TB; // [mem8] = parity
2276 def SETNPr : I<0x9B, MRM0r,
2279 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2280 TB; // GR8 = not parity
2281 def SETNPm : I<0x9B, MRM0m,
2284 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2285 TB; // [mem8] = not parity
2287 // Integer comparisons
2288 def CMP8rr : I<0x38, MRMDestReg,
2289 (ops GR8 :$src1, GR8 :$src2),
2290 "cmp{b} {$src2, $src1|$src1, $src2}",
2291 [(X86cmp GR8:$src1, GR8:$src2)]>;
2292 def CMP16rr : I<0x39, MRMDestReg,
2293 (ops GR16:$src1, GR16:$src2),
2294 "cmp{w} {$src2, $src1|$src1, $src2}",
2295 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
2296 def CMP32rr : I<0x39, MRMDestReg,
2297 (ops GR32:$src1, GR32:$src2),
2298 "cmp{l} {$src2, $src1|$src1, $src2}",
2299 [(X86cmp GR32:$src1, GR32:$src2)]>;
2300 def CMP8mr : I<0x38, MRMDestMem,
2301 (ops i8mem :$src1, GR8 :$src2),
2302 "cmp{b} {$src2, $src1|$src1, $src2}",
2303 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
2304 def CMP16mr : I<0x39, MRMDestMem,
2305 (ops i16mem:$src1, GR16:$src2),
2306 "cmp{w} {$src2, $src1|$src1, $src2}",
2307 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
2308 def CMP32mr : I<0x39, MRMDestMem,
2309 (ops i32mem:$src1, GR32:$src2),
2310 "cmp{l} {$src2, $src1|$src1, $src2}",
2311 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
2312 def CMP8rm : I<0x3A, MRMSrcMem,
2313 (ops GR8 :$src1, i8mem :$src2),
2314 "cmp{b} {$src2, $src1|$src1, $src2}",
2315 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
2316 def CMP16rm : I<0x3B, MRMSrcMem,
2317 (ops GR16:$src1, i16mem:$src2),
2318 "cmp{w} {$src2, $src1|$src1, $src2}",
2319 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
2320 def CMP32rm : I<0x3B, MRMSrcMem,
2321 (ops GR32:$src1, i32mem:$src2),
2322 "cmp{l} {$src2, $src1|$src1, $src2}",
2323 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
2324 def CMP8ri : Ii8<0x80, MRM7r,
2325 (ops GR8:$src1, i8imm:$src2),
2326 "cmp{b} {$src2, $src1|$src1, $src2}",
2327 [(X86cmp GR8:$src1, imm:$src2)]>;
2328 def CMP16ri : Ii16<0x81, MRM7r,
2329 (ops GR16:$src1, i16imm:$src2),
2330 "cmp{w} {$src2, $src1|$src1, $src2}",
2331 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
2332 def CMP32ri : Ii32<0x81, MRM7r,
2333 (ops GR32:$src1, i32imm:$src2),
2334 "cmp{l} {$src2, $src1|$src1, $src2}",
2335 [(X86cmp GR32:$src1, imm:$src2)]>;
2336 def CMP8mi : Ii8 <0x80, MRM7m,
2337 (ops i8mem :$src1, i8imm :$src2),
2338 "cmp{b} {$src2, $src1|$src1, $src2}",
2339 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2340 def CMP16mi : Ii16<0x81, MRM7m,
2341 (ops i16mem:$src1, i16imm:$src2),
2342 "cmp{w} {$src2, $src1|$src1, $src2}",
2343 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2344 def CMP32mi : Ii32<0x81, MRM7m,
2345 (ops i32mem:$src1, i32imm:$src2),
2346 "cmp{l} {$src2, $src1|$src1, $src2}",
2347 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2348 def CMP16ri8 : Ii8<0x83, MRM7r,
2349 (ops GR16:$src1, i16i8imm:$src2),
2350 "cmp{w} {$src2, $src1|$src1, $src2}",
2351 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
2352 def CMP16mi8 : Ii8<0x83, MRM7m,
2353 (ops i16mem:$src1, i16i8imm:$src2),
2354 "cmp{w} {$src2, $src1|$src1, $src2}",
2355 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
2356 def CMP32mi8 : Ii8<0x83, MRM7m,
2357 (ops i32mem:$src1, i32i8imm:$src2),
2358 "cmp{l} {$src2, $src1|$src1, $src2}",
2359 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
2360 def CMP32ri8 : Ii8<0x83, MRM7r,
2361 (ops GR32:$src1, i32i8imm:$src2),
2362 "cmp{l} {$src2, $src1|$src1, $src2}",
2363 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
2365 // Sign/Zero extenders
2366 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
2367 "movs{bw|x} {$src, $dst|$dst, $src}",
2368 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
2369 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
2370 "movs{bw|x} {$src, $dst|$dst, $src}",
2371 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2372 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
2373 "movs{bl|x} {$src, $dst|$dst, $src}",
2374 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2375 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
2376 "movs{bl|x} {$src, $dst|$dst, $src}",
2377 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2378 def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops GR32:$dst, GR16:$src),
2379 "movs{wl|x} {$src, $dst|$dst, $src}",
2380 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2381 def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
2382 "movs{wl|x} {$src, $dst|$dst, $src}",
2383 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2385 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
2386 "movz{bw|x} {$src, $dst|$dst, $src}",
2387 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
2388 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
2389 "movz{bw|x} {$src, $dst|$dst, $src}",
2390 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2391 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
2392 "movz{bl|x} {$src, $dst|$dst, $src}",
2393 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2394 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
2395 "movz{bl|x} {$src, $dst|$dst, $src}",
2396 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2397 def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops GR32:$dst, GR16:$src),
2398 "movz{wl|x} {$src, $dst|$dst, $src}",
2399 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2400 def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
2401 "movz{wl|x} {$src, $dst|$dst, $src}",
2402 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2404 def CBW : I<0x98, RawFrm, (ops),
2405 "{cbtw|cbw}", []>, Imp<[AL],[AX]>, OpSize; // AX = signext(AL)
2406 def CWDE : I<0x98, RawFrm, (ops),
2407 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2409 def CWD : I<0x99, RawFrm, (ops),
2410 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>, OpSize; // DX:AX = signext(AX)
2411 def CDQ : I<0x99, RawFrm, (ops),
2412 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2415 //===----------------------------------------------------------------------===//
2416 // Alias Instructions
2417 //===----------------------------------------------------------------------===//
2419 // Alias instructions that map movr0 to xor.
2420 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2421 def MOV8r0 : I<0x30, MRMInitReg, (ops GR8 :$dst),
2422 "xor{b} $dst, $dst",
2423 [(set GR8:$dst, 0)]>;
2424 def MOV16r0 : I<0x31, MRMInitReg, (ops GR16:$dst),
2425 "xor{w} $dst, $dst",
2426 [(set GR16:$dst, 0)]>, OpSize;
2427 def MOV32r0 : I<0x31, MRMInitReg, (ops GR32:$dst),
2428 "xor{l} $dst, $dst",
2429 [(set GR32:$dst, 0)]>;
2431 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2432 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2433 def MOV16to16_ : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16:$src),
2434 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2435 def MOV32to32_ : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32:$src),
2436 "mov{l} {$src, $dst|$dst, $src}", []>;
2438 def MOV16_rr : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16_:$src),
2439 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2440 def MOV32_rr : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32_:$src),
2441 "mov{l} {$src, $dst|$dst, $src}", []>;
2442 def MOV16_rm : I<0x8B, MRMSrcMem, (ops GR16_:$dst, i16mem:$src),
2443 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2444 def MOV32_rm : I<0x8B, MRMSrcMem, (ops GR32_:$dst, i32mem:$src),
2445 "mov{l} {$src, $dst|$dst, $src}", []>;
2446 def MOV16_mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16_:$src),
2447 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2448 def MOV32_mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32_:$src),
2449 "mov{l} {$src, $dst|$dst, $src}", []>;
2451 //===----------------------------------------------------------------------===//
2452 // DWARF Pseudo Instructions
2455 def DWARF_LOC : I<0, Pseudo, (ops i32imm:$line, i32imm:$col, i32imm:$file),
2456 "; .loc $file, $line, $col",
2457 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2460 //===----------------------------------------------------------------------===//
2461 // Non-Instruction Patterns
2462 //===----------------------------------------------------------------------===//
2464 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2465 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2466 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2467 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2468 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2470 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2471 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2472 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2473 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2474 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2475 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2476 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2477 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2479 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2480 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2481 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2482 (MOV32mi addr:$dst, texternalsym:$src)>;
2485 def : Pat<(X86tailcall GR32:$dst),
2486 (CALL32r GR32:$dst)>;
2488 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2489 (CALLpcrel32 tglobaladdr:$dst)>;
2490 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2491 (CALLpcrel32 texternalsym:$dst)>;
2493 def : Pat<(X86call (i32 tglobaladdr:$dst)),
2494 (CALLpcrel32 tglobaladdr:$dst)>;
2495 def : Pat<(X86call (i32 texternalsym:$dst)),
2496 (CALLpcrel32 texternalsym:$dst)>;
2498 // X86 specific add which produces a flag.
2499 def : Pat<(addc GR32:$src1, GR32:$src2),
2500 (ADD32rr GR32:$src1, GR32:$src2)>;
2501 def : Pat<(addc GR32:$src1, (load addr:$src2)),
2502 (ADD32rm GR32:$src1, addr:$src2)>;
2503 def : Pat<(addc GR32:$src1, imm:$src2),
2504 (ADD32ri GR32:$src1, imm:$src2)>;
2505 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2506 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2508 def : Pat<(subc GR32:$src1, GR32:$src2),
2509 (SUB32rr GR32:$src1, GR32:$src2)>;
2510 def : Pat<(subc GR32:$src1, (load addr:$src2)),
2511 (SUB32rm GR32:$src1, addr:$src2)>;
2512 def : Pat<(subc GR32:$src1, imm:$src2),
2513 (SUB32ri GR32:$src1, imm:$src2)>;
2514 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2515 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2517 def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2518 (MOV8mi addr:$dst, imm:$src)>;
2519 def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2520 (MOV8mr addr:$dst, GR8:$src)>;
2524 // TEST R,R is smaller than CMP R,0
2525 def : Pat<(X86cmp GR8:$src1, 0),
2526 (TEST8rr GR8:$src1, GR8:$src1)>;
2527 def : Pat<(X86cmp GR16:$src1, 0),
2528 (TEST16rr GR16:$src1, GR16:$src1)>;
2529 def : Pat<(X86cmp GR32:$src1, 0),
2530 (TEST32rr GR32:$src1, GR32:$src1)>;
2532 // {s|z}extload bool -> {s|z}extload byte
2533 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2534 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2535 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2536 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2537 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2539 // extload bool -> extload byte
2540 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2541 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2542 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2543 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2544 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2545 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2548 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2549 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2550 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2551 def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2552 def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2553 def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2555 //===----------------------------------------------------------------------===//
2557 //===----------------------------------------------------------------------===//
2559 // (shl x, 1) ==> (add x, x)
2560 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2561 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2562 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2564 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2565 def : Pat<(or (srl GR32:$src1, CL:$amt),
2566 (shl GR32:$src2, (sub 32, CL:$amt))),
2567 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2569 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2570 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2571 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2573 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2574 def : Pat<(or (shl GR32:$src1, CL:$amt),
2575 (srl GR32:$src2, (sub 32, CL:$amt))),
2576 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2578 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2579 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2580 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2582 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2583 def : Pat<(or (srl GR16:$src1, CL:$amt),
2584 (shl GR16:$src2, (sub 16, CL:$amt))),
2585 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2587 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2588 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2589 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2591 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2592 def : Pat<(or (shl GR16:$src1, CL:$amt),
2593 (srl GR16:$src2, (sub 16, CL:$amt))),
2594 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2596 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2597 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2598 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2601 //===----------------------------------------------------------------------===//
2602 // Floating Point Stack Support
2603 //===----------------------------------------------------------------------===//
2605 include "X86InstrFPStack.td"
2607 //===----------------------------------------------------------------------===//
2608 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2609 //===----------------------------------------------------------------------===//
2611 include "X86InstrMMX.td"
2613 //===----------------------------------------------------------------------===//
2614 // XMM Floating point support (requires SSE / SSE2)
2615 //===----------------------------------------------------------------------===//
2617 include "X86InstrSSE.td"
2619 //===----------------------------------------------------------------------===//
2621 //===----------------------------------------------------------------------===//
2623 include "X86InstrX86-64.td"