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 X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
128 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
130 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
131 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
132 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
133 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
136 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
137 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
139 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
140 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
142 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
143 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
144 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
145 SDT_X86SegmentBaseAddress, []>;
147 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
150 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
151 [SDNPHasChain, SDNPOptInFlag]>;
153 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
154 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
155 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
156 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
157 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
158 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
160 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
162 //===----------------------------------------------------------------------===//
163 // X86 Operand Definitions.
166 def i32imm_pcrel : Operand<i32> {
167 let PrintMethod = "print_pcrel_imm";
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, 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, 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 //===----------------------------------------------------------------------===//
222 // X86 Complex Pattern Definitions.
225 // Define X86 specific addressing mode.
226 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
227 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
228 [add, sub, mul, shl, or, frameindex], []>;
229 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
230 [tglobaltlsaddr], []>;
232 //===----------------------------------------------------------------------===//
233 // X86 Instruction Predicate Definitions.
234 def HasMMX : Predicate<"Subtarget->hasMMX()">;
235 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
236 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
237 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
238 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
239 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
240 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
241 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
242 def HasAVX : Predicate<"Subtarget->hasAVX()">;
243 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
244 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
245 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
246 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
247 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
248 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
249 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
250 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
251 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
252 def OptForSpeed : Predicate<"!OptForSize">;
253 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
254 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
256 //===----------------------------------------------------------------------===//
257 // X86 Instruction Format Definitions.
260 include "X86InstrFormats.td"
262 //===----------------------------------------------------------------------===//
263 // Pattern fragments...
266 // X86 specific condition code. These correspond to CondCode in
267 // X86InstrInfo.h. They must be kept in synch.
268 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
269 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
270 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
271 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
272 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
273 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
274 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
275 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
276 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
277 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
278 def X86_COND_NO : PatLeaf<(i8 10)>;
279 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
280 def X86_COND_NS : PatLeaf<(i8 12)>;
281 def X86_COND_O : PatLeaf<(i8 13)>;
282 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
283 def X86_COND_S : PatLeaf<(i8 15)>;
285 def i16immSExt8 : PatLeaf<(i16 imm), [{
286 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
287 // sign extended field.
288 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
291 def i32immSExt8 : PatLeaf<(i32 imm), [{
292 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
293 // sign extended field.
294 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
297 // Helper fragments for loads.
298 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
299 // known to be 32-bit aligned or better. Ditto for i8 to i16.
300 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
301 LoadSDNode *LD = cast<LoadSDNode>(N);
302 if (const Value *Src = LD->getSrcValue())
303 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
304 if (PT->getAddressSpace() > 255)
306 ISD::LoadExtType ExtType = LD->getExtensionType();
307 if (ExtType == ISD::NON_EXTLOAD)
309 if (ExtType == ISD::EXTLOAD)
310 return LD->getAlignment() >= 2 && !LD->isVolatile();
314 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
315 LoadSDNode *LD = cast<LoadSDNode>(N);
316 if (const Value *Src = LD->getSrcValue())
317 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
318 if (PT->getAddressSpace() > 255)
320 ISD::LoadExtType ExtType = LD->getExtensionType();
321 if (ExtType == ISD::EXTLOAD)
322 return LD->getAlignment() >= 2 && !LD->isVolatile();
326 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
327 LoadSDNode *LD = cast<LoadSDNode>(N);
328 if (const Value *Src = LD->getSrcValue())
329 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
330 if (PT->getAddressSpace() > 255)
332 ISD::LoadExtType ExtType = LD->getExtensionType();
333 if (ExtType == ISD::NON_EXTLOAD)
335 if (ExtType == ISD::EXTLOAD)
336 return LD->getAlignment() >= 4 && !LD->isVolatile();
340 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
341 LoadSDNode *LD = cast<LoadSDNode>(N);
342 if (const Value *Src = LD->getSrcValue())
343 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
344 if (PT->getAddressSpace() > 255)
346 if (LD->isVolatile())
348 ISD::LoadExtType ExtType = LD->getExtensionType();
349 if (ExtType == ISD::NON_EXTLOAD)
351 if (ExtType == ISD::EXTLOAD)
352 return LD->getAlignment() >= 4;
356 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
357 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
358 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
359 return PT->getAddressSpace() == 256;
363 def fsload : 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() == 257;
370 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
373 if (PT->getAddressSpace() > 255)
377 def loadi64 : PatFrag<(ops node:$ptr), (i64 (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)
385 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
386 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
387 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
388 if (PT->getAddressSpace() > 255)
392 def loadf64 : PatFrag<(ops node:$ptr), (f64 (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 loadf80 : PatFrag<(ops node:$ptr), (f80 (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)
407 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
408 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
409 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
411 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
412 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
413 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
414 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
415 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
416 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
418 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
419 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
420 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
421 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
422 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
423 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
426 // An 'and' node with a single use.
427 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
428 return N->hasOneUse();
430 // An 'srl' node with a single use.
431 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
432 return N->hasOneUse();
434 // An 'trunc' node with a single use.
435 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
436 return N->hasOneUse();
439 // 'shld' and 'shrd' instruction patterns. Note that even though these have
440 // the srl and shl in their patterns, the C++ code must still check for them,
441 // because predicates are tested before children nodes are explored.
443 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
444 (or (srl node:$src1, node:$amt1),
445 (shl node:$src2, node:$amt2)), [{
446 assert(N->getOpcode() == ISD::OR);
447 return N->getOperand(0).getOpcode() == ISD::SRL &&
448 N->getOperand(1).getOpcode() == ISD::SHL &&
449 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
450 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
451 N->getOperand(0).getConstantOperandVal(1) ==
452 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
455 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
456 (or (shl node:$src1, node:$amt1),
457 (srl node:$src2, node:$amt2)), [{
458 assert(N->getOpcode() == ISD::OR);
459 return N->getOperand(0).getOpcode() == ISD::SHL &&
460 N->getOperand(1).getOpcode() == ISD::SRL &&
461 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
462 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
463 N->getOperand(0).getConstantOperandVal(1) ==
464 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
467 //===----------------------------------------------------------------------===//
468 // Instruction list...
471 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
472 // a stack adjustment and the codegen must know that they may modify the stack
473 // pointer before prolog-epilog rewriting occurs.
474 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
475 // sub / add which can clobber EFLAGS.
476 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
477 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
479 [(X86callseq_start timm:$amt)]>,
480 Requires<[In32BitMode]>;
481 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
483 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
484 Requires<[In32BitMode]>;
488 let neverHasSideEffects = 1 in
489 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
492 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
493 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
497 //===----------------------------------------------------------------------===//
498 // Control Flow Instructions...
501 // Return instructions.
502 let isTerminator = 1, isReturn = 1, isBarrier = 1,
503 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
504 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
507 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
509 [(X86retflag imm:$amt)]>;
512 // All branches are RawFrm, Void, Branch, and Terminators
513 let isBranch = 1, isTerminator = 1 in
514 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
515 I<opcode, RawFrm, (outs), ins, asm, pattern>;
517 let isBranch = 1, isBarrier = 1 in
518 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
521 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
522 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
523 [(brind GR32:$dst)]>;
524 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
525 [(brind (loadi32 addr:$dst))]>;
528 // Conditional branches
529 let Uses = [EFLAGS] in {
530 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
531 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
532 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
533 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
534 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
535 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
536 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
537 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
538 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
539 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
540 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
541 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
543 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
544 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
545 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
546 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
547 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
548 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
549 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
550 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
552 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
553 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
554 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
555 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
556 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
557 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
558 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
559 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
560 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
561 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
562 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
563 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
566 //===----------------------------------------------------------------------===//
567 // Call Instructions...
570 // All calls clobber the non-callee saved registers. ESP is marked as
571 // a use to prevent stack-pointer assignments that appear immediately
572 // before calls from potentially appearing dead. Uses for argument
573 // registers are added manually.
574 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
575 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
576 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
577 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
579 def CALLpcrel32 : Ii32<0xE8, RawFrm,
580 (outs), (ins i32imm_pcrel:$dst,variable_ops),
582 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
583 "call\t{*}$dst", [(X86call GR32:$dst)]>;
584 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
585 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
590 def TAILCALL : I<0, Pseudo, (outs), (ins),
594 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
595 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
596 "#TC_RETURN $dst $offset",
599 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
600 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
601 "#TC_RETURN $dst $offset",
604 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
606 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
608 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
609 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
611 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
612 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
613 "jmp\t{*}$dst # TAILCALL", []>;
615 //===----------------------------------------------------------------------===//
616 // Miscellaneous Instructions...
618 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
619 def LEAVE : I<0xC9, RawFrm,
620 (outs), (ins), "leave", []>;
622 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
624 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
627 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
630 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
631 def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
632 "push{l}\t$imm", []>;
633 def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
634 "push{l}\t$imm", []>;
635 def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
636 "push{l}\t$imm", []>;
639 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
640 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
641 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
642 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
644 let isTwoAddress = 1 in // GR32 = bswap GR32
645 def BSWAP32r : I<0xC8, AddRegFrm,
646 (outs GR32:$dst), (ins GR32:$src),
648 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
651 // Bit scan instructions.
652 let Defs = [EFLAGS] in {
653 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
654 "bsf{w}\t{$src, $dst|$dst, $src}",
655 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
656 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
657 "bsf{w}\t{$src, $dst|$dst, $src}",
658 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
659 (implicit EFLAGS)]>, TB;
660 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
661 "bsf{l}\t{$src, $dst|$dst, $src}",
662 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
663 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
664 "bsf{l}\t{$src, $dst|$dst, $src}",
665 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
666 (implicit EFLAGS)]>, TB;
668 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
669 "bsr{w}\t{$src, $dst|$dst, $src}",
670 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
671 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
672 "bsr{w}\t{$src, $dst|$dst, $src}",
673 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
674 (implicit EFLAGS)]>, TB;
675 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
676 "bsr{l}\t{$src, $dst|$dst, $src}",
677 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
678 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
679 "bsr{l}\t{$src, $dst|$dst, $src}",
680 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
681 (implicit EFLAGS)]>, TB;
684 let neverHasSideEffects = 1 in
685 def LEA16r : I<0x8D, MRMSrcMem,
686 (outs GR16:$dst), (ins i32mem:$src),
687 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
688 let isReMaterializable = 1 in
689 def LEA32r : I<0x8D, MRMSrcMem,
690 (outs GR32:$dst), (ins lea32mem:$src),
691 "lea{l}\t{$src|$dst}, {$dst|$src}",
692 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
694 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
695 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
696 [(X86rep_movs i8)]>, REP;
697 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
698 [(X86rep_movs i16)]>, REP, OpSize;
699 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
700 [(X86rep_movs i32)]>, REP;
703 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
704 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
705 [(X86rep_stos i8)]>, REP;
706 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
707 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
708 [(X86rep_stos i16)]>, REP, OpSize;
709 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
710 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
711 [(X86rep_stos i32)]>, REP;
713 let Defs = [RAX, RDX] in
714 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
717 let isBarrier = 1, hasCtrlDep = 1 in {
718 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
721 //===----------------------------------------------------------------------===//
722 // Input/Output Instructions...
724 let Defs = [AL], Uses = [DX] in
725 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
726 "in{b}\t{%dx, %al|%AL, %DX}", []>;
727 let Defs = [AX], Uses = [DX] in
728 def IN16rr : I<0xED, RawFrm, (outs), (ins),
729 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
730 let Defs = [EAX], Uses = [DX] in
731 def IN32rr : I<0xED, RawFrm, (outs), (ins),
732 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
735 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
736 "in{b}\t{$port, %al|%AL, $port}", []>;
738 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
739 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
741 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
742 "in{l}\t{$port, %eax|%EAX, $port}", []>;
744 let Uses = [DX, AL] in
745 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
746 "out{b}\t{%al, %dx|%DX, %AL}", []>;
747 let Uses = [DX, AX] in
748 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
749 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
750 let Uses = [DX, EAX] in
751 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
752 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
755 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
756 "out{b}\t{%al, $port|$port, %AL}", []>;
758 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
759 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
761 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
762 "out{l}\t{%eax, $port|$port, %EAX}", []>;
764 //===----------------------------------------------------------------------===//
765 // Move Instructions...
767 let neverHasSideEffects = 1 in {
768 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
769 "mov{b}\t{$src, $dst|$dst, $src}", []>;
770 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
771 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
772 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
773 "mov{l}\t{$src, $dst|$dst, $src}", []>;
775 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
776 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
777 "mov{b}\t{$src, $dst|$dst, $src}",
778 [(set GR8:$dst, imm:$src)]>;
779 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
780 "mov{w}\t{$src, $dst|$dst, $src}",
781 [(set GR16:$dst, imm:$src)]>, OpSize;
782 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
783 "mov{l}\t{$src, $dst|$dst, $src}",
784 [(set GR32:$dst, imm:$src)]>;
786 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
787 "mov{b}\t{$src, $dst|$dst, $src}",
788 [(store (i8 imm:$src), addr:$dst)]>;
789 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
790 "mov{w}\t{$src, $dst|$dst, $src}",
791 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
792 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
793 "mov{l}\t{$src, $dst|$dst, $src}",
794 [(store (i32 imm:$src), addr:$dst)]>;
796 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
797 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
798 "mov{b}\t{$src, $dst|$dst, $src}",
799 [(set GR8:$dst, (loadi8 addr:$src))]>;
800 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
801 "mov{w}\t{$src, $dst|$dst, $src}",
802 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
803 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
804 "mov{l}\t{$src, $dst|$dst, $src}",
805 [(set GR32:$dst, (loadi32 addr:$src))]>;
808 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
809 "mov{b}\t{$src, $dst|$dst, $src}",
810 [(store GR8:$src, addr:$dst)]>;
811 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
812 "mov{w}\t{$src, $dst|$dst, $src}",
813 [(store GR16:$src, addr:$dst)]>, OpSize;
814 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
815 "mov{l}\t{$src, $dst|$dst, $src}",
816 [(store GR32:$src, addr:$dst)]>;
818 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
819 // that they can be used for copying and storing h registers, which can't be
820 // encoded when a REX prefix is present.
821 let neverHasSideEffects = 1 in
822 def MOV8rr_NOREX : I<0x88, MRMDestReg,
823 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
824 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
826 def MOV8mr_NOREX : I<0x88, MRMDestMem,
827 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
828 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
830 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
831 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
832 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
833 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
835 //===----------------------------------------------------------------------===//
836 // Fixed-Register Multiplication and Division Instructions...
839 // Extra precision multiplication
840 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
841 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
842 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
843 // This probably ought to be moved to a def : Pat<> if the
844 // syntax can be accepted.
845 [(set AL, (mul AL, GR8:$src)),
846 (implicit EFLAGS)]>; // AL,AH = AL*GR8
848 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
849 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
851 []>, OpSize; // AX,DX = AX*GR16
853 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
854 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
856 []>; // EAX,EDX = EAX*GR32
858 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
859 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
861 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
862 // This probably ought to be moved to a def : Pat<> if the
863 // syntax can be accepted.
864 [(set AL, (mul AL, (loadi8 addr:$src))),
865 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
867 let mayLoad = 1, neverHasSideEffects = 1 in {
868 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
869 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
871 []>, OpSize; // AX,DX = AX*[mem16]
873 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
874 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
876 []>; // EAX,EDX = EAX*[mem32]
879 let neverHasSideEffects = 1 in {
880 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
881 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
883 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
884 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
885 OpSize; // AX,DX = AX*GR16
886 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
887 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
888 // EAX,EDX = EAX*GR32
890 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
891 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
892 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
893 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
894 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
895 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
896 let Defs = [EAX,EDX], Uses = [EAX] in
897 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
898 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
900 } // neverHasSideEffects
902 // unsigned division/remainder
903 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
904 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
906 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
907 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
908 "div{w}\t$src", []>, OpSize;
909 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
910 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
913 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
914 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
916 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
917 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
918 "div{w}\t$src", []>, OpSize;
919 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
920 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
924 // Signed division/remainder.
925 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
926 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
927 "idiv{b}\t$src", []>;
928 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
929 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
930 "idiv{w}\t$src", []>, OpSize;
931 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
932 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
933 "idiv{l}\t$src", []>;
934 let mayLoad = 1, mayLoad = 1 in {
935 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
936 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
937 "idiv{b}\t$src", []>;
938 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
939 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
940 "idiv{w}\t$src", []>, OpSize;
941 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
942 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
943 "idiv{l}\t$src", []>;
946 //===----------------------------------------------------------------------===//
947 // Two address Instructions.
949 let isTwoAddress = 1 in {
952 let Uses = [EFLAGS] in {
953 let isCommutable = 1 in {
954 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
955 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
956 "cmovb\t{$src2, $dst|$dst, $src2}",
957 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
958 X86_COND_B, EFLAGS))]>,
960 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
961 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
962 "cmovb\t{$src2, $dst|$dst, $src2}",
963 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
964 X86_COND_B, EFLAGS))]>,
966 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
967 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
968 "cmovae\t{$src2, $dst|$dst, $src2}",
969 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
970 X86_COND_AE, EFLAGS))]>,
972 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
973 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
974 "cmovae\t{$src2, $dst|$dst, $src2}",
975 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
976 X86_COND_AE, EFLAGS))]>,
978 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
979 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
980 "cmove\t{$src2, $dst|$dst, $src2}",
981 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
982 X86_COND_E, EFLAGS))]>,
984 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
985 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
986 "cmove\t{$src2, $dst|$dst, $src2}",
987 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
988 X86_COND_E, EFLAGS))]>,
990 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
991 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
992 "cmovne\t{$src2, $dst|$dst, $src2}",
993 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
994 X86_COND_NE, EFLAGS))]>,
996 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
997 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
998 "cmovne\t{$src2, $dst|$dst, $src2}",
999 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1000 X86_COND_NE, EFLAGS))]>,
1002 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1003 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1004 "cmovbe\t{$src2, $dst|$dst, $src2}",
1005 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1006 X86_COND_BE, EFLAGS))]>,
1008 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1009 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1010 "cmovbe\t{$src2, $dst|$dst, $src2}",
1011 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1012 X86_COND_BE, EFLAGS))]>,
1014 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1015 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1016 "cmova\t{$src2, $dst|$dst, $src2}",
1017 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1018 X86_COND_A, EFLAGS))]>,
1020 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1021 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1022 "cmova\t{$src2, $dst|$dst, $src2}",
1023 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1024 X86_COND_A, EFLAGS))]>,
1026 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1027 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1028 "cmovl\t{$src2, $dst|$dst, $src2}",
1029 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1030 X86_COND_L, EFLAGS))]>,
1032 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1033 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1034 "cmovl\t{$src2, $dst|$dst, $src2}",
1035 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1036 X86_COND_L, EFLAGS))]>,
1038 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1039 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1040 "cmovge\t{$src2, $dst|$dst, $src2}",
1041 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1042 X86_COND_GE, EFLAGS))]>,
1044 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1045 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1046 "cmovge\t{$src2, $dst|$dst, $src2}",
1047 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1048 X86_COND_GE, EFLAGS))]>,
1050 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1051 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1052 "cmovle\t{$src2, $dst|$dst, $src2}",
1053 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1054 X86_COND_LE, EFLAGS))]>,
1056 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1057 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1058 "cmovle\t{$src2, $dst|$dst, $src2}",
1059 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1060 X86_COND_LE, EFLAGS))]>,
1062 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1063 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1064 "cmovg\t{$src2, $dst|$dst, $src2}",
1065 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1066 X86_COND_G, EFLAGS))]>,
1068 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1069 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1070 "cmovg\t{$src2, $dst|$dst, $src2}",
1071 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1072 X86_COND_G, EFLAGS))]>,
1074 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1075 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1076 "cmovs\t{$src2, $dst|$dst, $src2}",
1077 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1078 X86_COND_S, EFLAGS))]>,
1080 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1081 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1082 "cmovs\t{$src2, $dst|$dst, $src2}",
1083 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1084 X86_COND_S, EFLAGS))]>,
1086 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1087 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1088 "cmovns\t{$src2, $dst|$dst, $src2}",
1089 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1090 X86_COND_NS, EFLAGS))]>,
1092 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1093 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1094 "cmovns\t{$src2, $dst|$dst, $src2}",
1095 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1096 X86_COND_NS, EFLAGS))]>,
1098 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1099 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1100 "cmovp\t{$src2, $dst|$dst, $src2}",
1101 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1102 X86_COND_P, EFLAGS))]>,
1104 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1105 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1106 "cmovp\t{$src2, $dst|$dst, $src2}",
1107 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1108 X86_COND_P, EFLAGS))]>,
1110 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1111 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1112 "cmovnp\t{$src2, $dst|$dst, $src2}",
1113 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1114 X86_COND_NP, EFLAGS))]>,
1116 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1117 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1118 "cmovnp\t{$src2, $dst|$dst, $src2}",
1119 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1120 X86_COND_NP, EFLAGS))]>,
1122 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1123 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1124 "cmovo\t{$src2, $dst|$dst, $src2}",
1125 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1126 X86_COND_O, EFLAGS))]>,
1128 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1129 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1130 "cmovo\t{$src2, $dst|$dst, $src2}",
1131 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1132 X86_COND_O, EFLAGS))]>,
1134 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1135 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1136 "cmovno\t{$src2, $dst|$dst, $src2}",
1137 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1138 X86_COND_NO, EFLAGS))]>,
1140 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1141 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1142 "cmovno\t{$src2, $dst|$dst, $src2}",
1143 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1144 X86_COND_NO, EFLAGS))]>,
1146 } // isCommutable = 1
1148 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1149 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1150 "cmovb\t{$src2, $dst|$dst, $src2}",
1151 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1152 X86_COND_B, EFLAGS))]>,
1154 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1155 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1156 "cmovb\t{$src2, $dst|$dst, $src2}",
1157 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1158 X86_COND_B, EFLAGS))]>,
1160 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1161 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1162 "cmovae\t{$src2, $dst|$dst, $src2}",
1163 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1164 X86_COND_AE, EFLAGS))]>,
1166 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1167 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1168 "cmovae\t{$src2, $dst|$dst, $src2}",
1169 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1170 X86_COND_AE, EFLAGS))]>,
1172 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1173 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1174 "cmove\t{$src2, $dst|$dst, $src2}",
1175 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1176 X86_COND_E, EFLAGS))]>,
1178 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1179 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1180 "cmove\t{$src2, $dst|$dst, $src2}",
1181 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1182 X86_COND_E, EFLAGS))]>,
1184 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1185 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1186 "cmovne\t{$src2, $dst|$dst, $src2}",
1187 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1188 X86_COND_NE, EFLAGS))]>,
1190 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1191 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1192 "cmovne\t{$src2, $dst|$dst, $src2}",
1193 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1194 X86_COND_NE, EFLAGS))]>,
1196 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1197 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1198 "cmovbe\t{$src2, $dst|$dst, $src2}",
1199 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1200 X86_COND_BE, EFLAGS))]>,
1202 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1203 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1204 "cmovbe\t{$src2, $dst|$dst, $src2}",
1205 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1206 X86_COND_BE, EFLAGS))]>,
1208 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1209 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1210 "cmova\t{$src2, $dst|$dst, $src2}",
1211 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1212 X86_COND_A, EFLAGS))]>,
1214 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1215 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1216 "cmova\t{$src2, $dst|$dst, $src2}",
1217 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1218 X86_COND_A, EFLAGS))]>,
1220 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1221 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1222 "cmovl\t{$src2, $dst|$dst, $src2}",
1223 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1224 X86_COND_L, EFLAGS))]>,
1226 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1227 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1228 "cmovl\t{$src2, $dst|$dst, $src2}",
1229 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1230 X86_COND_L, EFLAGS))]>,
1232 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1233 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1234 "cmovge\t{$src2, $dst|$dst, $src2}",
1235 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1236 X86_COND_GE, EFLAGS))]>,
1238 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1239 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1240 "cmovge\t{$src2, $dst|$dst, $src2}",
1241 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1242 X86_COND_GE, EFLAGS))]>,
1244 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1245 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1246 "cmovle\t{$src2, $dst|$dst, $src2}",
1247 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1248 X86_COND_LE, EFLAGS))]>,
1250 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1251 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1252 "cmovle\t{$src2, $dst|$dst, $src2}",
1253 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1254 X86_COND_LE, EFLAGS))]>,
1256 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1257 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1258 "cmovg\t{$src2, $dst|$dst, $src2}",
1259 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1260 X86_COND_G, EFLAGS))]>,
1262 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1263 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1264 "cmovg\t{$src2, $dst|$dst, $src2}",
1265 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1266 X86_COND_G, EFLAGS))]>,
1268 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1269 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1270 "cmovs\t{$src2, $dst|$dst, $src2}",
1271 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1272 X86_COND_S, EFLAGS))]>,
1274 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1275 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1276 "cmovs\t{$src2, $dst|$dst, $src2}",
1277 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1278 X86_COND_S, EFLAGS))]>,
1280 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1281 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1282 "cmovns\t{$src2, $dst|$dst, $src2}",
1283 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1284 X86_COND_NS, EFLAGS))]>,
1286 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1287 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1288 "cmovns\t{$src2, $dst|$dst, $src2}",
1289 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1290 X86_COND_NS, EFLAGS))]>,
1292 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1293 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1294 "cmovp\t{$src2, $dst|$dst, $src2}",
1295 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1296 X86_COND_P, EFLAGS))]>,
1298 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1299 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1300 "cmovp\t{$src2, $dst|$dst, $src2}",
1301 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1302 X86_COND_P, EFLAGS))]>,
1304 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1305 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1306 "cmovnp\t{$src2, $dst|$dst, $src2}",
1307 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1308 X86_COND_NP, EFLAGS))]>,
1310 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1311 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1312 "cmovnp\t{$src2, $dst|$dst, $src2}",
1313 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1314 X86_COND_NP, EFLAGS))]>,
1316 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1317 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1318 "cmovo\t{$src2, $dst|$dst, $src2}",
1319 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1320 X86_COND_O, EFLAGS))]>,
1322 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1323 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1324 "cmovo\t{$src2, $dst|$dst, $src2}",
1325 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1326 X86_COND_O, EFLAGS))]>,
1328 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1329 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1330 "cmovno\t{$src2, $dst|$dst, $src2}",
1331 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1332 X86_COND_NO, EFLAGS))]>,
1334 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1335 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1336 "cmovno\t{$src2, $dst|$dst, $src2}",
1337 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1338 X86_COND_NO, EFLAGS))]>,
1340 } // Uses = [EFLAGS]
1343 // unary instructions
1344 let CodeSize = 2 in {
1345 let Defs = [EFLAGS] in {
1346 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1347 [(set GR8:$dst, (ineg GR8:$src)),
1348 (implicit EFLAGS)]>;
1349 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1350 [(set GR16:$dst, (ineg GR16:$src)),
1351 (implicit EFLAGS)]>, OpSize;
1352 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1353 [(set GR32:$dst, (ineg GR32:$src)),
1354 (implicit EFLAGS)]>;
1355 let isTwoAddress = 0 in {
1356 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1357 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1358 (implicit EFLAGS)]>;
1359 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1360 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1361 (implicit EFLAGS)]>, OpSize;
1362 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1363 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1364 (implicit EFLAGS)]>;
1366 } // Defs = [EFLAGS]
1368 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1369 let AddedComplexity = 15 in {
1370 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1371 [(set GR8:$dst, (not GR8:$src))]>;
1372 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1373 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1374 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1375 [(set GR32:$dst, (not GR32:$src))]>;
1377 let isTwoAddress = 0 in {
1378 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1379 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1380 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1381 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1382 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1383 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1387 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1388 let Defs = [EFLAGS] in {
1390 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1391 [(set GR8:$dst, (add GR8:$src, 1)),
1392 (implicit EFLAGS)]>;
1393 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1394 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1395 [(set GR16:$dst, (add GR16:$src, 1)),
1396 (implicit EFLAGS)]>,
1397 OpSize, Requires<[In32BitMode]>;
1398 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1399 [(set GR32:$dst, (add GR32:$src, 1)),
1400 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1402 let isTwoAddress = 0, CodeSize = 2 in {
1403 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1404 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1405 (implicit EFLAGS)]>;
1406 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1407 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1408 (implicit EFLAGS)]>,
1409 OpSize, Requires<[In32BitMode]>;
1410 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1411 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1412 (implicit EFLAGS)]>,
1413 Requires<[In32BitMode]>;
1417 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1418 [(set GR8:$dst, (add GR8:$src, -1)),
1419 (implicit EFLAGS)]>;
1420 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1421 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1422 [(set GR16:$dst, (add GR16:$src, -1)),
1423 (implicit EFLAGS)]>,
1424 OpSize, Requires<[In32BitMode]>;
1425 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1426 [(set GR32:$dst, (add GR32:$src, -1)),
1427 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1430 let isTwoAddress = 0, CodeSize = 2 in {
1431 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1432 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1433 (implicit EFLAGS)]>;
1434 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1435 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1436 (implicit EFLAGS)]>,
1437 OpSize, Requires<[In32BitMode]>;
1438 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1439 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1440 (implicit EFLAGS)]>,
1441 Requires<[In32BitMode]>;
1443 } // Defs = [EFLAGS]
1445 // Logical operators...
1446 let Defs = [EFLAGS] in {
1447 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1448 def AND8rr : I<0x20, MRMDestReg,
1449 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1450 "and{b}\t{$src2, $dst|$dst, $src2}",
1451 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1452 (implicit EFLAGS)]>;
1453 def AND16rr : I<0x21, MRMDestReg,
1454 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1455 "and{w}\t{$src2, $dst|$dst, $src2}",
1456 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1457 (implicit EFLAGS)]>, OpSize;
1458 def AND32rr : I<0x21, MRMDestReg,
1459 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1460 "and{l}\t{$src2, $dst|$dst, $src2}",
1461 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1462 (implicit EFLAGS)]>;
1465 def AND8rm : I<0x22, MRMSrcMem,
1466 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1467 "and{b}\t{$src2, $dst|$dst, $src2}",
1468 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1469 (implicit EFLAGS)]>;
1470 def AND16rm : I<0x23, MRMSrcMem,
1471 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1472 "and{w}\t{$src2, $dst|$dst, $src2}",
1473 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1474 (implicit EFLAGS)]>, OpSize;
1475 def AND32rm : I<0x23, MRMSrcMem,
1476 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1477 "and{l}\t{$src2, $dst|$dst, $src2}",
1478 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1479 (implicit EFLAGS)]>;
1481 def AND8ri : Ii8<0x80, MRM4r,
1482 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1483 "and{b}\t{$src2, $dst|$dst, $src2}",
1484 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1485 (implicit EFLAGS)]>;
1486 def AND16ri : Ii16<0x81, MRM4r,
1487 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1488 "and{w}\t{$src2, $dst|$dst, $src2}",
1489 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1490 (implicit EFLAGS)]>, OpSize;
1491 def AND32ri : Ii32<0x81, MRM4r,
1492 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1493 "and{l}\t{$src2, $dst|$dst, $src2}",
1494 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1495 (implicit EFLAGS)]>;
1496 def AND16ri8 : Ii8<0x83, MRM4r,
1497 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1498 "and{w}\t{$src2, $dst|$dst, $src2}",
1499 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1500 (implicit EFLAGS)]>,
1502 def AND32ri8 : Ii8<0x83, MRM4r,
1503 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1504 "and{l}\t{$src2, $dst|$dst, $src2}",
1505 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1506 (implicit EFLAGS)]>;
1508 let isTwoAddress = 0 in {
1509 def AND8mr : I<0x20, MRMDestMem,
1510 (outs), (ins i8mem :$dst, GR8 :$src),
1511 "and{b}\t{$src, $dst|$dst, $src}",
1512 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1513 (implicit EFLAGS)]>;
1514 def AND16mr : I<0x21, MRMDestMem,
1515 (outs), (ins i16mem:$dst, GR16:$src),
1516 "and{w}\t{$src, $dst|$dst, $src}",
1517 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1518 (implicit EFLAGS)]>,
1520 def AND32mr : I<0x21, MRMDestMem,
1521 (outs), (ins i32mem:$dst, GR32:$src),
1522 "and{l}\t{$src, $dst|$dst, $src}",
1523 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1524 (implicit EFLAGS)]>;
1525 def AND8mi : Ii8<0x80, MRM4m,
1526 (outs), (ins i8mem :$dst, i8imm :$src),
1527 "and{b}\t{$src, $dst|$dst, $src}",
1528 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1529 (implicit EFLAGS)]>;
1530 def AND16mi : Ii16<0x81, MRM4m,
1531 (outs), (ins i16mem:$dst, i16imm:$src),
1532 "and{w}\t{$src, $dst|$dst, $src}",
1533 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1534 (implicit EFLAGS)]>,
1536 def AND32mi : Ii32<0x81, MRM4m,
1537 (outs), (ins i32mem:$dst, i32imm:$src),
1538 "and{l}\t{$src, $dst|$dst, $src}",
1539 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1540 (implicit EFLAGS)]>;
1541 def AND16mi8 : Ii8<0x83, MRM4m,
1542 (outs), (ins i16mem:$dst, i16i8imm :$src),
1543 "and{w}\t{$src, $dst|$dst, $src}",
1544 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1545 (implicit EFLAGS)]>,
1547 def AND32mi8 : Ii8<0x83, MRM4m,
1548 (outs), (ins i32mem:$dst, i32i8imm :$src),
1549 "and{l}\t{$src, $dst|$dst, $src}",
1550 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1551 (implicit EFLAGS)]>;
1555 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1556 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1557 "or{b}\t{$src2, $dst|$dst, $src2}",
1558 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1559 (implicit EFLAGS)]>;
1560 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1561 "or{w}\t{$src2, $dst|$dst, $src2}",
1562 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1563 (implicit EFLAGS)]>, OpSize;
1564 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1565 "or{l}\t{$src2, $dst|$dst, $src2}",
1566 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1567 (implicit EFLAGS)]>;
1569 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1570 "or{b}\t{$src2, $dst|$dst, $src2}",
1571 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1572 (implicit EFLAGS)]>;
1573 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1574 "or{w}\t{$src2, $dst|$dst, $src2}",
1575 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1576 (implicit EFLAGS)]>, OpSize;
1577 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1578 "or{l}\t{$src2, $dst|$dst, $src2}",
1579 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1580 (implicit EFLAGS)]>;
1582 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1583 "or{b}\t{$src2, $dst|$dst, $src2}",
1584 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1585 (implicit EFLAGS)]>;
1586 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1587 "or{w}\t{$src2, $dst|$dst, $src2}",
1588 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1589 (implicit EFLAGS)]>, OpSize;
1590 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1591 "or{l}\t{$src2, $dst|$dst, $src2}",
1592 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1593 (implicit EFLAGS)]>;
1595 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1596 "or{w}\t{$src2, $dst|$dst, $src2}",
1597 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1598 (implicit EFLAGS)]>, OpSize;
1599 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1600 "or{l}\t{$src2, $dst|$dst, $src2}",
1601 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1602 (implicit EFLAGS)]>;
1603 let isTwoAddress = 0 in {
1604 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1605 "or{b}\t{$src, $dst|$dst, $src}",
1606 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1607 (implicit EFLAGS)]>;
1608 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1609 "or{w}\t{$src, $dst|$dst, $src}",
1610 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1611 (implicit EFLAGS)]>, OpSize;
1612 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1613 "or{l}\t{$src, $dst|$dst, $src}",
1614 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1615 (implicit EFLAGS)]>;
1616 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1617 "or{b}\t{$src, $dst|$dst, $src}",
1618 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1619 (implicit EFLAGS)]>;
1620 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1621 "or{w}\t{$src, $dst|$dst, $src}",
1622 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1623 (implicit EFLAGS)]>,
1625 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1626 "or{l}\t{$src, $dst|$dst, $src}",
1627 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1628 (implicit EFLAGS)]>;
1629 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1630 "or{w}\t{$src, $dst|$dst, $src}",
1631 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1632 (implicit EFLAGS)]>,
1634 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1635 "or{l}\t{$src, $dst|$dst, $src}",
1636 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1637 (implicit EFLAGS)]>;
1638 } // isTwoAddress = 0
1641 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1642 def XOR8rr : I<0x30, MRMDestReg,
1643 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1644 "xor{b}\t{$src2, $dst|$dst, $src2}",
1645 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1646 (implicit EFLAGS)]>;
1647 def XOR16rr : I<0x31, MRMDestReg,
1648 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1649 "xor{w}\t{$src2, $dst|$dst, $src2}",
1650 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1651 (implicit EFLAGS)]>, OpSize;
1652 def XOR32rr : I<0x31, MRMDestReg,
1653 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1654 "xor{l}\t{$src2, $dst|$dst, $src2}",
1655 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1656 (implicit EFLAGS)]>;
1657 } // isCommutable = 1
1659 def XOR8rm : I<0x32, MRMSrcMem ,
1660 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1661 "xor{b}\t{$src2, $dst|$dst, $src2}",
1662 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1663 (implicit EFLAGS)]>;
1664 def XOR16rm : I<0x33, MRMSrcMem ,
1665 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1666 "xor{w}\t{$src2, $dst|$dst, $src2}",
1667 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1668 (implicit EFLAGS)]>,
1670 def XOR32rm : I<0x33, MRMSrcMem ,
1671 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1672 "xor{l}\t{$src2, $dst|$dst, $src2}",
1673 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1674 (implicit EFLAGS)]>;
1676 def XOR8ri : Ii8<0x80, MRM6r,
1677 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1678 "xor{b}\t{$src2, $dst|$dst, $src2}",
1679 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1680 (implicit EFLAGS)]>;
1681 def XOR16ri : Ii16<0x81, MRM6r,
1682 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1683 "xor{w}\t{$src2, $dst|$dst, $src2}",
1684 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1685 (implicit EFLAGS)]>, OpSize;
1686 def XOR32ri : Ii32<0x81, MRM6r,
1687 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1688 "xor{l}\t{$src2, $dst|$dst, $src2}",
1689 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1690 (implicit EFLAGS)]>;
1691 def XOR16ri8 : Ii8<0x83, MRM6r,
1692 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1693 "xor{w}\t{$src2, $dst|$dst, $src2}",
1694 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1695 (implicit EFLAGS)]>,
1697 def XOR32ri8 : Ii8<0x83, MRM6r,
1698 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1699 "xor{l}\t{$src2, $dst|$dst, $src2}",
1700 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1701 (implicit EFLAGS)]>;
1703 let isTwoAddress = 0 in {
1704 def XOR8mr : I<0x30, MRMDestMem,
1705 (outs), (ins i8mem :$dst, GR8 :$src),
1706 "xor{b}\t{$src, $dst|$dst, $src}",
1707 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1708 (implicit EFLAGS)]>;
1709 def XOR16mr : I<0x31, MRMDestMem,
1710 (outs), (ins i16mem:$dst, GR16:$src),
1711 "xor{w}\t{$src, $dst|$dst, $src}",
1712 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1713 (implicit EFLAGS)]>,
1715 def XOR32mr : I<0x31, MRMDestMem,
1716 (outs), (ins i32mem:$dst, GR32:$src),
1717 "xor{l}\t{$src, $dst|$dst, $src}",
1718 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1719 (implicit EFLAGS)]>;
1720 def XOR8mi : Ii8<0x80, MRM6m,
1721 (outs), (ins i8mem :$dst, i8imm :$src),
1722 "xor{b}\t{$src, $dst|$dst, $src}",
1723 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1724 (implicit EFLAGS)]>;
1725 def XOR16mi : Ii16<0x81, MRM6m,
1726 (outs), (ins i16mem:$dst, i16imm:$src),
1727 "xor{w}\t{$src, $dst|$dst, $src}",
1728 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1729 (implicit EFLAGS)]>,
1731 def XOR32mi : Ii32<0x81, MRM6m,
1732 (outs), (ins i32mem:$dst, i32imm:$src),
1733 "xor{l}\t{$src, $dst|$dst, $src}",
1734 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1735 (implicit EFLAGS)]>;
1736 def XOR16mi8 : Ii8<0x83, MRM6m,
1737 (outs), (ins i16mem:$dst, i16i8imm :$src),
1738 "xor{w}\t{$src, $dst|$dst, $src}",
1739 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1740 (implicit EFLAGS)]>,
1742 def XOR32mi8 : Ii8<0x83, MRM6m,
1743 (outs), (ins i32mem:$dst, i32i8imm :$src),
1744 "xor{l}\t{$src, $dst|$dst, $src}",
1745 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1746 (implicit EFLAGS)]>;
1747 } // isTwoAddress = 0
1748 } // Defs = [EFLAGS]
1750 // Shift instructions
1751 let Defs = [EFLAGS] in {
1752 let Uses = [CL] in {
1753 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1754 "shl{b}\t{%cl, $dst|$dst, CL}",
1755 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1756 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1757 "shl{w}\t{%cl, $dst|$dst, CL}",
1758 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1759 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1760 "shl{l}\t{%cl, $dst|$dst, CL}",
1761 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1764 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1765 "shl{b}\t{$src2, $dst|$dst, $src2}",
1766 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1767 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1768 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1769 "shl{w}\t{$src2, $dst|$dst, $src2}",
1770 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1771 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1772 "shl{l}\t{$src2, $dst|$dst, $src2}",
1773 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1774 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1776 } // isConvertibleToThreeAddress = 1
1778 let isTwoAddress = 0 in {
1779 let Uses = [CL] in {
1780 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1781 "shl{b}\t{%cl, $dst|$dst, CL}",
1782 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1783 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1784 "shl{w}\t{%cl, $dst|$dst, CL}",
1785 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1786 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1787 "shl{l}\t{%cl, $dst|$dst, CL}",
1788 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1790 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1791 "shl{b}\t{$src, $dst|$dst, $src}",
1792 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1793 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1794 "shl{w}\t{$src, $dst|$dst, $src}",
1795 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1797 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1798 "shl{l}\t{$src, $dst|$dst, $src}",
1799 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1802 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1804 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1805 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1807 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1809 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1811 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1814 let Uses = [CL] in {
1815 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1816 "shr{b}\t{%cl, $dst|$dst, CL}",
1817 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1818 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1819 "shr{w}\t{%cl, $dst|$dst, CL}",
1820 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1821 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1822 "shr{l}\t{%cl, $dst|$dst, CL}",
1823 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1826 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1827 "shr{b}\t{$src2, $dst|$dst, $src2}",
1828 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1829 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1830 "shr{w}\t{$src2, $dst|$dst, $src2}",
1831 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1832 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1833 "shr{l}\t{$src2, $dst|$dst, $src2}",
1834 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1837 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1839 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1840 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1842 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1843 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1845 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1847 let isTwoAddress = 0 in {
1848 let Uses = [CL] in {
1849 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1850 "shr{b}\t{%cl, $dst|$dst, CL}",
1851 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1852 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1853 "shr{w}\t{%cl, $dst|$dst, CL}",
1854 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1856 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1857 "shr{l}\t{%cl, $dst|$dst, CL}",
1858 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1860 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1861 "shr{b}\t{$src, $dst|$dst, $src}",
1862 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1863 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1864 "shr{w}\t{$src, $dst|$dst, $src}",
1865 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1867 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1868 "shr{l}\t{$src, $dst|$dst, $src}",
1869 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1872 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1874 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1875 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1877 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1878 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1880 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1883 let Uses = [CL] in {
1884 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1885 "sar{b}\t{%cl, $dst|$dst, CL}",
1886 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1887 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1888 "sar{w}\t{%cl, $dst|$dst, CL}",
1889 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1890 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1891 "sar{l}\t{%cl, $dst|$dst, CL}",
1892 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1895 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1896 "sar{b}\t{$src2, $dst|$dst, $src2}",
1897 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1898 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1899 "sar{w}\t{$src2, $dst|$dst, $src2}",
1900 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1902 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1903 "sar{l}\t{$src2, $dst|$dst, $src2}",
1904 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1907 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1909 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1910 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1912 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1913 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1915 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1917 let isTwoAddress = 0 in {
1918 let Uses = [CL] in {
1919 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1920 "sar{b}\t{%cl, $dst|$dst, CL}",
1921 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1922 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1923 "sar{w}\t{%cl, $dst|$dst, CL}",
1924 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1925 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1926 "sar{l}\t{%cl, $dst|$dst, CL}",
1927 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1929 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1930 "sar{b}\t{$src, $dst|$dst, $src}",
1931 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1932 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1933 "sar{w}\t{$src, $dst|$dst, $src}",
1934 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1936 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1937 "sar{l}\t{$src, $dst|$dst, $src}",
1938 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1941 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1943 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1944 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1946 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1948 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1950 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1953 // Rotate instructions
1954 // FIXME: provide shorter instructions when imm8 == 1
1955 let Uses = [CL] in {
1956 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1957 "rol{b}\t{%cl, $dst|$dst, CL}",
1958 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1959 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1960 "rol{w}\t{%cl, $dst|$dst, CL}",
1961 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1962 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1963 "rol{l}\t{%cl, $dst|$dst, CL}",
1964 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1967 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1968 "rol{b}\t{$src2, $dst|$dst, $src2}",
1969 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1970 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1971 "rol{w}\t{$src2, $dst|$dst, $src2}",
1972 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1973 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1974 "rol{l}\t{$src2, $dst|$dst, $src2}",
1975 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1978 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1980 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1981 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1983 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1984 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1986 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1988 let isTwoAddress = 0 in {
1989 let Uses = [CL] in {
1990 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1991 "rol{b}\t{%cl, $dst|$dst, CL}",
1992 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
1993 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1994 "rol{w}\t{%cl, $dst|$dst, CL}",
1995 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1996 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1997 "rol{l}\t{%cl, $dst|$dst, CL}",
1998 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2000 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2001 "rol{b}\t{$src, $dst|$dst, $src}",
2002 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2003 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2004 "rol{w}\t{$src, $dst|$dst, $src}",
2005 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2007 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2008 "rol{l}\t{$src, $dst|$dst, $src}",
2009 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2012 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2014 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2015 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2017 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2019 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2021 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2024 let Uses = [CL] in {
2025 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2026 "ror{b}\t{%cl, $dst|$dst, CL}",
2027 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2028 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2029 "ror{w}\t{%cl, $dst|$dst, CL}",
2030 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2031 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2032 "ror{l}\t{%cl, $dst|$dst, CL}",
2033 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2036 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2037 "ror{b}\t{$src2, $dst|$dst, $src2}",
2038 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2039 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2040 "ror{w}\t{$src2, $dst|$dst, $src2}",
2041 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2042 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2043 "ror{l}\t{$src2, $dst|$dst, $src2}",
2044 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2047 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2049 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2050 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2052 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2053 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2055 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2057 let isTwoAddress = 0 in {
2058 let Uses = [CL] in {
2059 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2060 "ror{b}\t{%cl, $dst|$dst, CL}",
2061 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2062 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2063 "ror{w}\t{%cl, $dst|$dst, CL}",
2064 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2065 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2066 "ror{l}\t{%cl, $dst|$dst, CL}",
2067 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2069 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2070 "ror{b}\t{$src, $dst|$dst, $src}",
2071 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2072 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2073 "ror{w}\t{$src, $dst|$dst, $src}",
2074 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2076 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2077 "ror{l}\t{$src, $dst|$dst, $src}",
2078 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2081 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2083 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2084 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2086 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2088 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2090 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2095 // Double shift instructions (generalizations of rotate)
2096 let Uses = [CL] in {
2097 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2098 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2099 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2100 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2101 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2102 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2103 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2104 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2105 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2107 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2108 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2109 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2113 let isCommutable = 1 in { // These instructions commute to each other.
2114 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2115 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2116 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2117 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2120 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2121 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2122 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2123 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2126 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2127 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2128 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2129 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2132 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2133 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2134 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2135 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2140 let isTwoAddress = 0 in {
2141 let Uses = [CL] in {
2142 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2143 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2144 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2146 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2147 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2148 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2151 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2152 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2153 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2154 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2155 (i8 imm:$src3)), addr:$dst)]>,
2157 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2158 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2159 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2160 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2161 (i8 imm:$src3)), addr:$dst)]>,
2164 let Uses = [CL] in {
2165 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2166 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2167 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2168 addr:$dst)]>, TB, OpSize;
2169 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2170 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2171 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2172 addr:$dst)]>, TB, OpSize;
2174 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2175 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2176 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2177 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2178 (i8 imm:$src3)), addr:$dst)]>,
2180 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2181 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2182 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2183 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2184 (i8 imm:$src3)), addr:$dst)]>,
2187 } // Defs = [EFLAGS]
2191 let Defs = [EFLAGS] in {
2192 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2193 // Register-Register Addition
2194 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2195 (ins GR8 :$src1, GR8 :$src2),
2196 "add{b}\t{$src2, $dst|$dst, $src2}",
2197 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2198 (implicit EFLAGS)]>;
2200 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2201 // Register-Register Addition
2202 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2203 (ins GR16:$src1, GR16:$src2),
2204 "add{w}\t{$src2, $dst|$dst, $src2}",
2205 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2206 (implicit EFLAGS)]>, OpSize;
2207 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2208 (ins GR32:$src1, GR32:$src2),
2209 "add{l}\t{$src2, $dst|$dst, $src2}",
2210 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2211 (implicit EFLAGS)]>;
2212 } // end isConvertibleToThreeAddress
2213 } // end isCommutable
2215 // Register-Memory Addition
2216 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2217 (ins GR8 :$src1, i8mem :$src2),
2218 "add{b}\t{$src2, $dst|$dst, $src2}",
2219 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2220 (implicit EFLAGS)]>;
2221 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2222 (ins GR16:$src1, i16mem:$src2),
2223 "add{w}\t{$src2, $dst|$dst, $src2}",
2224 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2225 (implicit EFLAGS)]>, OpSize;
2226 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2227 (ins GR32:$src1, i32mem:$src2),
2228 "add{l}\t{$src2, $dst|$dst, $src2}",
2229 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2230 (implicit EFLAGS)]>;
2232 // Register-Integer Addition
2233 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2234 "add{b}\t{$src2, $dst|$dst, $src2}",
2235 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2236 (implicit EFLAGS)]>;
2238 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2239 // Register-Integer Addition
2240 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2241 (ins GR16:$src1, i16imm:$src2),
2242 "add{w}\t{$src2, $dst|$dst, $src2}",
2243 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2244 (implicit EFLAGS)]>, OpSize;
2245 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2246 (ins GR32:$src1, i32imm:$src2),
2247 "add{l}\t{$src2, $dst|$dst, $src2}",
2248 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2249 (implicit EFLAGS)]>;
2250 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2251 (ins GR16:$src1, i16i8imm:$src2),
2252 "add{w}\t{$src2, $dst|$dst, $src2}",
2253 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2254 (implicit EFLAGS)]>, OpSize;
2255 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2256 (ins GR32:$src1, i32i8imm:$src2),
2257 "add{l}\t{$src2, $dst|$dst, $src2}",
2258 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2259 (implicit EFLAGS)]>;
2262 let isTwoAddress = 0 in {
2263 // Memory-Register Addition
2264 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2265 "add{b}\t{$src2, $dst|$dst, $src2}",
2266 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2267 (implicit EFLAGS)]>;
2268 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2269 "add{w}\t{$src2, $dst|$dst, $src2}",
2270 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2271 (implicit EFLAGS)]>, OpSize;
2272 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2273 "add{l}\t{$src2, $dst|$dst, $src2}",
2274 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2275 (implicit EFLAGS)]>;
2276 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2277 "add{b}\t{$src2, $dst|$dst, $src2}",
2278 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2279 (implicit EFLAGS)]>;
2280 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2281 "add{w}\t{$src2, $dst|$dst, $src2}",
2282 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2283 (implicit EFLAGS)]>, OpSize;
2284 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2285 "add{l}\t{$src2, $dst|$dst, $src2}",
2286 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2287 (implicit EFLAGS)]>;
2288 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2289 "add{w}\t{$src2, $dst|$dst, $src2}",
2290 [(store (add (load addr:$dst), i16immSExt8:$src2),
2292 (implicit EFLAGS)]>, OpSize;
2293 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2294 "add{l}\t{$src2, $dst|$dst, $src2}",
2295 [(store (add (load addr:$dst), i32immSExt8:$src2),
2297 (implicit EFLAGS)]>;
2300 let Uses = [EFLAGS] in {
2301 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2302 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2303 "adc{b}\t{$src2, $dst|$dst, $src2}",
2304 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2305 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2306 (ins GR16:$src1, GR16:$src2),
2307 "adc{w}\t{$src2, $dst|$dst, $src2}",
2308 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2309 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2310 (ins GR32:$src1, GR32:$src2),
2311 "adc{l}\t{$src2, $dst|$dst, $src2}",
2312 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2314 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2315 (ins GR8:$src1, i8mem:$src2),
2316 "adc{b}\t{$src2, $dst|$dst, $src2}",
2317 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2318 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2319 (ins GR16:$src1, i16mem:$src2),
2320 "adc{w}\t{$src2, $dst|$dst, $src2}",
2321 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2323 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2324 (ins GR32:$src1, i32mem:$src2),
2325 "adc{l}\t{$src2, $dst|$dst, $src2}",
2326 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2327 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2328 "adc{b}\t{$src2, $dst|$dst, $src2}",
2329 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2330 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2331 (ins GR16:$src1, i16imm:$src2),
2332 "adc{w}\t{$src2, $dst|$dst, $src2}",
2333 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2334 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2335 (ins GR16:$src1, i16i8imm:$src2),
2336 "adc{w}\t{$src2, $dst|$dst, $src2}",
2337 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2339 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2340 (ins GR32:$src1, i32imm:$src2),
2341 "adc{l}\t{$src2, $dst|$dst, $src2}",
2342 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2343 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2344 (ins GR32:$src1, i32i8imm:$src2),
2345 "adc{l}\t{$src2, $dst|$dst, $src2}",
2346 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2348 let isTwoAddress = 0 in {
2349 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2350 "adc{b}\t{$src2, $dst|$dst, $src2}",
2351 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2352 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2353 "adc{w}\t{$src2, $dst|$dst, $src2}",
2354 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2356 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2357 "adc{l}\t{$src2, $dst|$dst, $src2}",
2358 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2359 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2360 "adc{b}\t{$src2, $dst|$dst, $src2}",
2361 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2362 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2363 "adc{w}\t{$src2, $dst|$dst, $src2}",
2364 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2366 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2367 "adc{w}\t{$src2, $dst|$dst, $src2}",
2368 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2370 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2371 "adc{l}\t{$src2, $dst|$dst, $src2}",
2372 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2373 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2374 "adc{l}\t{$src2, $dst|$dst, $src2}",
2375 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2377 } // Uses = [EFLAGS]
2379 // Register-Register Subtraction
2380 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2381 "sub{b}\t{$src2, $dst|$dst, $src2}",
2382 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2383 (implicit EFLAGS)]>;
2384 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2385 "sub{w}\t{$src2, $dst|$dst, $src2}",
2386 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2387 (implicit EFLAGS)]>, OpSize;
2388 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2389 "sub{l}\t{$src2, $dst|$dst, $src2}",
2390 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2391 (implicit EFLAGS)]>;
2393 // Register-Memory Subtraction
2394 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2395 (ins GR8 :$src1, i8mem :$src2),
2396 "sub{b}\t{$src2, $dst|$dst, $src2}",
2397 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2398 (implicit EFLAGS)]>;
2399 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2400 (ins GR16:$src1, i16mem:$src2),
2401 "sub{w}\t{$src2, $dst|$dst, $src2}",
2402 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2403 (implicit EFLAGS)]>, OpSize;
2404 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2405 (ins GR32:$src1, i32mem:$src2),
2406 "sub{l}\t{$src2, $dst|$dst, $src2}",
2407 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2408 (implicit EFLAGS)]>;
2410 // Register-Integer Subtraction
2411 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2412 (ins GR8:$src1, i8imm:$src2),
2413 "sub{b}\t{$src2, $dst|$dst, $src2}",
2414 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2415 (implicit EFLAGS)]>;
2416 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2417 (ins GR16:$src1, i16imm:$src2),
2418 "sub{w}\t{$src2, $dst|$dst, $src2}",
2419 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2420 (implicit EFLAGS)]>, OpSize;
2421 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2422 (ins GR32:$src1, i32imm:$src2),
2423 "sub{l}\t{$src2, $dst|$dst, $src2}",
2424 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2425 (implicit EFLAGS)]>;
2426 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2427 (ins GR16:$src1, i16i8imm:$src2),
2428 "sub{w}\t{$src2, $dst|$dst, $src2}",
2429 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2430 (implicit EFLAGS)]>, OpSize;
2431 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2432 (ins GR32:$src1, i32i8imm:$src2),
2433 "sub{l}\t{$src2, $dst|$dst, $src2}",
2434 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2435 (implicit EFLAGS)]>;
2437 let isTwoAddress = 0 in {
2438 // Memory-Register Subtraction
2439 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2440 "sub{b}\t{$src2, $dst|$dst, $src2}",
2441 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2442 (implicit EFLAGS)]>;
2443 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2444 "sub{w}\t{$src2, $dst|$dst, $src2}",
2445 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2446 (implicit EFLAGS)]>, OpSize;
2447 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2448 "sub{l}\t{$src2, $dst|$dst, $src2}",
2449 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2450 (implicit EFLAGS)]>;
2452 // Memory-Integer Subtraction
2453 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2454 "sub{b}\t{$src2, $dst|$dst, $src2}",
2455 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2456 (implicit EFLAGS)]>;
2457 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2458 "sub{w}\t{$src2, $dst|$dst, $src2}",
2459 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2460 (implicit EFLAGS)]>, OpSize;
2461 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2462 "sub{l}\t{$src2, $dst|$dst, $src2}",
2463 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2464 (implicit EFLAGS)]>;
2465 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2466 "sub{w}\t{$src2, $dst|$dst, $src2}",
2467 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2469 (implicit EFLAGS)]>, OpSize;
2470 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2471 "sub{l}\t{$src2, $dst|$dst, $src2}",
2472 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2474 (implicit EFLAGS)]>;
2477 let Uses = [EFLAGS] in {
2478 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2479 (ins GR8:$src1, GR8:$src2),
2480 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2481 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2482 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2483 (ins GR16:$src1, GR16:$src2),
2484 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2485 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2486 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2487 (ins GR32:$src1, GR32:$src2),
2488 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2489 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2491 let isTwoAddress = 0 in {
2492 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2493 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2494 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2495 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2496 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2497 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2499 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2500 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2501 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2502 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2503 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2504 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2505 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2506 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2507 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2509 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2510 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2511 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2513 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2514 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2515 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2516 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2517 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2518 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2520 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2521 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2522 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2523 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2524 (ins GR16:$src1, i16mem:$src2),
2525 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2526 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2528 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2529 (ins GR32:$src1, i32mem:$src2),
2530 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2531 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2532 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2533 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2534 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2535 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2536 (ins GR16:$src1, i16imm:$src2),
2537 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2538 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2539 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2540 (ins GR16:$src1, i16i8imm:$src2),
2541 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2542 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2544 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2545 (ins GR32:$src1, i32imm:$src2),
2546 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2547 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2548 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2549 (ins GR32:$src1, i32i8imm:$src2),
2550 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2551 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2552 } // Uses = [EFLAGS]
2553 } // Defs = [EFLAGS]
2555 let Defs = [EFLAGS] in {
2556 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2557 // Register-Register Signed Integer Multiply
2558 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2559 "imul{w}\t{$src2, $dst|$dst, $src2}",
2560 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2561 (implicit EFLAGS)]>, TB, OpSize;
2562 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2563 "imul{l}\t{$src2, $dst|$dst, $src2}",
2564 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2565 (implicit EFLAGS)]>, TB;
2568 // Register-Memory Signed Integer Multiply
2569 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2570 (ins GR16:$src1, i16mem:$src2),
2571 "imul{w}\t{$src2, $dst|$dst, $src2}",
2572 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2573 (implicit EFLAGS)]>, TB, OpSize;
2574 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2575 "imul{l}\t{$src2, $dst|$dst, $src2}",
2576 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2577 (implicit EFLAGS)]>, TB;
2578 } // Defs = [EFLAGS]
2579 } // end Two Address instructions
2581 // Suprisingly enough, these are not two address instructions!
2582 let Defs = [EFLAGS] in {
2583 // Register-Integer Signed Integer Multiply
2584 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2585 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2586 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2587 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2588 (implicit EFLAGS)]>, OpSize;
2589 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2590 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2591 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2592 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2593 (implicit EFLAGS)]>;
2594 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2595 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2596 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2597 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2598 (implicit EFLAGS)]>, OpSize;
2599 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2600 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2601 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2602 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2603 (implicit EFLAGS)]>;
2605 // Memory-Integer Signed Integer Multiply
2606 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2607 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2608 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2609 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2610 (implicit EFLAGS)]>, OpSize;
2611 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2612 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2613 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2614 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2615 (implicit EFLAGS)]>;
2616 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2617 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2618 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2619 [(set GR16:$dst, (mul (load addr:$src1),
2620 i16immSExt8:$src2)),
2621 (implicit EFLAGS)]>, OpSize;
2622 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2623 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2624 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2625 [(set GR32:$dst, (mul (load addr:$src1),
2626 i32immSExt8:$src2)),
2627 (implicit EFLAGS)]>;
2628 } // Defs = [EFLAGS]
2630 //===----------------------------------------------------------------------===//
2631 // Test instructions are just like AND, except they don't generate a result.
2633 let Defs = [EFLAGS] in {
2634 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2635 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2636 "test{b}\t{$src2, $src1|$src1, $src2}",
2637 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2638 (implicit EFLAGS)]>;
2639 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2640 "test{w}\t{$src2, $src1|$src1, $src2}",
2641 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2642 (implicit EFLAGS)]>,
2644 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2645 "test{l}\t{$src2, $src1|$src1, $src2}",
2646 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2647 (implicit EFLAGS)]>;
2650 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2651 "test{b}\t{$src2, $src1|$src1, $src2}",
2652 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2653 (implicit EFLAGS)]>;
2654 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2655 "test{w}\t{$src2, $src1|$src1, $src2}",
2656 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2657 (implicit EFLAGS)]>, OpSize;
2658 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2659 "test{l}\t{$src2, $src1|$src1, $src2}",
2660 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2661 (implicit EFLAGS)]>;
2663 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2664 (outs), (ins GR8:$src1, i8imm:$src2),
2665 "test{b}\t{$src2, $src1|$src1, $src2}",
2666 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2667 (implicit EFLAGS)]>;
2668 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2669 (outs), (ins GR16:$src1, i16imm:$src2),
2670 "test{w}\t{$src2, $src1|$src1, $src2}",
2671 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2672 (implicit EFLAGS)]>, OpSize;
2673 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2674 (outs), (ins GR32:$src1, i32imm:$src2),
2675 "test{l}\t{$src2, $src1|$src1, $src2}",
2676 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2677 (implicit EFLAGS)]>;
2679 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2680 (outs), (ins i8mem:$src1, i8imm:$src2),
2681 "test{b}\t{$src2, $src1|$src1, $src2}",
2682 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2683 (implicit EFLAGS)]>;
2684 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2685 (outs), (ins i16mem:$src1, i16imm:$src2),
2686 "test{w}\t{$src2, $src1|$src1, $src2}",
2687 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2688 (implicit EFLAGS)]>, OpSize;
2689 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2690 (outs), (ins i32mem:$src1, i32imm:$src2),
2691 "test{l}\t{$src2, $src1|$src1, $src2}",
2692 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2693 (implicit EFLAGS)]>;
2694 } // Defs = [EFLAGS]
2697 // Condition code ops, incl. set if equal/not equal/...
2698 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2699 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2700 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2701 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2703 let Uses = [EFLAGS] in {
2704 def SETEr : I<0x94, MRM0r,
2705 (outs GR8 :$dst), (ins),
2707 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2709 def SETEm : I<0x94, MRM0m,
2710 (outs), (ins i8mem:$dst),
2712 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2715 def SETNEr : I<0x95, MRM0r,
2716 (outs GR8 :$dst), (ins),
2718 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2720 def SETNEm : I<0x95, MRM0m,
2721 (outs), (ins i8mem:$dst),
2723 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2726 def SETLr : I<0x9C, MRM0r,
2727 (outs GR8 :$dst), (ins),
2729 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2730 TB; // GR8 = < signed
2731 def SETLm : I<0x9C, MRM0m,
2732 (outs), (ins i8mem:$dst),
2734 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2735 TB; // [mem8] = < signed
2737 def SETGEr : I<0x9D, MRM0r,
2738 (outs GR8 :$dst), (ins),
2740 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2741 TB; // GR8 = >= signed
2742 def SETGEm : I<0x9D, MRM0m,
2743 (outs), (ins i8mem:$dst),
2745 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2746 TB; // [mem8] = >= signed
2748 def SETLEr : I<0x9E, MRM0r,
2749 (outs GR8 :$dst), (ins),
2751 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2752 TB; // GR8 = <= signed
2753 def SETLEm : I<0x9E, MRM0m,
2754 (outs), (ins i8mem:$dst),
2756 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2757 TB; // [mem8] = <= signed
2759 def SETGr : I<0x9F, MRM0r,
2760 (outs GR8 :$dst), (ins),
2762 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2763 TB; // GR8 = > signed
2764 def SETGm : I<0x9F, MRM0m,
2765 (outs), (ins i8mem:$dst),
2767 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2768 TB; // [mem8] = > signed
2770 def SETBr : I<0x92, MRM0r,
2771 (outs GR8 :$dst), (ins),
2773 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2774 TB; // GR8 = < unsign
2775 def SETBm : I<0x92, MRM0m,
2776 (outs), (ins i8mem:$dst),
2778 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2779 TB; // [mem8] = < unsign
2781 def SETAEr : I<0x93, MRM0r,
2782 (outs GR8 :$dst), (ins),
2784 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2785 TB; // GR8 = >= unsign
2786 def SETAEm : I<0x93, MRM0m,
2787 (outs), (ins i8mem:$dst),
2789 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2790 TB; // [mem8] = >= unsign
2792 def SETBEr : I<0x96, MRM0r,
2793 (outs GR8 :$dst), (ins),
2795 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2796 TB; // GR8 = <= unsign
2797 def SETBEm : I<0x96, MRM0m,
2798 (outs), (ins i8mem:$dst),
2800 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2801 TB; // [mem8] = <= unsign
2803 def SETAr : I<0x97, MRM0r,
2804 (outs GR8 :$dst), (ins),
2806 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2807 TB; // GR8 = > signed
2808 def SETAm : I<0x97, MRM0m,
2809 (outs), (ins i8mem:$dst),
2811 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2812 TB; // [mem8] = > signed
2814 def SETSr : I<0x98, MRM0r,
2815 (outs GR8 :$dst), (ins),
2817 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2818 TB; // GR8 = <sign bit>
2819 def SETSm : I<0x98, MRM0m,
2820 (outs), (ins i8mem:$dst),
2822 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2823 TB; // [mem8] = <sign bit>
2824 def SETNSr : I<0x99, MRM0r,
2825 (outs GR8 :$dst), (ins),
2827 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2828 TB; // GR8 = !<sign bit>
2829 def SETNSm : I<0x99, MRM0m,
2830 (outs), (ins i8mem:$dst),
2832 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2833 TB; // [mem8] = !<sign bit>
2835 def SETPr : I<0x9A, MRM0r,
2836 (outs GR8 :$dst), (ins),
2838 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2840 def SETPm : I<0x9A, MRM0m,
2841 (outs), (ins i8mem:$dst),
2843 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2844 TB; // [mem8] = parity
2845 def SETNPr : I<0x9B, MRM0r,
2846 (outs GR8 :$dst), (ins),
2848 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2849 TB; // GR8 = not parity
2850 def SETNPm : I<0x9B, MRM0m,
2851 (outs), (ins i8mem:$dst),
2853 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2854 TB; // [mem8] = not parity
2856 def SETOr : I<0x90, MRM0r,
2857 (outs GR8 :$dst), (ins),
2859 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2860 TB; // GR8 = overflow
2861 def SETOm : I<0x90, MRM0m,
2862 (outs), (ins i8mem:$dst),
2864 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2865 TB; // [mem8] = overflow
2866 def SETNOr : I<0x91, MRM0r,
2867 (outs GR8 :$dst), (ins),
2869 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2870 TB; // GR8 = not overflow
2871 def SETNOm : I<0x91, MRM0m,
2872 (outs), (ins i8mem:$dst),
2874 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2875 TB; // [mem8] = not overflow
2876 } // Uses = [EFLAGS]
2879 // Integer comparisons
2880 let Defs = [EFLAGS] in {
2881 def CMP8rr : I<0x38, MRMDestReg,
2882 (outs), (ins GR8 :$src1, GR8 :$src2),
2883 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2884 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2885 def CMP16rr : I<0x39, MRMDestReg,
2886 (outs), (ins GR16:$src1, GR16:$src2),
2887 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2888 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2889 def CMP32rr : I<0x39, MRMDestReg,
2890 (outs), (ins GR32:$src1, GR32:$src2),
2891 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2892 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2893 def CMP8mr : I<0x38, MRMDestMem,
2894 (outs), (ins i8mem :$src1, GR8 :$src2),
2895 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2896 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2897 (implicit EFLAGS)]>;
2898 def CMP16mr : I<0x39, MRMDestMem,
2899 (outs), (ins i16mem:$src1, GR16:$src2),
2900 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2901 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2902 (implicit EFLAGS)]>, OpSize;
2903 def CMP32mr : I<0x39, MRMDestMem,
2904 (outs), (ins i32mem:$src1, GR32:$src2),
2905 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2906 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2907 (implicit EFLAGS)]>;
2908 def CMP8rm : I<0x3A, MRMSrcMem,
2909 (outs), (ins GR8 :$src1, i8mem :$src2),
2910 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2911 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2912 (implicit EFLAGS)]>;
2913 def CMP16rm : I<0x3B, MRMSrcMem,
2914 (outs), (ins GR16:$src1, i16mem:$src2),
2915 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2916 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2917 (implicit EFLAGS)]>, OpSize;
2918 def CMP32rm : I<0x3B, MRMSrcMem,
2919 (outs), (ins GR32:$src1, i32mem:$src2),
2920 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2921 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2922 (implicit EFLAGS)]>;
2923 def CMP8ri : Ii8<0x80, MRM7r,
2924 (outs), (ins GR8:$src1, i8imm:$src2),
2925 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2926 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
2927 def CMP16ri : Ii16<0x81, MRM7r,
2928 (outs), (ins GR16:$src1, i16imm:$src2),
2929 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2930 [(X86cmp GR16:$src1, imm:$src2),
2931 (implicit EFLAGS)]>, OpSize;
2932 def CMP32ri : Ii32<0x81, MRM7r,
2933 (outs), (ins GR32:$src1, i32imm:$src2),
2934 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2935 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
2936 def CMP8mi : Ii8 <0x80, MRM7m,
2937 (outs), (ins i8mem :$src1, i8imm :$src2),
2938 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2939 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2940 (implicit EFLAGS)]>;
2941 def CMP16mi : Ii16<0x81, MRM7m,
2942 (outs), (ins i16mem:$src1, i16imm:$src2),
2943 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2944 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2945 (implicit EFLAGS)]>, OpSize;
2946 def CMP32mi : Ii32<0x81, MRM7m,
2947 (outs), (ins i32mem:$src1, i32imm:$src2),
2948 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2949 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2950 (implicit EFLAGS)]>;
2951 def CMP16ri8 : Ii8<0x83, MRM7r,
2952 (outs), (ins GR16:$src1, i16i8imm:$src2),
2953 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2954 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2955 (implicit EFLAGS)]>, OpSize;
2956 def CMP16mi8 : Ii8<0x83, MRM7m,
2957 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2958 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2959 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2960 (implicit EFLAGS)]>, OpSize;
2961 def CMP32mi8 : Ii8<0x83, MRM7m,
2962 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2963 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2964 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2965 (implicit EFLAGS)]>;
2966 def CMP32ri8 : Ii8<0x83, MRM7r,
2967 (outs), (ins GR32:$src1, i32i8imm:$src2),
2968 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2969 [(X86cmp GR32:$src1, i32immSExt8:$src2),
2970 (implicit EFLAGS)]>;
2971 } // Defs = [EFLAGS]
2974 // TODO: BTC, BTR, and BTS
2975 let Defs = [EFLAGS] in {
2976 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2977 "bt{w}\t{$src2, $src1|$src1, $src2}",
2978 [(X86bt GR16:$src1, GR16:$src2),
2979 (implicit EFLAGS)]>, OpSize, TB;
2980 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2981 "bt{l}\t{$src2, $src1|$src1, $src2}",
2982 [(X86bt GR32:$src1, GR32:$src2),
2983 (implicit EFLAGS)]>, TB;
2985 // Unlike with the register+register form, the memory+register form of the
2986 // bt instruction does not ignore the high bits of the index. From ISel's
2987 // perspective, this is pretty bizarre. Disable these instructions for now.
2988 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2989 // "bt{w}\t{$src2, $src1|$src1, $src2}",
2990 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
2991 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2992 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2993 // "bt{l}\t{$src2, $src1|$src1, $src2}",
2994 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
2995 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
2997 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2998 "bt{w}\t{$src2, $src1|$src1, $src2}",
2999 [(X86bt GR16:$src1, i16immSExt8:$src2),
3000 (implicit EFLAGS)]>, OpSize, TB;
3001 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3002 "bt{l}\t{$src2, $src1|$src1, $src2}",
3003 [(X86bt GR32:$src1, i32immSExt8:$src2),
3004 (implicit EFLAGS)]>, TB;
3005 // Note that these instructions don't need FastBTMem because that
3006 // only applies when the other operand is in a register. When it's
3007 // an immediate, bt is still fast.
3008 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3009 "bt{w}\t{$src2, $src1|$src1, $src2}",
3010 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3011 (implicit EFLAGS)]>, OpSize, TB;
3012 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3013 "bt{l}\t{$src2, $src1|$src1, $src2}",
3014 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3015 (implicit EFLAGS)]>, TB;
3016 } // Defs = [EFLAGS]
3018 // Sign/Zero extenders
3019 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3020 // of the register here. This has a smaller encoding and avoids a
3021 // partial-register update.
3022 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3023 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3024 [(set GR16:$dst, (sext GR8:$src))]>, TB;
3025 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3026 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3027 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3028 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3029 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3030 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3031 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3032 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3033 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3034 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3035 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3036 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3037 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3038 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3039 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3041 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3042 // of the register here. This has a smaller encoding and avoids a
3043 // partial-register update.
3044 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3045 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3046 [(set GR16:$dst, (zext GR8:$src))]>, TB;
3047 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3048 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3049 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3050 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3051 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3052 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3053 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3054 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3055 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3056 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3057 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3058 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3059 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3060 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3061 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3063 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3064 // except that they use GR32_NOREX for the output operand register class
3065 // instead of GR32. This allows them to operate on h registers on x86-64.
3066 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3067 (outs GR32_NOREX:$dst), (ins GR8:$src),
3068 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3071 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3072 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3073 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3076 let neverHasSideEffects = 1 in {
3077 let Defs = [AX], Uses = [AL] in
3078 def CBW : I<0x98, RawFrm, (outs), (ins),
3079 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3080 let Defs = [EAX], Uses = [AX] in
3081 def CWDE : I<0x98, RawFrm, (outs), (ins),
3082 "{cwtl|cwde}", []>; // EAX = signext(AX)
3084 let Defs = [AX,DX], Uses = [AX] in
3085 def CWD : I<0x99, RawFrm, (outs), (ins),
3086 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3087 let Defs = [EAX,EDX], Uses = [EAX] in
3088 def CDQ : I<0x99, RawFrm, (outs), (ins),
3089 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3092 //===----------------------------------------------------------------------===//
3093 // Alias Instructions
3094 //===----------------------------------------------------------------------===//
3096 // Alias instructions that map movr0 to xor.
3097 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3098 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
3099 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
3100 "xor{b}\t$dst, $dst",
3101 [(set GR8:$dst, 0)]>;
3102 // Use xorl instead of xorw since we don't care about the high 16 bits,
3103 // it's smaller, and it avoids a partial-register update.
3104 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3105 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3106 [(set GR16:$dst, 0)]>;
3107 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3108 "xor{l}\t$dst, $dst",
3109 [(set GR32:$dst, 0)]>;
3112 //===----------------------------------------------------------------------===//
3113 // Thread Local Storage Instructions
3116 // All calls clobber the non-callee saved registers. ESP is marked as
3117 // a use to prevent stack-pointer assignments that appear immediately
3118 // before calls from potentially appearing dead.
3119 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3120 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3121 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3122 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3124 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3125 "leal\t$sym, %eax; "
3126 "call\t___tls_get_addr@PLT",
3127 [(X86tlsaddr tls32addr:$sym)]>,
3128 Requires<[In32BitMode]>;
3130 let AddedComplexity = 5 in
3131 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3132 "movl\t%gs:$src, $dst",
3133 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3135 let AddedComplexity = 5 in
3136 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3137 "movl\t%fs:$src, $dst",
3138 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3140 //===----------------------------------------------------------------------===//
3141 // DWARF Pseudo Instructions
3144 def DWARF_LOC : I<0, Pseudo, (outs),
3145 (ins i32imm:$line, i32imm:$col, i32imm:$file),
3146 ".loc\t$file $line $col",
3147 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3150 //===----------------------------------------------------------------------===//
3151 // EH Pseudo Instructions
3153 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3155 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3156 "ret\t#eh_return, addr: $addr",
3157 [(X86ehret GR32:$addr)]>;
3161 //===----------------------------------------------------------------------===//
3165 // Atomic swap. These are just normal xchg instructions. But since a memory
3166 // operand is referenced, the atomicity is ensured.
3167 let Constraints = "$val = $dst" in {
3168 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3169 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3170 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3171 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3172 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3173 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3175 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3176 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3177 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3180 // Atomic compare and swap.
3181 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3182 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3184 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3185 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3187 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3188 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3191 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3194 let Defs = [AX, EFLAGS], Uses = [AX] in {
3195 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3197 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3198 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3200 let Defs = [AL, EFLAGS], Uses = [AL] in {
3201 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3203 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3204 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3207 // Atomic exchange and add
3208 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3209 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3211 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3212 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3214 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3216 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3217 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3219 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3221 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3222 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3226 // Atomic exchange, and, or, xor
3227 let Constraints = "$val = $dst", Defs = [EFLAGS],
3228 usesCustomDAGSchedInserter = 1 in {
3229 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3230 "#ATOMAND32 PSEUDO!",
3231 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3232 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3233 "#ATOMOR32 PSEUDO!",
3234 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3235 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3236 "#ATOMXOR32 PSEUDO!",
3237 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3238 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3239 "#ATOMNAND32 PSEUDO!",
3240 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3241 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3242 "#ATOMMIN32 PSEUDO!",
3243 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3244 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3245 "#ATOMMAX32 PSEUDO!",
3246 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3247 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3248 "#ATOMUMIN32 PSEUDO!",
3249 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3250 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3251 "#ATOMUMAX32 PSEUDO!",
3252 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3254 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3255 "#ATOMAND16 PSEUDO!",
3256 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3257 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3258 "#ATOMOR16 PSEUDO!",
3259 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3260 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3261 "#ATOMXOR16 PSEUDO!",
3262 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3263 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3264 "#ATOMNAND16 PSEUDO!",
3265 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3266 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3267 "#ATOMMIN16 PSEUDO!",
3268 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3269 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3270 "#ATOMMAX16 PSEUDO!",
3271 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3272 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3273 "#ATOMUMIN16 PSEUDO!",
3274 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3275 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3276 "#ATOMUMAX16 PSEUDO!",
3277 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3279 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3280 "#ATOMAND8 PSEUDO!",
3281 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3282 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3284 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3285 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3286 "#ATOMXOR8 PSEUDO!",
3287 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3288 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3289 "#ATOMNAND8 PSEUDO!",
3290 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3293 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3294 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3295 Uses = [EAX, EBX, ECX, EDX],
3296 mayLoad = 1, mayStore = 1,
3297 usesCustomDAGSchedInserter = 1 in {
3298 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3299 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3300 "#ATOMAND6432 PSEUDO!", []>;
3301 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3302 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3303 "#ATOMOR6432 PSEUDO!", []>;
3304 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3305 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3306 "#ATOMXOR6432 PSEUDO!", []>;
3307 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3308 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3309 "#ATOMNAND6432 PSEUDO!", []>;
3310 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3311 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3312 "#ATOMADD6432 PSEUDO!", []>;
3313 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3314 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3315 "#ATOMSUB6432 PSEUDO!", []>;
3316 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3317 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3318 "#ATOMSWAP6432 PSEUDO!", []>;
3321 //===----------------------------------------------------------------------===//
3322 // Non-Instruction Patterns
3323 //===----------------------------------------------------------------------===//
3325 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3326 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3327 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3328 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3329 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3330 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3332 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3333 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3334 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3335 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3336 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3337 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3338 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3339 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3341 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3342 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3343 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3344 (MOV32mi addr:$dst, texternalsym:$src)>;
3348 def : Pat<(X86tailcall GR32:$dst),
3351 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
3353 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
3356 def : Pat<(X86tcret GR32:$dst, imm:$off),
3357 (TCRETURNri GR32:$dst, imm:$off)>;
3359 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3360 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3362 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3363 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3365 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3366 (CALLpcrel32 tglobaladdr:$dst)>;
3367 def : Pat<(X86call (i32 texternalsym:$dst)),
3368 (CALLpcrel32 texternalsym:$dst)>;
3369 def : Pat<(X86call (i32 imm:$dst)),
3370 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
3372 // X86 specific add which produces a flag.
3373 def : Pat<(addc GR32:$src1, GR32:$src2),
3374 (ADD32rr GR32:$src1, GR32:$src2)>;
3375 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3376 (ADD32rm GR32:$src1, addr:$src2)>;
3377 def : Pat<(addc GR32:$src1, imm:$src2),
3378 (ADD32ri GR32:$src1, imm:$src2)>;
3379 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3380 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3382 def : Pat<(subc GR32:$src1, GR32:$src2),
3383 (SUB32rr GR32:$src1, GR32:$src2)>;
3384 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3385 (SUB32rm GR32:$src1, addr:$src2)>;
3386 def : Pat<(subc GR32:$src1, imm:$src2),
3387 (SUB32ri GR32:$src1, imm:$src2)>;
3388 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3389 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3393 // TEST R,R is smaller than CMP R,0
3394 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3395 (TEST8rr GR8:$src1, GR8:$src1)>;
3396 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3397 (TEST16rr GR16:$src1, GR16:$src1)>;
3398 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3399 (TEST32rr GR32:$src1, GR32:$src1)>;
3401 // Conditional moves with folded loads with operands swapped and conditions
3403 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3404 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3405 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3406 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3407 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3408 (CMOVB16rm GR16:$src2, addr:$src1)>;
3409 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3410 (CMOVB32rm GR32:$src2, addr:$src1)>;
3411 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3412 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3413 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3414 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3415 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3416 (CMOVE16rm GR16:$src2, addr:$src1)>;
3417 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3418 (CMOVE32rm GR32:$src2, addr:$src1)>;
3419 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3420 (CMOVA16rm GR16:$src2, addr:$src1)>;
3421 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3422 (CMOVA32rm GR32:$src2, addr:$src1)>;
3423 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3424 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3425 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3426 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3427 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3428 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3429 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3430 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3431 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3432 (CMOVL16rm GR16:$src2, addr:$src1)>;
3433 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3434 (CMOVL32rm GR32:$src2, addr:$src1)>;
3435 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3436 (CMOVG16rm GR16:$src2, addr:$src1)>;
3437 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3438 (CMOVG32rm GR32:$src2, addr:$src1)>;
3439 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3440 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3441 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3442 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3443 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3444 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3445 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3446 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3447 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3448 (CMOVP16rm GR16:$src2, addr:$src1)>;
3449 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3450 (CMOVP32rm GR32:$src2, addr:$src1)>;
3451 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3452 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3453 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3454 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3455 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3456 (CMOVS16rm GR16:$src2, addr:$src1)>;
3457 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3458 (CMOVS32rm GR32:$src2, addr:$src1)>;
3459 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3460 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3461 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3462 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3463 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3464 (CMOVO16rm GR16:$src2, addr:$src1)>;
3465 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3466 (CMOVO32rm GR32:$src2, addr:$src1)>;
3468 // zextload bool -> zextload byte
3469 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3470 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3471 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3473 // extload bool -> extload byte
3474 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3475 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3476 Requires<[In32BitMode]>;
3477 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3478 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3479 Requires<[In32BitMode]>;
3480 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3481 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3484 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3485 Requires<[In32BitMode]>;
3486 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3487 Requires<[In32BitMode]>;
3488 def : Pat<(i32 (anyext GR16:$src)),
3489 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
3491 // (and (i32 load), 255) -> (zextload i8)
3492 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3493 (MOVZX32rm8 addr:$src)>;
3494 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3495 (MOVZX32rm16 addr:$src)>;
3497 //===----------------------------------------------------------------------===//
3499 //===----------------------------------------------------------------------===//
3501 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3502 // +128 doesn't, so in this special case use a sub instead of an add.
3503 def : Pat<(add GR16:$src1, 128),
3504 (SUB16ri8 GR16:$src1, -128)>;
3505 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3506 (SUB16mi8 addr:$dst, -128)>;
3507 def : Pat<(add GR32:$src1, 128),
3508 (SUB32ri8 GR32:$src1, -128)>;
3509 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3510 (SUB32mi8 addr:$dst, -128)>;
3512 // r & (2^16-1) ==> movz
3513 def : Pat<(and GR32:$src1, 0xffff),
3514 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
3515 // r & (2^8-1) ==> movz
3516 def : Pat<(and GR32:$src1, 0xff),
3517 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
3519 Requires<[In32BitMode]>;
3520 // r & (2^8-1) ==> movz
3521 def : Pat<(and GR16:$src1, 0xff),
3522 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
3524 Requires<[In32BitMode]>;
3526 // sext_inreg patterns
3527 def : Pat<(sext_inreg GR32:$src, i16),
3528 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3529 def : Pat<(sext_inreg GR32:$src, i8),
3530 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3532 Requires<[In32BitMode]>;
3533 def : Pat<(sext_inreg GR16:$src, i8),
3534 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3536 Requires<[In32BitMode]>;
3539 def : Pat<(i16 (trunc GR32:$src)),
3540 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
3541 def : Pat<(i8 (trunc GR32:$src)),
3542 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3544 Requires<[In32BitMode]>;
3545 def : Pat<(i8 (trunc GR16:$src)),
3546 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3548 Requires<[In32BitMode]>;
3550 // h-register tricks
3551 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
3552 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3553 x86_subreg_8bit_hi)>,
3554 Requires<[In32BitMode]>;
3555 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
3556 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3557 x86_subreg_8bit_hi)>,
3558 Requires<[In32BitMode]>;
3559 def : Pat<(srl_su GR16:$src, (i8 8)),
3562 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3563 x86_subreg_8bit_hi)),
3565 Requires<[In32BitMode]>;
3566 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3567 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3568 x86_subreg_8bit_hi))>,
3569 Requires<[In32BitMode]>;
3570 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
3571 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3572 x86_subreg_8bit_hi))>,
3573 Requires<[In32BitMode]>;
3575 // (shl x, 1) ==> (add x, x)
3576 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3577 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3578 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3580 // (shl x (and y, 31)) ==> (shl x, y)
3581 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3582 (SHL8rCL GR8:$src1)>;
3583 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3584 (SHL16rCL GR16:$src1)>;
3585 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3586 (SHL32rCL GR32:$src1)>;
3587 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3588 (SHL8mCL addr:$dst)>;
3589 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3590 (SHL16mCL addr:$dst)>;
3591 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3592 (SHL32mCL addr:$dst)>;
3594 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3595 (SHR8rCL GR8:$src1)>;
3596 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3597 (SHR16rCL GR16:$src1)>;
3598 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3599 (SHR32rCL GR32:$src1)>;
3600 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3601 (SHR8mCL addr:$dst)>;
3602 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3603 (SHR16mCL addr:$dst)>;
3604 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3605 (SHR32mCL addr:$dst)>;
3607 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3608 (SAR8rCL GR8:$src1)>;
3609 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3610 (SAR16rCL GR16:$src1)>;
3611 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3612 (SAR32rCL GR32:$src1)>;
3613 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3614 (SAR8mCL addr:$dst)>;
3615 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3616 (SAR16mCL addr:$dst)>;
3617 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3618 (SAR32mCL addr:$dst)>;
3620 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3621 def : Pat<(or (srl GR32:$src1, CL:$amt),
3622 (shl GR32:$src2, (sub 32, CL:$amt))),
3623 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3625 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3626 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3627 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3629 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3630 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3631 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3633 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3634 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3636 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3638 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3639 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3641 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3642 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3643 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3645 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3646 def : Pat<(or (shl GR32:$src1, CL:$amt),
3647 (srl GR32:$src2, (sub 32, CL:$amt))),
3648 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3650 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3651 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3652 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3654 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3655 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3656 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3658 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3659 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3661 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3663 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3664 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3666 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3667 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3668 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3670 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3671 def : Pat<(or (srl GR16:$src1, CL:$amt),
3672 (shl GR16:$src2, (sub 16, CL:$amt))),
3673 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3675 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3676 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3677 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3679 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3680 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3681 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3683 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3684 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3686 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3688 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3689 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3691 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3692 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3693 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3695 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3696 def : Pat<(or (shl GR16:$src1, CL:$amt),
3697 (srl GR16:$src2, (sub 16, CL:$amt))),
3698 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3700 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3701 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3702 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3704 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3705 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3706 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3708 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3709 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3711 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3713 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3714 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3716 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3717 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3718 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3720 //===----------------------------------------------------------------------===//
3721 // EFLAGS-defining Patterns
3722 //===----------------------------------------------------------------------===//
3724 // Register-Register Addition with EFLAGS result
3725 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
3727 (ADD8rr GR8:$src1, GR8:$src2)>;
3728 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
3730 (ADD16rr GR16:$src1, GR16:$src2)>;
3731 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
3733 (ADD32rr GR32:$src1, GR32:$src2)>;
3735 // Register-Memory Addition with EFLAGS result
3736 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
3738 (ADD8rm GR8:$src1, addr:$src2)>;
3739 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
3741 (ADD16rm GR16:$src1, addr:$src2)>;
3742 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
3744 (ADD32rm GR32:$src1, addr:$src2)>;
3746 // Register-Integer Addition with EFLAGS result
3747 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
3749 (ADD8ri GR8:$src1, imm:$src2)>;
3750 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
3752 (ADD16ri GR16:$src1, imm:$src2)>;
3753 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
3755 (ADD32ri GR32:$src1, imm:$src2)>;
3756 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
3758 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3759 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
3761 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3763 // Memory-Register Addition with EFLAGS result
3764 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
3767 (ADD8mr addr:$dst, GR8:$src2)>;
3768 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
3771 (ADD16mr addr:$dst, GR16:$src2)>;
3772 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
3775 (ADD32mr addr:$dst, GR32:$src2)>;
3777 // Memory-Integer Addition with EFLAGS result
3778 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
3781 (ADD8mi addr:$dst, imm:$src2)>;
3782 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
3785 (ADD16mi addr:$dst, imm:$src2)>;
3786 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
3789 (ADD32mi addr:$dst, imm:$src2)>;
3790 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3793 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3794 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3797 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3799 // Register-Register Subtraction with EFLAGS result
3800 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
3802 (SUB8rr GR8:$src1, GR8:$src2)>;
3803 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
3805 (SUB16rr GR16:$src1, GR16:$src2)>;
3806 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
3808 (SUB32rr GR32:$src1, GR32:$src2)>;
3810 // Register-Memory Subtraction with EFLAGS result
3811 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
3813 (SUB8rm GR8:$src1, addr:$src2)>;
3814 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
3816 (SUB16rm GR16:$src1, addr:$src2)>;
3817 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
3819 (SUB32rm GR32:$src1, addr:$src2)>;
3821 // Register-Integer Subtraction with EFLAGS result
3822 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
3824 (SUB8ri GR8:$src1, imm:$src2)>;
3825 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
3827 (SUB16ri GR16:$src1, imm:$src2)>;
3828 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
3830 (SUB32ri GR32:$src1, imm:$src2)>;
3831 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
3833 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3834 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
3836 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3838 // Memory-Register Subtraction with EFLAGS result
3839 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
3842 (SUB8mr addr:$dst, GR8:$src2)>;
3843 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
3846 (SUB16mr addr:$dst, GR16:$src2)>;
3847 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
3850 (SUB32mr addr:$dst, GR32:$src2)>;
3852 // Memory-Integer Subtraction with EFLAGS result
3853 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
3856 (SUB8mi addr:$dst, imm:$src2)>;
3857 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
3860 (SUB16mi addr:$dst, imm:$src2)>;
3861 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
3864 (SUB32mi addr:$dst, imm:$src2)>;
3865 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3868 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3869 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3872 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3875 // Register-Register Signed Integer Multiply with EFLAGS result
3876 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
3878 (IMUL16rr GR16:$src1, GR16:$src2)>;
3879 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
3881 (IMUL32rr GR32:$src1, GR32:$src2)>;
3883 // Register-Memory Signed Integer Multiply with EFLAGS result
3884 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
3886 (IMUL16rm GR16:$src1, addr:$src2)>;
3887 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
3889 (IMUL32rm GR32:$src1, addr:$src2)>;
3891 // Register-Integer Signed Integer Multiply with EFLAGS result
3892 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
3894 (IMUL16rri GR16:$src1, imm:$src2)>;
3895 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
3897 (IMUL32rri GR32:$src1, imm:$src2)>;
3898 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
3900 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
3901 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
3903 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3905 // Memory-Integer Signed Integer Multiply with EFLAGS result
3906 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
3908 (IMUL16rmi addr:$src1, imm:$src2)>;
3909 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
3911 (IMUL32rmi addr:$src1, imm:$src2)>;
3912 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
3914 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
3915 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
3917 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3919 // Optimize multiply by 2 with EFLAGS result.
3920 let AddedComplexity = 2 in {
3921 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
3923 (ADD16rr GR16:$src1, GR16:$src1)>;
3925 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
3927 (ADD32rr GR32:$src1, GR32:$src1)>;
3930 // INC and DEC with EFLAGS result. Note that these do not set CF.
3931 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3933 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3936 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3938 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3942 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
3943 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
3944 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3946 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
3947 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
3948 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
3949 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3951 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
3953 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
3954 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
3955 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3957 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
3958 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
3959 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
3960 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3962 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
3964 //===----------------------------------------------------------------------===//
3965 // Floating Point Stack Support
3966 //===----------------------------------------------------------------------===//
3968 include "X86InstrFPStack.td"
3970 //===----------------------------------------------------------------------===//
3972 //===----------------------------------------------------------------------===//
3974 include "X86Instr64bit.td"
3976 //===----------------------------------------------------------------------===//
3977 // XMM Floating point support (requires SSE / SSE2)
3978 //===----------------------------------------------------------------------===//
3980 include "X86InstrSSE.td"
3982 //===----------------------------------------------------------------------===//
3983 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3984 //===----------------------------------------------------------------------===//
3986 include "X86InstrMMX.td"