1 //===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // 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, 4,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
30 def SDTX86BrCond : SDTypeProfile<0, 3,
31 [SDTCisVT<0, OtherVT>,
32 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
34 def SDTX86SetCC : SDTypeProfile<1, 2,
36 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
38 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
40 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
42 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
44 def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
45 def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
48 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
50 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
52 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
54 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
56 def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
58 def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
60 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
62 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
64 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
65 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
66 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
67 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
69 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
71 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
72 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
74 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
76 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
77 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
79 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
80 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
83 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
84 [SDNPHasChain, SDNPOptInFlag]>;
86 def X86callseq_start :
87 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
88 [SDNPHasChain, SDNPOutFlag]>;
90 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
91 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
93 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
94 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
96 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
97 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
99 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
100 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
101 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
102 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
105 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
106 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
108 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
109 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
111 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
112 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
113 def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
115 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
118 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
119 [SDNPHasChain, SDNPOptInFlag]>;
121 //===----------------------------------------------------------------------===//
122 // X86 Operand Definitions.
125 // *mem - Operand definitions for the funky X86 addressing mode operands.
127 class X86MemOperand<string printMethod> : Operand<iPTR> {
128 let PrintMethod = printMethod;
129 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
132 def i8mem : X86MemOperand<"printi8mem">;
133 def i16mem : X86MemOperand<"printi16mem">;
134 def i32mem : X86MemOperand<"printi32mem">;
135 def i64mem : X86MemOperand<"printi64mem">;
136 def i128mem : X86MemOperand<"printi128mem">;
137 def f32mem : X86MemOperand<"printf32mem">;
138 def f64mem : X86MemOperand<"printf64mem">;
139 def f80mem : X86MemOperand<"printf80mem">;
140 def f128mem : X86MemOperand<"printf128mem">;
142 def lea32mem : Operand<i32> {
143 let PrintMethod = "printi32mem";
144 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
147 def SSECC : Operand<i8> {
148 let PrintMethod = "printSSECC";
151 def piclabel: Operand<i32> {
152 let PrintMethod = "printPICLabel";
155 // A couple of more descriptive operand definitions.
156 // 16-bits but only 8 bits are significant.
157 def i16i8imm : Operand<i16>;
158 // 32-bits but only 8 bits are significant.
159 def i32i8imm : Operand<i32>;
161 // Branch targets have OtherVT type.
162 def brtarget : Operand<OtherVT>;
164 //===----------------------------------------------------------------------===//
165 // X86 Complex Pattern Definitions.
168 // Define X86 specific addressing mode.
169 def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
170 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
171 [add, mul, shl, or, frameindex], []>;
173 //===----------------------------------------------------------------------===//
174 // X86 Instruction Predicate Definitions.
175 def HasMMX : Predicate<"Subtarget->hasMMX()">;
176 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
177 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
178 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
179 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
180 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
181 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
182 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
183 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
184 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
185 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
186 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
187 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
188 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
189 def OptForSpeed : Predicate<"!OptForSize">;
191 //===----------------------------------------------------------------------===//
192 // X86 Instruction Format Definitions.
195 include "X86InstrFormats.td"
197 //===----------------------------------------------------------------------===//
198 // Pattern fragments...
201 // X86 specific condition code. These correspond to CondCode in
202 // X86InstrInfo.h. They must be kept in synch.
203 def X86_COND_A : PatLeaf<(i8 0)>;
204 def X86_COND_AE : PatLeaf<(i8 1)>;
205 def X86_COND_B : PatLeaf<(i8 2)>;
206 def X86_COND_BE : PatLeaf<(i8 3)>;
207 def X86_COND_E : PatLeaf<(i8 4)>;
208 def X86_COND_G : PatLeaf<(i8 5)>;
209 def X86_COND_GE : PatLeaf<(i8 6)>;
210 def X86_COND_L : PatLeaf<(i8 7)>;
211 def X86_COND_LE : PatLeaf<(i8 8)>;
212 def X86_COND_NE : PatLeaf<(i8 9)>;
213 def X86_COND_NO : PatLeaf<(i8 10)>;
214 def X86_COND_NP : PatLeaf<(i8 11)>;
215 def X86_COND_NS : PatLeaf<(i8 12)>;
216 def X86_COND_O : PatLeaf<(i8 13)>;
217 def X86_COND_P : PatLeaf<(i8 14)>;
218 def X86_COND_S : PatLeaf<(i8 15)>;
220 def i16immSExt8 : PatLeaf<(i16 imm), [{
221 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
222 // sign extended field.
223 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
226 def i32immSExt8 : PatLeaf<(i32 imm), [{
227 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
228 // sign extended field.
229 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
232 // Helper fragments for loads.
233 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
234 // known to be 32-bit aligned or better. Ditto for i8 to i16.
235 def loadi16 : PatFrag<(ops node:$ptr), (i16 (ld node:$ptr)), [{
236 LoadSDNode *LD = cast<LoadSDNode>(N);
237 if (LD->getAddressingMode() != ISD::UNINDEXED)
239 ISD::LoadExtType ExtType = LD->getExtensionType();
240 if (ExtType == ISD::NON_EXTLOAD)
242 if (ExtType == ISD::EXTLOAD)
243 return LD->getAlignment() >= 2 && !LD->isVolatile();
247 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
248 LoadSDNode *LD = cast<LoadSDNode>(N);
249 if (LD->getAddressingMode() != ISD::UNINDEXED)
251 ISD::LoadExtType ExtType = LD->getExtensionType();
252 if (ExtType == ISD::EXTLOAD)
253 return LD->getAlignment() >= 2 && !LD->isVolatile();
257 def loadi32 : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
258 LoadSDNode *LD = cast<LoadSDNode>(N);
259 if (LD->getAddressingMode() != ISD::UNINDEXED)
261 ISD::LoadExtType ExtType = LD->getExtensionType();
262 if (ExtType == ISD::NON_EXTLOAD)
264 if (ExtType == ISD::EXTLOAD)
265 return LD->getAlignment() >= 4 && !LD->isVolatile();
269 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
270 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
272 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
273 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
274 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
276 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
277 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
278 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
280 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
281 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
282 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
283 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
284 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
285 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
287 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
288 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
289 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
290 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
291 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
292 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
295 // An 'and' node with a single use.
296 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
297 return N->hasOneUse();
300 //===----------------------------------------------------------------------===//
301 // Instruction list...
304 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
305 // a stack adjustment and the codegen must know that they may modify the stack
306 // pointer before prolog-epilog rewriting occurs.
307 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
308 // sub / add which can clobber EFLAGS.
309 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
310 def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt),
312 [(X86callseq_start imm:$amt)]>;
313 def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
315 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
319 let neverHasSideEffects = 1 in
320 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
323 let neverHasSideEffects = 1, isNotDuplicable = 1 in
324 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
325 "call\t$label\n\tpop{l}\t$reg", []>;
327 //===----------------------------------------------------------------------===//
328 // Control Flow Instructions...
331 // Return instructions.
332 let isTerminator = 1, isReturn = 1, isBarrier = 1,
333 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
334 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
337 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
339 [(X86retflag imm:$amt)]>;
342 // All branches are RawFrm, Void, Branch, and Terminators
343 let isBranch = 1, isTerminator = 1 in
344 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
345 I<opcode, RawFrm, (outs), ins, asm, pattern>;
347 let isBranch = 1, isBarrier = 1 in
348 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
351 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
352 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
353 [(brind GR32:$dst)]>;
354 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
355 [(brind (loadi32 addr:$dst))]>;
358 // Conditional branches
359 let Uses = [EFLAGS] in {
360 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
361 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
362 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
363 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
364 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
365 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
366 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
367 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
368 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
369 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
370 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
371 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
373 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
374 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
375 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
376 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
377 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
378 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
379 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
380 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
382 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
383 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
384 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
385 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
386 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
387 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
388 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
389 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
390 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
391 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
392 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
393 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
396 //===----------------------------------------------------------------------===//
397 // Call Instructions...
400 // All calls clobber the non-callee saved registers...
401 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
402 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
403 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS] in {
404 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
405 "call\t${dst:call}", []>;
406 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
407 "call\t{*}$dst", [(X86call GR32:$dst)]>;
408 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
409 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
414 def TAILCALL : I<0, Pseudo, (outs), (ins),
418 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
419 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
420 "#TC_RETURN $dst $offset",
423 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
424 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
425 "#TC_RETURN $dst $offset",
428 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
430 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
432 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
433 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
435 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
436 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
437 "jmp\t{*}$dst # TAILCALL", []>;
439 //===----------------------------------------------------------------------===//
440 // Miscellaneous Instructions...
442 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
443 def LEAVE : I<0xC9, RawFrm,
444 (outs), (ins), "leave", []>;
446 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
448 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
451 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
454 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
455 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
456 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
457 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
459 let isTwoAddress = 1 in // GR32 = bswap GR32
460 def BSWAP32r : I<0xC8, AddRegFrm,
461 (outs GR32:$dst), (ins GR32:$src),
463 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
466 // Bit scan instructions.
467 let Defs = [EFLAGS] in {
468 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
469 "bsf{w}\t{$src, $dst|$dst, $src}",
470 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
471 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
472 "bsf{w}\t{$src, $dst|$dst, $src}",
473 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
474 (implicit EFLAGS)]>, TB;
475 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
476 "bsf{l}\t{$src, $dst|$dst, $src}",
477 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
478 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
479 "bsf{l}\t{$src, $dst|$dst, $src}",
480 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
481 (implicit EFLAGS)]>, TB;
483 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
484 "bsr{w}\t{$src, $dst|$dst, $src}",
485 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
486 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
487 "bsr{w}\t{$src, $dst|$dst, $src}",
488 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
489 (implicit EFLAGS)]>, TB;
490 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
491 "bsr{l}\t{$src, $dst|$dst, $src}",
492 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
493 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
494 "bsr{l}\t{$src, $dst|$dst, $src}",
495 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
496 (implicit EFLAGS)]>, TB;
499 let neverHasSideEffects = 1 in
500 def LEA16r : I<0x8D, MRMSrcMem,
501 (outs GR16:$dst), (ins i32mem:$src),
502 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
503 let isReMaterializable = 1 in
504 def LEA32r : I<0x8D, MRMSrcMem,
505 (outs GR32:$dst), (ins lea32mem:$src),
506 "lea{l}\t{$src|$dst}, {$dst|$src}",
507 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
509 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
510 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
511 [(X86rep_movs i8)]>, REP;
512 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
513 [(X86rep_movs i16)]>, REP, OpSize;
514 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
515 [(X86rep_movs i32)]>, REP;
518 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
519 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
520 [(X86rep_stos i8)]>, REP;
521 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
522 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
523 [(X86rep_stos i16)]>, REP, OpSize;
524 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
525 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
526 [(X86rep_stos i32)]>, REP;
528 let Defs = [RAX, RDX] in
529 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
532 let isBarrier = 1, hasCtrlDep = 1 in {
533 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
536 //===----------------------------------------------------------------------===//
537 // Input/Output Instructions...
539 let Defs = [AL], Uses = [DX] in
540 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
541 "in{b}\t{%dx, %al|%AL, %DX}", []>;
542 let Defs = [AX], Uses = [DX] in
543 def IN16rr : I<0xED, RawFrm, (outs), (ins),
544 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
545 let Defs = [EAX], Uses = [DX] in
546 def IN32rr : I<0xED, RawFrm, (outs), (ins),
547 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
550 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
551 "in{b}\t{$port, %al|%AL, $port}", []>;
553 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
554 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
556 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
557 "in{l}\t{$port, %eax|%EAX, $port}", []>;
559 let Uses = [DX, AL] in
560 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
561 "out{b}\t{%al, %dx|%DX, %AL}", []>;
562 let Uses = [DX, AX] in
563 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
564 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
565 let Uses = [DX, EAX] in
566 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
567 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
570 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
571 "out{b}\t{%al, $port|$port, %AL}", []>;
573 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
574 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
576 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
577 "out{l}\t{%eax, $port|$port, %EAX}", []>;
579 //===----------------------------------------------------------------------===//
580 // Move Instructions...
582 let neverHasSideEffects = 1 in {
583 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
584 "mov{b}\t{$src, $dst|$dst, $src}", []>;
585 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
586 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
587 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
588 "mov{l}\t{$src, $dst|$dst, $src}", []>;
590 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
591 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
592 "mov{b}\t{$src, $dst|$dst, $src}",
593 [(set GR8:$dst, imm:$src)]>;
594 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
595 "mov{w}\t{$src, $dst|$dst, $src}",
596 [(set GR16:$dst, imm:$src)]>, OpSize;
597 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
598 "mov{l}\t{$src, $dst|$dst, $src}",
599 [(set GR32:$dst, imm:$src)]>;
601 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
602 "mov{b}\t{$src, $dst|$dst, $src}",
603 [(store (i8 imm:$src), addr:$dst)]>;
604 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
605 "mov{w}\t{$src, $dst|$dst, $src}",
606 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
607 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
608 "mov{l}\t{$src, $dst|$dst, $src}",
609 [(store (i32 imm:$src), addr:$dst)]>;
611 let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
612 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
613 "mov{b}\t{$src, $dst|$dst, $src}",
614 [(set GR8:$dst, (load addr:$src))]>;
615 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
616 "mov{w}\t{$src, $dst|$dst, $src}",
617 [(set GR16:$dst, (load addr:$src))]>, OpSize;
618 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
619 "mov{l}\t{$src, $dst|$dst, $src}",
620 [(set GR32:$dst, (load addr:$src))]>;
623 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
624 "mov{b}\t{$src, $dst|$dst, $src}",
625 [(store GR8:$src, addr:$dst)]>;
626 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
627 "mov{w}\t{$src, $dst|$dst, $src}",
628 [(store GR16:$src, addr:$dst)]>, OpSize;
629 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
630 "mov{l}\t{$src, $dst|$dst, $src}",
631 [(store GR32:$src, addr:$dst)]>;
633 //===----------------------------------------------------------------------===//
634 // Fixed-Register Multiplication and Division Instructions...
637 // Extra precision multiplication
638 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
639 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
640 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
641 // This probably ought to be moved to a def : Pat<> if the
642 // syntax can be accepted.
643 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
644 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
645 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
646 OpSize; // AX,DX = AX*GR16
647 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
648 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
649 // EAX,EDX = EAX*GR32
650 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
651 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
653 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
654 // This probably ought to be moved to a def : Pat<> if the
655 // syntax can be accepted.
656 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
657 let mayLoad = 1, neverHasSideEffects = 1 in {
658 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
659 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
660 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
661 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
662 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
663 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
666 let neverHasSideEffects = 1 in {
667 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
668 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
670 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
671 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
672 OpSize; // AX,DX = AX*GR16
673 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
674 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
675 // EAX,EDX = EAX*GR32
677 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
678 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
679 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
680 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
681 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
682 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
683 let Defs = [EAX,EDX], Uses = [EAX] in
684 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
685 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
688 // unsigned division/remainder
689 let Defs = [AX,EFLAGS], Uses = [AL,AH] in
690 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
692 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
693 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
694 "div{w}\t$src", []>, OpSize;
695 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
696 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
699 let Defs = [AX,EFLAGS], Uses = [AL,AH] in
700 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
702 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
703 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
704 "div{w}\t$src", []>, OpSize;
705 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
706 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
710 // Signed division/remainder.
711 let Defs = [AX,EFLAGS], Uses = [AL,AH] in
712 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
713 "idiv{b}\t$src", []>;
714 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
715 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
716 "idiv{w}\t$src", []>, OpSize;
717 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
718 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
719 "idiv{l}\t$src", []>;
720 let mayLoad = 1, mayLoad = 1 in {
721 let Defs = [AX,EFLAGS], Uses = [AL,AH] in
722 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
723 "idiv{b}\t$src", []>;
724 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
725 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
726 "idiv{w}\t$src", []>, OpSize;
727 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
728 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
729 "idiv{l}\t$src", []>;
731 } // neverHasSideEffects
733 //===----------------------------------------------------------------------===//
734 // Two address Instructions.
736 let isTwoAddress = 1 in {
739 let Uses = [EFLAGS] in {
740 let isCommutable = 1 in {
741 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
742 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
743 "cmovb\t{$src2, $dst|$dst, $src2}",
744 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
745 X86_COND_B, EFLAGS))]>,
747 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
748 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
749 "cmovb\t{$src2, $dst|$dst, $src2}",
750 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
751 X86_COND_B, EFLAGS))]>,
754 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
755 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
756 "cmovae\t{$src2, $dst|$dst, $src2}",
757 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
758 X86_COND_AE, EFLAGS))]>,
760 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
761 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
762 "cmovae\t{$src2, $dst|$dst, $src2}",
763 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
764 X86_COND_AE, EFLAGS))]>,
766 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
767 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
768 "cmove\t{$src2, $dst|$dst, $src2}",
769 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
770 X86_COND_E, EFLAGS))]>,
772 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
773 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
774 "cmove\t{$src2, $dst|$dst, $src2}",
775 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
776 X86_COND_E, EFLAGS))]>,
778 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
779 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
780 "cmovne\t{$src2, $dst|$dst, $src2}",
781 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
782 X86_COND_NE, EFLAGS))]>,
784 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
785 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
786 "cmovne\t{$src2, $dst|$dst, $src2}",
787 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
788 X86_COND_NE, EFLAGS))]>,
790 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
791 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
792 "cmovbe\t{$src2, $dst|$dst, $src2}",
793 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
794 X86_COND_BE, EFLAGS))]>,
796 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
797 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
798 "cmovbe\t{$src2, $dst|$dst, $src2}",
799 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
800 X86_COND_BE, EFLAGS))]>,
802 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
803 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
804 "cmova\t{$src2, $dst|$dst, $src2}",
805 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
806 X86_COND_A, EFLAGS))]>,
808 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
809 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
810 "cmova\t{$src2, $dst|$dst, $src2}",
811 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
812 X86_COND_A, EFLAGS))]>,
814 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
815 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
816 "cmovl\t{$src2, $dst|$dst, $src2}",
817 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
818 X86_COND_L, EFLAGS))]>,
820 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
821 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
822 "cmovl\t{$src2, $dst|$dst, $src2}",
823 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
824 X86_COND_L, EFLAGS))]>,
826 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
827 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
828 "cmovge\t{$src2, $dst|$dst, $src2}",
829 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
830 X86_COND_GE, EFLAGS))]>,
832 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
833 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
834 "cmovge\t{$src2, $dst|$dst, $src2}",
835 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
836 X86_COND_GE, EFLAGS))]>,
838 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
839 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
840 "cmovle\t{$src2, $dst|$dst, $src2}",
841 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
842 X86_COND_LE, EFLAGS))]>,
844 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
845 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
846 "cmovle\t{$src2, $dst|$dst, $src2}",
847 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
848 X86_COND_LE, EFLAGS))]>,
850 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
851 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
852 "cmovg\t{$src2, $dst|$dst, $src2}",
853 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
854 X86_COND_G, EFLAGS))]>,
856 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
857 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
858 "cmovg\t{$src2, $dst|$dst, $src2}",
859 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
860 X86_COND_G, EFLAGS))]>,
862 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
863 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
864 "cmovs\t{$src2, $dst|$dst, $src2}",
865 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
866 X86_COND_S, EFLAGS))]>,
868 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
869 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
870 "cmovs\t{$src2, $dst|$dst, $src2}",
871 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
872 X86_COND_S, EFLAGS))]>,
874 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
875 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
876 "cmovns\t{$src2, $dst|$dst, $src2}",
877 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
878 X86_COND_NS, EFLAGS))]>,
880 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
881 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
882 "cmovns\t{$src2, $dst|$dst, $src2}",
883 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
884 X86_COND_NS, EFLAGS))]>,
886 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
887 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
888 "cmovp\t{$src2, $dst|$dst, $src2}",
889 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
890 X86_COND_P, EFLAGS))]>,
892 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
893 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
894 "cmovp\t{$src2, $dst|$dst, $src2}",
895 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
896 X86_COND_P, EFLAGS))]>,
898 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
899 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
900 "cmovnp\t{$src2, $dst|$dst, $src2}",
901 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
902 X86_COND_NP, EFLAGS))]>,
904 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
905 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
906 "cmovnp\t{$src2, $dst|$dst, $src2}",
907 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
908 X86_COND_NP, EFLAGS))]>,
910 } // isCommutable = 1
912 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
913 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
914 "cmovnp\t{$src2, $dst|$dst, $src2}",
915 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
916 X86_COND_NP, EFLAGS))]>,
919 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
920 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
921 "cmovb\t{$src2, $dst|$dst, $src2}",
922 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
923 X86_COND_B, EFLAGS))]>,
925 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
926 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
927 "cmovb\t{$src2, $dst|$dst, $src2}",
928 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
929 X86_COND_B, EFLAGS))]>,
931 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
932 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
933 "cmovae\t{$src2, $dst|$dst, $src2}",
934 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
935 X86_COND_AE, EFLAGS))]>,
937 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
938 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
939 "cmovae\t{$src2, $dst|$dst, $src2}",
940 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
941 X86_COND_AE, EFLAGS))]>,
943 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
944 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
945 "cmove\t{$src2, $dst|$dst, $src2}",
946 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
947 X86_COND_E, EFLAGS))]>,
949 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
950 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
951 "cmove\t{$src2, $dst|$dst, $src2}",
952 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
953 X86_COND_E, EFLAGS))]>,
955 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
956 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
957 "cmovne\t{$src2, $dst|$dst, $src2}",
958 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
959 X86_COND_NE, EFLAGS))]>,
961 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
962 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
963 "cmovne\t{$src2, $dst|$dst, $src2}",
964 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
965 X86_COND_NE, EFLAGS))]>,
967 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
968 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
969 "cmovbe\t{$src2, $dst|$dst, $src2}",
970 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
971 X86_COND_BE, EFLAGS))]>,
973 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
974 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
975 "cmovbe\t{$src2, $dst|$dst, $src2}",
976 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
977 X86_COND_BE, EFLAGS))]>,
979 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
980 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
981 "cmova\t{$src2, $dst|$dst, $src2}",
982 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
983 X86_COND_A, EFLAGS))]>,
985 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
986 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
987 "cmova\t{$src2, $dst|$dst, $src2}",
988 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
989 X86_COND_A, EFLAGS))]>,
991 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
992 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
993 "cmovl\t{$src2, $dst|$dst, $src2}",
994 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
995 X86_COND_L, EFLAGS))]>,
997 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
998 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
999 "cmovl\t{$src2, $dst|$dst, $src2}",
1000 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1001 X86_COND_L, EFLAGS))]>,
1003 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1004 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1005 "cmovge\t{$src2, $dst|$dst, $src2}",
1006 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1007 X86_COND_GE, EFLAGS))]>,
1009 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1010 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1011 "cmovge\t{$src2, $dst|$dst, $src2}",
1012 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1013 X86_COND_GE, EFLAGS))]>,
1015 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1016 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1017 "cmovle\t{$src2, $dst|$dst, $src2}",
1018 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1019 X86_COND_LE, EFLAGS))]>,
1021 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1022 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1023 "cmovle\t{$src2, $dst|$dst, $src2}",
1024 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1025 X86_COND_LE, EFLAGS))]>,
1027 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1028 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1029 "cmovg\t{$src2, $dst|$dst, $src2}",
1030 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1031 X86_COND_G, EFLAGS))]>,
1033 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1034 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1035 "cmovg\t{$src2, $dst|$dst, $src2}",
1036 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1037 X86_COND_G, EFLAGS))]>,
1039 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1040 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1041 "cmovs\t{$src2, $dst|$dst, $src2}",
1042 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1043 X86_COND_S, EFLAGS))]>,
1045 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1046 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1047 "cmovs\t{$src2, $dst|$dst, $src2}",
1048 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1049 X86_COND_S, EFLAGS))]>,
1051 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1052 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1053 "cmovns\t{$src2, $dst|$dst, $src2}",
1054 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1055 X86_COND_NS, EFLAGS))]>,
1057 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1058 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1059 "cmovns\t{$src2, $dst|$dst, $src2}",
1060 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1061 X86_COND_NS, EFLAGS))]>,
1063 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1064 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1065 "cmovp\t{$src2, $dst|$dst, $src2}",
1066 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1067 X86_COND_P, EFLAGS))]>,
1069 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1070 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1071 "cmovp\t{$src2, $dst|$dst, $src2}",
1072 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1073 X86_COND_P, EFLAGS))]>,
1075 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1076 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1077 "cmovnp\t{$src2, $dst|$dst, $src2}",
1078 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1079 X86_COND_NP, EFLAGS))]>,
1081 } // Uses = [EFLAGS]
1084 // unary instructions
1085 let CodeSize = 2 in {
1086 let Defs = [EFLAGS] in {
1087 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1088 [(set GR8:$dst, (ineg GR8:$src))]>;
1089 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1090 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1091 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1092 [(set GR32:$dst, (ineg GR32:$src))]>;
1093 let isTwoAddress = 0 in {
1094 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1095 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1096 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1097 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1098 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1099 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1102 } // Defs = [EFLAGS]
1104 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1105 [(set GR8:$dst, (not GR8:$src))]>;
1106 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1107 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1108 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1109 [(set GR32:$dst, (not GR32:$src))]>;
1110 let isTwoAddress = 0 in {
1111 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1112 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1113 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1114 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1115 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1116 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1120 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1121 let Defs = [EFLAGS] in {
1123 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1124 [(set GR8:$dst, (add GR8:$src, 1))]>;
1125 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1126 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1127 [(set GR16:$dst, (add GR16:$src, 1))]>,
1128 OpSize, Requires<[In32BitMode]>;
1129 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1130 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1132 let isTwoAddress = 0, CodeSize = 2 in {
1133 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1134 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1135 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1136 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1137 OpSize, Requires<[In32BitMode]>;
1138 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1139 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1140 Requires<[In32BitMode]>;
1144 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1145 [(set GR8:$dst, (add GR8:$src, -1))]>;
1146 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1147 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1148 [(set GR16:$dst, (add GR16:$src, -1))]>,
1149 OpSize, Requires<[In32BitMode]>;
1150 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1151 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1154 let isTwoAddress = 0, CodeSize = 2 in {
1155 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1156 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1157 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1158 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1159 OpSize, Requires<[In32BitMode]>;
1160 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1161 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1162 Requires<[In32BitMode]>;
1164 } // Defs = [EFLAGS]
1166 // Logical operators...
1167 let Defs = [EFLAGS] in {
1168 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1169 def AND8rr : I<0x20, MRMDestReg,
1170 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1171 "and{b}\t{$src2, $dst|$dst, $src2}",
1172 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1173 def AND16rr : I<0x21, MRMDestReg,
1174 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1175 "and{w}\t{$src2, $dst|$dst, $src2}",
1176 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1177 def AND32rr : I<0x21, MRMDestReg,
1178 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1179 "and{l}\t{$src2, $dst|$dst, $src2}",
1180 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1183 def AND8rm : I<0x22, MRMSrcMem,
1184 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1185 "and{b}\t{$src2, $dst|$dst, $src2}",
1186 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1187 def AND16rm : I<0x23, MRMSrcMem,
1188 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1189 "and{w}\t{$src2, $dst|$dst, $src2}",
1190 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1191 def AND32rm : I<0x23, MRMSrcMem,
1192 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1193 "and{l}\t{$src2, $dst|$dst, $src2}",
1194 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1196 def AND8ri : Ii8<0x80, MRM4r,
1197 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1198 "and{b}\t{$src2, $dst|$dst, $src2}",
1199 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1200 def AND16ri : Ii16<0x81, MRM4r,
1201 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1202 "and{w}\t{$src2, $dst|$dst, $src2}",
1203 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1204 def AND32ri : Ii32<0x81, MRM4r,
1205 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1206 "and{l}\t{$src2, $dst|$dst, $src2}",
1207 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1208 def AND16ri8 : Ii8<0x83, MRM4r,
1209 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1210 "and{w}\t{$src2, $dst|$dst, $src2}",
1211 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1213 def AND32ri8 : Ii8<0x83, MRM4r,
1214 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1215 "and{l}\t{$src2, $dst|$dst, $src2}",
1216 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1218 let isTwoAddress = 0 in {
1219 def AND8mr : I<0x20, MRMDestMem,
1220 (outs), (ins i8mem :$dst, GR8 :$src),
1221 "and{b}\t{$src, $dst|$dst, $src}",
1222 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1223 def AND16mr : I<0x21, MRMDestMem,
1224 (outs), (ins i16mem:$dst, GR16:$src),
1225 "and{w}\t{$src, $dst|$dst, $src}",
1226 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1228 def AND32mr : I<0x21, MRMDestMem,
1229 (outs), (ins i32mem:$dst, GR32:$src),
1230 "and{l}\t{$src, $dst|$dst, $src}",
1231 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1232 def AND8mi : Ii8<0x80, MRM4m,
1233 (outs), (ins i8mem :$dst, i8imm :$src),
1234 "and{b}\t{$src, $dst|$dst, $src}",
1235 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1236 def AND16mi : Ii16<0x81, MRM4m,
1237 (outs), (ins i16mem:$dst, i16imm:$src),
1238 "and{w}\t{$src, $dst|$dst, $src}",
1239 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1241 def AND32mi : Ii32<0x81, MRM4m,
1242 (outs), (ins i32mem:$dst, i32imm:$src),
1243 "and{l}\t{$src, $dst|$dst, $src}",
1244 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1245 def AND16mi8 : Ii8<0x83, MRM4m,
1246 (outs), (ins i16mem:$dst, i16i8imm :$src),
1247 "and{w}\t{$src, $dst|$dst, $src}",
1248 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1250 def AND32mi8 : Ii8<0x83, MRM4m,
1251 (outs), (ins i32mem:$dst, i32i8imm :$src),
1252 "and{l}\t{$src, $dst|$dst, $src}",
1253 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1257 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1258 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1259 "or{b}\t{$src2, $dst|$dst, $src2}",
1260 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1261 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1262 "or{w}\t{$src2, $dst|$dst, $src2}",
1263 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1264 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1265 "or{l}\t{$src2, $dst|$dst, $src2}",
1266 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1268 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1269 "or{b}\t{$src2, $dst|$dst, $src2}",
1270 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1271 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1272 "or{w}\t{$src2, $dst|$dst, $src2}",
1273 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1274 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1275 "or{l}\t{$src2, $dst|$dst, $src2}",
1276 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1278 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1279 "or{b}\t{$src2, $dst|$dst, $src2}",
1280 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1281 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1282 "or{w}\t{$src2, $dst|$dst, $src2}",
1283 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1284 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1285 "or{l}\t{$src2, $dst|$dst, $src2}",
1286 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1288 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1289 "or{w}\t{$src2, $dst|$dst, $src2}",
1290 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1291 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1292 "or{l}\t{$src2, $dst|$dst, $src2}",
1293 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1294 let isTwoAddress = 0 in {
1295 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1296 "or{b}\t{$src, $dst|$dst, $src}",
1297 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1298 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1299 "or{w}\t{$src, $dst|$dst, $src}",
1300 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1301 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1302 "or{l}\t{$src, $dst|$dst, $src}",
1303 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
1304 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1305 "or{b}\t{$src, $dst|$dst, $src}",
1306 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1307 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1308 "or{w}\t{$src, $dst|$dst, $src}",
1309 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1311 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1312 "or{l}\t{$src, $dst|$dst, $src}",
1313 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1314 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1315 "or{w}\t{$src, $dst|$dst, $src}",
1316 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1318 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1319 "or{l}\t{$src, $dst|$dst, $src}",
1320 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1321 } // isTwoAddress = 0
1324 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1325 def XOR8rr : I<0x30, MRMDestReg,
1326 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1327 "xor{b}\t{$src2, $dst|$dst, $src2}",
1328 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1329 def XOR16rr : I<0x31, MRMDestReg,
1330 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1331 "xor{w}\t{$src2, $dst|$dst, $src2}",
1332 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1333 def XOR32rr : I<0x31, MRMDestReg,
1334 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1335 "xor{l}\t{$src2, $dst|$dst, $src2}",
1336 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1337 } // isCommutable = 1
1339 def XOR8rm : I<0x32, MRMSrcMem ,
1340 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1341 "xor{b}\t{$src2, $dst|$dst, $src2}",
1342 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1343 def XOR16rm : I<0x33, MRMSrcMem ,
1344 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1345 "xor{w}\t{$src2, $dst|$dst, $src2}",
1346 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1348 def XOR32rm : I<0x33, MRMSrcMem ,
1349 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1350 "xor{l}\t{$src2, $dst|$dst, $src2}",
1351 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1353 def XOR8ri : Ii8<0x80, MRM6r,
1354 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1355 "xor{b}\t{$src2, $dst|$dst, $src2}",
1356 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1357 def XOR16ri : Ii16<0x81, MRM6r,
1358 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1359 "xor{w}\t{$src2, $dst|$dst, $src2}",
1360 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1361 def XOR32ri : Ii32<0x81, MRM6r,
1362 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1363 "xor{l}\t{$src2, $dst|$dst, $src2}",
1364 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1365 def XOR16ri8 : Ii8<0x83, MRM6r,
1366 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1367 "xor{w}\t{$src2, $dst|$dst, $src2}",
1368 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1370 def XOR32ri8 : Ii8<0x83, MRM6r,
1371 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1372 "xor{l}\t{$src2, $dst|$dst, $src2}",
1373 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1375 let isTwoAddress = 0 in {
1376 def XOR8mr : I<0x30, MRMDestMem,
1377 (outs), (ins i8mem :$dst, GR8 :$src),
1378 "xor{b}\t{$src, $dst|$dst, $src}",
1379 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1380 def XOR16mr : I<0x31, MRMDestMem,
1381 (outs), (ins i16mem:$dst, GR16:$src),
1382 "xor{w}\t{$src, $dst|$dst, $src}",
1383 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1385 def XOR32mr : I<0x31, MRMDestMem,
1386 (outs), (ins i32mem:$dst, GR32:$src),
1387 "xor{l}\t{$src, $dst|$dst, $src}",
1388 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1389 def XOR8mi : Ii8<0x80, MRM6m,
1390 (outs), (ins i8mem :$dst, i8imm :$src),
1391 "xor{b}\t{$src, $dst|$dst, $src}",
1392 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1393 def XOR16mi : Ii16<0x81, MRM6m,
1394 (outs), (ins i16mem:$dst, i16imm:$src),
1395 "xor{w}\t{$src, $dst|$dst, $src}",
1396 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1398 def XOR32mi : Ii32<0x81, MRM6m,
1399 (outs), (ins i32mem:$dst, i32imm:$src),
1400 "xor{l}\t{$src, $dst|$dst, $src}",
1401 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1402 def XOR16mi8 : Ii8<0x83, MRM6m,
1403 (outs), (ins i16mem:$dst, i16i8imm :$src),
1404 "xor{w}\t{$src, $dst|$dst, $src}",
1405 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1407 def XOR32mi8 : Ii8<0x83, MRM6m,
1408 (outs), (ins i32mem:$dst, i32i8imm :$src),
1409 "xor{l}\t{$src, $dst|$dst, $src}",
1410 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1411 } // isTwoAddress = 0
1412 } // Defs = [EFLAGS]
1414 // Shift instructions
1415 let Defs = [EFLAGS] in {
1416 let Uses = [CL] in {
1417 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1418 "shl{b}\t{%cl, $dst|$dst, %CL}",
1419 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1420 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1421 "shl{w}\t{%cl, $dst|$dst, %CL}",
1422 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1423 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1424 "shl{l}\t{%cl, $dst|$dst, %CL}",
1425 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1428 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1429 "shl{b}\t{$src2, $dst|$dst, $src2}",
1430 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1431 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1432 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1433 "shl{w}\t{$src2, $dst|$dst, $src2}",
1434 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1435 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1436 "shl{l}\t{$src2, $dst|$dst, $src2}",
1437 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1438 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1440 } // isConvertibleToThreeAddress = 1
1442 let isTwoAddress = 0 in {
1443 let Uses = [CL] in {
1444 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1445 "shl{b}\t{%cl, $dst|$dst, %CL}",
1446 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1447 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1448 "shl{w}\t{%cl, $dst|$dst, %CL}",
1449 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1450 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1451 "shl{l}\t{%cl, $dst|$dst, %CL}",
1452 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1454 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1455 "shl{b}\t{$src, $dst|$dst, $src}",
1456 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1457 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1458 "shl{w}\t{$src, $dst|$dst, $src}",
1459 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1461 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1462 "shl{l}\t{$src, $dst|$dst, $src}",
1463 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1466 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1468 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1469 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1471 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1473 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1475 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1478 let Uses = [CL] in {
1479 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1480 "shr{b}\t{%cl, $dst|$dst, %CL}",
1481 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1482 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1483 "shr{w}\t{%cl, $dst|$dst, %CL}",
1484 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1485 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1486 "shr{l}\t{%cl, $dst|$dst, %CL}",
1487 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1490 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1491 "shr{b}\t{$src2, $dst|$dst, $src2}",
1492 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1493 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1494 "shr{w}\t{$src2, $dst|$dst, $src2}",
1495 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1496 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1497 "shr{l}\t{$src2, $dst|$dst, $src2}",
1498 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1501 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1503 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1504 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1506 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1507 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1509 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1511 let isTwoAddress = 0 in {
1512 let Uses = [CL] in {
1513 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1514 "shr{b}\t{%cl, $dst|$dst, %CL}",
1515 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1516 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1517 "shr{w}\t{%cl, $dst|$dst, %CL}",
1518 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1520 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1521 "shr{l}\t{%cl, $dst|$dst, %CL}",
1522 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1524 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1525 "shr{b}\t{$src, $dst|$dst, $src}",
1526 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1527 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1528 "shr{w}\t{$src, $dst|$dst, $src}",
1529 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1531 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1532 "shr{l}\t{$src, $dst|$dst, $src}",
1533 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1536 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1538 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1539 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1541 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1542 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1544 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1547 let Uses = [CL] in {
1548 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1549 "sar{b}\t{%cl, $dst|$dst, %CL}",
1550 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1551 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1552 "sar{w}\t{%cl, $dst|$dst, %CL}",
1553 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1554 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1555 "sar{l}\t{%cl, $dst|$dst, %CL}",
1556 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1559 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1560 "sar{b}\t{$src2, $dst|$dst, $src2}",
1561 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1562 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1563 "sar{w}\t{$src2, $dst|$dst, $src2}",
1564 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1566 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1567 "sar{l}\t{$src2, $dst|$dst, $src2}",
1568 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1571 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1573 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1574 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1576 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1577 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1579 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1581 let isTwoAddress = 0 in {
1582 let Uses = [CL] in {
1583 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1584 "sar{b}\t{%cl, $dst|$dst, %CL}",
1585 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1586 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1587 "sar{w}\t{%cl, $dst|$dst, %CL}",
1588 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1589 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1590 "sar{l}\t{%cl, $dst|$dst, %CL}",
1591 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1593 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1594 "sar{b}\t{$src, $dst|$dst, $src}",
1595 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1596 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1597 "sar{w}\t{$src, $dst|$dst, $src}",
1598 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1600 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1601 "sar{l}\t{$src, $dst|$dst, $src}",
1602 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1605 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1607 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1608 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1610 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1612 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1614 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1617 // Rotate instructions
1618 // FIXME: provide shorter instructions when imm8 == 1
1619 let Uses = [CL] in {
1620 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1621 "rol{b}\t{%cl, $dst|$dst, %CL}",
1622 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1623 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1624 "rol{w}\t{%cl, $dst|$dst, %CL}",
1625 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1626 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1627 "rol{l}\t{%cl, $dst|$dst, %CL}",
1628 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1631 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1632 "rol{b}\t{$src2, $dst|$dst, $src2}",
1633 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1634 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1635 "rol{w}\t{$src2, $dst|$dst, $src2}",
1636 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1637 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1638 "rol{l}\t{$src2, $dst|$dst, $src2}",
1639 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1642 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1644 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1645 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1647 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1648 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1650 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1652 let isTwoAddress = 0 in {
1653 let Uses = [CL] in {
1654 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1655 "rol{b}\t{%cl, $dst|$dst, %CL}",
1656 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
1657 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1658 "rol{w}\t{%cl, $dst|$dst, %CL}",
1659 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1660 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1661 "rol{l}\t{%cl, $dst|$dst, %CL}",
1662 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1664 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
1665 "rol{b}\t{$src, $dst|$dst, $src}",
1666 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1667 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
1668 "rol{w}\t{$src, $dst|$dst, $src}",
1669 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1671 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
1672 "rol{l}\t{$src, $dst|$dst, $src}",
1673 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1676 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
1678 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1679 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
1681 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1683 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
1685 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1688 let Uses = [CL] in {
1689 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
1690 "ror{b}\t{%cl, $dst|$dst, %CL}",
1691 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
1692 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
1693 "ror{w}\t{%cl, $dst|$dst, %CL}",
1694 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
1695 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
1696 "ror{l}\t{%cl, $dst|$dst, %CL}",
1697 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1700 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1701 "ror{b}\t{$src2, $dst|$dst, $src2}",
1702 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1703 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1704 "ror{w}\t{$src2, $dst|$dst, $src2}",
1705 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1706 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1707 "ror{l}\t{$src2, $dst|$dst, $src2}",
1708 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1711 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1713 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1714 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
1716 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1717 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
1719 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1721 let isTwoAddress = 0 in {
1722 let Uses = [CL] in {
1723 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
1724 "ror{b}\t{%cl, $dst|$dst, %CL}",
1725 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
1726 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
1727 "ror{w}\t{%cl, $dst|$dst, %CL}",
1728 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1729 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
1730 "ror{l}\t{%cl, $dst|$dst, %CL}",
1731 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1733 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1734 "ror{b}\t{$src, $dst|$dst, $src}",
1735 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1736 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
1737 "ror{w}\t{$src, $dst|$dst, $src}",
1738 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1740 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
1741 "ror{l}\t{$src, $dst|$dst, $src}",
1742 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1745 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
1747 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1748 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
1750 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1752 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
1754 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1759 // Double shift instructions (generalizations of rotate)
1760 let Uses = [CL] in {
1761 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1762 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1763 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
1764 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1765 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1766 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
1767 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1768 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1769 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1771 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1772 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1773 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1777 let isCommutable = 1 in { // These instructions commute to each other.
1778 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1779 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1780 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1781 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1784 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1785 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1786 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1787 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1790 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1791 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1792 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1793 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1796 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1797 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1798 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1799 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1804 let isTwoAddress = 0 in {
1805 let Uses = [CL] in {
1806 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1807 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1808 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1810 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1811 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1812 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1815 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1816 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1817 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1818 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1819 (i8 imm:$src3)), addr:$dst)]>,
1821 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1822 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1823 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1824 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1825 (i8 imm:$src3)), addr:$dst)]>,
1828 let Uses = [CL] in {
1829 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1830 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1831 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1832 addr:$dst)]>, TB, OpSize;
1833 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1834 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1835 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1836 addr:$dst)]>, TB, OpSize;
1838 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1839 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1840 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1841 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1842 (i8 imm:$src3)), addr:$dst)]>,
1844 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1845 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1846 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1847 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1848 (i8 imm:$src3)), addr:$dst)]>,
1851 } // Defs = [EFLAGS]
1855 let Defs = [EFLAGS] in {
1856 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1857 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1858 (ins GR8 :$src1, GR8 :$src2),
1859 "add{b}\t{$src2, $dst|$dst, $src2}",
1860 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1861 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1862 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1863 (ins GR16:$src1, GR16:$src2),
1864 "add{w}\t{$src2, $dst|$dst, $src2}",
1865 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1866 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1867 (ins GR32:$src1, GR32:$src2),
1868 "add{l}\t{$src2, $dst|$dst, $src2}",
1869 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1870 } // end isConvertibleToThreeAddress
1871 } // end isCommutable
1872 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1873 (ins GR8 :$src1, i8mem :$src2),
1874 "add{b}\t{$src2, $dst|$dst, $src2}",
1875 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1876 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1877 (ins GR16:$src1, i16mem:$src2),
1878 "add{w}\t{$src2, $dst|$dst, $src2}",
1879 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1880 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1881 (ins GR32:$src1, i32mem:$src2),
1882 "add{l}\t{$src2, $dst|$dst, $src2}",
1883 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1885 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1886 "add{b}\t{$src2, $dst|$dst, $src2}",
1887 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1889 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1890 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1891 (ins GR16:$src1, i16imm:$src2),
1892 "add{w}\t{$src2, $dst|$dst, $src2}",
1893 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1894 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1895 (ins GR32:$src1, i32imm:$src2),
1896 "add{l}\t{$src2, $dst|$dst, $src2}",
1897 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
1898 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1899 (ins GR16:$src1, i16i8imm:$src2),
1900 "add{w}\t{$src2, $dst|$dst, $src2}",
1901 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1902 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1903 (ins GR32:$src1, i32i8imm:$src2),
1904 "add{l}\t{$src2, $dst|$dst, $src2}",
1905 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1908 let isTwoAddress = 0 in {
1909 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
1910 "add{b}\t{$src2, $dst|$dst, $src2}",
1911 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1912 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1913 "add{w}\t{$src2, $dst|$dst, $src2}",
1914 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1916 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1917 "add{l}\t{$src2, $dst|$dst, $src2}",
1918 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
1919 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
1920 "add{b}\t{$src2, $dst|$dst, $src2}",
1921 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1922 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
1923 "add{w}\t{$src2, $dst|$dst, $src2}",
1924 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1926 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
1927 "add{l}\t{$src2, $dst|$dst, $src2}",
1928 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1929 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
1930 "add{w}\t{$src2, $dst|$dst, $src2}",
1931 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1933 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1934 "add{l}\t{$src2, $dst|$dst, $src2}",
1935 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1938 let Uses = [EFLAGS] in {
1939 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1940 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1941 "adc{l}\t{$src2, $dst|$dst, $src2}",
1942 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1944 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1945 "adc{l}\t{$src2, $dst|$dst, $src2}",
1946 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1947 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1948 "adc{l}\t{$src2, $dst|$dst, $src2}",
1949 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1950 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1951 "adc{l}\t{$src2, $dst|$dst, $src2}",
1952 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1954 let isTwoAddress = 0 in {
1955 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1956 "adc{l}\t{$src2, $dst|$dst, $src2}",
1957 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
1958 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
1959 "adc{l}\t{$src2, $dst|$dst, $src2}",
1960 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1961 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1962 "adc{l}\t{$src2, $dst|$dst, $src2}",
1963 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1965 } // Uses = [EFLAGS]
1967 def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1968 "sub{b}\t{$src2, $dst|$dst, $src2}",
1969 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1970 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1971 "sub{w}\t{$src2, $dst|$dst, $src2}",
1972 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1973 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1974 "sub{l}\t{$src2, $dst|$dst, $src2}",
1975 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1976 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1977 "sub{b}\t{$src2, $dst|$dst, $src2}",
1978 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1979 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1980 "sub{w}\t{$src2, $dst|$dst, $src2}",
1981 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1982 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1983 "sub{l}\t{$src2, $dst|$dst, $src2}",
1984 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1986 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1987 "sub{b}\t{$src2, $dst|$dst, $src2}",
1988 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1989 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1990 "sub{w}\t{$src2, $dst|$dst, $src2}",
1991 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1992 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1993 "sub{l}\t{$src2, $dst|$dst, $src2}",
1994 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1995 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1996 "sub{w}\t{$src2, $dst|$dst, $src2}",
1997 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
1999 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2000 "sub{l}\t{$src2, $dst|$dst, $src2}",
2001 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
2002 let isTwoAddress = 0 in {
2003 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2004 "sub{b}\t{$src2, $dst|$dst, $src2}",
2005 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
2006 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2007 "sub{w}\t{$src2, $dst|$dst, $src2}",
2008 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
2010 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2011 "sub{l}\t{$src2, $dst|$dst, $src2}",
2012 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
2013 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2014 "sub{b}\t{$src2, $dst|$dst, $src2}",
2015 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2016 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2017 "sub{w}\t{$src2, $dst|$dst, $src2}",
2018 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2020 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2021 "sub{l}\t{$src2, $dst|$dst, $src2}",
2022 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2023 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2024 "sub{w}\t{$src2, $dst|$dst, $src2}",
2025 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2027 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2028 "sub{l}\t{$src2, $dst|$dst, $src2}",
2029 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2032 let Uses = [EFLAGS] in {
2033 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2034 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2035 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2037 let isTwoAddress = 0 in {
2038 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2039 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2040 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2041 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2042 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2043 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2044 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2045 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2046 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2047 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2048 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2049 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2051 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2052 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2053 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2054 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2055 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2056 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2057 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2058 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2059 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2060 } // Uses = [EFLAGS]
2061 } // Defs = [EFLAGS]
2063 let Defs = [EFLAGS] in {
2064 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2065 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2066 "imul{w}\t{$src2, $dst|$dst, $src2}",
2067 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2068 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2069 "imul{l}\t{$src2, $dst|$dst, $src2}",
2070 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2072 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
2073 "imul{w}\t{$src2, $dst|$dst, $src2}",
2074 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2076 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2077 "imul{l}\t{$src2, $dst|$dst, $src2}",
2078 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
2079 } // Defs = [EFLAGS]
2080 } // end Two Address instructions
2082 // Suprisingly enough, these are not two address instructions!
2083 let Defs = [EFLAGS] in {
2084 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2085 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2086 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2087 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2088 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2089 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2090 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2091 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2092 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2093 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2094 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2095 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2097 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2098 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2099 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2100 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2102 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2103 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2104 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2105 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2107 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2108 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2109 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2110 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2111 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2112 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2113 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2114 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2116 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2117 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2118 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2119 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2120 } // Defs = [EFLAGS]
2122 //===----------------------------------------------------------------------===//
2123 // Test instructions are just like AND, except they don't generate a result.
2125 let Defs = [EFLAGS] in {
2126 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2127 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2128 "test{b}\t{$src2, $src1|$src1, $src2}",
2129 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2130 (implicit EFLAGS)]>;
2131 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2132 "test{w}\t{$src2, $src1|$src1, $src2}",
2133 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2134 (implicit EFLAGS)]>,
2136 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2137 "test{l}\t{$src2, $src1|$src1, $src2}",
2138 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2139 (implicit EFLAGS)]>;
2142 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2143 "test{b}\t{$src2, $src1|$src1, $src2}",
2144 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2145 (implicit EFLAGS)]>;
2146 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2147 "test{w}\t{$src2, $src1|$src1, $src2}",
2148 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2149 (implicit EFLAGS)]>, OpSize;
2150 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2151 "test{l}\t{$src2, $src1|$src1, $src2}",
2152 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2153 (implicit EFLAGS)]>;
2155 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2156 (outs), (ins GR8:$src1, i8imm:$src2),
2157 "test{b}\t{$src2, $src1|$src1, $src2}",
2158 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2159 (implicit EFLAGS)]>;
2160 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2161 (outs), (ins GR16:$src1, i16imm:$src2),
2162 "test{w}\t{$src2, $src1|$src1, $src2}",
2163 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2164 (implicit EFLAGS)]>, OpSize;
2165 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2166 (outs), (ins GR32:$src1, i32imm:$src2),
2167 "test{l}\t{$src2, $src1|$src1, $src2}",
2168 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2169 (implicit EFLAGS)]>;
2171 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2172 (outs), (ins i8mem:$src1, i8imm:$src2),
2173 "test{b}\t{$src2, $src1|$src1, $src2}",
2174 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2175 (implicit EFLAGS)]>;
2176 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2177 (outs), (ins i16mem:$src1, i16imm:$src2),
2178 "test{w}\t{$src2, $src1|$src1, $src2}",
2179 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2180 (implicit EFLAGS)]>, OpSize;
2181 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2182 (outs), (ins i32mem:$src1, i32imm:$src2),
2183 "test{l}\t{$src2, $src1|$src1, $src2}",
2184 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2185 (implicit EFLAGS)]>;
2186 } // Defs = [EFLAGS]
2189 // Condition code ops, incl. set if equal/not equal/...
2190 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2191 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2192 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2193 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2195 let Uses = [EFLAGS] in {
2196 def SETEr : I<0x94, MRM0r,
2197 (outs GR8 :$dst), (ins),
2199 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2201 def SETEm : I<0x94, MRM0m,
2202 (outs), (ins i8mem:$dst),
2204 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2206 def SETNEr : I<0x95, MRM0r,
2207 (outs GR8 :$dst), (ins),
2209 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2211 def SETNEm : I<0x95, MRM0m,
2212 (outs), (ins i8mem:$dst),
2214 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2216 def SETLr : I<0x9C, MRM0r,
2217 (outs GR8 :$dst), (ins),
2219 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2220 TB; // GR8 = < signed
2221 def SETLm : I<0x9C, MRM0m,
2222 (outs), (ins i8mem:$dst),
2224 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2225 TB; // [mem8] = < signed
2226 def SETGEr : I<0x9D, MRM0r,
2227 (outs GR8 :$dst), (ins),
2229 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2230 TB; // GR8 = >= signed
2231 def SETGEm : I<0x9D, MRM0m,
2232 (outs), (ins i8mem:$dst),
2234 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2235 TB; // [mem8] = >= signed
2236 def SETLEr : I<0x9E, MRM0r,
2237 (outs GR8 :$dst), (ins),
2239 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2240 TB; // GR8 = <= signed
2241 def SETLEm : I<0x9E, MRM0m,
2242 (outs), (ins i8mem:$dst),
2244 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2245 TB; // [mem8] = <= signed
2246 def SETGr : I<0x9F, MRM0r,
2247 (outs GR8 :$dst), (ins),
2249 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2250 TB; // GR8 = > signed
2251 def SETGm : I<0x9F, MRM0m,
2252 (outs), (ins i8mem:$dst),
2254 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2255 TB; // [mem8] = > signed
2257 def SETBr : I<0x92, MRM0r,
2258 (outs GR8 :$dst), (ins),
2260 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2261 TB; // GR8 = < unsign
2262 def SETBm : I<0x92, MRM0m,
2263 (outs), (ins i8mem:$dst),
2265 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2266 TB; // [mem8] = < unsign
2267 def SETAEr : I<0x93, MRM0r,
2268 (outs GR8 :$dst), (ins),
2270 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2271 TB; // GR8 = >= unsign
2272 def SETAEm : I<0x93, MRM0m,
2273 (outs), (ins i8mem:$dst),
2275 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2276 TB; // [mem8] = >= unsign
2277 def SETBEr : I<0x96, MRM0r,
2278 (outs GR8 :$dst), (ins),
2280 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2281 TB; // GR8 = <= unsign
2282 def SETBEm : I<0x96, MRM0m,
2283 (outs), (ins i8mem:$dst),
2285 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2286 TB; // [mem8] = <= unsign
2287 def SETAr : I<0x97, MRM0r,
2288 (outs GR8 :$dst), (ins),
2290 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2291 TB; // GR8 = > signed
2292 def SETAm : I<0x97, MRM0m,
2293 (outs), (ins i8mem:$dst),
2295 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2296 TB; // [mem8] = > signed
2298 def SETSr : I<0x98, MRM0r,
2299 (outs GR8 :$dst), (ins),
2301 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2302 TB; // GR8 = <sign bit>
2303 def SETSm : I<0x98, MRM0m,
2304 (outs), (ins i8mem:$dst),
2306 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2307 TB; // [mem8] = <sign bit>
2308 def SETNSr : I<0x99, MRM0r,
2309 (outs GR8 :$dst), (ins),
2311 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2312 TB; // GR8 = !<sign bit>
2313 def SETNSm : I<0x99, MRM0m,
2314 (outs), (ins i8mem:$dst),
2316 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2317 TB; // [mem8] = !<sign bit>
2318 def SETPr : I<0x9A, MRM0r,
2319 (outs GR8 :$dst), (ins),
2321 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2323 def SETPm : I<0x9A, MRM0m,
2324 (outs), (ins i8mem:$dst),
2326 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2327 TB; // [mem8] = parity
2328 def SETNPr : I<0x9B, MRM0r,
2329 (outs GR8 :$dst), (ins),
2331 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2332 TB; // GR8 = not parity
2333 def SETNPm : I<0x9B, MRM0m,
2334 (outs), (ins i8mem:$dst),
2336 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2337 TB; // [mem8] = not parity
2338 } // Uses = [EFLAGS]
2341 // Integer comparisons
2342 let Defs = [EFLAGS] in {
2343 def CMP8rr : I<0x38, MRMDestReg,
2344 (outs), (ins GR8 :$src1, GR8 :$src2),
2345 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2346 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2347 def CMP16rr : I<0x39, MRMDestReg,
2348 (outs), (ins GR16:$src1, GR16:$src2),
2349 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2350 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2351 def CMP32rr : I<0x39, MRMDestReg,
2352 (outs), (ins GR32:$src1, GR32:$src2),
2353 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2354 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2355 def CMP8mr : I<0x38, MRMDestMem,
2356 (outs), (ins i8mem :$src1, GR8 :$src2),
2357 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2358 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2359 (implicit EFLAGS)]>;
2360 def CMP16mr : I<0x39, MRMDestMem,
2361 (outs), (ins i16mem:$src1, GR16:$src2),
2362 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2363 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2364 (implicit EFLAGS)]>, OpSize;
2365 def CMP32mr : I<0x39, MRMDestMem,
2366 (outs), (ins i32mem:$src1, GR32:$src2),
2367 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2368 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2369 (implicit EFLAGS)]>;
2370 def CMP8rm : I<0x3A, MRMSrcMem,
2371 (outs), (ins GR8 :$src1, i8mem :$src2),
2372 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2373 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2374 (implicit EFLAGS)]>;
2375 def CMP16rm : I<0x3B, MRMSrcMem,
2376 (outs), (ins GR16:$src1, i16mem:$src2),
2377 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2378 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2379 (implicit EFLAGS)]>, OpSize;
2380 def CMP32rm : I<0x3B, MRMSrcMem,
2381 (outs), (ins GR32:$src1, i32mem:$src2),
2382 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2383 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2384 (implicit EFLAGS)]>;
2385 def CMP8ri : Ii8<0x80, MRM7r,
2386 (outs), (ins GR8:$src1, i8imm:$src2),
2387 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2388 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
2389 def CMP16ri : Ii16<0x81, MRM7r,
2390 (outs), (ins GR16:$src1, i16imm:$src2),
2391 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2392 [(X86cmp GR16:$src1, imm:$src2),
2393 (implicit EFLAGS)]>, OpSize;
2394 def CMP32ri : Ii32<0x81, MRM7r,
2395 (outs), (ins GR32:$src1, i32imm:$src2),
2396 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2397 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
2398 def CMP8mi : Ii8 <0x80, MRM7m,
2399 (outs), (ins i8mem :$src1, i8imm :$src2),
2400 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2401 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2402 (implicit EFLAGS)]>;
2403 def CMP16mi : Ii16<0x81, MRM7m,
2404 (outs), (ins i16mem:$src1, i16imm:$src2),
2405 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2406 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2407 (implicit EFLAGS)]>, OpSize;
2408 def CMP32mi : Ii32<0x81, MRM7m,
2409 (outs), (ins i32mem:$src1, i32imm:$src2),
2410 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2411 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2412 (implicit EFLAGS)]>;
2413 def CMP16ri8 : Ii8<0x83, MRM7r,
2414 (outs), (ins GR16:$src1, i16i8imm:$src2),
2415 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2416 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2417 (implicit EFLAGS)]>, OpSize;
2418 def CMP16mi8 : Ii8<0x83, MRM7m,
2419 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2420 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2421 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2422 (implicit EFLAGS)]>, OpSize;
2423 def CMP32mi8 : Ii8<0x83, MRM7m,
2424 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2425 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2426 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2427 (implicit EFLAGS)]>;
2428 def CMP32ri8 : Ii8<0x83, MRM7r,
2429 (outs), (ins GR32:$src1, i32i8imm:$src2),
2430 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2431 [(X86cmp GR32:$src1, i32immSExt8:$src2),
2432 (implicit EFLAGS)]>;
2433 } // Defs = [EFLAGS]
2435 // Sign/Zero extenders
2436 // Use movsbl intead of movsbw; we don't care about the high 16 bits
2437 // of the register here. This has a smaller encoding and avoids a
2438 // partial-register update.
2439 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2440 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2441 [(set GR16:$dst, (sext GR8:$src))]>, TB;
2442 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2443 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2444 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
2445 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2446 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2447 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2448 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2449 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2450 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2451 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2452 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2453 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2454 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2455 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2456 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2458 // Use movzbl intead of movzbw; we don't care about the high 16 bits
2459 // of the register here. This has a smaller encoding and avoids a
2460 // partial-register update.
2461 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2462 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2463 [(set GR16:$dst, (zext GR8:$src))]>, TB;
2464 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2465 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2466 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
2467 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2468 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2469 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2470 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2471 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2472 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2473 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2474 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2475 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2476 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2477 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2478 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2480 let neverHasSideEffects = 1 in {
2481 let Defs = [AX], Uses = [AL] in
2482 def CBW : I<0x98, RawFrm, (outs), (ins),
2483 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2484 let Defs = [EAX], Uses = [AX] in
2485 def CWDE : I<0x98, RawFrm, (outs), (ins),
2486 "{cwtl|cwde}", []>; // EAX = signext(AX)
2488 let Defs = [AX,DX], Uses = [AX] in
2489 def CWD : I<0x99, RawFrm, (outs), (ins),
2490 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2491 let Defs = [EAX,EDX], Uses = [EAX] in
2492 def CDQ : I<0x99, RawFrm, (outs), (ins),
2493 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2496 //===----------------------------------------------------------------------===//
2497 // Alias Instructions
2498 //===----------------------------------------------------------------------===//
2500 // Alias instructions that map movr0 to xor.
2501 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2502 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2503 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
2504 "xor{b}\t$dst, $dst",
2505 [(set GR8:$dst, 0)]>;
2506 // Use xorl instead of xorw since we don't care about the high 16 bits,
2507 // it's smaller, and it avoids a partial-register update.
2508 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
2509 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2510 [(set GR16:$dst, 0)]>;
2511 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
2512 "xor{l}\t$dst, $dst",
2513 [(set GR32:$dst, 0)]>;
2516 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2517 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2518 let neverHasSideEffects = 1 in {
2519 def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
2520 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2521 def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
2522 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2524 def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
2525 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2526 def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
2527 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2528 } // neverHasSideEffects
2530 let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
2531 def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
2532 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2533 def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
2534 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2536 let mayStore = 1, neverHasSideEffects = 1 in {
2537 def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
2538 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2539 def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
2540 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2543 //===----------------------------------------------------------------------===//
2544 // Thread Local Storage Instructions
2548 def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2549 "leal\t${sym:mem}(,%ebx,1), $dst",
2550 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
2552 let AddedComplexity = 10 in
2553 def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
2554 "movl\t%gs:($src), $dst",
2555 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2557 let AddedComplexity = 15 in
2558 def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2559 "movl\t%gs:${src:mem}, $dst",
2561 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2563 def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
2564 "movl\t%gs:0, $dst",
2565 [(set GR32:$dst, X86TLStp)]>;
2567 //===----------------------------------------------------------------------===//
2568 // DWARF Pseudo Instructions
2571 def DWARF_LOC : I<0, Pseudo, (outs),
2572 (ins i32imm:$line, i32imm:$col, i32imm:$file),
2573 ".loc\t${file:debug} ${line:debug} ${col:debug}",
2574 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2577 //===----------------------------------------------------------------------===//
2578 // EH Pseudo Instructions
2580 let isTerminator = 1, isReturn = 1, isBarrier = 1,
2582 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
2583 "ret\t#eh_return, addr: $addr",
2584 [(X86ehret GR32:$addr)]>;
2588 //===----------------------------------------------------------------------===//
2592 // Atomic swap. These are just normal xchg instructions. But since a memory
2593 // operand is referenced, the atomicity is ensured.
2594 let Constraints = "$val = $dst" in {
2595 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2596 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2597 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2598 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2599 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2600 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2602 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2603 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2604 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2607 // Atomic compare and swap.
2608 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
2609 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
2610 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
2611 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
2613 let Defs = [EAX, EBX, ECX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
2614 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
2615 "lock\n\tcmpxchg8b\t$ptr",
2616 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2619 let Defs = [AX, EFLAGS], Uses = [AX] in {
2620 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
2621 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
2622 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
2624 let Defs = [AL, EFLAGS], Uses = [AL] in {
2625 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
2626 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
2627 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
2630 // Atomic exchange and add
2631 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2632 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2633 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
2634 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
2636 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2637 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
2638 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
2640 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2641 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
2642 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
2646 // Atomic exchange, and, or, xor
2647 let Constraints = "$val = $dst", Defs = [EFLAGS],
2648 usesCustomDAGSchedInserter = 1 in {
2649 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2650 "#ATOMAND32 PSUEDO!",
2651 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
2652 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2653 "#ATOMOR32 PSUEDO!",
2654 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
2655 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2656 "#ATOMXOR32 PSUEDO!",
2657 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
2658 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2659 "#ATOMNAND32 PSUEDO!",
2660 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
2661 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2662 "#ATOMMIN32 PSUEDO!",
2663 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
2664 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2665 "#ATOMMAX32 PSUEDO!",
2666 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
2667 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2668 "#ATOMUMIN32 PSUEDO!",
2669 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
2670 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2671 "#ATOMUMAX32 PSUEDO!",
2672 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
2674 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2675 "#ATOMAND16 PSUEDO!",
2676 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
2677 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2678 "#ATOMOR16 PSUEDO!",
2679 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
2680 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2681 "#ATOMXOR16 PSUEDO!",
2682 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
2683 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2684 "#ATOMNAND16 PSUEDO!",
2685 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
2686 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2687 "#ATOMMIN16 PSUEDO!",
2688 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
2689 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2690 "#ATOMMAX16 PSUEDO!",
2691 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
2692 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2693 "#ATOMUMIN16 PSUEDO!",
2694 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
2695 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2696 "#ATOMUMAX16 PSUEDO!",
2697 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
2699 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2700 "#ATOMAND8 PSUEDO!",
2701 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
2702 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2704 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
2705 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2706 "#ATOMXOR8 PSUEDO!",
2707 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
2708 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2709 "#ATOMNAND8 PSUEDO!",
2710 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
2713 //===----------------------------------------------------------------------===//
2714 // Non-Instruction Patterns
2715 //===----------------------------------------------------------------------===//
2717 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2718 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2719 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2720 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
2721 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2722 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2724 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2725 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2726 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2727 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2728 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2729 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2730 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2731 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2733 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2734 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2735 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2736 (MOV32mi addr:$dst, texternalsym:$src)>;
2740 def : Pat<(X86tailcall GR32:$dst),
2743 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2745 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2748 def : Pat<(X86tcret GR32:$dst, imm:$off),
2749 (TCRETURNri GR32:$dst, imm:$off)>;
2751 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2752 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2754 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2755 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2757 def : Pat<(X86call (i32 tglobaladdr:$dst)),
2758 (CALLpcrel32 tglobaladdr:$dst)>;
2759 def : Pat<(X86call (i32 texternalsym:$dst)),
2760 (CALLpcrel32 texternalsym:$dst)>;
2762 // X86 specific add which produces a flag.
2763 def : Pat<(addc GR32:$src1, GR32:$src2),
2764 (ADD32rr GR32:$src1, GR32:$src2)>;
2765 def : Pat<(addc GR32:$src1, (load addr:$src2)),
2766 (ADD32rm GR32:$src1, addr:$src2)>;
2767 def : Pat<(addc GR32:$src1, imm:$src2),
2768 (ADD32ri GR32:$src1, imm:$src2)>;
2769 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2770 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2772 def : Pat<(subc GR32:$src1, GR32:$src2),
2773 (SUB32rr GR32:$src1, GR32:$src2)>;
2774 def : Pat<(subc GR32:$src1, (load addr:$src2)),
2775 (SUB32rm GR32:$src1, addr:$src2)>;
2776 def : Pat<(subc GR32:$src1, imm:$src2),
2777 (SUB32ri GR32:$src1, imm:$src2)>;
2778 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2779 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2783 // TEST R,R is smaller than CMP R,0
2784 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
2785 (TEST8rr GR8:$src1, GR8:$src1)>;
2786 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
2787 (TEST16rr GR16:$src1, GR16:$src1)>;
2788 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
2789 (TEST32rr GR32:$src1, GR32:$src1)>;
2791 // zextload bool -> zextload byte
2792 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2793 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2794 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2796 // extload bool -> extload byte
2797 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2798 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
2799 Requires<[In32BitMode]>;
2800 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2801 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
2802 Requires<[In32BitMode]>;
2803 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2804 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2807 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
2808 Requires<[In32BitMode]>;
2809 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
2810 Requires<[In32BitMode]>;
2811 def : Pat<(i32 (anyext GR16:$src)),
2812 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
2814 // (and (i32 load), 255) -> (zextload i8)
2815 def : Pat<(i32 (and (loadi32 addr:$src), (i32 255))), (MOVZX32rm8 addr:$src)>;
2816 def : Pat<(i32 (and (loadi32 addr:$src), (i32 65535))),(MOVZX32rm16 addr:$src)>;
2818 //===----------------------------------------------------------------------===//
2820 //===----------------------------------------------------------------------===//
2822 // r & (2^16-1) ==> movz
2823 def : Pat<(and GR32:$src1, 0xffff),
2824 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
2825 // r & (2^8-1) ==> movz
2826 def : Pat<(and GR32:$src1, 0xff),
2827 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
2828 x86_subreg_8bit)))>,
2829 Requires<[In32BitMode]>;
2830 // r & (2^8-1) ==> movz
2831 def : Pat<(and GR16:$src1, 0xff),
2832 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
2833 x86_subreg_8bit)))>,
2834 Requires<[In32BitMode]>;
2836 // sext_inreg patterns
2837 def : Pat<(sext_inreg GR32:$src, i16),
2838 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
2839 def : Pat<(sext_inreg GR32:$src, i8),
2840 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
2841 x86_subreg_8bit)))>,
2842 Requires<[In32BitMode]>;
2843 def : Pat<(sext_inreg GR16:$src, i8),
2844 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
2845 x86_subreg_8bit)))>,
2846 Requires<[In32BitMode]>;
2849 def : Pat<(i16 (trunc GR32:$src)),
2850 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
2851 def : Pat<(i8 (trunc GR32:$src)),
2852 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
2853 Requires<[In32BitMode]>;
2854 def : Pat<(i8 (trunc GR16:$src)),
2855 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
2856 Requires<[In32BitMode]>;
2858 // (shl x, 1) ==> (add x, x)
2859 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2860 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2861 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2863 // (shl x (and y, 31)) ==> (shl x, y)
2864 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
2865 (SHL8rCL GR8:$src1)>;
2866 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
2867 (SHL16rCL GR16:$src1)>;
2868 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
2869 (SHL32rCL GR32:$src1)>;
2870 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2871 (SHL8mCL addr:$dst)>;
2872 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2873 (SHL16mCL addr:$dst)>;
2874 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2875 (SHL32mCL addr:$dst)>;
2877 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
2878 (SHR8rCL GR8:$src1)>;
2879 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
2880 (SHR16rCL GR16:$src1)>;
2881 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
2882 (SHR32rCL GR32:$src1)>;
2883 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2884 (SHR8mCL addr:$dst)>;
2885 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2886 (SHR16mCL addr:$dst)>;
2887 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2888 (SHR32mCL addr:$dst)>;
2890 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
2891 (SAR8rCL GR8:$src1)>;
2892 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
2893 (SAR16rCL GR16:$src1)>;
2894 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
2895 (SAR32rCL GR32:$src1)>;
2896 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2897 (SAR8mCL addr:$dst)>;
2898 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2899 (SAR16mCL addr:$dst)>;
2900 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2901 (SAR32mCL addr:$dst)>;
2903 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2904 def : Pat<(or (srl GR32:$src1, CL:$amt),
2905 (shl GR32:$src2, (sub 32, CL:$amt))),
2906 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2908 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2909 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2910 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2912 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2913 def : Pat<(or (shl GR32:$src1, CL:$amt),
2914 (srl GR32:$src2, (sub 32, CL:$amt))),
2915 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2917 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2918 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2919 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2921 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2922 def : Pat<(or (srl GR16:$src1, CL:$amt),
2923 (shl GR16:$src2, (sub 16, CL:$amt))),
2924 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2926 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2927 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2928 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2930 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2931 def : Pat<(or (shl GR16:$src1, CL:$amt),
2932 (srl GR16:$src2, (sub 16, CL:$amt))),
2933 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2935 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2936 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2937 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2939 //===----------------------------------------------------------------------===//
2940 // Floating Point Stack Support
2941 //===----------------------------------------------------------------------===//
2943 include "X86InstrFPStack.td"
2945 //===----------------------------------------------------------------------===//
2947 //===----------------------------------------------------------------------===//
2949 include "X86Instr64bit.td"
2951 //===----------------------------------------------------------------------===//
2952 // XMM Floating point support (requires SSE / SSE2)
2953 //===----------------------------------------------------------------------===//
2955 include "X86InstrSSE.td"
2957 //===----------------------------------------------------------------------===//
2958 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2959 //===----------------------------------------------------------------------===//
2961 include "X86InstrMMX.td"