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,
37 def SDTX86BrCond : SDTypeProfile<0, 3,
38 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
41 def SDTX86SetCC : SDTypeProfile<1, 2,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
45 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
47 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
49 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
51 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
53 def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
54 def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
57 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
59 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
61 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
63 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
65 def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
67 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
69 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
71 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
73 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
74 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
75 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
76 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
78 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
80 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
82 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
83 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
85 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
87 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
90 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
91 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
102 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
105 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
106 [SDNPHasChain, SDNPMayStore,
107 SDNPMayLoad, SDNPMemOperand]>;
108 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
109 [SDNPHasChain, SDNPMayStore,
110 SDNPMayLoad, SDNPMemOperand]>;
111 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
112 [SDNPHasChain, SDNPMayStore,
113 SDNPMayLoad, SDNPMemOperand]>;
114 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
115 [SDNPHasChain, SDNPOptInFlag]>;
117 def X86callseq_start :
118 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
119 [SDNPHasChain, SDNPOutFlag]>;
121 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
122 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
124 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
125 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
127 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
128 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
129 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
130 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
133 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
134 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
136 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
137 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
139 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
140 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
141 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
142 SDT_X86SegmentBaseAddress, []>;
144 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
147 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
148 [SDNPHasChain, SDNPOptInFlag]>;
150 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
151 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
152 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
153 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
154 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
155 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
157 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
159 //===----------------------------------------------------------------------===//
160 // X86 Operand Definitions.
163 def i32imm_pcrel : Operand<i32> {
164 let PrintMethod = "print_pcrel_imm";
167 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
168 // the index operand of an address, to conform to x86 encoding restrictions.
169 def ptr_rc_nosp : PointerLikeRegClass<1>;
171 // *mem - Operand definitions for the funky X86 addressing mode operands.
173 class X86MemOperand<string printMethod> : Operand<iPTR> {
174 let PrintMethod = printMethod;
175 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
178 def i8mem : X86MemOperand<"printi8mem">;
179 def i16mem : X86MemOperand<"printi16mem">;
180 def i32mem : X86MemOperand<"printi32mem">;
181 def i64mem : X86MemOperand<"printi64mem">;
182 def i128mem : X86MemOperand<"printi128mem">;
183 def i256mem : X86MemOperand<"printi256mem">;
184 def f32mem : X86MemOperand<"printf32mem">;
185 def f64mem : X86MemOperand<"printf64mem">;
186 def f80mem : X86MemOperand<"printf80mem">;
187 def f128mem : X86MemOperand<"printf128mem">;
188 def f256mem : X86MemOperand<"printf256mem">;
190 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
191 // plain GR64, so that it doesn't potentially require a REX prefix.
192 def i8mem_NOREX : Operand<i64> {
193 let PrintMethod = "printi8mem";
194 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
197 def lea32mem : Operand<i32> {
198 let PrintMethod = "printlea32mem";
199 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
202 def SSECC : Operand<i8> {
203 let PrintMethod = "printSSECC";
206 def piclabel: Operand<i32> {
207 let PrintMethod = "printPICLabel";
210 // A couple of more descriptive operand definitions.
211 // 16-bits but only 8 bits are significant.
212 def i16i8imm : Operand<i16>;
213 // 32-bits but only 8 bits are significant.
214 def i32i8imm : Operand<i32>;
216 // Branch targets have OtherVT type and print as pc-relative values.
217 def brtarget : Operand<OtherVT> {
218 let PrintMethod = "print_pcrel_imm";
221 def brtarget8 : Operand<OtherVT> {
222 let PrintMethod = "print_pcrel_imm";
225 //===----------------------------------------------------------------------===//
226 // X86 Complex Pattern Definitions.
229 // Define X86 specific addressing mode.
230 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
231 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
232 [add, sub, mul, X86mul_imm, shl, or, frameindex],
234 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
235 [tglobaltlsaddr], []>;
237 //===----------------------------------------------------------------------===//
238 // X86 Instruction Predicate Definitions.
239 def HasMMX : Predicate<"Subtarget->hasMMX()">;
240 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
241 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
242 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
243 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
244 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
245 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
246 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
247 def HasAVX : Predicate<"Subtarget->hasAVX()">;
248 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
249 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
250 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
251 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
252 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
253 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
254 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
255 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
256 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
257 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
258 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
259 def OptForSpeed : Predicate<"!OptForSize">;
260 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
261 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
263 //===----------------------------------------------------------------------===//
264 // X86 Instruction Format Definitions.
267 include "X86InstrFormats.td"
269 //===----------------------------------------------------------------------===//
270 // Pattern fragments...
273 // X86 specific condition code. These correspond to CondCode in
274 // X86InstrInfo.h. They must be kept in synch.
275 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
276 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
277 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
278 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
279 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
280 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
281 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
282 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
283 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
284 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
285 def X86_COND_NO : PatLeaf<(i8 10)>;
286 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
287 def X86_COND_NS : PatLeaf<(i8 12)>;
288 def X86_COND_O : PatLeaf<(i8 13)>;
289 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
290 def X86_COND_S : PatLeaf<(i8 15)>;
292 def i16immSExt8 : PatLeaf<(i16 imm), [{
293 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
294 // sign extended field.
295 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
298 def i32immSExt8 : PatLeaf<(i32 imm), [{
299 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
300 // sign extended field.
301 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
304 // Helper fragments for loads.
305 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
306 // known to be 32-bit aligned or better. Ditto for i8 to i16.
307 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
308 LoadSDNode *LD = cast<LoadSDNode>(N);
309 if (const Value *Src = LD->getSrcValue())
310 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
311 if (PT->getAddressSpace() > 255)
313 ISD::LoadExtType ExtType = LD->getExtensionType();
314 if (ExtType == ISD::NON_EXTLOAD)
316 if (ExtType == ISD::EXTLOAD)
317 return LD->getAlignment() >= 2 && !LD->isVolatile();
321 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
322 LoadSDNode *LD = cast<LoadSDNode>(N);
323 if (const Value *Src = LD->getSrcValue())
324 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
325 if (PT->getAddressSpace() > 255)
327 ISD::LoadExtType ExtType = LD->getExtensionType();
328 if (ExtType == ISD::EXTLOAD)
329 return LD->getAlignment() >= 2 && !LD->isVolatile();
333 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
334 LoadSDNode *LD = cast<LoadSDNode>(N);
335 if (const Value *Src = LD->getSrcValue())
336 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
337 if (PT->getAddressSpace() > 255)
339 ISD::LoadExtType ExtType = LD->getExtensionType();
340 if (ExtType == ISD::NON_EXTLOAD)
342 if (ExtType == ISD::EXTLOAD)
343 return LD->getAlignment() >= 4 && !LD->isVolatile();
347 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
348 LoadSDNode *LD = cast<LoadSDNode>(N);
349 if (const Value *Src = LD->getSrcValue())
350 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
351 if (PT->getAddressSpace() > 255)
353 if (LD->isVolatile())
355 ISD::LoadExtType ExtType = LD->getExtensionType();
356 if (ExtType == ISD::NON_EXTLOAD)
358 if (ExtType == ISD::EXTLOAD)
359 return LD->getAlignment() >= 4;
363 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
364 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
365 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
366 return PT->getAddressSpace() == 256;
370 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
373 return PT->getAddressSpace() == 257;
377 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
378 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
380 if (PT->getAddressSpace() > 255)
384 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
385 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
386 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
387 if (PT->getAddressSpace() > 255)
392 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
393 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
394 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
395 if (PT->getAddressSpace() > 255)
399 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
400 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
401 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
402 if (PT->getAddressSpace() > 255)
406 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
407 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
408 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
409 if (PT->getAddressSpace() > 255)
414 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
415 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
416 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
418 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
419 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
420 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
421 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
422 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
423 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
425 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
426 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
427 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
428 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
429 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
430 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
433 // An 'and' node with a single use.
434 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
435 return N->hasOneUse();
437 // An 'srl' node with a single use.
438 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
439 return N->hasOneUse();
441 // An 'trunc' node with a single use.
442 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
443 return N->hasOneUse();
446 // 'shld' and 'shrd' instruction patterns. Note that even though these have
447 // the srl and shl in their patterns, the C++ code must still check for them,
448 // because predicates are tested before children nodes are explored.
450 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
451 (or (srl node:$src1, node:$amt1),
452 (shl node:$src2, node:$amt2)), [{
453 assert(N->getOpcode() == ISD::OR);
454 return N->getOperand(0).getOpcode() == ISD::SRL &&
455 N->getOperand(1).getOpcode() == ISD::SHL &&
456 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
457 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
458 N->getOperand(0).getConstantOperandVal(1) ==
459 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
462 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
463 (or (shl node:$src1, node:$amt1),
464 (srl node:$src2, node:$amt2)), [{
465 assert(N->getOpcode() == ISD::OR);
466 return N->getOperand(0).getOpcode() == ISD::SHL &&
467 N->getOperand(1).getOpcode() == ISD::SRL &&
468 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
469 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
470 N->getOperand(0).getConstantOperandVal(1) ==
471 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
474 //===----------------------------------------------------------------------===//
475 // Instruction list...
478 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
479 // a stack adjustment and the codegen must know that they may modify the stack
480 // pointer before prolog-epilog rewriting occurs.
481 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
482 // sub / add which can clobber EFLAGS.
483 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
484 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
486 [(X86callseq_start timm:$amt)]>,
487 Requires<[In32BitMode]>;
488 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
490 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
491 Requires<[In32BitMode]>;
495 let neverHasSideEffects = 1 in {
496 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
497 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
498 "nopl\t$zero", []>, TB;
502 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
503 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
507 //===----------------------------------------------------------------------===//
508 // Control Flow Instructions...
511 // Return instructions.
512 let isTerminator = 1, isReturn = 1, isBarrier = 1,
513 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
514 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
517 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
519 [(X86retflag imm:$amt)]>;
522 // All branches are RawFrm, Void, Branch, and Terminators
523 let isBranch = 1, isTerminator = 1 in
524 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
525 I<opcode, RawFrm, (outs), ins, asm, pattern>;
527 let isBranch = 1, isBarrier = 1 in {
528 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
529 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
533 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
534 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
535 [(brind GR32:$dst)]>;
536 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
537 [(brind (loadi32 addr:$dst))]>;
540 // Conditional branches
541 let Uses = [EFLAGS] in {
542 // Short conditional jumps
543 def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
544 def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
545 def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
546 def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
547 def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
548 def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
549 def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
550 def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
551 def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
552 def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
553 def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
554 def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
555 def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
556 def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
557 def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
558 def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
560 def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
562 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
563 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
564 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
565 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
566 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
567 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
568 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
569 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
570 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
571 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
572 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
573 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
575 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
576 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
577 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
578 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
579 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
580 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
581 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
582 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
584 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
585 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
586 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
587 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
588 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
589 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
590 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
591 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
592 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
593 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
594 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
595 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
598 //===----------------------------------------------------------------------===//
599 // Call Instructions...
602 // All calls clobber the non-callee saved registers. ESP is marked as
603 // a use to prevent stack-pointer assignments that appear immediately
604 // before calls from potentially appearing dead. Uses for argument
605 // registers are added manually.
606 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
607 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
608 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
609 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
611 def CALLpcrel32 : Ii32<0xE8, RawFrm,
612 (outs), (ins i32imm_pcrel:$dst,variable_ops),
614 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
615 "call\t{*}$dst", [(X86call GR32:$dst)]>;
616 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
617 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
622 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
623 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
624 "#TC_RETURN $dst $offset",
627 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
628 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
629 "#TC_RETURN $dst $offset",
632 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
634 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
636 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
637 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
639 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
640 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
641 "jmp\t{*}$dst # TAILCALL", []>;
643 //===----------------------------------------------------------------------===//
644 // Miscellaneous Instructions...
646 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
647 def LEAVE : I<0xC9, RawFrm,
648 (outs), (ins), "leave", []>;
650 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
652 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
655 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
658 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
659 def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
660 "push{l}\t$imm", []>;
661 def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
662 "push{l}\t$imm", []>;
663 def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
664 "push{l}\t$imm", []>;
667 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
668 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
669 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
670 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
672 let isTwoAddress = 1 in // GR32 = bswap GR32
673 def BSWAP32r : I<0xC8, AddRegFrm,
674 (outs GR32:$dst), (ins GR32:$src),
676 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
679 // Bit scan instructions.
680 let Defs = [EFLAGS] in {
681 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
682 "bsf{w}\t{$src, $dst|$dst, $src}",
683 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
684 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
685 "bsf{w}\t{$src, $dst|$dst, $src}",
686 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
687 (implicit EFLAGS)]>, TB;
688 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
689 "bsf{l}\t{$src, $dst|$dst, $src}",
690 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
691 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
692 "bsf{l}\t{$src, $dst|$dst, $src}",
693 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
694 (implicit EFLAGS)]>, TB;
696 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
697 "bsr{w}\t{$src, $dst|$dst, $src}",
698 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
699 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
700 "bsr{w}\t{$src, $dst|$dst, $src}",
701 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
702 (implicit EFLAGS)]>, TB;
703 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
704 "bsr{l}\t{$src, $dst|$dst, $src}",
705 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
706 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
707 "bsr{l}\t{$src, $dst|$dst, $src}",
708 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
709 (implicit EFLAGS)]>, TB;
712 let neverHasSideEffects = 1 in
713 def LEA16r : I<0x8D, MRMSrcMem,
714 (outs GR16:$dst), (ins i32mem:$src),
715 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
716 let isReMaterializable = 1 in
717 def LEA32r : I<0x8D, MRMSrcMem,
718 (outs GR32:$dst), (ins lea32mem:$src),
719 "lea{l}\t{$src|$dst}, {$dst|$src}",
720 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
722 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
723 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
724 [(X86rep_movs i8)]>, REP;
725 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
726 [(X86rep_movs i16)]>, REP, OpSize;
727 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
728 [(X86rep_movs i32)]>, REP;
731 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
732 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
733 [(X86rep_stos i8)]>, REP;
734 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
735 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
736 [(X86rep_stos i16)]>, REP, OpSize;
737 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
738 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
739 [(X86rep_stos i32)]>, REP;
741 let Defs = [RAX, RDX] in
742 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
745 let isBarrier = 1, hasCtrlDep = 1 in {
746 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
749 //===----------------------------------------------------------------------===//
750 // Input/Output Instructions...
752 let Defs = [AL], Uses = [DX] in
753 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
754 "in{b}\t{%dx, %al|%AL, %DX}", []>;
755 let Defs = [AX], Uses = [DX] in
756 def IN16rr : I<0xED, RawFrm, (outs), (ins),
757 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
758 let Defs = [EAX], Uses = [DX] in
759 def IN32rr : I<0xED, RawFrm, (outs), (ins),
760 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
763 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
764 "in{b}\t{$port, %al|%AL, $port}", []>;
766 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
767 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
769 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
770 "in{l}\t{$port, %eax|%EAX, $port}", []>;
772 let Uses = [DX, AL] in
773 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
774 "out{b}\t{%al, %dx|%DX, %AL}", []>;
775 let Uses = [DX, AX] in
776 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
777 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
778 let Uses = [DX, EAX] in
779 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
780 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
783 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
784 "out{b}\t{%al, $port|$port, %AL}", []>;
786 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
787 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
789 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
790 "out{l}\t{%eax, $port|$port, %EAX}", []>;
792 //===----------------------------------------------------------------------===//
793 // Move Instructions...
795 let neverHasSideEffects = 1 in {
796 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
797 "mov{b}\t{$src, $dst|$dst, $src}", []>;
798 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
799 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
800 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
801 "mov{l}\t{$src, $dst|$dst, $src}", []>;
803 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
804 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
805 "mov{b}\t{$src, $dst|$dst, $src}",
806 [(set GR8:$dst, imm:$src)]>;
807 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
808 "mov{w}\t{$src, $dst|$dst, $src}",
809 [(set GR16:$dst, imm:$src)]>, OpSize;
810 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
811 "mov{l}\t{$src, $dst|$dst, $src}",
812 [(set GR32:$dst, imm:$src)]>;
814 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
815 "mov{b}\t{$src, $dst|$dst, $src}",
816 [(store (i8 imm:$src), addr:$dst)]>;
817 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
818 "mov{w}\t{$src, $dst|$dst, $src}",
819 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
820 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
821 "mov{l}\t{$src, $dst|$dst, $src}",
822 [(store (i32 imm:$src), addr:$dst)]>;
824 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
825 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
826 "mov{b}\t{$src, $dst|$dst, $src}",
827 [(set GR8:$dst, (loadi8 addr:$src))]>;
828 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
829 "mov{w}\t{$src, $dst|$dst, $src}",
830 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
831 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
832 "mov{l}\t{$src, $dst|$dst, $src}",
833 [(set GR32:$dst, (loadi32 addr:$src))]>;
836 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
837 "mov{b}\t{$src, $dst|$dst, $src}",
838 [(store GR8:$src, addr:$dst)]>;
839 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
840 "mov{w}\t{$src, $dst|$dst, $src}",
841 [(store GR16:$src, addr:$dst)]>, OpSize;
842 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
843 "mov{l}\t{$src, $dst|$dst, $src}",
844 [(store GR32:$src, addr:$dst)]>;
846 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
847 // that they can be used for copying and storing h registers, which can't be
848 // encoded when a REX prefix is present.
849 let neverHasSideEffects = 1 in
850 def MOV8rr_NOREX : I<0x88, MRMDestReg,
851 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
852 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
854 def MOV8mr_NOREX : I<0x88, MRMDestMem,
855 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
856 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
858 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
859 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
860 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
861 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
863 //===----------------------------------------------------------------------===//
864 // Fixed-Register Multiplication and Division Instructions...
867 // Extra precision multiplication
868 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
869 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
870 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
871 // This probably ought to be moved to a def : Pat<> if the
872 // syntax can be accepted.
873 [(set AL, (mul AL, GR8:$src)),
874 (implicit EFLAGS)]>; // AL,AH = AL*GR8
876 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
877 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
879 []>, OpSize; // AX,DX = AX*GR16
881 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
882 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
884 []>; // EAX,EDX = EAX*GR32
886 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
887 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
889 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
890 // This probably ought to be moved to a def : Pat<> if the
891 // syntax can be accepted.
892 [(set AL, (mul AL, (loadi8 addr:$src))),
893 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
895 let mayLoad = 1, neverHasSideEffects = 1 in {
896 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
897 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
899 []>, OpSize; // AX,DX = AX*[mem16]
901 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
902 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
904 []>; // EAX,EDX = EAX*[mem32]
907 let neverHasSideEffects = 1 in {
908 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
909 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
911 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
912 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
913 OpSize; // AX,DX = AX*GR16
914 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
915 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
916 // EAX,EDX = EAX*GR32
918 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
919 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
920 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
921 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
922 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
923 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
924 let Defs = [EAX,EDX], Uses = [EAX] in
925 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
926 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
928 } // neverHasSideEffects
930 // unsigned division/remainder
931 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
932 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
934 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
935 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
936 "div{w}\t$src", []>, OpSize;
937 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
938 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
941 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
942 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
944 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
945 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
946 "div{w}\t$src", []>, OpSize;
947 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
948 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
952 // Signed division/remainder.
953 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
954 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
955 "idiv{b}\t$src", []>;
956 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
957 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
958 "idiv{w}\t$src", []>, OpSize;
959 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
960 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
961 "idiv{l}\t$src", []>;
962 let mayLoad = 1, mayLoad = 1 in {
963 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
964 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
965 "idiv{b}\t$src", []>;
966 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
967 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
968 "idiv{w}\t$src", []>, OpSize;
969 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
970 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
971 "idiv{l}\t$src", []>;
974 //===----------------------------------------------------------------------===//
975 // Two address Instructions.
977 let isTwoAddress = 1 in {
980 let Uses = [EFLAGS] in {
981 let isCommutable = 1 in {
982 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
983 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
984 "cmovb\t{$src2, $dst|$dst, $src2}",
985 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
986 X86_COND_B, EFLAGS))]>,
988 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
989 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
990 "cmovb\t{$src2, $dst|$dst, $src2}",
991 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
992 X86_COND_B, EFLAGS))]>,
994 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
995 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
996 "cmovae\t{$src2, $dst|$dst, $src2}",
997 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
998 X86_COND_AE, EFLAGS))]>,
1000 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1001 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1002 "cmovae\t{$src2, $dst|$dst, $src2}",
1003 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1004 X86_COND_AE, EFLAGS))]>,
1006 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1007 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1008 "cmove\t{$src2, $dst|$dst, $src2}",
1009 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1010 X86_COND_E, EFLAGS))]>,
1012 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1013 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1014 "cmove\t{$src2, $dst|$dst, $src2}",
1015 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1016 X86_COND_E, EFLAGS))]>,
1018 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1019 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1020 "cmovne\t{$src2, $dst|$dst, $src2}",
1021 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1022 X86_COND_NE, EFLAGS))]>,
1024 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1025 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1026 "cmovne\t{$src2, $dst|$dst, $src2}",
1027 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1028 X86_COND_NE, EFLAGS))]>,
1030 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1031 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1032 "cmovbe\t{$src2, $dst|$dst, $src2}",
1033 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1034 X86_COND_BE, EFLAGS))]>,
1036 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1037 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1038 "cmovbe\t{$src2, $dst|$dst, $src2}",
1039 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1040 X86_COND_BE, EFLAGS))]>,
1042 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1043 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1044 "cmova\t{$src2, $dst|$dst, $src2}",
1045 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1046 X86_COND_A, EFLAGS))]>,
1048 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1049 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1050 "cmova\t{$src2, $dst|$dst, $src2}",
1051 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1052 X86_COND_A, EFLAGS))]>,
1054 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1055 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1056 "cmovl\t{$src2, $dst|$dst, $src2}",
1057 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1058 X86_COND_L, EFLAGS))]>,
1060 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1061 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1062 "cmovl\t{$src2, $dst|$dst, $src2}",
1063 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1064 X86_COND_L, EFLAGS))]>,
1066 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1067 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1068 "cmovge\t{$src2, $dst|$dst, $src2}",
1069 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1070 X86_COND_GE, EFLAGS))]>,
1072 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1073 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1074 "cmovge\t{$src2, $dst|$dst, $src2}",
1075 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1076 X86_COND_GE, EFLAGS))]>,
1078 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1079 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1080 "cmovle\t{$src2, $dst|$dst, $src2}",
1081 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1082 X86_COND_LE, EFLAGS))]>,
1084 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1085 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1086 "cmovle\t{$src2, $dst|$dst, $src2}",
1087 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1088 X86_COND_LE, EFLAGS))]>,
1090 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1091 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1092 "cmovg\t{$src2, $dst|$dst, $src2}",
1093 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1094 X86_COND_G, EFLAGS))]>,
1096 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1097 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1098 "cmovg\t{$src2, $dst|$dst, $src2}",
1099 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1100 X86_COND_G, EFLAGS))]>,
1102 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1103 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1104 "cmovs\t{$src2, $dst|$dst, $src2}",
1105 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1106 X86_COND_S, EFLAGS))]>,
1108 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1109 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1110 "cmovs\t{$src2, $dst|$dst, $src2}",
1111 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1112 X86_COND_S, EFLAGS))]>,
1114 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1115 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1116 "cmovns\t{$src2, $dst|$dst, $src2}",
1117 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1118 X86_COND_NS, EFLAGS))]>,
1120 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1121 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1122 "cmovns\t{$src2, $dst|$dst, $src2}",
1123 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1124 X86_COND_NS, EFLAGS))]>,
1126 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1127 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1128 "cmovp\t{$src2, $dst|$dst, $src2}",
1129 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1130 X86_COND_P, EFLAGS))]>,
1132 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1133 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1134 "cmovp\t{$src2, $dst|$dst, $src2}",
1135 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1136 X86_COND_P, EFLAGS))]>,
1138 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1139 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1140 "cmovnp\t{$src2, $dst|$dst, $src2}",
1141 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1142 X86_COND_NP, EFLAGS))]>,
1144 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1145 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1146 "cmovnp\t{$src2, $dst|$dst, $src2}",
1147 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1148 X86_COND_NP, EFLAGS))]>,
1150 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1151 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1152 "cmovo\t{$src2, $dst|$dst, $src2}",
1153 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1154 X86_COND_O, EFLAGS))]>,
1156 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1157 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1158 "cmovo\t{$src2, $dst|$dst, $src2}",
1159 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1160 X86_COND_O, EFLAGS))]>,
1162 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1163 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1164 "cmovno\t{$src2, $dst|$dst, $src2}",
1165 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1166 X86_COND_NO, EFLAGS))]>,
1168 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1169 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1170 "cmovno\t{$src2, $dst|$dst, $src2}",
1171 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1172 X86_COND_NO, EFLAGS))]>,
1174 } // isCommutable = 1
1176 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1177 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1178 "cmovb\t{$src2, $dst|$dst, $src2}",
1179 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1180 X86_COND_B, EFLAGS))]>,
1182 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1183 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1184 "cmovb\t{$src2, $dst|$dst, $src2}",
1185 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1186 X86_COND_B, EFLAGS))]>,
1188 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1189 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1190 "cmovae\t{$src2, $dst|$dst, $src2}",
1191 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1192 X86_COND_AE, EFLAGS))]>,
1194 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1195 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1196 "cmovae\t{$src2, $dst|$dst, $src2}",
1197 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1198 X86_COND_AE, EFLAGS))]>,
1200 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1201 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1202 "cmove\t{$src2, $dst|$dst, $src2}",
1203 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1204 X86_COND_E, EFLAGS))]>,
1206 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1207 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1208 "cmove\t{$src2, $dst|$dst, $src2}",
1209 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1210 X86_COND_E, EFLAGS))]>,
1212 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1213 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1214 "cmovne\t{$src2, $dst|$dst, $src2}",
1215 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1216 X86_COND_NE, EFLAGS))]>,
1218 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1219 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1220 "cmovne\t{$src2, $dst|$dst, $src2}",
1221 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1222 X86_COND_NE, EFLAGS))]>,
1224 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1225 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1226 "cmovbe\t{$src2, $dst|$dst, $src2}",
1227 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1228 X86_COND_BE, EFLAGS))]>,
1230 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1231 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1232 "cmovbe\t{$src2, $dst|$dst, $src2}",
1233 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1234 X86_COND_BE, EFLAGS))]>,
1236 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1237 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1238 "cmova\t{$src2, $dst|$dst, $src2}",
1239 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1240 X86_COND_A, EFLAGS))]>,
1242 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1243 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1244 "cmova\t{$src2, $dst|$dst, $src2}",
1245 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1246 X86_COND_A, EFLAGS))]>,
1248 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1249 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1250 "cmovl\t{$src2, $dst|$dst, $src2}",
1251 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1252 X86_COND_L, EFLAGS))]>,
1254 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1255 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1256 "cmovl\t{$src2, $dst|$dst, $src2}",
1257 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1258 X86_COND_L, EFLAGS))]>,
1260 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1261 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1262 "cmovge\t{$src2, $dst|$dst, $src2}",
1263 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1264 X86_COND_GE, EFLAGS))]>,
1266 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1267 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1268 "cmovge\t{$src2, $dst|$dst, $src2}",
1269 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1270 X86_COND_GE, EFLAGS))]>,
1272 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1273 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1274 "cmovle\t{$src2, $dst|$dst, $src2}",
1275 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1276 X86_COND_LE, EFLAGS))]>,
1278 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1279 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1280 "cmovle\t{$src2, $dst|$dst, $src2}",
1281 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1282 X86_COND_LE, EFLAGS))]>,
1284 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1285 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1286 "cmovg\t{$src2, $dst|$dst, $src2}",
1287 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1288 X86_COND_G, EFLAGS))]>,
1290 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1291 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1292 "cmovg\t{$src2, $dst|$dst, $src2}",
1293 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1294 X86_COND_G, EFLAGS))]>,
1296 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1297 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1298 "cmovs\t{$src2, $dst|$dst, $src2}",
1299 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1300 X86_COND_S, EFLAGS))]>,
1302 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1303 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1304 "cmovs\t{$src2, $dst|$dst, $src2}",
1305 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1306 X86_COND_S, EFLAGS))]>,
1308 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1309 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1310 "cmovns\t{$src2, $dst|$dst, $src2}",
1311 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1312 X86_COND_NS, EFLAGS))]>,
1314 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1315 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1316 "cmovns\t{$src2, $dst|$dst, $src2}",
1317 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1318 X86_COND_NS, EFLAGS))]>,
1320 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1321 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1322 "cmovp\t{$src2, $dst|$dst, $src2}",
1323 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1324 X86_COND_P, EFLAGS))]>,
1326 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1327 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1328 "cmovp\t{$src2, $dst|$dst, $src2}",
1329 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1330 X86_COND_P, EFLAGS))]>,
1332 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1333 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1334 "cmovnp\t{$src2, $dst|$dst, $src2}",
1335 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1336 X86_COND_NP, EFLAGS))]>,
1338 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1339 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1340 "cmovnp\t{$src2, $dst|$dst, $src2}",
1341 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1342 X86_COND_NP, EFLAGS))]>,
1344 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1345 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1346 "cmovo\t{$src2, $dst|$dst, $src2}",
1347 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1348 X86_COND_O, EFLAGS))]>,
1350 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1351 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1352 "cmovo\t{$src2, $dst|$dst, $src2}",
1353 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1354 X86_COND_O, EFLAGS))]>,
1356 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1357 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1358 "cmovno\t{$src2, $dst|$dst, $src2}",
1359 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1360 X86_COND_NO, EFLAGS))]>,
1362 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1363 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1364 "cmovno\t{$src2, $dst|$dst, $src2}",
1365 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1366 X86_COND_NO, EFLAGS))]>,
1368 } // Uses = [EFLAGS]
1371 // unary instructions
1372 let CodeSize = 2 in {
1373 let Defs = [EFLAGS] in {
1374 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1375 [(set GR8:$dst, (ineg GR8:$src)),
1376 (implicit EFLAGS)]>;
1377 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1378 [(set GR16:$dst, (ineg GR16:$src)),
1379 (implicit EFLAGS)]>, OpSize;
1380 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1381 [(set GR32:$dst, (ineg GR32:$src)),
1382 (implicit EFLAGS)]>;
1383 let isTwoAddress = 0 in {
1384 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1385 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1386 (implicit EFLAGS)]>;
1387 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1388 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1389 (implicit EFLAGS)]>, OpSize;
1390 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1391 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1392 (implicit EFLAGS)]>;
1394 } // Defs = [EFLAGS]
1396 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1397 let AddedComplexity = 15 in {
1398 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1399 [(set GR8:$dst, (not GR8:$src))]>;
1400 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1401 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1402 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1403 [(set GR32:$dst, (not GR32:$src))]>;
1405 let isTwoAddress = 0 in {
1406 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1407 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1408 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1409 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1410 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1411 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1415 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1416 let Defs = [EFLAGS] in {
1418 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1419 [(set GR8:$dst, (add GR8:$src, 1)),
1420 (implicit EFLAGS)]>;
1421 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1422 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1423 [(set GR16:$dst, (add GR16:$src, 1)),
1424 (implicit EFLAGS)]>,
1425 OpSize, Requires<[In32BitMode]>;
1426 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1427 [(set GR32:$dst, (add GR32:$src, 1)),
1428 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1430 let isTwoAddress = 0, CodeSize = 2 in {
1431 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1432 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1433 (implicit EFLAGS)]>;
1434 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1435 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1436 (implicit EFLAGS)]>,
1437 OpSize, Requires<[In32BitMode]>;
1438 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1439 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1440 (implicit EFLAGS)]>,
1441 Requires<[In32BitMode]>;
1445 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1446 [(set GR8:$dst, (add GR8:$src, -1)),
1447 (implicit EFLAGS)]>;
1448 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1449 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1450 [(set GR16:$dst, (add GR16:$src, -1)),
1451 (implicit EFLAGS)]>,
1452 OpSize, Requires<[In32BitMode]>;
1453 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1454 [(set GR32:$dst, (add GR32:$src, -1)),
1455 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1458 let isTwoAddress = 0, CodeSize = 2 in {
1459 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1460 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1461 (implicit EFLAGS)]>;
1462 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1463 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1464 (implicit EFLAGS)]>,
1465 OpSize, Requires<[In32BitMode]>;
1466 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1467 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1468 (implicit EFLAGS)]>,
1469 Requires<[In32BitMode]>;
1471 } // Defs = [EFLAGS]
1473 // Logical operators...
1474 let Defs = [EFLAGS] in {
1475 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1476 def AND8rr : I<0x20, MRMDestReg,
1477 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1478 "and{b}\t{$src2, $dst|$dst, $src2}",
1479 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1480 (implicit EFLAGS)]>;
1481 def AND16rr : I<0x21, MRMDestReg,
1482 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1483 "and{w}\t{$src2, $dst|$dst, $src2}",
1484 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1485 (implicit EFLAGS)]>, OpSize;
1486 def AND32rr : I<0x21, MRMDestReg,
1487 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1488 "and{l}\t{$src2, $dst|$dst, $src2}",
1489 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1490 (implicit EFLAGS)]>;
1493 def AND8rm : I<0x22, MRMSrcMem,
1494 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1495 "and{b}\t{$src2, $dst|$dst, $src2}",
1496 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1497 (implicit EFLAGS)]>;
1498 def AND16rm : I<0x23, MRMSrcMem,
1499 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1500 "and{w}\t{$src2, $dst|$dst, $src2}",
1501 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1502 (implicit EFLAGS)]>, OpSize;
1503 def AND32rm : I<0x23, MRMSrcMem,
1504 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1505 "and{l}\t{$src2, $dst|$dst, $src2}",
1506 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1507 (implicit EFLAGS)]>;
1509 def AND8ri : Ii8<0x80, MRM4r,
1510 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1511 "and{b}\t{$src2, $dst|$dst, $src2}",
1512 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1513 (implicit EFLAGS)]>;
1514 def AND16ri : Ii16<0x81, MRM4r,
1515 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1516 "and{w}\t{$src2, $dst|$dst, $src2}",
1517 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1518 (implicit EFLAGS)]>, OpSize;
1519 def AND32ri : Ii32<0x81, MRM4r,
1520 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1521 "and{l}\t{$src2, $dst|$dst, $src2}",
1522 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1523 (implicit EFLAGS)]>;
1524 def AND16ri8 : Ii8<0x83, MRM4r,
1525 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1526 "and{w}\t{$src2, $dst|$dst, $src2}",
1527 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1528 (implicit EFLAGS)]>,
1530 def AND32ri8 : Ii8<0x83, MRM4r,
1531 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1532 "and{l}\t{$src2, $dst|$dst, $src2}",
1533 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1534 (implicit EFLAGS)]>;
1536 let isTwoAddress = 0 in {
1537 def AND8mr : I<0x20, MRMDestMem,
1538 (outs), (ins i8mem :$dst, GR8 :$src),
1539 "and{b}\t{$src, $dst|$dst, $src}",
1540 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1541 (implicit EFLAGS)]>;
1542 def AND16mr : I<0x21, MRMDestMem,
1543 (outs), (ins i16mem:$dst, GR16:$src),
1544 "and{w}\t{$src, $dst|$dst, $src}",
1545 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1546 (implicit EFLAGS)]>,
1548 def AND32mr : I<0x21, MRMDestMem,
1549 (outs), (ins i32mem:$dst, GR32:$src),
1550 "and{l}\t{$src, $dst|$dst, $src}",
1551 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1552 (implicit EFLAGS)]>;
1553 def AND8mi : Ii8<0x80, MRM4m,
1554 (outs), (ins i8mem :$dst, i8imm :$src),
1555 "and{b}\t{$src, $dst|$dst, $src}",
1556 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1557 (implicit EFLAGS)]>;
1558 def AND16mi : Ii16<0x81, MRM4m,
1559 (outs), (ins i16mem:$dst, i16imm:$src),
1560 "and{w}\t{$src, $dst|$dst, $src}",
1561 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1562 (implicit EFLAGS)]>,
1564 def AND32mi : Ii32<0x81, MRM4m,
1565 (outs), (ins i32mem:$dst, i32imm:$src),
1566 "and{l}\t{$src, $dst|$dst, $src}",
1567 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1568 (implicit EFLAGS)]>;
1569 def AND16mi8 : Ii8<0x83, MRM4m,
1570 (outs), (ins i16mem:$dst, i16i8imm :$src),
1571 "and{w}\t{$src, $dst|$dst, $src}",
1572 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1573 (implicit EFLAGS)]>,
1575 def AND32mi8 : Ii8<0x83, MRM4m,
1576 (outs), (ins i32mem:$dst, i32i8imm :$src),
1577 "and{l}\t{$src, $dst|$dst, $src}",
1578 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1579 (implicit EFLAGS)]>;
1583 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1584 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1585 "or{b}\t{$src2, $dst|$dst, $src2}",
1586 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1587 (implicit EFLAGS)]>;
1588 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1589 "or{w}\t{$src2, $dst|$dst, $src2}",
1590 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1591 (implicit EFLAGS)]>, OpSize;
1592 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1593 "or{l}\t{$src2, $dst|$dst, $src2}",
1594 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1595 (implicit EFLAGS)]>;
1597 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1598 "or{b}\t{$src2, $dst|$dst, $src2}",
1599 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1600 (implicit EFLAGS)]>;
1601 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1602 "or{w}\t{$src2, $dst|$dst, $src2}",
1603 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1604 (implicit EFLAGS)]>, OpSize;
1605 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1606 "or{l}\t{$src2, $dst|$dst, $src2}",
1607 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1608 (implicit EFLAGS)]>;
1610 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1611 "or{b}\t{$src2, $dst|$dst, $src2}",
1612 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1613 (implicit EFLAGS)]>;
1614 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1615 "or{w}\t{$src2, $dst|$dst, $src2}",
1616 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1617 (implicit EFLAGS)]>, OpSize;
1618 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1619 "or{l}\t{$src2, $dst|$dst, $src2}",
1620 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1621 (implicit EFLAGS)]>;
1623 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1624 "or{w}\t{$src2, $dst|$dst, $src2}",
1625 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1626 (implicit EFLAGS)]>, OpSize;
1627 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1628 "or{l}\t{$src2, $dst|$dst, $src2}",
1629 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1630 (implicit EFLAGS)]>;
1631 let isTwoAddress = 0 in {
1632 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1633 "or{b}\t{$src, $dst|$dst, $src}",
1634 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1635 (implicit EFLAGS)]>;
1636 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1637 "or{w}\t{$src, $dst|$dst, $src}",
1638 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1639 (implicit EFLAGS)]>, OpSize;
1640 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1641 "or{l}\t{$src, $dst|$dst, $src}",
1642 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1643 (implicit EFLAGS)]>;
1644 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1645 "or{b}\t{$src, $dst|$dst, $src}",
1646 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1647 (implicit EFLAGS)]>;
1648 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1649 "or{w}\t{$src, $dst|$dst, $src}",
1650 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1651 (implicit EFLAGS)]>,
1653 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1654 "or{l}\t{$src, $dst|$dst, $src}",
1655 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1656 (implicit EFLAGS)]>;
1657 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1658 "or{w}\t{$src, $dst|$dst, $src}",
1659 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1660 (implicit EFLAGS)]>,
1662 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1663 "or{l}\t{$src, $dst|$dst, $src}",
1664 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1665 (implicit EFLAGS)]>;
1666 } // isTwoAddress = 0
1669 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1670 def XOR8rr : I<0x30, MRMDestReg,
1671 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1672 "xor{b}\t{$src2, $dst|$dst, $src2}",
1673 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1674 (implicit EFLAGS)]>;
1675 def XOR16rr : I<0x31, MRMDestReg,
1676 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1677 "xor{w}\t{$src2, $dst|$dst, $src2}",
1678 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1679 (implicit EFLAGS)]>, OpSize;
1680 def XOR32rr : I<0x31, MRMDestReg,
1681 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1682 "xor{l}\t{$src2, $dst|$dst, $src2}",
1683 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1684 (implicit EFLAGS)]>;
1685 } // isCommutable = 1
1687 def XOR8rm : I<0x32, MRMSrcMem ,
1688 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1689 "xor{b}\t{$src2, $dst|$dst, $src2}",
1690 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1691 (implicit EFLAGS)]>;
1692 def XOR16rm : I<0x33, MRMSrcMem ,
1693 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1694 "xor{w}\t{$src2, $dst|$dst, $src2}",
1695 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1696 (implicit EFLAGS)]>,
1698 def XOR32rm : I<0x33, MRMSrcMem ,
1699 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1700 "xor{l}\t{$src2, $dst|$dst, $src2}",
1701 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1702 (implicit EFLAGS)]>;
1704 def XOR8ri : Ii8<0x80, MRM6r,
1705 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1706 "xor{b}\t{$src2, $dst|$dst, $src2}",
1707 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1708 (implicit EFLAGS)]>;
1709 def XOR16ri : Ii16<0x81, MRM6r,
1710 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1711 "xor{w}\t{$src2, $dst|$dst, $src2}",
1712 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1713 (implicit EFLAGS)]>, OpSize;
1714 def XOR32ri : Ii32<0x81, MRM6r,
1715 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1716 "xor{l}\t{$src2, $dst|$dst, $src2}",
1717 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1718 (implicit EFLAGS)]>;
1719 def XOR16ri8 : Ii8<0x83, MRM6r,
1720 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1721 "xor{w}\t{$src2, $dst|$dst, $src2}",
1722 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1723 (implicit EFLAGS)]>,
1725 def XOR32ri8 : Ii8<0x83, MRM6r,
1726 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1727 "xor{l}\t{$src2, $dst|$dst, $src2}",
1728 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1729 (implicit EFLAGS)]>;
1731 let isTwoAddress = 0 in {
1732 def XOR8mr : I<0x30, MRMDestMem,
1733 (outs), (ins i8mem :$dst, GR8 :$src),
1734 "xor{b}\t{$src, $dst|$dst, $src}",
1735 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1736 (implicit EFLAGS)]>;
1737 def XOR16mr : I<0x31, MRMDestMem,
1738 (outs), (ins i16mem:$dst, GR16:$src),
1739 "xor{w}\t{$src, $dst|$dst, $src}",
1740 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1741 (implicit EFLAGS)]>,
1743 def XOR32mr : I<0x31, MRMDestMem,
1744 (outs), (ins i32mem:$dst, GR32:$src),
1745 "xor{l}\t{$src, $dst|$dst, $src}",
1746 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1747 (implicit EFLAGS)]>;
1748 def XOR8mi : Ii8<0x80, MRM6m,
1749 (outs), (ins i8mem :$dst, i8imm :$src),
1750 "xor{b}\t{$src, $dst|$dst, $src}",
1751 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1752 (implicit EFLAGS)]>;
1753 def XOR16mi : Ii16<0x81, MRM6m,
1754 (outs), (ins i16mem:$dst, i16imm:$src),
1755 "xor{w}\t{$src, $dst|$dst, $src}",
1756 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1757 (implicit EFLAGS)]>,
1759 def XOR32mi : Ii32<0x81, MRM6m,
1760 (outs), (ins i32mem:$dst, i32imm:$src),
1761 "xor{l}\t{$src, $dst|$dst, $src}",
1762 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1763 (implicit EFLAGS)]>;
1764 def XOR16mi8 : Ii8<0x83, MRM6m,
1765 (outs), (ins i16mem:$dst, i16i8imm :$src),
1766 "xor{w}\t{$src, $dst|$dst, $src}",
1767 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1768 (implicit EFLAGS)]>,
1770 def XOR32mi8 : Ii8<0x83, MRM6m,
1771 (outs), (ins i32mem:$dst, i32i8imm :$src),
1772 "xor{l}\t{$src, $dst|$dst, $src}",
1773 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1774 (implicit EFLAGS)]>;
1775 } // isTwoAddress = 0
1776 } // Defs = [EFLAGS]
1778 // Shift instructions
1779 let Defs = [EFLAGS] in {
1780 let Uses = [CL] in {
1781 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1782 "shl{b}\t{%cl, $dst|$dst, CL}",
1783 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1784 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1785 "shl{w}\t{%cl, $dst|$dst, CL}",
1786 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1787 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1788 "shl{l}\t{%cl, $dst|$dst, CL}",
1789 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1792 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1793 "shl{b}\t{$src2, $dst|$dst, $src2}",
1794 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1795 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1796 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1797 "shl{w}\t{$src2, $dst|$dst, $src2}",
1798 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1799 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1800 "shl{l}\t{$src2, $dst|$dst, $src2}",
1801 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1802 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1804 } // isConvertibleToThreeAddress = 1
1806 let isTwoAddress = 0 in {
1807 let Uses = [CL] in {
1808 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1809 "shl{b}\t{%cl, $dst|$dst, CL}",
1810 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1811 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1812 "shl{w}\t{%cl, $dst|$dst, CL}",
1813 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1814 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1815 "shl{l}\t{%cl, $dst|$dst, CL}",
1816 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1818 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1819 "shl{b}\t{$src, $dst|$dst, $src}",
1820 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1821 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1822 "shl{w}\t{$src, $dst|$dst, $src}",
1823 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1825 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1826 "shl{l}\t{$src, $dst|$dst, $src}",
1827 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1830 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1832 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1833 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1835 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1837 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1839 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1842 let Uses = [CL] in {
1843 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1844 "shr{b}\t{%cl, $dst|$dst, CL}",
1845 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1846 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1847 "shr{w}\t{%cl, $dst|$dst, CL}",
1848 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1849 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1850 "shr{l}\t{%cl, $dst|$dst, CL}",
1851 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1854 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1855 "shr{b}\t{$src2, $dst|$dst, $src2}",
1856 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1857 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1858 "shr{w}\t{$src2, $dst|$dst, $src2}",
1859 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1860 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1861 "shr{l}\t{$src2, $dst|$dst, $src2}",
1862 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1865 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1867 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1868 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1870 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1871 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1873 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1875 let isTwoAddress = 0 in {
1876 let Uses = [CL] in {
1877 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1878 "shr{b}\t{%cl, $dst|$dst, CL}",
1879 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1880 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1881 "shr{w}\t{%cl, $dst|$dst, CL}",
1882 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1884 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1885 "shr{l}\t{%cl, $dst|$dst, CL}",
1886 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1888 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1889 "shr{b}\t{$src, $dst|$dst, $src}",
1890 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1891 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1892 "shr{w}\t{$src, $dst|$dst, $src}",
1893 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1895 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1896 "shr{l}\t{$src, $dst|$dst, $src}",
1897 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1900 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1902 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1903 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1905 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1906 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1908 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1911 let Uses = [CL] in {
1912 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1913 "sar{b}\t{%cl, $dst|$dst, CL}",
1914 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1915 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1916 "sar{w}\t{%cl, $dst|$dst, CL}",
1917 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1918 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1919 "sar{l}\t{%cl, $dst|$dst, CL}",
1920 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1923 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1924 "sar{b}\t{$src2, $dst|$dst, $src2}",
1925 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1926 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1927 "sar{w}\t{$src2, $dst|$dst, $src2}",
1928 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1930 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1931 "sar{l}\t{$src2, $dst|$dst, $src2}",
1932 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1935 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1937 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1938 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1940 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1941 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1943 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1945 let isTwoAddress = 0 in {
1946 let Uses = [CL] in {
1947 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1948 "sar{b}\t{%cl, $dst|$dst, CL}",
1949 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1950 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1951 "sar{w}\t{%cl, $dst|$dst, CL}",
1952 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1953 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1954 "sar{l}\t{%cl, $dst|$dst, CL}",
1955 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1957 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1958 "sar{b}\t{$src, $dst|$dst, $src}",
1959 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1960 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1961 "sar{w}\t{$src, $dst|$dst, $src}",
1962 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1964 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1965 "sar{l}\t{$src, $dst|$dst, $src}",
1966 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1969 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1971 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1972 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1974 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1976 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1978 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1981 // Rotate instructions
1982 // FIXME: provide shorter instructions when imm8 == 1
1983 let Uses = [CL] in {
1984 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1985 "rol{b}\t{%cl, $dst|$dst, CL}",
1986 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1987 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1988 "rol{w}\t{%cl, $dst|$dst, CL}",
1989 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1990 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1991 "rol{l}\t{%cl, $dst|$dst, CL}",
1992 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1995 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1996 "rol{b}\t{$src2, $dst|$dst, $src2}",
1997 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1998 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1999 "rol{w}\t{$src2, $dst|$dst, $src2}",
2000 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2001 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2002 "rol{l}\t{$src2, $dst|$dst, $src2}",
2003 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2006 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2008 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2009 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2011 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2012 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2014 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2016 let isTwoAddress = 0 in {
2017 let Uses = [CL] in {
2018 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2019 "rol{b}\t{%cl, $dst|$dst, CL}",
2020 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2021 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2022 "rol{w}\t{%cl, $dst|$dst, CL}",
2023 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2024 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2025 "rol{l}\t{%cl, $dst|$dst, CL}",
2026 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2028 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2029 "rol{b}\t{$src, $dst|$dst, $src}",
2030 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2031 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2032 "rol{w}\t{$src, $dst|$dst, $src}",
2033 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2035 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2036 "rol{l}\t{$src, $dst|$dst, $src}",
2037 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2040 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2042 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2043 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2045 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2047 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2049 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2052 let Uses = [CL] in {
2053 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2054 "ror{b}\t{%cl, $dst|$dst, CL}",
2055 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2056 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2057 "ror{w}\t{%cl, $dst|$dst, CL}",
2058 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2059 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2060 "ror{l}\t{%cl, $dst|$dst, CL}",
2061 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2064 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2065 "ror{b}\t{$src2, $dst|$dst, $src2}",
2066 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2067 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2068 "ror{w}\t{$src2, $dst|$dst, $src2}",
2069 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2070 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2071 "ror{l}\t{$src2, $dst|$dst, $src2}",
2072 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2075 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2077 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2078 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2080 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2081 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2083 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2085 let isTwoAddress = 0 in {
2086 let Uses = [CL] in {
2087 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2088 "ror{b}\t{%cl, $dst|$dst, CL}",
2089 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2090 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2091 "ror{w}\t{%cl, $dst|$dst, CL}",
2092 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2093 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2094 "ror{l}\t{%cl, $dst|$dst, CL}",
2095 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2097 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2098 "ror{b}\t{$src, $dst|$dst, $src}",
2099 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2100 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2101 "ror{w}\t{$src, $dst|$dst, $src}",
2102 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2104 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2105 "ror{l}\t{$src, $dst|$dst, $src}",
2106 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2109 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2111 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2112 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2114 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2116 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2118 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2123 // Double shift instructions (generalizations of rotate)
2124 let Uses = [CL] in {
2125 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2126 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2127 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2128 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2129 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2130 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2131 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2132 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2133 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2135 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2136 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2137 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2141 let isCommutable = 1 in { // These instructions commute to each other.
2142 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2143 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2144 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2145 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2148 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2149 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2150 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2151 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2154 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2155 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2156 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2157 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2160 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2161 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2162 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2163 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2168 let isTwoAddress = 0 in {
2169 let Uses = [CL] in {
2170 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2171 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2172 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2174 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2175 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2176 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2179 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2180 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2181 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2182 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2183 (i8 imm:$src3)), addr:$dst)]>,
2185 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2186 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2187 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2188 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2189 (i8 imm:$src3)), addr:$dst)]>,
2192 let Uses = [CL] in {
2193 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2194 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2195 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2196 addr:$dst)]>, TB, OpSize;
2197 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2198 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2199 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2200 addr:$dst)]>, TB, OpSize;
2202 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2203 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2204 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2205 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2206 (i8 imm:$src3)), addr:$dst)]>,
2208 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2209 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2210 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2211 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2212 (i8 imm:$src3)), addr:$dst)]>,
2215 } // Defs = [EFLAGS]
2219 let Defs = [EFLAGS] in {
2220 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2221 // Register-Register Addition
2222 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2223 (ins GR8 :$src1, GR8 :$src2),
2224 "add{b}\t{$src2, $dst|$dst, $src2}",
2225 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2226 (implicit EFLAGS)]>;
2228 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2229 // Register-Register Addition
2230 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2231 (ins GR16:$src1, GR16:$src2),
2232 "add{w}\t{$src2, $dst|$dst, $src2}",
2233 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2234 (implicit EFLAGS)]>, OpSize;
2235 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2236 (ins GR32:$src1, GR32:$src2),
2237 "add{l}\t{$src2, $dst|$dst, $src2}",
2238 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2239 (implicit EFLAGS)]>;
2240 } // end isConvertibleToThreeAddress
2241 } // end isCommutable
2243 // Register-Memory Addition
2244 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2245 (ins GR8 :$src1, i8mem :$src2),
2246 "add{b}\t{$src2, $dst|$dst, $src2}",
2247 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2248 (implicit EFLAGS)]>;
2249 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2250 (ins GR16:$src1, i16mem:$src2),
2251 "add{w}\t{$src2, $dst|$dst, $src2}",
2252 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2253 (implicit EFLAGS)]>, OpSize;
2254 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2255 (ins GR32:$src1, i32mem:$src2),
2256 "add{l}\t{$src2, $dst|$dst, $src2}",
2257 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2258 (implicit EFLAGS)]>;
2260 // Register-Integer Addition
2261 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2262 "add{b}\t{$src2, $dst|$dst, $src2}",
2263 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2264 (implicit EFLAGS)]>;
2266 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2267 // Register-Integer Addition
2268 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2269 (ins GR16:$src1, i16imm:$src2),
2270 "add{w}\t{$src2, $dst|$dst, $src2}",
2271 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2272 (implicit EFLAGS)]>, OpSize;
2273 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2274 (ins GR32:$src1, i32imm:$src2),
2275 "add{l}\t{$src2, $dst|$dst, $src2}",
2276 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2277 (implicit EFLAGS)]>;
2278 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2279 (ins GR16:$src1, i16i8imm:$src2),
2280 "add{w}\t{$src2, $dst|$dst, $src2}",
2281 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2282 (implicit EFLAGS)]>, OpSize;
2283 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2284 (ins GR32:$src1, i32i8imm:$src2),
2285 "add{l}\t{$src2, $dst|$dst, $src2}",
2286 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2287 (implicit EFLAGS)]>;
2290 let isTwoAddress = 0 in {
2291 // Memory-Register Addition
2292 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2293 "add{b}\t{$src2, $dst|$dst, $src2}",
2294 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2295 (implicit EFLAGS)]>;
2296 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2297 "add{w}\t{$src2, $dst|$dst, $src2}",
2298 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2299 (implicit EFLAGS)]>, OpSize;
2300 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2301 "add{l}\t{$src2, $dst|$dst, $src2}",
2302 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2303 (implicit EFLAGS)]>;
2304 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2305 "add{b}\t{$src2, $dst|$dst, $src2}",
2306 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2307 (implicit EFLAGS)]>;
2308 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2309 "add{w}\t{$src2, $dst|$dst, $src2}",
2310 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2311 (implicit EFLAGS)]>, OpSize;
2312 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2313 "add{l}\t{$src2, $dst|$dst, $src2}",
2314 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2315 (implicit EFLAGS)]>;
2316 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2317 "add{w}\t{$src2, $dst|$dst, $src2}",
2318 [(store (add (load addr:$dst), i16immSExt8:$src2),
2320 (implicit EFLAGS)]>, OpSize;
2321 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2322 "add{l}\t{$src2, $dst|$dst, $src2}",
2323 [(store (add (load addr:$dst), i32immSExt8:$src2),
2325 (implicit EFLAGS)]>;
2328 let Uses = [EFLAGS] in {
2329 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2330 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2331 "adc{b}\t{$src2, $dst|$dst, $src2}",
2332 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2333 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2334 (ins GR16:$src1, GR16:$src2),
2335 "adc{w}\t{$src2, $dst|$dst, $src2}",
2336 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2337 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2338 (ins GR32:$src1, GR32:$src2),
2339 "adc{l}\t{$src2, $dst|$dst, $src2}",
2340 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2342 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2343 (ins GR8:$src1, i8mem:$src2),
2344 "adc{b}\t{$src2, $dst|$dst, $src2}",
2345 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2346 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2347 (ins GR16:$src1, i16mem:$src2),
2348 "adc{w}\t{$src2, $dst|$dst, $src2}",
2349 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2351 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2352 (ins GR32:$src1, i32mem:$src2),
2353 "adc{l}\t{$src2, $dst|$dst, $src2}",
2354 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2355 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2356 "adc{b}\t{$src2, $dst|$dst, $src2}",
2357 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2358 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2359 (ins GR16:$src1, i16imm:$src2),
2360 "adc{w}\t{$src2, $dst|$dst, $src2}",
2361 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2362 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2363 (ins GR16:$src1, i16i8imm:$src2),
2364 "adc{w}\t{$src2, $dst|$dst, $src2}",
2365 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2367 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2368 (ins GR32:$src1, i32imm:$src2),
2369 "adc{l}\t{$src2, $dst|$dst, $src2}",
2370 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2371 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2372 (ins GR32:$src1, i32i8imm:$src2),
2373 "adc{l}\t{$src2, $dst|$dst, $src2}",
2374 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2376 let isTwoAddress = 0 in {
2377 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2378 "adc{b}\t{$src2, $dst|$dst, $src2}",
2379 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2380 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2381 "adc{w}\t{$src2, $dst|$dst, $src2}",
2382 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2384 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2385 "adc{l}\t{$src2, $dst|$dst, $src2}",
2386 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2387 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2388 "adc{b}\t{$src2, $dst|$dst, $src2}",
2389 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2390 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2391 "adc{w}\t{$src2, $dst|$dst, $src2}",
2392 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2394 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2395 "adc{w}\t{$src2, $dst|$dst, $src2}",
2396 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2398 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2399 "adc{l}\t{$src2, $dst|$dst, $src2}",
2400 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2401 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2402 "adc{l}\t{$src2, $dst|$dst, $src2}",
2403 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2405 } // Uses = [EFLAGS]
2407 // Register-Register Subtraction
2408 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2409 "sub{b}\t{$src2, $dst|$dst, $src2}",
2410 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2411 (implicit EFLAGS)]>;
2412 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2413 "sub{w}\t{$src2, $dst|$dst, $src2}",
2414 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2415 (implicit EFLAGS)]>, OpSize;
2416 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2417 "sub{l}\t{$src2, $dst|$dst, $src2}",
2418 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2419 (implicit EFLAGS)]>;
2421 // Register-Memory Subtraction
2422 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2423 (ins GR8 :$src1, i8mem :$src2),
2424 "sub{b}\t{$src2, $dst|$dst, $src2}",
2425 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2426 (implicit EFLAGS)]>;
2427 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2428 (ins GR16:$src1, i16mem:$src2),
2429 "sub{w}\t{$src2, $dst|$dst, $src2}",
2430 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2431 (implicit EFLAGS)]>, OpSize;
2432 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2433 (ins GR32:$src1, i32mem:$src2),
2434 "sub{l}\t{$src2, $dst|$dst, $src2}",
2435 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2436 (implicit EFLAGS)]>;
2438 // Register-Integer Subtraction
2439 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2440 (ins GR8:$src1, i8imm:$src2),
2441 "sub{b}\t{$src2, $dst|$dst, $src2}",
2442 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2443 (implicit EFLAGS)]>;
2444 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2445 (ins GR16:$src1, i16imm:$src2),
2446 "sub{w}\t{$src2, $dst|$dst, $src2}",
2447 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2448 (implicit EFLAGS)]>, OpSize;
2449 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2450 (ins GR32:$src1, i32imm:$src2),
2451 "sub{l}\t{$src2, $dst|$dst, $src2}",
2452 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2453 (implicit EFLAGS)]>;
2454 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2455 (ins GR16:$src1, i16i8imm:$src2),
2456 "sub{w}\t{$src2, $dst|$dst, $src2}",
2457 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2458 (implicit EFLAGS)]>, OpSize;
2459 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2460 (ins GR32:$src1, i32i8imm:$src2),
2461 "sub{l}\t{$src2, $dst|$dst, $src2}",
2462 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2463 (implicit EFLAGS)]>;
2465 let isTwoAddress = 0 in {
2466 // Memory-Register Subtraction
2467 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2468 "sub{b}\t{$src2, $dst|$dst, $src2}",
2469 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2470 (implicit EFLAGS)]>;
2471 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2472 "sub{w}\t{$src2, $dst|$dst, $src2}",
2473 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2474 (implicit EFLAGS)]>, OpSize;
2475 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2476 "sub{l}\t{$src2, $dst|$dst, $src2}",
2477 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2478 (implicit EFLAGS)]>;
2480 // Memory-Integer Subtraction
2481 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2482 "sub{b}\t{$src2, $dst|$dst, $src2}",
2483 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2484 (implicit EFLAGS)]>;
2485 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2486 "sub{w}\t{$src2, $dst|$dst, $src2}",
2487 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2488 (implicit EFLAGS)]>, OpSize;
2489 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2490 "sub{l}\t{$src2, $dst|$dst, $src2}",
2491 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2492 (implicit EFLAGS)]>;
2493 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2494 "sub{w}\t{$src2, $dst|$dst, $src2}",
2495 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2497 (implicit EFLAGS)]>, OpSize;
2498 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2499 "sub{l}\t{$src2, $dst|$dst, $src2}",
2500 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2502 (implicit EFLAGS)]>;
2505 let Uses = [EFLAGS] in {
2506 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2507 (ins GR8:$src1, GR8:$src2),
2508 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2509 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2510 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2511 (ins GR16:$src1, GR16:$src2),
2512 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2513 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2514 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2515 (ins GR32:$src1, GR32:$src2),
2516 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2517 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2519 let isTwoAddress = 0 in {
2520 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2521 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2522 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2523 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2524 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2525 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2527 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2528 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2529 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2530 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2531 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2532 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2533 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2534 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2535 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2537 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2538 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2539 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2541 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2542 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2543 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2544 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2545 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2546 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2548 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2549 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2550 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2551 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2552 (ins GR16:$src1, i16mem:$src2),
2553 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2554 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2556 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2557 (ins GR32:$src1, i32mem:$src2),
2558 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2559 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2560 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2561 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2562 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2563 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2564 (ins GR16:$src1, i16imm:$src2),
2565 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2566 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2567 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2568 (ins GR16:$src1, i16i8imm:$src2),
2569 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2570 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2572 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2573 (ins GR32:$src1, i32imm:$src2),
2574 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2575 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2576 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2577 (ins GR32:$src1, i32i8imm:$src2),
2578 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2579 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2580 } // Uses = [EFLAGS]
2581 } // Defs = [EFLAGS]
2583 let Defs = [EFLAGS] in {
2584 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2585 // Register-Register Signed Integer Multiply
2586 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2587 "imul{w}\t{$src2, $dst|$dst, $src2}",
2588 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2589 (implicit EFLAGS)]>, TB, OpSize;
2590 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2591 "imul{l}\t{$src2, $dst|$dst, $src2}",
2592 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2593 (implicit EFLAGS)]>, TB;
2596 // Register-Memory Signed Integer Multiply
2597 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2598 (ins GR16:$src1, i16mem:$src2),
2599 "imul{w}\t{$src2, $dst|$dst, $src2}",
2600 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2601 (implicit EFLAGS)]>, TB, OpSize;
2602 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2603 "imul{l}\t{$src2, $dst|$dst, $src2}",
2604 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2605 (implicit EFLAGS)]>, TB;
2606 } // Defs = [EFLAGS]
2607 } // end Two Address instructions
2609 // Suprisingly enough, these are not two address instructions!
2610 let Defs = [EFLAGS] in {
2611 // Register-Integer Signed Integer Multiply
2612 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2613 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2614 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2615 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2616 (implicit EFLAGS)]>, OpSize;
2617 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2618 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2619 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2620 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2621 (implicit EFLAGS)]>;
2622 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2623 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2624 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2625 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2626 (implicit EFLAGS)]>, OpSize;
2627 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2628 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2629 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2630 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2631 (implicit EFLAGS)]>;
2633 // Memory-Integer Signed Integer Multiply
2634 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2635 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2636 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2637 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2638 (implicit EFLAGS)]>, OpSize;
2639 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2640 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2641 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2642 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2643 (implicit EFLAGS)]>;
2644 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2645 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2646 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2647 [(set GR16:$dst, (mul (load addr:$src1),
2648 i16immSExt8:$src2)),
2649 (implicit EFLAGS)]>, OpSize;
2650 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2651 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2652 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2653 [(set GR32:$dst, (mul (load addr:$src1),
2654 i32immSExt8:$src2)),
2655 (implicit EFLAGS)]>;
2656 } // Defs = [EFLAGS]
2658 //===----------------------------------------------------------------------===//
2659 // Test instructions are just like AND, except they don't generate a result.
2661 let Defs = [EFLAGS] in {
2662 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2663 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2664 "test{b}\t{$src2, $src1|$src1, $src2}",
2665 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2666 (implicit EFLAGS)]>;
2667 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2668 "test{w}\t{$src2, $src1|$src1, $src2}",
2669 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2670 (implicit EFLAGS)]>,
2672 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2673 "test{l}\t{$src2, $src1|$src1, $src2}",
2674 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2675 (implicit EFLAGS)]>;
2678 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2679 "test{b}\t{$src2, $src1|$src1, $src2}",
2680 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2681 (implicit EFLAGS)]>;
2682 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2683 "test{w}\t{$src2, $src1|$src1, $src2}",
2684 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2685 (implicit EFLAGS)]>, OpSize;
2686 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2687 "test{l}\t{$src2, $src1|$src1, $src2}",
2688 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2689 (implicit EFLAGS)]>;
2691 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2692 (outs), (ins GR8:$src1, i8imm:$src2),
2693 "test{b}\t{$src2, $src1|$src1, $src2}",
2694 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2695 (implicit EFLAGS)]>;
2696 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2697 (outs), (ins GR16:$src1, i16imm:$src2),
2698 "test{w}\t{$src2, $src1|$src1, $src2}",
2699 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2700 (implicit EFLAGS)]>, OpSize;
2701 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2702 (outs), (ins GR32:$src1, i32imm:$src2),
2703 "test{l}\t{$src2, $src1|$src1, $src2}",
2704 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2705 (implicit EFLAGS)]>;
2707 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2708 (outs), (ins i8mem:$src1, i8imm:$src2),
2709 "test{b}\t{$src2, $src1|$src1, $src2}",
2710 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2711 (implicit EFLAGS)]>;
2712 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2713 (outs), (ins i16mem:$src1, i16imm:$src2),
2714 "test{w}\t{$src2, $src1|$src1, $src2}",
2715 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2716 (implicit EFLAGS)]>, OpSize;
2717 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2718 (outs), (ins i32mem:$src1, i32imm:$src2),
2719 "test{l}\t{$src2, $src1|$src1, $src2}",
2720 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2721 (implicit EFLAGS)]>;
2722 } // Defs = [EFLAGS]
2725 // Condition code ops, incl. set if equal/not equal/...
2726 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2727 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2728 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2729 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2731 let Uses = [EFLAGS] in {
2732 def SETEr : I<0x94, MRM0r,
2733 (outs GR8 :$dst), (ins),
2735 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2737 def SETEm : I<0x94, MRM0m,
2738 (outs), (ins i8mem:$dst),
2740 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2743 def SETNEr : I<0x95, MRM0r,
2744 (outs GR8 :$dst), (ins),
2746 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2748 def SETNEm : I<0x95, MRM0m,
2749 (outs), (ins i8mem:$dst),
2751 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2754 def SETLr : I<0x9C, MRM0r,
2755 (outs GR8 :$dst), (ins),
2757 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2758 TB; // GR8 = < signed
2759 def SETLm : I<0x9C, MRM0m,
2760 (outs), (ins i8mem:$dst),
2762 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2763 TB; // [mem8] = < signed
2765 def SETGEr : I<0x9D, MRM0r,
2766 (outs GR8 :$dst), (ins),
2768 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2769 TB; // GR8 = >= signed
2770 def SETGEm : I<0x9D, MRM0m,
2771 (outs), (ins i8mem:$dst),
2773 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2774 TB; // [mem8] = >= signed
2776 def SETLEr : I<0x9E, MRM0r,
2777 (outs GR8 :$dst), (ins),
2779 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2780 TB; // GR8 = <= signed
2781 def SETLEm : I<0x9E, MRM0m,
2782 (outs), (ins i8mem:$dst),
2784 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2785 TB; // [mem8] = <= signed
2787 def SETGr : I<0x9F, MRM0r,
2788 (outs GR8 :$dst), (ins),
2790 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2791 TB; // GR8 = > signed
2792 def SETGm : I<0x9F, MRM0m,
2793 (outs), (ins i8mem:$dst),
2795 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2796 TB; // [mem8] = > signed
2798 def SETBr : I<0x92, MRM0r,
2799 (outs GR8 :$dst), (ins),
2801 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2802 TB; // GR8 = < unsign
2803 def SETBm : I<0x92, MRM0m,
2804 (outs), (ins i8mem:$dst),
2806 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2807 TB; // [mem8] = < unsign
2809 def SETAEr : I<0x93, MRM0r,
2810 (outs GR8 :$dst), (ins),
2812 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2813 TB; // GR8 = >= unsign
2814 def SETAEm : I<0x93, MRM0m,
2815 (outs), (ins i8mem:$dst),
2817 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2818 TB; // [mem8] = >= unsign
2820 def SETBEr : I<0x96, MRM0r,
2821 (outs GR8 :$dst), (ins),
2823 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2824 TB; // GR8 = <= unsign
2825 def SETBEm : I<0x96, MRM0m,
2826 (outs), (ins i8mem:$dst),
2828 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2829 TB; // [mem8] = <= unsign
2831 def SETAr : I<0x97, MRM0r,
2832 (outs GR8 :$dst), (ins),
2834 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2835 TB; // GR8 = > signed
2836 def SETAm : I<0x97, MRM0m,
2837 (outs), (ins i8mem:$dst),
2839 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2840 TB; // [mem8] = > signed
2842 def SETSr : I<0x98, MRM0r,
2843 (outs GR8 :$dst), (ins),
2845 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2846 TB; // GR8 = <sign bit>
2847 def SETSm : I<0x98, MRM0m,
2848 (outs), (ins i8mem:$dst),
2850 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2851 TB; // [mem8] = <sign bit>
2852 def SETNSr : I<0x99, MRM0r,
2853 (outs GR8 :$dst), (ins),
2855 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2856 TB; // GR8 = !<sign bit>
2857 def SETNSm : I<0x99, MRM0m,
2858 (outs), (ins i8mem:$dst),
2860 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2861 TB; // [mem8] = !<sign bit>
2863 def SETPr : I<0x9A, MRM0r,
2864 (outs GR8 :$dst), (ins),
2866 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2868 def SETPm : I<0x9A, MRM0m,
2869 (outs), (ins i8mem:$dst),
2871 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2872 TB; // [mem8] = parity
2873 def SETNPr : I<0x9B, MRM0r,
2874 (outs GR8 :$dst), (ins),
2876 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2877 TB; // GR8 = not parity
2878 def SETNPm : I<0x9B, MRM0m,
2879 (outs), (ins i8mem:$dst),
2881 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2882 TB; // [mem8] = not parity
2884 def SETOr : I<0x90, MRM0r,
2885 (outs GR8 :$dst), (ins),
2887 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2888 TB; // GR8 = overflow
2889 def SETOm : I<0x90, MRM0m,
2890 (outs), (ins i8mem:$dst),
2892 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2893 TB; // [mem8] = overflow
2894 def SETNOr : I<0x91, MRM0r,
2895 (outs GR8 :$dst), (ins),
2897 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2898 TB; // GR8 = not overflow
2899 def SETNOm : I<0x91, MRM0m,
2900 (outs), (ins i8mem:$dst),
2902 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2903 TB; // [mem8] = not overflow
2904 } // Uses = [EFLAGS]
2907 // Integer comparisons
2908 let Defs = [EFLAGS] in {
2909 def CMP8rr : I<0x38, MRMDestReg,
2910 (outs), (ins GR8 :$src1, GR8 :$src2),
2911 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2912 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2913 def CMP16rr : I<0x39, MRMDestReg,
2914 (outs), (ins GR16:$src1, GR16:$src2),
2915 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2916 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2917 def CMP32rr : I<0x39, MRMDestReg,
2918 (outs), (ins GR32:$src1, GR32:$src2),
2919 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2920 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2921 def CMP8mr : I<0x38, MRMDestMem,
2922 (outs), (ins i8mem :$src1, GR8 :$src2),
2923 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2924 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2925 (implicit EFLAGS)]>;
2926 def CMP16mr : I<0x39, MRMDestMem,
2927 (outs), (ins i16mem:$src1, GR16:$src2),
2928 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2929 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2930 (implicit EFLAGS)]>, OpSize;
2931 def CMP32mr : I<0x39, MRMDestMem,
2932 (outs), (ins i32mem:$src1, GR32:$src2),
2933 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2934 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2935 (implicit EFLAGS)]>;
2936 def CMP8rm : I<0x3A, MRMSrcMem,
2937 (outs), (ins GR8 :$src1, i8mem :$src2),
2938 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2939 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2940 (implicit EFLAGS)]>;
2941 def CMP16rm : I<0x3B, MRMSrcMem,
2942 (outs), (ins GR16:$src1, i16mem:$src2),
2943 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2944 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2945 (implicit EFLAGS)]>, OpSize;
2946 def CMP32rm : I<0x3B, MRMSrcMem,
2947 (outs), (ins GR32:$src1, i32mem:$src2),
2948 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2949 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2950 (implicit EFLAGS)]>;
2951 def CMP8ri : Ii8<0x80, MRM7r,
2952 (outs), (ins GR8:$src1, i8imm:$src2),
2953 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2954 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
2955 def CMP16ri : Ii16<0x81, MRM7r,
2956 (outs), (ins GR16:$src1, i16imm:$src2),
2957 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2958 [(X86cmp GR16:$src1, imm:$src2),
2959 (implicit EFLAGS)]>, OpSize;
2960 def CMP32ri : Ii32<0x81, MRM7r,
2961 (outs), (ins GR32:$src1, i32imm:$src2),
2962 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2963 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
2964 def CMP8mi : Ii8 <0x80, MRM7m,
2965 (outs), (ins i8mem :$src1, i8imm :$src2),
2966 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2967 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2968 (implicit EFLAGS)]>;
2969 def CMP16mi : Ii16<0x81, MRM7m,
2970 (outs), (ins i16mem:$src1, i16imm:$src2),
2971 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2972 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2973 (implicit EFLAGS)]>, OpSize;
2974 def CMP32mi : Ii32<0x81, MRM7m,
2975 (outs), (ins i32mem:$src1, i32imm:$src2),
2976 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2977 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2978 (implicit EFLAGS)]>;
2979 def CMP16ri8 : Ii8<0x83, MRM7r,
2980 (outs), (ins GR16:$src1, i16i8imm:$src2),
2981 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2982 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2983 (implicit EFLAGS)]>, OpSize;
2984 def CMP16mi8 : Ii8<0x83, MRM7m,
2985 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2986 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2987 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2988 (implicit EFLAGS)]>, OpSize;
2989 def CMP32mi8 : Ii8<0x83, MRM7m,
2990 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2991 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2992 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2993 (implicit EFLAGS)]>;
2994 def CMP32ri8 : Ii8<0x83, MRM7r,
2995 (outs), (ins GR32:$src1, i32i8imm:$src2),
2996 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2997 [(X86cmp GR32:$src1, i32immSExt8:$src2),
2998 (implicit EFLAGS)]>;
2999 } // Defs = [EFLAGS]
3002 // TODO: BTC, BTR, and BTS
3003 let Defs = [EFLAGS] in {
3004 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3005 "bt{w}\t{$src2, $src1|$src1, $src2}",
3006 [(X86bt GR16:$src1, GR16:$src2),
3007 (implicit EFLAGS)]>, OpSize, TB;
3008 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3009 "bt{l}\t{$src2, $src1|$src1, $src2}",
3010 [(X86bt GR32:$src1, GR32:$src2),
3011 (implicit EFLAGS)]>, TB;
3013 // Unlike with the register+register form, the memory+register form of the
3014 // bt instruction does not ignore the high bits of the index. From ISel's
3015 // perspective, this is pretty bizarre. Disable these instructions for now.
3016 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3017 // "bt{w}\t{$src2, $src1|$src1, $src2}",
3018 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3019 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3020 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3021 // "bt{l}\t{$src2, $src1|$src1, $src2}",
3022 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3023 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
3025 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3026 "bt{w}\t{$src2, $src1|$src1, $src2}",
3027 [(X86bt GR16:$src1, i16immSExt8:$src2),
3028 (implicit EFLAGS)]>, OpSize, TB;
3029 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3030 "bt{l}\t{$src2, $src1|$src1, $src2}",
3031 [(X86bt GR32:$src1, i32immSExt8:$src2),
3032 (implicit EFLAGS)]>, TB;
3033 // Note that these instructions don't need FastBTMem because that
3034 // only applies when the other operand is in a register. When it's
3035 // an immediate, bt is still fast.
3036 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3037 "bt{w}\t{$src2, $src1|$src1, $src2}",
3038 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3039 (implicit EFLAGS)]>, OpSize, TB;
3040 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3041 "bt{l}\t{$src2, $src1|$src1, $src2}",
3042 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3043 (implicit EFLAGS)]>, TB;
3044 } // Defs = [EFLAGS]
3046 // Sign/Zero extenders
3047 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3048 // of the register here. This has a smaller encoding and avoids a
3049 // partial-register update.
3050 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3051 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3052 [(set GR16:$dst, (sext GR8:$src))]>, TB;
3053 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3054 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3055 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3056 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3057 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3058 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3059 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3060 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3061 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3062 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3063 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3064 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3065 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3066 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3067 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3069 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3070 // of the register here. This has a smaller encoding and avoids a
3071 // partial-register update.
3072 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3073 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3074 [(set GR16:$dst, (zext GR8:$src))]>, TB;
3075 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3076 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3077 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3078 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3079 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3080 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3081 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3082 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3083 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3084 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3085 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3086 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3087 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3088 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3089 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3091 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3092 // except that they use GR32_NOREX for the output operand register class
3093 // instead of GR32. This allows them to operate on h registers on x86-64.
3094 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3095 (outs GR32_NOREX:$dst), (ins GR8:$src),
3096 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3099 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3100 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3101 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3104 let neverHasSideEffects = 1 in {
3105 let Defs = [AX], Uses = [AL] in
3106 def CBW : I<0x98, RawFrm, (outs), (ins),
3107 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3108 let Defs = [EAX], Uses = [AX] in
3109 def CWDE : I<0x98, RawFrm, (outs), (ins),
3110 "{cwtl|cwde}", []>; // EAX = signext(AX)
3112 let Defs = [AX,DX], Uses = [AX] in
3113 def CWD : I<0x99, RawFrm, (outs), (ins),
3114 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3115 let Defs = [EAX,EDX], Uses = [EAX] in
3116 def CDQ : I<0x99, RawFrm, (outs), (ins),
3117 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3120 //===----------------------------------------------------------------------===//
3121 // Alias Instructions
3122 //===----------------------------------------------------------------------===//
3124 // Alias instructions that map movr0 to xor.
3125 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3126 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
3127 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
3128 "xor{b}\t$dst, $dst",
3129 [(set GR8:$dst, 0)]>;
3130 // Use xorl instead of xorw since we don't care about the high 16 bits,
3131 // it's smaller, and it avoids a partial-register update.
3132 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3133 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3134 [(set GR16:$dst, 0)]>;
3135 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3136 "xor{l}\t$dst, $dst",
3137 [(set GR32:$dst, 0)]>;
3140 //===----------------------------------------------------------------------===//
3141 // Thread Local Storage Instructions
3144 // All calls clobber the non-callee saved registers. ESP is marked as
3145 // a use to prevent stack-pointer assignments that appear immediately
3146 // before calls from potentially appearing dead.
3147 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3148 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3149 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3150 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3152 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3153 "leal\t$sym, %eax; "
3154 "call\t___tls_get_addr@PLT",
3155 [(X86tlsaddr tls32addr:$sym)]>,
3156 Requires<[In32BitMode]>;
3158 let AddedComplexity = 5 in
3159 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3160 "movl\t%gs:$src, $dst",
3161 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3163 let AddedComplexity = 5 in
3164 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3165 "movl\t%fs:$src, $dst",
3166 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3168 //===----------------------------------------------------------------------===//
3169 // DWARF Pseudo Instructions
3172 def DWARF_LOC : I<0, Pseudo, (outs),
3173 (ins i32imm:$line, i32imm:$col, i32imm:$file),
3174 ".loc\t$file $line $col",
3175 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3178 //===----------------------------------------------------------------------===//
3179 // EH Pseudo Instructions
3181 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3183 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3184 "ret\t#eh_return, addr: $addr",
3185 [(X86ehret GR32:$addr)]>;
3189 //===----------------------------------------------------------------------===//
3193 // Atomic swap. These are just normal xchg instructions. But since a memory
3194 // operand is referenced, the atomicity is ensured.
3195 let Constraints = "$val = $dst" in {
3196 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3197 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3198 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3199 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3200 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3201 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3203 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3204 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3205 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3208 // Atomic compare and swap.
3209 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3210 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3212 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3213 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3215 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3216 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3219 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3222 let Defs = [AX, EFLAGS], Uses = [AX] in {
3223 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3225 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3226 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3228 let Defs = [AL, EFLAGS], Uses = [AL] in {
3229 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3231 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3232 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3235 // Atomic exchange and add
3236 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3237 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3239 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3240 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3242 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3244 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3245 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3247 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3249 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3250 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3254 // Optimized codegen when the non-memory output is not used.
3255 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3256 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3258 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3259 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3261 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3262 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3264 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3265 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3267 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3268 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3270 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3271 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3273 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3274 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3276 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3277 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3279 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3281 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3283 "inc{b}\t$dst", []>, LOCK;
3284 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3286 "inc{w}\t$dst", []>, OpSize, LOCK;
3287 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3289 "inc{l}\t$dst", []>, LOCK;
3291 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3293 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3294 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3296 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3297 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3299 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3300 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3302 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3303 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3305 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3306 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3308 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3309 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3311 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3312 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3314 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3316 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3318 "dec{b}\t$dst", []>, LOCK;
3319 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3321 "dec{w}\t$dst", []>, OpSize, LOCK;
3322 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3324 "dec{l}\t$dst", []>, LOCK;
3326 // Atomic exchange, and, or, xor
3327 let Constraints = "$val = $dst", Defs = [EFLAGS],
3328 usesCustomDAGSchedInserter = 1 in {
3329 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3330 "#ATOMAND32 PSEUDO!",
3331 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3332 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3333 "#ATOMOR32 PSEUDO!",
3334 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3335 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3336 "#ATOMXOR32 PSEUDO!",
3337 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3338 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3339 "#ATOMNAND32 PSEUDO!",
3340 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3341 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3342 "#ATOMMIN32 PSEUDO!",
3343 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3344 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3345 "#ATOMMAX32 PSEUDO!",
3346 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3347 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3348 "#ATOMUMIN32 PSEUDO!",
3349 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3350 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3351 "#ATOMUMAX32 PSEUDO!",
3352 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3354 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3355 "#ATOMAND16 PSEUDO!",
3356 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3357 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3358 "#ATOMOR16 PSEUDO!",
3359 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3360 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3361 "#ATOMXOR16 PSEUDO!",
3362 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3363 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3364 "#ATOMNAND16 PSEUDO!",
3365 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3366 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3367 "#ATOMMIN16 PSEUDO!",
3368 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3369 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3370 "#ATOMMAX16 PSEUDO!",
3371 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3372 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3373 "#ATOMUMIN16 PSEUDO!",
3374 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3375 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3376 "#ATOMUMAX16 PSEUDO!",
3377 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3379 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3380 "#ATOMAND8 PSEUDO!",
3381 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3382 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3384 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3385 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3386 "#ATOMXOR8 PSEUDO!",
3387 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3388 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3389 "#ATOMNAND8 PSEUDO!",
3390 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3393 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3394 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3395 Uses = [EAX, EBX, ECX, EDX],
3396 mayLoad = 1, mayStore = 1,
3397 usesCustomDAGSchedInserter = 1 in {
3398 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3399 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3400 "#ATOMAND6432 PSEUDO!", []>;
3401 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3402 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3403 "#ATOMOR6432 PSEUDO!", []>;
3404 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3405 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3406 "#ATOMXOR6432 PSEUDO!", []>;
3407 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3408 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3409 "#ATOMNAND6432 PSEUDO!", []>;
3410 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3411 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3412 "#ATOMADD6432 PSEUDO!", []>;
3413 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3414 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3415 "#ATOMSUB6432 PSEUDO!", []>;
3416 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3417 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3418 "#ATOMSWAP6432 PSEUDO!", []>;
3421 //===----------------------------------------------------------------------===//
3422 // Non-Instruction Patterns
3423 //===----------------------------------------------------------------------===//
3425 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3426 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3427 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3428 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3429 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3430 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3432 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3433 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3434 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3435 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3436 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3437 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3438 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3439 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3441 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3442 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3443 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3444 (MOV32mi addr:$dst, texternalsym:$src)>;
3448 def : Pat<(X86tcret GR32:$dst, imm:$off),
3449 (TCRETURNri GR32:$dst, imm:$off)>;
3451 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3452 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3454 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3455 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3457 // Normal calls, with various flavors of addresses.
3458 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3459 (CALLpcrel32 tglobaladdr:$dst)>;
3460 def : Pat<(X86call (i32 texternalsym:$dst)),
3461 (CALLpcrel32 texternalsym:$dst)>;
3462 def : Pat<(X86call (i32 imm:$dst)),
3463 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
3465 // X86 specific add which produces a flag.
3466 def : Pat<(addc GR32:$src1, GR32:$src2),
3467 (ADD32rr GR32:$src1, GR32:$src2)>;
3468 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3469 (ADD32rm GR32:$src1, addr:$src2)>;
3470 def : Pat<(addc GR32:$src1, imm:$src2),
3471 (ADD32ri GR32:$src1, imm:$src2)>;
3472 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3473 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3475 def : Pat<(subc GR32:$src1, GR32:$src2),
3476 (SUB32rr GR32:$src1, GR32:$src2)>;
3477 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3478 (SUB32rm GR32:$src1, addr:$src2)>;
3479 def : Pat<(subc GR32:$src1, imm:$src2),
3480 (SUB32ri GR32:$src1, imm:$src2)>;
3481 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3482 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3486 // TEST R,R is smaller than CMP R,0
3487 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3488 (TEST8rr GR8:$src1, GR8:$src1)>;
3489 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3490 (TEST16rr GR16:$src1, GR16:$src1)>;
3491 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3492 (TEST32rr GR32:$src1, GR32:$src1)>;
3494 // Conditional moves with folded loads with operands swapped and conditions
3496 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3497 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3498 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3499 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3500 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3501 (CMOVB16rm GR16:$src2, addr:$src1)>;
3502 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3503 (CMOVB32rm GR32:$src2, addr:$src1)>;
3504 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3505 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3506 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3507 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3508 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3509 (CMOVE16rm GR16:$src2, addr:$src1)>;
3510 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3511 (CMOVE32rm GR32:$src2, addr:$src1)>;
3512 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3513 (CMOVA16rm GR16:$src2, addr:$src1)>;
3514 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3515 (CMOVA32rm GR32:$src2, addr:$src1)>;
3516 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3517 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3518 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3519 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3520 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3521 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3522 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3523 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3524 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3525 (CMOVL16rm GR16:$src2, addr:$src1)>;
3526 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3527 (CMOVL32rm GR32:$src2, addr:$src1)>;
3528 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3529 (CMOVG16rm GR16:$src2, addr:$src1)>;
3530 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3531 (CMOVG32rm GR32:$src2, addr:$src1)>;
3532 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3533 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3534 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3535 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3536 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3537 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3538 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3539 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3540 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3541 (CMOVP16rm GR16:$src2, addr:$src1)>;
3542 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3543 (CMOVP32rm GR32:$src2, addr:$src1)>;
3544 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3545 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3546 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3547 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3548 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3549 (CMOVS16rm GR16:$src2, addr:$src1)>;
3550 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3551 (CMOVS32rm GR32:$src2, addr:$src1)>;
3552 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3553 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3554 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3555 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3556 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3557 (CMOVO16rm GR16:$src2, addr:$src1)>;
3558 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3559 (CMOVO32rm GR32:$src2, addr:$src1)>;
3561 // zextload bool -> zextload byte
3562 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3563 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3564 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3566 // extload bool -> extload byte
3567 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3568 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3569 Requires<[In32BitMode]>;
3570 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3571 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3572 Requires<[In32BitMode]>;
3573 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3574 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3577 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3578 Requires<[In32BitMode]>;
3579 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3580 Requires<[In32BitMode]>;
3581 def : Pat<(i32 (anyext GR16:$src)),
3582 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
3584 // (and (i32 load), 255) -> (zextload i8)
3585 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3586 (MOVZX32rm8 addr:$src)>;
3587 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3588 (MOVZX32rm16 addr:$src)>;
3590 //===----------------------------------------------------------------------===//
3592 //===----------------------------------------------------------------------===//
3594 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3595 // +128 doesn't, so in this special case use a sub instead of an add.
3596 def : Pat<(add GR16:$src1, 128),
3597 (SUB16ri8 GR16:$src1, -128)>;
3598 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3599 (SUB16mi8 addr:$dst, -128)>;
3600 def : Pat<(add GR32:$src1, 128),
3601 (SUB32ri8 GR32:$src1, -128)>;
3602 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3603 (SUB32mi8 addr:$dst, -128)>;
3605 // r & (2^16-1) ==> movz
3606 def : Pat<(and GR32:$src1, 0xffff),
3607 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
3608 // r & (2^8-1) ==> movz
3609 def : Pat<(and GR32:$src1, 0xff),
3610 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
3612 Requires<[In32BitMode]>;
3613 // r & (2^8-1) ==> movz
3614 def : Pat<(and GR16:$src1, 0xff),
3615 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
3617 Requires<[In32BitMode]>;
3619 // sext_inreg patterns
3620 def : Pat<(sext_inreg GR32:$src, i16),
3621 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3622 def : Pat<(sext_inreg GR32:$src, i8),
3623 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3625 Requires<[In32BitMode]>;
3626 def : Pat<(sext_inreg GR16:$src, i8),
3627 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3629 Requires<[In32BitMode]>;
3632 def : Pat<(i16 (trunc GR32:$src)),
3633 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
3634 def : Pat<(i8 (trunc GR32:$src)),
3635 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3637 Requires<[In32BitMode]>;
3638 def : Pat<(i8 (trunc GR16:$src)),
3639 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3641 Requires<[In32BitMode]>;
3643 // h-register tricks
3644 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
3645 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3646 x86_subreg_8bit_hi)>,
3647 Requires<[In32BitMode]>;
3648 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
3649 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3650 x86_subreg_8bit_hi)>,
3651 Requires<[In32BitMode]>;
3652 def : Pat<(srl_su GR16:$src, (i8 8)),
3655 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3656 x86_subreg_8bit_hi)),
3658 Requires<[In32BitMode]>;
3659 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3660 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3661 x86_subreg_8bit_hi))>,
3662 Requires<[In32BitMode]>;
3663 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
3664 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3665 x86_subreg_8bit_hi))>,
3666 Requires<[In32BitMode]>;
3668 // (shl x, 1) ==> (add x, x)
3669 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3670 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3671 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3673 // (shl x (and y, 31)) ==> (shl x, y)
3674 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3675 (SHL8rCL GR8:$src1)>;
3676 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3677 (SHL16rCL GR16:$src1)>;
3678 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3679 (SHL32rCL GR32:$src1)>;
3680 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3681 (SHL8mCL addr:$dst)>;
3682 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3683 (SHL16mCL addr:$dst)>;
3684 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3685 (SHL32mCL addr:$dst)>;
3687 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3688 (SHR8rCL GR8:$src1)>;
3689 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3690 (SHR16rCL GR16:$src1)>;
3691 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3692 (SHR32rCL GR32:$src1)>;
3693 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3694 (SHR8mCL addr:$dst)>;
3695 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3696 (SHR16mCL addr:$dst)>;
3697 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3698 (SHR32mCL addr:$dst)>;
3700 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3701 (SAR8rCL GR8:$src1)>;
3702 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3703 (SAR16rCL GR16:$src1)>;
3704 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3705 (SAR32rCL GR32:$src1)>;
3706 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3707 (SAR8mCL addr:$dst)>;
3708 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3709 (SAR16mCL addr:$dst)>;
3710 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3711 (SAR32mCL addr:$dst)>;
3713 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3714 def : Pat<(or (srl GR32:$src1, CL:$amt),
3715 (shl GR32:$src2, (sub 32, CL:$amt))),
3716 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3718 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3719 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3720 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3722 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3723 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3724 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3726 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3727 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3729 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3731 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3732 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3734 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3735 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3736 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3738 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3739 def : Pat<(or (shl GR32:$src1, CL:$amt),
3740 (srl GR32:$src2, (sub 32, CL:$amt))),
3741 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3743 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3744 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3745 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3747 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3748 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3749 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3751 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3752 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3754 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3756 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3757 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3759 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3760 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3761 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3763 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3764 def : Pat<(or (srl GR16:$src1, CL:$amt),
3765 (shl GR16:$src2, (sub 16, CL:$amt))),
3766 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3768 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3769 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3770 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3772 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3773 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3774 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3776 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3777 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3779 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3781 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3782 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3784 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3785 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3786 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3788 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3789 def : Pat<(or (shl GR16:$src1, CL:$amt),
3790 (srl GR16:$src2, (sub 16, CL:$amt))),
3791 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3793 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3794 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3795 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3797 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3798 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3799 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3801 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3802 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3804 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3806 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3807 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3809 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3810 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3811 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3813 //===----------------------------------------------------------------------===//
3814 // EFLAGS-defining Patterns
3815 //===----------------------------------------------------------------------===//
3817 // Register-Register Addition with EFLAGS result
3818 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
3820 (ADD8rr GR8:$src1, GR8:$src2)>;
3821 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
3823 (ADD16rr GR16:$src1, GR16:$src2)>;
3824 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
3826 (ADD32rr GR32:$src1, GR32:$src2)>;
3828 // Register-Memory Addition with EFLAGS result
3829 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
3831 (ADD8rm GR8:$src1, addr:$src2)>;
3832 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
3834 (ADD16rm GR16:$src1, addr:$src2)>;
3835 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
3837 (ADD32rm GR32:$src1, addr:$src2)>;
3839 // Register-Integer Addition with EFLAGS result
3840 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
3842 (ADD8ri GR8:$src1, imm:$src2)>;
3843 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
3845 (ADD16ri GR16:$src1, imm:$src2)>;
3846 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
3848 (ADD32ri GR32:$src1, imm:$src2)>;
3849 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
3851 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3852 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
3854 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3856 // Memory-Register Addition with EFLAGS result
3857 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
3860 (ADD8mr addr:$dst, GR8:$src2)>;
3861 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
3864 (ADD16mr addr:$dst, GR16:$src2)>;
3865 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
3868 (ADD32mr addr:$dst, GR32:$src2)>;
3870 // Memory-Integer Addition with EFLAGS result
3871 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
3874 (ADD8mi addr:$dst, imm:$src2)>;
3875 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
3878 (ADD16mi addr:$dst, imm:$src2)>;
3879 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
3882 (ADD32mi addr:$dst, imm:$src2)>;
3883 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3886 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3887 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3890 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3892 // Register-Register Subtraction with EFLAGS result
3893 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
3895 (SUB8rr GR8:$src1, GR8:$src2)>;
3896 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
3898 (SUB16rr GR16:$src1, GR16:$src2)>;
3899 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
3901 (SUB32rr GR32:$src1, GR32:$src2)>;
3903 // Register-Memory Subtraction with EFLAGS result
3904 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
3906 (SUB8rm GR8:$src1, addr:$src2)>;
3907 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
3909 (SUB16rm GR16:$src1, addr:$src2)>;
3910 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
3912 (SUB32rm GR32:$src1, addr:$src2)>;
3914 // Register-Integer Subtraction with EFLAGS result
3915 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
3917 (SUB8ri GR8:$src1, imm:$src2)>;
3918 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
3920 (SUB16ri GR16:$src1, imm:$src2)>;
3921 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
3923 (SUB32ri GR32:$src1, imm:$src2)>;
3924 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
3926 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3927 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
3929 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3931 // Memory-Register Subtraction with EFLAGS result
3932 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
3935 (SUB8mr addr:$dst, GR8:$src2)>;
3936 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
3939 (SUB16mr addr:$dst, GR16:$src2)>;
3940 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
3943 (SUB32mr addr:$dst, GR32:$src2)>;
3945 // Memory-Integer Subtraction with EFLAGS result
3946 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
3949 (SUB8mi addr:$dst, imm:$src2)>;
3950 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
3953 (SUB16mi addr:$dst, imm:$src2)>;
3954 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
3957 (SUB32mi addr:$dst, imm:$src2)>;
3958 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3961 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3962 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3965 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3968 // Register-Register Signed Integer Multiply with EFLAGS result
3969 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
3971 (IMUL16rr GR16:$src1, GR16:$src2)>;
3972 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
3974 (IMUL32rr GR32:$src1, GR32:$src2)>;
3976 // Register-Memory Signed Integer Multiply with EFLAGS result
3977 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
3979 (IMUL16rm GR16:$src1, addr:$src2)>;
3980 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
3982 (IMUL32rm GR32:$src1, addr:$src2)>;
3984 // Register-Integer Signed Integer Multiply with EFLAGS result
3985 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
3987 (IMUL16rri GR16:$src1, imm:$src2)>;
3988 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
3990 (IMUL32rri GR32:$src1, imm:$src2)>;
3991 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
3993 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
3994 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
3996 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3998 // Memory-Integer Signed Integer Multiply with EFLAGS result
3999 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
4001 (IMUL16rmi addr:$src1, imm:$src2)>;
4002 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
4004 (IMUL32rmi addr:$src1, imm:$src2)>;
4005 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
4007 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4008 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
4010 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4012 // Optimize multiply by 2 with EFLAGS result.
4013 let AddedComplexity = 2 in {
4014 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
4016 (ADD16rr GR16:$src1, GR16:$src1)>;
4018 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
4020 (ADD32rr GR32:$src1, GR32:$src1)>;
4023 // INC and DEC with EFLAGS result. Note that these do not set CF.
4024 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4026 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4029 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4031 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4035 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
4036 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4037 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4039 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
4040 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
4041 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4042 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4044 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
4046 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
4047 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4048 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4050 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
4051 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
4052 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4053 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4055 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
4057 //===----------------------------------------------------------------------===//
4058 // Floating Point Stack Support
4059 //===----------------------------------------------------------------------===//
4061 include "X86InstrFPStack.td"
4063 //===----------------------------------------------------------------------===//
4065 //===----------------------------------------------------------------------===//
4067 include "X86Instr64bit.td"
4069 //===----------------------------------------------------------------------===//
4070 // XMM Floating point support (requires SSE / SSE2)
4071 //===----------------------------------------------------------------------===//
4073 include "X86InstrSSE.td"
4075 //===----------------------------------------------------------------------===//
4076 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4077 //===----------------------------------------------------------------------===//
4079 include "X86InstrMMX.td"