1 //===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86 instruction set, defining the instructions, and
11 // properties of the instructions which are needed for code generation, machine
12 // code emission, and analysis.
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
17 // X86 specific DAG Nodes.
20 def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
24 def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
26 def SDTX86Cmov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
30 def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
33 def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
36 def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
38 def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39 def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
42 def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
44 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
46 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
48 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
50 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
51 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
53 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
55 def X86test : SDNode<"X86ISD::TEST", SDTX86CmpTest,
58 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
59 [SDNPInFlag, SDNPOutFlag]>;
60 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
61 [SDNPHasChain, SDNPInFlag]>;
62 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
63 [SDNPInFlag, SDNPOutFlag]>;
65 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
66 [SDNPHasChain, SDNPOptInFlag]>;
68 def X86callseq_start :
69 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
72 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
73 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
75 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
76 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
78 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
79 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
81 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
82 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
83 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
84 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
86 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
87 [SDNPHasChain, SDNPOutFlag]>;
89 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
91 //===----------------------------------------------------------------------===//
92 // X86 Operand Definitions.
95 // *mem - Operand definitions for the funky X86 addressing mode operands.
97 class X86MemOperand<string printMethod> : Operand<iPTR> {
98 let PrintMethod = printMethod;
99 let NumMIOperands = 4;
100 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
103 def i8mem : X86MemOperand<"printi8mem">;
104 def i16mem : X86MemOperand<"printi16mem">;
105 def i32mem : X86MemOperand<"printi32mem">;
106 def i64mem : X86MemOperand<"printi64mem">;
107 def i128mem : X86MemOperand<"printi128mem">;
108 def f32mem : X86MemOperand<"printf32mem">;
109 def f64mem : X86MemOperand<"printf64mem">;
110 def f128mem : X86MemOperand<"printf128mem">;
112 def SSECC : Operand<i8> {
113 let PrintMethod = "printSSECC";
116 def piclabel: Operand<i32> {
117 let PrintMethod = "printPICLabel";
120 // A couple of more descriptive operand definitions.
121 // 16-bits but only 8 bits are significant.
122 def i16i8imm : Operand<i16>;
123 // 32-bits but only 8 bits are significant.
124 def i32i8imm : Operand<i32>;
126 // Branch targets have OtherVT type.
127 def brtarget : Operand<OtherVT>;
129 //===----------------------------------------------------------------------===//
130 // X86 Complex Pattern Definitions.
133 // Define X86 specific addressing mode.
134 def addr : ComplexPattern<iPTR, 4, "SelectAddr", []>;
135 def leaaddr : ComplexPattern<iPTR, 4, "SelectLEAAddr",
136 [add, mul, shl, or, frameindex]>;
138 //===----------------------------------------------------------------------===//
139 // X86 Instruction Format Definitions.
142 // Format specifies the encoding used by the instruction. This is part of the
143 // ad-hoc solution used to emit machine instruction encodings by our machine
145 class Format<bits<6> val> {
149 def Pseudo : Format<0>; def RawFrm : Format<1>;
150 def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
151 def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
152 def MRMSrcMem : Format<6>;
153 def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
154 def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
155 def MRM6r : Format<22>; def MRM7r : Format<23>;
156 def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
157 def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
158 def MRM6m : Format<30>; def MRM7m : Format<31>;
159 def MRMInitReg : Format<32>;
161 //===----------------------------------------------------------------------===//
162 // X86 Instruction Predicate Definitions.
163 def HasMMX : Predicate<"Subtarget->hasMMX()">;
164 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
165 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
166 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
167 def FPStack : Predicate<"!Subtarget->hasSSE2()">;
169 //===----------------------------------------------------------------------===//
170 // X86 specific pattern fragments.
173 // ImmType - This specifies the immediate type used by an instruction. This is
174 // part of the ad-hoc solution used to emit machine instruction encodings by our
175 // machine code emitter.
176 class ImmType<bits<2> val> {
179 def NoImm : ImmType<0>;
180 def Imm8 : ImmType<1>;
181 def Imm16 : ImmType<2>;
182 def Imm32 : ImmType<3>;
184 // FPFormat - This specifies what form this FP instruction has. This is used by
185 // the Floating-Point stackifier pass.
186 class FPFormat<bits<3> val> {
189 def NotFP : FPFormat<0>;
190 def ZeroArgFP : FPFormat<1>;
191 def OneArgFP : FPFormat<2>;
192 def OneArgFPRW : FPFormat<3>;
193 def TwoArgFP : FPFormat<4>;
194 def CompareFP : FPFormat<5>;
195 def CondMovFP : FPFormat<6>;
196 def SpecialFP : FPFormat<7>;
199 class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
201 let Namespace = "X86";
203 bits<8> Opcode = opcod;
205 bits<6> FormBits = Form.Value;
207 bits<2> ImmTypeBits = ImmT.Value;
209 dag OperandList = ops;
210 string AsmString = AsmStr;
213 // Attributes specific to X86 instructions...
215 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
217 bits<4> Prefix = 0; // Which prefix byte does this inst have?
218 FPFormat FPForm; // What flavor of FP instruction is this?
219 bits<3> FPFormBits = 0;
222 class Imp<list<Register> uses, list<Register> defs> {
223 list<Register> Uses = uses;
224 list<Register> Defs = defs;
228 // Prefix byte classes which are used to indicate to the ad-hoc machine code
229 // emitter that various prefix bytes are required.
230 class OpSize { bit hasOpSizePrefix = 1; }
231 class TB { bits<4> Prefix = 1; }
232 class REP { bits<4> Prefix = 2; }
233 class D8 { bits<4> Prefix = 3; }
234 class D9 { bits<4> Prefix = 4; }
235 class DA { bits<4> Prefix = 5; }
236 class DB { bits<4> Prefix = 6; }
237 class DC { bits<4> Prefix = 7; }
238 class DD { bits<4> Prefix = 8; }
239 class DE { bits<4> Prefix = 9; }
240 class DF { bits<4> Prefix = 10; }
241 class XD { bits<4> Prefix = 11; }
242 class XS { bits<4> Prefix = 12; }
245 //===----------------------------------------------------------------------===//
246 // Pattern fragments...
249 // X86 specific condition code. These correspond to CondCode in
250 // X86ISelLowering.h. They must be kept in synch.
251 def X86_COND_A : PatLeaf<(i8 0)>;
252 def X86_COND_AE : PatLeaf<(i8 1)>;
253 def X86_COND_B : PatLeaf<(i8 2)>;
254 def X86_COND_BE : PatLeaf<(i8 3)>;
255 def X86_COND_E : PatLeaf<(i8 4)>;
256 def X86_COND_G : PatLeaf<(i8 5)>;
257 def X86_COND_GE : PatLeaf<(i8 6)>;
258 def X86_COND_L : PatLeaf<(i8 7)>;
259 def X86_COND_LE : PatLeaf<(i8 8)>;
260 def X86_COND_NE : PatLeaf<(i8 9)>;
261 def X86_COND_NO : PatLeaf<(i8 10)>;
262 def X86_COND_NP : PatLeaf<(i8 11)>;
263 def X86_COND_NS : PatLeaf<(i8 12)>;
264 def X86_COND_O : PatLeaf<(i8 13)>;
265 def X86_COND_P : PatLeaf<(i8 14)>;
266 def X86_COND_S : PatLeaf<(i8 15)>;
268 def i16immSExt8 : PatLeaf<(i16 imm), [{
269 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
270 // sign extended field.
271 return (int16_t)N->getValue() == (int8_t)N->getValue();
274 def i32immSExt8 : PatLeaf<(i32 imm), [{
275 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
276 // sign extended field.
277 return (int32_t)N->getValue() == (int8_t)N->getValue();
280 // Helper fragments for loads.
281 def loadiPTR : PatFrag<(ops node:$ptr), (iPTR (load node:$ptr))>;
283 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
284 def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
285 def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
286 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
288 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
289 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
291 def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i1))>;
292 def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i1))>;
293 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i8))>;
294 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i8))>;
295 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i16))>;
297 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextload node:$ptr, i1))>;
298 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i1))>;
299 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i1))>;
300 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i8))>;
301 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i8))>;
302 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i16))>;
304 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extload node:$ptr, i1))>;
305 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extload node:$ptr, i1))>;
306 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extload node:$ptr, i1))>;
307 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extload node:$ptr, i8))>;
308 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extload node:$ptr, i8))>;
309 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extload node:$ptr, i16))>;
311 //===----------------------------------------------------------------------===//
312 // Instruction templates...
314 class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
315 : X86Inst<o, f, NoImm, ops, asm> {
316 let Pattern = pattern;
318 class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
319 : X86Inst<o, f, Imm8 , ops, asm> {
320 let Pattern = pattern;
322 class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
323 : X86Inst<o, f, Imm16, ops, asm> {
324 let Pattern = pattern;
326 class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
327 : X86Inst<o, f, Imm32, ops, asm> {
328 let Pattern = pattern;
331 //===----------------------------------------------------------------------===//
332 // Instruction list...
335 def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
336 [(X86callseq_start imm:$amt)]>;
337 def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
339 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
340 def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
341 def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
342 def IMPLICIT_DEF_GR8 : I<0, Pseudo, (ops GR8:$dst),
343 "#IMPLICIT_DEF $dst",
344 [(set GR8:$dst, (undef))]>;
345 def IMPLICIT_DEF_GR16 : I<0, Pseudo, (ops GR16:$dst),
346 "#IMPLICIT_DEF $dst",
347 [(set GR16:$dst, (undef))]>;
348 def IMPLICIT_DEF_GR32 : I<0, Pseudo, (ops GR32:$dst),
349 "#IMPLICIT_DEF $dst",
350 [(set GR32:$dst, (undef))]>;
353 def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
356 def TRUNC_GR32_GR8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR32_:$src),
357 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}", []>;
358 def TRUNC_GR16_GR8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR16_:$src),
359 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}}", []>;
360 def TRUNC_GR32_GR16 : I<0x89, MRMDestReg, (ops GR16:$dst, GR32:$src),
361 "mov{w} {${src:subreg16}, $dst|$dst, ${src:subreg16}}",
362 [(set GR16:$dst, (trunc GR32:$src))]>;
364 //===----------------------------------------------------------------------===//
365 // Control Flow Instructions...
368 // Return instructions.
369 let isTerminator = 1, isReturn = 1, isBarrier = 1,
370 hasCtrlDep = 1, noResults = 1 in {
371 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
372 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
373 [(X86retflag imm:$amt)]>;
376 // All branches are RawFrm, Void, Branch, and Terminators
377 let isBranch = 1, isTerminator = 1, noResults = 1 in
378 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
379 I<opcode, RawFrm, ops, asm, pattern>;
383 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
385 let isBranch = 1, isTerminator = 1, noResults = 1, isBarrier = 1 in {
386 def JMP32r : I<0xFF, MRM4r, (ops GR32:$dst), "jmp{l} {*}$dst",
387 [(brind GR32:$dst)]>;
388 def JMP32m : I<0xFF, MRM4m, (ops i32mem:$dst), "jmp{l} {*}$dst",
389 [(brind (loadiPTR addr:$dst))]>;
392 // Conditional branches
393 def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
394 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
395 def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
396 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
397 def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
398 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
399 def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
400 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
401 def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
402 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
403 def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
404 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
406 def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
407 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
408 def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
409 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
410 def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
411 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
412 def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
413 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
415 def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
416 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
417 def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
418 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
419 def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
420 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
421 def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
422 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
423 def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
424 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
425 def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
426 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
428 //===----------------------------------------------------------------------===//
429 // Call Instructions...
431 let isCall = 1, noResults = 1 in
432 // All calls clobber the non-callee saved registers...
433 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
434 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
435 def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst, variable_ops),
436 "call ${dst:call}", []>;
437 def CALL32r : I<0xFF, MRM2r, (ops GR32:$dst, variable_ops),
438 "call {*}$dst", [(X86call GR32:$dst)]>;
439 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst, variable_ops),
444 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
445 def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call} # TAIL CALL", []>;
446 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
447 def TAILJMPr : I<0xFF, MRM4r, (ops GR32:$dst), "jmp {*}$dst # TAIL CALL", []>;
448 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
449 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
450 "jmp {*}$dst # TAIL CALL", []>;
452 // ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
453 // way, except that it is marked as being a terminator. This causes the epilog
454 // inserter to insert reloads of callee saved registers BEFORE this. We need
455 // this until we have a more accurate way of tracking where the stack pointer is
456 // within a function.
457 let isTerminator = 1, isTwoAddress = 1 in
458 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
459 "add{l} {$src2, $dst|$dst, $src2}", []>;
461 //===----------------------------------------------------------------------===//
462 // Miscellaneous Instructions...
464 def LEAVE : I<0xC9, RawFrm,
465 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
466 def POP32r : I<0x58, AddRegFrm,
467 (ops GR32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
469 def MovePCtoStack : I<0, Pseudo, (ops piclabel:$label),
472 let isTwoAddress = 1 in // GR32 = bswap GR32
473 def BSWAP32r : I<0xC8, AddRegFrm,
474 (ops GR32:$dst, GR32:$src),
476 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
478 def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
479 (ops GR8:$src1, GR8:$src2),
480 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
481 def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
482 (ops GR16:$src1, GR16:$src2),
483 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
484 def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
485 (ops GR32:$src1, GR32:$src2),
486 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
488 def XCHG8mr : I<0x86, MRMDestMem,
489 (ops i8mem:$src1, GR8:$src2),
490 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
491 def XCHG16mr : I<0x87, MRMDestMem,
492 (ops i16mem:$src1, GR16:$src2),
493 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
494 def XCHG32mr : I<0x87, MRMDestMem,
495 (ops i32mem:$src1, GR32:$src2),
496 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
497 def XCHG8rm : I<0x86, MRMSrcMem,
498 (ops GR8:$src1, i8mem:$src2),
499 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
500 def XCHG16rm : I<0x87, MRMSrcMem,
501 (ops GR16:$src1, i16mem:$src2),
502 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
503 def XCHG32rm : I<0x87, MRMSrcMem,
504 (ops GR32:$src1, i32mem:$src2),
505 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
507 def LEA16r : I<0x8D, MRMSrcMem,
508 (ops GR16:$dst, i32mem:$src),
509 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
510 def LEA32r : I<0x8D, MRMSrcMem,
511 (ops GR32:$dst, i32mem:$src),
512 "lea{l} {$src|$dst}, {$dst|$src}",
513 [(set GR32:$dst, leaaddr:$src)]>;
515 def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
517 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
518 def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
519 [(X86rep_movs i16)]>,
520 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
521 def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsl|rep movsd}",
522 [(X86rep_movs i32)]>,
523 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
525 def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
527 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
528 def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
529 [(X86rep_stos i16)]>,
530 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
531 def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
532 [(X86rep_stos i32)]>,
533 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
536 //===----------------------------------------------------------------------===//
537 // Input/Output Instructions...
539 def IN8rr : I<0xEC, RawFrm, (ops),
540 "in{b} {%dx, %al|%AL, %DX}",
541 []>, Imp<[DX], [AL]>;
542 def IN16rr : I<0xED, RawFrm, (ops),
543 "in{w} {%dx, %ax|%AX, %DX}",
544 []>, Imp<[DX], [AX]>, OpSize;
545 def IN32rr : I<0xED, RawFrm, (ops),
546 "in{l} {%dx, %eax|%EAX, %DX}",
547 []>, Imp<[DX],[EAX]>;
549 def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
550 "in{b} {$port, %al|%AL, $port}",
553 def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
554 "in{w} {$port, %ax|%AX, $port}",
556 Imp<[], [AX]>, OpSize;
557 def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
558 "in{l} {$port, %eax|%EAX, $port}",
562 def OUT8rr : I<0xEE, RawFrm, (ops),
563 "out{b} {%al, %dx|%DX, %AL}",
564 []>, Imp<[DX, AL], []>;
565 def OUT16rr : I<0xEF, RawFrm, (ops),
566 "out{w} {%ax, %dx|%DX, %AX}",
567 []>, Imp<[DX, AX], []>, OpSize;
568 def OUT32rr : I<0xEF, RawFrm, (ops),
569 "out{l} {%eax, %dx|%DX, %EAX}",
570 []>, Imp<[DX, EAX], []>;
572 def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
573 "out{b} {%al, $port|$port, %AL}",
576 def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
577 "out{w} {%ax, $port|$port, %AX}",
579 Imp<[AX], []>, OpSize;
580 def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
581 "out{l} {%eax, $port|$port, %EAX}",
585 //===----------------------------------------------------------------------===//
586 // Move Instructions...
588 def MOV8rr : I<0x88, MRMDestReg, (ops GR8 :$dst, GR8 :$src),
589 "mov{b} {$src, $dst|$dst, $src}", []>;
590 def MOV16rr : I<0x89, MRMDestReg, (ops GR16:$dst, GR16:$src),
591 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
592 def MOV32rr : I<0x89, MRMDestReg, (ops GR32:$dst, GR32:$src),
593 "mov{l} {$src, $dst|$dst, $src}", []>;
594 def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops GR8 :$dst, i8imm :$src),
595 "mov{b} {$src, $dst|$dst, $src}",
596 [(set GR8:$dst, imm:$src)]>;
597 def MOV16ri : Ii16<0xB8, AddRegFrm, (ops GR16:$dst, i16imm:$src),
598 "mov{w} {$src, $dst|$dst, $src}",
599 [(set GR16:$dst, imm:$src)]>, OpSize;
600 def MOV32ri : Ii32<0xB8, AddRegFrm, (ops GR32:$dst, i32imm:$src),
601 "mov{l} {$src, $dst|$dst, $src}",
602 [(set GR32:$dst, imm:$src)]>;
603 def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
604 "mov{b} {$src, $dst|$dst, $src}",
605 [(store (i8 imm:$src), addr:$dst)]>;
606 def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
607 "mov{w} {$src, $dst|$dst, $src}",
608 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
609 def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
610 "mov{l} {$src, $dst|$dst, $src}",
611 [(store (i32 imm:$src), addr:$dst)]>;
613 def MOV8rm : I<0x8A, MRMSrcMem, (ops GR8 :$dst, i8mem :$src),
614 "mov{b} {$src, $dst|$dst, $src}",
615 [(set GR8:$dst, (load addr:$src))]>;
616 def MOV16rm : I<0x8B, MRMSrcMem, (ops GR16:$dst, i16mem:$src),
617 "mov{w} {$src, $dst|$dst, $src}",
618 [(set GR16:$dst, (load addr:$src))]>, OpSize;
619 def MOV32rm : I<0x8B, MRMSrcMem, (ops GR32:$dst, i32mem:$src),
620 "mov{l} {$src, $dst|$dst, $src}",
621 [(set GR32:$dst, (load addr:$src))]>;
623 def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, GR8 :$src),
624 "mov{b} {$src, $dst|$dst, $src}",
625 [(store GR8:$src, addr:$dst)]>;
626 def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16:$src),
627 "mov{w} {$src, $dst|$dst, $src}",
628 [(store GR16:$src, addr:$dst)]>, OpSize;
629 def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32:$src),
630 "mov{l} {$src, $dst|$dst, $src}",
631 [(store GR32:$src, addr:$dst)]>;
633 //===----------------------------------------------------------------------===//
634 // Fixed-Register Multiplication and Division Instructions...
637 // Extra precision multiplication
638 def MUL8r : I<0xF6, MRM4r, (ops GR8:$src), "mul{b} $src",
639 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
640 // This probably ought to be moved to a def : Pat<> if the
641 // syntax can be accepted.
642 [(set AL, (mul AL, GR8:$src))]>,
643 Imp<[AL],[AX]>; // AL,AH = AL*GR8
644 def MUL16r : I<0xF7, MRM4r, (ops GR16:$src), "mul{w} $src", []>,
645 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
646 def MUL32r : I<0xF7, MRM4r, (ops GR32:$src), "mul{l} $src", []>,
647 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
648 def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
650 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
651 // This probably ought to be moved to a def : Pat<> if the
652 // syntax can be accepted.
653 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
654 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
655 def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
656 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
657 OpSize; // AX,DX = AX*[mem16]
658 def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
659 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
661 def IMUL8r : I<0xF6, MRM5r, (ops GR8:$src), "imul{b} $src", []>,
662 Imp<[AL],[AX]>; // AL,AH = AL*GR8
663 def IMUL16r : I<0xF7, MRM5r, (ops GR16:$src), "imul{w} $src", []>,
664 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
665 def IMUL32r : I<0xF7, MRM5r, (ops GR32:$src), "imul{l} $src", []>,
666 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
667 def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
668 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
669 def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
670 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
671 OpSize; // AX,DX = AX*[mem16]
672 def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
674 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
676 // unsigned division/remainder
677 def DIV8r : I<0xF6, MRM6r, (ops GR8:$src), // AX/r8 = AL,AH
678 "div{b} $src", []>, Imp<[AX],[AX]>;
679 def DIV16r : I<0xF7, MRM6r, (ops GR16:$src), // DX:AX/r16 = AX,DX
680 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
681 def DIV32r : I<0xF7, MRM6r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
682 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
683 def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
684 "div{b} $src", []>, Imp<[AX],[AX]>;
685 def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
686 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
687 def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
688 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
690 // Signed division/remainder.
691 def IDIV8r : I<0xF6, MRM7r, (ops GR8:$src), // AX/r8 = AL,AH
692 "idiv{b} $src", []>, Imp<[AX],[AX]>;
693 def IDIV16r: I<0xF7, MRM7r, (ops GR16:$src), // DX:AX/r16 = AX,DX
694 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
695 def IDIV32r: I<0xF7, MRM7r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
696 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
697 def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
698 "idiv{b} $src", []>, Imp<[AX],[AX]>;
699 def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
700 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
701 def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
702 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
705 //===----------------------------------------------------------------------===//
706 // Two address Instructions...
708 let isTwoAddress = 1 in {
711 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
712 (ops GR16:$dst, GR16:$src1, GR16:$src2),
713 "cmovb {$src2, $dst|$dst, $src2}",
714 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
717 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
718 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
719 "cmovb {$src2, $dst|$dst, $src2}",
720 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
723 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
724 (ops GR32:$dst, GR32:$src1, GR32:$src2),
725 "cmovb {$src2, $dst|$dst, $src2}",
726 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
729 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
730 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
731 "cmovb {$src2, $dst|$dst, $src2}",
732 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
736 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
737 (ops GR16:$dst, GR16:$src1, GR16:$src2),
738 "cmovae {$src2, $dst|$dst, $src2}",
739 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
742 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
743 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
744 "cmovae {$src2, $dst|$dst, $src2}",
745 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
748 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
749 (ops GR32:$dst, GR32:$src1, GR32:$src2),
750 "cmovae {$src2, $dst|$dst, $src2}",
751 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
754 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
755 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
756 "cmovae {$src2, $dst|$dst, $src2}",
757 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
761 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
762 (ops GR16:$dst, GR16:$src1, GR16:$src2),
763 "cmove {$src2, $dst|$dst, $src2}",
764 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
767 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
768 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
769 "cmove {$src2, $dst|$dst, $src2}",
770 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
773 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
774 (ops GR32:$dst, GR32:$src1, GR32:$src2),
775 "cmove {$src2, $dst|$dst, $src2}",
776 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
779 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
780 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
781 "cmove {$src2, $dst|$dst, $src2}",
782 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
786 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
787 (ops GR16:$dst, GR16:$src1, GR16:$src2),
788 "cmovne {$src2, $dst|$dst, $src2}",
789 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
792 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
793 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
794 "cmovne {$src2, $dst|$dst, $src2}",
795 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
798 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
799 (ops GR32:$dst, GR32:$src1, GR32:$src2),
800 "cmovne {$src2, $dst|$dst, $src2}",
801 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
804 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
805 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
806 "cmovne {$src2, $dst|$dst, $src2}",
807 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
811 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
812 (ops GR16:$dst, GR16:$src1, GR16:$src2),
813 "cmovbe {$src2, $dst|$dst, $src2}",
814 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
817 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
818 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
819 "cmovbe {$src2, $dst|$dst, $src2}",
820 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
823 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
824 (ops GR32:$dst, GR32:$src1, GR32:$src2),
825 "cmovbe {$src2, $dst|$dst, $src2}",
826 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
829 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
830 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
831 "cmovbe {$src2, $dst|$dst, $src2}",
832 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
836 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
837 (ops GR16:$dst, GR16:$src1, GR16:$src2),
838 "cmova {$src2, $dst|$dst, $src2}",
839 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
842 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
843 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
844 "cmova {$src2, $dst|$dst, $src2}",
845 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
848 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
849 (ops GR32:$dst, GR32:$src1, GR32:$src2),
850 "cmova {$src2, $dst|$dst, $src2}",
851 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
854 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
855 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
856 "cmova {$src2, $dst|$dst, $src2}",
857 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
861 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
862 (ops GR16:$dst, GR16:$src1, GR16:$src2),
863 "cmovl {$src2, $dst|$dst, $src2}",
864 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
867 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
868 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
869 "cmovl {$src2, $dst|$dst, $src2}",
870 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
873 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
874 (ops GR32:$dst, GR32:$src1, GR32:$src2),
875 "cmovl {$src2, $dst|$dst, $src2}",
876 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
879 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
880 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
881 "cmovl {$src2, $dst|$dst, $src2}",
882 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
886 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
887 (ops GR16:$dst, GR16:$src1, GR16:$src2),
888 "cmovge {$src2, $dst|$dst, $src2}",
889 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
892 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
893 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
894 "cmovge {$src2, $dst|$dst, $src2}",
895 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
898 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
899 (ops GR32:$dst, GR32:$src1, GR32:$src2),
900 "cmovge {$src2, $dst|$dst, $src2}",
901 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
904 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
905 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
906 "cmovge {$src2, $dst|$dst, $src2}",
907 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
911 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
912 (ops GR16:$dst, GR16:$src1, GR16:$src2),
913 "cmovle {$src2, $dst|$dst, $src2}",
914 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
917 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
918 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
919 "cmovle {$src2, $dst|$dst, $src2}",
920 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
923 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
924 (ops GR32:$dst, GR32:$src1, GR32:$src2),
925 "cmovle {$src2, $dst|$dst, $src2}",
926 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
929 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
930 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
931 "cmovle {$src2, $dst|$dst, $src2}",
932 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
936 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
937 (ops GR16:$dst, GR16:$src1, GR16:$src2),
938 "cmovg {$src2, $dst|$dst, $src2}",
939 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
942 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
943 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
944 "cmovg {$src2, $dst|$dst, $src2}",
945 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
948 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
949 (ops GR32:$dst, GR32:$src1, GR32:$src2),
950 "cmovg {$src2, $dst|$dst, $src2}",
951 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
954 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
955 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
956 "cmovg {$src2, $dst|$dst, $src2}",
957 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
961 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
962 (ops GR16:$dst, GR16:$src1, GR16:$src2),
963 "cmovs {$src2, $dst|$dst, $src2}",
964 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
967 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
968 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
969 "cmovs {$src2, $dst|$dst, $src2}",
970 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
973 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
974 (ops GR32:$dst, GR32:$src1, GR32:$src2),
975 "cmovs {$src2, $dst|$dst, $src2}",
976 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
979 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
980 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
981 "cmovs {$src2, $dst|$dst, $src2}",
982 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
986 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
987 (ops GR16:$dst, GR16:$src1, GR16:$src2),
988 "cmovns {$src2, $dst|$dst, $src2}",
989 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
992 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
993 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
994 "cmovns {$src2, $dst|$dst, $src2}",
995 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
998 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
999 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1000 "cmovns {$src2, $dst|$dst, $src2}",
1001 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1004 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1005 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1006 "cmovns {$src2, $dst|$dst, $src2}",
1007 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1011 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1012 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1013 "cmovp {$src2, $dst|$dst, $src2}",
1014 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1017 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1018 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1019 "cmovp {$src2, $dst|$dst, $src2}",
1020 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1023 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1024 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1025 "cmovp {$src2, $dst|$dst, $src2}",
1026 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1029 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1030 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1031 "cmovp {$src2, $dst|$dst, $src2}",
1032 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1036 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1037 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1038 "cmovnp {$src2, $dst|$dst, $src2}",
1039 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1042 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1043 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1044 "cmovnp {$src2, $dst|$dst, $src2}",
1045 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1048 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1049 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1050 "cmovnp {$src2, $dst|$dst, $src2}",
1051 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1054 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1055 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1056 "cmovnp {$src2, $dst|$dst, $src2}",
1057 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1062 // unary instructions
1063 def NEG8r : I<0xF6, MRM3r, (ops GR8 :$dst, GR8 :$src), "neg{b} $dst",
1064 [(set GR8:$dst, (ineg GR8:$src))]>;
1065 def NEG16r : I<0xF7, MRM3r, (ops GR16:$dst, GR16:$src), "neg{w} $dst",
1066 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1067 def NEG32r : I<0xF7, MRM3r, (ops GR32:$dst, GR32:$src), "neg{l} $dst",
1068 [(set GR32:$dst, (ineg GR32:$src))]>;
1069 let isTwoAddress = 0 in {
1070 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
1071 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1072 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
1073 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1074 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
1075 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1079 def NOT8r : I<0xF6, MRM2r, (ops GR8 :$dst, GR8 :$src), "not{b} $dst",
1080 [(set GR8:$dst, (not GR8:$src))]>;
1081 def NOT16r : I<0xF7, MRM2r, (ops GR16:$dst, GR16:$src), "not{w} $dst",
1082 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1083 def NOT32r : I<0xF7, MRM2r, (ops GR32:$dst, GR32:$src), "not{l} $dst",
1084 [(set GR32:$dst, (not GR32:$src))]>;
1085 let isTwoAddress = 0 in {
1086 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
1087 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1088 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
1089 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1090 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
1091 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1094 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1095 def INC8r : I<0xFE, MRM0r, (ops GR8 :$dst, GR8 :$src), "inc{b} $dst",
1096 [(set GR8:$dst, (add GR8:$src, 1))]>;
1097 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1098 def INC16r : I<0xFF, MRM0r, (ops GR16:$dst, GR16:$src), "inc{w} $dst",
1099 [(set GR16:$dst, (add GR16:$src, 1))]>, OpSize;
1100 def INC32r : I<0xFF, MRM0r, (ops GR32:$dst, GR32:$src), "inc{l} $dst",
1101 [(set GR32:$dst, (add GR32:$src, 1))]>;
1103 let isTwoAddress = 0 in {
1104 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
1105 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1106 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
1107 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
1108 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
1109 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1112 def DEC8r : I<0xFE, MRM1r, (ops GR8 :$dst, GR8 :$src), "dec{b} $dst",
1113 [(set GR8:$dst, (add GR8:$src, -1))]>;
1114 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1115 def DEC16r : I<0xFF, MRM1r, (ops GR16:$dst, GR16:$src), "dec{w} $dst",
1116 [(set GR16:$dst, (add GR16:$src, -1))]>, OpSize;
1117 def DEC32r : I<0xFF, MRM1r, (ops GR32:$dst, GR32:$src), "dec{l} $dst",
1118 [(set GR32:$dst, (add GR32:$src, -1))]>;
1121 let isTwoAddress = 0 in {
1122 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
1123 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1124 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
1125 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
1126 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
1127 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1130 // Logical operators...
1131 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1132 def AND8rr : I<0x20, MRMDestReg,
1133 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1134 "and{b} {$src2, $dst|$dst, $src2}",
1135 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1136 def AND16rr : I<0x21, MRMDestReg,
1137 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1138 "and{w} {$src2, $dst|$dst, $src2}",
1139 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1140 def AND32rr : I<0x21, MRMDestReg,
1141 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1142 "and{l} {$src2, $dst|$dst, $src2}",
1143 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1146 def AND8rm : I<0x22, MRMSrcMem,
1147 (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1148 "and{b} {$src2, $dst|$dst, $src2}",
1149 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1150 def AND16rm : I<0x23, MRMSrcMem,
1151 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1152 "and{w} {$src2, $dst|$dst, $src2}",
1153 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1154 def AND32rm : I<0x23, MRMSrcMem,
1155 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1156 "and{l} {$src2, $dst|$dst, $src2}",
1157 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1159 def AND8ri : Ii8<0x80, MRM4r,
1160 (ops GR8 :$dst, GR8 :$src1, i8imm :$src2),
1161 "and{b} {$src2, $dst|$dst, $src2}",
1162 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1163 def AND16ri : Ii16<0x81, MRM4r,
1164 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1165 "and{w} {$src2, $dst|$dst, $src2}",
1166 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1167 def AND32ri : Ii32<0x81, MRM4r,
1168 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1169 "and{l} {$src2, $dst|$dst, $src2}",
1170 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1171 def AND16ri8 : Ii8<0x83, MRM4r,
1172 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1173 "and{w} {$src2, $dst|$dst, $src2}",
1174 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1176 def AND32ri8 : Ii8<0x83, MRM4r,
1177 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1178 "and{l} {$src2, $dst|$dst, $src2}",
1179 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1181 let isTwoAddress = 0 in {
1182 def AND8mr : I<0x20, MRMDestMem,
1183 (ops i8mem :$dst, GR8 :$src),
1184 "and{b} {$src, $dst|$dst, $src}",
1185 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1186 def AND16mr : I<0x21, MRMDestMem,
1187 (ops i16mem:$dst, GR16:$src),
1188 "and{w} {$src, $dst|$dst, $src}",
1189 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1191 def AND32mr : I<0x21, MRMDestMem,
1192 (ops i32mem:$dst, GR32:$src),
1193 "and{l} {$src, $dst|$dst, $src}",
1194 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1195 def AND8mi : Ii8<0x80, MRM4m,
1196 (ops i8mem :$dst, i8imm :$src),
1197 "and{b} {$src, $dst|$dst, $src}",
1198 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1199 def AND16mi : Ii16<0x81, MRM4m,
1200 (ops i16mem:$dst, i16imm:$src),
1201 "and{w} {$src, $dst|$dst, $src}",
1202 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1204 def AND32mi : Ii32<0x81, MRM4m,
1205 (ops i32mem:$dst, i32imm:$src),
1206 "and{l} {$src, $dst|$dst, $src}",
1207 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1208 def AND16mi8 : Ii8<0x83, MRM4m,
1209 (ops i16mem:$dst, i16i8imm :$src),
1210 "and{w} {$src, $dst|$dst, $src}",
1211 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1213 def AND32mi8 : Ii8<0x83, MRM4m,
1214 (ops i32mem:$dst, i32i8imm :$src),
1215 "and{l} {$src, $dst|$dst, $src}",
1216 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1220 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1221 def OR8rr : I<0x08, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1222 "or{b} {$src2, $dst|$dst, $src2}",
1223 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1224 def OR16rr : I<0x09, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1225 "or{w} {$src2, $dst|$dst, $src2}",
1226 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1227 def OR32rr : I<0x09, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1228 "or{l} {$src2, $dst|$dst, $src2}",
1229 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1231 def OR8rm : I<0x0A, MRMSrcMem , (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1232 "or{b} {$src2, $dst|$dst, $src2}",
1233 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1234 def OR16rm : I<0x0B, MRMSrcMem , (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1235 "or{w} {$src2, $dst|$dst, $src2}",
1236 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1237 def OR32rm : I<0x0B, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1238 "or{l} {$src2, $dst|$dst, $src2}",
1239 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1241 def OR8ri : Ii8 <0x80, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1242 "or{b} {$src2, $dst|$dst, $src2}",
1243 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1244 def OR16ri : Ii16<0x81, MRM1r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1245 "or{w} {$src2, $dst|$dst, $src2}",
1246 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1247 def OR32ri : Ii32<0x81, MRM1r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1248 "or{l} {$src2, $dst|$dst, $src2}",
1249 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1251 def OR16ri8 : Ii8<0x83, MRM1r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1252 "or{w} {$src2, $dst|$dst, $src2}",
1253 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1254 def OR32ri8 : Ii8<0x83, MRM1r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1255 "or{l} {$src2, $dst|$dst, $src2}",
1256 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1257 let isTwoAddress = 0 in {
1258 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, GR8:$src),
1259 "or{b} {$src, $dst|$dst, $src}",
1260 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1261 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, GR16:$src),
1262 "or{w} {$src, $dst|$dst, $src}",
1263 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1264 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, GR32:$src),
1265 "or{l} {$src, $dst|$dst, $src}",
1266 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
1267 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
1268 "or{b} {$src, $dst|$dst, $src}",
1269 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1270 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
1271 "or{w} {$src, $dst|$dst, $src}",
1272 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1274 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
1275 "or{l} {$src, $dst|$dst, $src}",
1276 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1277 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1278 "or{w} {$src, $dst|$dst, $src}",
1279 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1281 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1282 "or{l} {$src, $dst|$dst, $src}",
1283 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1287 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1288 def XOR8rr : I<0x30, MRMDestReg,
1289 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1290 "xor{b} {$src2, $dst|$dst, $src2}",
1291 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1292 def XOR16rr : I<0x31, MRMDestReg,
1293 (ops GR16:$dst, GR16:$src1, GR16:$src2),
1294 "xor{w} {$src2, $dst|$dst, $src2}",
1295 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1296 def XOR32rr : I<0x31, MRMDestReg,
1297 (ops GR32:$dst, GR32:$src1, GR32:$src2),
1298 "xor{l} {$src2, $dst|$dst, $src2}",
1299 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1302 def XOR8rm : I<0x32, MRMSrcMem ,
1303 (ops GR8 :$dst, GR8:$src1, i8mem :$src2),
1304 "xor{b} {$src2, $dst|$dst, $src2}",
1305 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1306 def XOR16rm : I<0x33, MRMSrcMem ,
1307 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1308 "xor{w} {$src2, $dst|$dst, $src2}",
1309 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1310 def XOR32rm : I<0x33, MRMSrcMem ,
1311 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1312 "xor{l} {$src2, $dst|$dst, $src2}",
1313 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1315 def XOR8ri : Ii8<0x80, MRM6r,
1316 (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1317 "xor{b} {$src2, $dst|$dst, $src2}",
1318 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1319 def XOR16ri : Ii16<0x81, MRM6r,
1320 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1321 "xor{w} {$src2, $dst|$dst, $src2}",
1322 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1323 def XOR32ri : Ii32<0x81, MRM6r,
1324 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1325 "xor{l} {$src2, $dst|$dst, $src2}",
1326 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1327 def XOR16ri8 : Ii8<0x83, MRM6r,
1328 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1329 "xor{w} {$src2, $dst|$dst, $src2}",
1330 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1332 def XOR32ri8 : Ii8<0x83, MRM6r,
1333 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1334 "xor{l} {$src2, $dst|$dst, $src2}",
1335 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1336 let isTwoAddress = 0 in {
1337 def XOR8mr : I<0x30, MRMDestMem,
1338 (ops i8mem :$dst, GR8 :$src),
1339 "xor{b} {$src, $dst|$dst, $src}",
1340 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1341 def XOR16mr : I<0x31, MRMDestMem,
1342 (ops i16mem:$dst, GR16:$src),
1343 "xor{w} {$src, $dst|$dst, $src}",
1344 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1346 def XOR32mr : I<0x31, MRMDestMem,
1347 (ops i32mem:$dst, GR32:$src),
1348 "xor{l} {$src, $dst|$dst, $src}",
1349 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1350 def XOR8mi : Ii8<0x80, MRM6m,
1351 (ops i8mem :$dst, i8imm :$src),
1352 "xor{b} {$src, $dst|$dst, $src}",
1353 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1354 def XOR16mi : Ii16<0x81, MRM6m,
1355 (ops i16mem:$dst, i16imm:$src),
1356 "xor{w} {$src, $dst|$dst, $src}",
1357 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1359 def XOR32mi : Ii32<0x81, MRM6m,
1360 (ops i32mem:$dst, i32imm:$src),
1361 "xor{l} {$src, $dst|$dst, $src}",
1362 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1363 def XOR16mi8 : Ii8<0x83, MRM6m,
1364 (ops i16mem:$dst, i16i8imm :$src),
1365 "xor{w} {$src, $dst|$dst, $src}",
1366 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1368 def XOR32mi8 : Ii8<0x83, MRM6m,
1369 (ops i32mem:$dst, i32i8imm :$src),
1370 "xor{l} {$src, $dst|$dst, $src}",
1371 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1374 // Shift instructions
1375 def SHL8rCL : I<0xD2, MRM4r, (ops GR8 :$dst, GR8 :$src),
1376 "shl{b} {%cl, $dst|$dst, %CL}",
1377 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
1378 def SHL16rCL : I<0xD3, MRM4r, (ops GR16:$dst, GR16:$src),
1379 "shl{w} {%cl, $dst|$dst, %CL}",
1380 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1381 def SHL32rCL : I<0xD3, MRM4r, (ops GR32:$dst, GR32:$src),
1382 "shl{l} {%cl, $dst|$dst, %CL}",
1383 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
1385 def SHL8ri : Ii8<0xC0, MRM4r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1386 "shl{b} {$src2, $dst|$dst, $src2}",
1387 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1388 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1389 def SHL16ri : Ii8<0xC1, MRM4r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1390 "shl{w} {$src2, $dst|$dst, $src2}",
1391 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1392 def SHL32ri : Ii8<0xC1, MRM4r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1393 "shl{l} {$src2, $dst|$dst, $src2}",
1394 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1397 // Shift left by one. Not used because (add x, x) is slightly cheaper.
1398 def SHL8r1 : I<0xD0, MRM4r, (ops GR8 :$dst, GR8 :$src1),
1399 "shl{b} {$dst|$dst}", []>;
1400 def SHL16r1 : I<0xD1, MRM4r, (ops GR16:$dst, GR16:$src1),
1401 "shl{w} {$dst|$dst}", []>, OpSize;
1402 def SHL32r1 : I<0xD1, MRM4r, (ops GR32:$dst, GR32:$src1),
1403 "shl{l} {$dst|$dst}", []>;
1405 let isTwoAddress = 0 in {
1406 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
1407 "shl{b} {%cl, $dst|$dst, %CL}",
1408 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1410 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
1411 "shl{w} {%cl, $dst|$dst, %CL}",
1412 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1413 Imp<[CL],[]>, OpSize;
1414 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
1415 "shl{l} {%cl, $dst|$dst, %CL}",
1416 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1418 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
1419 "shl{b} {$src, $dst|$dst, $src}",
1420 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1421 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
1422 "shl{w} {$src, $dst|$dst, $src}",
1423 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1425 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
1426 "shl{l} {$src, $dst|$dst, $src}",
1427 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1430 def SHL8m1 : I<0xD0, MRM4m, (ops i8mem :$dst),
1432 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1433 def SHL16m1 : I<0xD1, MRM4m, (ops i16mem:$dst),
1435 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1437 def SHL32m1 : I<0xD1, MRM4m, (ops i32mem:$dst),
1439 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1442 def SHR8rCL : I<0xD2, MRM5r, (ops GR8 :$dst, GR8 :$src),
1443 "shr{b} {%cl, $dst|$dst, %CL}",
1444 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
1445 def SHR16rCL : I<0xD3, MRM5r, (ops GR16:$dst, GR16:$src),
1446 "shr{w} {%cl, $dst|$dst, %CL}",
1447 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1448 def SHR32rCL : I<0xD3, MRM5r, (ops GR32:$dst, GR32:$src),
1449 "shr{l} {%cl, $dst|$dst, %CL}",
1450 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
1452 def SHR8ri : Ii8<0xC0, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1453 "shr{b} {$src2, $dst|$dst, $src2}",
1454 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1455 def SHR16ri : Ii8<0xC1, MRM5r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1456 "shr{w} {$src2, $dst|$dst, $src2}",
1457 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1458 def SHR32ri : Ii8<0xC1, MRM5r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1459 "shr{l} {$src2, $dst|$dst, $src2}",
1460 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1463 def SHR8r1 : I<0xD0, MRM5r, (ops GR8:$dst, GR8:$src1),
1465 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1466 def SHR16r1 : I<0xD1, MRM5r, (ops GR16:$dst, GR16:$src1),
1468 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1469 def SHR32r1 : I<0xD1, MRM5r, (ops GR32:$dst, GR32:$src1),
1471 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1473 let isTwoAddress = 0 in {
1474 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
1475 "shr{b} {%cl, $dst|$dst, %CL}",
1476 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1478 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
1479 "shr{w} {%cl, $dst|$dst, %CL}",
1480 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1481 Imp<[CL],[]>, OpSize;
1482 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
1483 "shr{l} {%cl, $dst|$dst, %CL}",
1484 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1486 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
1487 "shr{b} {$src, $dst|$dst, $src}",
1488 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1489 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
1490 "shr{w} {$src, $dst|$dst, $src}",
1491 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1493 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
1494 "shr{l} {$src, $dst|$dst, $src}",
1495 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1498 def SHR8m1 : I<0xD0, MRM5m, (ops i8mem :$dst),
1500 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1501 def SHR16m1 : I<0xD1, MRM5m, (ops i16mem:$dst),
1503 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1504 def SHR32m1 : I<0xD1, MRM5m, (ops i32mem:$dst),
1506 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1509 def SAR8rCL : I<0xD2, MRM7r, (ops GR8 :$dst, GR8 :$src),
1510 "sar{b} {%cl, $dst|$dst, %CL}",
1511 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
1512 def SAR16rCL : I<0xD3, MRM7r, (ops GR16:$dst, GR16:$src),
1513 "sar{w} {%cl, $dst|$dst, %CL}",
1514 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1515 def SAR32rCL : I<0xD3, MRM7r, (ops GR32:$dst, GR32:$src),
1516 "sar{l} {%cl, $dst|$dst, %CL}",
1517 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
1519 def SAR8ri : Ii8<0xC0, MRM7r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1520 "sar{b} {$src2, $dst|$dst, $src2}",
1521 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1522 def SAR16ri : Ii8<0xC1, MRM7r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1523 "sar{w} {$src2, $dst|$dst, $src2}",
1524 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1526 def SAR32ri : Ii8<0xC1, MRM7r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1527 "sar{l} {$src2, $dst|$dst, $src2}",
1528 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1531 def SAR8r1 : I<0xD0, MRM7r, (ops GR8 :$dst, GR8 :$src1),
1533 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1534 def SAR16r1 : I<0xD1, MRM7r, (ops GR16:$dst, GR16:$src1),
1536 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1537 def SAR32r1 : I<0xD1, MRM7r, (ops GR32:$dst, GR32:$src1),
1539 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1541 let isTwoAddress = 0 in {
1542 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
1543 "sar{b} {%cl, $dst|$dst, %CL}",
1544 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1546 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
1547 "sar{w} {%cl, $dst|$dst, %CL}",
1548 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1549 Imp<[CL],[]>, OpSize;
1550 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
1551 "sar{l} {%cl, $dst|$dst, %CL}",
1552 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1554 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
1555 "sar{b} {$src, $dst|$dst, $src}",
1556 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1557 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
1558 "sar{w} {$src, $dst|$dst, $src}",
1559 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1561 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
1562 "sar{l} {$src, $dst|$dst, $src}",
1563 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1566 def SAR8m1 : I<0xD0, MRM7m, (ops i8mem :$dst),
1568 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1569 def SAR16m1 : I<0xD1, MRM7m, (ops i16mem:$dst),
1571 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1573 def SAR32m1 : I<0xD1, MRM7m, (ops i32mem:$dst),
1575 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1578 // Rotate instructions
1579 // FIXME: provide shorter instructions when imm8 == 1
1580 def ROL8rCL : I<0xD2, MRM0r, (ops GR8 :$dst, GR8 :$src),
1581 "rol{b} {%cl, $dst|$dst, %CL}",
1582 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
1583 def ROL16rCL : I<0xD3, MRM0r, (ops GR16:$dst, GR16:$src),
1584 "rol{w} {%cl, $dst|$dst, %CL}",
1585 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1586 def ROL32rCL : I<0xD3, MRM0r, (ops GR32:$dst, GR32:$src),
1587 "rol{l} {%cl, $dst|$dst, %CL}",
1588 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
1590 def ROL8ri : Ii8<0xC0, MRM0r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1591 "rol{b} {$src2, $dst|$dst, $src2}",
1592 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1593 def ROL16ri : Ii8<0xC1, MRM0r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1594 "rol{w} {$src2, $dst|$dst, $src2}",
1595 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1596 def ROL32ri : Ii8<0xC1, MRM0r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1597 "rol{l} {$src2, $dst|$dst, $src2}",
1598 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1601 def ROL8r1 : I<0xD0, MRM0r, (ops GR8 :$dst, GR8 :$src1),
1603 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1604 def ROL16r1 : I<0xD1, MRM0r, (ops GR16:$dst, GR16:$src1),
1606 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1607 def ROL32r1 : I<0xD1, MRM0r, (ops GR32:$dst, GR32:$src1),
1609 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1611 let isTwoAddress = 0 in {
1612 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
1613 "rol{b} {%cl, $dst|$dst, %CL}",
1614 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1616 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
1617 "rol{w} {%cl, $dst|$dst, %CL}",
1618 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1619 Imp<[CL],[]>, OpSize;
1620 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
1621 "rol{l} {%cl, $dst|$dst, %CL}",
1622 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1624 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
1625 "rol{b} {$src, $dst|$dst, $src}",
1626 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1627 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
1628 "rol{w} {$src, $dst|$dst, $src}",
1629 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1631 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
1632 "rol{l} {$src, $dst|$dst, $src}",
1633 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1636 def ROL8m1 : I<0xD0, MRM0m, (ops i8mem :$dst),
1638 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1639 def ROL16m1 : I<0xD1, MRM0m, (ops i16mem:$dst),
1641 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1643 def ROL32m1 : I<0xD1, MRM0m, (ops i32mem:$dst),
1645 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1648 def ROR8rCL : I<0xD2, MRM1r, (ops GR8 :$dst, GR8 :$src),
1649 "ror{b} {%cl, $dst|$dst, %CL}",
1650 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
1651 def ROR16rCL : I<0xD3, MRM1r, (ops GR16:$dst, GR16:$src),
1652 "ror{w} {%cl, $dst|$dst, %CL}",
1653 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1654 def ROR32rCL : I<0xD3, MRM1r, (ops GR32:$dst, GR32:$src),
1655 "ror{l} {%cl, $dst|$dst, %CL}",
1656 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
1658 def ROR8ri : Ii8<0xC0, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
1659 "ror{b} {$src2, $dst|$dst, $src2}",
1660 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1661 def ROR16ri : Ii8<0xC1, MRM1r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
1662 "ror{w} {$src2, $dst|$dst, $src2}",
1663 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1664 def ROR32ri : Ii8<0xC1, MRM1r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
1665 "ror{l} {$src2, $dst|$dst, $src2}",
1666 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1669 def ROR8r1 : I<0xD0, MRM1r, (ops GR8 :$dst, GR8 :$src1),
1671 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1672 def ROR16r1 : I<0xD1, MRM1r, (ops GR16:$dst, GR16:$src1),
1674 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1675 def ROR32r1 : I<0xD1, MRM1r, (ops GR32:$dst, GR32:$src1),
1677 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1679 let isTwoAddress = 0 in {
1680 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
1681 "ror{b} {%cl, $dst|$dst, %CL}",
1682 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1684 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
1685 "ror{w} {%cl, $dst|$dst, %CL}",
1686 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1687 Imp<[CL],[]>, OpSize;
1688 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
1689 "ror{l} {%cl, $dst|$dst, %CL}",
1690 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1692 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
1693 "ror{b} {$src, $dst|$dst, $src}",
1694 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1695 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
1696 "ror{w} {$src, $dst|$dst, $src}",
1697 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1699 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
1700 "ror{l} {$src, $dst|$dst, $src}",
1701 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1704 def ROR8m1 : I<0xD0, MRM1m, (ops i8mem :$dst),
1706 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1707 def ROR16m1 : I<0xD1, MRM1m, (ops i16mem:$dst),
1709 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1711 def ROR32m1 : I<0xD1, MRM1m, (ops i32mem:$dst),
1713 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1718 // Double shift instructions (generalizations of rotate)
1719 def SHLD32rrCL : I<0xA5, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1720 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1721 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
1723 def SHRD32rrCL : I<0xAD, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1724 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1725 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
1727 def SHLD16rrCL : I<0xA5, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1728 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1729 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1730 Imp<[CL],[]>, TB, OpSize;
1731 def SHRD16rrCL : I<0xAD, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1732 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1733 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1734 Imp<[CL],[]>, TB, OpSize;
1736 let isCommutable = 1 in { // These instructions commute to each other.
1737 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1738 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
1739 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1740 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1743 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1744 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
1745 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1746 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1749 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1750 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
1751 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1752 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1755 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1756 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
1757 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1758 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1763 let isTwoAddress = 0 in {
1764 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1765 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1766 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1769 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1770 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1771 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1774 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1775 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
1776 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1777 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1778 (i8 imm:$src3)), addr:$dst)]>,
1780 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1781 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
1782 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1783 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1784 (i8 imm:$src3)), addr:$dst)]>,
1787 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1788 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1789 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1791 Imp<[CL],[]>, TB, OpSize;
1792 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1793 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1794 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1796 Imp<[CL],[]>, TB, OpSize;
1797 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1798 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
1799 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1800 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1801 (i8 imm:$src3)), addr:$dst)]>,
1803 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1804 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
1805 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1806 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1807 (i8 imm:$src3)), addr:$dst)]>,
1813 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1814 def ADD8rr : I<0x00, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1815 "add{b} {$src2, $dst|$dst, $src2}",
1816 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1817 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1818 def ADD16rr : I<0x01, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1819 "add{w} {$src2, $dst|$dst, $src2}",
1820 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1821 def ADD32rr : I<0x01, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1822 "add{l} {$src2, $dst|$dst, $src2}",
1823 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1824 } // end isConvertibleToThreeAddress
1825 } // end isCommutable
1826 def ADD8rm : I<0x02, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1827 "add{b} {$src2, $dst|$dst, $src2}",
1828 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1829 def ADD16rm : I<0x03, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1830 "add{w} {$src2, $dst|$dst, $src2}",
1831 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
1832 def ADD32rm : I<0x03, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1833 "add{l} {$src2, $dst|$dst, $src2}",
1834 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1836 def ADD8ri : Ii8<0x80, MRM0r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1837 "add{b} {$src2, $dst|$dst, $src2}",
1838 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1840 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1841 def ADD16ri : Ii16<0x81, MRM0r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1842 "add{w} {$src2, $dst|$dst, $src2}",
1843 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1844 def ADD32ri : Ii32<0x81, MRM0r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1845 "add{l} {$src2, $dst|$dst, $src2}",
1846 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
1847 def ADD16ri8 : Ii8<0x83, MRM0r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1848 "add{w} {$src2, $dst|$dst, $src2}",
1849 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
1851 def ADD32ri8 : Ii8<0x83, MRM0r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1852 "add{l} {$src2, $dst|$dst, $src2}",
1853 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1856 let isTwoAddress = 0 in {
1857 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
1858 "add{b} {$src2, $dst|$dst, $src2}",
1859 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1860 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1861 "add{w} {$src2, $dst|$dst, $src2}",
1862 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1864 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1865 "add{l} {$src2, $dst|$dst, $src2}",
1866 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
1867 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
1868 "add{b} {$src2, $dst|$dst, $src2}",
1869 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1870 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
1871 "add{w} {$src2, $dst|$dst, $src2}",
1872 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1874 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
1875 "add{l} {$src2, $dst|$dst, $src2}",
1876 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1877 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1878 "add{w} {$src2, $dst|$dst, $src2}",
1879 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1881 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1882 "add{l} {$src2, $dst|$dst, $src2}",
1883 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1886 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1887 def ADC32rr : I<0x11, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1888 "adc{l} {$src2, $dst|$dst, $src2}",
1889 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1891 def ADC32rm : I<0x13, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1892 "adc{l} {$src2, $dst|$dst, $src2}",
1893 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1894 def ADC32ri : Ii32<0x81, MRM2r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1895 "adc{l} {$src2, $dst|$dst, $src2}",
1896 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1897 def ADC32ri8 : Ii8<0x83, MRM2r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1898 "adc{l} {$src2, $dst|$dst, $src2}",
1899 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1901 let isTwoAddress = 0 in {
1902 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1903 "adc{l} {$src2, $dst|$dst, $src2}",
1904 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
1905 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
1906 "adc{l} {$src2, $dst|$dst, $src2}",
1907 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1908 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1909 "adc{l} {$src2, $dst|$dst, $src2}",
1910 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1913 def SUB8rr : I<0x28, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
1914 "sub{b} {$src2, $dst|$dst, $src2}",
1915 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1916 def SUB16rr : I<0x29, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
1917 "sub{w} {$src2, $dst|$dst, $src2}",
1918 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1919 def SUB32rr : I<0x29, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1920 "sub{l} {$src2, $dst|$dst, $src2}",
1921 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1922 def SUB8rm : I<0x2A, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
1923 "sub{b} {$src2, $dst|$dst, $src2}",
1924 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1925 def SUB16rm : I<0x2B, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
1926 "sub{w} {$src2, $dst|$dst, $src2}",
1927 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1928 def SUB32rm : I<0x2B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1929 "sub{l} {$src2, $dst|$dst, $src2}",
1930 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1932 def SUB8ri : Ii8 <0x80, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
1933 "sub{b} {$src2, $dst|$dst, $src2}",
1934 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1935 def SUB16ri : Ii16<0x81, MRM5r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
1936 "sub{w} {$src2, $dst|$dst, $src2}",
1937 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1938 def SUB32ri : Ii32<0x81, MRM5r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
1939 "sub{l} {$src2, $dst|$dst, $src2}",
1940 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1941 def SUB16ri8 : Ii8<0x83, MRM5r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
1942 "sub{w} {$src2, $dst|$dst, $src2}",
1943 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
1945 def SUB32ri8 : Ii8<0x83, MRM5r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
1946 "sub{l} {$src2, $dst|$dst, $src2}",
1947 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1948 let isTwoAddress = 0 in {
1949 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
1950 "sub{b} {$src2, $dst|$dst, $src2}",
1951 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
1952 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
1953 "sub{w} {$src2, $dst|$dst, $src2}",
1954 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
1956 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1957 "sub{l} {$src2, $dst|$dst, $src2}",
1958 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
1959 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
1960 "sub{b} {$src2, $dst|$dst, $src2}",
1961 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1962 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
1963 "sub{w} {$src2, $dst|$dst, $src2}",
1964 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1966 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
1967 "sub{l} {$src2, $dst|$dst, $src2}",
1968 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1969 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1970 "sub{w} {$src2, $dst|$dst, $src2}",
1971 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1973 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1974 "sub{l} {$src2, $dst|$dst, $src2}",
1975 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1978 def SBB32rr : I<0x19, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
1979 "sbb{l} {$src2, $dst|$dst, $src2}",
1980 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
1982 let isTwoAddress = 0 in {
1983 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
1984 "sbb{l} {$src2, $dst|$dst, $src2}",
1985 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
1986 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
1987 "sbb{b} {$src2, $dst|$dst, $src2}",
1988 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1989 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
1990 "sbb{l} {$src2, $dst|$dst, $src2}",
1991 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1992 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
1993 "sbb{l} {$src2, $dst|$dst, $src2}",
1994 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1996 def SBB32rm : I<0x1B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
1997 "sbb{l} {$src2, $dst|$dst, $src2}",
1998 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
1999 def SBB32ri : Ii32<0x81, MRM3r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
2000 "sbb{l} {$src2, $dst|$dst, $src2}",
2001 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2002 def SBB32ri8 : Ii8<0x83, MRM3r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
2003 "sbb{l} {$src2, $dst|$dst, $src2}",
2004 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2006 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2007 def IMUL16rr : I<0xAF, MRMSrcReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
2008 "imul{w} {$src2, $dst|$dst, $src2}",
2009 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2010 def IMUL32rr : I<0xAF, MRMSrcReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
2011 "imul{l} {$src2, $dst|$dst, $src2}",
2012 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2014 def IMUL16rm : I<0xAF, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
2015 "imul{w} {$src2, $dst|$dst, $src2}",
2016 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2018 def IMUL32rm : I<0xAF, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
2019 "imul{l} {$src2, $dst|$dst, $src2}",
2020 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
2022 } // end Two Address instructions
2024 // Suprisingly enough, these are not two address instructions!
2025 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2026 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
2027 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2028 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2029 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2030 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
2031 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2032 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2033 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2034 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
2035 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2036 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2038 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2039 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
2040 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2041 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2043 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2044 (ops GR16:$dst, i16mem:$src1, i16imm:$src2),
2045 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2046 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2048 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2049 (ops GR32:$dst, i32mem:$src1, i32imm:$src2),
2050 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2051 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2052 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2053 (ops GR16:$dst, i16mem:$src1, i16i8imm :$src2),
2054 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2055 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2057 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2058 (ops GR32:$dst, i32mem:$src1, i32i8imm: $src2),
2059 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2060 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2062 //===----------------------------------------------------------------------===//
2063 // Test instructions are just like AND, except they don't generate a result.
2065 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2066 def TEST8rr : I<0x84, MRMDestReg, (ops GR8:$src1, GR8:$src2),
2067 "test{b} {$src2, $src1|$src1, $src2}",
2068 [(X86test GR8:$src1, GR8:$src2)]>;
2069 def TEST16rr : I<0x85, MRMDestReg, (ops GR16:$src1, GR16:$src2),
2070 "test{w} {$src2, $src1|$src1, $src2}",
2071 [(X86test GR16:$src1, GR16:$src2)]>, OpSize;
2072 def TEST32rr : I<0x85, MRMDestReg, (ops GR32:$src1, GR32:$src2),
2073 "test{l} {$src2, $src1|$src1, $src2}",
2074 [(X86test GR32:$src1, GR32:$src2)]>;
2076 def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, GR8 :$src2),
2077 "test{b} {$src2, $src1|$src1, $src2}",
2078 [(X86test (loadi8 addr:$src1), GR8:$src2)]>;
2079 def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, GR16:$src2),
2080 "test{w} {$src2, $src1|$src1, $src2}",
2081 [(X86test (loadi16 addr:$src1), GR16:$src2)]>,
2083 def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, GR32:$src2),
2084 "test{l} {$src2, $src1|$src1, $src2}",
2085 [(X86test (loadi32 addr:$src1), GR32:$src2)]>;
2086 def TEST8rm : I<0x84, MRMSrcMem, (ops GR8 :$src1, i8mem :$src2),
2087 "test{b} {$src2, $src1|$src1, $src2}",
2088 [(X86test GR8:$src1, (loadi8 addr:$src2))]>;
2089 def TEST16rm : I<0x85, MRMSrcMem, (ops GR16:$src1, i16mem:$src2),
2090 "test{w} {$src2, $src1|$src1, $src2}",
2091 [(X86test GR16:$src1, (loadi16 addr:$src2))]>,
2093 def TEST32rm : I<0x85, MRMSrcMem, (ops GR32:$src1, i32mem:$src2),
2094 "test{l} {$src2, $src1|$src1, $src2}",
2095 [(X86test GR32:$src1, (loadi32 addr:$src2))]>;
2097 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2098 (ops GR8:$src1, i8imm:$src2),
2099 "test{b} {$src2, $src1|$src1, $src2}",
2100 [(X86test GR8:$src1, imm:$src2)]>;
2101 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2102 (ops GR16:$src1, i16imm:$src2),
2103 "test{w} {$src2, $src1|$src1, $src2}",
2104 [(X86test GR16:$src1, imm:$src2)]>, OpSize;
2105 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2106 (ops GR32:$src1, i32imm:$src2),
2107 "test{l} {$src2, $src1|$src1, $src2}",
2108 [(X86test GR32:$src1, imm:$src2)]>;
2109 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2110 (ops i8mem:$src1, i8imm:$src2),
2111 "test{b} {$src2, $src1|$src1, $src2}",
2112 [(X86test (loadi8 addr:$src1), imm:$src2)]>;
2113 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2114 (ops i16mem:$src1, i16imm:$src2),
2115 "test{w} {$src2, $src1|$src1, $src2}",
2116 [(X86test (loadi16 addr:$src1), imm:$src2)]>,
2118 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2119 (ops i32mem:$src1, i32imm:$src2),
2120 "test{l} {$src2, $src1|$src1, $src2}",
2121 [(X86test (loadi32 addr:$src1), imm:$src2)]>;
2124 // Condition code ops, incl. set if equal/not equal/...
2125 def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2126 def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
2128 def SETEr : I<0x94, MRM0r,
2131 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2133 def SETEm : I<0x94, MRM0m,
2136 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2138 def SETNEr : I<0x95, MRM0r,
2141 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2143 def SETNEm : I<0x95, MRM0m,
2146 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2148 def SETLr : I<0x9C, MRM0r,
2151 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2152 TB; // GR8 = < signed
2153 def SETLm : I<0x9C, MRM0m,
2156 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2157 TB; // [mem8] = < signed
2158 def SETGEr : I<0x9D, MRM0r,
2161 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2162 TB; // GR8 = >= signed
2163 def SETGEm : I<0x9D, MRM0m,
2166 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2167 TB; // [mem8] = >= signed
2168 def SETLEr : I<0x9E, MRM0r,
2171 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2172 TB; // GR8 = <= signed
2173 def SETLEm : I<0x9E, MRM0m,
2176 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2177 TB; // [mem8] = <= signed
2178 def SETGr : I<0x9F, MRM0r,
2181 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2182 TB; // GR8 = > signed
2183 def SETGm : I<0x9F, MRM0m,
2186 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2187 TB; // [mem8] = > signed
2189 def SETBr : I<0x92, MRM0r,
2192 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2193 TB; // GR8 = < unsign
2194 def SETBm : I<0x92, MRM0m,
2197 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2198 TB; // [mem8] = < unsign
2199 def SETAEr : I<0x93, MRM0r,
2202 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2203 TB; // GR8 = >= unsign
2204 def SETAEm : I<0x93, MRM0m,
2207 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2208 TB; // [mem8] = >= unsign
2209 def SETBEr : I<0x96, MRM0r,
2212 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2213 TB; // GR8 = <= unsign
2214 def SETBEm : I<0x96, MRM0m,
2217 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2218 TB; // [mem8] = <= unsign
2219 def SETAr : I<0x97, MRM0r,
2222 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2223 TB; // GR8 = > signed
2224 def SETAm : I<0x97, MRM0m,
2227 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2228 TB; // [mem8] = > signed
2230 def SETSr : I<0x98, MRM0r,
2233 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2234 TB; // GR8 = <sign bit>
2235 def SETSm : I<0x98, MRM0m,
2238 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2239 TB; // [mem8] = <sign bit>
2240 def SETNSr : I<0x99, MRM0r,
2243 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2244 TB; // GR8 = !<sign bit>
2245 def SETNSm : I<0x99, MRM0m,
2248 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2249 TB; // [mem8] = !<sign bit>
2250 def SETPr : I<0x9A, MRM0r,
2253 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2255 def SETPm : I<0x9A, MRM0m,
2258 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2259 TB; // [mem8] = parity
2260 def SETNPr : I<0x9B, MRM0r,
2263 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2264 TB; // GR8 = not parity
2265 def SETNPm : I<0x9B, MRM0m,
2268 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2269 TB; // [mem8] = not parity
2271 // Integer comparisons
2272 def CMP8rr : I<0x38, MRMDestReg,
2273 (ops GR8 :$src1, GR8 :$src2),
2274 "cmp{b} {$src2, $src1|$src1, $src2}",
2275 [(X86cmp GR8:$src1, GR8:$src2)]>;
2276 def CMP16rr : I<0x39, MRMDestReg,
2277 (ops GR16:$src1, GR16:$src2),
2278 "cmp{w} {$src2, $src1|$src1, $src2}",
2279 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
2280 def CMP32rr : I<0x39, MRMDestReg,
2281 (ops GR32:$src1, GR32:$src2),
2282 "cmp{l} {$src2, $src1|$src1, $src2}",
2283 [(X86cmp GR32:$src1, GR32:$src2)]>;
2284 def CMP8mr : I<0x38, MRMDestMem,
2285 (ops i8mem :$src1, GR8 :$src2),
2286 "cmp{b} {$src2, $src1|$src1, $src2}",
2287 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
2288 def CMP16mr : I<0x39, MRMDestMem,
2289 (ops i16mem:$src1, GR16:$src2),
2290 "cmp{w} {$src2, $src1|$src1, $src2}",
2291 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
2292 def CMP32mr : I<0x39, MRMDestMem,
2293 (ops i32mem:$src1, GR32:$src2),
2294 "cmp{l} {$src2, $src1|$src1, $src2}",
2295 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
2296 def CMP8rm : I<0x3A, MRMSrcMem,
2297 (ops GR8 :$src1, i8mem :$src2),
2298 "cmp{b} {$src2, $src1|$src1, $src2}",
2299 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
2300 def CMP16rm : I<0x3B, MRMSrcMem,
2301 (ops GR16:$src1, i16mem:$src2),
2302 "cmp{w} {$src2, $src1|$src1, $src2}",
2303 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
2304 def CMP32rm : I<0x3B, MRMSrcMem,
2305 (ops GR32:$src1, i32mem:$src2),
2306 "cmp{l} {$src2, $src1|$src1, $src2}",
2307 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
2308 def CMP8ri : Ii8<0x80, MRM7r,
2309 (ops GR8:$src1, i8imm:$src2),
2310 "cmp{b} {$src2, $src1|$src1, $src2}",
2311 [(X86cmp GR8:$src1, imm:$src2)]>;
2312 def CMP16ri : Ii16<0x81, MRM7r,
2313 (ops GR16:$src1, i16imm:$src2),
2314 "cmp{w} {$src2, $src1|$src1, $src2}",
2315 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
2316 def CMP32ri : Ii32<0x81, MRM7r,
2317 (ops GR32:$src1, i32imm:$src2),
2318 "cmp{l} {$src2, $src1|$src1, $src2}",
2319 [(X86cmp GR32:$src1, imm:$src2)]>;
2320 def CMP8mi : Ii8 <0x80, MRM7m,
2321 (ops i8mem :$src1, i8imm :$src2),
2322 "cmp{b} {$src2, $src1|$src1, $src2}",
2323 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2324 def CMP16mi : Ii16<0x81, MRM7m,
2325 (ops i16mem:$src1, i16imm:$src2),
2326 "cmp{w} {$src2, $src1|$src1, $src2}",
2327 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2328 def CMP32mi : Ii32<0x81, MRM7m,
2329 (ops i32mem:$src1, i32imm:$src2),
2330 "cmp{l} {$src2, $src1|$src1, $src2}",
2331 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2332 def CMP16ri8 : Ii8<0x83, MRM7r,
2333 (ops GR16:$src1, i16i8imm:$src2),
2334 "cmp{w} {$src2, $src1|$src1, $src2}",
2335 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
2336 def CMP16mi8 : Ii8<0x83, MRM7m,
2337 (ops i16mem:$src1, i16i8imm:$src2),
2338 "cmp{w} {$src2, $src1|$src1, $src2}",
2339 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
2340 def CMP32mi8 : Ii8<0x83, MRM7m,
2341 (ops i32mem:$src1, i32i8imm:$src2),
2342 "cmp{l} {$src2, $src1|$src1, $src2}",
2343 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
2344 def CMP32ri8 : Ii8<0x83, MRM7r,
2345 (ops GR32:$src1, i32i8imm:$src2),
2346 "cmp{l} {$src2, $src1|$src1, $src2}",
2347 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
2349 // Sign/Zero extenders
2350 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
2351 "movs{bw|x} {$src, $dst|$dst, $src}",
2352 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
2353 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
2354 "movs{bw|x} {$src, $dst|$dst, $src}",
2355 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2356 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
2357 "movs{bl|x} {$src, $dst|$dst, $src}",
2358 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2359 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
2360 "movs{bl|x} {$src, $dst|$dst, $src}",
2361 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2362 def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops GR32:$dst, GR16:$src),
2363 "movs{wl|x} {$src, $dst|$dst, $src}",
2364 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2365 def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
2366 "movs{wl|x} {$src, $dst|$dst, $src}",
2367 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2369 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
2370 "movz{bw|x} {$src, $dst|$dst, $src}",
2371 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
2372 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
2373 "movz{bw|x} {$src, $dst|$dst, $src}",
2374 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2375 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
2376 "movz{bl|x} {$src, $dst|$dst, $src}",
2377 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2378 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
2379 "movz{bl|x} {$src, $dst|$dst, $src}",
2380 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2381 def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops GR32:$dst, GR16:$src),
2382 "movz{wl|x} {$src, $dst|$dst, $src}",
2383 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2384 def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
2385 "movz{wl|x} {$src, $dst|$dst, $src}",
2386 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2388 def CBW : I<0x98, RawFrm, (ops),
2389 "{cbtw|cbw}", []>, Imp<[AL],[AX]>; // AX = signext(AL)
2390 def CWDE : I<0x98, RawFrm, (ops),
2391 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2393 def CWD : I<0x99, RawFrm, (ops),
2394 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>; // DX:AX = signext(AX)
2395 def CDQ : I<0x99, RawFrm, (ops),
2396 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2398 //===----------------------------------------------------------------------===//
2399 // Miscellaneous Instructions
2400 //===----------------------------------------------------------------------===//
2402 def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
2403 TB, Imp<[],[EAX,EDX]>;
2405 //===----------------------------------------------------------------------===//
2406 // Alias Instructions
2407 //===----------------------------------------------------------------------===//
2409 // Alias instructions that map movr0 to xor.
2410 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2411 def MOV8r0 : I<0x30, MRMInitReg, (ops GR8 :$dst),
2412 "xor{b} $dst, $dst",
2413 [(set GR8:$dst, 0)]>;
2414 def MOV16r0 : I<0x31, MRMInitReg, (ops GR16:$dst),
2415 "xor{w} $dst, $dst",
2416 [(set GR16:$dst, 0)]>, OpSize;
2417 def MOV32r0 : I<0x31, MRMInitReg, (ops GR32:$dst),
2418 "xor{l} $dst, $dst",
2419 [(set GR32:$dst, 0)]>;
2421 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2422 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2423 def MOV16to16_ : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16:$src),
2424 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2425 def MOV32to32_ : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32:$src),
2426 "mov{l} {$src, $dst|$dst, $src}", []>;
2428 def MOV16_rr : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16_:$src),
2429 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2430 def MOV32_rr : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32_:$src),
2431 "mov{l} {$src, $dst|$dst, $src}", []>;
2432 def MOV16_rm : I<0x8B, MRMSrcMem, (ops GR16_:$dst, i16mem:$src),
2433 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2434 def MOV32_rm : I<0x8B, MRMSrcMem, (ops GR32_:$dst, i32mem:$src),
2435 "mov{l} {$src, $dst|$dst, $src}", []>;
2436 def MOV16_mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16_:$src),
2437 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
2438 def MOV32_mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32_:$src),
2439 "mov{l} {$src, $dst|$dst, $src}", []>;
2441 //===----------------------------------------------------------------------===//
2442 // DWARF Pseudo Instructions
2445 def DWARF_LOC : I<0, Pseudo, (ops i32imm:$line, i32imm:$col, i32imm:$file),
2446 "; .loc $file, $line, $col",
2447 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2450 def DWARF_LABEL : I<0, Pseudo, (ops i32imm:$id),
2451 "\nLdebug_loc${id:debug}:",
2452 [(dwarf_label (i32 imm:$id))]>;
2454 //===----------------------------------------------------------------------===//
2455 // Non-Instruction Patterns
2456 //===----------------------------------------------------------------------===//
2458 // ConstantPool GlobalAddress, ExternalSymbol
2459 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2460 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2461 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2462 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2464 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2465 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2466 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2467 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2468 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2469 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2470 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2471 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2473 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2474 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2475 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2476 (MOV32mi addr:$dst, texternalsym:$src)>;
2479 def : Pat<(X86tailcall GR32:$dst),
2480 (CALL32r GR32:$dst)>;
2482 def : Pat<(X86tailcall tglobaladdr:$dst),
2483 (CALLpcrel32 tglobaladdr:$dst)>;
2484 def : Pat<(X86tailcall texternalsym:$dst),
2485 (CALLpcrel32 texternalsym:$dst)>;
2489 def : Pat<(X86call tglobaladdr:$dst),
2490 (CALLpcrel32 tglobaladdr:$dst)>;
2491 def : Pat<(X86call texternalsym:$dst),
2492 (CALLpcrel32 texternalsym:$dst)>;
2494 // X86 specific add which produces a flag.
2495 def : Pat<(addc GR32:$src1, GR32:$src2),
2496 (ADD32rr GR32:$src1, GR32:$src2)>;
2497 def : Pat<(addc GR32:$src1, (load addr:$src2)),
2498 (ADD32rm GR32:$src1, addr:$src2)>;
2499 def : Pat<(addc GR32:$src1, imm:$src2),
2500 (ADD32ri GR32:$src1, imm:$src2)>;
2501 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2502 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2504 def : Pat<(subc GR32:$src1, GR32:$src2),
2505 (SUB32rr GR32:$src1, GR32:$src2)>;
2506 def : Pat<(subc GR32:$src1, (load addr:$src2)),
2507 (SUB32rm GR32:$src1, addr:$src2)>;
2508 def : Pat<(subc GR32:$src1, imm:$src2),
2509 (SUB32ri GR32:$src1, imm:$src2)>;
2510 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2511 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2513 def : Pat<(truncstore (i8 imm:$src), addr:$dst, i1),
2514 (MOV8mi addr:$dst, imm:$src)>;
2515 def : Pat<(truncstore GR8:$src, addr:$dst, i1),
2516 (MOV8mr addr:$dst, GR8:$src)>;
2518 // {s|z}extload bool -> {s|z}extload byte
2519 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2520 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2521 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2522 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2523 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2525 // extload bool -> extload byte
2526 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2527 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2528 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2529 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2530 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2531 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2534 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2535 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2536 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2537 def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2538 def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2539 def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2541 //===----------------------------------------------------------------------===//
2543 //===----------------------------------------------------------------------===//
2545 // (shl x, 1) ==> (add x, x)
2546 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2547 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2548 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2550 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2551 def : Pat<(or (srl GR32:$src1, CL:$amt),
2552 (shl GR32:$src2, (sub 32, CL:$amt))),
2553 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2555 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2556 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2557 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2559 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2560 def : Pat<(or (shl GR32:$src1, CL:$amt),
2561 (srl GR32:$src2, (sub 32, CL:$amt))),
2562 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2564 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2565 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2566 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2568 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2569 def : Pat<(or (srl GR16:$src1, CL:$amt),
2570 (shl GR16:$src2, (sub 16, CL:$amt))),
2571 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2573 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2574 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2575 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2577 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2578 def : Pat<(or (shl GR16:$src1, CL:$amt),
2579 (srl GR16:$src2, (sub 16, CL:$amt))),
2580 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2582 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2583 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2584 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2587 //===----------------------------------------------------------------------===//
2588 // Floating Point Stack Support
2589 //===----------------------------------------------------------------------===//
2591 include "X86InstrFPStack.td"
2593 //===----------------------------------------------------------------------===//
2594 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2595 //===----------------------------------------------------------------------===//
2597 include "X86InstrMMX.td"
2599 //===----------------------------------------------------------------------===//
2600 // XMM Floating point support (requires SSE / SSE2)
2601 //===----------------------------------------------------------------------===//
2603 include "X86InstrSSE.td"