1 //===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86 instruction set, defining the instructions, and
11 // properties of the instructions which are needed for code generation, machine
12 // code emission, and analysis.
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
17 // X86 specific DAG Nodes.
20 def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
24 def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
26 def SDTX86Cmov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
30 def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
33 def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
36 def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
38 def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39 def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
42 def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
44 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
46 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
48 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
50 def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
52 def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
54 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
55 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
57 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
58 [SDNPHasChain, SDNPOutFlag]>;
60 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
61 [SDNPInFlag, SDNPOutFlag]>;
62 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
63 [SDNPHasChain, SDNPInFlag]>;
64 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
65 [SDNPInFlag, SDNPOutFlag]>;
67 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
68 [SDNPHasChain, SDNPOptInFlag]>;
70 def X86callseq_start :
71 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
72 [SDNPHasChain, SDNPOutFlag]>;
74 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
75 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
77 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
78 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
80 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
81 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
83 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
84 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
85 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
86 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
88 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
89 [SDNPHasChain, SDNPOutFlag]>;
91 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
92 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
94 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
95 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
96 def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
99 //===----------------------------------------------------------------------===//
100 // X86 Operand Definitions.
103 // *mem - Operand definitions for the funky X86 addressing mode operands.
105 class X86MemOperand<string printMethod> : Operand<iPTR> {
106 let PrintMethod = printMethod;
107 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
110 def i8mem : X86MemOperand<"printi8mem">;
111 def i16mem : X86MemOperand<"printi16mem">;
112 def i32mem : X86MemOperand<"printi32mem">;
113 def i64mem : X86MemOperand<"printi64mem">;
114 def i128mem : X86MemOperand<"printi128mem">;
115 def f32mem : X86MemOperand<"printf32mem">;
116 def f64mem : X86MemOperand<"printf64mem">;
117 def f128mem : X86MemOperand<"printf128mem">;
119 def lea32mem : Operand<i32> {
120 let PrintMethod = "printi32mem";
121 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
124 def SSECC : Operand<i8> {
125 let PrintMethod = "printSSECC";
128 def piclabel: Operand<i32> {
129 let PrintMethod = "printPICLabel";
132 // A couple of more descriptive operand definitions.
133 // 16-bits but only 8 bits are significant.
134 def i16i8imm : Operand<i16>;
135 // 32-bits but only 8 bits are significant.
136 def i32i8imm : Operand<i32>;
138 // Branch targets have OtherVT type.
139 def brtarget : Operand<OtherVT>;
141 //===----------------------------------------------------------------------===//
142 // X86 Complex Pattern Definitions.
145 // Define X86 specific addressing mode.
146 def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
147 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
148 [add, mul, shl, or, frameindex], []>;
150 //===----------------------------------------------------------------------===//
151 // X86 Instruction Format Definitions.
154 // Format specifies the encoding used by the instruction. This is part of the
155 // ad-hoc solution used to emit machine instruction encodings by our machine
157 class Format<bits<6> val> {
161 def Pseudo : Format<0>; def RawFrm : Format<1>;
162 def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
163 def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
164 def MRMSrcMem : Format<6>;
165 def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
166 def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
167 def MRM6r : Format<22>; def MRM7r : Format<23>;
168 def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
169 def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
170 def MRM6m : Format<30>; def MRM7m : Format<31>;
171 def MRMInitReg : Format<32>;
173 //===----------------------------------------------------------------------===//
174 // X86 Instruction Predicate Definitions.
175 def HasMMX : Predicate<"Subtarget->hasMMX()">;
176 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
177 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
178 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
179 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
180 def FPStack : Predicate<"!Subtarget->hasSSE2()">;
181 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
182 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
183 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
184 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
185 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
187 //===----------------------------------------------------------------------===//
188 // X86 specific pattern fragments.
191 // ImmType - This specifies the immediate type used by an instruction. This is
192 // part of the ad-hoc solution used to emit machine instruction encodings by our
193 // machine code emitter.
194 class ImmType<bits<3> val> {
197 def NoImm : ImmType<0>;
198 def Imm8 : ImmType<1>;
199 def Imm16 : ImmType<2>;
200 def Imm32 : ImmType<3>;
201 def Imm64 : ImmType<4>;
203 // FPFormat - This specifies what form this FP instruction has. This is used by
204 // the Floating-Point stackifier pass.
205 class FPFormat<bits<3> val> {
208 def NotFP : FPFormat<0>;
209 def ZeroArgFP : FPFormat<1>;
210 def OneArgFP : FPFormat<2>;
211 def OneArgFPRW : FPFormat<3>;
212 def TwoArgFP : FPFormat<4>;
213 def CompareFP : FPFormat<5>;
214 def CondMovFP : FPFormat<6>;
215 def SpecialFP : FPFormat<7>;
218 class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
220 let Namespace = "X86";
222 bits<8> Opcode = opcod;
224 bits<6> FormBits = Form.Value;
226 bits<3> ImmTypeBits = ImmT.Value;
228 dag OperandList = ops;
229 string AsmString = AsmStr;
232 // Attributes specific to X86 instructions...
234 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
235 bit hasAdSizePrefix = 0; // Does this inst have a 0x67 prefix?
237 bits<4> Prefix = 0; // Which prefix byte does this inst have?
238 bit hasREX_WPrefix = 0; // Does this inst requires the REX.W prefix?
239 FPFormat FPForm; // What flavor of FP instruction is this?
240 bits<3> FPFormBits = 0;
244 // Prefix byte classes which are used to indicate to the ad-hoc machine code
245 // emitter that various prefix bytes are required.
246 class OpSize { bit hasOpSizePrefix = 1; }
247 class AdSize { bit hasAdSizePrefix = 1; }
248 class REX_W { bit hasREX_WPrefix = 1; }
249 class TB { bits<4> Prefix = 1; }
250 class REP { bits<4> Prefix = 2; }
251 class D8 { bits<4> Prefix = 3; }
252 class D9 { bits<4> Prefix = 4; }
253 class DA { bits<4> Prefix = 5; }
254 class DB { bits<4> Prefix = 6; }
255 class DC { bits<4> Prefix = 7; }
256 class DD { bits<4> Prefix = 8; }
257 class DE { bits<4> Prefix = 9; }
258 class DF { bits<4> Prefix = 10; }
259 class XD { bits<4> Prefix = 11; }
260 class XS { bits<4> Prefix = 12; }
261 class T8 { bits<4> Prefix = 13; }
262 class TA { bits<4> Prefix = 14; }
265 //===----------------------------------------------------------------------===//
266 // Pattern fragments...
269 // X86 specific condition code. These correspond to CondCode in
270 // X86InstrInfo.h. They must be kept in synch.
271 def X86_COND_A : PatLeaf<(i8 0)>;
272 def X86_COND_AE : PatLeaf<(i8 1)>;
273 def X86_COND_B : PatLeaf<(i8 2)>;
274 def X86_COND_BE : PatLeaf<(i8 3)>;
275 def X86_COND_E : PatLeaf<(i8 4)>;
276 def X86_COND_G : PatLeaf<(i8 5)>;
277 def X86_COND_GE : PatLeaf<(i8 6)>;
278 def X86_COND_L : PatLeaf<(i8 7)>;
279 def X86_COND_LE : PatLeaf<(i8 8)>;
280 def X86_COND_NE : PatLeaf<(i8 9)>;
281 def X86_COND_NO : PatLeaf<(i8 10)>;
282 def X86_COND_NP : PatLeaf<(i8 11)>;
283 def X86_COND_NS : PatLeaf<(i8 12)>;
284 def X86_COND_O : PatLeaf<(i8 13)>;
285 def X86_COND_P : PatLeaf<(i8 14)>;
286 def X86_COND_S : PatLeaf<(i8 15)>;
288 def i16immSExt8 : PatLeaf<(i16 imm), [{
289 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
290 // sign extended field.
291 return (int16_t)N->getValue() == (int8_t)N->getValue();
294 def i32immSExt8 : PatLeaf<(i32 imm), [{
295 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
296 // sign extended field.
297 return (int32_t)N->getValue() == (int8_t)N->getValue();
300 // Helper fragments for loads.
301 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
302 def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
303 def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
304 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
306 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
307 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
309 def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
310 def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
311 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
312 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
313 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
315 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
316 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
317 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
318 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
319 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
320 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
322 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
323 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
324 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
325 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
326 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
327 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
329 //===----------------------------------------------------------------------===//
330 // Instruction templates...
333 class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
334 : X86Inst<o, f, NoImm, ops, asm> {
335 let Pattern = pattern;
338 class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
339 : X86Inst<o, f, Imm8 , ops, asm> {
340 let Pattern = pattern;
343 class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
344 : X86Inst<o, f, Imm16, ops, asm> {
345 let Pattern = pattern;
348 class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
349 : X86Inst<o, f, Imm32, ops, asm> {
350 let Pattern = pattern;
354 //===----------------------------------------------------------------------===//
355 // Instruction list...
358 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
359 // a stack adjustment and the codegen must know that they may modify the stack
360 // pointer before prolog-epilog rewriting occurs.
361 def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
362 [(X86callseq_start imm:$amt)]>, Imp<[ESP],[ESP]>;
363 def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
365 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
367 def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
368 def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
369 def IMPLICIT_DEF_GR8 : I<0, Pseudo, (ops GR8:$dst),
370 "#IMPLICIT_DEF $dst",
371 [(set GR8:$dst, (undef))]>;
372 def IMPLICIT_DEF_GR16 : I<0, Pseudo, (ops GR16:$dst),
373 "#IMPLICIT_DEF $dst",
374 [(set GR16:$dst, (undef))]>;
375 def IMPLICIT_DEF_GR32 : I<0, Pseudo, (ops GR32:$dst),
376 "#IMPLICIT_DEF $dst",
377 [(set GR32:$dst, (undef))]>;
380 def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
383 def TRUNC_32_to8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR32_:$src),
384 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}", []>;
385 def TRUNC_16_to8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR16_:$src),
386 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}}", []>;
387 def TRUNC_32to16 : I<0x89, MRMDestReg, (ops GR16:$dst, GR32:$src),
388 "mov{w} {${src:subreg16}, $dst|$dst, ${src:subreg16}}",
389 [(set GR16:$dst, (trunc GR32:$src))]>;
391 //===----------------------------------------------------------------------===//
392 // Control Flow Instructions...
395 // Return instructions.
396 let isTerminator = 1, isReturn = 1, isBarrier = 1,
397 hasCtrlDep = 1, noResults = 1 in {
398 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
399 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
400 [(X86retflag imm:$amt)]>;
403 // All branches are RawFrm, Void, Branch, and Terminators
404 let isBranch = 1, isTerminator = 1, noResults = 1 in
405 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
406 I<opcode, RawFrm, ops, asm, pattern>;
409 let isBranch = 1, isBarrier = 1 in
410 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
412 let isBranch = 1, isTerminator = 1, noResults = 1, isBarrier = 1 in {
413 def JMP32r : I<0xFF, MRM4r, (ops GR32:$dst), "jmp{l} {*}$dst",
414 [(brind GR32:$dst)]>;
415 def JMP32m : I<0xFF, MRM4m, (ops i32mem:$dst), "jmp{l} {*}$dst",
416 [(brind (loadi32 addr:$dst))]>;
419 // Conditional branches
420 def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
421 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
422 def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
423 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
424 def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
425 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
426 def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
427 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
428 def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
429 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
430 def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
431 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
433 def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
434 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
435 def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
436 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
437 def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
438 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
439 def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
440 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
442 def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
443 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
444 def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
445 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
446 def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
447 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
448 def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
449 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
450 def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
451 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
452 def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
453 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
455 //===----------------------------------------------------------------------===//
456 // Call Instructions...
458 let isCall = 1, noResults = 1 in
459 // All calls clobber the non-callee saved registers...
460 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
461 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
462 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
463 def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst, variable_ops),
464 "call ${dst:call}", []>;
465 def CALL32r : I<0xFF, MRM2r, (ops GR32:$dst, variable_ops),
466 "call {*}$dst", [(X86call GR32:$dst)]>;
467 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst, variable_ops),
472 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
473 def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call} # TAIL CALL",
475 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
476 def TAILJMPr : I<0xFF, MRM4r, (ops GR32:$dst), "jmp {*}$dst # TAIL CALL",
478 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
479 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
480 "jmp {*}$dst # TAIL CALL", []>;
482 //===----------------------------------------------------------------------===//
483 // Miscellaneous Instructions...
485 def LEAVE : I<0xC9, RawFrm,
486 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
487 def POP32r : I<0x58, AddRegFrm,
488 (ops GR32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
490 def PUSH32r : I<0x50, AddRegFrm,
491 (ops GR32:$reg), "push{l} $reg", []>, Imp<[ESP],[ESP]>;
493 def MovePCtoStack : I<0, Pseudo, (ops piclabel:$label),
496 let isTwoAddress = 1 in // GR32 = bswap GR32
497 def BSWAP32r : I<0xC8, AddRegFrm,
498 (ops GR32:$dst, GR32:$src),
500 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
502 def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
503 (ops GR8:$src1, GR8:$src2),
504 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
505 def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
506 (ops GR16:$src1, GR16:$src2),
507 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
508 def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
509 (ops GR32:$src1, GR32:$src2),
510 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
512 def XCHG8mr : I<0x86, MRMDestMem,
513 (ops i8mem:$src1, GR8:$src2),
514 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
515 def XCHG16mr : I<0x87, MRMDestMem,
516 (ops i16mem:$src1, GR16:$src2),
517 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
518 def XCHG32mr : I<0x87, MRMDestMem,
519 (ops i32mem:$src1, GR32:$src2),
520 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
521 def XCHG8rm : I<0x86, MRMSrcMem,
522 (ops GR8:$src1, i8mem:$src2),
523 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
524 def XCHG16rm : I<0x87, MRMSrcMem,
525 (ops GR16:$src1, i16mem:$src2),
526 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
527 def XCHG32rm : I<0x87, MRMSrcMem,
528 (ops GR32:$src1, i32mem:$src2),
529 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
531 def LEA16r : I<0x8D, MRMSrcMem,
532 (ops GR16:$dst, i32mem:$src),
533 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
534 def LEA32r : I<0x8D, MRMSrcMem,
535 (ops GR32:$dst, lea32mem:$src),
536 "lea{l} {$src|$dst}, {$dst|$src}",
537 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
539 def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
541 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
542 def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
543 [(X86rep_movs i16)]>,
544 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
545 def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsl|rep movsd}",
546 [(X86rep_movs i32)]>,
547 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
549 def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
551 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
552 def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
553 [(X86rep_stos i16)]>,
554 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
555 def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
556 [(X86rep_stos i32)]>,
557 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
559 def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
560 TB, Imp<[],[RAX,RDX]>;
562 //===----------------------------------------------------------------------===//
563 // Input/Output Instructions...
565 def IN8rr : I<0xEC, RawFrm, (ops),
566 "in{b} {%dx, %al|%AL, %DX}",
567 []>, Imp<[DX], [AL]>;
568 def IN16rr : I<0xED, RawFrm, (ops),
569 "in{w} {%dx, %ax|%AX, %DX}",
570 []>, Imp<[DX], [AX]>, OpSize;
571 def IN32rr : I<0xED, RawFrm, (ops),
572 "in{l} {%dx, %eax|%EAX, %DX}",
573 []>, Imp<[DX],[EAX]>;
575 def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
576 "in{b} {$port, %al|%AL, $port}",
579 def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
580 "in{w} {$port, %ax|%AX, $port}",
582 Imp<[], [AX]>, OpSize;
583 def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
584 "in{l} {$port, %eax|%EAX, $port}",
588 def OUT8rr : I<0xEE, RawFrm, (ops),
589 "out{b} {%al, %dx|%DX, %AL}",
590 []>, Imp<[DX, AL], []>;
591 def OUT16rr : I<0xEF, RawFrm, (ops),
592 "out{w} {%ax, %dx|%DX, %AX}",
593 []>, Imp<[DX, AX], []>, OpSize;
594 def OUT32rr : I<0xEF, RawFrm, (ops),
595 "out{l} {%eax, %dx|%DX, %EAX}",
596 []>, Imp<[DX, EAX], []>;
598 def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
599 "out{b} {%al, $port|$port, %AL}",
602 def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
603 "out{w} {%ax, $port|$port, %AX}",
605 Imp<[AX], []>, OpSize;
606 def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
607 "out{l} {%eax, $port|$port, %EAX}",
611 //===----------------------------------------------------------------------===//
612 // Move Instructions...
614 def MOV8rr : I<0x88, MRMDestReg, (ops GR8 :$dst, GR8 :$src),
615 "mov{b} {$src, $dst|$dst, $src}", []>;
616 def MOV16rr : I<0x89, MRMDestReg, (ops GR16:$dst, GR16:$src),
617 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
618 def MOV32rr : I<0x89, MRMDestReg, (ops GR32:$dst, GR32:$src),
619 "mov{l} {$src, $dst|$dst, $src}", []>;
620 def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops GR8 :$dst, i8imm :$src),
621 "mov{b} {$src, $dst|$dst, $src}",
622 [(set GR8:$dst, imm:$src)]>;
623 def MOV16ri : Ii16<0xB8, AddRegFrm, (ops GR16:$dst, i16imm:$src),
624 "mov{w} {$src, $dst|$dst, $src}",
625 [(set GR16:$dst, imm:$src)]>, OpSize;
626 def MOV32ri : Ii32<0xB8, AddRegFrm, (ops GR32:$dst, i32imm:$src),
627 "mov{l} {$src, $dst|$dst, $src}",
628 [(set GR32:$dst, imm:$src)]>;
629 def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
630 "mov{b} {$src, $dst|$dst, $src}",
631 [(store (i8 imm:$src), addr:$dst)]>;
632 def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
633 "mov{w} {$src, $dst|$dst, $src}",
634 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
635 def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
636 "mov{l} {$src, $dst|$dst, $src}",
637 [(store (i32 imm:$src), addr:$dst)]>;
639 def MOV8rm : I<0x8A, MRMSrcMem, (ops GR8 :$dst, i8mem :$src),
640 "mov{b} {$src, $dst|$dst, $src}",
641 [(set GR8:$dst, (load addr:$src))]>;
642 def MOV16rm : I<0x8B, MRMSrcMem, (ops GR16:$dst, i16mem:$src),
643 "mov{w} {$src, $dst|$dst, $src}",
644 [(set GR16:$dst, (load addr:$src))]>, OpSize;
645 def MOV32rm : I<0x8B, MRMSrcMem, (ops GR32:$dst, i32mem:$src),
646 "mov{l} {$src, $dst|$dst, $src}",
647 [(set GR32:$dst, (load addr:$src))]>;
649 def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, GR8 :$src),
650 "mov{b} {$src, $dst|$dst, $src}",
651 [(store GR8:$src, addr:$dst)]>;
652 def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16:$src),
653 "mov{w} {$src, $dst|$dst, $src}",
654 [(store GR16:$src, addr:$dst)]>, OpSize;
655 def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32:$src),
656 "mov{l} {$src, $dst|$dst, $src}",
657 [(store GR32:$src, addr:$dst)]>;
659 //===----------------------------------------------------------------------===//
660 // Fixed-Register Multiplication and Division Instructions...
663 // Extra precision multiplication
664 def MUL8r : I<0xF6, MRM4r, (ops GR8:$src), "mul{b} $src",
665 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
666 // This probably ought to be moved to a def : Pat<> if the
667 // syntax can be accepted.
668 [(set AL, (mul AL, GR8:$src))]>,
669 Imp<[AL],[AX]>; // AL,AH = AL*GR8
670 def MUL16r : I<0xF7, MRM4r, (ops GR16:$src), "mul{w} $src", []>,
671 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
672 def MUL32r : I<0xF7, MRM4r, (ops GR32:$src), "mul{l} $src", []>,
673 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
674 def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
676 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
677 // This probably ought to be moved to a def : Pat<> if the
678 // syntax can be accepted.
679 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
680 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
681 def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
682 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
683 OpSize; // AX,DX = AX*[mem16]
684 def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
685 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
687 def IMUL8r : I<0xF6, MRM5r, (ops GR8:$src), "imul{b} $src", []>,
688 Imp<[AL],[AX]>; // AL,AH = AL*GR8
689 def IMUL16r : I<0xF7, MRM5r, (ops GR16:$src), "imul{w} $src", []>,
690 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
691 def IMUL32r : I<0xF7, MRM5r, (ops GR32:$src), "imul{l} $src", []>,
692 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
693 def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
694 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
695 def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
696 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
697 OpSize; // AX,DX = AX*[mem16]
698 def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
700 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
702 // unsigned division/remainder
703 def DIV8r : I<0xF6, MRM6r, (ops GR8:$src), // AX/r8 = AL,AH
704 "div{b} $src", []>, Imp<[AX],[AX]>;
705 def DIV16r : I<0xF7, MRM6r, (ops GR16:$src), // DX:AX/r16 = AX,DX
706 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
707 def DIV32r : I<0xF7, MRM6r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
708 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
709 def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
710 "div{b} $src", []>, Imp<[AX],[AX]>;
711 def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
712 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
713 def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
714 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
716 // Signed division/remainder.
717 def IDIV8r : I<0xF6, MRM7r, (ops GR8:$src), // AX/r8 = AL,AH
718 "idiv{b} $src", []>, Imp<[AX],[AX]>;
719 def IDIV16r: I<0xF7, MRM7r, (ops GR16:$src), // DX:AX/r16 = AX,DX
720 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
721 def IDIV32r: I<0xF7, MRM7r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
722 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
723 def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
724 "idiv{b} $src", []>, Imp<[AX],[AX]>;
725 def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
726 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
727 def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
728 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
731 //===----------------------------------------------------------------------===//
732 // Two address Instructions...
734 let isTwoAddress = 1 in {
737 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
738 (ops GR16:$dst, GR16:$src1, GR16:$src2),
739 "cmovb {$src2, $dst|$dst, $src2}",
740 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
743 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
744 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
745 "cmovb {$src2, $dst|$dst, $src2}",
746 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
749 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
750 (ops GR32:$dst, GR32:$src1, GR32:$src2),
751 "cmovb {$src2, $dst|$dst, $src2}",
752 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
755 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
756 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
757 "cmovb {$src2, $dst|$dst, $src2}",
758 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
762 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
763 (ops GR16:$dst, GR16:$src1, GR16:$src2),
764 "cmovae {$src2, $dst|$dst, $src2}",
765 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
768 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
769 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
770 "cmovae {$src2, $dst|$dst, $src2}",
771 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
774 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
775 (ops GR32:$dst, GR32:$src1, GR32:$src2),
776 "cmovae {$src2, $dst|$dst, $src2}",
777 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
780 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
781 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
782 "cmovae {$src2, $dst|$dst, $src2}",
783 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
787 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
788 (ops GR16:$dst, GR16:$src1, GR16:$src2),
789 "cmove {$src2, $dst|$dst, $src2}",
790 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
793 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
794 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
795 "cmove {$src2, $dst|$dst, $src2}",
796 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
799 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
800 (ops GR32:$dst, GR32:$src1, GR32:$src2),
801 "cmove {$src2, $dst|$dst, $src2}",
802 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
805 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
806 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
807 "cmove {$src2, $dst|$dst, $src2}",
808 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
812 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
813 (ops GR16:$dst, GR16:$src1, GR16:$src2),
814 "cmovne {$src2, $dst|$dst, $src2}",
815 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
818 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
819 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
820 "cmovne {$src2, $dst|$dst, $src2}",
821 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
824 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
825 (ops GR32:$dst, GR32:$src1, GR32:$src2),
826 "cmovne {$src2, $dst|$dst, $src2}",
827 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
830 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
831 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
832 "cmovne {$src2, $dst|$dst, $src2}",
833 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
837 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
838 (ops GR16:$dst, GR16:$src1, GR16:$src2),
839 "cmovbe {$src2, $dst|$dst, $src2}",
840 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
843 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
844 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
845 "cmovbe {$src2, $dst|$dst, $src2}",
846 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
849 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
850 (ops GR32:$dst, GR32:$src1, GR32:$src2),
851 "cmovbe {$src2, $dst|$dst, $src2}",
852 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
855 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
856 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
857 "cmovbe {$src2, $dst|$dst, $src2}",
858 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
862 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
863 (ops GR16:$dst, GR16:$src1, GR16:$src2),
864 "cmova {$src2, $dst|$dst, $src2}",
865 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
868 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
869 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
870 "cmova {$src2, $dst|$dst, $src2}",
871 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
874 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
875 (ops GR32:$dst, GR32:$src1, GR32:$src2),
876 "cmova {$src2, $dst|$dst, $src2}",
877 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
880 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
881 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
882 "cmova {$src2, $dst|$dst, $src2}",
883 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
887 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
888 (ops GR16:$dst, GR16:$src1, GR16:$src2),
889 "cmovl {$src2, $dst|$dst, $src2}",
890 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
893 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
894 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
895 "cmovl {$src2, $dst|$dst, $src2}",
896 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
899 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
900 (ops GR32:$dst, GR32:$src1, GR32:$src2),
901 "cmovl {$src2, $dst|$dst, $src2}",
902 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
905 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
906 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
907 "cmovl {$src2, $dst|$dst, $src2}",
908 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
912 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
913 (ops GR16:$dst, GR16:$src1, GR16:$src2),
914 "cmovge {$src2, $dst|$dst, $src2}",
915 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
918 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
919 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
920 "cmovge {$src2, $dst|$dst, $src2}",
921 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
924 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
925 (ops GR32:$dst, GR32:$src1, GR32:$src2),
926 "cmovge {$src2, $dst|$dst, $src2}",
927 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
930 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
931 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
932 "cmovge {$src2, $dst|$dst, $src2}",
933 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
937 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
938 (ops GR16:$dst, GR16:$src1, GR16:$src2),
939 "cmovle {$src2, $dst|$dst, $src2}",
940 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
943 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
944 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
945 "cmovle {$src2, $dst|$dst, $src2}",
946 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
949 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
950 (ops GR32:$dst, GR32:$src1, GR32:$src2),
951 "cmovle {$src2, $dst|$dst, $src2}",
952 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
955 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
956 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
957 "cmovle {$src2, $dst|$dst, $src2}",
958 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
962 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
963 (ops GR16:$dst, GR16:$src1, GR16:$src2),
964 "cmovg {$src2, $dst|$dst, $src2}",
965 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
968 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
969 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
970 "cmovg {$src2, $dst|$dst, $src2}",
971 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
974 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
975 (ops GR32:$dst, GR32:$src1, GR32:$src2),
976 "cmovg {$src2, $dst|$dst, $src2}",
977 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
980 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
981 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
982 "cmovg {$src2, $dst|$dst, $src2}",
983 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
987 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
988 (ops GR16:$dst, GR16:$src1, GR16:$src2),
989 "cmovs {$src2, $dst|$dst, $src2}",
990 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
993 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
994 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
995 "cmovs {$src2, $dst|$dst, $src2}",
996 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
999 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1000 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1001 "cmovs {$src2, $dst|$dst, $src2}",
1002 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1005 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1006 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1007 "cmovs {$src2, $dst|$dst, $src2}",
1008 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1012 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1013 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1014 "cmovns {$src2, $dst|$dst, $src2}",
1015 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1018 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1019 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1020 "cmovns {$src2, $dst|$dst, $src2}",
1021 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1024 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1025 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1026 "cmovns {$src2, $dst|$dst, $src2}",
1027 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1030 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1031 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1032 "cmovns {$src2, $dst|$dst, $src2}",
1033 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1037 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1038 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1039 "cmovp {$src2, $dst|$dst, $src2}",
1040 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1043 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1044 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1045 "cmovp {$src2, $dst|$dst, $src2}",
1046 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1049 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1050 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1051 "cmovp {$src2, $dst|$dst, $src2}",
1052 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1055 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1056 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1057 "cmovp {$src2, $dst|$dst, $src2}",
1058 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1062 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1063 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1064 "cmovnp {$src2, $dst|$dst, $src2}",
1065 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1068 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1069 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1070 "cmovnp {$src2, $dst|$dst, $src2}",
1071 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1074 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1075 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1076 "cmovnp {$src2, $dst|$dst, $src2}",
1077 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1080 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1081 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1082 "cmovnp {$src2, $dst|$dst, $src2}",
1083 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1088 // unary instructions
1089 let CodeSize = 2 in {
1090 def NEG8r : I<0xF6, MRM3r, (ops GR8 :$dst, GR8 :$src), "neg{b} $dst",
1091 [(set GR8:$dst, (ineg GR8:$src))]>;
1092 def NEG16r : I<0xF7, MRM3r, (ops GR16:$dst, GR16:$src), "neg{w} $dst",
1093 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1094 def NEG32r : I<0xF7, MRM3r, (ops GR32:$dst, GR32:$src), "neg{l} $dst",
1095 [(set GR32:$dst, (ineg GR32:$src))]>;
1096 let isTwoAddress = 0 in {
1097 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
1098 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1099 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
1100 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1101 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
1102 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1106 def NOT8r : I<0xF6, MRM2r, (ops GR8 :$dst, GR8 :$src), "not{b} $dst",
1107 [(set GR8:$dst, (not GR8:$src))]>;
1108 def NOT16r : I<0xF7, MRM2r, (ops GR16:$dst, GR16:$src), "not{w} $dst",
1109 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1110 def NOT32r : I<0xF7, MRM2r, (ops GR32:$dst, GR32:$src), "not{l} $dst",
1111 [(set GR32:$dst, (not GR32:$src))]>;
1112 let isTwoAddress = 0 in {
1113 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
1114 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1115 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
1116 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1117 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
1118 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1122 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1124 def INC8r : I<0xFE, MRM0r, (ops GR8 :$dst, GR8 :$src), "inc{b} $dst",
1125 [(set GR8:$dst, (add GR8:$src, 1))]>;
1126 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1127 def INC16r : I<0x40, AddRegFrm, (ops GR16:$dst, GR16:$src), "inc{w} $dst",
1128 [(set GR16:$dst, (add GR16:$src, 1))]>,
1129 OpSize, Requires<[In32BitMode]>;
1130 def INC32r : I<0x40, AddRegFrm, (ops GR32:$dst, GR32:$src), "inc{l} $dst",
1131 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1133 let isTwoAddress = 0, CodeSize = 2 in {
1134 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
1135 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1136 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
1137 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
1138 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
1139 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1143 def DEC8r : I<0xFE, MRM1r, (ops GR8 :$dst, GR8 :$src), "dec{b} $dst",
1144 [(set GR8:$dst, (add GR8:$src, -1))]>;
1145 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1146 def DEC16r : I<0x48, AddRegFrm, (ops GR16:$dst, GR16:$src), "dec{w} $dst",
1147 [(set GR16:$dst, (add GR16:$src, -1))]>,
1148 OpSize, Requires<[In32BitMode]>;
1149 def DEC32r : I<0x48, AddRegFrm, (ops GR32:$dst, GR32:$src), "dec{l} $dst",
1150 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1153 let isTwoAddress = 0, CodeSize = 2 in {
1154 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
1155 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1156 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
1157 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
1158 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
1159 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1162 // Logical operators...
1163 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1164 def AND8rr : I<0x20, MRMDestReg,
1165 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1166 "and{b} {$src2, $dst|$dst, $src2}",
1167 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1168 def AND16rr : I<0x21, MRMDestReg,
1169 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1170 "and{w} {$src2, $dst|$dst, $src2}",
1171 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1172 def AND32rr : I<0x21, MRMDestReg,
1173 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1174 "and{l} {$src2, $dst|$dst, $src2}",
1175 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1178 def AND8rm : I<0x22, MRMSrcMem,
1179 (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1180 "and{b} {$src2, $dst|$dst, $src2}",
1181 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1182 def AND16rm : I<0x23, MRMSrcMem,
1183 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1184 "and{w} {$src2, $dst|$dst, $src2}",
1185 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1186 def AND32rm : I<0x23, MRMSrcMem,
1187 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1188 "and{l} {$src2, $dst|$dst, $src2}",
1189 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1191 def AND8ri : Ii8<0x80, MRM4r,
1192 (ops GR8 :$dst, GR8 :$src1, i8imm :$src2),
1193 "and{b} {$src2, $dst|$dst, $src2}",
1194 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1195 def AND16ri : Ii16<0x81, MRM4r,
1196 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1197 "and{w} {$src2, $dst|$dst, $src2}",
1198 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1199 def AND32ri : Ii32<0x81, MRM4r,
1200 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1201 "and{l} {$src2, $dst|$dst, $src2}",
1202 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1203 def AND16ri8 : Ii8<0x83, MRM4r,
1204 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1205 "and{w} {$src2, $dst|$dst, $src2}",
1206 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1208 def AND32ri8 : Ii8<0x83, MRM4r,
1209 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1210 "and{l} {$src2, $dst|$dst, $src2}",
1211 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1213 let isTwoAddress = 0 in {
1214 def AND8mr : I<0x20, MRMDestMem,
1215 (ops i8mem :$dst, GR8 :$src),
1216 "and{b} {$src, $dst|$dst, $src}",
1217 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1218 def AND16mr : I<0x21, MRMDestMem,
1219 (ops i16mem:$dst, GR16:$src),
1220 "and{w} {$src, $dst|$dst, $src}",
1221 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1223 def AND32mr : I<0x21, MRMDestMem,
1224 (ops i32mem:$dst, GR32:$src),
1225 "and{l} {$src, $dst|$dst, $src}",
1226 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1227 def AND8mi : Ii8<0x80, MRM4m,
1228 (ops i8mem :$dst, i8imm :$src),
1229 "and{b} {$src, $dst|$dst, $src}",
1230 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1231 def AND16mi : Ii16<0x81, MRM4m,
1232 (ops i16mem:$dst, i16imm:$src),
1233 "and{w} {$src, $dst|$dst, $src}",
1234 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1236 def AND32mi : Ii32<0x81, MRM4m,
1237 (ops i32mem:$dst, i32imm:$src),
1238 "and{l} {$src, $dst|$dst, $src}",
1239 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1240 def AND16mi8 : Ii8<0x83, MRM4m,
1241 (ops i16mem:$dst, i16i8imm :$src),
1242 "and{w} {$src, $dst|$dst, $src}",
1243 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1245 def AND32mi8 : Ii8<0x83, MRM4m,
1246 (ops i32mem:$dst, i32i8imm :$src),
1247 "and{l} {$src, $dst|$dst, $src}",
1248 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1252 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1253 def OR8rr : I<0x08, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1254 "or{b} {$src2, $dst|$dst, $src2}",
1255 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1256 def OR16rr : I<0x09, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1257 "or{w} {$src2, $dst|$dst, $src2}",
1258 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1259 def OR32rr : I<0x09, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1260 "or{l} {$src2, $dst|$dst, $src2}",
1261 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1263 def OR8rm : I<0x0A, MRMSrcMem , (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1264 "or{b} {$src2, $dst|$dst, $src2}",
1265 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1266 def OR16rm : I<0x0B, MRMSrcMem , (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1267 "or{w} {$src2, $dst|$dst, $src2}",
1268 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1269 def OR32rm : I<0x0B, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1270 "or{l} {$src2, $dst|$dst, $src2}",
1271 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1273 def OR8ri : Ii8 <0x80, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1274 "or{b} {$src2, $dst|$dst, $src2}",
1275 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1276 def OR16ri : Ii16<0x81, MRM1r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1277 "or{w} {$src2, $dst|$dst, $src2}",
1278 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1279 def OR32ri : Ii32<0x81, MRM1r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1280 "or{l} {$src2, $dst|$dst, $src2}",
1281 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1283 def OR16ri8 : Ii8<0x83, MRM1r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1284 "or{w} {$src2, $dst|$dst, $src2}",
1285 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1286 def OR32ri8 : Ii8<0x83, MRM1r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1287 "or{l} {$src2, $dst|$dst, $src2}",
1288 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1289 let isTwoAddress = 0 in {
1290 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, GR8:$src),
1291 "or{b} {$src, $dst|$dst, $src}",
1292 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1293 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, GR16:$src),
1294 "or{w} {$src, $dst|$dst, $src}",
1295 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1296 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, GR32:$src),
1297 "or{l} {$src, $dst|$dst, $src}",
1298 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
1299 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
1300 "or{b} {$src, $dst|$dst, $src}",
1301 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1302 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
1303 "or{w} {$src, $dst|$dst, $src}",
1304 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1306 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
1307 "or{l} {$src, $dst|$dst, $src}",
1308 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1309 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1310 "or{w} {$src, $dst|$dst, $src}",
1311 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1313 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1314 "or{l} {$src, $dst|$dst, $src}",
1315 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1319 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1320 def XOR8rr : I<0x30, MRMDestReg,
1321 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1322 "xor{b} {$src2, $dst|$dst, $src2}",
1323 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1324 def XOR16rr : I<0x31, MRMDestReg,
1325 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1326 "xor{w} {$src2, $dst|$dst, $src2}",
1327 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1328 def XOR32rr : I<0x31, MRMDestReg,
1329 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1330 "xor{l} {$src2, $dst|$dst, $src2}",
1331 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1334 def XOR8rm : I<0x32, MRMSrcMem ,
1335 (ops GR8 :$dst, GR8:$src1, i8mem :$src2),
1336 "xor{b} {$src2, $dst|$dst, $src2}",
1337 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1338 def XOR16rm : I<0x33, MRMSrcMem ,
1339 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1340 "xor{w} {$src2, $dst|$dst, $src2}",
1341 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1342 def XOR32rm : I<0x33, MRMSrcMem ,
1343 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1344 "xor{l} {$src2, $dst|$dst, $src2}",
1345 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1347 def XOR8ri : Ii8<0x80, MRM6r,
1348 (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1349 "xor{b} {$src2, $dst|$dst, $src2}",
1350 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1351 def XOR16ri : Ii16<0x81, MRM6r,
1352 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1353 "xor{w} {$src2, $dst|$dst, $src2}",
1354 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1355 def XOR32ri : Ii32<0x81, MRM6r,
1356 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1357 "xor{l} {$src2, $dst|$dst, $src2}",
1358 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1359 def XOR16ri8 : Ii8<0x83, MRM6r,
1360 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1361 "xor{w} {$src2, $dst|$dst, $src2}",
1362 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1364 def XOR32ri8 : Ii8<0x83, MRM6r,
1365 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1366 "xor{l} {$src2, $dst|$dst, $src2}",
1367 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1368 let isTwoAddress = 0 in {
1369 def XOR8mr : I<0x30, MRMDestMem,
1370 (ops i8mem :$dst, GR8 :$src),
1371 "xor{b} {$src, $dst|$dst, $src}",
1372 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1373 def XOR16mr : I<0x31, MRMDestMem,
1374 (ops i16mem:$dst, GR16:$src),
1375 "xor{w} {$src, $dst|$dst, $src}",
1376 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1378 def XOR32mr : I<0x31, MRMDestMem,
1379 (ops i32mem:$dst, GR32:$src),
1380 "xor{l} {$src, $dst|$dst, $src}",
1381 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1382 def XOR8mi : Ii8<0x80, MRM6m,
1383 (ops i8mem :$dst, i8imm :$src),
1384 "xor{b} {$src, $dst|$dst, $src}",
1385 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1386 def XOR16mi : Ii16<0x81, MRM6m,
1387 (ops i16mem:$dst, i16imm:$src),
1388 "xor{w} {$src, $dst|$dst, $src}",
1389 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1391 def XOR32mi : Ii32<0x81, MRM6m,
1392 (ops i32mem:$dst, i32imm:$src),
1393 "xor{l} {$src, $dst|$dst, $src}",
1394 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1395 def XOR16mi8 : Ii8<0x83, MRM6m,
1396 (ops i16mem:$dst, i16i8imm :$src),
1397 "xor{w} {$src, $dst|$dst, $src}",
1398 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1400 def XOR32mi8 : Ii8<0x83, MRM6m,
1401 (ops i32mem:$dst, i32i8imm :$src),
1402 "xor{l} {$src, $dst|$dst, $src}",
1403 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1406 // Shift instructions
1407 def SHL8rCL : I<0xD2, MRM4r, (ops GR8 :$dst, GR8 :$src),
1408 "shl{b} {%cl, $dst|$dst, %CL}",
1409 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
1410 def SHL16rCL : I<0xD3, MRM4r, (ops GR16:$dst, GR16:$src),
1411 "shl{w} {%cl, $dst|$dst, %CL}",
1412 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1413 def SHL32rCL : I<0xD3, MRM4r, (ops GR32:$dst, GR32:$src),
1414 "shl{l} {%cl, $dst|$dst, %CL}",
1415 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
1417 def SHL8ri : Ii8<0xC0, MRM4r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1418 "shl{b} {$src2, $dst|$dst, $src2}",
1419 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1420 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1421 def SHL16ri : Ii8<0xC1, MRM4r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1422 "shl{w} {$src2, $dst|$dst, $src2}",
1423 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1424 def SHL32ri : Ii8<0xC1, MRM4r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1425 "shl{l} {$src2, $dst|$dst, $src2}",
1426 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1429 // Shift left by one. Not used because (add x, x) is slightly cheaper.
1430 def SHL8r1 : I<0xD0, MRM4r, (ops GR8 :$dst, GR8 :$src1),
1432 def SHL16r1 : I<0xD1, MRM4r, (ops GR16:$dst, GR16:$src1),
1433 "shl{w} $dst", []>, OpSize;
1434 def SHL32r1 : I<0xD1, MRM4r, (ops GR32:$dst, GR32:$src1),
1437 let isTwoAddress = 0 in {
1438 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
1439 "shl{b} {%cl, $dst|$dst, %CL}",
1440 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1442 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
1443 "shl{w} {%cl, $dst|$dst, %CL}",
1444 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1445 Imp<[CL],[]>, OpSize;
1446 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
1447 "shl{l} {%cl, $dst|$dst, %CL}",
1448 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1450 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
1451 "shl{b} {$src, $dst|$dst, $src}",
1452 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1453 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
1454 "shl{w} {$src, $dst|$dst, $src}",
1455 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1457 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
1458 "shl{l} {$src, $dst|$dst, $src}",
1459 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1462 def SHL8m1 : I<0xD0, MRM4m, (ops i8mem :$dst),
1464 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1465 def SHL16m1 : I<0xD1, MRM4m, (ops i16mem:$dst),
1467 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1469 def SHL32m1 : I<0xD1, MRM4m, (ops i32mem:$dst),
1471 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1474 def SHR8rCL : I<0xD2, MRM5r, (ops GR8 :$dst, GR8 :$src),
1475 "shr{b} {%cl, $dst|$dst, %CL}",
1476 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
1477 def SHR16rCL : I<0xD3, MRM5r, (ops GR16:$dst, GR16:$src),
1478 "shr{w} {%cl, $dst|$dst, %CL}",
1479 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1480 def SHR32rCL : I<0xD3, MRM5r, (ops GR32:$dst, GR32:$src),
1481 "shr{l} {%cl, $dst|$dst, %CL}",
1482 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
1484 def SHR8ri : Ii8<0xC0, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1485 "shr{b} {$src2, $dst|$dst, $src2}",
1486 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1487 def SHR16ri : Ii8<0xC1, MRM5r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1488 "shr{w} {$src2, $dst|$dst, $src2}",
1489 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1490 def SHR32ri : Ii8<0xC1, MRM5r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1491 "shr{l} {$src2, $dst|$dst, $src2}",
1492 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1495 def SHR8r1 : I<0xD0, MRM5r, (ops GR8:$dst, GR8:$src1),
1497 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1498 def SHR16r1 : I<0xD1, MRM5r, (ops GR16:$dst, GR16:$src1),
1500 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1501 def SHR32r1 : I<0xD1, MRM5r, (ops GR32:$dst, GR32:$src1),
1503 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1505 let isTwoAddress = 0 in {
1506 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
1507 "shr{b} {%cl, $dst|$dst, %CL}",
1508 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1510 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
1511 "shr{w} {%cl, $dst|$dst, %CL}",
1512 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1513 Imp<[CL],[]>, OpSize;
1514 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
1515 "shr{l} {%cl, $dst|$dst, %CL}",
1516 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1518 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
1519 "shr{b} {$src, $dst|$dst, $src}",
1520 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1521 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
1522 "shr{w} {$src, $dst|$dst, $src}",
1523 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1525 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
1526 "shr{l} {$src, $dst|$dst, $src}",
1527 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1530 def SHR8m1 : I<0xD0, MRM5m, (ops i8mem :$dst),
1532 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1533 def SHR16m1 : I<0xD1, MRM5m, (ops i16mem:$dst),
1535 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1536 def SHR32m1 : I<0xD1, MRM5m, (ops i32mem:$dst),
1538 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1541 def SAR8rCL : I<0xD2, MRM7r, (ops GR8 :$dst, GR8 :$src),
1542 "sar{b} {%cl, $dst|$dst, %CL}",
1543 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
1544 def SAR16rCL : I<0xD3, MRM7r, (ops GR16:$dst, GR16:$src),
1545 "sar{w} {%cl, $dst|$dst, %CL}",
1546 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1547 def SAR32rCL : I<0xD3, MRM7r, (ops GR32:$dst, GR32:$src),
1548 "sar{l} {%cl, $dst|$dst, %CL}",
1549 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
1551 def SAR8ri : Ii8<0xC0, MRM7r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1552 "sar{b} {$src2, $dst|$dst, $src2}",
1553 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1554 def SAR16ri : Ii8<0xC1, MRM7r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1555 "sar{w} {$src2, $dst|$dst, $src2}",
1556 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1558 def SAR32ri : Ii8<0xC1, MRM7r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1559 "sar{l} {$src2, $dst|$dst, $src2}",
1560 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1563 def SAR8r1 : I<0xD0, MRM7r, (ops GR8 :$dst, GR8 :$src1),
1565 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1566 def SAR16r1 : I<0xD1, MRM7r, (ops GR16:$dst, GR16:$src1),
1568 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1569 def SAR32r1 : I<0xD1, MRM7r, (ops GR32:$dst, GR32:$src1),
1571 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1573 let isTwoAddress = 0 in {
1574 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
1575 "sar{b} {%cl, $dst|$dst, %CL}",
1576 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1578 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
1579 "sar{w} {%cl, $dst|$dst, %CL}",
1580 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1581 Imp<[CL],[]>, OpSize;
1582 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
1583 "sar{l} {%cl, $dst|$dst, %CL}",
1584 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1586 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
1587 "sar{b} {$src, $dst|$dst, $src}",
1588 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1589 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
1590 "sar{w} {$src, $dst|$dst, $src}",
1591 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1593 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
1594 "sar{l} {$src, $dst|$dst, $src}",
1595 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1598 def SAR8m1 : I<0xD0, MRM7m, (ops i8mem :$dst),
1600 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1601 def SAR16m1 : I<0xD1, MRM7m, (ops i16mem:$dst),
1603 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1605 def SAR32m1 : I<0xD1, MRM7m, (ops i32mem:$dst),
1607 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1610 // Rotate instructions
1611 // FIXME: provide shorter instructions when imm8 == 1
1612 def ROL8rCL : I<0xD2, MRM0r, (ops GR8 :$dst, GR8 :$src),
1613 "rol{b} {%cl, $dst|$dst, %CL}",
1614 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
1615 def ROL16rCL : I<0xD3, MRM0r, (ops GR16:$dst, GR16:$src),
1616 "rol{w} {%cl, $dst|$dst, %CL}",
1617 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1618 def ROL32rCL : I<0xD3, MRM0r, (ops GR32:$dst, GR32:$src),
1619 "rol{l} {%cl, $dst|$dst, %CL}",
1620 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
1622 def ROL8ri : Ii8<0xC0, MRM0r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1623 "rol{b} {$src2, $dst|$dst, $src2}",
1624 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1625 def ROL16ri : Ii8<0xC1, MRM0r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1626 "rol{w} {$src2, $dst|$dst, $src2}",
1627 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1628 def ROL32ri : Ii8<0xC1, MRM0r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1629 "rol{l} {$src2, $dst|$dst, $src2}",
1630 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1633 def ROL8r1 : I<0xD0, MRM0r, (ops GR8 :$dst, GR8 :$src1),
1635 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1636 def ROL16r1 : I<0xD1, MRM0r, (ops GR16:$dst, GR16:$src1),
1638 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1639 def ROL32r1 : I<0xD1, MRM0r, (ops GR32:$dst, GR32:$src1),
1641 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1643 let isTwoAddress = 0 in {
1644 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
1645 "rol{b} {%cl, $dst|$dst, %CL}",
1646 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1648 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
1649 "rol{w} {%cl, $dst|$dst, %CL}",
1650 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1651 Imp<[CL],[]>, OpSize;
1652 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
1653 "rol{l} {%cl, $dst|$dst, %CL}",
1654 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1656 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
1657 "rol{b} {$src, $dst|$dst, $src}",
1658 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1659 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
1660 "rol{w} {$src, $dst|$dst, $src}",
1661 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1663 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
1664 "rol{l} {$src, $dst|$dst, $src}",
1665 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1668 def ROL8m1 : I<0xD0, MRM0m, (ops i8mem :$dst),
1670 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1671 def ROL16m1 : I<0xD1, MRM0m, (ops i16mem:$dst),
1673 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1675 def ROL32m1 : I<0xD1, MRM0m, (ops i32mem:$dst),
1677 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1680 def ROR8rCL : I<0xD2, MRM1r, (ops GR8 :$dst, GR8 :$src),
1681 "ror{b} {%cl, $dst|$dst, %CL}",
1682 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
1683 def ROR16rCL : I<0xD3, MRM1r, (ops GR16:$dst, GR16:$src),
1684 "ror{w} {%cl, $dst|$dst, %CL}",
1685 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1686 def ROR32rCL : I<0xD3, MRM1r, (ops GR32:$dst, GR32:$src),
1687 "ror{l} {%cl, $dst|$dst, %CL}",
1688 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
1690 def ROR8ri : Ii8<0xC0, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1691 "ror{b} {$src2, $dst|$dst, $src2}",
1692 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1693 def ROR16ri : Ii8<0xC1, MRM1r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1694 "ror{w} {$src2, $dst|$dst, $src2}",
1695 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1696 def ROR32ri : Ii8<0xC1, MRM1r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1697 "ror{l} {$src2, $dst|$dst, $src2}",
1698 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1701 def ROR8r1 : I<0xD0, MRM1r, (ops GR8 :$dst, GR8 :$src1),
1703 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1704 def ROR16r1 : I<0xD1, MRM1r, (ops GR16:$dst, GR16:$src1),
1706 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1707 def ROR32r1 : I<0xD1, MRM1r, (ops GR32:$dst, GR32:$src1),
1709 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1711 let isTwoAddress = 0 in {
1712 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
1713 "ror{b} {%cl, $dst|$dst, %CL}",
1714 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1716 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
1717 "ror{w} {%cl, $dst|$dst, %CL}",
1718 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1719 Imp<[CL],[]>, OpSize;
1720 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
1721 "ror{l} {%cl, $dst|$dst, %CL}",
1722 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1724 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
1725 "ror{b} {$src, $dst|$dst, $src}",
1726 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1727 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
1728 "ror{w} {$src, $dst|$dst, $src}",
1729 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1731 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
1732 "ror{l} {$src, $dst|$dst, $src}",
1733 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1736 def ROR8m1 : I<0xD0, MRM1m, (ops i8mem :$dst),
1738 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1739 def ROR16m1 : I<0xD1, MRM1m, (ops i16mem:$dst),
1741 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1743 def ROR32m1 : I<0xD1, MRM1m, (ops i32mem:$dst),
1745 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1750 // Double shift instructions (generalizations of rotate)
1751 def SHLD32rrCL : I<0xA5, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1752 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1753 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
1755 def SHRD32rrCL : I<0xAD, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1756 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1757 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
1759 def SHLD16rrCL : I<0xA5, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1760 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1761 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1762 Imp<[CL],[]>, TB, OpSize;
1763 def SHRD16rrCL : I<0xAD, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1764 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1765 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1766 Imp<[CL],[]>, TB, OpSize;
1768 let isCommutable = 1 in { // These instructions commute to each other.
1769 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1770 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
1771 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1772 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1775 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1776 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
1777 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1778 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1781 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1782 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
1783 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1784 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1787 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1788 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
1789 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1790 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1795 let isTwoAddress = 0 in {
1796 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1797 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1798 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1801 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1802 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1803 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1806 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1807 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
1808 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1809 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1810 (i8 imm:$src3)), addr:$dst)]>,
1812 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1813 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
1814 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1815 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1816 (i8 imm:$src3)), addr:$dst)]>,
1819 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1820 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1821 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1823 Imp<[CL],[]>, TB, OpSize;
1824 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1825 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1826 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1828 Imp<[CL],[]>, TB, OpSize;
1829 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1830 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
1831 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1832 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1833 (i8 imm:$src3)), addr:$dst)]>,
1835 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1836 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
1837 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1838 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1839 (i8 imm:$src3)), addr:$dst)]>,
1845 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1846 def ADD8rr : I<0x00, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1847 "add{b} {$src2, $dst|$dst, $src2}",
1848 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1849 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1850 def ADD16rr : I<0x01, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1851 "add{w} {$src2, $dst|$dst, $src2}",
1852 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1853 def ADD32rr : I<0x01, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1854 "add{l} {$src2, $dst|$dst, $src2}",
1855 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1856 } // end isConvertibleToThreeAddress
1857 } // end isCommutable
1858 def ADD8rm : I<0x02, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1859 "add{b} {$src2, $dst|$dst, $src2}",
1860 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1861 def ADD16rm : I<0x03, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1862 "add{w} {$src2, $dst|$dst, $src2}",
1863 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
1864 def ADD32rm : I<0x03, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1865 "add{l} {$src2, $dst|$dst, $src2}",
1866 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1868 def ADD8ri : Ii8<0x80, MRM0r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1869 "add{b} {$src2, $dst|$dst, $src2}",
1870 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1872 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1873 def ADD16ri : Ii16<0x81, MRM0r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1874 "add{w} {$src2, $dst|$dst, $src2}",
1875 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1876 def ADD32ri : Ii32<0x81, MRM0r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1877 "add{l} {$src2, $dst|$dst, $src2}",
1878 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
1879 def ADD16ri8 : Ii8<0x83, MRM0r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1880 "add{w} {$src2, $dst|$dst, $src2}",
1881 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
1883 def ADD32ri8 : Ii8<0x83, MRM0r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1884 "add{l} {$src2, $dst|$dst, $src2}",
1885 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1888 let isTwoAddress = 0 in {
1889 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
1890 "add{b} {$src2, $dst|$dst, $src2}",
1891 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1892 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1893 "add{w} {$src2, $dst|$dst, $src2}",
1894 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1896 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1897 "add{l} {$src2, $dst|$dst, $src2}",
1898 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
1899 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
1900 "add{b} {$src2, $dst|$dst, $src2}",
1901 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1902 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
1903 "add{w} {$src2, $dst|$dst, $src2}",
1904 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1906 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
1907 "add{l} {$src2, $dst|$dst, $src2}",
1908 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1909 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1910 "add{w} {$src2, $dst|$dst, $src2}",
1911 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1913 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1914 "add{l} {$src2, $dst|$dst, $src2}",
1915 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1918 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1919 def ADC32rr : I<0x11, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1920 "adc{l} {$src2, $dst|$dst, $src2}",
1921 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1923 def ADC32rm : I<0x13, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1924 "adc{l} {$src2, $dst|$dst, $src2}",
1925 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1926 def ADC32ri : Ii32<0x81, MRM2r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1927 "adc{l} {$src2, $dst|$dst, $src2}",
1928 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1929 def ADC32ri8 : Ii8<0x83, MRM2r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1930 "adc{l} {$src2, $dst|$dst, $src2}",
1931 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1933 let isTwoAddress = 0 in {
1934 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1935 "adc{l} {$src2, $dst|$dst, $src2}",
1936 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
1937 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
1938 "adc{l} {$src2, $dst|$dst, $src2}",
1939 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1940 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1941 "adc{l} {$src2, $dst|$dst, $src2}",
1942 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1945 def SUB8rr : I<0x28, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1946 "sub{b} {$src2, $dst|$dst, $src2}",
1947 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1948 def SUB16rr : I<0x29, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1949 "sub{w} {$src2, $dst|$dst, $src2}",
1950 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1951 def SUB32rr : I<0x29, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1952 "sub{l} {$src2, $dst|$dst, $src2}",
1953 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1954 def SUB8rm : I<0x2A, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1955 "sub{b} {$src2, $dst|$dst, $src2}",
1956 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1957 def SUB16rm : I<0x2B, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1958 "sub{w} {$src2, $dst|$dst, $src2}",
1959 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1960 def SUB32rm : I<0x2B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1961 "sub{l} {$src2, $dst|$dst, $src2}",
1962 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1964 def SUB8ri : Ii8 <0x80, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1965 "sub{b} {$src2, $dst|$dst, $src2}",
1966 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1967 def SUB16ri : Ii16<0x81, MRM5r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1968 "sub{w} {$src2, $dst|$dst, $src2}",
1969 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1970 def SUB32ri : Ii32<0x81, MRM5r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1971 "sub{l} {$src2, $dst|$dst, $src2}",
1972 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1973 def SUB16ri8 : Ii8<0x83, MRM5r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1974 "sub{w} {$src2, $dst|$dst, $src2}",
1975 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
1977 def SUB32ri8 : Ii8<0x83, MRM5r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1978 "sub{l} {$src2, $dst|$dst, $src2}",
1979 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1980 let isTwoAddress = 0 in {
1981 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
1982 "sub{b} {$src2, $dst|$dst, $src2}",
1983 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
1984 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1985 "sub{w} {$src2, $dst|$dst, $src2}",
1986 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
1988 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1989 "sub{l} {$src2, $dst|$dst, $src2}",
1990 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
1991 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
1992 "sub{b} {$src2, $dst|$dst, $src2}",
1993 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1994 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
1995 "sub{w} {$src2, $dst|$dst, $src2}",
1996 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1998 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
1999 "sub{l} {$src2, $dst|$dst, $src2}",
2000 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2001 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
2002 "sub{w} {$src2, $dst|$dst, $src2}",
2003 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2005 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
2006 "sub{l} {$src2, $dst|$dst, $src2}",
2007 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2010 def SBB32rr : I<0x19, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
2011 "sbb{l} {$src2, $dst|$dst, $src2}",
2012 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2014 let isTwoAddress = 0 in {
2015 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
2016 "sbb{l} {$src2, $dst|$dst, $src2}",
2017 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2018 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
2019 "sbb{b} {$src2, $dst|$dst, $src2}",
2020 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2021 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
2022 "sbb{l} {$src2, $dst|$dst, $src2}",
2023 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2024 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
2025 "sbb{l} {$src2, $dst|$dst, $src2}",
2026 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2028 def SBB32rm : I<0x1B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
2029 "sbb{l} {$src2, $dst|$dst, $src2}",
2030 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2031 def SBB32ri : Ii32<0x81, MRM3r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
2032 "sbb{l} {$src2, $dst|$dst, $src2}",
2033 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2034 def SBB32ri8 : Ii8<0x83, MRM3r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
2035 "sbb{l} {$src2, $dst|$dst, $src2}",
2036 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2038 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2039 def IMUL16rr : I<0xAF, MRMSrcReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
2040 "imul{w} {$src2, $dst|$dst, $src2}",
2041 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2042 def IMUL32rr : I<0xAF, MRMSrcReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
2043 "imul{l} {$src2, $dst|$dst, $src2}",
2044 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2046 def IMUL16rm : I<0xAF, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
2047 "imul{w} {$src2, $dst|$dst, $src2}",
2048 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2050 def IMUL32rm : I<0xAF, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
2051 "imul{l} {$src2, $dst|$dst, $src2}",
2052 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
2054 } // end Two Address instructions
2056 // Suprisingly enough, these are not two address instructions!
2057 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2058 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
2059 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2060 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2061 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2062 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
2063 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2064 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2065 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2066 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
2067 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2068 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2070 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2071 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
2072 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2073 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2075 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2076 (ops GR16:$dst, i16mem:$src1, i16imm:$src2),
2077 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2078 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2080 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2081 (ops GR32:$dst, i32mem:$src1, i32imm:$src2),
2082 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2083 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2084 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2085 (ops GR16:$dst, i16mem:$src1, i16i8imm :$src2),
2086 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2087 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2089 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2090 (ops GR32:$dst, i32mem:$src1, i32i8imm: $src2),
2091 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2092 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2094 //===----------------------------------------------------------------------===//
2095 // Test instructions are just like AND, except they don't generate a result.
2097 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2098 def TEST8rr : I<0x84, MRMDestReg, (ops GR8:$src1, GR8:$src2),
2099 "test{b} {$src2, $src1|$src1, $src2}",
2100 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
2101 def TEST16rr : I<0x85, MRMDestReg, (ops GR16:$src1, GR16:$src2),
2102 "test{w} {$src2, $src1|$src1, $src2}",
2103 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
2104 def TEST32rr : I<0x85, MRMDestReg, (ops GR32:$src1, GR32:$src2),
2105 "test{l} {$src2, $src1|$src1, $src2}",
2106 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
2109 def TEST8rm : I<0x84, MRMSrcMem, (ops GR8 :$src1, i8mem :$src2),
2110 "test{b} {$src2, $src1|$src1, $src2}",
2111 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
2112 def TEST16rm : I<0x85, MRMSrcMem, (ops GR16:$src1, i16mem:$src2),
2113 "test{w} {$src2, $src1|$src1, $src2}",
2114 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
2116 def TEST32rm : I<0x85, MRMSrcMem, (ops GR32:$src1, i32mem:$src2),
2117 "test{l} {$src2, $src1|$src1, $src2}",
2118 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
2120 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2121 (ops GR8:$src1, i8imm:$src2),
2122 "test{b} {$src2, $src1|$src1, $src2}",
2123 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
2124 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2125 (ops GR16:$src1, i16imm:$src2),
2126 "test{w} {$src2, $src1|$src1, $src2}",
2127 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
2128 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2129 (ops GR32:$src1, i32imm:$src2),
2130 "test{l} {$src2, $src1|$src1, $src2}",
2131 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
2133 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2134 (ops i8mem:$src1, i8imm:$src2),
2135 "test{b} {$src2, $src1|$src1, $src2}",
2136 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
2137 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2138 (ops i16mem:$src1, i16imm:$src2),
2139 "test{w} {$src2, $src1|$src1, $src2}",
2140 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
2142 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2143 (ops i32mem:$src1, i32imm:$src2),
2144 "test{l} {$src2, $src1|$src1, $src2}",
2145 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
2148 // Condition code ops, incl. set if equal/not equal/...
2149 def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2150 def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
2152 def SETEr : I<0x94, MRM0r,
2155 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2157 def SETEm : I<0x94, MRM0m,
2160 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2162 def SETNEr : I<0x95, MRM0r,
2165 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2167 def SETNEm : I<0x95, MRM0m,
2170 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2172 def SETLr : I<0x9C, MRM0r,
2175 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2176 TB; // GR8 = < signed
2177 def SETLm : I<0x9C, MRM0m,
2180 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2181 TB; // [mem8] = < signed
2182 def SETGEr : I<0x9D, MRM0r,
2185 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2186 TB; // GR8 = >= signed
2187 def SETGEm : I<0x9D, MRM0m,
2190 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2191 TB; // [mem8] = >= signed
2192 def SETLEr : I<0x9E, MRM0r,
2195 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2196 TB; // GR8 = <= signed
2197 def SETLEm : I<0x9E, MRM0m,
2200 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2201 TB; // [mem8] = <= signed
2202 def SETGr : I<0x9F, MRM0r,
2205 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2206 TB; // GR8 = > signed
2207 def SETGm : I<0x9F, MRM0m,
2210 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2211 TB; // [mem8] = > signed
2213 def SETBr : I<0x92, MRM0r,
2216 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2217 TB; // GR8 = < unsign
2218 def SETBm : I<0x92, MRM0m,
2221 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2222 TB; // [mem8] = < unsign
2223 def SETAEr : I<0x93, MRM0r,
2226 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2227 TB; // GR8 = >= unsign
2228 def SETAEm : I<0x93, MRM0m,
2231 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2232 TB; // [mem8] = >= unsign
2233 def SETBEr : I<0x96, MRM0r,
2236 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2237 TB; // GR8 = <= unsign
2238 def SETBEm : I<0x96, MRM0m,
2241 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2242 TB; // [mem8] = <= unsign
2243 def SETAr : I<0x97, MRM0r,
2246 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2247 TB; // GR8 = > signed
2248 def SETAm : I<0x97, MRM0m,
2251 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2252 TB; // [mem8] = > signed
2254 def SETSr : I<0x98, MRM0r,
2257 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2258 TB; // GR8 = <sign bit>
2259 def SETSm : I<0x98, MRM0m,
2262 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2263 TB; // [mem8] = <sign bit>
2264 def SETNSr : I<0x99, MRM0r,
2267 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2268 TB; // GR8 = !<sign bit>
2269 def SETNSm : I<0x99, MRM0m,
2272 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2273 TB; // [mem8] = !<sign bit>
2274 def SETPr : I<0x9A, MRM0r,
2277 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2279 def SETPm : I<0x9A, MRM0m,
2282 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2283 TB; // [mem8] = parity
2284 def SETNPr : I<0x9B, MRM0r,
2287 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2288 TB; // GR8 = not parity
2289 def SETNPm : I<0x9B, MRM0m,
2292 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2293 TB; // [mem8] = not parity
2295 // Integer comparisons
2296 def CMP8rr : I<0x38, MRMDestReg,
2297 (ops GR8 :$src1, GR8 :$src2),
2298 "cmp{b} {$src2, $src1|$src1, $src2}",
2299 [(X86cmp GR8:$src1, GR8:$src2)]>;
2300 def CMP16rr : I<0x39, MRMDestReg,
2301 (ops GR16:$src1, GR16:$src2),
2302 "cmp{w} {$src2, $src1|$src1, $src2}",
2303 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
2304 def CMP32rr : I<0x39, MRMDestReg,
2305 (ops GR32:$src1, GR32:$src2),
2306 "cmp{l} {$src2, $src1|$src1, $src2}",
2307 [(X86cmp GR32:$src1, GR32:$src2)]>;
2308 def CMP8mr : I<0x38, MRMDestMem,
2309 (ops i8mem :$src1, GR8 :$src2),
2310 "cmp{b} {$src2, $src1|$src1, $src2}",
2311 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
2312 def CMP16mr : I<0x39, MRMDestMem,
2313 (ops i16mem:$src1, GR16:$src2),
2314 "cmp{w} {$src2, $src1|$src1, $src2}",
2315 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
2316 def CMP32mr : I<0x39, MRMDestMem,
2317 (ops i32mem:$src1, GR32:$src2),
2318 "cmp{l} {$src2, $src1|$src1, $src2}",
2319 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
2320 def CMP8rm : I<0x3A, MRMSrcMem,
2321 (ops GR8 :$src1, i8mem :$src2),
2322 "cmp{b} {$src2, $src1|$src1, $src2}",
2323 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
2324 def CMP16rm : I<0x3B, MRMSrcMem,
2325 (ops GR16:$src1, i16mem:$src2),
2326 "cmp{w} {$src2, $src1|$src1, $src2}",
2327 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
2328 def CMP32rm : I<0x3B, MRMSrcMem,
2329 (ops GR32:$src1, i32mem:$src2),
2330 "cmp{l} {$src2, $src1|$src1, $src2}",
2331 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
2332 def CMP8ri : Ii8<0x80, MRM7r,
2333 (ops GR8:$src1, i8imm:$src2),
2334 "cmp{b} {$src2, $src1|$src1, $src2}",
2335 [(X86cmp GR8:$src1, imm:$src2)]>;
2336 def CMP16ri : Ii16<0x81, MRM7r,
2337 (ops GR16:$src1, i16imm:$src2),
2338 "cmp{w} {$src2, $src1|$src1, $src2}",
2339 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
2340 def CMP32ri : Ii32<0x81, MRM7r,
2341 (ops GR32:$src1, i32imm:$src2),
2342 "cmp{l} {$src2, $src1|$src1, $src2}",
2343 [(X86cmp GR32:$src1, imm:$src2)]>;
2344 def CMP8mi : Ii8 <0x80, MRM7m,
2345 (ops i8mem :$src1, i8imm :$src2),
2346 "cmp{b} {$src2, $src1|$src1, $src2}",
2347 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2348 def CMP16mi : Ii16<0x81, MRM7m,
2349 (ops i16mem:$src1, i16imm:$src2),
2350 "cmp{w} {$src2, $src1|$src1, $src2}",
2351 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2352 def CMP32mi : Ii32<0x81, MRM7m,
2353 (ops i32mem:$src1, i32imm:$src2),
2354 "cmp{l} {$src2, $src1|$src1, $src2}",
2355 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2356 def CMP16ri8 : Ii8<0x83, MRM7r,
2357 (ops GR16:$src1, i16i8imm:$src2),
2358 "cmp{w} {$src2, $src1|$src1, $src2}",
2359 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
2360 def CMP16mi8 : Ii8<0x83, MRM7m,
2361 (ops i16mem:$src1, i16i8imm:$src2),
2362 "cmp{w} {$src2, $src1|$src1, $src2}",
2363 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
2364 def CMP32mi8 : Ii8<0x83, MRM7m,
2365 (ops i32mem:$src1, i32i8imm:$src2),
2366 "cmp{l} {$src2, $src1|$src1, $src2}",
2367 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
2368 def CMP32ri8 : Ii8<0x83, MRM7r,
2369 (ops GR32:$src1, i32i8imm:$src2),
2370 "cmp{l} {$src2, $src1|$src1, $src2}",
2371 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
2373 // Sign/Zero extenders
2374 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
2375 "movs{bw|x} {$src, $dst|$dst, $src}",
2376 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
2377 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
2378 "movs{bw|x} {$src, $dst|$dst, $src}",
2379 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2380 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
2381 "movs{bl|x} {$src, $dst|$dst, $src}",
2382 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2383 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
2384 "movs{bl|x} {$src, $dst|$dst, $src}",
2385 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2386 def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops GR32:$dst, GR16:$src),
2387 "movs{wl|x} {$src, $dst|$dst, $src}",
2388 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2389 def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
2390 "movs{wl|x} {$src, $dst|$dst, $src}",
2391 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2393 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
2394 "movz{bw|x} {$src, $dst|$dst, $src}",
2395 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
2396 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
2397 "movz{bw|x} {$src, $dst|$dst, $src}",
2398 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2399 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
2400 "movz{bl|x} {$src, $dst|$dst, $src}",
2401 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2402 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
2403 "movz{bl|x} {$src, $dst|$dst, $src}",
2404 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2405 def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops GR32:$dst, GR16:$src),
2406 "movz{wl|x} {$src, $dst|$dst, $src}",
2407 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2408 def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
2409 "movz{wl|x} {$src, $dst|$dst, $src}",
2410 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2412 def CBW : I<0x98, RawFrm, (ops),
2413 "{cbtw|cbw}", []>, Imp<[AL],[AX]>, OpSize; // AX = signext(AL)
2414 def CWDE : I<0x98, RawFrm, (ops),
2415 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2417 def CWD : I<0x99, RawFrm, (ops),
2418 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>, OpSize; // DX:AX = signext(AX)
2419 def CDQ : I<0x99, RawFrm, (ops),
2420 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2423 //===----------------------------------------------------------------------===//
2424 // Alias Instructions
2425 //===----------------------------------------------------------------------===//
2427 // Alias instructions that map movr0 to xor.
2428 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2429 def MOV8r0 : I<0x30, MRMInitReg, (ops GR8 :$dst),
2430 "xor{b} $dst, $dst",
2431 [(set GR8:$dst, 0)]>;
2432 def MOV16r0 : I<0x31, MRMInitReg, (ops GR16:$dst),
2433 "xor{w} $dst, $dst",
2434 [(set GR16:$dst, 0)]>, OpSize;
2435 def MOV32r0 : I<0x31, MRMInitReg, (ops GR32:$dst),
2436 "xor{l} $dst, $dst",
2437 [(set GR32:$dst, 0)]>;
2439 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2440 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2441 def MOV16to16_ : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16:$src),
2442 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2443 def MOV32to32_ : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32:$src),
2444 "mov{l} {$src, $dst|$dst, $src}", []>;
2446 def MOV16_rr : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16_:$src),
2447 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2448 def MOV32_rr : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32_:$src),
2449 "mov{l} {$src, $dst|$dst, $src}", []>;
2450 def MOV16_rm : I<0x8B, MRMSrcMem, (ops GR16_:$dst, i16mem:$src),
2451 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2452 def MOV32_rm : I<0x8B, MRMSrcMem, (ops GR32_:$dst, i32mem:$src),
2453 "mov{l} {$src, $dst|$dst, $src}", []>;
2454 def MOV16_mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16_:$src),
2455 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2456 def MOV32_mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32_:$src),
2457 "mov{l} {$src, $dst|$dst, $src}", []>;
2459 //===----------------------------------------------------------------------===//
2460 // Thread Local Storage Instructions
2463 def TLS_addr : I<0, Pseudo, (ops GR32:$dst, i32imm:$sym),
2464 "leal ${sym:mem}(,%ebx,1), $dst",
2465 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>,
2468 let AddedComplexity = 10 in
2469 def TLS_gs_rr : I<0, Pseudo, (ops GR32:$dst, GR32:$src),
2470 "movl %gs:($src), $dst",
2471 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2473 let AddedComplexity = 15 in
2474 def TLS_gs_ri : I<0, Pseudo, (ops GR32:$dst, i32imm:$src),
2475 "movl %gs:${src:mem}, $dst",
2477 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2479 def TLS_tp : I<0, Pseudo, (ops GR32:$dst),
2481 [(set GR32:$dst, X86TLStp)]>;
2483 //===----------------------------------------------------------------------===//
2484 // DWARF Pseudo Instructions
2487 def DWARF_LOC : I<0, Pseudo, (ops i32imm:$line, i32imm:$col, i32imm:$file),
2488 "; .loc $file, $line, $col",
2489 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2492 //===----------------------------------------------------------------------===//
2493 // Non-Instruction Patterns
2494 //===----------------------------------------------------------------------===//
2496 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2497 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2498 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2499 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2500 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2501 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2503 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2504 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2505 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2506 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2507 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2508 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2509 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2510 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2512 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2513 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2514 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2515 (MOV32mi addr:$dst, texternalsym:$src)>;
2518 def : Pat<(X86tailcall GR32:$dst),
2519 (CALL32r GR32:$dst)>;
2521 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2522 (CALLpcrel32 tglobaladdr:$dst)>;
2523 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2524 (CALLpcrel32 texternalsym:$dst)>;
2526 def : Pat<(X86call (i32 tglobaladdr:$dst)),
2527 (CALLpcrel32 tglobaladdr:$dst)>;
2528 def : Pat<(X86call (i32 texternalsym:$dst)),
2529 (CALLpcrel32 texternalsym:$dst)>;
2531 // X86 specific add which produces a flag.
2532 def : Pat<(addc GR32:$src1, GR32:$src2),
2533 (ADD32rr GR32:$src1, GR32:$src2)>;
2534 def : Pat<(addc GR32:$src1, (load addr:$src2)),
2535 (ADD32rm GR32:$src1, addr:$src2)>;
2536 def : Pat<(addc GR32:$src1, imm:$src2),
2537 (ADD32ri GR32:$src1, imm:$src2)>;
2538 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2539 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2541 def : Pat<(subc GR32:$src1, GR32:$src2),
2542 (SUB32rr GR32:$src1, GR32:$src2)>;
2543 def : Pat<(subc GR32:$src1, (load addr:$src2)),
2544 (SUB32rm GR32:$src1, addr:$src2)>;
2545 def : Pat<(subc GR32:$src1, imm:$src2),
2546 (SUB32ri GR32:$src1, imm:$src2)>;
2547 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2548 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2550 def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2551 (MOV8mi addr:$dst, imm:$src)>;
2552 def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2553 (MOV8mr addr:$dst, GR8:$src)>;
2557 // TEST R,R is smaller than CMP R,0
2558 def : Pat<(X86cmp GR8:$src1, 0),
2559 (TEST8rr GR8:$src1, GR8:$src1)>;
2560 def : Pat<(X86cmp GR16:$src1, 0),
2561 (TEST16rr GR16:$src1, GR16:$src1)>;
2562 def : Pat<(X86cmp GR32:$src1, 0),
2563 (TEST32rr GR32:$src1, GR32:$src1)>;
2565 // {s|z}extload bool -> {s|z}extload byte
2566 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2567 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2568 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2569 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2570 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2572 // extload bool -> extload byte
2573 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2574 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2575 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2576 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2577 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2578 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2581 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2582 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2583 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2584 def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2585 def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2586 def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2588 //===----------------------------------------------------------------------===//
2590 //===----------------------------------------------------------------------===//
2592 // (shl x, 1) ==> (add x, x)
2593 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2594 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2595 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2597 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2598 def : Pat<(or (srl GR32:$src1, CL:$amt),
2599 (shl GR32:$src2, (sub 32, CL:$amt))),
2600 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2602 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2603 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2604 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2606 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2607 def : Pat<(or (shl GR32:$src1, CL:$amt),
2608 (srl GR32:$src2, (sub 32, CL:$amt))),
2609 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2611 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2612 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2613 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2615 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2616 def : Pat<(or (srl GR16:$src1, CL:$amt),
2617 (shl GR16:$src2, (sub 16, CL:$amt))),
2618 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2620 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2621 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2622 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2624 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2625 def : Pat<(or (shl GR16:$src1, CL:$amt),
2626 (srl GR16:$src2, (sub 16, CL:$amt))),
2627 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2629 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2630 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2631 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2634 //===----------------------------------------------------------------------===//
2635 // Floating Point Stack Support
2636 //===----------------------------------------------------------------------===//
2638 include "X86InstrFPStack.td"
2640 //===----------------------------------------------------------------------===//
2641 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2642 //===----------------------------------------------------------------------===//
2644 include "X86InstrMMX.td"
2646 //===----------------------------------------------------------------------===//
2647 // XMM Floating point support (requires SSE / SSE2)
2648 //===----------------------------------------------------------------------===//
2650 include "X86InstrSSE.td"
2652 //===----------------------------------------------------------------------===//
2654 //===----------------------------------------------------------------------===//
2656 include "X86InstrX86-64.td"