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 SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
63 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
65 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
67 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
69 def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
71 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
73 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
75 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
77 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
78 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
79 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
80 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
82 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
84 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
86 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
87 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
89 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
91 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
94 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
95 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
97 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
112 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
115 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
116 [SDNPHasChain, SDNPMayStore,
117 SDNPMayLoad, SDNPMemOperand]>;
118 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
119 [SDNPHasChain, SDNPOptInFlag]>;
121 def X86vastart_save_xmm_regs :
122 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
123 SDT_X86VASTART_SAVE_XMM_REGS,
126 def X86callseq_start :
127 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
128 [SDNPHasChain, SDNPOutFlag]>;
130 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
131 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
133 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
134 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
136 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
137 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
138 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
139 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
142 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
143 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
145 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
146 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
148 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
149 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
150 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
151 SDT_X86SegmentBaseAddress, []>;
153 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
156 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
157 [SDNPHasChain, SDNPOptInFlag]>;
159 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
160 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
161 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
162 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
163 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
164 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
166 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
168 //===----------------------------------------------------------------------===//
169 // X86 Operand Definitions.
172 def i32imm_pcrel : Operand<i32> {
173 let PrintMethod = "print_pcrel_imm";
176 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
177 // the index operand of an address, to conform to x86 encoding restrictions.
178 def ptr_rc_nosp : PointerLikeRegClass<1>;
180 // *mem - Operand definitions for the funky X86 addressing mode operands.
182 def X86MemAsmOperand : AsmOperandClass {
186 class X86MemOperand<string printMethod> : Operand<iPTR> {
187 let PrintMethod = printMethod;
188 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
189 let ParserMatchClass = X86MemAsmOperand;
192 def opaque32mem : X86MemOperand<"printopaquemem">;
193 def opaque48mem : X86MemOperand<"printopaquemem">;
194 def opaque80mem : X86MemOperand<"printopaquemem">;
196 def i8mem : X86MemOperand<"printi8mem">;
197 def i16mem : X86MemOperand<"printi16mem">;
198 def i32mem : X86MemOperand<"printi32mem">;
199 def i64mem : X86MemOperand<"printi64mem">;
200 def i128mem : X86MemOperand<"printi128mem">;
201 def i256mem : X86MemOperand<"printi256mem">;
202 def f32mem : X86MemOperand<"printf32mem">;
203 def f64mem : X86MemOperand<"printf64mem">;
204 def f80mem : X86MemOperand<"printf80mem">;
205 def f128mem : X86MemOperand<"printf128mem">;
206 def f256mem : X86MemOperand<"printf256mem">;
208 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
209 // plain GR64, so that it doesn't potentially require a REX prefix.
210 def i8mem_NOREX : Operand<i64> {
211 let PrintMethod = "printi8mem";
212 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
213 let ParserMatchClass = X86MemAsmOperand;
216 def lea32mem : Operand<i32> {
217 let PrintMethod = "printlea32mem";
218 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
219 let ParserMatchClass = X86MemAsmOperand;
222 def SSECC : Operand<i8> {
223 let PrintMethod = "printSSECC";
226 def piclabel: Operand<i32> {
227 let PrintMethod = "printPICLabel";
230 def ImmSExt8AsmOperand : AsmOperandClass {
231 let Name = "ImmSExt8";
232 let SuperClass = ImmAsmOperand;
235 // A couple of more descriptive operand definitions.
236 // 16-bits but only 8 bits are significant.
237 def i16i8imm : Operand<i16> {
238 let ParserMatchClass = ImmSExt8AsmOperand;
240 // 32-bits but only 8 bits are significant.
241 def i32i8imm : Operand<i32> {
242 let ParserMatchClass = ImmSExt8AsmOperand;
245 // Branch targets have OtherVT type and print as pc-relative values.
246 def brtarget : Operand<OtherVT> {
247 let PrintMethod = "print_pcrel_imm";
250 def brtarget8 : Operand<OtherVT> {
251 let PrintMethod = "print_pcrel_imm";
254 //===----------------------------------------------------------------------===//
255 // X86 Complex Pattern Definitions.
258 // Define X86 specific addressing mode.
259 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
260 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
261 [add, sub, mul, X86mul_imm, shl, or, frameindex],
263 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
264 [tglobaltlsaddr], []>;
266 //===----------------------------------------------------------------------===//
267 // X86 Instruction Predicate Definitions.
268 def HasMMX : Predicate<"Subtarget->hasMMX()">;
269 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
270 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
271 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
272 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
273 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
274 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
275 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
276 def HasAVX : Predicate<"Subtarget->hasAVX()">;
277 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
278 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
279 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
280 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
281 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
282 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
283 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
284 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
285 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
286 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
287 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
288 "TM.getCodeModel() != CodeModel::Kernel">;
289 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
290 "TM.getCodeModel() == CodeModel::Kernel">;
291 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
292 def OptForSpeed : Predicate<"!OptForSize">;
293 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
294 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
296 //===----------------------------------------------------------------------===//
297 // X86 Instruction Format Definitions.
300 include "X86InstrFormats.td"
302 //===----------------------------------------------------------------------===//
303 // Pattern fragments...
306 // X86 specific condition code. These correspond to CondCode in
307 // X86InstrInfo.h. They must be kept in synch.
308 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
309 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
310 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
311 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
312 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
313 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
314 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
315 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
316 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
317 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
318 def X86_COND_NO : PatLeaf<(i8 10)>;
319 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
320 def X86_COND_NS : PatLeaf<(i8 12)>;
321 def X86_COND_O : PatLeaf<(i8 13)>;
322 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
323 def X86_COND_S : PatLeaf<(i8 15)>;
325 def i16immSExt8 : PatLeaf<(i16 imm), [{
326 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
327 // sign extended field.
328 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
331 def i32immSExt8 : PatLeaf<(i32 imm), [{
332 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
333 // sign extended field.
334 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
337 // Helper fragments for loads.
338 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
339 // known to be 32-bit aligned or better. Ditto for i8 to i16.
340 def loadi16 : PatFrag<(ops node:$ptr), (i16 (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 ISD::LoadExtType ExtType = LD->getExtensionType();
347 if (ExtType == ISD::NON_EXTLOAD)
349 if (ExtType == ISD::EXTLOAD)
350 return LD->getAlignment() >= 2 && !LD->isVolatile();
354 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
355 LoadSDNode *LD = cast<LoadSDNode>(N);
356 if (const Value *Src = LD->getSrcValue())
357 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
358 if (PT->getAddressSpace() > 255)
360 ISD::LoadExtType ExtType = LD->getExtensionType();
361 if (ExtType == ISD::EXTLOAD)
362 return LD->getAlignment() >= 2 && !LD->isVolatile();
366 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
367 LoadSDNode *LD = cast<LoadSDNode>(N);
368 if (const Value *Src = LD->getSrcValue())
369 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
370 if (PT->getAddressSpace() > 255)
372 ISD::LoadExtType ExtType = LD->getExtensionType();
373 if (ExtType == ISD::NON_EXTLOAD)
375 if (ExtType == ISD::EXTLOAD)
376 return LD->getAlignment() >= 4 && !LD->isVolatile();
380 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
381 LoadSDNode *LD = cast<LoadSDNode>(N);
382 if (const Value *Src = LD->getSrcValue())
383 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
384 if (PT->getAddressSpace() > 255)
386 if (LD->isVolatile())
388 ISD::LoadExtType ExtType = LD->getExtensionType();
389 if (ExtType == ISD::NON_EXTLOAD)
391 if (ExtType == ISD::EXTLOAD)
392 return LD->getAlignment() >= 4;
396 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
397 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
398 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
399 return PT->getAddressSpace() == 256;
403 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
404 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
405 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
406 return PT->getAddressSpace() == 257;
410 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
411 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
412 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
413 if (PT->getAddressSpace() > 255)
417 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
418 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
419 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
420 if (PT->getAddressSpace() > 255)
425 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
426 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
427 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
428 if (PT->getAddressSpace() > 255)
432 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
433 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
434 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
435 if (PT->getAddressSpace() > 255)
439 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
440 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
441 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
442 if (PT->getAddressSpace() > 255)
447 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
448 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
449 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
451 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
452 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
453 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
454 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
455 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
456 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
458 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
459 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
460 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
461 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
462 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
463 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
466 // An 'and' node with a single use.
467 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
468 return N->hasOneUse();
470 // An 'srl' node with a single use.
471 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
472 return N->hasOneUse();
474 // An 'trunc' node with a single use.
475 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
476 return N->hasOneUse();
479 // 'shld' and 'shrd' instruction patterns. Note that even though these have
480 // the srl and shl in their patterns, the C++ code must still check for them,
481 // because predicates are tested before children nodes are explored.
483 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
484 (or (srl node:$src1, node:$amt1),
485 (shl node:$src2, node:$amt2)), [{
486 assert(N->getOpcode() == ISD::OR);
487 return N->getOperand(0).getOpcode() == ISD::SRL &&
488 N->getOperand(1).getOpcode() == ISD::SHL &&
489 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
490 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
491 N->getOperand(0).getConstantOperandVal(1) ==
492 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
495 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
496 (or (shl node:$src1, node:$amt1),
497 (srl node:$src2, node:$amt2)), [{
498 assert(N->getOpcode() == ISD::OR);
499 return N->getOperand(0).getOpcode() == ISD::SHL &&
500 N->getOperand(1).getOpcode() == ISD::SRL &&
501 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
502 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
503 N->getOperand(0).getConstantOperandVal(1) ==
504 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
507 //===----------------------------------------------------------------------===//
508 // Instruction list...
511 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
512 // a stack adjustment and the codegen must know that they may modify the stack
513 // pointer before prolog-epilog rewriting occurs.
514 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
515 // sub / add which can clobber EFLAGS.
516 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
517 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
519 [(X86callseq_start timm:$amt)]>,
520 Requires<[In32BitMode]>;
521 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
523 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
524 Requires<[In32BitMode]>;
527 // x86-64 va_start lowering magic.
528 let usesCustomDAGSchedInserter = 1 in
529 def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
532 i64imm:$regsavefi, i64imm:$offset,
534 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
535 [(X86vastart_save_xmm_regs GR8:$al,
540 let neverHasSideEffects = 1 in {
541 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
542 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
543 "nopl\t$zero", []>, TB;
547 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int 3", []>;
548 def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
551 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
552 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
556 //===----------------------------------------------------------------------===//
557 // Control Flow Instructions...
560 // Return instructions.
561 let isTerminator = 1, isReturn = 1, isBarrier = 1,
562 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
563 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
566 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
568 [(X86retflag timm:$amt)]>;
569 def LRET : I <0xCB, RawFrm, (outs), (ins),
571 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
575 // All branches are RawFrm, Void, Branch, and Terminators
576 let isBranch = 1, isTerminator = 1 in
577 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
578 I<opcode, RawFrm, (outs), ins, asm, pattern>;
580 let isBranch = 1, isBarrier = 1 in {
581 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
582 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
586 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
587 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
588 [(brind GR32:$dst)]>;
589 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
590 [(brind (loadi32 addr:$dst))]>;
592 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
593 (ins i16imm:$seg, i16imm:$off),
594 "ljmp{w}\t$seg, $off", []>, OpSize;
595 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
596 (ins i16imm:$seg, i32imm:$off),
597 "ljmp{l}\t$seg, $off", []>;
599 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
600 "ljmp{w}\t{*}$dst", []>, OpSize;
601 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
602 "ljmp{l}\t{*}$dst", []>;
605 // Conditional branches
606 let Uses = [EFLAGS] in {
607 // Short conditional jumps
608 def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
609 def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
610 def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
611 def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
612 def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
613 def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
614 def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
615 def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
616 def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
617 def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
618 def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
619 def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
620 def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
621 def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
622 def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
623 def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
625 def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
627 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
628 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
629 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
630 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
631 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
632 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
633 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
634 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
635 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
636 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
637 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
638 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
640 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
641 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
642 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
643 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
644 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
645 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
646 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
647 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
649 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
650 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
651 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
652 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
653 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
654 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
655 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
656 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
657 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
658 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
659 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
660 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
665 def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
666 def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
667 def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
669 //===----------------------------------------------------------------------===//
670 // Call Instructions...
673 // All calls clobber the non-callee saved registers. ESP is marked as
674 // a use to prevent stack-pointer assignments that appear immediately
675 // before calls from potentially appearing dead. Uses for argument
676 // registers are added manually.
677 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
678 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
679 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
680 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
682 def CALLpcrel32 : Ii32<0xE8, RawFrm,
683 (outs), (ins i32imm_pcrel:$dst,variable_ops),
685 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
686 "call\t{*}$dst", [(X86call GR32:$dst)]>;
687 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
688 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
690 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
691 (ins i16imm:$seg, i16imm:$off),
692 "lcall{w}\t$seg, $off", []>, OpSize;
693 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
694 (ins i16imm:$seg, i32imm:$off),
695 "lcall{l}\t$seg, $off", []>;
697 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
698 "lcall{w}\t{*}$dst", []>, OpSize;
699 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
700 "lcall{l}\t{*}$dst", []>;
703 // Constructing a stack frame.
705 def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
706 "enter\t$len, $lvl", []>;
710 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
711 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
712 "#TC_RETURN $dst $offset",
715 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
716 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
717 "#TC_RETURN $dst $offset",
720 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
722 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
724 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
725 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
727 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
728 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
729 "jmp\t{*}$dst # TAILCALL", []>;
731 //===----------------------------------------------------------------------===//
732 // Miscellaneous Instructions...
734 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
735 def LEAVE : I<0xC9, RawFrm,
736 (outs), (ins), "leave", []>;
738 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
740 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
742 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
743 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
745 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
747 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
748 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
751 let mayStore = 1 in {
752 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
754 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
755 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
757 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
759 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
760 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
764 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
765 def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
766 "push{l}\t$imm", []>;
767 def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
768 "push{l}\t$imm", []>;
769 def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
770 "push{l}\t$imm", []>;
773 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
774 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
775 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
776 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
778 let isTwoAddress = 1 in // GR32 = bswap GR32
779 def BSWAP32r : I<0xC8, AddRegFrm,
780 (outs GR32:$dst), (ins GR32:$src),
782 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
785 // Bit scan instructions.
786 let Defs = [EFLAGS] in {
787 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
788 "bsf{w}\t{$src, $dst|$dst, $src}",
789 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
790 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
791 "bsf{w}\t{$src, $dst|$dst, $src}",
792 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
793 (implicit EFLAGS)]>, TB;
794 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
795 "bsf{l}\t{$src, $dst|$dst, $src}",
796 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
797 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
798 "bsf{l}\t{$src, $dst|$dst, $src}",
799 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
800 (implicit EFLAGS)]>, TB;
802 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
803 "bsr{w}\t{$src, $dst|$dst, $src}",
804 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
805 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
806 "bsr{w}\t{$src, $dst|$dst, $src}",
807 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
808 (implicit EFLAGS)]>, TB;
809 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
810 "bsr{l}\t{$src, $dst|$dst, $src}",
811 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
812 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
813 "bsr{l}\t{$src, $dst|$dst, $src}",
814 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
815 (implicit EFLAGS)]>, TB;
818 let neverHasSideEffects = 1 in
819 def LEA16r : I<0x8D, MRMSrcMem,
820 (outs GR16:$dst), (ins i32mem:$src),
821 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
822 let isReMaterializable = 1 in
823 def LEA32r : I<0x8D, MRMSrcMem,
824 (outs GR32:$dst), (ins lea32mem:$src),
825 "lea{l}\t{$src|$dst}, {$dst|$src}",
826 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
828 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
829 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
830 [(X86rep_movs i8)]>, REP;
831 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
832 [(X86rep_movs i16)]>, REP, OpSize;
833 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
834 [(X86rep_movs i32)]>, REP;
837 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
838 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
839 [(X86rep_stos i8)]>, REP;
840 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
841 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
842 [(X86rep_stos i16)]>, REP, OpSize;
843 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
844 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
845 [(X86rep_stos i32)]>, REP;
847 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
848 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
849 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
851 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
852 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
853 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
855 let Defs = [RAX, RDX] in
856 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
859 let isBarrier = 1, hasCtrlDep = 1 in {
860 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
863 def SYSCALL : I<0x05, RawFrm,
864 (outs), (ins), "syscall", []>, TB;
865 def SYSRET : I<0x07, RawFrm,
866 (outs), (ins), "sysret", []>, TB;
867 def SYSENTER : I<0x34, RawFrm,
868 (outs), (ins), "sysenter", []>, TB;
869 def SYSEXIT : I<0x35, RawFrm,
870 (outs), (ins), "sysexit", []>, TB;
872 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
875 //===----------------------------------------------------------------------===//
876 // Input/Output Instructions...
878 let Defs = [AL], Uses = [DX] in
879 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
880 "in{b}\t{%dx, %al|%AL, %DX}", []>;
881 let Defs = [AX], Uses = [DX] in
882 def IN16rr : I<0xED, RawFrm, (outs), (ins),
883 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
884 let Defs = [EAX], Uses = [DX] in
885 def IN32rr : I<0xED, RawFrm, (outs), (ins),
886 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
889 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
890 "in{b}\t{$port, %al|%AL, $port}", []>;
892 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
893 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
895 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
896 "in{l}\t{$port, %eax|%EAX, $port}", []>;
898 let Uses = [DX, AL] in
899 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
900 "out{b}\t{%al, %dx|%DX, %AL}", []>;
901 let Uses = [DX, AX] in
902 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
903 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
904 let Uses = [DX, EAX] in
905 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
906 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
909 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
910 "out{b}\t{%al, $port|$port, %AL}", []>;
912 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
913 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
915 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
916 "out{l}\t{%eax, $port|$port, %EAX}", []>;
918 //===----------------------------------------------------------------------===//
919 // Move Instructions...
921 let neverHasSideEffects = 1 in {
922 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
923 "mov{b}\t{$src, $dst|$dst, $src}", []>;
924 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
925 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
926 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
927 "mov{l}\t{$src, $dst|$dst, $src}", []>;
929 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
930 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
931 "mov{b}\t{$src, $dst|$dst, $src}",
932 [(set GR8:$dst, imm:$src)]>;
933 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
934 "mov{w}\t{$src, $dst|$dst, $src}",
935 [(set GR16:$dst, imm:$src)]>, OpSize;
936 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
937 "mov{l}\t{$src, $dst|$dst, $src}",
938 [(set GR32:$dst, imm:$src)]>;
940 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
941 "mov{b}\t{$src, $dst|$dst, $src}",
942 [(store (i8 imm:$src), addr:$dst)]>;
943 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
944 "mov{w}\t{$src, $dst|$dst, $src}",
945 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
946 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
947 "mov{l}\t{$src, $dst|$dst, $src}",
948 [(store (i32 imm:$src), addr:$dst)]>;
950 def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins i8imm:$src),
951 "mov{b}\t{$src, %al|%al, $src}", []>;
952 def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins i16imm:$src),
953 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
954 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins i32imm:$src),
955 "mov{l}\t{$src, %eax|%eax, $src}", []>;
957 def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs i8imm:$dst), (ins),
958 "mov{b}\t{%al, $dst|$dst, %al}", []>;
959 def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs i16imm:$dst), (ins),
960 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
961 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs i32imm:$dst), (ins),
962 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
964 // Moves to and from segment registers
965 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
966 "mov{w}\t{$src, $dst|$dst, $src}", []>;
967 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
968 "mov{w}\t{$src, $dst|$dst, $src}", []>;
969 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
970 "mov{w}\t{$src, $dst|$dst, $src}", []>;
971 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
972 "mov{w}\t{$src, $dst|$dst, $src}", []>;
974 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
975 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
976 "mov{b}\t{$src, $dst|$dst, $src}",
977 [(set GR8:$dst, (loadi8 addr:$src))]>;
978 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
979 "mov{w}\t{$src, $dst|$dst, $src}",
980 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
981 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
982 "mov{l}\t{$src, $dst|$dst, $src}",
983 [(set GR32:$dst, (loadi32 addr:$src))]>;
986 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
987 "mov{b}\t{$src, $dst|$dst, $src}",
988 [(store GR8:$src, addr:$dst)]>;
989 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
990 "mov{w}\t{$src, $dst|$dst, $src}",
991 [(store GR16:$src, addr:$dst)]>, OpSize;
992 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
993 "mov{l}\t{$src, $dst|$dst, $src}",
994 [(store GR32:$src, addr:$dst)]>;
996 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
997 // that they can be used for copying and storing h registers, which can't be
998 // encoded when a REX prefix is present.
999 let neverHasSideEffects = 1 in
1000 def MOV8rr_NOREX : I<0x88, MRMDestReg,
1001 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
1002 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1004 def MOV8mr_NOREX : I<0x88, MRMDestMem,
1005 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1006 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1008 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
1009 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1010 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1011 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1013 //===----------------------------------------------------------------------===//
1014 // Fixed-Register Multiplication and Division Instructions...
1017 // Extra precision multiplication
1018 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1019 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
1020 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1021 // This probably ought to be moved to a def : Pat<> if the
1022 // syntax can be accepted.
1023 [(set AL, (mul AL, GR8:$src)),
1024 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1026 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1027 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1029 []>, OpSize; // AX,DX = AX*GR16
1031 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1032 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1034 []>; // EAX,EDX = EAX*GR32
1036 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1037 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1039 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1040 // This probably ought to be moved to a def : Pat<> if the
1041 // syntax can be accepted.
1042 [(set AL, (mul AL, (loadi8 addr:$src))),
1043 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1045 let mayLoad = 1, neverHasSideEffects = 1 in {
1046 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1047 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1049 []>, OpSize; // AX,DX = AX*[mem16]
1051 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1052 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1054 []>; // EAX,EDX = EAX*[mem32]
1057 let neverHasSideEffects = 1 in {
1058 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1059 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1061 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1062 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
1063 OpSize; // AX,DX = AX*GR16
1064 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1065 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1066 // EAX,EDX = EAX*GR32
1067 let mayLoad = 1 in {
1068 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1069 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1070 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
1071 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1072 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1073 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1074 let Defs = [EAX,EDX], Uses = [EAX] in
1075 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1076 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
1078 } // neverHasSideEffects
1080 // unsigned division/remainder
1081 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1082 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1083 "div{b}\t$src", []>;
1084 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1085 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1086 "div{w}\t$src", []>, OpSize;
1087 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1088 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1089 "div{l}\t$src", []>;
1090 let mayLoad = 1 in {
1091 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1092 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1093 "div{b}\t$src", []>;
1094 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1095 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1096 "div{w}\t$src", []>, OpSize;
1097 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1098 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
1099 "div{l}\t$src", []>;
1102 // Signed division/remainder.
1103 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1104 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1105 "idiv{b}\t$src", []>;
1106 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1107 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1108 "idiv{w}\t$src", []>, OpSize;
1109 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1110 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1111 "idiv{l}\t$src", []>;
1112 let mayLoad = 1, mayLoad = 1 in {
1113 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1114 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1115 "idiv{b}\t$src", []>;
1116 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1117 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1118 "idiv{w}\t$src", []>, OpSize;
1119 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1120 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
1121 "idiv{l}\t$src", []>;
1124 //===----------------------------------------------------------------------===//
1125 // Two address Instructions.
1127 let isTwoAddress = 1 in {
1129 // Conditional moves
1130 let Uses = [EFLAGS] in {
1132 // X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1133 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1134 // however that requires promoting the operands, and can induce additional
1135 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1136 // clobber EFLAGS, because if one of the operands is zero, the expansion
1137 // could involve an xor.
1138 let usesCustomDAGSchedInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
1139 def CMOV_GR8 : I<0, Pseudo,
1140 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1141 "#CMOV_GR8 PSEUDO!",
1142 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1143 imm:$cond, EFLAGS))]>;
1145 let isCommutable = 1 in {
1146 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1147 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1148 "cmovb\t{$src2, $dst|$dst, $src2}",
1149 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1150 X86_COND_B, EFLAGS))]>,
1152 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1153 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1154 "cmovb\t{$src2, $dst|$dst, $src2}",
1155 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1156 X86_COND_B, EFLAGS))]>,
1158 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1159 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1160 "cmovae\t{$src2, $dst|$dst, $src2}",
1161 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1162 X86_COND_AE, EFLAGS))]>,
1164 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1165 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1166 "cmovae\t{$src2, $dst|$dst, $src2}",
1167 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1168 X86_COND_AE, EFLAGS))]>,
1170 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1171 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1172 "cmove\t{$src2, $dst|$dst, $src2}",
1173 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1174 X86_COND_E, EFLAGS))]>,
1176 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1177 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1178 "cmove\t{$src2, $dst|$dst, $src2}",
1179 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1180 X86_COND_E, EFLAGS))]>,
1182 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1183 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1184 "cmovne\t{$src2, $dst|$dst, $src2}",
1185 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1186 X86_COND_NE, EFLAGS))]>,
1188 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1189 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1190 "cmovne\t{$src2, $dst|$dst, $src2}",
1191 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1192 X86_COND_NE, EFLAGS))]>,
1194 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1195 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1196 "cmovbe\t{$src2, $dst|$dst, $src2}",
1197 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1198 X86_COND_BE, EFLAGS))]>,
1200 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1201 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1202 "cmovbe\t{$src2, $dst|$dst, $src2}",
1203 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1204 X86_COND_BE, EFLAGS))]>,
1206 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1207 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1208 "cmova\t{$src2, $dst|$dst, $src2}",
1209 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1210 X86_COND_A, EFLAGS))]>,
1212 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1213 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1214 "cmova\t{$src2, $dst|$dst, $src2}",
1215 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1216 X86_COND_A, EFLAGS))]>,
1218 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1219 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1220 "cmovl\t{$src2, $dst|$dst, $src2}",
1221 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1222 X86_COND_L, EFLAGS))]>,
1224 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1225 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1226 "cmovl\t{$src2, $dst|$dst, $src2}",
1227 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1228 X86_COND_L, EFLAGS))]>,
1230 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1231 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1232 "cmovge\t{$src2, $dst|$dst, $src2}",
1233 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1234 X86_COND_GE, EFLAGS))]>,
1236 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1237 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1238 "cmovge\t{$src2, $dst|$dst, $src2}",
1239 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1240 X86_COND_GE, EFLAGS))]>,
1242 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1243 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1244 "cmovle\t{$src2, $dst|$dst, $src2}",
1245 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1246 X86_COND_LE, EFLAGS))]>,
1248 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1249 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1250 "cmovle\t{$src2, $dst|$dst, $src2}",
1251 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1252 X86_COND_LE, EFLAGS))]>,
1254 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1255 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1256 "cmovg\t{$src2, $dst|$dst, $src2}",
1257 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1258 X86_COND_G, EFLAGS))]>,
1260 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1261 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1262 "cmovg\t{$src2, $dst|$dst, $src2}",
1263 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1264 X86_COND_G, EFLAGS))]>,
1266 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1267 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1268 "cmovs\t{$src2, $dst|$dst, $src2}",
1269 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1270 X86_COND_S, EFLAGS))]>,
1272 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1273 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1274 "cmovs\t{$src2, $dst|$dst, $src2}",
1275 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1276 X86_COND_S, EFLAGS))]>,
1278 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1279 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1280 "cmovns\t{$src2, $dst|$dst, $src2}",
1281 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1282 X86_COND_NS, EFLAGS))]>,
1284 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1285 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1286 "cmovns\t{$src2, $dst|$dst, $src2}",
1287 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1288 X86_COND_NS, EFLAGS))]>,
1290 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1291 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1292 "cmovp\t{$src2, $dst|$dst, $src2}",
1293 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1294 X86_COND_P, EFLAGS))]>,
1296 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1297 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1298 "cmovp\t{$src2, $dst|$dst, $src2}",
1299 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1300 X86_COND_P, EFLAGS))]>,
1302 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1303 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1304 "cmovnp\t{$src2, $dst|$dst, $src2}",
1305 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1306 X86_COND_NP, EFLAGS))]>,
1308 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1309 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1310 "cmovnp\t{$src2, $dst|$dst, $src2}",
1311 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1312 X86_COND_NP, EFLAGS))]>,
1314 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1315 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1316 "cmovo\t{$src2, $dst|$dst, $src2}",
1317 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1318 X86_COND_O, EFLAGS))]>,
1320 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1321 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1322 "cmovo\t{$src2, $dst|$dst, $src2}",
1323 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1324 X86_COND_O, EFLAGS))]>,
1326 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1327 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1328 "cmovno\t{$src2, $dst|$dst, $src2}",
1329 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1330 X86_COND_NO, EFLAGS))]>,
1332 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1333 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1334 "cmovno\t{$src2, $dst|$dst, $src2}",
1335 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1336 X86_COND_NO, EFLAGS))]>,
1338 } // isCommutable = 1
1340 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1341 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1342 "cmovb\t{$src2, $dst|$dst, $src2}",
1343 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1344 X86_COND_B, EFLAGS))]>,
1346 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1347 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1348 "cmovb\t{$src2, $dst|$dst, $src2}",
1349 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1350 X86_COND_B, EFLAGS))]>,
1352 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1353 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1354 "cmovae\t{$src2, $dst|$dst, $src2}",
1355 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1356 X86_COND_AE, EFLAGS))]>,
1358 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1359 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1360 "cmovae\t{$src2, $dst|$dst, $src2}",
1361 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1362 X86_COND_AE, EFLAGS))]>,
1364 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1365 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1366 "cmove\t{$src2, $dst|$dst, $src2}",
1367 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1368 X86_COND_E, EFLAGS))]>,
1370 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1371 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1372 "cmove\t{$src2, $dst|$dst, $src2}",
1373 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1374 X86_COND_E, EFLAGS))]>,
1376 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1377 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1378 "cmovne\t{$src2, $dst|$dst, $src2}",
1379 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1380 X86_COND_NE, EFLAGS))]>,
1382 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1383 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1384 "cmovne\t{$src2, $dst|$dst, $src2}",
1385 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1386 X86_COND_NE, EFLAGS))]>,
1388 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1389 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1390 "cmovbe\t{$src2, $dst|$dst, $src2}",
1391 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1392 X86_COND_BE, EFLAGS))]>,
1394 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1395 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1396 "cmovbe\t{$src2, $dst|$dst, $src2}",
1397 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1398 X86_COND_BE, EFLAGS))]>,
1400 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1401 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1402 "cmova\t{$src2, $dst|$dst, $src2}",
1403 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1404 X86_COND_A, EFLAGS))]>,
1406 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1407 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1408 "cmova\t{$src2, $dst|$dst, $src2}",
1409 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1410 X86_COND_A, EFLAGS))]>,
1412 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1413 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1414 "cmovl\t{$src2, $dst|$dst, $src2}",
1415 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1416 X86_COND_L, EFLAGS))]>,
1418 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1419 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1420 "cmovl\t{$src2, $dst|$dst, $src2}",
1421 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1422 X86_COND_L, EFLAGS))]>,
1424 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1425 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1426 "cmovge\t{$src2, $dst|$dst, $src2}",
1427 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1428 X86_COND_GE, EFLAGS))]>,
1430 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1431 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1432 "cmovge\t{$src2, $dst|$dst, $src2}",
1433 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1434 X86_COND_GE, EFLAGS))]>,
1436 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1437 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1438 "cmovle\t{$src2, $dst|$dst, $src2}",
1439 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1440 X86_COND_LE, EFLAGS))]>,
1442 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1443 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1444 "cmovle\t{$src2, $dst|$dst, $src2}",
1445 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1446 X86_COND_LE, EFLAGS))]>,
1448 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1449 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1450 "cmovg\t{$src2, $dst|$dst, $src2}",
1451 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1452 X86_COND_G, EFLAGS))]>,
1454 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1455 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1456 "cmovg\t{$src2, $dst|$dst, $src2}",
1457 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1458 X86_COND_G, EFLAGS))]>,
1460 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1461 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1462 "cmovs\t{$src2, $dst|$dst, $src2}",
1463 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1464 X86_COND_S, EFLAGS))]>,
1466 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1467 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1468 "cmovs\t{$src2, $dst|$dst, $src2}",
1469 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1470 X86_COND_S, EFLAGS))]>,
1472 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1473 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1474 "cmovns\t{$src2, $dst|$dst, $src2}",
1475 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1476 X86_COND_NS, EFLAGS))]>,
1478 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1479 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1480 "cmovns\t{$src2, $dst|$dst, $src2}",
1481 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1482 X86_COND_NS, EFLAGS))]>,
1484 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1485 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1486 "cmovp\t{$src2, $dst|$dst, $src2}",
1487 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1488 X86_COND_P, EFLAGS))]>,
1490 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1491 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1492 "cmovp\t{$src2, $dst|$dst, $src2}",
1493 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1494 X86_COND_P, EFLAGS))]>,
1496 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1497 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1498 "cmovnp\t{$src2, $dst|$dst, $src2}",
1499 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1500 X86_COND_NP, EFLAGS))]>,
1502 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1503 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1504 "cmovnp\t{$src2, $dst|$dst, $src2}",
1505 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1506 X86_COND_NP, EFLAGS))]>,
1508 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1509 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1510 "cmovo\t{$src2, $dst|$dst, $src2}",
1511 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1512 X86_COND_O, EFLAGS))]>,
1514 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1515 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1516 "cmovo\t{$src2, $dst|$dst, $src2}",
1517 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1518 X86_COND_O, EFLAGS))]>,
1520 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1521 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1522 "cmovno\t{$src2, $dst|$dst, $src2}",
1523 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1524 X86_COND_NO, EFLAGS))]>,
1526 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1527 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1528 "cmovno\t{$src2, $dst|$dst, $src2}",
1529 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1530 X86_COND_NO, EFLAGS))]>,
1532 } // Uses = [EFLAGS]
1535 // unary instructions
1536 let CodeSize = 2 in {
1537 let Defs = [EFLAGS] in {
1538 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1539 [(set GR8:$dst, (ineg GR8:$src)),
1540 (implicit EFLAGS)]>;
1541 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1542 [(set GR16:$dst, (ineg GR16:$src)),
1543 (implicit EFLAGS)]>, OpSize;
1544 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1545 [(set GR32:$dst, (ineg GR32:$src)),
1546 (implicit EFLAGS)]>;
1547 let isTwoAddress = 0 in {
1548 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1549 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1550 (implicit EFLAGS)]>;
1551 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1552 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1553 (implicit EFLAGS)]>, OpSize;
1554 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1555 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1556 (implicit EFLAGS)]>;
1558 } // Defs = [EFLAGS]
1560 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1561 let AddedComplexity = 15 in {
1562 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1563 [(set GR8:$dst, (not GR8:$src))]>;
1564 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1565 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1566 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1567 [(set GR32:$dst, (not GR32:$src))]>;
1569 let isTwoAddress = 0 in {
1570 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1571 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1572 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1573 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1574 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1575 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1579 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1580 let Defs = [EFLAGS] in {
1582 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1583 [(set GR8:$dst, (add GR8:$src, 1)),
1584 (implicit EFLAGS)]>;
1585 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1586 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1587 [(set GR16:$dst, (add GR16:$src, 1)),
1588 (implicit EFLAGS)]>,
1589 OpSize, Requires<[In32BitMode]>;
1590 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1591 [(set GR32:$dst, (add GR32:$src, 1)),
1592 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1594 let isTwoAddress = 0, CodeSize = 2 in {
1595 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1596 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1597 (implicit EFLAGS)]>;
1598 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1599 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1600 (implicit EFLAGS)]>,
1601 OpSize, Requires<[In32BitMode]>;
1602 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1603 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1604 (implicit EFLAGS)]>,
1605 Requires<[In32BitMode]>;
1609 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1610 [(set GR8:$dst, (add GR8:$src, -1)),
1611 (implicit EFLAGS)]>;
1612 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1613 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1614 [(set GR16:$dst, (add GR16:$src, -1)),
1615 (implicit EFLAGS)]>,
1616 OpSize, Requires<[In32BitMode]>;
1617 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1618 [(set GR32:$dst, (add GR32:$src, -1)),
1619 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1622 let isTwoAddress = 0, CodeSize = 2 in {
1623 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1624 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1625 (implicit EFLAGS)]>;
1626 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1627 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1628 (implicit EFLAGS)]>,
1629 OpSize, Requires<[In32BitMode]>;
1630 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1631 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1632 (implicit EFLAGS)]>,
1633 Requires<[In32BitMode]>;
1635 } // Defs = [EFLAGS]
1637 // Logical operators...
1638 let Defs = [EFLAGS] in {
1639 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1640 def AND8rr : I<0x20, MRMDestReg,
1641 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1642 "and{b}\t{$src2, $dst|$dst, $src2}",
1643 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1644 (implicit EFLAGS)]>;
1645 def AND16rr : I<0x21, MRMDestReg,
1646 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1647 "and{w}\t{$src2, $dst|$dst, $src2}",
1648 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1649 (implicit EFLAGS)]>, OpSize;
1650 def AND32rr : I<0x21, MRMDestReg,
1651 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1652 "and{l}\t{$src2, $dst|$dst, $src2}",
1653 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1654 (implicit EFLAGS)]>;
1657 def AND8rm : I<0x22, MRMSrcMem,
1658 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1659 "and{b}\t{$src2, $dst|$dst, $src2}",
1660 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1661 (implicit EFLAGS)]>;
1662 def AND16rm : I<0x23, MRMSrcMem,
1663 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1664 "and{w}\t{$src2, $dst|$dst, $src2}",
1665 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1666 (implicit EFLAGS)]>, OpSize;
1667 def AND32rm : I<0x23, MRMSrcMem,
1668 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1669 "and{l}\t{$src2, $dst|$dst, $src2}",
1670 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1671 (implicit EFLAGS)]>;
1673 def AND8ri : Ii8<0x80, MRM4r,
1674 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1675 "and{b}\t{$src2, $dst|$dst, $src2}",
1676 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1677 (implicit EFLAGS)]>;
1678 def AND16ri : Ii16<0x81, MRM4r,
1679 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1680 "and{w}\t{$src2, $dst|$dst, $src2}",
1681 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1682 (implicit EFLAGS)]>, OpSize;
1683 def AND32ri : Ii32<0x81, MRM4r,
1684 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1685 "and{l}\t{$src2, $dst|$dst, $src2}",
1686 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1687 (implicit EFLAGS)]>;
1688 def AND16ri8 : Ii8<0x83, MRM4r,
1689 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1690 "and{w}\t{$src2, $dst|$dst, $src2}",
1691 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1692 (implicit EFLAGS)]>,
1694 def AND32ri8 : Ii8<0x83, MRM4r,
1695 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1696 "and{l}\t{$src2, $dst|$dst, $src2}",
1697 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1698 (implicit EFLAGS)]>;
1700 let isTwoAddress = 0 in {
1701 def AND8mr : I<0x20, MRMDestMem,
1702 (outs), (ins i8mem :$dst, GR8 :$src),
1703 "and{b}\t{$src, $dst|$dst, $src}",
1704 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1705 (implicit EFLAGS)]>;
1706 def AND16mr : I<0x21, MRMDestMem,
1707 (outs), (ins i16mem:$dst, GR16:$src),
1708 "and{w}\t{$src, $dst|$dst, $src}",
1709 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1710 (implicit EFLAGS)]>,
1712 def AND32mr : I<0x21, MRMDestMem,
1713 (outs), (ins i32mem:$dst, GR32:$src),
1714 "and{l}\t{$src, $dst|$dst, $src}",
1715 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1716 (implicit EFLAGS)]>;
1717 def AND8mi : Ii8<0x80, MRM4m,
1718 (outs), (ins i8mem :$dst, i8imm :$src),
1719 "and{b}\t{$src, $dst|$dst, $src}",
1720 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1721 (implicit EFLAGS)]>;
1722 def AND16mi : Ii16<0x81, MRM4m,
1723 (outs), (ins i16mem:$dst, i16imm:$src),
1724 "and{w}\t{$src, $dst|$dst, $src}",
1725 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1726 (implicit EFLAGS)]>,
1728 def AND32mi : Ii32<0x81, MRM4m,
1729 (outs), (ins i32mem:$dst, i32imm:$src),
1730 "and{l}\t{$src, $dst|$dst, $src}",
1731 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1732 (implicit EFLAGS)]>;
1733 def AND16mi8 : Ii8<0x83, MRM4m,
1734 (outs), (ins i16mem:$dst, i16i8imm :$src),
1735 "and{w}\t{$src, $dst|$dst, $src}",
1736 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1737 (implicit EFLAGS)]>,
1739 def AND32mi8 : Ii8<0x83, MRM4m,
1740 (outs), (ins i32mem:$dst, i32i8imm :$src),
1741 "and{l}\t{$src, $dst|$dst, $src}",
1742 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1743 (implicit EFLAGS)]>;
1745 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1746 "and{b}\t{$src, %al|%al, $src}", []>;
1747 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1748 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1749 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1750 "and{l}\t{$src, %eax|%eax, $src}", []>;
1755 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1756 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1757 "or{b}\t{$src2, $dst|$dst, $src2}",
1758 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1759 (implicit EFLAGS)]>;
1760 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1761 "or{w}\t{$src2, $dst|$dst, $src2}",
1762 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1763 (implicit EFLAGS)]>, OpSize;
1764 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1765 "or{l}\t{$src2, $dst|$dst, $src2}",
1766 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1767 (implicit EFLAGS)]>;
1769 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1770 "or{b}\t{$src2, $dst|$dst, $src2}",
1771 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1772 (implicit EFLAGS)]>;
1773 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1774 "or{w}\t{$src2, $dst|$dst, $src2}",
1775 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1776 (implicit EFLAGS)]>, OpSize;
1777 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1778 "or{l}\t{$src2, $dst|$dst, $src2}",
1779 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1780 (implicit EFLAGS)]>;
1782 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1783 "or{b}\t{$src2, $dst|$dst, $src2}",
1784 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1785 (implicit EFLAGS)]>;
1786 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1787 "or{w}\t{$src2, $dst|$dst, $src2}",
1788 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1789 (implicit EFLAGS)]>, OpSize;
1790 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1791 "or{l}\t{$src2, $dst|$dst, $src2}",
1792 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1793 (implicit EFLAGS)]>;
1795 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1796 "or{w}\t{$src2, $dst|$dst, $src2}",
1797 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1798 (implicit EFLAGS)]>, OpSize;
1799 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1800 "or{l}\t{$src2, $dst|$dst, $src2}",
1801 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1802 (implicit EFLAGS)]>;
1803 let isTwoAddress = 0 in {
1804 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1805 "or{b}\t{$src, $dst|$dst, $src}",
1806 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1807 (implicit EFLAGS)]>;
1808 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1809 "or{w}\t{$src, $dst|$dst, $src}",
1810 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1811 (implicit EFLAGS)]>, OpSize;
1812 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1813 "or{l}\t{$src, $dst|$dst, $src}",
1814 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1815 (implicit EFLAGS)]>;
1816 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1817 "or{b}\t{$src, $dst|$dst, $src}",
1818 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1819 (implicit EFLAGS)]>;
1820 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1821 "or{w}\t{$src, $dst|$dst, $src}",
1822 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1823 (implicit EFLAGS)]>,
1825 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1826 "or{l}\t{$src, $dst|$dst, $src}",
1827 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1828 (implicit EFLAGS)]>;
1829 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1830 "or{w}\t{$src, $dst|$dst, $src}",
1831 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1832 (implicit EFLAGS)]>,
1834 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1835 "or{l}\t{$src, $dst|$dst, $src}",
1836 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1837 (implicit EFLAGS)]>;
1839 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1840 "or{b}\t{$src, %al|%al, $src}", []>;
1841 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1842 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1843 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1844 "or{l}\t{$src, %eax|%eax, $src}", []>;
1845 } // isTwoAddress = 0
1848 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1849 def XOR8rr : I<0x30, MRMDestReg,
1850 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1851 "xor{b}\t{$src2, $dst|$dst, $src2}",
1852 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1853 (implicit EFLAGS)]>;
1854 def XOR16rr : I<0x31, MRMDestReg,
1855 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1856 "xor{w}\t{$src2, $dst|$dst, $src2}",
1857 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1858 (implicit EFLAGS)]>, OpSize;
1859 def XOR32rr : I<0x31, MRMDestReg,
1860 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1861 "xor{l}\t{$src2, $dst|$dst, $src2}",
1862 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1863 (implicit EFLAGS)]>;
1864 } // isCommutable = 1
1866 def XOR8rm : I<0x32, MRMSrcMem ,
1867 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1868 "xor{b}\t{$src2, $dst|$dst, $src2}",
1869 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1870 (implicit EFLAGS)]>;
1871 def XOR16rm : I<0x33, MRMSrcMem ,
1872 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1873 "xor{w}\t{$src2, $dst|$dst, $src2}",
1874 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1875 (implicit EFLAGS)]>,
1877 def XOR32rm : I<0x33, MRMSrcMem ,
1878 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1879 "xor{l}\t{$src2, $dst|$dst, $src2}",
1880 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1881 (implicit EFLAGS)]>;
1883 def XOR8ri : Ii8<0x80, MRM6r,
1884 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1885 "xor{b}\t{$src2, $dst|$dst, $src2}",
1886 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1887 (implicit EFLAGS)]>;
1888 def XOR16ri : Ii16<0x81, MRM6r,
1889 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1890 "xor{w}\t{$src2, $dst|$dst, $src2}",
1891 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1892 (implicit EFLAGS)]>, OpSize;
1893 def XOR32ri : Ii32<0x81, MRM6r,
1894 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1895 "xor{l}\t{$src2, $dst|$dst, $src2}",
1896 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1897 (implicit EFLAGS)]>;
1898 def XOR16ri8 : Ii8<0x83, MRM6r,
1899 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1900 "xor{w}\t{$src2, $dst|$dst, $src2}",
1901 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1902 (implicit EFLAGS)]>,
1904 def XOR32ri8 : Ii8<0x83, MRM6r,
1905 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1906 "xor{l}\t{$src2, $dst|$dst, $src2}",
1907 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1908 (implicit EFLAGS)]>;
1910 let isTwoAddress = 0 in {
1911 def XOR8mr : I<0x30, MRMDestMem,
1912 (outs), (ins i8mem :$dst, GR8 :$src),
1913 "xor{b}\t{$src, $dst|$dst, $src}",
1914 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1915 (implicit EFLAGS)]>;
1916 def XOR16mr : I<0x31, MRMDestMem,
1917 (outs), (ins i16mem:$dst, GR16:$src),
1918 "xor{w}\t{$src, $dst|$dst, $src}",
1919 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1920 (implicit EFLAGS)]>,
1922 def XOR32mr : I<0x31, MRMDestMem,
1923 (outs), (ins i32mem:$dst, GR32:$src),
1924 "xor{l}\t{$src, $dst|$dst, $src}",
1925 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1926 (implicit EFLAGS)]>;
1927 def XOR8mi : Ii8<0x80, MRM6m,
1928 (outs), (ins i8mem :$dst, i8imm :$src),
1929 "xor{b}\t{$src, $dst|$dst, $src}",
1930 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1931 (implicit EFLAGS)]>;
1932 def XOR16mi : Ii16<0x81, MRM6m,
1933 (outs), (ins i16mem:$dst, i16imm:$src),
1934 "xor{w}\t{$src, $dst|$dst, $src}",
1935 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1936 (implicit EFLAGS)]>,
1938 def XOR32mi : Ii32<0x81, MRM6m,
1939 (outs), (ins i32mem:$dst, i32imm:$src),
1940 "xor{l}\t{$src, $dst|$dst, $src}",
1941 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1942 (implicit EFLAGS)]>;
1943 def XOR16mi8 : Ii8<0x83, MRM6m,
1944 (outs), (ins i16mem:$dst, i16i8imm :$src),
1945 "xor{w}\t{$src, $dst|$dst, $src}",
1946 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1947 (implicit EFLAGS)]>,
1949 def XOR32mi8 : Ii8<0x83, MRM6m,
1950 (outs), (ins i32mem:$dst, i32i8imm :$src),
1951 "xor{l}\t{$src, $dst|$dst, $src}",
1952 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1953 (implicit EFLAGS)]>;
1955 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1956 "xor{b}\t{$src, %al|%al, $src}", []>;
1957 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
1958 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1959 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
1960 "xor{l}\t{$src, %eax|%eax, $src}", []>;
1961 } // isTwoAddress = 0
1962 } // Defs = [EFLAGS]
1964 // Shift instructions
1965 let Defs = [EFLAGS] in {
1966 let Uses = [CL] in {
1967 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1968 "shl{b}\t{%cl, $dst|$dst, CL}",
1969 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1970 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1971 "shl{w}\t{%cl, $dst|$dst, CL}",
1972 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1973 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1974 "shl{l}\t{%cl, $dst|$dst, CL}",
1975 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1978 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1979 "shl{b}\t{$src2, $dst|$dst, $src2}",
1980 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1981 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1982 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1983 "shl{w}\t{$src2, $dst|$dst, $src2}",
1984 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1985 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1986 "shl{l}\t{$src2, $dst|$dst, $src2}",
1987 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1989 // NOTE: We don't include patterns for shifts of a register by one, because
1990 // 'add reg,reg' is cheaper.
1992 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
1993 "shl{b}\t$dst", []>;
1994 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1995 "shl{w}\t$dst", []>, OpSize;
1996 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1997 "shl{l}\t$dst", []>;
1999 } // isConvertibleToThreeAddress = 1
2001 let isTwoAddress = 0 in {
2002 let Uses = [CL] in {
2003 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
2004 "shl{b}\t{%cl, $dst|$dst, CL}",
2005 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
2006 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
2007 "shl{w}\t{%cl, $dst|$dst, CL}",
2008 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2009 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
2010 "shl{l}\t{%cl, $dst|$dst, CL}",
2011 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2013 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
2014 "shl{b}\t{$src, $dst|$dst, $src}",
2015 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2016 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
2017 "shl{w}\t{$src, $dst|$dst, $src}",
2018 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2020 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
2021 "shl{l}\t{$src, $dst|$dst, $src}",
2022 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2025 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2027 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2028 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2030 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2032 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2034 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2037 let Uses = [CL] in {
2038 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
2039 "shr{b}\t{%cl, $dst|$dst, CL}",
2040 [(set GR8:$dst, (srl GR8:$src, CL))]>;
2041 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
2042 "shr{w}\t{%cl, $dst|$dst, CL}",
2043 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
2044 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
2045 "shr{l}\t{%cl, $dst|$dst, CL}",
2046 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2049 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2050 "shr{b}\t{$src2, $dst|$dst, $src2}",
2051 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2052 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2053 "shr{w}\t{$src2, $dst|$dst, $src2}",
2054 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2055 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2056 "shr{l}\t{$src2, $dst|$dst, $src2}",
2057 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2060 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2062 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2063 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2065 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2066 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2068 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2070 let isTwoAddress = 0 in {
2071 let Uses = [CL] in {
2072 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2073 "shr{b}\t{%cl, $dst|$dst, CL}",
2074 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2075 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2076 "shr{w}\t{%cl, $dst|$dst, CL}",
2077 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2079 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2080 "shr{l}\t{%cl, $dst|$dst, CL}",
2081 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2083 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2084 "shr{b}\t{$src, $dst|$dst, $src}",
2085 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2086 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2087 "shr{w}\t{$src, $dst|$dst, $src}",
2088 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2090 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2091 "shr{l}\t{$src, $dst|$dst, $src}",
2092 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2095 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2097 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2098 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2100 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2101 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2103 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2106 let Uses = [CL] in {
2107 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
2108 "sar{b}\t{%cl, $dst|$dst, CL}",
2109 [(set GR8:$dst, (sra GR8:$src, CL))]>;
2110 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
2111 "sar{w}\t{%cl, $dst|$dst, CL}",
2112 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
2113 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
2114 "sar{l}\t{%cl, $dst|$dst, CL}",
2115 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2118 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2119 "sar{b}\t{$src2, $dst|$dst, $src2}",
2120 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2121 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2122 "sar{w}\t{$src2, $dst|$dst, $src2}",
2123 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2125 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2126 "sar{l}\t{$src2, $dst|$dst, $src2}",
2127 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2130 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2132 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2133 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2135 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2136 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2138 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2140 let isTwoAddress = 0 in {
2141 let Uses = [CL] in {
2142 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2143 "sar{b}\t{%cl, $dst|$dst, CL}",
2144 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2145 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2146 "sar{w}\t{%cl, $dst|$dst, CL}",
2147 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2148 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2149 "sar{l}\t{%cl, $dst|$dst, CL}",
2150 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2152 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2153 "sar{b}\t{$src, $dst|$dst, $src}",
2154 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2155 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2156 "sar{w}\t{$src, $dst|$dst, $src}",
2157 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2159 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2160 "sar{l}\t{$src, $dst|$dst, $src}",
2161 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2164 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2166 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2167 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2169 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2171 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2173 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2176 // Rotate instructions
2177 // FIXME: provide shorter instructions when imm8 == 1
2178 let Uses = [CL] in {
2179 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
2180 "rol{b}\t{%cl, $dst|$dst, CL}",
2181 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
2182 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
2183 "rol{w}\t{%cl, $dst|$dst, CL}",
2184 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
2185 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
2186 "rol{l}\t{%cl, $dst|$dst, CL}",
2187 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2190 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2191 "rol{b}\t{$src2, $dst|$dst, $src2}",
2192 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2193 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2194 "rol{w}\t{$src2, $dst|$dst, $src2}",
2195 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2196 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2197 "rol{l}\t{$src2, $dst|$dst, $src2}",
2198 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2201 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2203 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2204 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2206 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2207 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2209 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2211 let isTwoAddress = 0 in {
2212 let Uses = [CL] in {
2213 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2214 "rol{b}\t{%cl, $dst|$dst, CL}",
2215 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2216 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2217 "rol{w}\t{%cl, $dst|$dst, CL}",
2218 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2219 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2220 "rol{l}\t{%cl, $dst|$dst, CL}",
2221 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2223 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2224 "rol{b}\t{$src, $dst|$dst, $src}",
2225 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2226 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2227 "rol{w}\t{$src, $dst|$dst, $src}",
2228 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2230 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2231 "rol{l}\t{$src, $dst|$dst, $src}",
2232 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2235 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2237 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2238 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2240 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2242 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2244 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2247 let Uses = [CL] in {
2248 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2249 "ror{b}\t{%cl, $dst|$dst, CL}",
2250 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2251 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2252 "ror{w}\t{%cl, $dst|$dst, CL}",
2253 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2254 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2255 "ror{l}\t{%cl, $dst|$dst, CL}",
2256 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2259 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2260 "ror{b}\t{$src2, $dst|$dst, $src2}",
2261 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2262 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2263 "ror{w}\t{$src2, $dst|$dst, $src2}",
2264 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2265 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2266 "ror{l}\t{$src2, $dst|$dst, $src2}",
2267 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2270 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2272 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2273 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2275 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2276 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2278 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2280 let isTwoAddress = 0 in {
2281 let Uses = [CL] in {
2282 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2283 "ror{b}\t{%cl, $dst|$dst, CL}",
2284 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2285 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2286 "ror{w}\t{%cl, $dst|$dst, CL}",
2287 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2288 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2289 "ror{l}\t{%cl, $dst|$dst, CL}",
2290 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2292 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2293 "ror{b}\t{$src, $dst|$dst, $src}",
2294 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2295 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2296 "ror{w}\t{$src, $dst|$dst, $src}",
2297 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2299 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2300 "ror{l}\t{$src, $dst|$dst, $src}",
2301 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2304 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2306 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2307 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2309 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2311 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2313 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2318 // Double shift instructions (generalizations of rotate)
2319 let Uses = [CL] in {
2320 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2321 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2322 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2323 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2324 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2325 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2326 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2327 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2328 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2330 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2331 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2332 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2336 let isCommutable = 1 in { // These instructions commute to each other.
2337 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2338 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2339 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2340 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2343 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2344 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2345 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2346 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2349 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2350 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2351 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2352 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2355 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2356 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2357 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2358 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2363 let isTwoAddress = 0 in {
2364 let Uses = [CL] in {
2365 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2366 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2367 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2369 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2370 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2371 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2374 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2375 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2376 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2377 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2378 (i8 imm:$src3)), addr:$dst)]>,
2380 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2381 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2382 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2383 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2384 (i8 imm:$src3)), addr:$dst)]>,
2387 let Uses = [CL] in {
2388 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2389 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2390 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2391 addr:$dst)]>, TB, OpSize;
2392 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2393 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2394 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2395 addr:$dst)]>, TB, OpSize;
2397 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2398 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2399 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2400 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2401 (i8 imm:$src3)), addr:$dst)]>,
2403 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2404 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2405 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2406 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2407 (i8 imm:$src3)), addr:$dst)]>,
2410 } // Defs = [EFLAGS]
2414 let Defs = [EFLAGS] in {
2415 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2416 // Register-Register Addition
2417 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2418 (ins GR8 :$src1, GR8 :$src2),
2419 "add{b}\t{$src2, $dst|$dst, $src2}",
2420 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2421 (implicit EFLAGS)]>;
2423 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2424 // Register-Register Addition
2425 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2426 (ins GR16:$src1, GR16:$src2),
2427 "add{w}\t{$src2, $dst|$dst, $src2}",
2428 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2429 (implicit EFLAGS)]>, OpSize;
2430 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2431 (ins GR32:$src1, GR32:$src2),
2432 "add{l}\t{$src2, $dst|$dst, $src2}",
2433 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2434 (implicit EFLAGS)]>;
2435 } // end isConvertibleToThreeAddress
2436 } // end isCommutable
2438 // Register-Memory Addition
2439 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2440 (ins GR8 :$src1, i8mem :$src2),
2441 "add{b}\t{$src2, $dst|$dst, $src2}",
2442 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2443 (implicit EFLAGS)]>;
2444 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2445 (ins GR16:$src1, i16mem:$src2),
2446 "add{w}\t{$src2, $dst|$dst, $src2}",
2447 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2448 (implicit EFLAGS)]>, OpSize;
2449 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2450 (ins GR32:$src1, i32mem:$src2),
2451 "add{l}\t{$src2, $dst|$dst, $src2}",
2452 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2453 (implicit EFLAGS)]>;
2455 // Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2456 // ADD16rr, and ADD32rr), but differently encoded.
2457 def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2458 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2459 def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2460 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2461 def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2462 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2464 // Register-Integer Addition
2465 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2466 "add{b}\t{$src2, $dst|$dst, $src2}",
2467 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2468 (implicit EFLAGS)]>;
2470 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2471 // Register-Integer Addition
2472 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2473 (ins GR16:$src1, i16imm:$src2),
2474 "add{w}\t{$src2, $dst|$dst, $src2}",
2475 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2476 (implicit EFLAGS)]>, OpSize;
2477 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2478 (ins GR32:$src1, i32imm:$src2),
2479 "add{l}\t{$src2, $dst|$dst, $src2}",
2480 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2481 (implicit EFLAGS)]>;
2482 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2483 (ins GR16:$src1, i16i8imm:$src2),
2484 "add{w}\t{$src2, $dst|$dst, $src2}",
2485 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2486 (implicit EFLAGS)]>, OpSize;
2487 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2488 (ins GR32:$src1, i32i8imm:$src2),
2489 "add{l}\t{$src2, $dst|$dst, $src2}",
2490 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2491 (implicit EFLAGS)]>;
2494 let isTwoAddress = 0 in {
2495 // Memory-Register Addition
2496 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2497 "add{b}\t{$src2, $dst|$dst, $src2}",
2498 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2499 (implicit EFLAGS)]>;
2500 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2501 "add{w}\t{$src2, $dst|$dst, $src2}",
2502 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2503 (implicit EFLAGS)]>, OpSize;
2504 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2505 "add{l}\t{$src2, $dst|$dst, $src2}",
2506 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2507 (implicit EFLAGS)]>;
2508 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2509 "add{b}\t{$src2, $dst|$dst, $src2}",
2510 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2511 (implicit EFLAGS)]>;
2512 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2513 "add{w}\t{$src2, $dst|$dst, $src2}",
2514 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2515 (implicit EFLAGS)]>, OpSize;
2516 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2517 "add{l}\t{$src2, $dst|$dst, $src2}",
2518 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2519 (implicit EFLAGS)]>;
2520 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2521 "add{w}\t{$src2, $dst|$dst, $src2}",
2522 [(store (add (load addr:$dst), i16immSExt8:$src2),
2524 (implicit EFLAGS)]>, OpSize;
2525 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2526 "add{l}\t{$src2, $dst|$dst, $src2}",
2527 [(store (add (load addr:$dst), i32immSExt8:$src2),
2529 (implicit EFLAGS)]>;
2532 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2533 "add{b}\t{$src, %al|%al, $src}", []>;
2534 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2535 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2536 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2537 "add{l}\t{$src, %eax|%eax, $src}", []>;
2540 let Uses = [EFLAGS] in {
2541 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2542 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2543 "adc{b}\t{$src2, $dst|$dst, $src2}",
2544 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2545 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2546 (ins GR16:$src1, GR16:$src2),
2547 "adc{w}\t{$src2, $dst|$dst, $src2}",
2548 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2549 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2550 (ins GR32:$src1, GR32:$src2),
2551 "adc{l}\t{$src2, $dst|$dst, $src2}",
2552 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2554 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2555 (ins GR8:$src1, i8mem:$src2),
2556 "adc{b}\t{$src2, $dst|$dst, $src2}",
2557 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2558 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2559 (ins GR16:$src1, i16mem:$src2),
2560 "adc{w}\t{$src2, $dst|$dst, $src2}",
2561 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2563 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2564 (ins GR32:$src1, i32mem:$src2),
2565 "adc{l}\t{$src2, $dst|$dst, $src2}",
2566 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2567 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2568 "adc{b}\t{$src2, $dst|$dst, $src2}",
2569 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2570 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2571 (ins GR16:$src1, i16imm:$src2),
2572 "adc{w}\t{$src2, $dst|$dst, $src2}",
2573 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2574 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2575 (ins GR16:$src1, i16i8imm:$src2),
2576 "adc{w}\t{$src2, $dst|$dst, $src2}",
2577 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2579 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2580 (ins GR32:$src1, i32imm:$src2),
2581 "adc{l}\t{$src2, $dst|$dst, $src2}",
2582 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2583 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2584 (ins GR32:$src1, i32i8imm:$src2),
2585 "adc{l}\t{$src2, $dst|$dst, $src2}",
2586 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2588 let isTwoAddress = 0 in {
2589 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2590 "adc{b}\t{$src2, $dst|$dst, $src2}",
2591 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2592 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2593 "adc{w}\t{$src2, $dst|$dst, $src2}",
2594 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2596 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2597 "adc{l}\t{$src2, $dst|$dst, $src2}",
2598 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2599 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2600 "adc{b}\t{$src2, $dst|$dst, $src2}",
2601 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2602 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2603 "adc{w}\t{$src2, $dst|$dst, $src2}",
2604 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2606 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2607 "adc{w}\t{$src2, $dst|$dst, $src2}",
2608 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2610 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2611 "adc{l}\t{$src2, $dst|$dst, $src2}",
2612 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2613 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2614 "adc{l}\t{$src2, $dst|$dst, $src2}",
2615 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2617 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2618 "adc{b}\t{$src, %al|%al, $src}", []>;
2619 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2620 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2621 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2622 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2624 } // Uses = [EFLAGS]
2626 // Register-Register Subtraction
2627 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2628 "sub{b}\t{$src2, $dst|$dst, $src2}",
2629 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2630 (implicit EFLAGS)]>;
2631 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2632 "sub{w}\t{$src2, $dst|$dst, $src2}",
2633 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2634 (implicit EFLAGS)]>, OpSize;
2635 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2636 "sub{l}\t{$src2, $dst|$dst, $src2}",
2637 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2638 (implicit EFLAGS)]>;
2640 // Register-Memory Subtraction
2641 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2642 (ins GR8 :$src1, i8mem :$src2),
2643 "sub{b}\t{$src2, $dst|$dst, $src2}",
2644 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2645 (implicit EFLAGS)]>;
2646 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2647 (ins GR16:$src1, i16mem:$src2),
2648 "sub{w}\t{$src2, $dst|$dst, $src2}",
2649 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2650 (implicit EFLAGS)]>, OpSize;
2651 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2652 (ins GR32:$src1, i32mem:$src2),
2653 "sub{l}\t{$src2, $dst|$dst, $src2}",
2654 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2655 (implicit EFLAGS)]>;
2657 // Register-Integer Subtraction
2658 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2659 (ins GR8:$src1, i8imm:$src2),
2660 "sub{b}\t{$src2, $dst|$dst, $src2}",
2661 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2662 (implicit EFLAGS)]>;
2663 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2664 (ins GR16:$src1, i16imm:$src2),
2665 "sub{w}\t{$src2, $dst|$dst, $src2}",
2666 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2667 (implicit EFLAGS)]>, OpSize;
2668 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2669 (ins GR32:$src1, i32imm:$src2),
2670 "sub{l}\t{$src2, $dst|$dst, $src2}",
2671 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2672 (implicit EFLAGS)]>;
2673 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2674 (ins GR16:$src1, i16i8imm:$src2),
2675 "sub{w}\t{$src2, $dst|$dst, $src2}",
2676 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2677 (implicit EFLAGS)]>, OpSize;
2678 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2679 (ins GR32:$src1, i32i8imm:$src2),
2680 "sub{l}\t{$src2, $dst|$dst, $src2}",
2681 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2682 (implicit EFLAGS)]>;
2684 let isTwoAddress = 0 in {
2685 // Memory-Register Subtraction
2686 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2687 "sub{b}\t{$src2, $dst|$dst, $src2}",
2688 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2689 (implicit EFLAGS)]>;
2690 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2691 "sub{w}\t{$src2, $dst|$dst, $src2}",
2692 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2693 (implicit EFLAGS)]>, OpSize;
2694 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2695 "sub{l}\t{$src2, $dst|$dst, $src2}",
2696 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2697 (implicit EFLAGS)]>;
2699 // Memory-Integer Subtraction
2700 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2701 "sub{b}\t{$src2, $dst|$dst, $src2}",
2702 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2703 (implicit EFLAGS)]>;
2704 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2705 "sub{w}\t{$src2, $dst|$dst, $src2}",
2706 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2707 (implicit EFLAGS)]>, OpSize;
2708 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2709 "sub{l}\t{$src2, $dst|$dst, $src2}",
2710 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2711 (implicit EFLAGS)]>;
2712 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2713 "sub{w}\t{$src2, $dst|$dst, $src2}",
2714 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2716 (implicit EFLAGS)]>, OpSize;
2717 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2718 "sub{l}\t{$src2, $dst|$dst, $src2}",
2719 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2721 (implicit EFLAGS)]>;
2723 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2724 "sub{b}\t{$src, %al|%al, $src}", []>;
2725 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2726 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2727 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2728 "sub{l}\t{$src, %eax|%eax, $src}", []>;
2731 let Uses = [EFLAGS] in {
2732 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2733 (ins GR8:$src1, GR8:$src2),
2734 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2735 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2736 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2737 (ins GR16:$src1, GR16:$src2),
2738 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2739 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2740 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2741 (ins GR32:$src1, GR32:$src2),
2742 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2743 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2745 let isTwoAddress = 0 in {
2746 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2747 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2748 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2749 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2750 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2751 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2753 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2754 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2755 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2756 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2757 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2758 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2759 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2760 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2761 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2763 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2764 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2765 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2767 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2768 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2769 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2770 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2771 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2772 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2774 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2775 "sbb{b}\t{$src, %al|%al, $src}", []>;
2776 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2777 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2778 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2779 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
2781 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2782 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2783 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2784 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2785 (ins GR16:$src1, i16mem:$src2),
2786 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2787 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2789 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2790 (ins GR32:$src1, i32mem:$src2),
2791 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2792 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2793 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2794 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2795 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2796 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2797 (ins GR16:$src1, i16imm:$src2),
2798 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2799 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2800 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2801 (ins GR16:$src1, i16i8imm:$src2),
2802 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2803 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2805 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2806 (ins GR32:$src1, i32imm:$src2),
2807 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2808 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2809 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2810 (ins GR32:$src1, i32i8imm:$src2),
2811 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2812 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2813 } // Uses = [EFLAGS]
2814 } // Defs = [EFLAGS]
2816 let Defs = [EFLAGS] in {
2817 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2818 // Register-Register Signed Integer Multiply
2819 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2820 "imul{w}\t{$src2, $dst|$dst, $src2}",
2821 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2822 (implicit EFLAGS)]>, TB, OpSize;
2823 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2824 "imul{l}\t{$src2, $dst|$dst, $src2}",
2825 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2826 (implicit EFLAGS)]>, TB;
2829 // Register-Memory Signed Integer Multiply
2830 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2831 (ins GR16:$src1, i16mem:$src2),
2832 "imul{w}\t{$src2, $dst|$dst, $src2}",
2833 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2834 (implicit EFLAGS)]>, TB, OpSize;
2835 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2836 "imul{l}\t{$src2, $dst|$dst, $src2}",
2837 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2838 (implicit EFLAGS)]>, TB;
2839 } // Defs = [EFLAGS]
2840 } // end Two Address instructions
2842 // Suprisingly enough, these are not two address instructions!
2843 let Defs = [EFLAGS] in {
2844 // Register-Integer Signed Integer Multiply
2845 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2846 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2847 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2848 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2849 (implicit EFLAGS)]>, OpSize;
2850 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2851 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2852 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2853 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2854 (implicit EFLAGS)]>;
2855 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2856 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2857 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2858 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2859 (implicit EFLAGS)]>, OpSize;
2860 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2861 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2862 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2863 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2864 (implicit EFLAGS)]>;
2866 // Memory-Integer Signed Integer Multiply
2867 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2868 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2869 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2870 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2871 (implicit EFLAGS)]>, OpSize;
2872 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2873 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2874 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2875 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2876 (implicit EFLAGS)]>;
2877 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2878 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2879 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2880 [(set GR16:$dst, (mul (load addr:$src1),
2881 i16immSExt8:$src2)),
2882 (implicit EFLAGS)]>, OpSize;
2883 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2884 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2885 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2886 [(set GR32:$dst, (mul (load addr:$src1),
2887 i32immSExt8:$src2)),
2888 (implicit EFLAGS)]>;
2889 } // Defs = [EFLAGS]
2891 //===----------------------------------------------------------------------===//
2892 // Test instructions are just like AND, except they don't generate a result.
2894 let Defs = [EFLAGS] in {
2895 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2896 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2897 "test{b}\t{$src2, $src1|$src1, $src2}",
2898 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2899 (implicit EFLAGS)]>;
2900 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2901 "test{w}\t{$src2, $src1|$src1, $src2}",
2902 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2903 (implicit EFLAGS)]>,
2905 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2906 "test{l}\t{$src2, $src1|$src1, $src2}",
2907 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2908 (implicit EFLAGS)]>;
2911 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
2912 "test{b}\t{$src, %al|%al, $src}", []>;
2913 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
2914 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2915 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
2916 "test{l}\t{$src, %eax|%eax, $src}", []>;
2918 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2919 "test{b}\t{$src2, $src1|$src1, $src2}",
2920 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2921 (implicit EFLAGS)]>;
2922 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2923 "test{w}\t{$src2, $src1|$src1, $src2}",
2924 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2925 (implicit EFLAGS)]>, OpSize;
2926 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2927 "test{l}\t{$src2, $src1|$src1, $src2}",
2928 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2929 (implicit EFLAGS)]>;
2931 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2932 (outs), (ins GR8:$src1, i8imm:$src2),
2933 "test{b}\t{$src2, $src1|$src1, $src2}",
2934 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2935 (implicit EFLAGS)]>;
2936 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2937 (outs), (ins GR16:$src1, i16imm:$src2),
2938 "test{w}\t{$src2, $src1|$src1, $src2}",
2939 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2940 (implicit EFLAGS)]>, OpSize;
2941 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2942 (outs), (ins GR32:$src1, i32imm:$src2),
2943 "test{l}\t{$src2, $src1|$src1, $src2}",
2944 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2945 (implicit EFLAGS)]>;
2947 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2948 (outs), (ins i8mem:$src1, i8imm:$src2),
2949 "test{b}\t{$src2, $src1|$src1, $src2}",
2950 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2951 (implicit EFLAGS)]>;
2952 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2953 (outs), (ins i16mem:$src1, i16imm:$src2),
2954 "test{w}\t{$src2, $src1|$src1, $src2}",
2955 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2956 (implicit EFLAGS)]>, OpSize;
2957 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2958 (outs), (ins i32mem:$src1, i32imm:$src2),
2959 "test{l}\t{$src2, $src1|$src1, $src2}",
2960 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2961 (implicit EFLAGS)]>;
2962 } // Defs = [EFLAGS]
2965 // Condition code ops, incl. set if equal/not equal/...
2966 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2967 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2968 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2969 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2971 let Uses = [EFLAGS] in {
2972 def SETEr : I<0x94, MRM0r,
2973 (outs GR8 :$dst), (ins),
2975 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2977 def SETEm : I<0x94, MRM0m,
2978 (outs), (ins i8mem:$dst),
2980 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2983 def SETNEr : I<0x95, MRM0r,
2984 (outs GR8 :$dst), (ins),
2986 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2988 def SETNEm : I<0x95, MRM0m,
2989 (outs), (ins i8mem:$dst),
2991 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2994 def SETLr : I<0x9C, MRM0r,
2995 (outs GR8 :$dst), (ins),
2997 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2998 TB; // GR8 = < signed
2999 def SETLm : I<0x9C, MRM0m,
3000 (outs), (ins i8mem:$dst),
3002 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
3003 TB; // [mem8] = < signed
3005 def SETGEr : I<0x9D, MRM0r,
3006 (outs GR8 :$dst), (ins),
3008 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
3009 TB; // GR8 = >= signed
3010 def SETGEm : I<0x9D, MRM0m,
3011 (outs), (ins i8mem:$dst),
3013 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
3014 TB; // [mem8] = >= signed
3016 def SETLEr : I<0x9E, MRM0r,
3017 (outs GR8 :$dst), (ins),
3019 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3020 TB; // GR8 = <= signed
3021 def SETLEm : I<0x9E, MRM0m,
3022 (outs), (ins i8mem:$dst),
3024 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3025 TB; // [mem8] = <= signed
3027 def SETGr : I<0x9F, MRM0r,
3028 (outs GR8 :$dst), (ins),
3030 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3031 TB; // GR8 = > signed
3032 def SETGm : I<0x9F, MRM0m,
3033 (outs), (ins i8mem:$dst),
3035 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3036 TB; // [mem8] = > signed
3038 def SETBr : I<0x92, MRM0r,
3039 (outs GR8 :$dst), (ins),
3041 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3042 TB; // GR8 = < unsign
3043 def SETBm : I<0x92, MRM0m,
3044 (outs), (ins i8mem:$dst),
3046 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3047 TB; // [mem8] = < unsign
3049 def SETAEr : I<0x93, MRM0r,
3050 (outs GR8 :$dst), (ins),
3052 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3053 TB; // GR8 = >= unsign
3054 def SETAEm : I<0x93, MRM0m,
3055 (outs), (ins i8mem:$dst),
3057 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3058 TB; // [mem8] = >= unsign
3060 def SETBEr : I<0x96, MRM0r,
3061 (outs GR8 :$dst), (ins),
3063 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3064 TB; // GR8 = <= unsign
3065 def SETBEm : I<0x96, MRM0m,
3066 (outs), (ins i8mem:$dst),
3068 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3069 TB; // [mem8] = <= unsign
3071 def SETAr : I<0x97, MRM0r,
3072 (outs GR8 :$dst), (ins),
3074 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3075 TB; // GR8 = > signed
3076 def SETAm : I<0x97, MRM0m,
3077 (outs), (ins i8mem:$dst),
3079 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3080 TB; // [mem8] = > signed
3082 def SETSr : I<0x98, MRM0r,
3083 (outs GR8 :$dst), (ins),
3085 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3086 TB; // GR8 = <sign bit>
3087 def SETSm : I<0x98, MRM0m,
3088 (outs), (ins i8mem:$dst),
3090 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3091 TB; // [mem8] = <sign bit>
3092 def SETNSr : I<0x99, MRM0r,
3093 (outs GR8 :$dst), (ins),
3095 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3096 TB; // GR8 = !<sign bit>
3097 def SETNSm : I<0x99, MRM0m,
3098 (outs), (ins i8mem:$dst),
3100 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3101 TB; // [mem8] = !<sign bit>
3103 def SETPr : I<0x9A, MRM0r,
3104 (outs GR8 :$dst), (ins),
3106 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3108 def SETPm : I<0x9A, MRM0m,
3109 (outs), (ins i8mem:$dst),
3111 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3112 TB; // [mem8] = parity
3113 def SETNPr : I<0x9B, MRM0r,
3114 (outs GR8 :$dst), (ins),
3116 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3117 TB; // GR8 = not parity
3118 def SETNPm : I<0x9B, MRM0m,
3119 (outs), (ins i8mem:$dst),
3121 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3122 TB; // [mem8] = not parity
3124 def SETOr : I<0x90, MRM0r,
3125 (outs GR8 :$dst), (ins),
3127 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3128 TB; // GR8 = overflow
3129 def SETOm : I<0x90, MRM0m,
3130 (outs), (ins i8mem:$dst),
3132 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3133 TB; // [mem8] = overflow
3134 def SETNOr : I<0x91, MRM0r,
3135 (outs GR8 :$dst), (ins),
3137 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3138 TB; // GR8 = not overflow
3139 def SETNOm : I<0x91, MRM0m,
3140 (outs), (ins i8mem:$dst),
3142 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3143 TB; // [mem8] = not overflow
3144 } // Uses = [EFLAGS]
3147 // Integer comparisons
3148 let Defs = [EFLAGS] in {
3149 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3150 "cmp{b}\t{$src, %al|%al, $src}", []>;
3151 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3152 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3153 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3154 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3156 def CMP8rr : I<0x38, MRMDestReg,
3157 (outs), (ins GR8 :$src1, GR8 :$src2),
3158 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3159 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
3160 def CMP16rr : I<0x39, MRMDestReg,
3161 (outs), (ins GR16:$src1, GR16:$src2),
3162 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3163 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
3164 def CMP32rr : I<0x39, MRMDestReg,
3165 (outs), (ins GR32:$src1, GR32:$src2),
3166 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3167 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
3168 def CMP8mr : I<0x38, MRMDestMem,
3169 (outs), (ins i8mem :$src1, GR8 :$src2),
3170 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3171 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3172 (implicit EFLAGS)]>;
3173 def CMP16mr : I<0x39, MRMDestMem,
3174 (outs), (ins i16mem:$src1, GR16:$src2),
3175 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3176 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3177 (implicit EFLAGS)]>, OpSize;
3178 def CMP32mr : I<0x39, MRMDestMem,
3179 (outs), (ins i32mem:$src1, GR32:$src2),
3180 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3181 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3182 (implicit EFLAGS)]>;
3183 def CMP8rm : I<0x3A, MRMSrcMem,
3184 (outs), (ins GR8 :$src1, i8mem :$src2),
3185 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3186 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3187 (implicit EFLAGS)]>;
3188 def CMP16rm : I<0x3B, MRMSrcMem,
3189 (outs), (ins GR16:$src1, i16mem:$src2),
3190 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3191 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3192 (implicit EFLAGS)]>, OpSize;
3193 def CMP32rm : I<0x3B, MRMSrcMem,
3194 (outs), (ins GR32:$src1, i32mem:$src2),
3195 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3196 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3197 (implicit EFLAGS)]>;
3198 def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3199 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3200 def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3201 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3202 def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3203 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3204 def CMP8ri : Ii8<0x80, MRM7r,
3205 (outs), (ins GR8:$src1, i8imm:$src2),
3206 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3207 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
3208 def CMP16ri : Ii16<0x81, MRM7r,
3209 (outs), (ins GR16:$src1, i16imm:$src2),
3210 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3211 [(X86cmp GR16:$src1, imm:$src2),
3212 (implicit EFLAGS)]>, OpSize;
3213 def CMP32ri : Ii32<0x81, MRM7r,
3214 (outs), (ins GR32:$src1, i32imm:$src2),
3215 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3216 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
3217 def CMP8mi : Ii8 <0x80, MRM7m,
3218 (outs), (ins i8mem :$src1, i8imm :$src2),
3219 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3220 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3221 (implicit EFLAGS)]>;
3222 def CMP16mi : Ii16<0x81, MRM7m,
3223 (outs), (ins i16mem:$src1, i16imm:$src2),
3224 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3225 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3226 (implicit EFLAGS)]>, OpSize;
3227 def CMP32mi : Ii32<0x81, MRM7m,
3228 (outs), (ins i32mem:$src1, i32imm:$src2),
3229 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3230 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3231 (implicit EFLAGS)]>;
3232 def CMP16ri8 : Ii8<0x83, MRM7r,
3233 (outs), (ins GR16:$src1, i16i8imm:$src2),
3234 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3235 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3236 (implicit EFLAGS)]>, OpSize;
3237 def CMP16mi8 : Ii8<0x83, MRM7m,
3238 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3239 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3240 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3241 (implicit EFLAGS)]>, OpSize;
3242 def CMP32mi8 : Ii8<0x83, MRM7m,
3243 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3244 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3245 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3246 (implicit EFLAGS)]>;
3247 def CMP32ri8 : Ii8<0x83, MRM7r,
3248 (outs), (ins GR32:$src1, i32i8imm:$src2),
3249 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3250 [(X86cmp GR32:$src1, i32immSExt8:$src2),
3251 (implicit EFLAGS)]>;
3252 } // Defs = [EFLAGS]
3255 // TODO: BTC, BTR, and BTS
3256 let Defs = [EFLAGS] in {
3257 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3258 "bt{w}\t{$src2, $src1|$src1, $src2}",
3259 [(X86bt GR16:$src1, GR16:$src2),
3260 (implicit EFLAGS)]>, OpSize, TB;
3261 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3262 "bt{l}\t{$src2, $src1|$src1, $src2}",
3263 [(X86bt GR32:$src1, GR32:$src2),
3264 (implicit EFLAGS)]>, TB;
3266 // Unlike with the register+register form, the memory+register form of the
3267 // bt instruction does not ignore the high bits of the index. From ISel's
3268 // perspective, this is pretty bizarre. Disable these instructions for now.
3269 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3270 // "bt{w}\t{$src2, $src1|$src1, $src2}",
3271 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3272 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3273 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3274 // "bt{l}\t{$src2, $src1|$src1, $src2}",
3275 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3276 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
3278 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3279 "bt{w}\t{$src2, $src1|$src1, $src2}",
3280 [(X86bt GR16:$src1, i16immSExt8:$src2),
3281 (implicit EFLAGS)]>, OpSize, TB;
3282 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3283 "bt{l}\t{$src2, $src1|$src1, $src2}",
3284 [(X86bt GR32:$src1, i32immSExt8:$src2),
3285 (implicit EFLAGS)]>, TB;
3286 // Note that these instructions don't need FastBTMem because that
3287 // only applies when the other operand is in a register. When it's
3288 // an immediate, bt is still fast.
3289 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3290 "bt{w}\t{$src2, $src1|$src1, $src2}",
3291 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3292 (implicit EFLAGS)]>, OpSize, TB;
3293 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3294 "bt{l}\t{$src2, $src1|$src1, $src2}",
3295 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3296 (implicit EFLAGS)]>, TB;
3297 } // Defs = [EFLAGS]
3299 // Sign/Zero extenders
3300 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3301 // of the register here. This has a smaller encoding and avoids a
3302 // partial-register update.
3303 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3304 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3305 [(set GR16:$dst, (sext GR8:$src))]>, TB;
3306 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3307 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3308 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3309 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3310 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3311 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3312 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3313 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3314 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3315 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3316 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3317 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3318 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3319 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3320 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3322 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3323 // of the register here. This has a smaller encoding and avoids a
3324 // partial-register update.
3325 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3326 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3327 [(set GR16:$dst, (zext GR8:$src))]>, TB;
3328 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3329 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3330 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3331 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3332 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3333 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3334 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3335 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3336 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3337 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3338 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3339 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3340 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3341 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3342 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3344 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3345 // except that they use GR32_NOREX for the output operand register class
3346 // instead of GR32. This allows them to operate on h registers on x86-64.
3347 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3348 (outs GR32_NOREX:$dst), (ins GR8:$src),
3349 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3352 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3353 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3354 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3357 let neverHasSideEffects = 1 in {
3358 let Defs = [AX], Uses = [AL] in
3359 def CBW : I<0x98, RawFrm, (outs), (ins),
3360 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3361 let Defs = [EAX], Uses = [AX] in
3362 def CWDE : I<0x98, RawFrm, (outs), (ins),
3363 "{cwtl|cwde}", []>; // EAX = signext(AX)
3365 let Defs = [AX,DX], Uses = [AX] in
3366 def CWD : I<0x99, RawFrm, (outs), (ins),
3367 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3368 let Defs = [EAX,EDX], Uses = [EAX] in
3369 def CDQ : I<0x99, RawFrm, (outs), (ins),
3370 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3373 //===----------------------------------------------------------------------===//
3374 // Alias Instructions
3375 //===----------------------------------------------------------------------===//
3377 // Alias instructions that map movr0 to xor.
3378 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3379 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3380 isCodeGenOnly = 1 in {
3381 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
3382 "xor{b}\t$dst, $dst",
3383 [(set GR8:$dst, 0)]>;
3384 // Use xorl instead of xorw since we don't care about the high 16 bits,
3385 // it's smaller, and it avoids a partial-register update.
3386 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3387 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3388 [(set GR16:$dst, 0)]>;
3389 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3390 "xor{l}\t$dst, $dst",
3391 [(set GR32:$dst, 0)]>;
3394 //===----------------------------------------------------------------------===//
3395 // Thread Local Storage Instructions
3398 // All calls clobber the non-callee saved registers. ESP is marked as
3399 // a use to prevent stack-pointer assignments that appear immediately
3400 // before calls from potentially appearing dead.
3401 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3402 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3403 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3404 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3406 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3407 "leal\t$sym, %eax; "
3408 "call\t___tls_get_addr@PLT",
3409 [(X86tlsaddr tls32addr:$sym)]>,
3410 Requires<[In32BitMode]>;
3412 let AddedComplexity = 5, isCodeGenOnly = 1 in
3413 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3414 "movl\t%gs:$src, $dst",
3415 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3417 let AddedComplexity = 5, isCodeGenOnly = 1 in
3418 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3419 "movl\t%fs:$src, $dst",
3420 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3422 //===----------------------------------------------------------------------===//
3423 // DWARF Pseudo Instructions
3426 def DWARF_LOC : I<0, Pseudo, (outs),
3427 (ins i32imm:$line, i32imm:$col, i32imm:$file),
3428 ".loc\t$file $line $col",
3429 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3432 //===----------------------------------------------------------------------===//
3433 // EH Pseudo Instructions
3435 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3436 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3437 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3438 "ret\t#eh_return, addr: $addr",
3439 [(X86ehret GR32:$addr)]>;
3443 //===----------------------------------------------------------------------===//
3447 // Atomic swap. These are just normal xchg instructions. But since a memory
3448 // operand is referenced, the atomicity is ensured.
3449 let Constraints = "$val = $dst" in {
3450 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3451 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3452 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3453 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3454 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3455 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3457 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3458 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3459 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3462 // Atomic compare and swap.
3463 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3464 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3466 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3467 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3469 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3470 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3473 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3476 let Defs = [AX, EFLAGS], Uses = [AX] in {
3477 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3479 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3480 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3482 let Defs = [AL, EFLAGS], Uses = [AL] in {
3483 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3485 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3486 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3489 // Atomic exchange and add
3490 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3491 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3493 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3494 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3496 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3498 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3499 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3501 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3503 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3504 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3508 // Optimized codegen when the non-memory output is not used.
3509 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3510 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3512 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3513 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3515 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3516 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3518 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3519 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3521 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3522 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3524 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3525 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3527 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3528 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3530 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3531 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3533 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3535 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3537 "inc{b}\t$dst", []>, LOCK;
3538 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3540 "inc{w}\t$dst", []>, OpSize, LOCK;
3541 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3543 "inc{l}\t$dst", []>, LOCK;
3545 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3547 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3548 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3550 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3551 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3553 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3554 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3556 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3557 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3559 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3560 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3562 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3563 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3565 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3566 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3568 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3570 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3572 "dec{b}\t$dst", []>, LOCK;
3573 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3575 "dec{w}\t$dst", []>, OpSize, LOCK;
3576 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3578 "dec{l}\t$dst", []>, LOCK;
3580 // Atomic exchange, and, or, xor
3581 let Constraints = "$val = $dst", Defs = [EFLAGS],
3582 usesCustomDAGSchedInserter = 1 in {
3583 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3584 "#ATOMAND32 PSEUDO!",
3585 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3586 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3587 "#ATOMOR32 PSEUDO!",
3588 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3589 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3590 "#ATOMXOR32 PSEUDO!",
3591 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3592 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3593 "#ATOMNAND32 PSEUDO!",
3594 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3595 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3596 "#ATOMMIN32 PSEUDO!",
3597 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3598 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3599 "#ATOMMAX32 PSEUDO!",
3600 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3601 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3602 "#ATOMUMIN32 PSEUDO!",
3603 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3604 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3605 "#ATOMUMAX32 PSEUDO!",
3606 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3608 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3609 "#ATOMAND16 PSEUDO!",
3610 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3611 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3612 "#ATOMOR16 PSEUDO!",
3613 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3614 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3615 "#ATOMXOR16 PSEUDO!",
3616 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3617 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3618 "#ATOMNAND16 PSEUDO!",
3619 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3620 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3621 "#ATOMMIN16 PSEUDO!",
3622 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3623 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3624 "#ATOMMAX16 PSEUDO!",
3625 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3626 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3627 "#ATOMUMIN16 PSEUDO!",
3628 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3629 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3630 "#ATOMUMAX16 PSEUDO!",
3631 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3633 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3634 "#ATOMAND8 PSEUDO!",
3635 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3636 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3638 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3639 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3640 "#ATOMXOR8 PSEUDO!",
3641 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3642 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3643 "#ATOMNAND8 PSEUDO!",
3644 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3647 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3648 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3649 Uses = [EAX, EBX, ECX, EDX],
3650 mayLoad = 1, mayStore = 1,
3651 usesCustomDAGSchedInserter = 1 in {
3652 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3653 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3654 "#ATOMAND6432 PSEUDO!", []>;
3655 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3656 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3657 "#ATOMOR6432 PSEUDO!", []>;
3658 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3659 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3660 "#ATOMXOR6432 PSEUDO!", []>;
3661 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3662 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3663 "#ATOMNAND6432 PSEUDO!", []>;
3664 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3665 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3666 "#ATOMADD6432 PSEUDO!", []>;
3667 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3668 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3669 "#ATOMSUB6432 PSEUDO!", []>;
3670 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3671 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3672 "#ATOMSWAP6432 PSEUDO!", []>;
3675 // Segmentation support instructions.
3677 def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
3678 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3679 def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
3680 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3682 // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
3683 def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3684 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
3685 def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
3686 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
3688 //===----------------------------------------------------------------------===//
3689 // Non-Instruction Patterns
3690 //===----------------------------------------------------------------------===//
3692 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3693 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3694 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3695 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3696 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3697 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3699 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3700 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3701 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3702 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3703 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3704 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3705 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3706 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3708 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3709 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3710 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3711 (MOV32mi addr:$dst, texternalsym:$src)>;
3715 def : Pat<(X86tcret GR32:$dst, imm:$off),
3716 (TCRETURNri GR32:$dst, imm:$off)>;
3718 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3719 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3721 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3722 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3724 // Normal calls, with various flavors of addresses.
3725 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3726 (CALLpcrel32 tglobaladdr:$dst)>;
3727 def : Pat<(X86call (i32 texternalsym:$dst)),
3728 (CALLpcrel32 texternalsym:$dst)>;
3729 def : Pat<(X86call (i32 imm:$dst)),
3730 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
3732 // X86 specific add which produces a flag.
3733 def : Pat<(addc GR32:$src1, GR32:$src2),
3734 (ADD32rr GR32:$src1, GR32:$src2)>;
3735 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3736 (ADD32rm GR32:$src1, addr:$src2)>;
3737 def : Pat<(addc GR32:$src1, imm:$src2),
3738 (ADD32ri GR32:$src1, imm:$src2)>;
3739 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3740 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3742 def : Pat<(subc GR32:$src1, GR32:$src2),
3743 (SUB32rr GR32:$src1, GR32:$src2)>;
3744 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3745 (SUB32rm GR32:$src1, addr:$src2)>;
3746 def : Pat<(subc GR32:$src1, imm:$src2),
3747 (SUB32ri GR32:$src1, imm:$src2)>;
3748 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3749 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3753 // TEST R,R is smaller than CMP R,0
3754 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3755 (TEST8rr GR8:$src1, GR8:$src1)>;
3756 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3757 (TEST16rr GR16:$src1, GR16:$src1)>;
3758 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3759 (TEST32rr GR32:$src1, GR32:$src1)>;
3761 // Conditional moves with folded loads with operands swapped and conditions
3763 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3764 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3765 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3766 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3767 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3768 (CMOVB16rm GR16:$src2, addr:$src1)>;
3769 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3770 (CMOVB32rm GR32:$src2, addr:$src1)>;
3771 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3772 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3773 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3774 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3775 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3776 (CMOVE16rm GR16:$src2, addr:$src1)>;
3777 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3778 (CMOVE32rm GR32:$src2, addr:$src1)>;
3779 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3780 (CMOVA16rm GR16:$src2, addr:$src1)>;
3781 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3782 (CMOVA32rm GR32:$src2, addr:$src1)>;
3783 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3784 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3785 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3786 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3787 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3788 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3789 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3790 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3791 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3792 (CMOVL16rm GR16:$src2, addr:$src1)>;
3793 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3794 (CMOVL32rm GR32:$src2, addr:$src1)>;
3795 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3796 (CMOVG16rm GR16:$src2, addr:$src1)>;
3797 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3798 (CMOVG32rm GR32:$src2, addr:$src1)>;
3799 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3800 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3801 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3802 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3803 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3804 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3805 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3806 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3807 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3808 (CMOVP16rm GR16:$src2, addr:$src1)>;
3809 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3810 (CMOVP32rm GR32:$src2, addr:$src1)>;
3811 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3812 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3813 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3814 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3815 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3816 (CMOVS16rm GR16:$src2, addr:$src1)>;
3817 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3818 (CMOVS32rm GR32:$src2, addr:$src1)>;
3819 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3820 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3821 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3822 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3823 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3824 (CMOVO16rm GR16:$src2, addr:$src1)>;
3825 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3826 (CMOVO32rm GR32:$src2, addr:$src1)>;
3828 // zextload bool -> zextload byte
3829 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3830 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3831 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3833 // extload bool -> extload byte
3834 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3835 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3836 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3837 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
3838 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3839 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3841 // anyext. Define these to do an explicit zero-extend to
3842 // avoid partial-register updates.
3843 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3844 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3845 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
3847 // (and (i32 load), 255) -> (zextload i8)
3848 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3849 (MOVZX32rm8 addr:$src)>;
3850 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3851 (MOVZX32rm16 addr:$src)>;
3853 //===----------------------------------------------------------------------===//
3855 //===----------------------------------------------------------------------===//
3857 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3858 // +128 doesn't, so in this special case use a sub instead of an add.
3859 def : Pat<(add GR16:$src1, 128),
3860 (SUB16ri8 GR16:$src1, -128)>;
3861 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3862 (SUB16mi8 addr:$dst, -128)>;
3863 def : Pat<(add GR32:$src1, 128),
3864 (SUB32ri8 GR32:$src1, -128)>;
3865 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3866 (SUB32mi8 addr:$dst, -128)>;
3868 // r & (2^16-1) ==> movz
3869 def : Pat<(and GR32:$src1, 0xffff),
3870 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
3871 // r & (2^8-1) ==> movz
3872 def : Pat<(and GR32:$src1, 0xff),
3873 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
3875 Requires<[In32BitMode]>;
3876 // r & (2^8-1) ==> movz
3877 def : Pat<(and GR16:$src1, 0xff),
3878 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
3880 Requires<[In32BitMode]>;
3882 // sext_inreg patterns
3883 def : Pat<(sext_inreg GR32:$src, i16),
3884 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3885 def : Pat<(sext_inreg GR32:$src, i8),
3886 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3888 Requires<[In32BitMode]>;
3889 def : Pat<(sext_inreg GR16:$src, i8),
3890 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3892 Requires<[In32BitMode]>;
3895 def : Pat<(i16 (trunc GR32:$src)),
3896 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
3897 def : Pat<(i8 (trunc GR32:$src)),
3898 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3900 Requires<[In32BitMode]>;
3901 def : Pat<(i8 (trunc GR16:$src)),
3902 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3904 Requires<[In32BitMode]>;
3906 // h-register tricks
3907 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
3908 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3909 x86_subreg_8bit_hi)>,
3910 Requires<[In32BitMode]>;
3911 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
3912 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3913 x86_subreg_8bit_hi)>,
3914 Requires<[In32BitMode]>;
3915 def : Pat<(srl_su GR16:$src, (i8 8)),
3918 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3919 x86_subreg_8bit_hi)),
3921 Requires<[In32BitMode]>;
3922 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3923 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3924 x86_subreg_8bit_hi))>,
3925 Requires<[In32BitMode]>;
3926 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3927 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3928 x86_subreg_8bit_hi))>,
3929 Requires<[In32BitMode]>;
3930 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
3931 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3932 x86_subreg_8bit_hi))>,
3933 Requires<[In32BitMode]>;
3935 // (shl x, 1) ==> (add x, x)
3936 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3937 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3938 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3940 // (shl x (and y, 31)) ==> (shl x, y)
3941 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3942 (SHL8rCL GR8:$src1)>;
3943 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3944 (SHL16rCL GR16:$src1)>;
3945 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3946 (SHL32rCL GR32:$src1)>;
3947 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3948 (SHL8mCL addr:$dst)>;
3949 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3950 (SHL16mCL addr:$dst)>;
3951 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3952 (SHL32mCL addr:$dst)>;
3954 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3955 (SHR8rCL GR8:$src1)>;
3956 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3957 (SHR16rCL GR16:$src1)>;
3958 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3959 (SHR32rCL GR32:$src1)>;
3960 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3961 (SHR8mCL addr:$dst)>;
3962 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3963 (SHR16mCL addr:$dst)>;
3964 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3965 (SHR32mCL addr:$dst)>;
3967 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3968 (SAR8rCL GR8:$src1)>;
3969 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3970 (SAR16rCL GR16:$src1)>;
3971 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3972 (SAR32rCL GR32:$src1)>;
3973 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3974 (SAR8mCL addr:$dst)>;
3975 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3976 (SAR16mCL addr:$dst)>;
3977 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3978 (SAR32mCL addr:$dst)>;
3980 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3981 def : Pat<(or (srl GR32:$src1, CL:$amt),
3982 (shl GR32:$src2, (sub 32, CL:$amt))),
3983 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3985 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3986 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3987 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3989 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3990 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3991 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3993 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3994 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3996 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3998 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3999 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4001 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4002 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4003 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4005 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4006 def : Pat<(or (shl GR32:$src1, CL:$amt),
4007 (srl GR32:$src2, (sub 32, CL:$amt))),
4008 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4010 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4011 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4012 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4014 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4015 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4016 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4018 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4019 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4021 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4023 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4024 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4026 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4027 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4028 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4030 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4031 def : Pat<(or (srl GR16:$src1, CL:$amt),
4032 (shl GR16:$src2, (sub 16, CL:$amt))),
4033 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4035 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4036 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4037 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4039 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4040 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4041 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4043 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4044 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4046 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4048 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4049 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4051 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4052 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4053 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4055 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4056 def : Pat<(or (shl GR16:$src1, CL:$amt),
4057 (srl GR16:$src2, (sub 16, CL:$amt))),
4058 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4060 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4061 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4062 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4064 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4065 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4066 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4068 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4069 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4071 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4073 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4074 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4076 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4077 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4078 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4080 //===----------------------------------------------------------------------===//
4081 // EFLAGS-defining Patterns
4082 //===----------------------------------------------------------------------===//
4084 // Register-Register Addition with EFLAGS result
4085 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
4087 (ADD8rr GR8:$src1, GR8:$src2)>;
4088 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
4090 (ADD16rr GR16:$src1, GR16:$src2)>;
4091 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
4093 (ADD32rr GR32:$src1, GR32:$src2)>;
4095 // Register-Memory Addition with EFLAGS result
4096 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
4098 (ADD8rm GR8:$src1, addr:$src2)>;
4099 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
4101 (ADD16rm GR16:$src1, addr:$src2)>;
4102 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
4104 (ADD32rm GR32:$src1, addr:$src2)>;
4106 // Register-Integer Addition with EFLAGS result
4107 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
4109 (ADD8ri GR8:$src1, imm:$src2)>;
4110 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
4112 (ADD16ri GR16:$src1, imm:$src2)>;
4113 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
4115 (ADD32ri GR32:$src1, imm:$src2)>;
4116 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
4118 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4119 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
4121 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4123 // Memory-Register Addition with EFLAGS result
4124 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
4127 (ADD8mr addr:$dst, GR8:$src2)>;
4128 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
4131 (ADD16mr addr:$dst, GR16:$src2)>;
4132 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
4135 (ADD32mr addr:$dst, GR32:$src2)>;
4137 // Memory-Integer Addition with EFLAGS result
4138 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
4141 (ADD8mi addr:$dst, imm:$src2)>;
4142 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
4145 (ADD16mi addr:$dst, imm:$src2)>;
4146 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
4149 (ADD32mi addr:$dst, imm:$src2)>;
4150 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4153 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
4154 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4157 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4159 // Register-Register Subtraction with EFLAGS result
4160 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
4162 (SUB8rr GR8:$src1, GR8:$src2)>;
4163 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
4165 (SUB16rr GR16:$src1, GR16:$src2)>;
4166 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
4168 (SUB32rr GR32:$src1, GR32:$src2)>;
4170 // Register-Memory Subtraction with EFLAGS result
4171 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
4173 (SUB8rm GR8:$src1, addr:$src2)>;
4174 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
4176 (SUB16rm GR16:$src1, addr:$src2)>;
4177 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
4179 (SUB32rm GR32:$src1, addr:$src2)>;
4181 // Register-Integer Subtraction with EFLAGS result
4182 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
4184 (SUB8ri GR8:$src1, imm:$src2)>;
4185 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
4187 (SUB16ri GR16:$src1, imm:$src2)>;
4188 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
4190 (SUB32ri GR32:$src1, imm:$src2)>;
4191 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
4193 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4194 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
4196 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4198 // Memory-Register Subtraction with EFLAGS result
4199 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
4202 (SUB8mr addr:$dst, GR8:$src2)>;
4203 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
4206 (SUB16mr addr:$dst, GR16:$src2)>;
4207 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
4210 (SUB32mr addr:$dst, GR32:$src2)>;
4212 // Memory-Integer Subtraction with EFLAGS result
4213 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
4216 (SUB8mi addr:$dst, imm:$src2)>;
4217 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
4220 (SUB16mi addr:$dst, imm:$src2)>;
4221 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
4224 (SUB32mi addr:$dst, imm:$src2)>;
4225 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4228 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
4229 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4232 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4235 // Register-Register Signed Integer Multiply with EFLAGS result
4236 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
4238 (IMUL16rr GR16:$src1, GR16:$src2)>;
4239 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
4241 (IMUL32rr GR32:$src1, GR32:$src2)>;
4243 // Register-Memory Signed Integer Multiply with EFLAGS result
4244 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
4246 (IMUL16rm GR16:$src1, addr:$src2)>;
4247 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
4249 (IMUL32rm GR32:$src1, addr:$src2)>;
4251 // Register-Integer Signed Integer Multiply with EFLAGS result
4252 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
4254 (IMUL16rri GR16:$src1, imm:$src2)>;
4255 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
4257 (IMUL32rri GR32:$src1, imm:$src2)>;
4258 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
4260 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4261 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
4263 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4265 // Memory-Integer Signed Integer Multiply with EFLAGS result
4266 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
4268 (IMUL16rmi addr:$src1, imm:$src2)>;
4269 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
4271 (IMUL32rmi addr:$src1, imm:$src2)>;
4272 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
4274 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4275 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
4277 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4279 // Optimize multiply by 2 with EFLAGS result.
4280 let AddedComplexity = 2 in {
4281 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
4283 (ADD16rr GR16:$src1, GR16:$src1)>;
4285 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
4287 (ADD32rr GR32:$src1, GR32:$src1)>;
4290 // INC and DEC with EFLAGS result. Note that these do not set CF.
4291 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4293 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4296 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4298 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4302 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
4303 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4304 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4306 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
4307 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
4308 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4309 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4311 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
4313 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
4314 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4315 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4317 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
4318 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
4319 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4320 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4322 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
4324 // -disable-16bit support.
4325 def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
4326 (MOV16mi addr:$dst, imm:$src)>;
4327 def : Pat<(truncstorei16 GR32:$src, addr:$dst),
4328 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4329 def : Pat<(i32 (sextloadi16 addr:$dst)),
4330 (MOVSX32rm16 addr:$dst)>;
4331 def : Pat<(i32 (zextloadi16 addr:$dst)),
4332 (MOVZX32rm16 addr:$dst)>;
4333 def : Pat<(i32 (extloadi16 addr:$dst)),
4334 (MOVZX32rm16 addr:$dst)>;
4336 //===----------------------------------------------------------------------===//
4337 // Floating Point Stack Support
4338 //===----------------------------------------------------------------------===//
4340 include "X86InstrFPStack.td"
4342 //===----------------------------------------------------------------------===//
4344 //===----------------------------------------------------------------------===//
4346 include "X86Instr64bit.td"
4348 //===----------------------------------------------------------------------===//
4349 // XMM Floating point support (requires SSE / SSE2)
4350 //===----------------------------------------------------------------------===//
4352 include "X86InstrSSE.td"
4354 //===----------------------------------------------------------------------===//
4355 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4356 //===----------------------------------------------------------------------===//
4358 include "X86InstrMMX.td"