1 //===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86 instruction set, defining the instructions, and
11 // properties of the instructions which are needed for code generation, machine
12 // code emission, and analysis.
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
17 // X86 specific DAG Nodes.
20 def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
24 def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
26 def SDTX86Cmov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
30 def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
33 def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
36 def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
38 def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39 def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
42 def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
44 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
46 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
48 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
50 def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
52 def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
54 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
56 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
57 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
59 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
60 [SDNPHasChain, SDNPOutFlag]>;
62 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
63 [SDNPInFlag, SDNPOutFlag]>;
64 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
65 [SDNPHasChain, SDNPInFlag]>;
66 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
67 [SDNPInFlag, SDNPOutFlag]>;
69 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
70 [SDNPHasChain, SDNPOptInFlag]>;
72 def X86callseq_start :
73 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
74 [SDNPHasChain, SDNPOutFlag]>;
76 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
77 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
79 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
80 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
82 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
83 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
85 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
86 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
87 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
90 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
91 [SDNPHasChain, SDNPOutFlag]>;
93 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
94 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
96 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
97 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
98 def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
100 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
104 //===----------------------------------------------------------------------===//
105 // X86 Operand Definitions.
108 // *mem - Operand definitions for the funky X86 addressing mode operands.
110 class X86MemOperand<string printMethod> : Operand<iPTR> {
111 let PrintMethod = printMethod;
112 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
115 def i8mem : X86MemOperand<"printi8mem">;
116 def i16mem : X86MemOperand<"printi16mem">;
117 def i32mem : X86MemOperand<"printi32mem">;
118 def i64mem : X86MemOperand<"printi64mem">;
119 def i128mem : X86MemOperand<"printi128mem">;
120 def f32mem : X86MemOperand<"printf32mem">;
121 def f64mem : X86MemOperand<"printf64mem">;
122 def f80mem : X86MemOperand<"printf80mem">;
123 def f128mem : X86MemOperand<"printf128mem">;
125 def lea32mem : Operand<i32> {
126 let PrintMethod = "printi32mem";
127 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
130 def SSECC : Operand<i8> {
131 let PrintMethod = "printSSECC";
134 def piclabel: Operand<i32> {
135 let PrintMethod = "printPICLabel";
138 // A couple of more descriptive operand definitions.
139 // 16-bits but only 8 bits are significant.
140 def i16i8imm : Operand<i16>;
141 // 32-bits but only 8 bits are significant.
142 def i32i8imm : Operand<i32>;
144 // Branch targets have OtherVT type.
145 def brtarget : Operand<OtherVT>;
147 //===----------------------------------------------------------------------===//
148 // X86 Complex Pattern Definitions.
151 // Define X86 specific addressing mode.
152 def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
153 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
154 [add, mul, shl, or, frameindex], []>;
156 //===----------------------------------------------------------------------===//
157 // X86 Instruction Predicate Definitions.
158 def HasMMX : Predicate<"Subtarget->hasMMX()">;
159 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
160 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
161 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
162 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
163 def FPStack : Predicate<"!Subtarget->hasSSE2()">;
164 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
165 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
166 def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
167 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
168 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
169 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
171 //===----------------------------------------------------------------------===//
172 // X86 Instruction Format Definitions.
175 include "X86InstrFormats.td"
177 //===----------------------------------------------------------------------===//
178 // Pattern fragments...
181 // X86 specific condition code. These correspond to CondCode in
182 // X86InstrInfo.h. They must be kept in synch.
183 def X86_COND_A : PatLeaf<(i8 0)>;
184 def X86_COND_AE : PatLeaf<(i8 1)>;
185 def X86_COND_B : PatLeaf<(i8 2)>;
186 def X86_COND_BE : PatLeaf<(i8 3)>;
187 def X86_COND_E : PatLeaf<(i8 4)>;
188 def X86_COND_G : PatLeaf<(i8 5)>;
189 def X86_COND_GE : PatLeaf<(i8 6)>;
190 def X86_COND_L : PatLeaf<(i8 7)>;
191 def X86_COND_LE : PatLeaf<(i8 8)>;
192 def X86_COND_NE : PatLeaf<(i8 9)>;
193 def X86_COND_NO : PatLeaf<(i8 10)>;
194 def X86_COND_NP : PatLeaf<(i8 11)>;
195 def X86_COND_NS : PatLeaf<(i8 12)>;
196 def X86_COND_O : PatLeaf<(i8 13)>;
197 def X86_COND_P : PatLeaf<(i8 14)>;
198 def X86_COND_S : PatLeaf<(i8 15)>;
200 def i16immSExt8 : PatLeaf<(i16 imm), [{
201 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
202 // sign extended field.
203 return (int16_t)N->getValue() == (int8_t)N->getValue();
206 def i32immSExt8 : PatLeaf<(i32 imm), [{
207 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
208 // sign extended field.
209 return (int32_t)N->getValue() == (int8_t)N->getValue();
212 // Helper fragments for loads.
213 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
214 def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
215 def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
216 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
218 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
219 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
220 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
222 def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
223 def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
224 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
225 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
226 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
228 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
229 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
230 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
231 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
232 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
233 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
235 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
236 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
237 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
238 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
239 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
240 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
242 //===----------------------------------------------------------------------===//
243 // Instruction list...
246 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
247 // a stack adjustment and the codegen must know that they may modify the stack
248 // pointer before prolog-epilog rewriting occurs.
249 let Defs = [ESP], Uses = [ESP] in {
250 def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt), "#ADJCALLSTACKDOWN",
251 [(X86callseq_start imm:$amt)]>;
252 def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
254 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
256 def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
257 "#IMPLICIT_USE", []>;
258 def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
259 "#IMPLICIT_DEF", []>;
260 def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
261 "#IMPLICIT_DEF $dst",
262 [(set GR8:$dst, (undef))]>;
263 def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
264 "#IMPLICIT_DEF $dst",
265 [(set GR16:$dst, (undef))]>;
266 def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
267 "#IMPLICIT_DEF $dst",
268 [(set GR32:$dst, (undef))]>;
271 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
274 //===----------------------------------------------------------------------===//
275 // Control Flow Instructions...
278 // Return instructions.
279 let isTerminator = 1, isReturn = 1, isBarrier = 1,
281 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
282 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
283 [(X86retflag imm:$amt)]>;
286 // All branches are RawFrm, Void, Branch, and Terminators
287 let isBranch = 1, isTerminator = 1 in
288 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
289 I<opcode, RawFrm, (outs), ins, asm, pattern>;
292 let isBranch = 1, isBarrier = 1 in
293 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
295 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
296 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
297 [(brind GR32:$dst)]>;
298 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
299 [(brind (loadi32 addr:$dst))]>;
302 // Conditional branches
303 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
304 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
305 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
306 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
307 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
308 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
309 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
310 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
311 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
312 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
313 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
314 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
316 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
317 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
318 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
319 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
320 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
321 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
322 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
323 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
325 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
326 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
327 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
328 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
329 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
330 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
331 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
332 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
333 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
334 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
335 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
336 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
338 //===----------------------------------------------------------------------===//
339 // Call Instructions...
342 // All calls clobber the non-callee saved registers...
343 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
344 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
345 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
346 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
347 "call\t${dst:call}", []>;
348 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
349 "call\t{*}$dst", [(X86call GR32:$dst)]>;
350 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
351 "call\t{*}$dst", []>;
355 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
356 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAIL CALL",
358 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
359 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp\t{*}$dst # TAIL CALL",
361 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
362 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
363 "jmp\t{*}$dst # TAIL CALL", []>;
365 //===----------------------------------------------------------------------===//
366 // Miscellaneous Instructions...
368 let Defs = [EBP, ESP], Uses = [EBP, ESP] in
369 def LEAVE : I<0xC9, RawFrm,
370 (outs), (ins), "leave", []>;
372 let Defs = [ESP], Uses = [ESP] in {
373 def POP32r : I<0x58, AddRegFrm,
374 (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
376 def PUSH32r : I<0x50, AddRegFrm,
377 (outs), (ins GR32:$reg), "push{l}\t$reg", []>;
380 def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
383 let isTwoAddress = 1 in // GR32 = bswap GR32
384 def BSWAP32r : I<0xC8, AddRegFrm,
385 (outs GR32:$dst), (ins GR32:$src),
387 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
389 // FIXME: Model xchg* as two address instructions?
390 def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
391 (outs), (ins GR8:$src1, GR8:$src2),
392 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
393 def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
394 (outs), (ins GR16:$src1, GR16:$src2),
395 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
396 def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
397 (outs), (ins GR32:$src1, GR32:$src2),
398 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
400 def XCHG8mr : I<0x86, MRMDestMem,
401 (outs), (ins i8mem:$src1, GR8:$src2),
402 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
403 def XCHG16mr : I<0x87, MRMDestMem,
404 (outs), (ins i16mem:$src1, GR16:$src2),
405 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
406 def XCHG32mr : I<0x87, MRMDestMem,
407 (outs), (ins i32mem:$src1, GR32:$src2),
408 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
409 def XCHG8rm : I<0x86, MRMSrcMem,
410 (outs), (ins GR8:$src1, i8mem:$src2),
411 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
412 def XCHG16rm : I<0x87, MRMSrcMem,
413 (outs), (ins GR16:$src1, i16mem:$src2),
414 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
415 def XCHG32rm : I<0x87, MRMSrcMem,
416 (outs), (ins GR32:$src1, i32mem:$src2),
417 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
419 def LEA16r : I<0x8D, MRMSrcMem,
420 (outs GR16:$dst), (ins i32mem:$src),
421 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
422 def LEA32r : I<0x8D, MRMSrcMem,
423 (outs GR32:$dst), (ins lea32mem:$src),
424 "lea{l}\t{$src|$dst}, {$dst|$src}",
425 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
427 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
428 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
429 [(X86rep_movs i8)]>, REP;
430 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
431 [(X86rep_movs i16)]>, REP, OpSize;
432 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
433 [(X86rep_movs i32)]>, REP;
436 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
437 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
438 [(X86rep_stos i8)]>, REP;
439 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
440 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
441 [(X86rep_stos i16)]>, REP, OpSize;
442 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
443 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
444 [(X86rep_stos i32)]>, REP;
446 let Defs = [RAX, RDX] in
447 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
450 //===----------------------------------------------------------------------===//
451 // Input/Output Instructions...
453 let Defs = [AL], Uses = [DX] in
454 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
455 "in{b}\t{%dx, %al|%AL, %DX}", []>;
456 let Defs = [AX], Uses = [DX] in
457 def IN16rr : I<0xED, RawFrm, (outs), (ins),
458 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
459 let Defs = [EAX], Uses = [DX] in
460 def IN32rr : I<0xED, RawFrm, (outs), (ins),
461 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
464 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
465 "in{b}\t{$port, %al|%AL, $port}", []>;
467 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
468 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
470 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
471 "in{l}\t{$port, %eax|%EAX, $port}", []>;
473 let Uses = [DX, AL] in
474 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
475 "out{b}\t{%al, %dx|%DX, %AL}", []>;
476 let Uses = [DX, AX] in
477 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
478 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
479 let Uses = [DX, EAX] in
480 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
481 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
484 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
485 "out{b}\t{%al, $port|$port, %AL}", []>;
487 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
488 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
490 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
491 "out{l}\t{%eax, $port|$port, %EAX}", []>;
493 //===----------------------------------------------------------------------===//
494 // Move Instructions...
496 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
497 "mov{b}\t{$src, $dst|$dst, $src}", []>;
498 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
499 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
500 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
501 "mov{l}\t{$src, $dst|$dst, $src}", []>;
502 let isReMaterializable = 1 in {
503 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
504 "mov{b}\t{$src, $dst|$dst, $src}",
505 [(set GR8:$dst, imm:$src)]>;
506 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
507 "mov{w}\t{$src, $dst|$dst, $src}",
508 [(set GR16:$dst, imm:$src)]>, OpSize;
509 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
510 "mov{l}\t{$src, $dst|$dst, $src}",
511 [(set GR32:$dst, imm:$src)]>;
513 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
514 "mov{b}\t{$src, $dst|$dst, $src}",
515 [(store (i8 imm:$src), addr:$dst)]>;
516 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
517 "mov{w}\t{$src, $dst|$dst, $src}",
518 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
519 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
520 "mov{l}\t{$src, $dst|$dst, $src}",
521 [(store (i32 imm:$src), addr:$dst)]>;
524 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
525 "mov{b}\t{$src, $dst|$dst, $src}",
526 [(set GR8:$dst, (load addr:$src))]>;
527 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
528 "mov{w}\t{$src, $dst|$dst, $src}",
529 [(set GR16:$dst, (load addr:$src))]>, OpSize;
530 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
531 "mov{l}\t{$src, $dst|$dst, $src}",
532 [(set GR32:$dst, (load addr:$src))]>;
535 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
536 "mov{b}\t{$src, $dst|$dst, $src}",
537 [(store GR8:$src, addr:$dst)]>;
538 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
539 "mov{w}\t{$src, $dst|$dst, $src}",
540 [(store GR16:$src, addr:$dst)]>, OpSize;
541 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
542 "mov{l}\t{$src, $dst|$dst, $src}",
543 [(store GR32:$src, addr:$dst)]>;
545 //===----------------------------------------------------------------------===//
546 // Fixed-Register Multiplication and Division Instructions...
549 // Extra precision multiplication
550 let Defs = [AL,AH], Uses = [AL] in
551 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
552 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
553 // This probably ought to be moved to a def : Pat<> if the
554 // syntax can be accepted.
555 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
556 let Defs = [AX,DX], Uses = [AX] in
557 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
558 OpSize; // AX,DX = AX*GR16
559 let Defs = [EAX,EDX], Uses = [EAX] in
560 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
561 // EAX,EDX = EAX*GR32
562 let Defs = [AL,AH], Uses = [AL] in
563 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
565 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
566 // This probably ought to be moved to a def : Pat<> if the
567 // syntax can be accepted.
568 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
569 let Defs = [AX,DX], Uses = [AX] in
570 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
571 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
572 let Defs = [EAX,EDX], Uses = [EAX] in
573 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
574 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
576 let Defs = [AL,AH], Uses = [AL] in
577 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
579 let Defs = [AX,DX], Uses = [AX] in
580 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
581 OpSize; // AX,DX = AX*GR16
582 let Defs = [EAX,EDX], Uses = [EAX] in
583 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
584 // EAX,EDX = EAX*GR32
585 let Defs = [AL,AH], Uses = [AL] in
586 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
587 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
588 let Defs = [AX,DX], Uses = [AX] in
589 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
590 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
591 let Defs = [EAX,EDX], Uses = [EAX] in
592 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
593 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
595 // unsigned division/remainder
596 let Defs = [AX], Uses = [AL,AH] in
597 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
599 let Defs = [AX,DX], Uses = [AX,DX] in
600 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
601 "div{w}\t$src", []>, OpSize;
602 let Defs = [EAX,EDX], Uses = [EAX,EDX] in
603 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
605 let Defs = [AX], Uses = [AL,AH] in
606 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
608 let Defs = [AX,DX], Uses = [AX,DX] in
609 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
610 "div{w}\t$src", []>, OpSize;
611 let Defs = [EAX,EDX], Uses = [EAX,EDX] in
612 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
615 // Signed division/remainder.
616 let Defs = [AX], Uses = [AL,AH] in
617 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
618 "idiv{b}\t$src", []>;
619 let Defs = [AX,DX], Uses = [AX,DX] in
620 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
621 "idiv{w}\t$src", []>, OpSize;
622 let Defs = [EAX,EDX], Uses = [EAX,EDX] in
623 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
624 "idiv{l}\t$src", []>;
625 let Defs = [AX], Uses = [AL,AH] in
626 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
627 "idiv{b}\t$src", []>;
628 let Defs = [AX,DX], Uses = [AX,DX] in
629 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
630 "idiv{w}\t$src", []>, OpSize;
631 let Defs = [EAX,EDX], Uses = [EAX,EDX] in
632 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
633 "idiv{l}\t$src", []>;
636 //===----------------------------------------------------------------------===//
637 // Two address Instructions...
639 let isTwoAddress = 1 in {
642 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
643 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
644 "cmovb\t{$src2, $dst|$dst, $src2}",
645 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
648 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
649 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
650 "cmovb\t{$src2, $dst|$dst, $src2}",
651 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
654 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
655 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
656 "cmovb\t{$src2, $dst|$dst, $src2}",
657 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
660 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
661 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
662 "cmovb\t{$src2, $dst|$dst, $src2}",
663 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
667 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
668 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
669 "cmovae\t{$src2, $dst|$dst, $src2}",
670 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
673 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
674 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
675 "cmovae\t{$src2, $dst|$dst, $src2}",
676 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
679 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
680 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
681 "cmovae\t{$src2, $dst|$dst, $src2}",
682 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
685 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
686 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
687 "cmovae\t{$src2, $dst|$dst, $src2}",
688 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
692 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
693 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
694 "cmove\t{$src2, $dst|$dst, $src2}",
695 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
698 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
699 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
700 "cmove\t{$src2, $dst|$dst, $src2}",
701 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
704 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
705 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
706 "cmove\t{$src2, $dst|$dst, $src2}",
707 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
710 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
711 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
712 "cmove\t{$src2, $dst|$dst, $src2}",
713 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
717 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
718 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
719 "cmovne\t{$src2, $dst|$dst, $src2}",
720 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
723 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
724 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
725 "cmovne\t{$src2, $dst|$dst, $src2}",
726 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
729 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
730 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
731 "cmovne\t{$src2, $dst|$dst, $src2}",
732 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
735 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
736 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
737 "cmovne\t{$src2, $dst|$dst, $src2}",
738 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
742 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
743 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
744 "cmovbe\t{$src2, $dst|$dst, $src2}",
745 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
748 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
749 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
750 "cmovbe\t{$src2, $dst|$dst, $src2}",
751 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
754 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
755 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
756 "cmovbe\t{$src2, $dst|$dst, $src2}",
757 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
760 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
761 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
762 "cmovbe\t{$src2, $dst|$dst, $src2}",
763 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
767 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
768 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
769 "cmova\t{$src2, $dst|$dst, $src2}",
770 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
773 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
774 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
775 "cmova\t{$src2, $dst|$dst, $src2}",
776 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
779 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
780 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
781 "cmova\t{$src2, $dst|$dst, $src2}",
782 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
785 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
786 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
787 "cmova\t{$src2, $dst|$dst, $src2}",
788 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
792 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
793 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
794 "cmovl\t{$src2, $dst|$dst, $src2}",
795 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
798 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
799 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
800 "cmovl\t{$src2, $dst|$dst, $src2}",
801 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
804 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
805 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
806 "cmovl\t{$src2, $dst|$dst, $src2}",
807 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
810 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
811 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
812 "cmovl\t{$src2, $dst|$dst, $src2}",
813 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
817 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
818 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
819 "cmovge\t{$src2, $dst|$dst, $src2}",
820 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
823 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
824 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
825 "cmovge\t{$src2, $dst|$dst, $src2}",
826 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
829 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
830 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
831 "cmovge\t{$src2, $dst|$dst, $src2}",
832 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
835 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
836 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
837 "cmovge\t{$src2, $dst|$dst, $src2}",
838 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
842 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
843 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
844 "cmovle\t{$src2, $dst|$dst, $src2}",
845 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
848 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
849 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
850 "cmovle\t{$src2, $dst|$dst, $src2}",
851 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
854 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
855 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
856 "cmovle\t{$src2, $dst|$dst, $src2}",
857 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
860 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
861 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
862 "cmovle\t{$src2, $dst|$dst, $src2}",
863 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
867 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
868 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
869 "cmovg\t{$src2, $dst|$dst, $src2}",
870 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
873 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
874 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
875 "cmovg\t{$src2, $dst|$dst, $src2}",
876 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
879 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
880 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
881 "cmovg\t{$src2, $dst|$dst, $src2}",
882 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
885 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
886 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
887 "cmovg\t{$src2, $dst|$dst, $src2}",
888 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
892 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
893 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
894 "cmovs\t{$src2, $dst|$dst, $src2}",
895 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
898 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
899 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
900 "cmovs\t{$src2, $dst|$dst, $src2}",
901 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
904 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
905 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
906 "cmovs\t{$src2, $dst|$dst, $src2}",
907 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
910 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
911 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
912 "cmovs\t{$src2, $dst|$dst, $src2}",
913 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
917 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
918 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
919 "cmovns\t{$src2, $dst|$dst, $src2}",
920 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
923 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
924 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
925 "cmovns\t{$src2, $dst|$dst, $src2}",
926 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
929 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
930 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
931 "cmovns\t{$src2, $dst|$dst, $src2}",
932 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
935 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
936 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
937 "cmovns\t{$src2, $dst|$dst, $src2}",
938 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
942 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
943 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
944 "cmovp\t{$src2, $dst|$dst, $src2}",
945 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
948 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
949 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
950 "cmovp\t{$src2, $dst|$dst, $src2}",
951 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
954 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
955 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
956 "cmovp\t{$src2, $dst|$dst, $src2}",
957 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
960 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
961 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
962 "cmovp\t{$src2, $dst|$dst, $src2}",
963 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
967 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
968 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
969 "cmovnp\t{$src2, $dst|$dst, $src2}",
970 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
973 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
974 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
975 "cmovnp\t{$src2, $dst|$dst, $src2}",
976 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
979 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
980 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
981 "cmovnp\t{$src2, $dst|$dst, $src2}",
982 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
985 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
986 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
987 "cmovnp\t{$src2, $dst|$dst, $src2}",
988 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
993 // unary instructions
994 let CodeSize = 2 in {
995 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
996 [(set GR8:$dst, (ineg GR8:$src))]>;
997 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
998 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
999 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1000 [(set GR32:$dst, (ineg GR32:$src))]>;
1001 let isTwoAddress = 0 in {
1002 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1003 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1004 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1005 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1006 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1007 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1011 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1012 [(set GR8:$dst, (not GR8:$src))]>;
1013 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1014 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1015 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1016 [(set GR32:$dst, (not GR32:$src))]>;
1017 let isTwoAddress = 0 in {
1018 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1019 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1020 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1021 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1022 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1023 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1027 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1029 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1030 [(set GR8:$dst, (add GR8:$src, 1))]>;
1031 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1032 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1033 [(set GR16:$dst, (add GR16:$src, 1))]>,
1034 OpSize, Requires<[In32BitMode]>;
1035 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1036 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1038 let isTwoAddress = 0, CodeSize = 2 in {
1039 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1040 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1041 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1042 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
1043 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1044 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1048 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1049 [(set GR8:$dst, (add GR8:$src, -1))]>;
1050 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1051 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1052 [(set GR16:$dst, (add GR16:$src, -1))]>,
1053 OpSize, Requires<[In32BitMode]>;
1054 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1055 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1058 let isTwoAddress = 0, CodeSize = 2 in {
1059 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1060 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1061 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1062 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
1063 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1064 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1067 // Logical operators...
1068 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1069 def AND8rr : I<0x20, MRMDestReg,
1070 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1071 "and{b}\t{$src2, $dst|$dst, $src2}",
1072 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1073 def AND16rr : I<0x21, MRMDestReg,
1074 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1075 "and{w}\t{$src2, $dst|$dst, $src2}",
1076 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1077 def AND32rr : I<0x21, MRMDestReg,
1078 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1079 "and{l}\t{$src2, $dst|$dst, $src2}",
1080 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1083 def AND8rm : I<0x22, MRMSrcMem,
1084 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1085 "and{b}\t{$src2, $dst|$dst, $src2}",
1086 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1087 def AND16rm : I<0x23, MRMSrcMem,
1088 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1089 "and{w}\t{$src2, $dst|$dst, $src2}",
1090 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1091 def AND32rm : I<0x23, MRMSrcMem,
1092 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1093 "and{l}\t{$src2, $dst|$dst, $src2}",
1094 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1096 def AND8ri : Ii8<0x80, MRM4r,
1097 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1098 "and{b}\t{$src2, $dst|$dst, $src2}",
1099 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1100 def AND16ri : Ii16<0x81, MRM4r,
1101 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1102 "and{w}\t{$src2, $dst|$dst, $src2}",
1103 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1104 def AND32ri : Ii32<0x81, MRM4r,
1105 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1106 "and{l}\t{$src2, $dst|$dst, $src2}",
1107 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1108 def AND16ri8 : Ii8<0x83, MRM4r,
1109 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1110 "and{w}\t{$src2, $dst|$dst, $src2}",
1111 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1113 def AND32ri8 : Ii8<0x83, MRM4r,
1114 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1115 "and{l}\t{$src2, $dst|$dst, $src2}",
1116 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1118 let isTwoAddress = 0 in {
1119 def AND8mr : I<0x20, MRMDestMem,
1120 (outs), (ins i8mem :$dst, GR8 :$src),
1121 "and{b}\t{$src, $dst|$dst, $src}",
1122 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1123 def AND16mr : I<0x21, MRMDestMem,
1124 (outs), (ins i16mem:$dst, GR16:$src),
1125 "and{w}\t{$src, $dst|$dst, $src}",
1126 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1128 def AND32mr : I<0x21, MRMDestMem,
1129 (outs), (ins i32mem:$dst, GR32:$src),
1130 "and{l}\t{$src, $dst|$dst, $src}",
1131 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1132 def AND8mi : Ii8<0x80, MRM4m,
1133 (outs), (ins i8mem :$dst, i8imm :$src),
1134 "and{b}\t{$src, $dst|$dst, $src}",
1135 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1136 def AND16mi : Ii16<0x81, MRM4m,
1137 (outs), (ins i16mem:$dst, i16imm:$src),
1138 "and{w}\t{$src, $dst|$dst, $src}",
1139 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1141 def AND32mi : Ii32<0x81, MRM4m,
1142 (outs), (ins i32mem:$dst, i32imm:$src),
1143 "and{l}\t{$src, $dst|$dst, $src}",
1144 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1145 def AND16mi8 : Ii8<0x83, MRM4m,
1146 (outs), (ins i16mem:$dst, i16i8imm :$src),
1147 "and{w}\t{$src, $dst|$dst, $src}",
1148 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1150 def AND32mi8 : Ii8<0x83, MRM4m,
1151 (outs), (ins i32mem:$dst, i32i8imm :$src),
1152 "and{l}\t{$src, $dst|$dst, $src}",
1153 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1157 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1158 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1159 "or{b}\t{$src2, $dst|$dst, $src2}",
1160 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1161 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1162 "or{w}\t{$src2, $dst|$dst, $src2}",
1163 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1164 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1165 "or{l}\t{$src2, $dst|$dst, $src2}",
1166 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1168 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1169 "or{b}\t{$src2, $dst|$dst, $src2}",
1170 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1171 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1172 "or{w}\t{$src2, $dst|$dst, $src2}",
1173 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1174 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1175 "or{l}\t{$src2, $dst|$dst, $src2}",
1176 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1178 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1179 "or{b}\t{$src2, $dst|$dst, $src2}",
1180 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1181 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1182 "or{w}\t{$src2, $dst|$dst, $src2}",
1183 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1184 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1185 "or{l}\t{$src2, $dst|$dst, $src2}",
1186 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1188 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1189 "or{w}\t{$src2, $dst|$dst, $src2}",
1190 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1191 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1192 "or{l}\t{$src2, $dst|$dst, $src2}",
1193 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1194 let isTwoAddress = 0 in {
1195 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1196 "or{b}\t{$src, $dst|$dst, $src}",
1197 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1198 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1199 "or{w}\t{$src, $dst|$dst, $src}",
1200 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1201 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1202 "or{l}\t{$src, $dst|$dst, $src}",
1203 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
1204 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1205 "or{b}\t{$src, $dst|$dst, $src}",
1206 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1207 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1208 "or{w}\t{$src, $dst|$dst, $src}",
1209 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1211 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1212 "or{l}\t{$src, $dst|$dst, $src}",
1213 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1214 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1215 "or{w}\t{$src, $dst|$dst, $src}",
1216 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1218 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1219 "or{l}\t{$src, $dst|$dst, $src}",
1220 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1224 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1225 def XOR8rr : I<0x30, MRMDestReg,
1226 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1227 "xor{b}\t{$src2, $dst|$dst, $src2}",
1228 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1229 def XOR16rr : I<0x31, MRMDestReg,
1230 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1231 "xor{w}\t{$src2, $dst|$dst, $src2}",
1232 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1233 def XOR32rr : I<0x31, MRMDestReg,
1234 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1235 "xor{l}\t{$src2, $dst|$dst, $src2}",
1236 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1239 def XOR8rm : I<0x32, MRMSrcMem ,
1240 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1241 "xor{b}\t{$src2, $dst|$dst, $src2}",
1242 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1243 def XOR16rm : I<0x33, MRMSrcMem ,
1244 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1245 "xor{w}\t{$src2, $dst|$dst, $src2}",
1246 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1247 def XOR32rm : I<0x33, MRMSrcMem ,
1248 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1249 "xor{l}\t{$src2, $dst|$dst, $src2}",
1250 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1252 def XOR8ri : Ii8<0x80, MRM6r,
1253 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1254 "xor{b}\t{$src2, $dst|$dst, $src2}",
1255 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1256 def XOR16ri : Ii16<0x81, MRM6r,
1257 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1258 "xor{w}\t{$src2, $dst|$dst, $src2}",
1259 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1260 def XOR32ri : Ii32<0x81, MRM6r,
1261 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1262 "xor{l}\t{$src2, $dst|$dst, $src2}",
1263 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1264 def XOR16ri8 : Ii8<0x83, MRM6r,
1265 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1266 "xor{w}\t{$src2, $dst|$dst, $src2}",
1267 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1269 def XOR32ri8 : Ii8<0x83, MRM6r,
1270 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1271 "xor{l}\t{$src2, $dst|$dst, $src2}",
1272 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1273 let isTwoAddress = 0 in {
1274 def XOR8mr : I<0x30, MRMDestMem,
1275 (outs), (ins i8mem :$dst, GR8 :$src),
1276 "xor{b}\t{$src, $dst|$dst, $src}",
1277 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1278 def XOR16mr : I<0x31, MRMDestMem,
1279 (outs), (ins i16mem:$dst, GR16:$src),
1280 "xor{w}\t{$src, $dst|$dst, $src}",
1281 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1283 def XOR32mr : I<0x31, MRMDestMem,
1284 (outs), (ins i32mem:$dst, GR32:$src),
1285 "xor{l}\t{$src, $dst|$dst, $src}",
1286 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1287 def XOR8mi : Ii8<0x80, MRM6m,
1288 (outs), (ins i8mem :$dst, i8imm :$src),
1289 "xor{b}\t{$src, $dst|$dst, $src}",
1290 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1291 def XOR16mi : Ii16<0x81, MRM6m,
1292 (outs), (ins i16mem:$dst, i16imm:$src),
1293 "xor{w}\t{$src, $dst|$dst, $src}",
1294 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1296 def XOR32mi : Ii32<0x81, MRM6m,
1297 (outs), (ins i32mem:$dst, i32imm:$src),
1298 "xor{l}\t{$src, $dst|$dst, $src}",
1299 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1300 def XOR16mi8 : Ii8<0x83, MRM6m,
1301 (outs), (ins i16mem:$dst, i16i8imm :$src),
1302 "xor{w}\t{$src, $dst|$dst, $src}",
1303 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1305 def XOR32mi8 : Ii8<0x83, MRM6m,
1306 (outs), (ins i32mem:$dst, i32i8imm :$src),
1307 "xor{l}\t{$src, $dst|$dst, $src}",
1308 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1311 // Shift instructions
1312 let Uses = [CL] in {
1313 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1314 "shl{b}\t{%cl, $dst|$dst, %CL}",
1315 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1316 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1317 "shl{w}\t{%cl, $dst|$dst, %CL}",
1318 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1319 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1320 "shl{l}\t{%cl, $dst|$dst, %CL}",
1321 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1324 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1325 "shl{b}\t{$src2, $dst|$dst, $src2}",
1326 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1327 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1328 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1329 "shl{w}\t{$src2, $dst|$dst, $src2}",
1330 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1331 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1332 "shl{l}\t{$src2, $dst|$dst, $src2}",
1333 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1336 // Shift left by one. Not used because (add x, x) is slightly cheaper.
1337 def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
1338 "shl{b}\t$dst", []>;
1339 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1340 "shl{w}\t$dst", []>, OpSize;
1341 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1342 "shl{l}\t$dst", []>;
1344 let isTwoAddress = 0 in {
1345 let Uses = [CL] in {
1346 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1347 "shl{b}\t{%cl, $dst|$dst, %CL}",
1348 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1349 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1350 "shl{w}\t{%cl, $dst|$dst, %CL}",
1351 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1352 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1353 "shl{l}\t{%cl, $dst|$dst, %CL}",
1354 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1356 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1357 "shl{b}\t{$src, $dst|$dst, $src}",
1358 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1359 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1360 "shl{w}\t{$src, $dst|$dst, $src}",
1361 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1363 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1364 "shl{l}\t{$src, $dst|$dst, $src}",
1365 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1368 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1370 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1371 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1373 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1375 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1377 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1380 let Uses = [CL] in {
1381 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1382 "shr{b}\t{%cl, $dst|$dst, %CL}",
1383 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1384 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1385 "shr{w}\t{%cl, $dst|$dst, %CL}",
1386 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1387 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1388 "shr{l}\t{%cl, $dst|$dst, %CL}",
1389 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1392 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1393 "shr{b}\t{$src2, $dst|$dst, $src2}",
1394 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1395 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1396 "shr{w}\t{$src2, $dst|$dst, $src2}",
1397 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1398 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1399 "shr{l}\t{$src2, $dst|$dst, $src2}",
1400 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1403 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1405 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1406 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1408 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1409 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1411 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1413 let isTwoAddress = 0 in {
1414 let Uses = [CL] in {
1415 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1416 "shr{b}\t{%cl, $dst|$dst, %CL}",
1417 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1418 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1419 "shr{w}\t{%cl, $dst|$dst, %CL}",
1420 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1422 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1423 "shr{l}\t{%cl, $dst|$dst, %CL}",
1424 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1426 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1427 "shr{b}\t{$src, $dst|$dst, $src}",
1428 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1429 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1430 "shr{w}\t{$src, $dst|$dst, $src}",
1431 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1433 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1434 "shr{l}\t{$src, $dst|$dst, $src}",
1435 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1438 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1440 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1441 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1443 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1444 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1446 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1449 let Uses = [CL] in {
1450 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1451 "sar{b}\t{%cl, $dst|$dst, %CL}",
1452 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1453 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1454 "sar{w}\t{%cl, $dst|$dst, %CL}",
1455 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1456 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1457 "sar{l}\t{%cl, $dst|$dst, %CL}",
1458 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1461 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1462 "sar{b}\t{$src2, $dst|$dst, $src2}",
1463 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1464 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1465 "sar{w}\t{$src2, $dst|$dst, $src2}",
1466 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1468 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1469 "sar{l}\t{$src2, $dst|$dst, $src2}",
1470 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1473 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1475 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1476 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1478 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1479 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1481 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1483 let isTwoAddress = 0 in {
1484 let Uses = [CL] in {
1485 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1486 "sar{b}\t{%cl, $dst|$dst, %CL}",
1487 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1488 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1489 "sar{w}\t{%cl, $dst|$dst, %CL}",
1490 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1491 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1492 "sar{l}\t{%cl, $dst|$dst, %CL}",
1493 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1495 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1496 "sar{b}\t{$src, $dst|$dst, $src}",
1497 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1498 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1499 "sar{w}\t{$src, $dst|$dst, $src}",
1500 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1502 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1503 "sar{l}\t{$src, $dst|$dst, $src}",
1504 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1507 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1509 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1510 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1512 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1514 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1516 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1519 // Rotate instructions
1520 // FIXME: provide shorter instructions when imm8 == 1
1521 let Uses = [CL] in {
1522 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1523 "rol{b}\t{%cl, $dst|$dst, %CL}",
1524 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1525 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1526 "rol{w}\t{%cl, $dst|$dst, %CL}",
1527 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1528 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1529 "rol{l}\t{%cl, $dst|$dst, %CL}",
1530 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1533 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1534 "rol{b}\t{$src2, $dst|$dst, $src2}",
1535 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1536 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1537 "rol{w}\t{$src2, $dst|$dst, $src2}",
1538 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1539 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1540 "rol{l}\t{$src2, $dst|$dst, $src2}",
1541 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1544 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1546 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1547 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1549 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1550 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1552 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1554 let isTwoAddress = 0 in {
1555 let Uses = [CL] in {
1556 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1557 "rol{b}\t{%cl, $dst|$dst, %CL}",
1558 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
1559 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1560 "rol{w}\t{%cl, $dst|$dst, %CL}",
1561 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1562 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1563 "rol{l}\t{%cl, $dst|$dst, %CL}",
1564 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1566 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
1567 "rol{b}\t{$src, $dst|$dst, $src}",
1568 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1569 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
1570 "rol{w}\t{$src, $dst|$dst, $src}",
1571 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1573 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
1574 "rol{l}\t{$src, $dst|$dst, $src}",
1575 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1578 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
1580 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1581 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
1583 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1585 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
1587 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1590 let Uses = [CL] in {
1591 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
1592 "ror{b}\t{%cl, $dst|$dst, %CL}",
1593 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
1594 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
1595 "ror{w}\t{%cl, $dst|$dst, %CL}",
1596 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
1597 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
1598 "ror{l}\t{%cl, $dst|$dst, %CL}",
1599 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1602 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1603 "ror{b}\t{$src2, $dst|$dst, $src2}",
1604 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1605 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1606 "ror{w}\t{$src2, $dst|$dst, $src2}",
1607 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1608 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1609 "ror{l}\t{$src2, $dst|$dst, $src2}",
1610 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1613 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1615 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1616 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
1618 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1619 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
1621 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1623 let isTwoAddress = 0 in {
1624 let Uses = [CL] in {
1625 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
1626 "ror{b}\t{%cl, $dst|$dst, %CL}",
1627 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
1628 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
1629 "ror{w}\t{%cl, $dst|$dst, %CL}",
1630 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1631 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
1632 "ror{l}\t{%cl, $dst|$dst, %CL}",
1633 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1635 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1636 "ror{b}\t{$src, $dst|$dst, $src}",
1637 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1638 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
1639 "ror{w}\t{$src, $dst|$dst, $src}",
1640 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1642 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
1643 "ror{l}\t{$src, $dst|$dst, $src}",
1644 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1647 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
1649 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1650 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
1652 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1654 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
1656 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1661 // Double shift instructions (generalizations of rotate)
1662 let Uses = [CL] in {
1663 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1664 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1665 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
1666 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1667 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1668 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
1669 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1670 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1671 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1673 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1674 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1675 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1679 let isCommutable = 1 in { // These instructions commute to each other.
1680 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1681 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1682 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1683 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1686 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1687 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1688 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1689 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1692 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1693 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1694 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1695 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1698 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1699 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1700 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1701 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1706 let isTwoAddress = 0 in {
1707 let Uses = [CL] in {
1708 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1709 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1710 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1712 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1713 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1714 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1717 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1718 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1719 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1720 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1721 (i8 imm:$src3)), addr:$dst)]>,
1723 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1724 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1725 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1726 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1727 (i8 imm:$src3)), addr:$dst)]>,
1730 let Uses = [CL] in {
1731 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1732 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1733 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1734 addr:$dst)]>, TB, OpSize;
1735 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1736 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1737 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1738 addr:$dst)]>, TB, OpSize;
1740 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1741 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1742 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1743 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1744 (i8 imm:$src3)), addr:$dst)]>,
1746 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1747 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1748 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1749 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1750 (i8 imm:$src3)), addr:$dst)]>,
1756 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1757 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1758 (ins GR8 :$src1, GR8 :$src2),
1759 "add{b}\t{$src2, $dst|$dst, $src2}",
1760 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1761 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1762 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1763 (ins GR16:$src1, GR16:$src2),
1764 "add{w}\t{$src2, $dst|$dst, $src2}",
1765 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1766 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1767 (ins GR32:$src1, GR32:$src2),
1768 "add{l}\t{$src2, $dst|$dst, $src2}",
1769 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1770 } // end isConvertibleToThreeAddress
1771 } // end isCommutable
1772 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1773 (ins GR8 :$src1, i8mem :$src2),
1774 "add{b}\t{$src2, $dst|$dst, $src2}",
1775 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1776 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1777 (ins GR16:$src1, i16mem:$src2),
1778 "add{w}\t{$src2, $dst|$dst, $src2}",
1779 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1780 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1781 (ins GR32:$src1, i32mem:$src2),
1782 "add{l}\t{$src2, $dst|$dst, $src2}",
1783 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1785 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1786 "add{b}\t{$src2, $dst|$dst, $src2}",
1787 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1789 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1790 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1791 (ins GR16:$src1, i16imm:$src2),
1792 "add{w}\t{$src2, $dst|$dst, $src2}",
1793 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1794 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1795 (ins GR32:$src1, i32imm:$src2),
1796 "add{l}\t{$src2, $dst|$dst, $src2}",
1797 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
1798 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1799 (ins GR16:$src1, i16i8imm:$src2),
1800 "add{w}\t{$src2, $dst|$dst, $src2}",
1801 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1802 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1803 (ins GR32:$src1, i32i8imm:$src2),
1804 "add{l}\t{$src2, $dst|$dst, $src2}",
1805 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1808 let isTwoAddress = 0 in {
1809 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
1810 "add{b}\t{$src2, $dst|$dst, $src2}",
1811 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1812 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1813 "add{w}\t{$src2, $dst|$dst, $src2}",
1814 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1816 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1817 "add{l}\t{$src2, $dst|$dst, $src2}",
1818 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
1819 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
1820 "add{b}\t{$src2, $dst|$dst, $src2}",
1821 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1822 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
1823 "add{w}\t{$src2, $dst|$dst, $src2}",
1824 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1826 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
1827 "add{l}\t{$src2, $dst|$dst, $src2}",
1828 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1829 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
1830 "add{w}\t{$src2, $dst|$dst, $src2}",
1831 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1833 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1834 "add{l}\t{$src2, $dst|$dst, $src2}",
1835 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1838 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1839 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1840 "adc{l}\t{$src2, $dst|$dst, $src2}",
1841 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1843 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1844 "adc{l}\t{$src2, $dst|$dst, $src2}",
1845 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1846 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1847 "adc{l}\t{$src2, $dst|$dst, $src2}",
1848 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1849 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1850 "adc{l}\t{$src2, $dst|$dst, $src2}",
1851 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1853 let isTwoAddress = 0 in {
1854 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1855 "adc{l}\t{$src2, $dst|$dst, $src2}",
1856 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
1857 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
1858 "adc{l}\t{$src2, $dst|$dst, $src2}",
1859 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1860 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1861 "adc{l}\t{$src2, $dst|$dst, $src2}",
1862 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1865 def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1866 "sub{b}\t{$src2, $dst|$dst, $src2}",
1867 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1868 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1869 "sub{w}\t{$src2, $dst|$dst, $src2}",
1870 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1871 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1872 "sub{l}\t{$src2, $dst|$dst, $src2}",
1873 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1874 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1875 "sub{b}\t{$src2, $dst|$dst, $src2}",
1876 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1877 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1878 "sub{w}\t{$src2, $dst|$dst, $src2}",
1879 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1880 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1881 "sub{l}\t{$src2, $dst|$dst, $src2}",
1882 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1884 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1885 "sub{b}\t{$src2, $dst|$dst, $src2}",
1886 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1887 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1888 "sub{w}\t{$src2, $dst|$dst, $src2}",
1889 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1890 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1891 "sub{l}\t{$src2, $dst|$dst, $src2}",
1892 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1893 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1894 "sub{w}\t{$src2, $dst|$dst, $src2}",
1895 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
1897 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1898 "sub{l}\t{$src2, $dst|$dst, $src2}",
1899 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1900 let isTwoAddress = 0 in {
1901 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
1902 "sub{b}\t{$src2, $dst|$dst, $src2}",
1903 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
1904 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1905 "sub{w}\t{$src2, $dst|$dst, $src2}",
1906 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
1908 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1909 "sub{l}\t{$src2, $dst|$dst, $src2}",
1910 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
1911 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
1912 "sub{b}\t{$src2, $dst|$dst, $src2}",
1913 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1914 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
1915 "sub{w}\t{$src2, $dst|$dst, $src2}",
1916 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1918 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
1919 "sub{l}\t{$src2, $dst|$dst, $src2}",
1920 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1921 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
1922 "sub{w}\t{$src2, $dst|$dst, $src2}",
1923 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1925 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1926 "sub{l}\t{$src2, $dst|$dst, $src2}",
1927 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1930 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1931 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1932 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
1934 let isTwoAddress = 0 in {
1935 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1936 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1937 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
1938 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
1939 "sbb{b}\t{$src2, $dst|$dst, $src2}",
1940 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1941 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
1942 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1943 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1944 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1945 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1946 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1948 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1949 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1950 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
1951 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1952 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1953 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
1954 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1955 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1956 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
1958 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
1959 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1960 "imul{w}\t{$src2, $dst|$dst, $src2}",
1961 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
1962 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1963 "imul{l}\t{$src2, $dst|$dst, $src2}",
1964 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
1966 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1967 "imul{w}\t{$src2, $dst|$dst, $src2}",
1968 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
1970 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1971 "imul{l}\t{$src2, $dst|$dst, $src2}",
1972 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
1974 } // end Two Address instructions
1976 // Suprisingly enough, these are not two address instructions!
1977 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
1978 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1979 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1980 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
1981 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
1982 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1983 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1984 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
1985 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
1986 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1987 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1988 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
1990 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
1991 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1992 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1993 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
1995 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
1996 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
1997 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
1998 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2000 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2001 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2002 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2003 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2004 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2005 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2006 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2007 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2009 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2010 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2011 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2012 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2014 //===----------------------------------------------------------------------===//
2015 // Test instructions are just like AND, except they don't generate a result.
2017 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2018 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2019 "test{b}\t{$src2, $src1|$src1, $src2}",
2020 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
2021 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2022 "test{w}\t{$src2, $src1|$src1, $src2}",
2023 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
2024 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2025 "test{l}\t{$src2, $src1|$src1, $src2}",
2026 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
2029 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2030 "test{b}\t{$src2, $src1|$src1, $src2}",
2031 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
2032 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2033 "test{w}\t{$src2, $src1|$src1, $src2}",
2034 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
2036 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2037 "test{l}\t{$src2, $src1|$src1, $src2}",
2038 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
2040 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2041 (outs), (ins GR8:$src1, i8imm:$src2),
2042 "test{b}\t{$src2, $src1|$src1, $src2}",
2043 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
2044 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2045 (outs), (ins GR16:$src1, i16imm:$src2),
2046 "test{w}\t{$src2, $src1|$src1, $src2}",
2047 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
2048 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2049 (outs), (ins GR32:$src1, i32imm:$src2),
2050 "test{l}\t{$src2, $src1|$src1, $src2}",
2051 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
2053 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2054 (outs), (ins i8mem:$src1, i8imm:$src2),
2055 "test{b}\t{$src2, $src1|$src1, $src2}",
2056 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
2057 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2058 (outs), (ins i16mem:$src1, i16imm:$src2),
2059 "test{w}\t{$src2, $src1|$src1, $src2}",
2060 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
2062 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2063 (outs), (ins i32mem:$src1, i32imm:$src2),
2064 "test{l}\t{$src2, $src1|$src1, $src2}",
2065 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
2068 // Condition code ops, incl. set if equal/not equal/...
2070 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2072 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2074 def SETEr : I<0x94, MRM0r,
2075 (outs GR8 :$dst), (ins),
2077 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2079 def SETEm : I<0x94, MRM0m,
2080 (outs), (ins i8mem:$dst),
2082 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2084 def SETNEr : I<0x95, MRM0r,
2085 (outs GR8 :$dst), (ins),
2087 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2089 def SETNEm : I<0x95, MRM0m,
2090 (outs), (ins i8mem:$dst),
2092 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2094 def SETLr : I<0x9C, MRM0r,
2095 (outs GR8 :$dst), (ins),
2097 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2098 TB; // GR8 = < signed
2099 def SETLm : I<0x9C, MRM0m,
2100 (outs), (ins i8mem:$dst),
2102 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2103 TB; // [mem8] = < signed
2104 def SETGEr : I<0x9D, MRM0r,
2105 (outs GR8 :$dst), (ins),
2107 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2108 TB; // GR8 = >= signed
2109 def SETGEm : I<0x9D, MRM0m,
2110 (outs), (ins i8mem:$dst),
2112 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2113 TB; // [mem8] = >= signed
2114 def SETLEr : I<0x9E, MRM0r,
2115 (outs GR8 :$dst), (ins),
2117 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2118 TB; // GR8 = <= signed
2119 def SETLEm : I<0x9E, MRM0m,
2120 (outs), (ins i8mem:$dst),
2122 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2123 TB; // [mem8] = <= signed
2124 def SETGr : I<0x9F, MRM0r,
2125 (outs GR8 :$dst), (ins),
2127 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2128 TB; // GR8 = > signed
2129 def SETGm : I<0x9F, MRM0m,
2130 (outs), (ins i8mem:$dst),
2132 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2133 TB; // [mem8] = > signed
2135 def SETBr : I<0x92, MRM0r,
2136 (outs GR8 :$dst), (ins),
2138 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2139 TB; // GR8 = < unsign
2140 def SETBm : I<0x92, MRM0m,
2141 (outs), (ins i8mem:$dst),
2143 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2144 TB; // [mem8] = < unsign
2145 def SETAEr : I<0x93, MRM0r,
2146 (outs GR8 :$dst), (ins),
2148 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2149 TB; // GR8 = >= unsign
2150 def SETAEm : I<0x93, MRM0m,
2151 (outs), (ins i8mem:$dst),
2153 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2154 TB; // [mem8] = >= unsign
2155 def SETBEr : I<0x96, MRM0r,
2156 (outs GR8 :$dst), (ins),
2158 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2159 TB; // GR8 = <= unsign
2160 def SETBEm : I<0x96, MRM0m,
2161 (outs), (ins i8mem:$dst),
2163 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2164 TB; // [mem8] = <= unsign
2165 def SETAr : I<0x97, MRM0r,
2166 (outs GR8 :$dst), (ins),
2168 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2169 TB; // GR8 = > signed
2170 def SETAm : I<0x97, MRM0m,
2171 (outs), (ins i8mem:$dst),
2173 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2174 TB; // [mem8] = > signed
2176 def SETSr : I<0x98, MRM0r,
2177 (outs GR8 :$dst), (ins),
2179 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2180 TB; // GR8 = <sign bit>
2181 def SETSm : I<0x98, MRM0m,
2182 (outs), (ins i8mem:$dst),
2184 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2185 TB; // [mem8] = <sign bit>
2186 def SETNSr : I<0x99, MRM0r,
2187 (outs GR8 :$dst), (ins),
2189 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2190 TB; // GR8 = !<sign bit>
2191 def SETNSm : I<0x99, MRM0m,
2192 (outs), (ins i8mem:$dst),
2194 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2195 TB; // [mem8] = !<sign bit>
2196 def SETPr : I<0x9A, MRM0r,
2197 (outs GR8 :$dst), (ins),
2199 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2201 def SETPm : I<0x9A, MRM0m,
2202 (outs), (ins i8mem:$dst),
2204 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2205 TB; // [mem8] = parity
2206 def SETNPr : I<0x9B, MRM0r,
2207 (outs GR8 :$dst), (ins),
2209 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2210 TB; // GR8 = not parity
2211 def SETNPm : I<0x9B, MRM0m,
2212 (outs), (ins i8mem:$dst),
2214 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2215 TB; // [mem8] = not parity
2217 // Integer comparisons
2218 def CMP8rr : I<0x38, MRMDestReg,
2219 (outs), (ins GR8 :$src1, GR8 :$src2),
2220 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2221 [(X86cmp GR8:$src1, GR8:$src2)]>;
2222 def CMP16rr : I<0x39, MRMDestReg,
2223 (outs), (ins GR16:$src1, GR16:$src2),
2224 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2225 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
2226 def CMP32rr : I<0x39, MRMDestReg,
2227 (outs), (ins GR32:$src1, GR32:$src2),
2228 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2229 [(X86cmp GR32:$src1, GR32:$src2)]>;
2230 def CMP8mr : I<0x38, MRMDestMem,
2231 (outs), (ins i8mem :$src1, GR8 :$src2),
2232 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2233 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
2234 def CMP16mr : I<0x39, MRMDestMem,
2235 (outs), (ins i16mem:$src1, GR16:$src2),
2236 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2237 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
2238 def CMP32mr : I<0x39, MRMDestMem,
2239 (outs), (ins i32mem:$src1, GR32:$src2),
2240 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2241 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
2242 def CMP8rm : I<0x3A, MRMSrcMem,
2243 (outs), (ins GR8 :$src1, i8mem :$src2),
2244 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2245 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
2246 def CMP16rm : I<0x3B, MRMSrcMem,
2247 (outs), (ins GR16:$src1, i16mem:$src2),
2248 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2249 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
2250 def CMP32rm : I<0x3B, MRMSrcMem,
2251 (outs), (ins GR32:$src1, i32mem:$src2),
2252 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2253 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
2254 def CMP8ri : Ii8<0x80, MRM7r,
2255 (outs), (ins GR8:$src1, i8imm:$src2),
2256 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2257 [(X86cmp GR8:$src1, imm:$src2)]>;
2258 def CMP16ri : Ii16<0x81, MRM7r,
2259 (outs), (ins GR16:$src1, i16imm:$src2),
2260 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2261 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
2262 def CMP32ri : Ii32<0x81, MRM7r,
2263 (outs), (ins GR32:$src1, i32imm:$src2),
2264 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2265 [(X86cmp GR32:$src1, imm:$src2)]>;
2266 def CMP8mi : Ii8 <0x80, MRM7m,
2267 (outs), (ins i8mem :$src1, i8imm :$src2),
2268 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2269 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2270 def CMP16mi : Ii16<0x81, MRM7m,
2271 (outs), (ins i16mem:$src1, i16imm:$src2),
2272 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2273 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2274 def CMP32mi : Ii32<0x81, MRM7m,
2275 (outs), (ins i32mem:$src1, i32imm:$src2),
2276 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2277 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2278 def CMP16ri8 : Ii8<0x83, MRM7r,
2279 (outs), (ins GR16:$src1, i16i8imm:$src2),
2280 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2281 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
2282 def CMP16mi8 : Ii8<0x83, MRM7m,
2283 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2284 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2285 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
2286 def CMP32mi8 : Ii8<0x83, MRM7m,
2287 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2288 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2289 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
2290 def CMP32ri8 : Ii8<0x83, MRM7r,
2291 (outs), (ins GR32:$src1, i32i8imm:$src2),
2292 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2293 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
2295 // Sign/Zero extenders
2296 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2297 "movs{bw|x}\t{$src, $dst|$dst, $src}",
2298 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
2299 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2300 "movs{bw|x}\t{$src, $dst|$dst, $src}",
2301 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2302 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2303 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2304 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2305 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2306 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2307 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2308 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2309 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2310 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2311 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2312 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2313 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2315 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2316 "movz{bw|x}\t{$src, $dst|$dst, $src}",
2317 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
2318 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2319 "movz{bw|x}\t{$src, $dst|$dst, $src}",
2320 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2321 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2322 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2323 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2324 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2325 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2326 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2327 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2328 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2329 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2330 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2331 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2332 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2334 let Defs = [AX], Uses = [AL] in
2335 def CBW : I<0x98, RawFrm, (outs), (ins),
2336 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2337 let Defs = [EAX], Uses = [AX] in
2338 def CWDE : I<0x98, RawFrm, (outs), (ins),
2339 "{cwtl|cwde}", []>; // EAX = signext(AX)
2341 let Defs = [AX,DX], Uses = [AX] in
2342 def CWD : I<0x99, RawFrm, (outs), (ins),
2343 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2344 let Defs = [EAX,EDX], Uses = [EAX] in
2345 def CDQ : I<0x99, RawFrm, (outs), (ins),
2346 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2349 //===----------------------------------------------------------------------===//
2350 // Alias Instructions
2351 //===----------------------------------------------------------------------===//
2353 // Alias instructions that map movr0 to xor.
2354 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2355 let isReMaterializable = 1 in {
2356 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
2357 "xor{b}\t$dst, $dst",
2358 [(set GR8:$dst, 0)]>;
2359 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
2360 "xor{w}\t$dst, $dst",
2361 [(set GR16:$dst, 0)]>, OpSize;
2362 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
2363 "xor{l}\t$dst, $dst",
2364 [(set GR32:$dst, 0)]>;
2367 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2368 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2369 def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
2370 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2371 def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
2372 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2374 def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
2375 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2376 def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
2377 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2379 def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
2380 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2381 def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
2382 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2384 def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
2385 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2386 def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
2387 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2389 //===----------------------------------------------------------------------===//
2390 // Thread Local Storage Instructions
2394 def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2395 "leal\t${sym:mem}(,%ebx,1), $dst",
2396 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
2398 let AddedComplexity = 10 in
2399 def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
2400 "movl\t%gs:($src), $dst",
2401 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2403 let AddedComplexity = 15 in
2404 def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2405 "movl\t%gs:${src:mem}, $dst",
2407 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2409 def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
2410 "movl\t%gs:0, $dst",
2411 [(set GR32:$dst, X86TLStp)]>;
2413 //===----------------------------------------------------------------------===//
2414 // DWARF Pseudo Instructions
2417 def DWARF_LOC : I<0, Pseudo, (outs),
2418 (ins i32imm:$line, i32imm:$col, i32imm:$file),
2419 "; .loc ${file:debug}, ${line:debug}, ${col:debug}",
2420 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2423 //===----------------------------------------------------------------------===//
2424 // EH Pseudo Instructions
2426 let isTerminator = 1, isReturn = 1, isBarrier = 1,
2428 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
2429 "ret\t#eh_return, addr: $addr",
2430 [(X86ehret GR32:$addr)]>;
2434 //===----------------------------------------------------------------------===//
2435 // Non-Instruction Patterns
2436 //===----------------------------------------------------------------------===//
2438 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2439 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2440 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2441 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2442 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2443 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2445 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2446 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2447 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2448 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2449 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2450 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2451 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2452 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2454 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2455 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2456 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2457 (MOV32mi addr:$dst, texternalsym:$src)>;
2460 def : Pat<(X86tailcall GR32:$dst),
2461 (CALL32r GR32:$dst)>;
2463 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2464 (CALLpcrel32 tglobaladdr:$dst)>;
2465 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2466 (CALLpcrel32 texternalsym:$dst)>;
2468 def : Pat<(X86call (i32 tglobaladdr:$dst)),
2469 (CALLpcrel32 tglobaladdr:$dst)>;
2470 def : Pat<(X86call (i32 texternalsym:$dst)),
2471 (CALLpcrel32 texternalsym:$dst)>;
2473 // X86 specific add which produces a flag.
2474 def : Pat<(addc GR32:$src1, GR32:$src2),
2475 (ADD32rr GR32:$src1, GR32:$src2)>;
2476 def : Pat<(addc GR32:$src1, (load addr:$src2)),
2477 (ADD32rm GR32:$src1, addr:$src2)>;
2478 def : Pat<(addc GR32:$src1, imm:$src2),
2479 (ADD32ri GR32:$src1, imm:$src2)>;
2480 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2481 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2483 def : Pat<(subc GR32:$src1, GR32:$src2),
2484 (SUB32rr GR32:$src1, GR32:$src2)>;
2485 def : Pat<(subc GR32:$src1, (load addr:$src2)),
2486 (SUB32rm GR32:$src1, addr:$src2)>;
2487 def : Pat<(subc GR32:$src1, imm:$src2),
2488 (SUB32ri GR32:$src1, imm:$src2)>;
2489 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2490 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2492 def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2493 (MOV8mi addr:$dst, imm:$src)>;
2494 def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2495 (MOV8mr addr:$dst, GR8:$src)>;
2499 // TEST R,R is smaller than CMP R,0
2500 def : Pat<(X86cmp GR8:$src1, 0),
2501 (TEST8rr GR8:$src1, GR8:$src1)>;
2502 def : Pat<(X86cmp GR16:$src1, 0),
2503 (TEST16rr GR16:$src1, GR16:$src1)>;
2504 def : Pat<(X86cmp GR32:$src1, 0),
2505 (TEST32rr GR32:$src1, GR32:$src1)>;
2507 // {s|z}extload bool -> {s|z}extload byte
2508 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2509 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2510 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2511 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2512 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2514 // extload bool -> extload byte
2515 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2516 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2517 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2518 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2519 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2520 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2523 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2524 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2525 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2526 def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2527 def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2528 def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2530 //===----------------------------------------------------------------------===//
2532 //===----------------------------------------------------------------------===//
2534 // (shl x, 1) ==> (add x, x)
2535 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2536 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2537 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2539 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2540 def : Pat<(or (srl GR32:$src1, CL:$amt),
2541 (shl GR32:$src2, (sub 32, CL:$amt))),
2542 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2544 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2545 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2546 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2548 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2549 def : Pat<(or (shl GR32:$src1, CL:$amt),
2550 (srl GR32:$src2, (sub 32, CL:$amt))),
2551 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2553 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2554 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2555 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2557 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2558 def : Pat<(or (srl GR16:$src1, CL:$amt),
2559 (shl GR16:$src2, (sub 16, CL:$amt))),
2560 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2562 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2563 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2564 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2566 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2567 def : Pat<(or (shl GR16:$src1, CL:$amt),
2568 (srl GR16:$src2, (sub 16, CL:$amt))),
2569 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2571 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2572 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2573 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2576 //===----------------------------------------------------------------------===//
2577 // Floating Point Stack Support
2578 //===----------------------------------------------------------------------===//
2580 include "X86InstrFPStack.td"
2582 //===----------------------------------------------------------------------===//
2584 //===----------------------------------------------------------------------===//
2586 include "X86InstrX86-64.td"
2588 //===----------------------------------------------------------------------===//
2589 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2590 //===----------------------------------------------------------------------===//
2592 include "X86InstrMMX.td"
2594 //===----------------------------------------------------------------------===//
2595 // XMM Floating point support (requires SSE / SSE2)
2596 //===----------------------------------------------------------------------===//
2598 include "X86InstrSSE.td"