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}", []>;
497 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
498 "call\t{*}$dst", [(X86call GR32:$dst)]>;
499 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
500 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
505 def TAILCALL : I<0, Pseudo, (outs), (ins),
509 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
510 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
511 "#TC_RETURN $dst $offset",
514 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
515 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
516 "#TC_RETURN $dst $offset",
519 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
521 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
523 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
524 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
526 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
527 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
528 "jmp\t{*}$dst # TAILCALL", []>;
530 //===----------------------------------------------------------------------===//
531 // Miscellaneous Instructions...
533 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
534 def LEAVE : I<0xC9, RawFrm,
535 (outs), (ins), "leave", []>;
537 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
539 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
542 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
545 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
546 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
547 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
548 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
550 let isTwoAddress = 1 in // GR32 = bswap GR32
551 def BSWAP32r : I<0xC8, AddRegFrm,
552 (outs GR32:$dst), (ins GR32:$src),
554 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
557 // Bit scan instructions.
558 let Defs = [EFLAGS] in {
559 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
560 "bsf{w}\t{$src, $dst|$dst, $src}",
561 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
562 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
563 "bsf{w}\t{$src, $dst|$dst, $src}",
564 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
565 (implicit EFLAGS)]>, TB;
566 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
567 "bsf{l}\t{$src, $dst|$dst, $src}",
568 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
569 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
570 "bsf{l}\t{$src, $dst|$dst, $src}",
571 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
572 (implicit EFLAGS)]>, TB;
574 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
575 "bsr{w}\t{$src, $dst|$dst, $src}",
576 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
577 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
578 "bsr{w}\t{$src, $dst|$dst, $src}",
579 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
580 (implicit EFLAGS)]>, TB;
581 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
582 "bsr{l}\t{$src, $dst|$dst, $src}",
583 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
584 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
585 "bsr{l}\t{$src, $dst|$dst, $src}",
586 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
587 (implicit EFLAGS)]>, TB;
590 let neverHasSideEffects = 1 in
591 def LEA16r : I<0x8D, MRMSrcMem,
592 (outs GR16:$dst), (ins i32mem:$src),
593 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
594 let isReMaterializable = 1 in
595 def LEA32r : I<0x8D, MRMSrcMem,
596 (outs GR32:$dst), (ins lea32mem:$src),
597 "lea{l}\t{$src|$dst}, {$dst|$src}",
598 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
600 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
601 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
602 [(X86rep_movs i8)]>, REP;
603 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
604 [(X86rep_movs i16)]>, REP, OpSize;
605 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
606 [(X86rep_movs i32)]>, REP;
609 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
610 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
611 [(X86rep_stos i8)]>, REP;
612 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
613 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
614 [(X86rep_stos i16)]>, REP, OpSize;
615 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
616 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
617 [(X86rep_stos i32)]>, REP;
619 let Defs = [RAX, RDX] in
620 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
623 let isBarrier = 1, hasCtrlDep = 1 in {
624 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
627 //===----------------------------------------------------------------------===//
628 // Input/Output Instructions...
630 let Defs = [AL], Uses = [DX] in
631 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
632 "in{b}\t{%dx, %al|%AL, %DX}", []>;
633 let Defs = [AX], Uses = [DX] in
634 def IN16rr : I<0xED, RawFrm, (outs), (ins),
635 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
636 let Defs = [EAX], Uses = [DX] in
637 def IN32rr : I<0xED, RawFrm, (outs), (ins),
638 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
641 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
642 "in{b}\t{$port, %al|%AL, $port}", []>;
644 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
645 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
647 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
648 "in{l}\t{$port, %eax|%EAX, $port}", []>;
650 let Uses = [DX, AL] in
651 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
652 "out{b}\t{%al, %dx|%DX, %AL}", []>;
653 let Uses = [DX, AX] in
654 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
655 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
656 let Uses = [DX, EAX] in
657 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
658 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
661 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
662 "out{b}\t{%al, $port|$port, %AL}", []>;
664 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
665 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
667 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
668 "out{l}\t{%eax, $port|$port, %EAX}", []>;
670 //===----------------------------------------------------------------------===//
671 // Move Instructions...
673 let neverHasSideEffects = 1 in {
674 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
675 "mov{b}\t{$src, $dst|$dst, $src}", []>;
676 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
677 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
678 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
679 "mov{l}\t{$src, $dst|$dst, $src}", []>;
681 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
682 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
683 "mov{b}\t{$src, $dst|$dst, $src}",
684 [(set GR8:$dst, imm:$src)]>;
685 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
686 "mov{w}\t{$src, $dst|$dst, $src}",
687 [(set GR16:$dst, imm:$src)]>, OpSize;
688 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
689 "mov{l}\t{$src, $dst|$dst, $src}",
690 [(set GR32:$dst, imm:$src)]>;
692 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
693 "mov{b}\t{$src, $dst|$dst, $src}",
694 [(store (i8 imm:$src), addr:$dst)]>;
695 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
696 "mov{w}\t{$src, $dst|$dst, $src}",
697 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
698 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
699 "mov{l}\t{$src, $dst|$dst, $src}",
700 [(store (i32 imm:$src), addr:$dst)]>;
702 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
703 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
704 "mov{b}\t{$src, $dst|$dst, $src}",
705 [(set GR8:$dst, (load addr:$src))]>;
706 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
707 "mov{w}\t{$src, $dst|$dst, $src}",
708 [(set GR16:$dst, (load addr:$src))]>, OpSize;
709 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
710 "mov{l}\t{$src, $dst|$dst, $src}",
711 [(set GR32:$dst, (load addr:$src))]>;
714 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
715 "mov{b}\t{$src, $dst|$dst, $src}",
716 [(store GR8:$src, addr:$dst)]>;
717 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
718 "mov{w}\t{$src, $dst|$dst, $src}",
719 [(store GR16:$src, addr:$dst)]>, OpSize;
720 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
721 "mov{l}\t{$src, $dst|$dst, $src}",
722 [(store GR32:$src, addr:$dst)]>;
724 //===----------------------------------------------------------------------===//
725 // Fixed-Register Multiplication and Division Instructions...
728 // Extra precision multiplication
729 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
730 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
731 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
732 // This probably ought to be moved to a def : Pat<> if the
733 // syntax can be accepted.
734 [(set AL, (mul AL, GR8:$src)),
735 (implicit EFLAGS)]>; // AL,AH = AL*GR8
737 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
738 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
740 []>, OpSize; // AX,DX = AX*GR16
742 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
743 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
745 []>; // EAX,EDX = EAX*GR32
747 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
748 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
750 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
751 // This probably ought to be moved to a def : Pat<> if the
752 // syntax can be accepted.
753 [(set AL, (mul AL, (loadi8 addr:$src))),
754 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
756 let mayLoad = 1, neverHasSideEffects = 1 in {
757 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
758 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
760 []>, OpSize; // AX,DX = AX*[mem16]
762 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
763 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
765 []>; // EAX,EDX = EAX*[mem32]
768 let neverHasSideEffects = 1 in {
769 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
770 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
772 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
773 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
774 OpSize; // AX,DX = AX*GR16
775 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
776 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
777 // EAX,EDX = EAX*GR32
779 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
780 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
781 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
782 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
783 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
784 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
785 let Defs = [EAX,EDX], Uses = [EAX] in
786 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
787 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
789 } // neverHasSideEffects
791 // unsigned division/remainder
792 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
793 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
795 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
796 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
797 "div{w}\t$src", []>, OpSize;
798 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
799 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
802 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
803 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
805 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
806 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
807 "div{w}\t$src", []>, OpSize;
808 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
809 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
813 // Signed division/remainder.
814 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
815 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
816 "idiv{b}\t$src", []>;
817 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
818 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
819 "idiv{w}\t$src", []>, OpSize;
820 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
821 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
822 "idiv{l}\t$src", []>;
823 let mayLoad = 1, mayLoad = 1 in {
824 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
825 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
826 "idiv{b}\t$src", []>;
827 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
828 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
829 "idiv{w}\t$src", []>, OpSize;
830 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
831 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
832 "idiv{l}\t$src", []>;
835 //===----------------------------------------------------------------------===//
836 // Two address Instructions.
838 let isTwoAddress = 1 in {
841 let Uses = [EFLAGS] in {
842 let isCommutable = 1 in {
843 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
844 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
845 "cmovb\t{$src2, $dst|$dst, $src2}",
846 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
847 X86_COND_B, EFLAGS))]>,
849 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
850 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
851 "cmovb\t{$src2, $dst|$dst, $src2}",
852 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
853 X86_COND_B, EFLAGS))]>,
855 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
856 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
857 "cmovae\t{$src2, $dst|$dst, $src2}",
858 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
859 X86_COND_AE, EFLAGS))]>,
861 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
862 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
863 "cmovae\t{$src2, $dst|$dst, $src2}",
864 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
865 X86_COND_AE, EFLAGS))]>,
867 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
868 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
869 "cmove\t{$src2, $dst|$dst, $src2}",
870 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
871 X86_COND_E, EFLAGS))]>,
873 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
874 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
875 "cmove\t{$src2, $dst|$dst, $src2}",
876 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
877 X86_COND_E, EFLAGS))]>,
879 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
880 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
881 "cmovne\t{$src2, $dst|$dst, $src2}",
882 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
883 X86_COND_NE, EFLAGS))]>,
885 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
886 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
887 "cmovne\t{$src2, $dst|$dst, $src2}",
888 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
889 X86_COND_NE, EFLAGS))]>,
891 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
892 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
893 "cmovbe\t{$src2, $dst|$dst, $src2}",
894 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
895 X86_COND_BE, EFLAGS))]>,
897 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
898 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
899 "cmovbe\t{$src2, $dst|$dst, $src2}",
900 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
901 X86_COND_BE, EFLAGS))]>,
903 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
904 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
905 "cmova\t{$src2, $dst|$dst, $src2}",
906 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
907 X86_COND_A, EFLAGS))]>,
909 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
910 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
911 "cmova\t{$src2, $dst|$dst, $src2}",
912 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
913 X86_COND_A, EFLAGS))]>,
915 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
916 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
917 "cmovl\t{$src2, $dst|$dst, $src2}",
918 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
919 X86_COND_L, EFLAGS))]>,
921 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
922 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
923 "cmovl\t{$src2, $dst|$dst, $src2}",
924 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
925 X86_COND_L, EFLAGS))]>,
927 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
928 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
929 "cmovge\t{$src2, $dst|$dst, $src2}",
930 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
931 X86_COND_GE, EFLAGS))]>,
933 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
934 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
935 "cmovge\t{$src2, $dst|$dst, $src2}",
936 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
937 X86_COND_GE, EFLAGS))]>,
939 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
940 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
941 "cmovle\t{$src2, $dst|$dst, $src2}",
942 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
943 X86_COND_LE, EFLAGS))]>,
945 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
946 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
947 "cmovle\t{$src2, $dst|$dst, $src2}",
948 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
949 X86_COND_LE, EFLAGS))]>,
951 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
952 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
953 "cmovg\t{$src2, $dst|$dst, $src2}",
954 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
955 X86_COND_G, EFLAGS))]>,
957 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
958 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
959 "cmovg\t{$src2, $dst|$dst, $src2}",
960 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
961 X86_COND_G, EFLAGS))]>,
963 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
964 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
965 "cmovs\t{$src2, $dst|$dst, $src2}",
966 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
967 X86_COND_S, EFLAGS))]>,
969 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
970 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
971 "cmovs\t{$src2, $dst|$dst, $src2}",
972 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
973 X86_COND_S, EFLAGS))]>,
975 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
976 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
977 "cmovns\t{$src2, $dst|$dst, $src2}",
978 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
979 X86_COND_NS, EFLAGS))]>,
981 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
982 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
983 "cmovns\t{$src2, $dst|$dst, $src2}",
984 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
985 X86_COND_NS, EFLAGS))]>,
987 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
988 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
989 "cmovp\t{$src2, $dst|$dst, $src2}",
990 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
991 X86_COND_P, EFLAGS))]>,
993 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
994 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
995 "cmovp\t{$src2, $dst|$dst, $src2}",
996 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
997 X86_COND_P, EFLAGS))]>,
999 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1000 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1001 "cmovnp\t{$src2, $dst|$dst, $src2}",
1002 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1003 X86_COND_NP, EFLAGS))]>,
1005 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1006 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1007 "cmovnp\t{$src2, $dst|$dst, $src2}",
1008 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1009 X86_COND_NP, EFLAGS))]>,
1011 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1012 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1013 "cmovo\t{$src2, $dst|$dst, $src2}",
1014 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1015 X86_COND_O, EFLAGS))]>,
1017 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1018 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1019 "cmovo\t{$src2, $dst|$dst, $src2}",
1020 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1021 X86_COND_O, EFLAGS))]>,
1023 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1024 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1025 "cmovno\t{$src2, $dst|$dst, $src2}",
1026 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1027 X86_COND_NO, EFLAGS))]>,
1029 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1030 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1031 "cmovno\t{$src2, $dst|$dst, $src2}",
1032 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1033 X86_COND_NO, EFLAGS))]>,
1035 } // isCommutable = 1
1037 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1038 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1039 "cmovb\t{$src2, $dst|$dst, $src2}",
1040 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1041 X86_COND_B, EFLAGS))]>,
1043 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1044 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1045 "cmovb\t{$src2, $dst|$dst, $src2}",
1046 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1047 X86_COND_B, EFLAGS))]>,
1049 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1050 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1051 "cmovae\t{$src2, $dst|$dst, $src2}",
1052 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1053 X86_COND_AE, EFLAGS))]>,
1055 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1056 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1057 "cmovae\t{$src2, $dst|$dst, $src2}",
1058 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1059 X86_COND_AE, EFLAGS))]>,
1061 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1062 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1063 "cmove\t{$src2, $dst|$dst, $src2}",
1064 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1065 X86_COND_E, EFLAGS))]>,
1067 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1068 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1069 "cmove\t{$src2, $dst|$dst, $src2}",
1070 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1071 X86_COND_E, EFLAGS))]>,
1073 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1074 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1075 "cmovne\t{$src2, $dst|$dst, $src2}",
1076 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1077 X86_COND_NE, EFLAGS))]>,
1079 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1080 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1081 "cmovne\t{$src2, $dst|$dst, $src2}",
1082 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1083 X86_COND_NE, EFLAGS))]>,
1085 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1086 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1087 "cmovbe\t{$src2, $dst|$dst, $src2}",
1088 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1089 X86_COND_BE, EFLAGS))]>,
1091 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1092 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1093 "cmovbe\t{$src2, $dst|$dst, $src2}",
1094 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1095 X86_COND_BE, EFLAGS))]>,
1097 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1098 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1099 "cmova\t{$src2, $dst|$dst, $src2}",
1100 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1101 X86_COND_A, EFLAGS))]>,
1103 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1104 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1105 "cmova\t{$src2, $dst|$dst, $src2}",
1106 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1107 X86_COND_A, EFLAGS))]>,
1109 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1110 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1111 "cmovl\t{$src2, $dst|$dst, $src2}",
1112 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1113 X86_COND_L, EFLAGS))]>,
1115 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1116 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1117 "cmovl\t{$src2, $dst|$dst, $src2}",
1118 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1119 X86_COND_L, EFLAGS))]>,
1121 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1122 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1123 "cmovge\t{$src2, $dst|$dst, $src2}",
1124 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1125 X86_COND_GE, EFLAGS))]>,
1127 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1128 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1129 "cmovge\t{$src2, $dst|$dst, $src2}",
1130 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1131 X86_COND_GE, EFLAGS))]>,
1133 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1134 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1135 "cmovle\t{$src2, $dst|$dst, $src2}",
1136 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1137 X86_COND_LE, EFLAGS))]>,
1139 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1140 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1141 "cmovle\t{$src2, $dst|$dst, $src2}",
1142 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1143 X86_COND_LE, EFLAGS))]>,
1145 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1146 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1147 "cmovg\t{$src2, $dst|$dst, $src2}",
1148 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1149 X86_COND_G, EFLAGS))]>,
1151 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1152 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1153 "cmovg\t{$src2, $dst|$dst, $src2}",
1154 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1155 X86_COND_G, EFLAGS))]>,
1157 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1158 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1159 "cmovs\t{$src2, $dst|$dst, $src2}",
1160 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1161 X86_COND_S, EFLAGS))]>,
1163 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1164 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1165 "cmovs\t{$src2, $dst|$dst, $src2}",
1166 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1167 X86_COND_S, EFLAGS))]>,
1169 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1170 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1171 "cmovns\t{$src2, $dst|$dst, $src2}",
1172 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1173 X86_COND_NS, EFLAGS))]>,
1175 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1176 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1177 "cmovns\t{$src2, $dst|$dst, $src2}",
1178 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1179 X86_COND_NS, EFLAGS))]>,
1181 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1182 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1183 "cmovp\t{$src2, $dst|$dst, $src2}",
1184 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1185 X86_COND_P, EFLAGS))]>,
1187 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1188 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1189 "cmovp\t{$src2, $dst|$dst, $src2}",
1190 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1191 X86_COND_P, EFLAGS))]>,
1193 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1194 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1195 "cmovnp\t{$src2, $dst|$dst, $src2}",
1196 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1197 X86_COND_NP, EFLAGS))]>,
1199 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1200 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1201 "cmovnp\t{$src2, $dst|$dst, $src2}",
1202 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1203 X86_COND_NP, EFLAGS))]>,
1205 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1206 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1207 "cmovo\t{$src2, $dst|$dst, $src2}",
1208 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1209 X86_COND_O, EFLAGS))]>,
1211 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1212 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1213 "cmovo\t{$src2, $dst|$dst, $src2}",
1214 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1215 X86_COND_O, EFLAGS))]>,
1217 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1218 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1219 "cmovno\t{$src2, $dst|$dst, $src2}",
1220 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1221 X86_COND_NO, EFLAGS))]>,
1223 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1224 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1225 "cmovno\t{$src2, $dst|$dst, $src2}",
1226 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1227 X86_COND_NO, EFLAGS))]>,
1229 } // Uses = [EFLAGS]
1232 // unary instructions
1233 let CodeSize = 2 in {
1234 let Defs = [EFLAGS] in {
1235 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1236 [(set GR8:$dst, (ineg GR8:$src)),
1237 (implicit EFLAGS)]>;
1238 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1239 [(set GR16:$dst, (ineg GR16:$src)),
1240 (implicit EFLAGS)]>, OpSize;
1241 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1242 [(set GR32:$dst, (ineg GR32:$src)),
1243 (implicit EFLAGS)]>;
1244 let isTwoAddress = 0 in {
1245 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1246 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1247 (implicit EFLAGS)]>;
1248 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1249 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1250 (implicit EFLAGS)]>, OpSize;
1251 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1252 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1253 (implicit EFLAGS)]>;
1255 } // Defs = [EFLAGS]
1257 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1258 let AddedComplexity = 15 in {
1259 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1260 [(set GR8:$dst, (not GR8:$src))]>;
1261 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1262 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1263 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1264 [(set GR32:$dst, (not GR32:$src))]>;
1266 let isTwoAddress = 0 in {
1267 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1268 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1269 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1270 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1271 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1272 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1276 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1277 let Defs = [EFLAGS] in {
1279 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1280 [(set GR8:$dst, (add GR8:$src, 1)),
1281 (implicit EFLAGS)]>;
1282 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1283 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1284 [(set GR16:$dst, (add GR16:$src, 1)),
1285 (implicit EFLAGS)]>,
1286 OpSize, Requires<[In32BitMode]>;
1287 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1288 [(set GR32:$dst, (add GR32:$src, 1)),
1289 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1291 let isTwoAddress = 0, CodeSize = 2 in {
1292 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1293 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1294 (implicit EFLAGS)]>;
1295 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1296 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1297 (implicit EFLAGS)]>,
1298 OpSize, Requires<[In32BitMode]>;
1299 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1300 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1301 (implicit EFLAGS)]>,
1302 Requires<[In32BitMode]>;
1306 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1307 [(set GR8:$dst, (add GR8:$src, -1)),
1308 (implicit EFLAGS)]>;
1309 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1310 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1311 [(set GR16:$dst, (add GR16:$src, -1)),
1312 (implicit EFLAGS)]>,
1313 OpSize, Requires<[In32BitMode]>;
1314 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1315 [(set GR32:$dst, (add GR32:$src, -1)),
1316 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1319 let isTwoAddress = 0, CodeSize = 2 in {
1320 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1321 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1322 (implicit EFLAGS)]>;
1323 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1324 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1325 (implicit EFLAGS)]>,
1326 OpSize, Requires<[In32BitMode]>;
1327 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1328 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1329 (implicit EFLAGS)]>,
1330 Requires<[In32BitMode]>;
1332 } // Defs = [EFLAGS]
1334 // Logical operators...
1335 let Defs = [EFLAGS] in {
1336 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1337 def AND8rr : I<0x20, MRMDestReg,
1338 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1339 "and{b}\t{$src2, $dst|$dst, $src2}",
1340 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1341 (implicit EFLAGS)]>;
1342 def AND16rr : I<0x21, MRMDestReg,
1343 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1344 "and{w}\t{$src2, $dst|$dst, $src2}",
1345 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1346 (implicit EFLAGS)]>, OpSize;
1347 def AND32rr : I<0x21, MRMDestReg,
1348 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1349 "and{l}\t{$src2, $dst|$dst, $src2}",
1350 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1351 (implicit EFLAGS)]>;
1354 def AND8rm : I<0x22, MRMSrcMem,
1355 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1356 "and{b}\t{$src2, $dst|$dst, $src2}",
1357 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))),
1358 (implicit EFLAGS)]>;
1359 def AND16rm : I<0x23, MRMSrcMem,
1360 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1361 "and{w}\t{$src2, $dst|$dst, $src2}",
1362 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))),
1363 (implicit EFLAGS)]>, OpSize;
1364 def AND32rm : I<0x23, MRMSrcMem,
1365 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1366 "and{l}\t{$src2, $dst|$dst, $src2}",
1367 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2))),
1368 (implicit EFLAGS)]>;
1370 def AND8ri : Ii8<0x80, MRM4r,
1371 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1372 "and{b}\t{$src2, $dst|$dst, $src2}",
1373 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1374 (implicit EFLAGS)]>;
1375 def AND16ri : Ii16<0x81, MRM4r,
1376 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1377 "and{w}\t{$src2, $dst|$dst, $src2}",
1378 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1379 (implicit EFLAGS)]>, OpSize;
1380 def AND32ri : Ii32<0x81, MRM4r,
1381 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1382 "and{l}\t{$src2, $dst|$dst, $src2}",
1383 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1384 (implicit EFLAGS)]>;
1385 def AND16ri8 : Ii8<0x83, MRM4r,
1386 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1387 "and{w}\t{$src2, $dst|$dst, $src2}",
1388 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1389 (implicit EFLAGS)]>,
1391 def AND32ri8 : Ii8<0x83, MRM4r,
1392 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1393 "and{l}\t{$src2, $dst|$dst, $src2}",
1394 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1395 (implicit EFLAGS)]>;
1397 let isTwoAddress = 0 in {
1398 def AND8mr : I<0x20, MRMDestMem,
1399 (outs), (ins i8mem :$dst, GR8 :$src),
1400 "and{b}\t{$src, $dst|$dst, $src}",
1401 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1402 (implicit EFLAGS)]>;
1403 def AND16mr : I<0x21, MRMDestMem,
1404 (outs), (ins i16mem:$dst, GR16:$src),
1405 "and{w}\t{$src, $dst|$dst, $src}",
1406 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1407 (implicit EFLAGS)]>,
1409 def AND32mr : I<0x21, MRMDestMem,
1410 (outs), (ins i32mem:$dst, GR32:$src),
1411 "and{l}\t{$src, $dst|$dst, $src}",
1412 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1413 (implicit EFLAGS)]>;
1414 def AND8mi : Ii8<0x80, MRM4m,
1415 (outs), (ins i8mem :$dst, i8imm :$src),
1416 "and{b}\t{$src, $dst|$dst, $src}",
1417 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1418 (implicit EFLAGS)]>;
1419 def AND16mi : Ii16<0x81, MRM4m,
1420 (outs), (ins i16mem:$dst, i16imm:$src),
1421 "and{w}\t{$src, $dst|$dst, $src}",
1422 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1423 (implicit EFLAGS)]>,
1425 def AND32mi : Ii32<0x81, MRM4m,
1426 (outs), (ins i32mem:$dst, i32imm:$src),
1427 "and{l}\t{$src, $dst|$dst, $src}",
1428 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1429 (implicit EFLAGS)]>;
1430 def AND16mi8 : Ii8<0x83, MRM4m,
1431 (outs), (ins i16mem:$dst, i16i8imm :$src),
1432 "and{w}\t{$src, $dst|$dst, $src}",
1433 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1434 (implicit EFLAGS)]>,
1436 def AND32mi8 : Ii8<0x83, MRM4m,
1437 (outs), (ins i32mem:$dst, i32i8imm :$src),
1438 "and{l}\t{$src, $dst|$dst, $src}",
1439 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1440 (implicit EFLAGS)]>;
1444 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1445 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1446 "or{b}\t{$src2, $dst|$dst, $src2}",
1447 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1448 (implicit EFLAGS)]>;
1449 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1450 "or{w}\t{$src2, $dst|$dst, $src2}",
1451 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1452 (implicit EFLAGS)]>, OpSize;
1453 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1454 "or{l}\t{$src2, $dst|$dst, $src2}",
1455 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1456 (implicit EFLAGS)]>;
1458 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1459 "or{b}\t{$src2, $dst|$dst, $src2}",
1460 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1461 (implicit EFLAGS)]>;
1462 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1463 "or{w}\t{$src2, $dst|$dst, $src2}",
1464 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1465 (implicit EFLAGS)]>, OpSize;
1466 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1467 "or{l}\t{$src2, $dst|$dst, $src2}",
1468 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1469 (implicit EFLAGS)]>;
1471 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1472 "or{b}\t{$src2, $dst|$dst, $src2}",
1473 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1474 (implicit EFLAGS)]>;
1475 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1476 "or{w}\t{$src2, $dst|$dst, $src2}",
1477 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1478 (implicit EFLAGS)]>, OpSize;
1479 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1480 "or{l}\t{$src2, $dst|$dst, $src2}",
1481 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1482 (implicit EFLAGS)]>;
1484 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1485 "or{w}\t{$src2, $dst|$dst, $src2}",
1486 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1487 (implicit EFLAGS)]>, OpSize;
1488 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1489 "or{l}\t{$src2, $dst|$dst, $src2}",
1490 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1491 (implicit EFLAGS)]>;
1492 let isTwoAddress = 0 in {
1493 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1494 "or{b}\t{$src, $dst|$dst, $src}",
1495 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1496 (implicit EFLAGS)]>;
1497 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1498 "or{w}\t{$src, $dst|$dst, $src}",
1499 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1500 (implicit EFLAGS)]>, OpSize;
1501 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1502 "or{l}\t{$src, $dst|$dst, $src}",
1503 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1504 (implicit EFLAGS)]>;
1505 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1506 "or{b}\t{$src, $dst|$dst, $src}",
1507 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1508 (implicit EFLAGS)]>;
1509 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1510 "or{w}\t{$src, $dst|$dst, $src}",
1511 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1512 (implicit EFLAGS)]>,
1514 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1515 "or{l}\t{$src, $dst|$dst, $src}",
1516 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1517 (implicit EFLAGS)]>;
1518 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1519 "or{w}\t{$src, $dst|$dst, $src}",
1520 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1521 (implicit EFLAGS)]>,
1523 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1524 "or{l}\t{$src, $dst|$dst, $src}",
1525 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1526 (implicit EFLAGS)]>;
1527 } // isTwoAddress = 0
1530 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1531 def XOR8rr : I<0x30, MRMDestReg,
1532 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1533 "xor{b}\t{$src2, $dst|$dst, $src2}",
1534 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1535 (implicit EFLAGS)]>;
1536 def XOR16rr : I<0x31, MRMDestReg,
1537 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1538 "xor{w}\t{$src2, $dst|$dst, $src2}",
1539 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1540 (implicit EFLAGS)]>, OpSize;
1541 def XOR32rr : I<0x31, MRMDestReg,
1542 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1543 "xor{l}\t{$src2, $dst|$dst, $src2}",
1544 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1545 (implicit EFLAGS)]>;
1546 } // isCommutable = 1
1548 def XOR8rm : I<0x32, MRMSrcMem ,
1549 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1550 "xor{b}\t{$src2, $dst|$dst, $src2}",
1551 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1552 (implicit EFLAGS)]>;
1553 def XOR16rm : I<0x33, MRMSrcMem ,
1554 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1555 "xor{w}\t{$src2, $dst|$dst, $src2}",
1556 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1557 (implicit EFLAGS)]>,
1559 def XOR32rm : I<0x33, MRMSrcMem ,
1560 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1561 "xor{l}\t{$src2, $dst|$dst, $src2}",
1562 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1563 (implicit EFLAGS)]>;
1565 def XOR8ri : Ii8<0x80, MRM6r,
1566 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1567 "xor{b}\t{$src2, $dst|$dst, $src2}",
1568 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1569 (implicit EFLAGS)]>;
1570 def XOR16ri : Ii16<0x81, MRM6r,
1571 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1572 "xor{w}\t{$src2, $dst|$dst, $src2}",
1573 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1574 (implicit EFLAGS)]>, OpSize;
1575 def XOR32ri : Ii32<0x81, MRM6r,
1576 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1577 "xor{l}\t{$src2, $dst|$dst, $src2}",
1578 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1579 (implicit EFLAGS)]>;
1580 def XOR16ri8 : Ii8<0x83, MRM6r,
1581 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1582 "xor{w}\t{$src2, $dst|$dst, $src2}",
1583 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1584 (implicit EFLAGS)]>,
1586 def XOR32ri8 : Ii8<0x83, MRM6r,
1587 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1588 "xor{l}\t{$src2, $dst|$dst, $src2}",
1589 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1590 (implicit EFLAGS)]>;
1592 let isTwoAddress = 0 in {
1593 def XOR8mr : I<0x30, MRMDestMem,
1594 (outs), (ins i8mem :$dst, GR8 :$src),
1595 "xor{b}\t{$src, $dst|$dst, $src}",
1596 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1597 (implicit EFLAGS)]>;
1598 def XOR16mr : I<0x31, MRMDestMem,
1599 (outs), (ins i16mem:$dst, GR16:$src),
1600 "xor{w}\t{$src, $dst|$dst, $src}",
1601 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1602 (implicit EFLAGS)]>,
1604 def XOR32mr : I<0x31, MRMDestMem,
1605 (outs), (ins i32mem:$dst, GR32:$src),
1606 "xor{l}\t{$src, $dst|$dst, $src}",
1607 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1608 (implicit EFLAGS)]>;
1609 def XOR8mi : Ii8<0x80, MRM6m,
1610 (outs), (ins i8mem :$dst, i8imm :$src),
1611 "xor{b}\t{$src, $dst|$dst, $src}",
1612 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1613 (implicit EFLAGS)]>;
1614 def XOR16mi : Ii16<0x81, MRM6m,
1615 (outs), (ins i16mem:$dst, i16imm:$src),
1616 "xor{w}\t{$src, $dst|$dst, $src}",
1617 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1618 (implicit EFLAGS)]>,
1620 def XOR32mi : Ii32<0x81, MRM6m,
1621 (outs), (ins i32mem:$dst, i32imm:$src),
1622 "xor{l}\t{$src, $dst|$dst, $src}",
1623 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1624 (implicit EFLAGS)]>;
1625 def XOR16mi8 : Ii8<0x83, MRM6m,
1626 (outs), (ins i16mem:$dst, i16i8imm :$src),
1627 "xor{w}\t{$src, $dst|$dst, $src}",
1628 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1629 (implicit EFLAGS)]>,
1631 def XOR32mi8 : Ii8<0x83, MRM6m,
1632 (outs), (ins i32mem:$dst, i32i8imm :$src),
1633 "xor{l}\t{$src, $dst|$dst, $src}",
1634 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1635 (implicit EFLAGS)]>;
1636 } // isTwoAddress = 0
1637 } // Defs = [EFLAGS]
1639 // Shift instructions
1640 let Defs = [EFLAGS] in {
1641 let Uses = [CL] in {
1642 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1643 "shl{b}\t{%cl, $dst|$dst, %CL}",
1644 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1645 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1646 "shl{w}\t{%cl, $dst|$dst, %CL}",
1647 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1648 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1649 "shl{l}\t{%cl, $dst|$dst, %CL}",
1650 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1653 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1654 "shl{b}\t{$src2, $dst|$dst, $src2}",
1655 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1656 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1657 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1658 "shl{w}\t{$src2, $dst|$dst, $src2}",
1659 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1660 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1661 "shl{l}\t{$src2, $dst|$dst, $src2}",
1662 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1663 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1665 } // isConvertibleToThreeAddress = 1
1667 let isTwoAddress = 0 in {
1668 let Uses = [CL] in {
1669 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1670 "shl{b}\t{%cl, $dst|$dst, %CL}",
1671 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1672 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1673 "shl{w}\t{%cl, $dst|$dst, %CL}",
1674 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1675 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1676 "shl{l}\t{%cl, $dst|$dst, %CL}",
1677 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1679 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1680 "shl{b}\t{$src, $dst|$dst, $src}",
1681 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1682 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1683 "shl{w}\t{$src, $dst|$dst, $src}",
1684 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1686 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1687 "shl{l}\t{$src, $dst|$dst, $src}",
1688 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1691 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1693 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1694 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1696 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1698 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1700 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1703 let Uses = [CL] in {
1704 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1705 "shr{b}\t{%cl, $dst|$dst, %CL}",
1706 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1707 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1708 "shr{w}\t{%cl, $dst|$dst, %CL}",
1709 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1710 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1711 "shr{l}\t{%cl, $dst|$dst, %CL}",
1712 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1715 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1716 "shr{b}\t{$src2, $dst|$dst, $src2}",
1717 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1718 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1719 "shr{w}\t{$src2, $dst|$dst, $src2}",
1720 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1721 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1722 "shr{l}\t{$src2, $dst|$dst, $src2}",
1723 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1726 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1728 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1729 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1731 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1732 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1734 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1736 let isTwoAddress = 0 in {
1737 let Uses = [CL] in {
1738 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1739 "shr{b}\t{%cl, $dst|$dst, %CL}",
1740 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1741 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1742 "shr{w}\t{%cl, $dst|$dst, %CL}",
1743 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1745 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1746 "shr{l}\t{%cl, $dst|$dst, %CL}",
1747 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1749 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1750 "shr{b}\t{$src, $dst|$dst, $src}",
1751 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1752 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1753 "shr{w}\t{$src, $dst|$dst, $src}",
1754 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1756 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1757 "shr{l}\t{$src, $dst|$dst, $src}",
1758 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1761 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1763 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1764 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1766 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1767 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1769 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1772 let Uses = [CL] in {
1773 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1774 "sar{b}\t{%cl, $dst|$dst, %CL}",
1775 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1776 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1777 "sar{w}\t{%cl, $dst|$dst, %CL}",
1778 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1779 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1780 "sar{l}\t{%cl, $dst|$dst, %CL}",
1781 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1784 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1785 "sar{b}\t{$src2, $dst|$dst, $src2}",
1786 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1787 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1788 "sar{w}\t{$src2, $dst|$dst, $src2}",
1789 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1791 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1792 "sar{l}\t{$src2, $dst|$dst, $src2}",
1793 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1796 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1798 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1799 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1801 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1802 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1804 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1806 let isTwoAddress = 0 in {
1807 let Uses = [CL] in {
1808 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1809 "sar{b}\t{%cl, $dst|$dst, %CL}",
1810 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1811 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1812 "sar{w}\t{%cl, $dst|$dst, %CL}",
1813 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1814 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1815 "sar{l}\t{%cl, $dst|$dst, %CL}",
1816 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1818 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1819 "sar{b}\t{$src, $dst|$dst, $src}",
1820 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1821 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1822 "sar{w}\t{$src, $dst|$dst, $src}",
1823 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1825 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1826 "sar{l}\t{$src, $dst|$dst, $src}",
1827 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1830 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1832 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1833 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1835 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1837 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1839 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1842 // Rotate instructions
1843 // FIXME: provide shorter instructions when imm8 == 1
1844 let Uses = [CL] in {
1845 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1846 "rol{b}\t{%cl, $dst|$dst, %CL}",
1847 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1848 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1849 "rol{w}\t{%cl, $dst|$dst, %CL}",
1850 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1851 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1852 "rol{l}\t{%cl, $dst|$dst, %CL}",
1853 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1856 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1857 "rol{b}\t{$src2, $dst|$dst, $src2}",
1858 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1859 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1860 "rol{w}\t{$src2, $dst|$dst, $src2}",
1861 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1862 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1863 "rol{l}\t{$src2, $dst|$dst, $src2}",
1864 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1867 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1869 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1870 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1872 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1873 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1875 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1877 let isTwoAddress = 0 in {
1878 let Uses = [CL] in {
1879 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1880 "rol{b}\t{%cl, $dst|$dst, %CL}",
1881 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
1882 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1883 "rol{w}\t{%cl, $dst|$dst, %CL}",
1884 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1885 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1886 "rol{l}\t{%cl, $dst|$dst, %CL}",
1887 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1889 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
1890 "rol{b}\t{$src, $dst|$dst, $src}",
1891 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1892 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
1893 "rol{w}\t{$src, $dst|$dst, $src}",
1894 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1896 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
1897 "rol{l}\t{$src, $dst|$dst, $src}",
1898 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1901 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
1903 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1904 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
1906 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1908 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
1910 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1913 let Uses = [CL] in {
1914 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
1915 "ror{b}\t{%cl, $dst|$dst, %CL}",
1916 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
1917 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
1918 "ror{w}\t{%cl, $dst|$dst, %CL}",
1919 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
1920 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
1921 "ror{l}\t{%cl, $dst|$dst, %CL}",
1922 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1925 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1926 "ror{b}\t{$src2, $dst|$dst, $src2}",
1927 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1928 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1929 "ror{w}\t{$src2, $dst|$dst, $src2}",
1930 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1931 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1932 "ror{l}\t{$src2, $dst|$dst, $src2}",
1933 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1936 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1938 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1939 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
1941 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1942 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
1944 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1946 let isTwoAddress = 0 in {
1947 let Uses = [CL] in {
1948 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
1949 "ror{b}\t{%cl, $dst|$dst, %CL}",
1950 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
1951 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
1952 "ror{w}\t{%cl, $dst|$dst, %CL}",
1953 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1954 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
1955 "ror{l}\t{%cl, $dst|$dst, %CL}",
1956 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1958 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1959 "ror{b}\t{$src, $dst|$dst, $src}",
1960 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1961 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
1962 "ror{w}\t{$src, $dst|$dst, $src}",
1963 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1965 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
1966 "ror{l}\t{$src, $dst|$dst, $src}",
1967 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1970 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
1972 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1973 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
1975 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1977 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
1979 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1984 // Double shift instructions (generalizations of rotate)
1985 let Uses = [CL] in {
1986 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1987 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1988 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
1989 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1990 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1991 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
1992 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1993 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1994 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1996 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1997 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1998 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2002 let isCommutable = 1 in { // These instructions commute to each other.
2003 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2004 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2005 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2006 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2009 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2010 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2011 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2012 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2015 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2016 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2017 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2018 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2021 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2022 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2023 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2024 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2029 let isTwoAddress = 0 in {
2030 let Uses = [CL] in {
2031 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2032 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2033 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2035 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2036 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2037 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2040 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2041 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2042 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2043 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2044 (i8 imm:$src3)), addr:$dst)]>,
2046 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2047 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2048 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2049 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2050 (i8 imm:$src3)), addr:$dst)]>,
2053 let Uses = [CL] in {
2054 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2055 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2056 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2057 addr:$dst)]>, TB, OpSize;
2058 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2059 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2060 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2061 addr:$dst)]>, TB, OpSize;
2063 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2064 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2065 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2066 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2067 (i8 imm:$src3)), addr:$dst)]>,
2069 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2070 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2071 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2072 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2073 (i8 imm:$src3)), addr:$dst)]>,
2076 } // Defs = [EFLAGS]
2080 let Defs = [EFLAGS] in {
2081 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2082 // Register-Register Addition
2083 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2084 (ins GR8 :$src1, GR8 :$src2),
2085 "add{b}\t{$src2, $dst|$dst, $src2}",
2086 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2087 (implicit EFLAGS)]>;
2089 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2090 // Register-Register Addition
2091 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2092 (ins GR16:$src1, GR16:$src2),
2093 "add{w}\t{$src2, $dst|$dst, $src2}",
2094 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2095 (implicit EFLAGS)]>, OpSize;
2096 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2097 (ins GR32:$src1, GR32:$src2),
2098 "add{l}\t{$src2, $dst|$dst, $src2}",
2099 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2100 (implicit EFLAGS)]>;
2101 } // end isConvertibleToThreeAddress
2102 } // end isCommutable
2104 // Register-Memory Addition
2105 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2106 (ins GR8 :$src1, i8mem :$src2),
2107 "add{b}\t{$src2, $dst|$dst, $src2}",
2108 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2109 (implicit EFLAGS)]>;
2110 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2111 (ins GR16:$src1, i16mem:$src2),
2112 "add{w}\t{$src2, $dst|$dst, $src2}",
2113 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2114 (implicit EFLAGS)]>, OpSize;
2115 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2116 (ins GR32:$src1, i32mem:$src2),
2117 "add{l}\t{$src2, $dst|$dst, $src2}",
2118 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2119 (implicit EFLAGS)]>;
2121 // Register-Integer Addition
2122 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2123 "add{b}\t{$src2, $dst|$dst, $src2}",
2124 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2125 (implicit EFLAGS)]>;
2127 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2128 // Register-Integer Addition
2129 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2130 (ins GR16:$src1, i16imm:$src2),
2131 "add{w}\t{$src2, $dst|$dst, $src2}",
2132 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2133 (implicit EFLAGS)]>, OpSize;
2134 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2135 (ins GR32:$src1, i32imm:$src2),
2136 "add{l}\t{$src2, $dst|$dst, $src2}",
2137 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2138 (implicit EFLAGS)]>;
2139 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2140 (ins GR16:$src1, i16i8imm:$src2),
2141 "add{w}\t{$src2, $dst|$dst, $src2}",
2142 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2143 (implicit EFLAGS)]>, OpSize;
2144 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2145 (ins GR32:$src1, i32i8imm:$src2),
2146 "add{l}\t{$src2, $dst|$dst, $src2}",
2147 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2148 (implicit EFLAGS)]>;
2151 let isTwoAddress = 0 in {
2152 // Memory-Register Addition
2153 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2154 "add{b}\t{$src2, $dst|$dst, $src2}",
2155 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2156 (implicit EFLAGS)]>;
2157 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2158 "add{w}\t{$src2, $dst|$dst, $src2}",
2159 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2160 (implicit EFLAGS)]>, OpSize;
2161 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2162 "add{l}\t{$src2, $dst|$dst, $src2}",
2163 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2164 (implicit EFLAGS)]>;
2165 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2166 "add{b}\t{$src2, $dst|$dst, $src2}",
2167 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2168 (implicit EFLAGS)]>;
2169 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2170 "add{w}\t{$src2, $dst|$dst, $src2}",
2171 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2172 (implicit EFLAGS)]>, OpSize;
2173 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2174 "add{l}\t{$src2, $dst|$dst, $src2}",
2175 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2176 (implicit EFLAGS)]>;
2177 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2178 "add{w}\t{$src2, $dst|$dst, $src2}",
2179 [(store (add (load addr:$dst), i16immSExt8:$src2),
2181 (implicit EFLAGS)]>, OpSize;
2182 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2183 "add{l}\t{$src2, $dst|$dst, $src2}",
2184 [(store (add (load addr:$dst), i32immSExt8:$src2),
2186 (implicit EFLAGS)]>;
2189 let Uses = [EFLAGS] in {
2190 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2191 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2192 "adc{l}\t{$src2, $dst|$dst, $src2}",
2193 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2195 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2196 "adc{l}\t{$src2, $dst|$dst, $src2}",
2197 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2198 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2199 "adc{l}\t{$src2, $dst|$dst, $src2}",
2200 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2201 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2202 "adc{l}\t{$src2, $dst|$dst, $src2}",
2203 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2205 let isTwoAddress = 0 in {
2206 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2207 "adc{l}\t{$src2, $dst|$dst, $src2}",
2208 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2209 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2210 "adc{l}\t{$src2, $dst|$dst, $src2}",
2211 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2212 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2213 "adc{l}\t{$src2, $dst|$dst, $src2}",
2214 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2216 } // Uses = [EFLAGS]
2218 // Register-Register Subtraction
2219 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2220 "sub{b}\t{$src2, $dst|$dst, $src2}",
2221 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2222 (implicit EFLAGS)]>;
2223 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2224 "sub{w}\t{$src2, $dst|$dst, $src2}",
2225 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2226 (implicit EFLAGS)]>, OpSize;
2227 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2228 "sub{l}\t{$src2, $dst|$dst, $src2}",
2229 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2230 (implicit EFLAGS)]>;
2232 // Register-Memory Subtraction
2233 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2234 (ins GR8 :$src1, i8mem :$src2),
2235 "sub{b}\t{$src2, $dst|$dst, $src2}",
2236 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2237 (implicit EFLAGS)]>;
2238 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2239 (ins GR16:$src1, i16mem:$src2),
2240 "sub{w}\t{$src2, $dst|$dst, $src2}",
2241 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2242 (implicit EFLAGS)]>, OpSize;
2243 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2244 (ins GR32:$src1, i32mem:$src2),
2245 "sub{l}\t{$src2, $dst|$dst, $src2}",
2246 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2247 (implicit EFLAGS)]>;
2249 // Register-Integer Subtraction
2250 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2251 (ins GR8:$src1, i8imm:$src2),
2252 "sub{b}\t{$src2, $dst|$dst, $src2}",
2253 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2254 (implicit EFLAGS)]>;
2255 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2256 (ins GR16:$src1, i16imm:$src2),
2257 "sub{w}\t{$src2, $dst|$dst, $src2}",
2258 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2259 (implicit EFLAGS)]>, OpSize;
2260 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2261 (ins GR32:$src1, i32imm:$src2),
2262 "sub{l}\t{$src2, $dst|$dst, $src2}",
2263 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2264 (implicit EFLAGS)]>;
2265 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2266 (ins GR16:$src1, i16i8imm:$src2),
2267 "sub{w}\t{$src2, $dst|$dst, $src2}",
2268 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2269 (implicit EFLAGS)]>, OpSize;
2270 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2271 (ins GR32:$src1, i32i8imm:$src2),
2272 "sub{l}\t{$src2, $dst|$dst, $src2}",
2273 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2274 (implicit EFLAGS)]>;
2276 let isTwoAddress = 0 in {
2277 // Memory-Register Subtraction
2278 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2279 "sub{b}\t{$src2, $dst|$dst, $src2}",
2280 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2281 (implicit EFLAGS)]>;
2282 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2283 "sub{w}\t{$src2, $dst|$dst, $src2}",
2284 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2285 (implicit EFLAGS)]>, OpSize;
2286 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2287 "sub{l}\t{$src2, $dst|$dst, $src2}",
2288 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2289 (implicit EFLAGS)]>;
2291 // Memory-Integer Subtraction
2292 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2293 "sub{b}\t{$src2, $dst|$dst, $src2}",
2294 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2295 (implicit EFLAGS)]>;
2296 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2297 "sub{w}\t{$src2, $dst|$dst, $src2}",
2298 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2299 (implicit EFLAGS)]>, OpSize;
2300 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2301 "sub{l}\t{$src2, $dst|$dst, $src2}",
2302 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2303 (implicit EFLAGS)]>;
2304 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2305 "sub{w}\t{$src2, $dst|$dst, $src2}",
2306 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2308 (implicit EFLAGS)]>, OpSize;
2309 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2310 "sub{l}\t{$src2, $dst|$dst, $src2}",
2311 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2313 (implicit EFLAGS)]>;
2316 let Uses = [EFLAGS] in {
2317 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2318 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2319 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2321 let isTwoAddress = 0 in {
2322 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2323 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2324 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2325 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2326 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2327 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2328 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2329 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2330 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2331 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2332 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2333 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2335 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2336 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2337 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2338 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2339 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2340 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2341 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2342 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2343 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2344 } // Uses = [EFLAGS]
2345 } // Defs = [EFLAGS]
2347 let Defs = [EFLAGS] in {
2348 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2349 // Register-Register Signed Integer Multiply
2350 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2351 "imul{w}\t{$src2, $dst|$dst, $src2}",
2352 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2353 (implicit EFLAGS)]>, TB, OpSize;
2354 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2355 "imul{l}\t{$src2, $dst|$dst, $src2}",
2356 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2357 (implicit EFLAGS)]>, TB;
2360 // Register-Memory Signed Integer Multiply
2361 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2362 (ins GR16:$src1, i16mem:$src2),
2363 "imul{w}\t{$src2, $dst|$dst, $src2}",
2364 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2365 (implicit EFLAGS)]>, TB, OpSize;
2366 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2367 "imul{l}\t{$src2, $dst|$dst, $src2}",
2368 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2369 (implicit EFLAGS)]>, TB;
2370 } // Defs = [EFLAGS]
2371 } // end Two Address instructions
2373 // Suprisingly enough, these are not two address instructions!
2374 let Defs = [EFLAGS] in {
2375 // Register-Integer Signed Integer Multiply
2376 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2377 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2378 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2379 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2380 (implicit EFLAGS)]>, OpSize;
2381 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2382 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2383 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2384 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2385 (implicit EFLAGS)]>;
2386 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2387 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2388 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2389 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2390 (implicit EFLAGS)]>, OpSize;
2391 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2392 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2393 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2394 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2395 (implicit EFLAGS)]>;
2397 // Memory-Integer Signed Integer Multiply
2398 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2399 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2400 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2401 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2402 (implicit EFLAGS)]>, OpSize;
2403 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2404 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2405 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2406 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2407 (implicit EFLAGS)]>;
2408 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2409 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2410 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2411 [(set GR16:$dst, (mul (load addr:$src1),
2412 i16immSExt8:$src2)),
2413 (implicit EFLAGS)]>, OpSize;
2414 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2415 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2416 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2417 [(set GR32:$dst, (mul (load addr:$src1),
2418 i32immSExt8:$src2)),
2419 (implicit EFLAGS)]>;
2420 } // Defs = [EFLAGS]
2422 //===----------------------------------------------------------------------===//
2423 // Test instructions are just like AND, except they don't generate a result.
2425 let Defs = [EFLAGS] in {
2426 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2427 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2428 "test{b}\t{$src2, $src1|$src1, $src2}",
2429 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2430 (implicit EFLAGS)]>;
2431 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2432 "test{w}\t{$src2, $src1|$src1, $src2}",
2433 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2434 (implicit EFLAGS)]>,
2436 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2437 "test{l}\t{$src2, $src1|$src1, $src2}",
2438 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2439 (implicit EFLAGS)]>;
2442 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2443 "test{b}\t{$src2, $src1|$src1, $src2}",
2444 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2445 (implicit EFLAGS)]>;
2446 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2447 "test{w}\t{$src2, $src1|$src1, $src2}",
2448 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2449 (implicit EFLAGS)]>, OpSize;
2450 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2451 "test{l}\t{$src2, $src1|$src1, $src2}",
2452 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2453 (implicit EFLAGS)]>;
2455 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2456 (outs), (ins GR8:$src1, i8imm:$src2),
2457 "test{b}\t{$src2, $src1|$src1, $src2}",
2458 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2459 (implicit EFLAGS)]>;
2460 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2461 (outs), (ins GR16:$src1, i16imm:$src2),
2462 "test{w}\t{$src2, $src1|$src1, $src2}",
2463 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2464 (implicit EFLAGS)]>, OpSize;
2465 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2466 (outs), (ins GR32:$src1, i32imm:$src2),
2467 "test{l}\t{$src2, $src1|$src1, $src2}",
2468 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2469 (implicit EFLAGS)]>;
2471 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2472 (outs), (ins i8mem:$src1, i8imm:$src2),
2473 "test{b}\t{$src2, $src1|$src1, $src2}",
2474 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2475 (implicit EFLAGS)]>;
2476 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2477 (outs), (ins i16mem:$src1, i16imm:$src2),
2478 "test{w}\t{$src2, $src1|$src1, $src2}",
2479 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2480 (implicit EFLAGS)]>, OpSize;
2481 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2482 (outs), (ins i32mem:$src1, i32imm:$src2),
2483 "test{l}\t{$src2, $src1|$src1, $src2}",
2484 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2485 (implicit EFLAGS)]>;
2486 } // Defs = [EFLAGS]
2489 // Condition code ops, incl. set if equal/not equal/...
2490 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2491 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2492 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2493 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2495 let Uses = [EFLAGS] in {
2496 def SETEr : I<0x94, MRM0r,
2497 (outs GR8 :$dst), (ins),
2499 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2501 def SETEm : I<0x94, MRM0m,
2502 (outs), (ins i8mem:$dst),
2504 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2507 def SETNEr : I<0x95, MRM0r,
2508 (outs GR8 :$dst), (ins),
2510 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2512 def SETNEm : I<0x95, MRM0m,
2513 (outs), (ins i8mem:$dst),
2515 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2518 def SETLr : I<0x9C, MRM0r,
2519 (outs GR8 :$dst), (ins),
2521 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2522 TB; // GR8 = < signed
2523 def SETLm : I<0x9C, MRM0m,
2524 (outs), (ins i8mem:$dst),
2526 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2527 TB; // [mem8] = < signed
2529 def SETGEr : I<0x9D, MRM0r,
2530 (outs GR8 :$dst), (ins),
2532 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2533 TB; // GR8 = >= signed
2534 def SETGEm : I<0x9D, MRM0m,
2535 (outs), (ins i8mem:$dst),
2537 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2538 TB; // [mem8] = >= signed
2540 def SETLEr : I<0x9E, MRM0r,
2541 (outs GR8 :$dst), (ins),
2543 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2544 TB; // GR8 = <= signed
2545 def SETLEm : I<0x9E, MRM0m,
2546 (outs), (ins i8mem:$dst),
2548 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2549 TB; // [mem8] = <= signed
2551 def SETGr : I<0x9F, MRM0r,
2552 (outs GR8 :$dst), (ins),
2554 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2555 TB; // GR8 = > signed
2556 def SETGm : I<0x9F, MRM0m,
2557 (outs), (ins i8mem:$dst),
2559 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2560 TB; // [mem8] = > signed
2562 def SETBr : I<0x92, MRM0r,
2563 (outs GR8 :$dst), (ins),
2565 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2566 TB; // GR8 = < unsign
2567 def SETBm : I<0x92, MRM0m,
2568 (outs), (ins i8mem:$dst),
2570 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2571 TB; // [mem8] = < unsign
2573 def SETAEr : I<0x93, MRM0r,
2574 (outs GR8 :$dst), (ins),
2576 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2577 TB; // GR8 = >= unsign
2578 def SETAEm : I<0x93, MRM0m,
2579 (outs), (ins i8mem:$dst),
2581 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2582 TB; // [mem8] = >= unsign
2584 def SETBEr : I<0x96, MRM0r,
2585 (outs GR8 :$dst), (ins),
2587 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2588 TB; // GR8 = <= unsign
2589 def SETBEm : I<0x96, MRM0m,
2590 (outs), (ins i8mem:$dst),
2592 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2593 TB; // [mem8] = <= unsign
2595 def SETAr : I<0x97, MRM0r,
2596 (outs GR8 :$dst), (ins),
2598 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2599 TB; // GR8 = > signed
2600 def SETAm : I<0x97, MRM0m,
2601 (outs), (ins i8mem:$dst),
2603 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2604 TB; // [mem8] = > signed
2606 def SETSr : I<0x98, MRM0r,
2607 (outs GR8 :$dst), (ins),
2609 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2610 TB; // GR8 = <sign bit>
2611 def SETSm : I<0x98, MRM0m,
2612 (outs), (ins i8mem:$dst),
2614 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2615 TB; // [mem8] = <sign bit>
2616 def SETNSr : I<0x99, MRM0r,
2617 (outs GR8 :$dst), (ins),
2619 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2620 TB; // GR8 = !<sign bit>
2621 def SETNSm : I<0x99, MRM0m,
2622 (outs), (ins i8mem:$dst),
2624 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2625 TB; // [mem8] = !<sign bit>
2627 def SETPr : I<0x9A, MRM0r,
2628 (outs GR8 :$dst), (ins),
2630 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2632 def SETPm : I<0x9A, MRM0m,
2633 (outs), (ins i8mem:$dst),
2635 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2636 TB; // [mem8] = parity
2637 def SETNPr : I<0x9B, MRM0r,
2638 (outs GR8 :$dst), (ins),
2640 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2641 TB; // GR8 = not parity
2642 def SETNPm : I<0x9B, MRM0m,
2643 (outs), (ins i8mem:$dst),
2645 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2646 TB; // [mem8] = not parity
2648 def SETOr : I<0x90, MRM0r,
2649 (outs GR8 :$dst), (ins),
2651 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2652 TB; // GR8 = overflow
2653 def SETOm : I<0x90, MRM0m,
2654 (outs), (ins i8mem:$dst),
2656 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2657 TB; // [mem8] = overflow
2658 def SETNOr : I<0x91, MRM0r,
2659 (outs GR8 :$dst), (ins),
2661 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2662 TB; // GR8 = not overflow
2663 def SETNOm : I<0x91, MRM0m,
2664 (outs), (ins i8mem:$dst),
2666 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2667 TB; // [mem8] = not overflow
2668 } // Uses = [EFLAGS]
2671 // Integer comparisons
2672 let Defs = [EFLAGS] in {
2673 def CMP8rr : I<0x38, MRMDestReg,
2674 (outs), (ins GR8 :$src1, GR8 :$src2),
2675 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2676 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2677 def CMP16rr : I<0x39, MRMDestReg,
2678 (outs), (ins GR16:$src1, GR16:$src2),
2679 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2680 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2681 def CMP32rr : I<0x39, MRMDestReg,
2682 (outs), (ins GR32:$src1, GR32:$src2),
2683 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2684 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2685 def CMP8mr : I<0x38, MRMDestMem,
2686 (outs), (ins i8mem :$src1, GR8 :$src2),
2687 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2688 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2689 (implicit EFLAGS)]>;
2690 def CMP16mr : I<0x39, MRMDestMem,
2691 (outs), (ins i16mem:$src1, GR16:$src2),
2692 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2693 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2694 (implicit EFLAGS)]>, OpSize;
2695 def CMP32mr : I<0x39, MRMDestMem,
2696 (outs), (ins i32mem:$src1, GR32:$src2),
2697 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2698 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2699 (implicit EFLAGS)]>;
2700 def CMP8rm : I<0x3A, MRMSrcMem,
2701 (outs), (ins GR8 :$src1, i8mem :$src2),
2702 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2703 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2704 (implicit EFLAGS)]>;
2705 def CMP16rm : I<0x3B, MRMSrcMem,
2706 (outs), (ins GR16:$src1, i16mem:$src2),
2707 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2708 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2709 (implicit EFLAGS)]>, OpSize;
2710 def CMP32rm : I<0x3B, MRMSrcMem,
2711 (outs), (ins GR32:$src1, i32mem:$src2),
2712 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2713 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2714 (implicit EFLAGS)]>;
2715 def CMP8ri : Ii8<0x80, MRM7r,
2716 (outs), (ins GR8:$src1, i8imm:$src2),
2717 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2718 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
2719 def CMP16ri : Ii16<0x81, MRM7r,
2720 (outs), (ins GR16:$src1, i16imm:$src2),
2721 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2722 [(X86cmp GR16:$src1, imm:$src2),
2723 (implicit EFLAGS)]>, OpSize;
2724 def CMP32ri : Ii32<0x81, MRM7r,
2725 (outs), (ins GR32:$src1, i32imm:$src2),
2726 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2727 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
2728 def CMP8mi : Ii8 <0x80, MRM7m,
2729 (outs), (ins i8mem :$src1, i8imm :$src2),
2730 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2731 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2732 (implicit EFLAGS)]>;
2733 def CMP16mi : Ii16<0x81, MRM7m,
2734 (outs), (ins i16mem:$src1, i16imm:$src2),
2735 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2736 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2737 (implicit EFLAGS)]>, OpSize;
2738 def CMP32mi : Ii32<0x81, MRM7m,
2739 (outs), (ins i32mem:$src1, i32imm:$src2),
2740 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2741 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2742 (implicit EFLAGS)]>;
2743 def CMP16ri8 : Ii8<0x83, MRM7r,
2744 (outs), (ins GR16:$src1, i16i8imm:$src2),
2745 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2746 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2747 (implicit EFLAGS)]>, OpSize;
2748 def CMP16mi8 : Ii8<0x83, MRM7m,
2749 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2750 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2751 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2752 (implicit EFLAGS)]>, OpSize;
2753 def CMP32mi8 : Ii8<0x83, MRM7m,
2754 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2755 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2756 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2757 (implicit EFLAGS)]>;
2758 def CMP32ri8 : Ii8<0x83, MRM7r,
2759 (outs), (ins GR32:$src1, i32i8imm:$src2),
2760 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2761 [(X86cmp GR32:$src1, i32immSExt8:$src2),
2762 (implicit EFLAGS)]>;
2763 } // Defs = [EFLAGS]
2766 // TODO: BTC, BTR, and BTS
2767 let Defs = [EFLAGS] in {
2768 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2769 "bt{w}\t{$src2, $src1|$src1, $src2}",
2770 [(X86bt GR16:$src1, GR16:$src2),
2771 (implicit EFLAGS)]>, OpSize, TB;
2772 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2773 "bt{l}\t{$src2, $src1|$src1, $src2}",
2774 [(X86bt GR32:$src1, GR32:$src2),
2775 (implicit EFLAGS)]>, TB;
2777 // Unlike with the register+register form, the memory+register form of the
2778 // bt instruction does not ignore the high bits of the index. From ISel's
2779 // perspective, this is pretty bizarre. Disable these instructions for now.
2780 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2781 // "bt{w}\t{$src2, $src1|$src1, $src2}",
2782 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
2783 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2784 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2785 // "bt{l}\t{$src2, $src1|$src1, $src2}",
2786 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
2787 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
2789 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2790 "bt{w}\t{$src2, $src1|$src1, $src2}",
2791 [(X86bt GR16:$src1, i16immSExt8:$src2),
2792 (implicit EFLAGS)]>, OpSize, TB;
2793 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2794 "bt{l}\t{$src2, $src1|$src1, $src2}",
2795 [(X86bt GR32:$src1, i32immSExt8:$src2),
2796 (implicit EFLAGS)]>, TB;
2797 // Note that these instructions don't need FastBTMem because that
2798 // only applies when the other operand is in a register. When it's
2799 // an immediate, bt is still fast.
2800 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2801 "bt{w}\t{$src2, $src1|$src1, $src2}",
2802 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2803 (implicit EFLAGS)]>, OpSize, TB;
2804 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2805 "bt{l}\t{$src2, $src1|$src1, $src2}",
2806 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2807 (implicit EFLAGS)]>, TB;
2808 } // Defs = [EFLAGS]
2810 // Sign/Zero extenders
2811 // Use movsbl intead of movsbw; we don't care about the high 16 bits
2812 // of the register here. This has a smaller encoding and avoids a
2813 // partial-register update.
2814 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2815 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2816 [(set GR16:$dst, (sext GR8:$src))]>, TB;
2817 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2818 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2819 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
2820 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2821 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2822 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2823 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2824 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2825 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2826 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2827 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2828 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2829 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2830 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2831 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2833 // Use movzbl intead of movzbw; we don't care about the high 16 bits
2834 // of the register here. This has a smaller encoding and avoids a
2835 // partial-register update.
2836 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2837 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2838 [(set GR16:$dst, (zext GR8:$src))]>, TB;
2839 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2840 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2841 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
2842 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2843 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2844 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2845 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2846 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2847 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2848 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2849 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2850 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2851 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2852 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2853 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2855 let neverHasSideEffects = 1 in {
2856 let Defs = [AX], Uses = [AL] in
2857 def CBW : I<0x98, RawFrm, (outs), (ins),
2858 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2859 let Defs = [EAX], Uses = [AX] in
2860 def CWDE : I<0x98, RawFrm, (outs), (ins),
2861 "{cwtl|cwde}", []>; // EAX = signext(AX)
2863 let Defs = [AX,DX], Uses = [AX] in
2864 def CWD : I<0x99, RawFrm, (outs), (ins),
2865 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2866 let Defs = [EAX,EDX], Uses = [EAX] in
2867 def CDQ : I<0x99, RawFrm, (outs), (ins),
2868 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2871 //===----------------------------------------------------------------------===//
2872 // Alias Instructions
2873 //===----------------------------------------------------------------------===//
2875 // Alias instructions that map movr0 to xor.
2876 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2877 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2878 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
2879 "xor{b}\t$dst, $dst",
2880 [(set GR8:$dst, 0)]>;
2881 // Use xorl instead of xorw since we don't care about the high 16 bits,
2882 // it's smaller, and it avoids a partial-register update.
2883 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
2884 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2885 [(set GR16:$dst, 0)]>;
2886 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
2887 "xor{l}\t$dst, $dst",
2888 [(set GR32:$dst, 0)]>;
2891 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2892 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2893 let neverHasSideEffects = 1, isAsCheapAsAMove = 1 in {
2894 def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
2895 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2896 def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
2897 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2899 def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
2900 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2901 def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
2902 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2903 } // neverHasSideEffects
2905 let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
2906 def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
2907 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2908 def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
2909 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2911 let mayStore = 1, neverHasSideEffects = 1 in {
2912 def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
2913 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2914 def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
2915 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2918 //===----------------------------------------------------------------------===//
2919 // Thread Local Storage Instructions
2923 def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2924 "leal\t${sym:mem}(,%ebx,1), $dst",
2925 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
2927 let AddedComplexity = 10 in
2928 def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
2929 "movl\t%gs:($src), $dst",
2930 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2932 let AddedComplexity = 15 in
2933 def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2934 "movl\t%gs:${src:mem}, $dst",
2936 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
2939 def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
2940 "movl\t%gs:0, $dst",
2941 [(set GR32:$dst, X86TLStp)]>, SegGS;
2943 let AddedComplexity = 5 in
2944 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
2945 "movl\t%gs:$src, $dst",
2946 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
2948 //===----------------------------------------------------------------------===//
2949 // DWARF Pseudo Instructions
2952 def DWARF_LOC : I<0, Pseudo, (outs),
2953 (ins i32imm:$line, i32imm:$col, i32imm:$file),
2954 ".loc\t${file:debug} ${line:debug} ${col:debug}",
2955 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2958 //===----------------------------------------------------------------------===//
2959 // EH Pseudo Instructions
2961 let isTerminator = 1, isReturn = 1, isBarrier = 1,
2963 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
2964 "ret\t#eh_return, addr: $addr",
2965 [(X86ehret GR32:$addr)]>;
2969 //===----------------------------------------------------------------------===//
2973 // Atomic swap. These are just normal xchg instructions. But since a memory
2974 // operand is referenced, the atomicity is ensured.
2975 let Constraints = "$val = $dst" in {
2976 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2977 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2978 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2979 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2980 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2981 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2983 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2984 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2985 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2988 // Atomic compare and swap.
2989 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
2990 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
2991 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
2992 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
2994 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
2995 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
2996 "lock\n\tcmpxchg8b\t$ptr",
2997 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3000 let Defs = [AX, EFLAGS], Uses = [AX] in {
3001 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3002 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3003 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3005 let Defs = [AL, EFLAGS], Uses = [AL] in {
3006 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3007 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3008 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3011 // Atomic exchange and add
3012 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3013 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3014 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
3015 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3017 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3018 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
3019 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3021 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3022 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
3023 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3027 // Atomic exchange, and, or, xor
3028 let Constraints = "$val = $dst", Defs = [EFLAGS],
3029 usesCustomDAGSchedInserter = 1 in {
3030 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3031 "#ATOMAND32 PSEUDO!",
3032 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3033 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3034 "#ATOMOR32 PSEUDO!",
3035 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3036 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3037 "#ATOMXOR32 PSEUDO!",
3038 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3039 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3040 "#ATOMNAND32 PSEUDO!",
3041 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3042 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3043 "#ATOMMIN32 PSEUDO!",
3044 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3045 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3046 "#ATOMMAX32 PSEUDO!",
3047 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3048 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3049 "#ATOMUMIN32 PSEUDO!",
3050 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3051 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3052 "#ATOMUMAX32 PSEUDO!",
3053 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3055 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3056 "#ATOMAND16 PSEUDO!",
3057 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3058 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3059 "#ATOMOR16 PSEUDO!",
3060 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3061 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3062 "#ATOMXOR16 PSEUDO!",
3063 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3064 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3065 "#ATOMNAND16 PSEUDO!",
3066 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3067 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3068 "#ATOMMIN16 PSEUDO!",
3069 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3070 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3071 "#ATOMMAX16 PSEUDO!",
3072 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3073 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3074 "#ATOMUMIN16 PSEUDO!",
3075 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3076 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3077 "#ATOMUMAX16 PSEUDO!",
3078 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3080 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3081 "#ATOMAND8 PSEUDO!",
3082 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3083 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3085 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3086 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3087 "#ATOMXOR8 PSEUDO!",
3088 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3089 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3090 "#ATOMNAND8 PSEUDO!",
3091 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3094 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3095 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3096 Uses = [EAX, EBX, ECX, EDX],
3097 mayLoad = 1, mayStore = 1,
3098 usesCustomDAGSchedInserter = 1 in {
3099 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3100 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3101 "#ATOMAND6432 PSEUDO!", []>;
3102 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3103 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3104 "#ATOMOR6432 PSEUDO!", []>;
3105 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3106 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3107 "#ATOMXOR6432 PSEUDO!", []>;
3108 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3109 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3110 "#ATOMNAND6432 PSEUDO!", []>;
3111 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3112 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3113 "#ATOMADD6432 PSEUDO!", []>;
3114 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3115 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3116 "#ATOMSUB6432 PSEUDO!", []>;
3117 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3118 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3119 "#ATOMSWAP6432 PSEUDO!", []>;
3122 //===----------------------------------------------------------------------===//
3123 // Non-Instruction Patterns
3124 //===----------------------------------------------------------------------===//
3126 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3127 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3128 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3129 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3130 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3131 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3133 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3134 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3135 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3136 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3137 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3138 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3139 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3140 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3142 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3143 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3144 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3145 (MOV32mi addr:$dst, texternalsym:$src)>;
3149 def : Pat<(X86tailcall GR32:$dst),
3152 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
3154 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
3157 def : Pat<(X86tcret GR32:$dst, imm:$off),
3158 (TCRETURNri GR32:$dst, imm:$off)>;
3160 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3161 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3163 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3164 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3166 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3167 (CALLpcrel32 tglobaladdr:$dst)>;
3168 def : Pat<(X86call (i32 texternalsym:$dst)),
3169 (CALLpcrel32 texternalsym:$dst)>;
3171 // X86 specific add which produces a flag.
3172 def : Pat<(addc GR32:$src1, GR32:$src2),
3173 (ADD32rr GR32:$src1, GR32:$src2)>;
3174 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3175 (ADD32rm GR32:$src1, addr:$src2)>;
3176 def : Pat<(addc GR32:$src1, imm:$src2),
3177 (ADD32ri GR32:$src1, imm:$src2)>;
3178 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3179 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3181 def : Pat<(subc GR32:$src1, GR32:$src2),
3182 (SUB32rr GR32:$src1, GR32:$src2)>;
3183 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3184 (SUB32rm GR32:$src1, addr:$src2)>;
3185 def : Pat<(subc GR32:$src1, imm:$src2),
3186 (SUB32ri GR32:$src1, imm:$src2)>;
3187 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3188 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3192 // TEST R,R is smaller than CMP R,0
3193 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3194 (TEST8rr GR8:$src1, GR8:$src1)>;
3195 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3196 (TEST16rr GR16:$src1, GR16:$src1)>;
3197 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3198 (TEST32rr GR32:$src1, GR32:$src1)>;
3200 // Conditional moves with folded loads with operands swapped and conditions
3202 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3203 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3204 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3205 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3206 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3207 (CMOVB16rm GR16:$src2, addr:$src1)>;
3208 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3209 (CMOVB32rm GR32:$src2, addr:$src1)>;
3210 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3211 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3212 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3213 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3214 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3215 (CMOVE16rm GR16:$src2, addr:$src1)>;
3216 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3217 (CMOVE32rm GR32:$src2, addr:$src1)>;
3218 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3219 (CMOVA16rm GR16:$src2, addr:$src1)>;
3220 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3221 (CMOVA32rm GR32:$src2, addr:$src1)>;
3222 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3223 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3224 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3225 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3226 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3227 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3228 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3229 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3230 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3231 (CMOVL16rm GR16:$src2, addr:$src1)>;
3232 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3233 (CMOVL32rm GR32:$src2, addr:$src1)>;
3234 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3235 (CMOVG16rm GR16:$src2, addr:$src1)>;
3236 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3237 (CMOVG32rm GR32:$src2, addr:$src1)>;
3238 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3239 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3240 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3241 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3242 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3243 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3244 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3245 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3246 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3247 (CMOVP16rm GR16:$src2, addr:$src1)>;
3248 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3249 (CMOVP32rm GR32:$src2, addr:$src1)>;
3250 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3251 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3252 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3253 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3254 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3255 (CMOVS16rm GR16:$src2, addr:$src1)>;
3256 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3257 (CMOVS32rm GR32:$src2, addr:$src1)>;
3258 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3259 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3260 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3261 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3262 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3263 (CMOVO16rm GR16:$src2, addr:$src1)>;
3264 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3265 (CMOVO32rm GR32:$src2, addr:$src1)>;
3267 // zextload bool -> zextload byte
3268 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3269 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3270 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3272 // extload bool -> extload byte
3273 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3274 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3275 Requires<[In32BitMode]>;
3276 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3277 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3278 Requires<[In32BitMode]>;
3279 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3280 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3283 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3284 Requires<[In32BitMode]>;
3285 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3286 Requires<[In32BitMode]>;
3287 def : Pat<(i32 (anyext GR16:$src)),
3288 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
3290 // (and (i32 load), 255) -> (zextload i8)
3291 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3292 (MOVZX32rm8 addr:$src)>;
3293 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3294 (MOVZX32rm16 addr:$src)>;
3296 //===----------------------------------------------------------------------===//
3298 //===----------------------------------------------------------------------===//
3300 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3301 // +128 doesn't, so in this special case use a sub instead of an add.
3302 def : Pat<(add GR16:$src1, 128),
3303 (SUB16ri8 GR16:$src1, -128)>;
3304 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3305 (SUB16mi8 addr:$dst, -128)>;
3306 def : Pat<(add GR32:$src1, 128),
3307 (SUB32ri8 GR32:$src1, -128)>;
3308 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3309 (SUB32mi8 addr:$dst, -128)>;
3311 // r & (2^16-1) ==> movz
3312 def : Pat<(and GR32:$src1, 0xffff),
3313 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
3314 // r & (2^8-1) ==> movz
3315 def : Pat<(and GR32:$src1, 0xff),
3316 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3317 x86_subreg_8bit)))>,
3318 Requires<[In32BitMode]>;
3319 // r & (2^8-1) ==> movz
3320 def : Pat<(and GR16:$src1, 0xff),
3321 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3322 x86_subreg_8bit)))>,
3323 Requires<[In32BitMode]>;
3325 // sext_inreg patterns
3326 def : Pat<(sext_inreg GR32:$src, i16),
3327 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3328 def : Pat<(sext_inreg GR32:$src, i8),
3329 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3330 x86_subreg_8bit)))>,
3331 Requires<[In32BitMode]>;
3332 def : Pat<(sext_inreg GR16:$src, i8),
3333 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3334 x86_subreg_8bit)))>,
3335 Requires<[In32BitMode]>;
3338 def : Pat<(i16 (trunc GR32:$src)),
3339 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3340 def : Pat<(i8 (trunc GR32:$src)),
3341 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3342 Requires<[In32BitMode]>;
3343 def : Pat<(i8 (trunc GR16:$src)),
3344 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
3345 Requires<[In32BitMode]>;
3347 // (shl x, 1) ==> (add x, x)
3348 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3349 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3350 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3352 // (shl x (and y, 31)) ==> (shl x, y)
3353 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3354 (SHL8rCL GR8:$src1)>;
3355 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3356 (SHL16rCL GR16:$src1)>;
3357 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3358 (SHL32rCL GR32:$src1)>;
3359 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3360 (SHL8mCL addr:$dst)>;
3361 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3362 (SHL16mCL addr:$dst)>;
3363 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3364 (SHL32mCL addr:$dst)>;
3366 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3367 (SHR8rCL GR8:$src1)>;
3368 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3369 (SHR16rCL GR16:$src1)>;
3370 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3371 (SHR32rCL GR32:$src1)>;
3372 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3373 (SHR8mCL addr:$dst)>;
3374 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3375 (SHR16mCL addr:$dst)>;
3376 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3377 (SHR32mCL addr:$dst)>;
3379 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3380 (SAR8rCL GR8:$src1)>;
3381 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3382 (SAR16rCL GR16:$src1)>;
3383 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3384 (SAR32rCL GR32:$src1)>;
3385 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3386 (SAR8mCL addr:$dst)>;
3387 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3388 (SAR16mCL addr:$dst)>;
3389 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3390 (SAR32mCL addr:$dst)>;
3392 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3393 def : Pat<(or (srl GR32:$src1, CL:$amt),
3394 (shl GR32:$src2, (sub 32, CL:$amt))),
3395 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3397 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3398 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3399 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3401 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3402 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3403 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3405 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3406 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3408 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3410 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3411 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3413 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3414 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3415 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3417 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3418 def : Pat<(or (shl GR32:$src1, CL:$amt),
3419 (srl GR32:$src2, (sub 32, CL:$amt))),
3420 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3422 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3423 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3424 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3426 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3427 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3428 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3430 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3431 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3433 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3435 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3436 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3438 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3439 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3440 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3442 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3443 def : Pat<(or (srl GR16:$src1, CL:$amt),
3444 (shl GR16:$src2, (sub 16, CL:$amt))),
3445 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3447 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3448 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3449 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3451 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3452 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3453 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3455 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3456 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3458 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3460 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3461 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3463 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3464 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3465 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3467 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3468 def : Pat<(or (shl GR16:$src1, CL:$amt),
3469 (srl GR16:$src2, (sub 16, CL:$amt))),
3470 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3472 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3473 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3474 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3476 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3477 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3478 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3480 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3481 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3483 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3485 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3486 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3488 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3489 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3490 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3492 //===----------------------------------------------------------------------===//
3493 // EFLAGS-defining Patterns
3494 //===----------------------------------------------------------------------===//
3496 // Register-Register Addition with EFLAGS result
3497 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
3499 (ADD8rr GR8:$src1, GR8:$src2)>;
3501 // Register-Register Addition with EFLAGS result
3502 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
3504 (ADD16rr GR16:$src1, GR16:$src2)>;
3505 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
3507 (ADD32rr GR32:$src1, GR32:$src2)>;
3509 // Register-Memory Addition with EFLAGS result
3510 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
3512 (ADD8rm GR8:$src1, addr:$src2)>;
3513 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
3515 (ADD16rm GR16:$src1, addr:$src2)>;
3516 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
3518 (ADD32rm GR32:$src1, addr:$src2)>;
3520 // Register-Integer Addition with EFLAGS result
3521 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
3523 (ADD8ri GR8:$src1, imm:$src2)>;
3525 // Register-Integer Addition with EFLAGS result
3526 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
3528 (ADD16ri GR16:$src1, imm:$src2)>;
3529 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
3531 (ADD32ri GR32:$src1, imm:$src2)>;
3532 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
3534 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3535 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
3537 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3539 // Memory-Register Addition with EFLAGS result
3540 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
3543 (ADD8mr addr:$dst, GR8:$src2)>;
3544 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
3547 (ADD16mr addr:$dst, GR16:$src2)>;
3548 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
3551 (ADD32mr addr:$dst, GR32:$src2)>;
3552 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
3555 (ADD8mi addr:$dst, imm:$src2)>;
3556 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
3559 (ADD16mi addr:$dst, imm:$src2)>;
3560 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
3563 (ADD32mi addr:$dst, imm:$src2)>;
3564 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3567 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3568 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3571 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3573 // Register-Register Subtraction with EFLAGS result
3574 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
3576 (SUB8rr GR8:$src1, GR8:$src2)>;
3577 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
3579 (SUB16rr GR16:$src1, GR16:$src2)>;
3580 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
3582 (SUB32rr GR32:$src1, GR32:$src2)>;
3584 // Register-Memory Subtraction with EFLAGS result
3585 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
3587 (SUB8rm GR8:$src1, addr:$src2)>;
3588 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
3590 (SUB16rm GR16:$src1, addr:$src2)>;
3591 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
3593 (SUB32rm GR32:$src1, addr:$src2)>;
3595 // Register-Integer Subtraction with EFLAGS result
3596 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
3598 (SUB8ri GR8:$src1, imm:$src2)>;
3599 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
3601 (SUB16ri GR16:$src1, imm:$src2)>;
3602 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
3604 (SUB32ri GR32:$src1, imm:$src2)>;
3605 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
3607 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3608 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
3610 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3612 // Memory-Register Subtraction with EFLAGS result
3613 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
3616 (SUB8mr addr:$dst, GR8:$src2)>;
3617 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
3620 (SUB16mr addr:$dst, GR16:$src2)>;
3621 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
3624 (SUB32mr addr:$dst, GR32:$src2)>;
3626 // Memory-Integer Subtraction with EFLAGS result
3627 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
3630 (SUB8mi addr:$dst, imm:$src2)>;
3631 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
3634 (SUB16mi addr:$dst, imm:$src2)>;
3635 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
3638 (SUB32mi addr:$dst, imm:$src2)>;
3639 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3642 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3643 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3646 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3649 // Register-Register Signed Integer Multiply with EFLAGS result
3650 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
3652 (IMUL16rr GR16:$src1, GR16:$src2)>;
3653 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
3655 (IMUL32rr GR32:$src1, GR32:$src2)>;
3657 // Register-Memory Signed Integer Multiply with EFLAGS result
3658 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
3660 (IMUL16rm GR16:$src1, addr:$src2)>;
3661 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
3663 (IMUL32rm GR32:$src1, addr:$src2)>;
3665 // Register-Integer Signed Integer Multiply with EFLAGS result
3666 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
3668 (IMUL16rri GR16:$src1, imm:$src2)>;
3669 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
3671 (IMUL32rri GR32:$src1, imm:$src2)>;
3672 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
3674 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
3675 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
3677 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3679 // Memory-Integer Signed Integer Multiply with EFLAGS result
3680 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
3682 (IMUL16rmi addr:$src1, imm:$src2)>;
3683 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
3685 (IMUL32rmi addr:$src1, imm:$src2)>;
3686 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
3688 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
3689 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
3691 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3693 // Optimize multiply by 2 with EFLAGS result.
3694 let AddedComplexity = 2 in {
3695 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
3697 (ADD16rr GR16:$src1, GR16:$src1)>;
3699 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
3701 (ADD32rr GR32:$src1, GR32:$src1)>;
3704 // INC and DEC with EFLAGS result. Note that these do not set CF.
3705 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3707 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3710 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3712 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3716 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
3717 (INC16r GR16:$src)>;
3718 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3720 (INC16m addr:$dst)>;
3721 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
3722 (DEC16r GR16:$src)>;
3723 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3725 (DEC16m addr:$dst)>;
3727 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
3728 (INC32r GR32:$src)>;
3729 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3731 (INC32m addr:$dst)>;
3732 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
3733 (DEC32r GR32:$src)>;
3734 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3736 (DEC32m addr:$dst)>;
3738 //===----------------------------------------------------------------------===//
3739 // Floating Point Stack Support
3740 //===----------------------------------------------------------------------===//
3742 include "X86InstrFPStack.td"
3744 //===----------------------------------------------------------------------===//
3746 //===----------------------------------------------------------------------===//
3748 include "X86Instr64bit.td"
3750 //===----------------------------------------------------------------------===//
3751 // XMM Floating point support (requires SSE / SSE2)
3752 //===----------------------------------------------------------------------===//
3754 include "X86InstrSSE.td"
3756 //===----------------------------------------------------------------------===//
3757 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3758 //===----------------------------------------------------------------------===//
3760 include "X86InstrMMX.td"