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 // Unary and binary operator instructions that set EFLAGS as a side-effect.
31 def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
33 def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
38 def SDTX86BrCond : SDTypeProfile<0, 3,
39 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
42 def SDTX86SetCC : SDTypeProfile<1, 2,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
46 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
48 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
50 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
51 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
52 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
54 def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
55 def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
58 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
60 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
62 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
64 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
66 def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
68 def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
70 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
72 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
74 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
75 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
76 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
77 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
79 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
81 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
83 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
84 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
86 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
88 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
91 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
94 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
95 [SDNPHasChain, SDNPMayStore,
96 SDNPMayLoad, SDNPMemOperand]>;
97 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
112 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
115 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
116 [SDNPHasChain, SDNPOptInFlag]>;
118 def X86callseq_start :
119 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
120 [SDNPHasChain, SDNPOutFlag]>;
122 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
123 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
125 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
126 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
128 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
129 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
131 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
133 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
134 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
137 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
138 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
140 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
141 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
143 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
144 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
145 def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
147 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
150 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
151 [SDNPHasChain, SDNPOptInFlag]>;
153 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
154 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
155 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
156 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
157 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
158 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
160 //===----------------------------------------------------------------------===//
161 // X86 Operand Definitions.
164 // *mem - Operand definitions for the funky X86 addressing mode operands.
166 class X86MemOperand<string printMethod> : Operand<iPTR> {
167 let PrintMethod = printMethod;
168 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
171 def i8mem : X86MemOperand<"printi8mem">;
172 def i16mem : X86MemOperand<"printi16mem">;
173 def i32mem : X86MemOperand<"printi32mem">;
174 def i64mem : X86MemOperand<"printi64mem">;
175 def i128mem : X86MemOperand<"printi128mem">;
176 def f32mem : X86MemOperand<"printf32mem">;
177 def f64mem : X86MemOperand<"printf64mem">;
178 def f80mem : X86MemOperand<"printf80mem">;
179 def f128mem : X86MemOperand<"printf128mem">;
181 def lea32mem : Operand<i32> {
182 let PrintMethod = "printi32mem";
183 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
186 def SSECC : Operand<i8> {
187 let PrintMethod = "printSSECC";
190 def piclabel: Operand<i32> {
191 let PrintMethod = "printPICLabel";
194 // A couple of more descriptive operand definitions.
195 // 16-bits but only 8 bits are significant.
196 def i16i8imm : Operand<i16>;
197 // 32-bits but only 8 bits are significant.
198 def i32i8imm : Operand<i32>;
200 // Branch targets have OtherVT type.
201 def brtarget : Operand<OtherVT>;
203 //===----------------------------------------------------------------------===//
204 // X86 Complex Pattern Definitions.
207 // Define X86 specific addressing mode.
208 def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
209 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
210 [add, mul, shl, or, frameindex], []>;
212 //===----------------------------------------------------------------------===//
213 // X86 Instruction Predicate Definitions.
214 def HasMMX : Predicate<"Subtarget->hasMMX()">;
215 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
216 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
217 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
218 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
219 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
220 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
221 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
222 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
223 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
224 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
225 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
226 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
227 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
228 def OptForSpeed : Predicate<"!OptForSize">;
229 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
231 //===----------------------------------------------------------------------===//
232 // X86 Instruction Format Definitions.
235 include "X86InstrFormats.td"
237 //===----------------------------------------------------------------------===//
238 // Pattern fragments...
241 // X86 specific condition code. These correspond to CondCode in
242 // X86InstrInfo.h. They must be kept in synch.
243 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
244 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
245 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
246 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
247 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
248 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
249 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
250 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
251 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
252 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
253 def X86_COND_NO : PatLeaf<(i8 10)>;
254 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
255 def X86_COND_NS : PatLeaf<(i8 12)>;
256 def X86_COND_O : PatLeaf<(i8 13)>;
257 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
258 def X86_COND_S : PatLeaf<(i8 15)>;
260 def i16immSExt8 : PatLeaf<(i16 imm), [{
261 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
262 // sign extended field.
263 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
266 def i32immSExt8 : PatLeaf<(i32 imm), [{
267 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
268 // sign extended field.
269 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
272 // Helper fragments for loads.
273 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
274 // known to be 32-bit aligned or better. Ditto for i8 to i16.
275 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
276 LoadSDNode *LD = cast<LoadSDNode>(N);
277 ISD::LoadExtType ExtType = LD->getExtensionType();
278 if (ExtType == ISD::NON_EXTLOAD)
280 if (ExtType == ISD::EXTLOAD)
281 return LD->getAlignment() >= 2 && !LD->isVolatile();
285 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
286 LoadSDNode *LD = cast<LoadSDNode>(N);
287 ISD::LoadExtType ExtType = LD->getExtensionType();
288 if (ExtType == ISD::EXTLOAD)
289 return LD->getAlignment() >= 2 && !LD->isVolatile();
293 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
294 LoadSDNode *LD = cast<LoadSDNode>(N);
295 ISD::LoadExtType ExtType = LD->getExtensionType();
296 if (ExtType == ISD::NON_EXTLOAD)
298 if (ExtType == ISD::EXTLOAD)
299 return LD->getAlignment() >= 4 && !LD->isVolatile();
303 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
304 LoadSDNode *LD = cast<LoadSDNode>(N);
305 if (LD->isVolatile())
307 ISD::LoadExtType ExtType = LD->getExtensionType();
308 if (ExtType == ISD::NON_EXTLOAD)
310 if (ExtType == ISD::EXTLOAD)
311 return LD->getAlignment() >= 4;
315 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
316 LoadSDNode *LD = cast<LoadSDNode>(N);
317 const Value *Src = LD->getSrcValue();
320 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
321 return PT->getAddressSpace() == 256;
325 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
326 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
328 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
329 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
330 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
332 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
333 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
334 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
336 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
337 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
338 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
339 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
340 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
341 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
343 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
344 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
345 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
346 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
347 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
348 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
351 // An 'and' node with a single use.
352 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
353 return N->hasOneUse();
356 // 'shld' and 'shrd' instruction patterns. Note that even though these have
357 // the srl and shl in their patterns, the C++ code must still check for them,
358 // because predicates are tested before children nodes are explored.
360 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
361 (or (srl node:$src1, node:$amt1),
362 (shl node:$src2, node:$amt2)), [{
363 assert(N->getOpcode() == ISD::OR);
364 return N->getOperand(0).getOpcode() == ISD::SRL &&
365 N->getOperand(1).getOpcode() == ISD::SHL &&
366 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
367 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
368 N->getOperand(0).getConstantOperandVal(1) ==
369 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
372 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
373 (or (shl node:$src1, node:$amt1),
374 (srl node:$src2, node:$amt2)), [{
375 assert(N->getOpcode() == ISD::OR);
376 return N->getOperand(0).getOpcode() == ISD::SHL &&
377 N->getOperand(1).getOpcode() == ISD::SRL &&
378 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
379 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
380 N->getOperand(0).getConstantOperandVal(1) ==
381 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
384 //===----------------------------------------------------------------------===//
385 // Instruction list...
388 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
389 // a stack adjustment and the codegen must know that they may modify the stack
390 // pointer before prolog-epilog rewriting occurs.
391 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
392 // sub / add which can clobber EFLAGS.
393 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
394 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
396 [(X86callseq_start timm:$amt)]>,
397 Requires<[In32BitMode]>;
398 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
400 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
401 Requires<[In32BitMode]>;
405 let neverHasSideEffects = 1 in
406 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
409 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
410 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
411 "call\t$label\n\tpop{l}\t$reg", []>;
413 //===----------------------------------------------------------------------===//
414 // Control Flow Instructions...
417 // Return instructions.
418 let isTerminator = 1, isReturn = 1, isBarrier = 1,
419 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
420 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
423 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
425 [(X86retflag imm:$amt)]>;
428 // All branches are RawFrm, Void, Branch, and Terminators
429 let isBranch = 1, isTerminator = 1 in
430 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
431 I<opcode, RawFrm, (outs), ins, asm, pattern>;
433 let isBranch = 1, isBarrier = 1 in
434 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
437 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
438 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
439 [(brind GR32:$dst)]>;
440 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
441 [(brind (loadi32 addr:$dst))]>;
444 // Conditional branches
445 let Uses = [EFLAGS] in {
446 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
447 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
448 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
449 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
450 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
451 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
452 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
453 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
454 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
455 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
456 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
457 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
459 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
460 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
461 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
462 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
463 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
464 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
465 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
466 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
468 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
469 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
470 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
471 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
472 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
473 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
474 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
475 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
476 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
477 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
478 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
479 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
482 //===----------------------------------------------------------------------===//
483 // Call Instructions...
486 // All calls clobber the non-callee saved registers. ESP is marked as
487 // a use to prevent stack-pointer assignments that appear immediately
488 // before calls from potentially appearing dead. Uses for argument
489 // registers are added manually.
490 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
491 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
492 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
493 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
495 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
496 "call\t${dst:call}", [(X86call imm:$dst)]>,
497 Requires<[In32BitMode]>;
498 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
499 "call\t{*}$dst", [(X86call GR32:$dst)]>;
500 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
501 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
506 def TAILCALL : I<0, Pseudo, (outs), (ins),
510 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
511 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
512 "#TC_RETURN $dst $offset",
515 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
516 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
517 "#TC_RETURN $dst $offset",
520 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
522 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
524 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
525 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
527 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
528 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
529 "jmp\t{*}$dst # TAILCALL", []>;
531 //===----------------------------------------------------------------------===//
532 // Miscellaneous Instructions...
534 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
535 def LEAVE : I<0xC9, RawFrm,
536 (outs), (ins), "leave", []>;
538 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
540 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
543 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
546 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
547 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
548 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
549 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
551 let isTwoAddress = 1 in // GR32 = bswap GR32
552 def BSWAP32r : I<0xC8, AddRegFrm,
553 (outs GR32:$dst), (ins GR32:$src),
555 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
558 // Bit scan instructions.
559 let Defs = [EFLAGS] in {
560 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
561 "bsf{w}\t{$src, $dst|$dst, $src}",
562 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
563 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
564 "bsf{w}\t{$src, $dst|$dst, $src}",
565 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
566 (implicit EFLAGS)]>, TB;
567 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
568 "bsf{l}\t{$src, $dst|$dst, $src}",
569 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
570 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
571 "bsf{l}\t{$src, $dst|$dst, $src}",
572 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
573 (implicit EFLAGS)]>, TB;
575 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
576 "bsr{w}\t{$src, $dst|$dst, $src}",
577 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
578 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
579 "bsr{w}\t{$src, $dst|$dst, $src}",
580 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
581 (implicit EFLAGS)]>, TB;
582 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
583 "bsr{l}\t{$src, $dst|$dst, $src}",
584 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
585 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
586 "bsr{l}\t{$src, $dst|$dst, $src}",
587 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
588 (implicit EFLAGS)]>, TB;
591 let neverHasSideEffects = 1 in
592 def LEA16r : I<0x8D, MRMSrcMem,
593 (outs GR16:$dst), (ins i32mem:$src),
594 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
595 let isReMaterializable = 1 in
596 def LEA32r : I<0x8D, MRMSrcMem,
597 (outs GR32:$dst), (ins lea32mem:$src),
598 "lea{l}\t{$src|$dst}, {$dst|$src}",
599 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
601 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
602 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
603 [(X86rep_movs i8)]>, REP;
604 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
605 [(X86rep_movs i16)]>, REP, OpSize;
606 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
607 [(X86rep_movs i32)]>, REP;
610 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
611 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
612 [(X86rep_stos i8)]>, REP;
613 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
614 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
615 [(X86rep_stos i16)]>, REP, OpSize;
616 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
617 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
618 [(X86rep_stos i32)]>, REP;
620 let Defs = [RAX, RDX] in
621 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
624 let isBarrier = 1, hasCtrlDep = 1 in {
625 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
628 //===----------------------------------------------------------------------===//
629 // Input/Output Instructions...
631 let Defs = [AL], Uses = [DX] in
632 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
633 "in{b}\t{%dx, %al|%AL, %DX}", []>;
634 let Defs = [AX], Uses = [DX] in
635 def IN16rr : I<0xED, RawFrm, (outs), (ins),
636 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
637 let Defs = [EAX], Uses = [DX] in
638 def IN32rr : I<0xED, RawFrm, (outs), (ins),
639 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
642 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
643 "in{b}\t{$port, %al|%AL, $port}", []>;
645 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
646 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
648 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
649 "in{l}\t{$port, %eax|%EAX, $port}", []>;
651 let Uses = [DX, AL] in
652 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
653 "out{b}\t{%al, %dx|%DX, %AL}", []>;
654 let Uses = [DX, AX] in
655 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
656 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
657 let Uses = [DX, EAX] in
658 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
659 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
662 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
663 "out{b}\t{%al, $port|$port, %AL}", []>;
665 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
666 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
668 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
669 "out{l}\t{%eax, $port|$port, %EAX}", []>;
671 //===----------------------------------------------------------------------===//
672 // Move Instructions...
674 let neverHasSideEffects = 1 in {
675 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
676 "mov{b}\t{$src, $dst|$dst, $src}", []>;
677 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
678 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
679 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
680 "mov{l}\t{$src, $dst|$dst, $src}", []>;
682 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
683 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
684 "mov{b}\t{$src, $dst|$dst, $src}",
685 [(set GR8:$dst, imm:$src)]>;
686 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
687 "mov{w}\t{$src, $dst|$dst, $src}",
688 [(set GR16:$dst, imm:$src)]>, OpSize;
689 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
690 "mov{l}\t{$src, $dst|$dst, $src}",
691 [(set GR32:$dst, imm:$src)]>;
693 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
694 "mov{b}\t{$src, $dst|$dst, $src}",
695 [(store (i8 imm:$src), addr:$dst)]>;
696 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
697 "mov{w}\t{$src, $dst|$dst, $src}",
698 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
699 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
700 "mov{l}\t{$src, $dst|$dst, $src}",
701 [(store (i32 imm:$src), addr:$dst)]>;
703 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
704 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
705 "mov{b}\t{$src, $dst|$dst, $src}",
706 [(set GR8:$dst, (load addr:$src))]>;
707 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
708 "mov{w}\t{$src, $dst|$dst, $src}",
709 [(set GR16:$dst, (load addr:$src))]>, OpSize;
710 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
711 "mov{l}\t{$src, $dst|$dst, $src}",
712 [(set GR32:$dst, (load addr:$src))]>;
715 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
716 "mov{b}\t{$src, $dst|$dst, $src}",
717 [(store GR8:$src, addr:$dst)]>;
718 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
719 "mov{w}\t{$src, $dst|$dst, $src}",
720 [(store GR16:$src, addr:$dst)]>, OpSize;
721 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
722 "mov{l}\t{$src, $dst|$dst, $src}",
723 [(store GR32:$src, addr:$dst)]>;
725 //===----------------------------------------------------------------------===//
726 // Fixed-Register Multiplication and Division Instructions...
729 // Extra precision multiplication
730 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
731 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
732 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
733 // This probably ought to be moved to a def : Pat<> if the
734 // syntax can be accepted.
735 [(set AL, (mul AL, GR8:$src)),
736 (implicit EFLAGS)]>; // AL,AH = AL*GR8
738 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
739 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
741 []>, OpSize; // AX,DX = AX*GR16
743 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
744 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
746 []>; // EAX,EDX = EAX*GR32
748 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
749 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
751 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
752 // This probably ought to be moved to a def : Pat<> if the
753 // syntax can be accepted.
754 [(set AL, (mul AL, (loadi8 addr:$src))),
755 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
757 let mayLoad = 1, neverHasSideEffects = 1 in {
758 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
759 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
761 []>, OpSize; // AX,DX = AX*[mem16]
763 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
764 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
766 []>; // EAX,EDX = EAX*[mem32]
769 let neverHasSideEffects = 1 in {
770 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
771 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
773 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
774 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
775 OpSize; // AX,DX = AX*GR16
776 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
777 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
778 // EAX,EDX = EAX*GR32
780 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
781 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
782 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
783 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
784 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
785 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
786 let Defs = [EAX,EDX], Uses = [EAX] in
787 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
788 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
790 } // neverHasSideEffects
792 // unsigned division/remainder
793 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
794 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
796 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
797 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
798 "div{w}\t$src", []>, OpSize;
799 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
800 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
803 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
804 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
806 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
807 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
808 "div{w}\t$src", []>, OpSize;
809 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
810 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
814 // Signed division/remainder.
815 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
816 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
817 "idiv{b}\t$src", []>;
818 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
819 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
820 "idiv{w}\t$src", []>, OpSize;
821 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
822 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
823 "idiv{l}\t$src", []>;
824 let mayLoad = 1, mayLoad = 1 in {
825 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
826 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
827 "idiv{b}\t$src", []>;
828 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
829 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
830 "idiv{w}\t$src", []>, OpSize;
831 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
832 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
833 "idiv{l}\t$src", []>;
836 //===----------------------------------------------------------------------===//
837 // Two address Instructions.
839 let isTwoAddress = 1 in {
842 let Uses = [EFLAGS] in {
843 let isCommutable = 1 in {
844 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
845 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
846 "cmovb\t{$src2, $dst|$dst, $src2}",
847 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
848 X86_COND_B, EFLAGS))]>,
850 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
851 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
852 "cmovb\t{$src2, $dst|$dst, $src2}",
853 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
854 X86_COND_B, EFLAGS))]>,
856 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
857 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
858 "cmovae\t{$src2, $dst|$dst, $src2}",
859 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
860 X86_COND_AE, EFLAGS))]>,
862 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
863 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
864 "cmovae\t{$src2, $dst|$dst, $src2}",
865 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
866 X86_COND_AE, EFLAGS))]>,
868 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
869 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
870 "cmove\t{$src2, $dst|$dst, $src2}",
871 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
872 X86_COND_E, EFLAGS))]>,
874 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
875 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
876 "cmove\t{$src2, $dst|$dst, $src2}",
877 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
878 X86_COND_E, EFLAGS))]>,
880 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
881 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
882 "cmovne\t{$src2, $dst|$dst, $src2}",
883 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
884 X86_COND_NE, EFLAGS))]>,
886 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
887 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
888 "cmovne\t{$src2, $dst|$dst, $src2}",
889 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
890 X86_COND_NE, EFLAGS))]>,
892 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
893 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
894 "cmovbe\t{$src2, $dst|$dst, $src2}",
895 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
896 X86_COND_BE, EFLAGS))]>,
898 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
899 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
900 "cmovbe\t{$src2, $dst|$dst, $src2}",
901 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
902 X86_COND_BE, EFLAGS))]>,
904 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
905 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
906 "cmova\t{$src2, $dst|$dst, $src2}",
907 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
908 X86_COND_A, EFLAGS))]>,
910 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
911 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
912 "cmova\t{$src2, $dst|$dst, $src2}",
913 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
914 X86_COND_A, EFLAGS))]>,
916 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
917 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
918 "cmovl\t{$src2, $dst|$dst, $src2}",
919 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
920 X86_COND_L, EFLAGS))]>,
922 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
923 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
924 "cmovl\t{$src2, $dst|$dst, $src2}",
925 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
926 X86_COND_L, EFLAGS))]>,
928 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
929 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
930 "cmovge\t{$src2, $dst|$dst, $src2}",
931 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
932 X86_COND_GE, EFLAGS))]>,
934 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
935 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
936 "cmovge\t{$src2, $dst|$dst, $src2}",
937 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
938 X86_COND_GE, EFLAGS))]>,
940 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
941 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
942 "cmovle\t{$src2, $dst|$dst, $src2}",
943 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
944 X86_COND_LE, EFLAGS))]>,
946 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
947 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
948 "cmovle\t{$src2, $dst|$dst, $src2}",
949 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
950 X86_COND_LE, EFLAGS))]>,
952 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
953 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
954 "cmovg\t{$src2, $dst|$dst, $src2}",
955 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
956 X86_COND_G, EFLAGS))]>,
958 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
959 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
960 "cmovg\t{$src2, $dst|$dst, $src2}",
961 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
962 X86_COND_G, EFLAGS))]>,
964 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
965 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
966 "cmovs\t{$src2, $dst|$dst, $src2}",
967 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
968 X86_COND_S, EFLAGS))]>,
970 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
971 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
972 "cmovs\t{$src2, $dst|$dst, $src2}",
973 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
974 X86_COND_S, EFLAGS))]>,
976 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
977 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
978 "cmovns\t{$src2, $dst|$dst, $src2}",
979 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
980 X86_COND_NS, EFLAGS))]>,
982 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
983 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
984 "cmovns\t{$src2, $dst|$dst, $src2}",
985 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
986 X86_COND_NS, EFLAGS))]>,
988 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
989 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
990 "cmovp\t{$src2, $dst|$dst, $src2}",
991 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
992 X86_COND_P, EFLAGS))]>,
994 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
995 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
996 "cmovp\t{$src2, $dst|$dst, $src2}",
997 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
998 X86_COND_P, EFLAGS))]>,
1000 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1001 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1002 "cmovnp\t{$src2, $dst|$dst, $src2}",
1003 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1004 X86_COND_NP, EFLAGS))]>,
1006 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1007 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1008 "cmovnp\t{$src2, $dst|$dst, $src2}",
1009 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1010 X86_COND_NP, EFLAGS))]>,
1012 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1013 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1014 "cmovo\t{$src2, $dst|$dst, $src2}",
1015 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1016 X86_COND_O, EFLAGS))]>,
1018 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1019 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1020 "cmovo\t{$src2, $dst|$dst, $src2}",
1021 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1022 X86_COND_O, EFLAGS))]>,
1024 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1025 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1026 "cmovno\t{$src2, $dst|$dst, $src2}",
1027 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1028 X86_COND_NO, EFLAGS))]>,
1030 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1031 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1032 "cmovno\t{$src2, $dst|$dst, $src2}",
1033 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1034 X86_COND_NO, EFLAGS))]>,
1036 } // isCommutable = 1
1038 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1039 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1040 "cmovb\t{$src2, $dst|$dst, $src2}",
1041 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1042 X86_COND_B, EFLAGS))]>,
1044 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1045 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1046 "cmovb\t{$src2, $dst|$dst, $src2}",
1047 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1048 X86_COND_B, EFLAGS))]>,
1050 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1051 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1052 "cmovae\t{$src2, $dst|$dst, $src2}",
1053 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1054 X86_COND_AE, EFLAGS))]>,
1056 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1057 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1058 "cmovae\t{$src2, $dst|$dst, $src2}",
1059 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1060 X86_COND_AE, EFLAGS))]>,
1062 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1063 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1064 "cmove\t{$src2, $dst|$dst, $src2}",
1065 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1066 X86_COND_E, EFLAGS))]>,
1068 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1069 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1070 "cmove\t{$src2, $dst|$dst, $src2}",
1071 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1072 X86_COND_E, EFLAGS))]>,
1074 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1075 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1076 "cmovne\t{$src2, $dst|$dst, $src2}",
1077 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1078 X86_COND_NE, EFLAGS))]>,
1080 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1081 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1082 "cmovne\t{$src2, $dst|$dst, $src2}",
1083 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1084 X86_COND_NE, EFLAGS))]>,
1086 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1087 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1088 "cmovbe\t{$src2, $dst|$dst, $src2}",
1089 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1090 X86_COND_BE, EFLAGS))]>,
1092 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1093 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1094 "cmovbe\t{$src2, $dst|$dst, $src2}",
1095 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1096 X86_COND_BE, EFLAGS))]>,
1098 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1099 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1100 "cmova\t{$src2, $dst|$dst, $src2}",
1101 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1102 X86_COND_A, EFLAGS))]>,
1104 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1105 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1106 "cmova\t{$src2, $dst|$dst, $src2}",
1107 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1108 X86_COND_A, EFLAGS))]>,
1110 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1111 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1112 "cmovl\t{$src2, $dst|$dst, $src2}",
1113 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1114 X86_COND_L, EFLAGS))]>,
1116 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1117 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1118 "cmovl\t{$src2, $dst|$dst, $src2}",
1119 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1120 X86_COND_L, EFLAGS))]>,
1122 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1123 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1124 "cmovge\t{$src2, $dst|$dst, $src2}",
1125 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1126 X86_COND_GE, EFLAGS))]>,
1128 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1129 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1130 "cmovge\t{$src2, $dst|$dst, $src2}",
1131 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1132 X86_COND_GE, EFLAGS))]>,
1134 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1135 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1136 "cmovle\t{$src2, $dst|$dst, $src2}",
1137 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1138 X86_COND_LE, EFLAGS))]>,
1140 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1141 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1142 "cmovle\t{$src2, $dst|$dst, $src2}",
1143 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1144 X86_COND_LE, EFLAGS))]>,
1146 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1147 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1148 "cmovg\t{$src2, $dst|$dst, $src2}",
1149 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1150 X86_COND_G, EFLAGS))]>,
1152 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1153 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1154 "cmovg\t{$src2, $dst|$dst, $src2}",
1155 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1156 X86_COND_G, EFLAGS))]>,
1158 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1159 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1160 "cmovs\t{$src2, $dst|$dst, $src2}",
1161 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1162 X86_COND_S, EFLAGS))]>,
1164 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1165 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1166 "cmovs\t{$src2, $dst|$dst, $src2}",
1167 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1168 X86_COND_S, EFLAGS))]>,
1170 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1171 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1172 "cmovns\t{$src2, $dst|$dst, $src2}",
1173 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1174 X86_COND_NS, EFLAGS))]>,
1176 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1177 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1178 "cmovns\t{$src2, $dst|$dst, $src2}",
1179 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1180 X86_COND_NS, EFLAGS))]>,
1182 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1183 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1184 "cmovp\t{$src2, $dst|$dst, $src2}",
1185 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1186 X86_COND_P, EFLAGS))]>,
1188 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1189 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1190 "cmovp\t{$src2, $dst|$dst, $src2}",
1191 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1192 X86_COND_P, EFLAGS))]>,
1194 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1195 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1196 "cmovnp\t{$src2, $dst|$dst, $src2}",
1197 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1198 X86_COND_NP, EFLAGS))]>,
1200 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1201 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1202 "cmovnp\t{$src2, $dst|$dst, $src2}",
1203 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1204 X86_COND_NP, EFLAGS))]>,
1206 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1207 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1208 "cmovo\t{$src2, $dst|$dst, $src2}",
1209 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1210 X86_COND_O, EFLAGS))]>,
1212 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1213 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1214 "cmovo\t{$src2, $dst|$dst, $src2}",
1215 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1216 X86_COND_O, EFLAGS))]>,
1218 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1219 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1220 "cmovno\t{$src2, $dst|$dst, $src2}",
1221 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1222 X86_COND_NO, EFLAGS))]>,
1224 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1225 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1226 "cmovno\t{$src2, $dst|$dst, $src2}",
1227 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1228 X86_COND_NO, EFLAGS))]>,
1230 } // Uses = [EFLAGS]
1233 // unary instructions
1234 let CodeSize = 2 in {
1235 let Defs = [EFLAGS] in {
1236 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1237 [(set GR8:$dst, (ineg GR8:$src)),
1238 (implicit EFLAGS)]>;
1239 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1240 [(set GR16:$dst, (ineg GR16:$src)),
1241 (implicit EFLAGS)]>, OpSize;
1242 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1243 [(set GR32:$dst, (ineg GR32:$src)),
1244 (implicit EFLAGS)]>;
1245 let isTwoAddress = 0 in {
1246 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1247 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1248 (implicit EFLAGS)]>;
1249 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1250 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1251 (implicit EFLAGS)]>, OpSize;
1252 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1253 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1254 (implicit EFLAGS)]>;
1256 } // Defs = [EFLAGS]
1258 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1259 let AddedComplexity = 15 in {
1260 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1261 [(set GR8:$dst, (not GR8:$src))]>;
1262 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1263 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1264 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1265 [(set GR32:$dst, (not GR32:$src))]>;
1267 let isTwoAddress = 0 in {
1268 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1269 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1270 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1271 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1272 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1273 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1277 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1278 let Defs = [EFLAGS] in {
1280 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1281 [(set GR8:$dst, (add GR8:$src, 1)),
1282 (implicit EFLAGS)]>;
1283 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1284 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1285 [(set GR16:$dst, (add GR16:$src, 1)),
1286 (implicit EFLAGS)]>,
1287 OpSize, Requires<[In32BitMode]>;
1288 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1289 [(set GR32:$dst, (add GR32:$src, 1)),
1290 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1292 let isTwoAddress = 0, CodeSize = 2 in {
1293 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1294 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1295 (implicit EFLAGS)]>;
1296 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1297 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1298 (implicit EFLAGS)]>,
1299 OpSize, Requires<[In32BitMode]>;
1300 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1301 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1302 (implicit EFLAGS)]>,
1303 Requires<[In32BitMode]>;
1307 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1308 [(set GR8:$dst, (add GR8:$src, -1)),
1309 (implicit EFLAGS)]>;
1310 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1311 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1312 [(set GR16:$dst, (add GR16:$src, -1)),
1313 (implicit EFLAGS)]>,
1314 OpSize, Requires<[In32BitMode]>;
1315 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1316 [(set GR32:$dst, (add GR32:$src, -1)),
1317 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1320 let isTwoAddress = 0, CodeSize = 2 in {
1321 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1322 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1323 (implicit EFLAGS)]>;
1324 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1325 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1326 (implicit EFLAGS)]>,
1327 OpSize, Requires<[In32BitMode]>;
1328 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1329 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1330 (implicit EFLAGS)]>,
1331 Requires<[In32BitMode]>;
1333 } // Defs = [EFLAGS]
1335 // Logical operators...
1336 let Defs = [EFLAGS] in {
1337 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1338 def AND8rr : I<0x20, MRMDestReg,
1339 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1340 "and{b}\t{$src2, $dst|$dst, $src2}",
1341 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1342 (implicit EFLAGS)]>;
1343 def AND16rr : I<0x21, MRMDestReg,
1344 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1345 "and{w}\t{$src2, $dst|$dst, $src2}",
1346 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1347 (implicit EFLAGS)]>, OpSize;
1348 def AND32rr : I<0x21, MRMDestReg,
1349 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1350 "and{l}\t{$src2, $dst|$dst, $src2}",
1351 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1352 (implicit EFLAGS)]>;
1355 def AND8rm : I<0x22, MRMSrcMem,
1356 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1357 "and{b}\t{$src2, $dst|$dst, $src2}",
1358 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))),
1359 (implicit EFLAGS)]>;
1360 def AND16rm : I<0x23, MRMSrcMem,
1361 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1362 "and{w}\t{$src2, $dst|$dst, $src2}",
1363 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))),
1364 (implicit EFLAGS)]>, OpSize;
1365 def AND32rm : I<0x23, MRMSrcMem,
1366 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1367 "and{l}\t{$src2, $dst|$dst, $src2}",
1368 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2))),
1369 (implicit EFLAGS)]>;
1371 def AND8ri : Ii8<0x80, MRM4r,
1372 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1373 "and{b}\t{$src2, $dst|$dst, $src2}",
1374 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1375 (implicit EFLAGS)]>;
1376 def AND16ri : Ii16<0x81, MRM4r,
1377 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1378 "and{w}\t{$src2, $dst|$dst, $src2}",
1379 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1380 (implicit EFLAGS)]>, OpSize;
1381 def AND32ri : Ii32<0x81, MRM4r,
1382 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1383 "and{l}\t{$src2, $dst|$dst, $src2}",
1384 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1385 (implicit EFLAGS)]>;
1386 def AND16ri8 : Ii8<0x83, MRM4r,
1387 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1388 "and{w}\t{$src2, $dst|$dst, $src2}",
1389 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1390 (implicit EFLAGS)]>,
1392 def AND32ri8 : Ii8<0x83, MRM4r,
1393 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1394 "and{l}\t{$src2, $dst|$dst, $src2}",
1395 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1396 (implicit EFLAGS)]>;
1398 let isTwoAddress = 0 in {
1399 def AND8mr : I<0x20, MRMDestMem,
1400 (outs), (ins i8mem :$dst, GR8 :$src),
1401 "and{b}\t{$src, $dst|$dst, $src}",
1402 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1403 (implicit EFLAGS)]>;
1404 def AND16mr : I<0x21, MRMDestMem,
1405 (outs), (ins i16mem:$dst, GR16:$src),
1406 "and{w}\t{$src, $dst|$dst, $src}",
1407 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1408 (implicit EFLAGS)]>,
1410 def AND32mr : I<0x21, MRMDestMem,
1411 (outs), (ins i32mem:$dst, GR32:$src),
1412 "and{l}\t{$src, $dst|$dst, $src}",
1413 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1414 (implicit EFLAGS)]>;
1415 def AND8mi : Ii8<0x80, MRM4m,
1416 (outs), (ins i8mem :$dst, i8imm :$src),
1417 "and{b}\t{$src, $dst|$dst, $src}",
1418 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1419 (implicit EFLAGS)]>;
1420 def AND16mi : Ii16<0x81, MRM4m,
1421 (outs), (ins i16mem:$dst, i16imm:$src),
1422 "and{w}\t{$src, $dst|$dst, $src}",
1423 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1424 (implicit EFLAGS)]>,
1426 def AND32mi : Ii32<0x81, MRM4m,
1427 (outs), (ins i32mem:$dst, i32imm:$src),
1428 "and{l}\t{$src, $dst|$dst, $src}",
1429 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1430 (implicit EFLAGS)]>;
1431 def AND16mi8 : Ii8<0x83, MRM4m,
1432 (outs), (ins i16mem:$dst, i16i8imm :$src),
1433 "and{w}\t{$src, $dst|$dst, $src}",
1434 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1435 (implicit EFLAGS)]>,
1437 def AND32mi8 : Ii8<0x83, MRM4m,
1438 (outs), (ins i32mem:$dst, i32i8imm :$src),
1439 "and{l}\t{$src, $dst|$dst, $src}",
1440 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1441 (implicit EFLAGS)]>;
1445 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1446 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1447 "or{b}\t{$src2, $dst|$dst, $src2}",
1448 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1449 (implicit EFLAGS)]>;
1450 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1451 "or{w}\t{$src2, $dst|$dst, $src2}",
1452 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1453 (implicit EFLAGS)]>, OpSize;
1454 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1455 "or{l}\t{$src2, $dst|$dst, $src2}",
1456 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1457 (implicit EFLAGS)]>;
1459 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1460 "or{b}\t{$src2, $dst|$dst, $src2}",
1461 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1462 (implicit EFLAGS)]>;
1463 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1464 "or{w}\t{$src2, $dst|$dst, $src2}",
1465 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1466 (implicit EFLAGS)]>, OpSize;
1467 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1468 "or{l}\t{$src2, $dst|$dst, $src2}",
1469 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1470 (implicit EFLAGS)]>;
1472 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1473 "or{b}\t{$src2, $dst|$dst, $src2}",
1474 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1475 (implicit EFLAGS)]>;
1476 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1477 "or{w}\t{$src2, $dst|$dst, $src2}",
1478 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1479 (implicit EFLAGS)]>, OpSize;
1480 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1481 "or{l}\t{$src2, $dst|$dst, $src2}",
1482 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1483 (implicit EFLAGS)]>;
1485 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1486 "or{w}\t{$src2, $dst|$dst, $src2}",
1487 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1488 (implicit EFLAGS)]>, OpSize;
1489 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1490 "or{l}\t{$src2, $dst|$dst, $src2}",
1491 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1492 (implicit EFLAGS)]>;
1493 let isTwoAddress = 0 in {
1494 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1495 "or{b}\t{$src, $dst|$dst, $src}",
1496 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1497 (implicit EFLAGS)]>;
1498 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1499 "or{w}\t{$src, $dst|$dst, $src}",
1500 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1501 (implicit EFLAGS)]>, OpSize;
1502 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1503 "or{l}\t{$src, $dst|$dst, $src}",
1504 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1505 (implicit EFLAGS)]>;
1506 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1507 "or{b}\t{$src, $dst|$dst, $src}",
1508 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1509 (implicit EFLAGS)]>;
1510 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1511 "or{w}\t{$src, $dst|$dst, $src}",
1512 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1513 (implicit EFLAGS)]>,
1515 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1516 "or{l}\t{$src, $dst|$dst, $src}",
1517 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1518 (implicit EFLAGS)]>;
1519 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1520 "or{w}\t{$src, $dst|$dst, $src}",
1521 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1522 (implicit EFLAGS)]>,
1524 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1525 "or{l}\t{$src, $dst|$dst, $src}",
1526 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1527 (implicit EFLAGS)]>;
1528 } // isTwoAddress = 0
1531 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1532 def XOR8rr : I<0x30, MRMDestReg,
1533 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1534 "xor{b}\t{$src2, $dst|$dst, $src2}",
1535 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1536 (implicit EFLAGS)]>;
1537 def XOR16rr : I<0x31, MRMDestReg,
1538 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1539 "xor{w}\t{$src2, $dst|$dst, $src2}",
1540 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1541 (implicit EFLAGS)]>, OpSize;
1542 def XOR32rr : I<0x31, MRMDestReg,
1543 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1544 "xor{l}\t{$src2, $dst|$dst, $src2}",
1545 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1546 (implicit EFLAGS)]>;
1547 } // isCommutable = 1
1549 def XOR8rm : I<0x32, MRMSrcMem ,
1550 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1551 "xor{b}\t{$src2, $dst|$dst, $src2}",
1552 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1553 (implicit EFLAGS)]>;
1554 def XOR16rm : I<0x33, MRMSrcMem ,
1555 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1556 "xor{w}\t{$src2, $dst|$dst, $src2}",
1557 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1558 (implicit EFLAGS)]>,
1560 def XOR32rm : I<0x33, MRMSrcMem ,
1561 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1562 "xor{l}\t{$src2, $dst|$dst, $src2}",
1563 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1564 (implicit EFLAGS)]>;
1566 def XOR8ri : Ii8<0x80, MRM6r,
1567 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1568 "xor{b}\t{$src2, $dst|$dst, $src2}",
1569 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1570 (implicit EFLAGS)]>;
1571 def XOR16ri : Ii16<0x81, MRM6r,
1572 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1573 "xor{w}\t{$src2, $dst|$dst, $src2}",
1574 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1575 (implicit EFLAGS)]>, OpSize;
1576 def XOR32ri : Ii32<0x81, MRM6r,
1577 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1578 "xor{l}\t{$src2, $dst|$dst, $src2}",
1579 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1580 (implicit EFLAGS)]>;
1581 def XOR16ri8 : Ii8<0x83, MRM6r,
1582 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1583 "xor{w}\t{$src2, $dst|$dst, $src2}",
1584 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1585 (implicit EFLAGS)]>,
1587 def XOR32ri8 : Ii8<0x83, MRM6r,
1588 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1589 "xor{l}\t{$src2, $dst|$dst, $src2}",
1590 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1591 (implicit EFLAGS)]>;
1593 let isTwoAddress = 0 in {
1594 def XOR8mr : I<0x30, MRMDestMem,
1595 (outs), (ins i8mem :$dst, GR8 :$src),
1596 "xor{b}\t{$src, $dst|$dst, $src}",
1597 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1598 (implicit EFLAGS)]>;
1599 def XOR16mr : I<0x31, MRMDestMem,
1600 (outs), (ins i16mem:$dst, GR16:$src),
1601 "xor{w}\t{$src, $dst|$dst, $src}",
1602 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1603 (implicit EFLAGS)]>,
1605 def XOR32mr : I<0x31, MRMDestMem,
1606 (outs), (ins i32mem:$dst, GR32:$src),
1607 "xor{l}\t{$src, $dst|$dst, $src}",
1608 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1609 (implicit EFLAGS)]>;
1610 def XOR8mi : Ii8<0x80, MRM6m,
1611 (outs), (ins i8mem :$dst, i8imm :$src),
1612 "xor{b}\t{$src, $dst|$dst, $src}",
1613 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1614 (implicit EFLAGS)]>;
1615 def XOR16mi : Ii16<0x81, MRM6m,
1616 (outs), (ins i16mem:$dst, i16imm:$src),
1617 "xor{w}\t{$src, $dst|$dst, $src}",
1618 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1619 (implicit EFLAGS)]>,
1621 def XOR32mi : Ii32<0x81, MRM6m,
1622 (outs), (ins i32mem:$dst, i32imm:$src),
1623 "xor{l}\t{$src, $dst|$dst, $src}",
1624 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1625 (implicit EFLAGS)]>;
1626 def XOR16mi8 : Ii8<0x83, MRM6m,
1627 (outs), (ins i16mem:$dst, i16i8imm :$src),
1628 "xor{w}\t{$src, $dst|$dst, $src}",
1629 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1630 (implicit EFLAGS)]>,
1632 def XOR32mi8 : Ii8<0x83, MRM6m,
1633 (outs), (ins i32mem:$dst, i32i8imm :$src),
1634 "xor{l}\t{$src, $dst|$dst, $src}",
1635 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1636 (implicit EFLAGS)]>;
1637 } // isTwoAddress = 0
1638 } // Defs = [EFLAGS]
1640 // Shift instructions
1641 let Defs = [EFLAGS] in {
1642 let Uses = [CL] in {
1643 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1644 "shl{b}\t{%cl, $dst|$dst, %CL}",
1645 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1646 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1647 "shl{w}\t{%cl, $dst|$dst, %CL}",
1648 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1649 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1650 "shl{l}\t{%cl, $dst|$dst, %CL}",
1651 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1654 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1655 "shl{b}\t{$src2, $dst|$dst, $src2}",
1656 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1657 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1658 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1659 "shl{w}\t{$src2, $dst|$dst, $src2}",
1660 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1661 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1662 "shl{l}\t{$src2, $dst|$dst, $src2}",
1663 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1664 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1666 } // isConvertibleToThreeAddress = 1
1668 let isTwoAddress = 0 in {
1669 let Uses = [CL] in {
1670 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1671 "shl{b}\t{%cl, $dst|$dst, %CL}",
1672 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1673 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1674 "shl{w}\t{%cl, $dst|$dst, %CL}",
1675 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1676 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1677 "shl{l}\t{%cl, $dst|$dst, %CL}",
1678 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1680 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1681 "shl{b}\t{$src, $dst|$dst, $src}",
1682 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1683 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1684 "shl{w}\t{$src, $dst|$dst, $src}",
1685 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1687 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1688 "shl{l}\t{$src, $dst|$dst, $src}",
1689 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1692 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1694 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1695 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1697 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1699 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1701 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1704 let Uses = [CL] in {
1705 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1706 "shr{b}\t{%cl, $dst|$dst, %CL}",
1707 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1708 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1709 "shr{w}\t{%cl, $dst|$dst, %CL}",
1710 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1711 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1712 "shr{l}\t{%cl, $dst|$dst, %CL}",
1713 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1716 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1717 "shr{b}\t{$src2, $dst|$dst, $src2}",
1718 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1719 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1720 "shr{w}\t{$src2, $dst|$dst, $src2}",
1721 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1722 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1723 "shr{l}\t{$src2, $dst|$dst, $src2}",
1724 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1727 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1729 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1730 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1732 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1733 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1735 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1737 let isTwoAddress = 0 in {
1738 let Uses = [CL] in {
1739 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1740 "shr{b}\t{%cl, $dst|$dst, %CL}",
1741 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1742 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1743 "shr{w}\t{%cl, $dst|$dst, %CL}",
1744 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1746 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1747 "shr{l}\t{%cl, $dst|$dst, %CL}",
1748 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1750 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1751 "shr{b}\t{$src, $dst|$dst, $src}",
1752 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1753 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1754 "shr{w}\t{$src, $dst|$dst, $src}",
1755 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1757 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1758 "shr{l}\t{$src, $dst|$dst, $src}",
1759 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1762 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1764 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1765 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1767 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1768 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1770 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1773 let Uses = [CL] in {
1774 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1775 "sar{b}\t{%cl, $dst|$dst, %CL}",
1776 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1777 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1778 "sar{w}\t{%cl, $dst|$dst, %CL}",
1779 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1780 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1781 "sar{l}\t{%cl, $dst|$dst, %CL}",
1782 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1785 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1786 "sar{b}\t{$src2, $dst|$dst, $src2}",
1787 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1788 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1789 "sar{w}\t{$src2, $dst|$dst, $src2}",
1790 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1792 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1793 "sar{l}\t{$src2, $dst|$dst, $src2}",
1794 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1797 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1799 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1800 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1802 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1803 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1805 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1807 let isTwoAddress = 0 in {
1808 let Uses = [CL] in {
1809 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1810 "sar{b}\t{%cl, $dst|$dst, %CL}",
1811 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1812 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1813 "sar{w}\t{%cl, $dst|$dst, %CL}",
1814 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1815 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1816 "sar{l}\t{%cl, $dst|$dst, %CL}",
1817 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1819 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1820 "sar{b}\t{$src, $dst|$dst, $src}",
1821 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1822 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1823 "sar{w}\t{$src, $dst|$dst, $src}",
1824 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1826 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1827 "sar{l}\t{$src, $dst|$dst, $src}",
1828 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1831 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1833 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1834 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1836 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1838 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1840 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1843 // Rotate instructions
1844 // FIXME: provide shorter instructions when imm8 == 1
1845 let Uses = [CL] in {
1846 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1847 "rol{b}\t{%cl, $dst|$dst, %CL}",
1848 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1849 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1850 "rol{w}\t{%cl, $dst|$dst, %CL}",
1851 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1852 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1853 "rol{l}\t{%cl, $dst|$dst, %CL}",
1854 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1857 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1858 "rol{b}\t{$src2, $dst|$dst, $src2}",
1859 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1860 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1861 "rol{w}\t{$src2, $dst|$dst, $src2}",
1862 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1863 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1864 "rol{l}\t{$src2, $dst|$dst, $src2}",
1865 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1868 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1870 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1871 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1873 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1874 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1876 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1878 let isTwoAddress = 0 in {
1879 let Uses = [CL] in {
1880 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1881 "rol{b}\t{%cl, $dst|$dst, %CL}",
1882 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
1883 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1884 "rol{w}\t{%cl, $dst|$dst, %CL}",
1885 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1886 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1887 "rol{l}\t{%cl, $dst|$dst, %CL}",
1888 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1890 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
1891 "rol{b}\t{$src, $dst|$dst, $src}",
1892 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1893 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
1894 "rol{w}\t{$src, $dst|$dst, $src}",
1895 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1897 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
1898 "rol{l}\t{$src, $dst|$dst, $src}",
1899 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1902 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
1904 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1905 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
1907 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1909 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
1911 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1914 let Uses = [CL] in {
1915 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
1916 "ror{b}\t{%cl, $dst|$dst, %CL}",
1917 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
1918 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
1919 "ror{w}\t{%cl, $dst|$dst, %CL}",
1920 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
1921 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
1922 "ror{l}\t{%cl, $dst|$dst, %CL}",
1923 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1926 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1927 "ror{b}\t{$src2, $dst|$dst, $src2}",
1928 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1929 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1930 "ror{w}\t{$src2, $dst|$dst, $src2}",
1931 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1932 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1933 "ror{l}\t{$src2, $dst|$dst, $src2}",
1934 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1937 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1939 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1940 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
1942 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1943 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
1945 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1947 let isTwoAddress = 0 in {
1948 let Uses = [CL] in {
1949 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
1950 "ror{b}\t{%cl, $dst|$dst, %CL}",
1951 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
1952 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
1953 "ror{w}\t{%cl, $dst|$dst, %CL}",
1954 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1955 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
1956 "ror{l}\t{%cl, $dst|$dst, %CL}",
1957 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1959 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1960 "ror{b}\t{$src, $dst|$dst, $src}",
1961 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1962 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
1963 "ror{w}\t{$src, $dst|$dst, $src}",
1964 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1966 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
1967 "ror{l}\t{$src, $dst|$dst, $src}",
1968 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1971 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
1973 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1974 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
1976 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1978 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
1980 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1985 // Double shift instructions (generalizations of rotate)
1986 let Uses = [CL] in {
1987 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1988 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1989 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
1990 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1991 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1992 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
1993 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1994 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1995 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1997 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1998 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1999 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2003 let isCommutable = 1 in { // These instructions commute to each other.
2004 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2005 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2006 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2007 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2010 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2011 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2012 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2013 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2016 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2017 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2018 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2019 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2022 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2023 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2024 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2025 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2030 let isTwoAddress = 0 in {
2031 let Uses = [CL] in {
2032 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2033 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2034 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2036 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2037 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2038 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2041 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2042 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2043 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2044 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2045 (i8 imm:$src3)), addr:$dst)]>,
2047 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2048 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2049 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2050 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2051 (i8 imm:$src3)), addr:$dst)]>,
2054 let Uses = [CL] in {
2055 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2056 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2057 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2058 addr:$dst)]>, TB, OpSize;
2059 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2060 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2061 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2062 addr:$dst)]>, TB, OpSize;
2064 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2065 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2066 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2067 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2068 (i8 imm:$src3)), addr:$dst)]>,
2070 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2071 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2072 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2073 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2074 (i8 imm:$src3)), addr:$dst)]>,
2077 } // Defs = [EFLAGS]
2081 let Defs = [EFLAGS] in {
2082 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2083 // Register-Register Addition
2084 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2085 (ins GR8 :$src1, GR8 :$src2),
2086 "add{b}\t{$src2, $dst|$dst, $src2}",
2087 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2088 (implicit EFLAGS)]>;
2090 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2091 // Register-Register Addition
2092 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2093 (ins GR16:$src1, GR16:$src2),
2094 "add{w}\t{$src2, $dst|$dst, $src2}",
2095 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2096 (implicit EFLAGS)]>, OpSize;
2097 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2098 (ins GR32:$src1, GR32:$src2),
2099 "add{l}\t{$src2, $dst|$dst, $src2}",
2100 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2101 (implicit EFLAGS)]>;
2102 } // end isConvertibleToThreeAddress
2103 } // end isCommutable
2105 // Register-Memory Addition
2106 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2107 (ins GR8 :$src1, i8mem :$src2),
2108 "add{b}\t{$src2, $dst|$dst, $src2}",
2109 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2110 (implicit EFLAGS)]>;
2111 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2112 (ins GR16:$src1, i16mem:$src2),
2113 "add{w}\t{$src2, $dst|$dst, $src2}",
2114 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2115 (implicit EFLAGS)]>, OpSize;
2116 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2117 (ins GR32:$src1, i32mem:$src2),
2118 "add{l}\t{$src2, $dst|$dst, $src2}",
2119 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2120 (implicit EFLAGS)]>;
2122 // Register-Integer Addition
2123 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2124 "add{b}\t{$src2, $dst|$dst, $src2}",
2125 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2126 (implicit EFLAGS)]>;
2128 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2129 // Register-Integer Addition
2130 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2131 (ins GR16:$src1, i16imm:$src2),
2132 "add{w}\t{$src2, $dst|$dst, $src2}",
2133 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2134 (implicit EFLAGS)]>, OpSize;
2135 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2136 (ins GR32:$src1, i32imm:$src2),
2137 "add{l}\t{$src2, $dst|$dst, $src2}",
2138 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2139 (implicit EFLAGS)]>;
2140 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2141 (ins GR16:$src1, i16i8imm:$src2),
2142 "add{w}\t{$src2, $dst|$dst, $src2}",
2143 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2144 (implicit EFLAGS)]>, OpSize;
2145 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2146 (ins GR32:$src1, i32i8imm:$src2),
2147 "add{l}\t{$src2, $dst|$dst, $src2}",
2148 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2149 (implicit EFLAGS)]>;
2152 let isTwoAddress = 0 in {
2153 // Memory-Register Addition
2154 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2155 "add{b}\t{$src2, $dst|$dst, $src2}",
2156 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2157 (implicit EFLAGS)]>;
2158 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2159 "add{w}\t{$src2, $dst|$dst, $src2}",
2160 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2161 (implicit EFLAGS)]>, OpSize;
2162 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2163 "add{l}\t{$src2, $dst|$dst, $src2}",
2164 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2165 (implicit EFLAGS)]>;
2166 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2167 "add{b}\t{$src2, $dst|$dst, $src2}",
2168 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2169 (implicit EFLAGS)]>;
2170 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2171 "add{w}\t{$src2, $dst|$dst, $src2}",
2172 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2173 (implicit EFLAGS)]>, OpSize;
2174 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2175 "add{l}\t{$src2, $dst|$dst, $src2}",
2176 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2177 (implicit EFLAGS)]>;
2178 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2179 "add{w}\t{$src2, $dst|$dst, $src2}",
2180 [(store (add (load addr:$dst), i16immSExt8:$src2),
2182 (implicit EFLAGS)]>, OpSize;
2183 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2184 "add{l}\t{$src2, $dst|$dst, $src2}",
2185 [(store (add (load addr:$dst), i32immSExt8:$src2),
2187 (implicit EFLAGS)]>;
2190 let Uses = [EFLAGS] in {
2191 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2192 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2193 "adc{l}\t{$src2, $dst|$dst, $src2}",
2194 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2196 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2197 "adc{l}\t{$src2, $dst|$dst, $src2}",
2198 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2199 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2200 "adc{l}\t{$src2, $dst|$dst, $src2}",
2201 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2202 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2203 "adc{l}\t{$src2, $dst|$dst, $src2}",
2204 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2206 let isTwoAddress = 0 in {
2207 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2208 "adc{l}\t{$src2, $dst|$dst, $src2}",
2209 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2210 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2211 "adc{l}\t{$src2, $dst|$dst, $src2}",
2212 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2213 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2214 "adc{l}\t{$src2, $dst|$dst, $src2}",
2215 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2217 } // Uses = [EFLAGS]
2219 // Register-Register Subtraction
2220 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2221 "sub{b}\t{$src2, $dst|$dst, $src2}",
2222 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2223 (implicit EFLAGS)]>;
2224 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2225 "sub{w}\t{$src2, $dst|$dst, $src2}",
2226 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2227 (implicit EFLAGS)]>, OpSize;
2228 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2229 "sub{l}\t{$src2, $dst|$dst, $src2}",
2230 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2231 (implicit EFLAGS)]>;
2233 // Register-Memory Subtraction
2234 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2235 (ins GR8 :$src1, i8mem :$src2),
2236 "sub{b}\t{$src2, $dst|$dst, $src2}",
2237 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2238 (implicit EFLAGS)]>;
2239 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2240 (ins GR16:$src1, i16mem:$src2),
2241 "sub{w}\t{$src2, $dst|$dst, $src2}",
2242 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2243 (implicit EFLAGS)]>, OpSize;
2244 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2245 (ins GR32:$src1, i32mem:$src2),
2246 "sub{l}\t{$src2, $dst|$dst, $src2}",
2247 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2248 (implicit EFLAGS)]>;
2250 // Register-Integer Subtraction
2251 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2252 (ins GR8:$src1, i8imm:$src2),
2253 "sub{b}\t{$src2, $dst|$dst, $src2}",
2254 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2255 (implicit EFLAGS)]>;
2256 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2257 (ins GR16:$src1, i16imm:$src2),
2258 "sub{w}\t{$src2, $dst|$dst, $src2}",
2259 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2260 (implicit EFLAGS)]>, OpSize;
2261 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2262 (ins GR32:$src1, i32imm:$src2),
2263 "sub{l}\t{$src2, $dst|$dst, $src2}",
2264 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2265 (implicit EFLAGS)]>;
2266 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2267 (ins GR16:$src1, i16i8imm:$src2),
2268 "sub{w}\t{$src2, $dst|$dst, $src2}",
2269 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2270 (implicit EFLAGS)]>, OpSize;
2271 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2272 (ins GR32:$src1, i32i8imm:$src2),
2273 "sub{l}\t{$src2, $dst|$dst, $src2}",
2274 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2275 (implicit EFLAGS)]>;
2277 let isTwoAddress = 0 in {
2278 // Memory-Register Subtraction
2279 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2280 "sub{b}\t{$src2, $dst|$dst, $src2}",
2281 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2282 (implicit EFLAGS)]>;
2283 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2284 "sub{w}\t{$src2, $dst|$dst, $src2}",
2285 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2286 (implicit EFLAGS)]>, OpSize;
2287 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2288 "sub{l}\t{$src2, $dst|$dst, $src2}",
2289 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2290 (implicit EFLAGS)]>;
2292 // Memory-Integer Subtraction
2293 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2294 "sub{b}\t{$src2, $dst|$dst, $src2}",
2295 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2296 (implicit EFLAGS)]>;
2297 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2298 "sub{w}\t{$src2, $dst|$dst, $src2}",
2299 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2300 (implicit EFLAGS)]>, OpSize;
2301 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2302 "sub{l}\t{$src2, $dst|$dst, $src2}",
2303 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2304 (implicit EFLAGS)]>;
2305 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2306 "sub{w}\t{$src2, $dst|$dst, $src2}",
2307 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2309 (implicit EFLAGS)]>, OpSize;
2310 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2311 "sub{l}\t{$src2, $dst|$dst, $src2}",
2312 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2314 (implicit EFLAGS)]>;
2317 let Uses = [EFLAGS] in {
2318 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2319 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2320 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2322 let isTwoAddress = 0 in {
2323 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2324 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2325 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2326 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2327 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2328 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2329 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2330 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2331 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2332 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2333 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2334 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2336 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2337 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2338 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2339 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2340 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2341 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2342 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2343 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2344 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2345 } // Uses = [EFLAGS]
2346 } // Defs = [EFLAGS]
2348 let Defs = [EFLAGS] in {
2349 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2350 // Register-Register Signed Integer Multiply
2351 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2352 "imul{w}\t{$src2, $dst|$dst, $src2}",
2353 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2354 (implicit EFLAGS)]>, TB, OpSize;
2355 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2356 "imul{l}\t{$src2, $dst|$dst, $src2}",
2357 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2358 (implicit EFLAGS)]>, TB;
2361 // Register-Memory Signed Integer Multiply
2362 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2363 (ins GR16:$src1, i16mem:$src2),
2364 "imul{w}\t{$src2, $dst|$dst, $src2}",
2365 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2366 (implicit EFLAGS)]>, TB, OpSize;
2367 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2368 "imul{l}\t{$src2, $dst|$dst, $src2}",
2369 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2370 (implicit EFLAGS)]>, TB;
2371 } // Defs = [EFLAGS]
2372 } // end Two Address instructions
2374 // Suprisingly enough, these are not two address instructions!
2375 let Defs = [EFLAGS] in {
2376 // Register-Integer Signed Integer Multiply
2377 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2378 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2379 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2380 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2381 (implicit EFLAGS)]>, OpSize;
2382 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2383 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2384 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2385 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2386 (implicit EFLAGS)]>;
2387 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2388 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2389 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2390 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2391 (implicit EFLAGS)]>, OpSize;
2392 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2393 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2394 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2395 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2396 (implicit EFLAGS)]>;
2398 // Memory-Integer Signed Integer Multiply
2399 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2400 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2401 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2402 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2403 (implicit EFLAGS)]>, OpSize;
2404 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2405 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2406 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2407 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2408 (implicit EFLAGS)]>;
2409 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2410 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2411 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2412 [(set GR16:$dst, (mul (load addr:$src1),
2413 i16immSExt8:$src2)),
2414 (implicit EFLAGS)]>, OpSize;
2415 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2416 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2417 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2418 [(set GR32:$dst, (mul (load addr:$src1),
2419 i32immSExt8:$src2)),
2420 (implicit EFLAGS)]>;
2421 } // Defs = [EFLAGS]
2423 //===----------------------------------------------------------------------===//
2424 // Test instructions are just like AND, except they don't generate a result.
2426 let Defs = [EFLAGS] in {
2427 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2428 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2429 "test{b}\t{$src2, $src1|$src1, $src2}",
2430 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2431 (implicit EFLAGS)]>;
2432 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2433 "test{w}\t{$src2, $src1|$src1, $src2}",
2434 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2435 (implicit EFLAGS)]>,
2437 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2438 "test{l}\t{$src2, $src1|$src1, $src2}",
2439 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2440 (implicit EFLAGS)]>;
2443 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2444 "test{b}\t{$src2, $src1|$src1, $src2}",
2445 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2446 (implicit EFLAGS)]>;
2447 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2448 "test{w}\t{$src2, $src1|$src1, $src2}",
2449 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2450 (implicit EFLAGS)]>, OpSize;
2451 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2452 "test{l}\t{$src2, $src1|$src1, $src2}",
2453 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2454 (implicit EFLAGS)]>;
2456 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2457 (outs), (ins GR8:$src1, i8imm:$src2),
2458 "test{b}\t{$src2, $src1|$src1, $src2}",
2459 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2460 (implicit EFLAGS)]>;
2461 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2462 (outs), (ins GR16:$src1, i16imm:$src2),
2463 "test{w}\t{$src2, $src1|$src1, $src2}",
2464 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2465 (implicit EFLAGS)]>, OpSize;
2466 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2467 (outs), (ins GR32:$src1, i32imm:$src2),
2468 "test{l}\t{$src2, $src1|$src1, $src2}",
2469 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2470 (implicit EFLAGS)]>;
2472 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2473 (outs), (ins i8mem:$src1, i8imm:$src2),
2474 "test{b}\t{$src2, $src1|$src1, $src2}",
2475 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2476 (implicit EFLAGS)]>;
2477 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2478 (outs), (ins i16mem:$src1, i16imm:$src2),
2479 "test{w}\t{$src2, $src1|$src1, $src2}",
2480 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2481 (implicit EFLAGS)]>, OpSize;
2482 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2483 (outs), (ins i32mem:$src1, i32imm:$src2),
2484 "test{l}\t{$src2, $src1|$src1, $src2}",
2485 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2486 (implicit EFLAGS)]>;
2487 } // Defs = [EFLAGS]
2490 // Condition code ops, incl. set if equal/not equal/...
2491 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2492 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2493 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2494 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2496 let Uses = [EFLAGS] in {
2497 def SETEr : I<0x94, MRM0r,
2498 (outs GR8 :$dst), (ins),
2500 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2502 def SETEm : I<0x94, MRM0m,
2503 (outs), (ins i8mem:$dst),
2505 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2508 def SETNEr : I<0x95, MRM0r,
2509 (outs GR8 :$dst), (ins),
2511 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2513 def SETNEm : I<0x95, MRM0m,
2514 (outs), (ins i8mem:$dst),
2516 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2519 def SETLr : I<0x9C, MRM0r,
2520 (outs GR8 :$dst), (ins),
2522 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2523 TB; // GR8 = < signed
2524 def SETLm : I<0x9C, MRM0m,
2525 (outs), (ins i8mem:$dst),
2527 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2528 TB; // [mem8] = < signed
2530 def SETGEr : I<0x9D, MRM0r,
2531 (outs GR8 :$dst), (ins),
2533 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2534 TB; // GR8 = >= signed
2535 def SETGEm : I<0x9D, MRM0m,
2536 (outs), (ins i8mem:$dst),
2538 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2539 TB; // [mem8] = >= signed
2541 def SETLEr : I<0x9E, MRM0r,
2542 (outs GR8 :$dst), (ins),
2544 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2545 TB; // GR8 = <= signed
2546 def SETLEm : I<0x9E, MRM0m,
2547 (outs), (ins i8mem:$dst),
2549 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2550 TB; // [mem8] = <= signed
2552 def SETGr : I<0x9F, MRM0r,
2553 (outs GR8 :$dst), (ins),
2555 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2556 TB; // GR8 = > signed
2557 def SETGm : I<0x9F, MRM0m,
2558 (outs), (ins i8mem:$dst),
2560 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2561 TB; // [mem8] = > signed
2563 def SETBr : I<0x92, MRM0r,
2564 (outs GR8 :$dst), (ins),
2566 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2567 TB; // GR8 = < unsign
2568 def SETBm : I<0x92, MRM0m,
2569 (outs), (ins i8mem:$dst),
2571 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2572 TB; // [mem8] = < unsign
2574 def SETAEr : I<0x93, MRM0r,
2575 (outs GR8 :$dst), (ins),
2577 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2578 TB; // GR8 = >= unsign
2579 def SETAEm : I<0x93, MRM0m,
2580 (outs), (ins i8mem:$dst),
2582 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2583 TB; // [mem8] = >= unsign
2585 def SETBEr : I<0x96, MRM0r,
2586 (outs GR8 :$dst), (ins),
2588 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2589 TB; // GR8 = <= unsign
2590 def SETBEm : I<0x96, MRM0m,
2591 (outs), (ins i8mem:$dst),
2593 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2594 TB; // [mem8] = <= unsign
2596 def SETAr : I<0x97, MRM0r,
2597 (outs GR8 :$dst), (ins),
2599 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2600 TB; // GR8 = > signed
2601 def SETAm : I<0x97, MRM0m,
2602 (outs), (ins i8mem:$dst),
2604 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2605 TB; // [mem8] = > signed
2607 def SETSr : I<0x98, MRM0r,
2608 (outs GR8 :$dst), (ins),
2610 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2611 TB; // GR8 = <sign bit>
2612 def SETSm : I<0x98, MRM0m,
2613 (outs), (ins i8mem:$dst),
2615 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2616 TB; // [mem8] = <sign bit>
2617 def SETNSr : I<0x99, MRM0r,
2618 (outs GR8 :$dst), (ins),
2620 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2621 TB; // GR8 = !<sign bit>
2622 def SETNSm : I<0x99, MRM0m,
2623 (outs), (ins i8mem:$dst),
2625 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2626 TB; // [mem8] = !<sign bit>
2628 def SETPr : I<0x9A, MRM0r,
2629 (outs GR8 :$dst), (ins),
2631 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2633 def SETPm : I<0x9A, MRM0m,
2634 (outs), (ins i8mem:$dst),
2636 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2637 TB; // [mem8] = parity
2638 def SETNPr : I<0x9B, MRM0r,
2639 (outs GR8 :$dst), (ins),
2641 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2642 TB; // GR8 = not parity
2643 def SETNPm : I<0x9B, MRM0m,
2644 (outs), (ins i8mem:$dst),
2646 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2647 TB; // [mem8] = not parity
2649 def SETOr : I<0x90, MRM0r,
2650 (outs GR8 :$dst), (ins),
2652 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2653 TB; // GR8 = overflow
2654 def SETOm : I<0x90, MRM0m,
2655 (outs), (ins i8mem:$dst),
2657 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2658 TB; // [mem8] = overflow
2659 def SETNOr : I<0x91, MRM0r,
2660 (outs GR8 :$dst), (ins),
2662 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2663 TB; // GR8 = not overflow
2664 def SETNOm : I<0x91, MRM0m,
2665 (outs), (ins i8mem:$dst),
2667 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2668 TB; // [mem8] = not overflow
2669 } // Uses = [EFLAGS]
2672 // Integer comparisons
2673 let Defs = [EFLAGS] in {
2674 def CMP8rr : I<0x38, MRMDestReg,
2675 (outs), (ins GR8 :$src1, GR8 :$src2),
2676 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2677 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2678 def CMP16rr : I<0x39, MRMDestReg,
2679 (outs), (ins GR16:$src1, GR16:$src2),
2680 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2681 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2682 def CMP32rr : I<0x39, MRMDestReg,
2683 (outs), (ins GR32:$src1, GR32:$src2),
2684 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2685 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2686 def CMP8mr : I<0x38, MRMDestMem,
2687 (outs), (ins i8mem :$src1, GR8 :$src2),
2688 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2689 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2690 (implicit EFLAGS)]>;
2691 def CMP16mr : I<0x39, MRMDestMem,
2692 (outs), (ins i16mem:$src1, GR16:$src2),
2693 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2694 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2695 (implicit EFLAGS)]>, OpSize;
2696 def CMP32mr : I<0x39, MRMDestMem,
2697 (outs), (ins i32mem:$src1, GR32:$src2),
2698 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2699 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2700 (implicit EFLAGS)]>;
2701 def CMP8rm : I<0x3A, MRMSrcMem,
2702 (outs), (ins GR8 :$src1, i8mem :$src2),
2703 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2704 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2705 (implicit EFLAGS)]>;
2706 def CMP16rm : I<0x3B, MRMSrcMem,
2707 (outs), (ins GR16:$src1, i16mem:$src2),
2708 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2709 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2710 (implicit EFLAGS)]>, OpSize;
2711 def CMP32rm : I<0x3B, MRMSrcMem,
2712 (outs), (ins GR32:$src1, i32mem:$src2),
2713 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2714 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2715 (implicit EFLAGS)]>;
2716 def CMP8ri : Ii8<0x80, MRM7r,
2717 (outs), (ins GR8:$src1, i8imm:$src2),
2718 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2719 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
2720 def CMP16ri : Ii16<0x81, MRM7r,
2721 (outs), (ins GR16:$src1, i16imm:$src2),
2722 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2723 [(X86cmp GR16:$src1, imm:$src2),
2724 (implicit EFLAGS)]>, OpSize;
2725 def CMP32ri : Ii32<0x81, MRM7r,
2726 (outs), (ins GR32:$src1, i32imm:$src2),
2727 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2728 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
2729 def CMP8mi : Ii8 <0x80, MRM7m,
2730 (outs), (ins i8mem :$src1, i8imm :$src2),
2731 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2732 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2733 (implicit EFLAGS)]>;
2734 def CMP16mi : Ii16<0x81, MRM7m,
2735 (outs), (ins i16mem:$src1, i16imm:$src2),
2736 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2737 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2738 (implicit EFLAGS)]>, OpSize;
2739 def CMP32mi : Ii32<0x81, MRM7m,
2740 (outs), (ins i32mem:$src1, i32imm:$src2),
2741 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2742 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2743 (implicit EFLAGS)]>;
2744 def CMP16ri8 : Ii8<0x83, MRM7r,
2745 (outs), (ins GR16:$src1, i16i8imm:$src2),
2746 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2747 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2748 (implicit EFLAGS)]>, OpSize;
2749 def CMP16mi8 : Ii8<0x83, MRM7m,
2750 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2751 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2752 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2753 (implicit EFLAGS)]>, OpSize;
2754 def CMP32mi8 : Ii8<0x83, MRM7m,
2755 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2756 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2757 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2758 (implicit EFLAGS)]>;
2759 def CMP32ri8 : Ii8<0x83, MRM7r,
2760 (outs), (ins GR32:$src1, i32i8imm:$src2),
2761 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2762 [(X86cmp GR32:$src1, i32immSExt8:$src2),
2763 (implicit EFLAGS)]>;
2764 } // Defs = [EFLAGS]
2767 // TODO: BTC, BTR, and BTS
2768 let Defs = [EFLAGS] in {
2769 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2770 "bt{w}\t{$src2, $src1|$src1, $src2}",
2771 [(X86bt GR16:$src1, GR16:$src2),
2772 (implicit EFLAGS)]>, OpSize, TB;
2773 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2774 "bt{l}\t{$src2, $src1|$src1, $src2}",
2775 [(X86bt GR32:$src1, GR32:$src2),
2776 (implicit EFLAGS)]>, TB;
2778 // Unlike with the register+register form, the memory+register form of the
2779 // bt instruction does not ignore the high bits of the index. From ISel's
2780 // perspective, this is pretty bizarre. Disable these instructions for now.
2781 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2782 // "bt{w}\t{$src2, $src1|$src1, $src2}",
2783 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
2784 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2785 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2786 // "bt{l}\t{$src2, $src1|$src1, $src2}",
2787 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
2788 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
2790 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2791 "bt{w}\t{$src2, $src1|$src1, $src2}",
2792 [(X86bt GR16:$src1, i16immSExt8:$src2),
2793 (implicit EFLAGS)]>, OpSize, TB;
2794 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2795 "bt{l}\t{$src2, $src1|$src1, $src2}",
2796 [(X86bt GR32:$src1, i32immSExt8:$src2),
2797 (implicit EFLAGS)]>, TB;
2798 // Note that these instructions don't need FastBTMem because that
2799 // only applies when the other operand is in a register. When it's
2800 // an immediate, bt is still fast.
2801 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2802 "bt{w}\t{$src2, $src1|$src1, $src2}",
2803 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2804 (implicit EFLAGS)]>, OpSize, TB;
2805 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2806 "bt{l}\t{$src2, $src1|$src1, $src2}",
2807 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2808 (implicit EFLAGS)]>, TB;
2809 } // Defs = [EFLAGS]
2811 // Sign/Zero extenders
2812 // Use movsbl intead of movsbw; we don't care about the high 16 bits
2813 // of the register here. This has a smaller encoding and avoids a
2814 // partial-register update.
2815 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2816 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2817 [(set GR16:$dst, (sext GR8:$src))]>, TB;
2818 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2819 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2820 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
2821 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2822 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2823 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2824 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2825 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2826 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2827 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2828 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2829 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2830 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2831 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2832 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2834 // Use movzbl intead of movzbw; we don't care about the high 16 bits
2835 // of the register here. This has a smaller encoding and avoids a
2836 // partial-register update.
2837 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2838 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2839 [(set GR16:$dst, (zext GR8:$src))]>, TB;
2840 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2841 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2842 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
2843 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2844 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2845 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2846 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2847 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2848 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2849 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2850 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2851 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2852 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2853 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2854 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2856 let neverHasSideEffects = 1 in {
2857 let Defs = [AX], Uses = [AL] in
2858 def CBW : I<0x98, RawFrm, (outs), (ins),
2859 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2860 let Defs = [EAX], Uses = [AX] in
2861 def CWDE : I<0x98, RawFrm, (outs), (ins),
2862 "{cwtl|cwde}", []>; // EAX = signext(AX)
2864 let Defs = [AX,DX], Uses = [AX] in
2865 def CWD : I<0x99, RawFrm, (outs), (ins),
2866 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2867 let Defs = [EAX,EDX], Uses = [EAX] in
2868 def CDQ : I<0x99, RawFrm, (outs), (ins),
2869 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2872 //===----------------------------------------------------------------------===//
2873 // Alias Instructions
2874 //===----------------------------------------------------------------------===//
2876 // Alias instructions that map movr0 to xor.
2877 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2878 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2879 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
2880 "xor{b}\t$dst, $dst",
2881 [(set GR8:$dst, 0)]>;
2882 // Use xorl instead of xorw since we don't care about the high 16 bits,
2883 // it's smaller, and it avoids a partial-register update.
2884 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
2885 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2886 [(set GR16:$dst, 0)]>;
2887 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
2888 "xor{l}\t$dst, $dst",
2889 [(set GR32:$dst, 0)]>;
2892 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2893 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2894 let neverHasSideEffects = 1, isAsCheapAsAMove = 1 in {
2895 def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
2896 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2897 def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
2898 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2900 def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
2901 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2902 def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
2903 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2904 } // neverHasSideEffects
2906 let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
2907 def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
2908 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2909 def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
2910 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2912 let mayStore = 1, neverHasSideEffects = 1 in {
2913 def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
2914 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2915 def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
2916 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2919 //===----------------------------------------------------------------------===//
2920 // Thread Local Storage Instructions
2924 def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2925 "leal\t${sym:mem}(,%ebx,1), $dst",
2926 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
2928 let AddedComplexity = 10 in
2929 def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
2930 "movl\t%gs:($src), $dst",
2931 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2933 let AddedComplexity = 15 in
2934 def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2935 "movl\t%gs:${src:mem}, $dst",
2937 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
2940 let AddedComplexity = 15 in
2941 def TLS_ext16_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2942 "movzwl\t%gs:${src:mem}, $dst",
2946 (X86Wrapper tglobaltlsaddr:$src))))]>,
2949 let AddedComplexity = 15 in
2950 def TLS_sext16_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2951 "movswl\t%gs:${src:mem}, $dst",
2955 (X86Wrapper tglobaltlsaddr:$src))))]>,
2958 let AddedComplexity = 15 in
2959 def TLS_zext16_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2960 "movzwl\t%gs:${src:mem}, $dst",
2964 (X86Wrapper tglobaltlsaddr:$src))))]>,
2967 let AddedComplexity = 15 in
2968 def TLS_ext8_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2969 "movzbl\t%gs:${src:mem}, $dst",
2973 (X86Wrapper tglobaltlsaddr:$src))))]>,
2976 let AddedComplexity = 15 in
2977 def TLS_sext8_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2978 "movsbl\t%gs:${src:mem}, $dst",
2982 (X86Wrapper tglobaltlsaddr:$src))))]>,
2985 let AddedComplexity = 15 in
2986 def TLS_zext8_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2987 "movzbl\t%gs:${src:mem}, $dst",
2991 (X86Wrapper tglobaltlsaddr:$src))))]>,
2994 def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
2995 "movl\t%gs:0, $dst",
2996 [(set GR32:$dst, X86TLStp)]>, SegGS;
2998 let AddedComplexity = 5 in
2999 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3000 "movl\t%gs:$src, $dst",
3001 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3003 //===----------------------------------------------------------------------===//
3004 // DWARF Pseudo Instructions
3007 def DWARF_LOC : I<0, Pseudo, (outs),
3008 (ins i32imm:$line, i32imm:$col, i32imm:$file),
3009 ".loc\t${file:debug} ${line:debug} ${col:debug}",
3010 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3013 //===----------------------------------------------------------------------===//
3014 // EH Pseudo Instructions
3016 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3018 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3019 "ret\t#eh_return, addr: $addr",
3020 [(X86ehret GR32:$addr)]>;
3024 //===----------------------------------------------------------------------===//
3028 // Atomic swap. These are just normal xchg instructions. But since a memory
3029 // operand is referenced, the atomicity is ensured.
3030 let Constraints = "$val = $dst" in {
3031 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3032 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3033 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3034 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3035 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3036 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3038 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3039 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3040 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3043 // Atomic compare and swap.
3044 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3045 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3046 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3047 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3049 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3050 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3051 "lock\n\tcmpxchg8b\t$ptr",
3052 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3055 let Defs = [AX, EFLAGS], Uses = [AX] in {
3056 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3057 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3058 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3060 let Defs = [AL, EFLAGS], Uses = [AL] in {
3061 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3062 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3063 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3066 // Atomic exchange and add
3067 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3068 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3069 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
3070 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3072 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3073 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
3074 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3076 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3077 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
3078 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3082 // Atomic exchange, and, or, xor
3083 let Constraints = "$val = $dst", Defs = [EFLAGS],
3084 usesCustomDAGSchedInserter = 1 in {
3085 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3086 "#ATOMAND32 PSEUDO!",
3087 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3088 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3089 "#ATOMOR32 PSEUDO!",
3090 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3091 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3092 "#ATOMXOR32 PSEUDO!",
3093 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3094 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3095 "#ATOMNAND32 PSEUDO!",
3096 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3097 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3098 "#ATOMMIN32 PSEUDO!",
3099 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3100 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3101 "#ATOMMAX32 PSEUDO!",
3102 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3103 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3104 "#ATOMUMIN32 PSEUDO!",
3105 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3106 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3107 "#ATOMUMAX32 PSEUDO!",
3108 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3110 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3111 "#ATOMAND16 PSEUDO!",
3112 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3113 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3114 "#ATOMOR16 PSEUDO!",
3115 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3116 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3117 "#ATOMXOR16 PSEUDO!",
3118 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3119 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3120 "#ATOMNAND16 PSEUDO!",
3121 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3122 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3123 "#ATOMMIN16 PSEUDO!",
3124 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3125 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3126 "#ATOMMAX16 PSEUDO!",
3127 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3128 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3129 "#ATOMUMIN16 PSEUDO!",
3130 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3131 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3132 "#ATOMUMAX16 PSEUDO!",
3133 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3135 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3136 "#ATOMAND8 PSEUDO!",
3137 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3138 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3140 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3141 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3142 "#ATOMXOR8 PSEUDO!",
3143 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3144 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3145 "#ATOMNAND8 PSEUDO!",
3146 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3149 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3150 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3151 Uses = [EAX, EBX, ECX, EDX],
3152 mayLoad = 1, mayStore = 1,
3153 usesCustomDAGSchedInserter = 1 in {
3154 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3155 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3156 "#ATOMAND6432 PSEUDO!", []>;
3157 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3158 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3159 "#ATOMOR6432 PSEUDO!", []>;
3160 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3161 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3162 "#ATOMXOR6432 PSEUDO!", []>;
3163 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3164 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3165 "#ATOMNAND6432 PSEUDO!", []>;
3166 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3167 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3168 "#ATOMADD6432 PSEUDO!", []>;
3169 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3170 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3171 "#ATOMSUB6432 PSEUDO!", []>;
3172 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3173 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3174 "#ATOMSWAP6432 PSEUDO!", []>;
3177 //===----------------------------------------------------------------------===//
3178 // Non-Instruction Patterns
3179 //===----------------------------------------------------------------------===//
3181 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3182 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3183 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3184 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3185 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3186 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3188 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3189 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3190 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3191 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3192 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3193 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3194 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3195 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3197 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3198 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3199 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3200 (MOV32mi addr:$dst, texternalsym:$src)>;
3204 def : Pat<(X86tailcall GR32:$dst),
3207 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
3209 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
3212 def : Pat<(X86tcret GR32:$dst, imm:$off),
3213 (TCRETURNri GR32:$dst, imm:$off)>;
3215 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3216 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3218 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3219 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3221 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3222 (CALLpcrel32 tglobaladdr:$dst)>;
3223 def : Pat<(X86call (i32 texternalsym:$dst)),
3224 (CALLpcrel32 texternalsym:$dst)>;
3226 // X86 specific add which produces a flag.
3227 def : Pat<(addc GR32:$src1, GR32:$src2),
3228 (ADD32rr GR32:$src1, GR32:$src2)>;
3229 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3230 (ADD32rm GR32:$src1, addr:$src2)>;
3231 def : Pat<(addc GR32:$src1, imm:$src2),
3232 (ADD32ri GR32:$src1, imm:$src2)>;
3233 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3234 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3236 def : Pat<(subc GR32:$src1, GR32:$src2),
3237 (SUB32rr GR32:$src1, GR32:$src2)>;
3238 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3239 (SUB32rm GR32:$src1, addr:$src2)>;
3240 def : Pat<(subc GR32:$src1, imm:$src2),
3241 (SUB32ri GR32:$src1, imm:$src2)>;
3242 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3243 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3247 // TEST R,R is smaller than CMP R,0
3248 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3249 (TEST8rr GR8:$src1, GR8:$src1)>;
3250 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3251 (TEST16rr GR16:$src1, GR16:$src1)>;
3252 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3253 (TEST32rr GR32:$src1, GR32:$src1)>;
3255 // Conditional moves with folded loads with operands swapped and conditions
3257 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3258 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3259 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3260 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3261 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3262 (CMOVB16rm GR16:$src2, addr:$src1)>;
3263 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3264 (CMOVB32rm GR32:$src2, addr:$src1)>;
3265 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3266 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3267 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3268 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3269 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3270 (CMOVE16rm GR16:$src2, addr:$src1)>;
3271 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3272 (CMOVE32rm GR32:$src2, addr:$src1)>;
3273 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3274 (CMOVA16rm GR16:$src2, addr:$src1)>;
3275 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3276 (CMOVA32rm GR32:$src2, addr:$src1)>;
3277 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3278 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3279 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3280 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3281 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3282 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3283 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3284 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3285 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3286 (CMOVL16rm GR16:$src2, addr:$src1)>;
3287 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3288 (CMOVL32rm GR32:$src2, addr:$src1)>;
3289 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3290 (CMOVG16rm GR16:$src2, addr:$src1)>;
3291 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3292 (CMOVG32rm GR32:$src2, addr:$src1)>;
3293 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3294 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3295 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3296 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3297 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3298 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3299 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3300 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3301 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3302 (CMOVP16rm GR16:$src2, addr:$src1)>;
3303 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3304 (CMOVP32rm GR32:$src2, addr:$src1)>;
3305 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3306 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3307 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3308 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3309 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3310 (CMOVS16rm GR16:$src2, addr:$src1)>;
3311 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3312 (CMOVS32rm GR32:$src2, addr:$src1)>;
3313 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3314 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3315 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3316 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3317 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3318 (CMOVO16rm GR16:$src2, addr:$src1)>;
3319 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3320 (CMOVO32rm GR32:$src2, addr:$src1)>;
3322 // zextload bool -> zextload byte
3323 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3324 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3325 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3327 // extload bool -> extload byte
3328 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3329 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3330 Requires<[In32BitMode]>;
3331 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3332 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3333 Requires<[In32BitMode]>;
3334 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3335 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3338 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3339 Requires<[In32BitMode]>;
3340 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3341 Requires<[In32BitMode]>;
3342 def : Pat<(i32 (anyext GR16:$src)),
3343 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
3345 // (and (i32 load), 255) -> (zextload i8)
3346 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3347 (MOVZX32rm8 addr:$src)>;
3348 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3349 (MOVZX32rm16 addr:$src)>;
3351 //===----------------------------------------------------------------------===//
3353 //===----------------------------------------------------------------------===//
3355 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3356 // +128 doesn't, so in this special case use a sub instead of an add.
3357 def : Pat<(add GR16:$src1, 128),
3358 (SUB16ri8 GR16:$src1, -128)>;
3359 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3360 (SUB16mi8 addr:$dst, -128)>;
3361 def : Pat<(add GR32:$src1, 128),
3362 (SUB32ri8 GR32:$src1, -128)>;
3363 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3364 (SUB32mi8 addr:$dst, -128)>;
3366 // r & (2^16-1) ==> movz
3367 def : Pat<(and GR32:$src1, 0xffff),
3368 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
3369 // r & (2^8-1) ==> movz
3370 def : Pat<(and GR32:$src1, 0xff),
3371 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3372 x86_subreg_8bit)))>,
3373 Requires<[In32BitMode]>;
3374 // r & (2^8-1) ==> movz
3375 def : Pat<(and GR16:$src1, 0xff),
3376 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3377 x86_subreg_8bit)))>,
3378 Requires<[In32BitMode]>;
3380 // sext_inreg patterns
3381 def : Pat<(sext_inreg GR32:$src, i16),
3382 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3383 def : Pat<(sext_inreg GR32:$src, i8),
3384 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3385 x86_subreg_8bit)))>,
3386 Requires<[In32BitMode]>;
3387 def : Pat<(sext_inreg GR16:$src, i8),
3388 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3389 x86_subreg_8bit)))>,
3390 Requires<[In32BitMode]>;
3393 def : Pat<(i16 (trunc GR32:$src)),
3394 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3395 def : Pat<(i8 (trunc GR32:$src)),
3396 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3397 Requires<[In32BitMode]>;
3398 def : Pat<(i8 (trunc GR16:$src)),
3399 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
3400 Requires<[In32BitMode]>;
3402 // (shl x, 1) ==> (add x, x)
3403 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3404 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3405 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3407 // (shl x (and y, 31)) ==> (shl x, y)
3408 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3409 (SHL8rCL GR8:$src1)>;
3410 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3411 (SHL16rCL GR16:$src1)>;
3412 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3413 (SHL32rCL GR32:$src1)>;
3414 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3415 (SHL8mCL addr:$dst)>;
3416 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3417 (SHL16mCL addr:$dst)>;
3418 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3419 (SHL32mCL addr:$dst)>;
3421 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3422 (SHR8rCL GR8:$src1)>;
3423 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3424 (SHR16rCL GR16:$src1)>;
3425 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3426 (SHR32rCL GR32:$src1)>;
3427 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3428 (SHR8mCL addr:$dst)>;
3429 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3430 (SHR16mCL addr:$dst)>;
3431 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3432 (SHR32mCL addr:$dst)>;
3434 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3435 (SAR8rCL GR8:$src1)>;
3436 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3437 (SAR16rCL GR16:$src1)>;
3438 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3439 (SAR32rCL GR32:$src1)>;
3440 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3441 (SAR8mCL addr:$dst)>;
3442 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3443 (SAR16mCL addr:$dst)>;
3444 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3445 (SAR32mCL addr:$dst)>;
3447 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3448 def : Pat<(or (srl GR32:$src1, CL:$amt),
3449 (shl GR32:$src2, (sub 32, CL:$amt))),
3450 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3452 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3453 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3454 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3456 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3457 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3458 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3460 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3461 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3463 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3465 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3466 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3468 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3469 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3470 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3472 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3473 def : Pat<(or (shl GR32:$src1, CL:$amt),
3474 (srl GR32:$src2, (sub 32, CL:$amt))),
3475 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3477 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3478 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3479 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3481 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3482 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3483 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3485 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3486 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3488 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3490 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3491 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3493 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3494 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3495 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3497 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3498 def : Pat<(or (srl GR16:$src1, CL:$amt),
3499 (shl GR16:$src2, (sub 16, CL:$amt))),
3500 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3502 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3503 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3504 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3506 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3507 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3508 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3510 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3511 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3513 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3515 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3516 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3518 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3519 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3520 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3522 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3523 def : Pat<(or (shl GR16:$src1, CL:$amt),
3524 (srl GR16:$src2, (sub 16, CL:$amt))),
3525 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3527 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3528 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3529 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3531 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3532 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3533 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3535 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3536 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3538 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3540 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3541 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3543 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3544 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3545 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3547 //===----------------------------------------------------------------------===//
3548 // EFLAGS-defining Patterns
3549 //===----------------------------------------------------------------------===//
3551 // Register-Register Addition with EFLAGS result
3552 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
3554 (ADD8rr GR8:$src1, GR8:$src2)>;
3556 // Register-Register Addition with EFLAGS result
3557 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
3559 (ADD16rr GR16:$src1, GR16:$src2)>;
3560 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
3562 (ADD32rr GR32:$src1, GR32:$src2)>;
3564 // Register-Memory Addition with EFLAGS result
3565 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
3567 (ADD8rm GR8:$src1, addr:$src2)>;
3568 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
3570 (ADD16rm GR16:$src1, addr:$src2)>;
3571 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
3573 (ADD32rm GR32:$src1, addr:$src2)>;
3575 // Register-Integer Addition with EFLAGS result
3576 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
3578 (ADD8ri GR8:$src1, imm:$src2)>;
3580 // Register-Integer Addition with EFLAGS result
3581 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
3583 (ADD16ri GR16:$src1, imm:$src2)>;
3584 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
3586 (ADD32ri GR32:$src1, imm:$src2)>;
3587 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
3589 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3590 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
3592 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3594 // Memory-Register Addition with EFLAGS result
3595 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
3598 (ADD8mr addr:$dst, GR8:$src2)>;
3599 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
3602 (ADD16mr addr:$dst, GR16:$src2)>;
3603 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
3606 (ADD32mr addr:$dst, GR32:$src2)>;
3607 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
3610 (ADD8mi addr:$dst, imm:$src2)>;
3611 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
3614 (ADD16mi addr:$dst, imm:$src2)>;
3615 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
3618 (ADD32mi addr:$dst, imm:$src2)>;
3619 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3622 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3623 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3626 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3628 // Register-Register Subtraction with EFLAGS result
3629 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
3631 (SUB8rr GR8:$src1, GR8:$src2)>;
3632 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
3634 (SUB16rr GR16:$src1, GR16:$src2)>;
3635 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
3637 (SUB32rr GR32:$src1, GR32:$src2)>;
3639 // Register-Memory Subtraction with EFLAGS result
3640 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
3642 (SUB8rm GR8:$src1, addr:$src2)>;
3643 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
3645 (SUB16rm GR16:$src1, addr:$src2)>;
3646 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
3648 (SUB32rm GR32:$src1, addr:$src2)>;
3650 // Register-Integer Subtraction with EFLAGS result
3651 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
3653 (SUB8ri GR8:$src1, imm:$src2)>;
3654 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
3656 (SUB16ri GR16:$src1, imm:$src2)>;
3657 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
3659 (SUB32ri GR32:$src1, imm:$src2)>;
3660 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
3662 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3663 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
3665 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3667 // Memory-Register Subtraction with EFLAGS result
3668 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
3671 (SUB8mr addr:$dst, GR8:$src2)>;
3672 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
3675 (SUB16mr addr:$dst, GR16:$src2)>;
3676 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
3679 (SUB32mr addr:$dst, GR32:$src2)>;
3681 // Memory-Integer Subtraction with EFLAGS result
3682 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
3685 (SUB8mi addr:$dst, imm:$src2)>;
3686 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
3689 (SUB16mi addr:$dst, imm:$src2)>;
3690 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
3693 (SUB32mi addr:$dst, imm:$src2)>;
3694 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3697 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3698 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3701 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3704 // Register-Register Signed Integer Multiply with EFLAGS result
3705 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
3707 (IMUL16rr GR16:$src1, GR16:$src2)>;
3708 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
3710 (IMUL32rr GR32:$src1, GR32:$src2)>;
3712 // Register-Memory Signed Integer Multiply with EFLAGS result
3713 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
3715 (IMUL16rm GR16:$src1, addr:$src2)>;
3716 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
3718 (IMUL32rm GR32:$src1, addr:$src2)>;
3720 // Register-Integer Signed Integer Multiply with EFLAGS result
3721 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
3723 (IMUL16rri GR16:$src1, imm:$src2)>;
3724 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
3726 (IMUL32rri GR32:$src1, imm:$src2)>;
3727 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
3729 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
3730 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
3732 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3734 // Memory-Integer Signed Integer Multiply with EFLAGS result
3735 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
3737 (IMUL16rmi addr:$src1, imm:$src2)>;
3738 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
3740 (IMUL32rmi addr:$src1, imm:$src2)>;
3741 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
3743 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
3744 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
3746 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3748 // Optimize multiply by 2 with EFLAGS result.
3749 let AddedComplexity = 2 in {
3750 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
3752 (ADD16rr GR16:$src1, GR16:$src1)>;
3754 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
3756 (ADD32rr GR32:$src1, GR32:$src1)>;
3759 // INC and DEC with EFLAGS result. Note that these do not set CF.
3760 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3762 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3765 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3767 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3771 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
3772 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
3773 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3775 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
3776 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
3777 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
3778 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3780 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
3782 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
3783 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
3784 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3786 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
3787 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
3788 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
3789 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3791 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
3793 //===----------------------------------------------------------------------===//
3794 // Floating Point Stack Support
3795 //===----------------------------------------------------------------------===//
3797 include "X86InstrFPStack.td"
3799 //===----------------------------------------------------------------------===//
3801 //===----------------------------------------------------------------------===//
3803 include "X86Instr64bit.td"
3805 //===----------------------------------------------------------------------===//
3806 // XMM Floating point support (requires SSE / SSE2)
3807 //===----------------------------------------------------------------------===//
3809 include "X86InstrSSE.td"
3811 //===----------------------------------------------------------------------===//
3812 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3813 //===----------------------------------------------------------------------===//
3815 include "X86InstrMMX.td"