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;
663 //===----------------------------------------------------------------------===//
664 // Call Instructions...
667 // All calls clobber the non-callee saved registers. ESP is marked as
668 // a use to prevent stack-pointer assignments that appear immediately
669 // before calls from potentially appearing dead. Uses for argument
670 // registers are added manually.
671 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
672 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
673 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
674 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
676 def CALLpcrel32 : Ii32<0xE8, RawFrm,
677 (outs), (ins i32imm_pcrel:$dst,variable_ops),
679 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
680 "call\t{*}$dst", [(X86call GR32:$dst)]>;
681 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
682 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
684 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
685 (ins i16imm:$seg, i16imm:$off),
686 "lcall{w}\t$seg, $off", []>, OpSize;
687 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
688 (ins i16imm:$seg, i32imm:$off),
689 "lcall{l}\t$seg, $off", []>;
691 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
692 "lcall{w}\t{*}$dst", []>, OpSize;
693 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
694 "lcall{l}\t{*}$dst", []>;
699 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
700 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
701 "#TC_RETURN $dst $offset",
704 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
705 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
706 "#TC_RETURN $dst $offset",
709 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
711 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
713 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
714 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
716 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
717 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
718 "jmp\t{*}$dst # TAILCALL", []>;
720 //===----------------------------------------------------------------------===//
721 // Miscellaneous Instructions...
723 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
724 def LEAVE : I<0xC9, RawFrm,
725 (outs), (ins), "leave", []>;
727 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
729 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
731 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
732 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
734 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
736 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
737 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
740 let mayStore = 1 in {
741 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
743 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
744 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
746 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
748 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
749 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
753 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
754 def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
755 "push{l}\t$imm", []>;
756 def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
757 "push{l}\t$imm", []>;
758 def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
759 "push{l}\t$imm", []>;
762 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
763 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
764 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
765 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
767 let isTwoAddress = 1 in // GR32 = bswap GR32
768 def BSWAP32r : I<0xC8, AddRegFrm,
769 (outs GR32:$dst), (ins GR32:$src),
771 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
774 // Bit scan instructions.
775 let Defs = [EFLAGS] in {
776 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
777 "bsf{w}\t{$src, $dst|$dst, $src}",
778 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
779 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
780 "bsf{w}\t{$src, $dst|$dst, $src}",
781 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
782 (implicit EFLAGS)]>, TB;
783 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
784 "bsf{l}\t{$src, $dst|$dst, $src}",
785 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
786 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
787 "bsf{l}\t{$src, $dst|$dst, $src}",
788 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
789 (implicit EFLAGS)]>, TB;
791 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
792 "bsr{w}\t{$src, $dst|$dst, $src}",
793 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
794 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
795 "bsr{w}\t{$src, $dst|$dst, $src}",
796 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
797 (implicit EFLAGS)]>, TB;
798 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
799 "bsr{l}\t{$src, $dst|$dst, $src}",
800 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
801 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
802 "bsr{l}\t{$src, $dst|$dst, $src}",
803 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
804 (implicit EFLAGS)]>, TB;
807 let neverHasSideEffects = 1 in
808 def LEA16r : I<0x8D, MRMSrcMem,
809 (outs GR16:$dst), (ins i32mem:$src),
810 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
811 let isReMaterializable = 1 in
812 def LEA32r : I<0x8D, MRMSrcMem,
813 (outs GR32:$dst), (ins lea32mem:$src),
814 "lea{l}\t{$src|$dst}, {$dst|$src}",
815 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
817 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
818 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
819 [(X86rep_movs i8)]>, REP;
820 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
821 [(X86rep_movs i16)]>, REP, OpSize;
822 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
823 [(X86rep_movs i32)]>, REP;
826 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
827 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
828 [(X86rep_stos i8)]>, REP;
829 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
830 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
831 [(X86rep_stos i16)]>, REP, OpSize;
832 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
833 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
834 [(X86rep_stos i32)]>, REP;
836 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
837 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
838 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
840 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
841 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
842 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
844 let Defs = [RAX, RDX] in
845 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
848 let isBarrier = 1, hasCtrlDep = 1 in {
849 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
852 def SYSCALL : I<0x05, RawFrm,
853 (outs), (ins), "syscall", []>, TB;
854 def SYSRET : I<0x07, RawFrm,
855 (outs), (ins), "sysret", []>, TB;
856 def SYSENTER : I<0x34, RawFrm,
857 (outs), (ins), "sysenter", []>, TB;
858 def SYSEXIT : I<0x35, RawFrm,
859 (outs), (ins), "sysexit", []>, TB;
861 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
864 //===----------------------------------------------------------------------===//
865 // Input/Output Instructions...
867 let Defs = [AL], Uses = [DX] in
868 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
869 "in{b}\t{%dx, %al|%AL, %DX}", []>;
870 let Defs = [AX], Uses = [DX] in
871 def IN16rr : I<0xED, RawFrm, (outs), (ins),
872 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
873 let Defs = [EAX], Uses = [DX] in
874 def IN32rr : I<0xED, RawFrm, (outs), (ins),
875 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
878 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
879 "in{b}\t{$port, %al|%AL, $port}", []>;
881 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
882 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
884 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
885 "in{l}\t{$port, %eax|%EAX, $port}", []>;
887 let Uses = [DX, AL] in
888 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
889 "out{b}\t{%al, %dx|%DX, %AL}", []>;
890 let Uses = [DX, AX] in
891 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
892 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
893 let Uses = [DX, EAX] in
894 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
895 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
898 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
899 "out{b}\t{%al, $port|$port, %AL}", []>;
901 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
902 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
904 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
905 "out{l}\t{%eax, $port|$port, %EAX}", []>;
907 //===----------------------------------------------------------------------===//
908 // Move Instructions...
910 let neverHasSideEffects = 1 in {
911 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
912 "mov{b}\t{$src, $dst|$dst, $src}", []>;
913 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
914 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
915 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
916 "mov{l}\t{$src, $dst|$dst, $src}", []>;
918 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
919 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
920 "mov{b}\t{$src, $dst|$dst, $src}",
921 [(set GR8:$dst, imm:$src)]>;
922 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
923 "mov{w}\t{$src, $dst|$dst, $src}",
924 [(set GR16:$dst, imm:$src)]>, OpSize;
925 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
926 "mov{l}\t{$src, $dst|$dst, $src}",
927 [(set GR32:$dst, imm:$src)]>;
929 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
930 "mov{b}\t{$src, $dst|$dst, $src}",
931 [(store (i8 imm:$src), addr:$dst)]>;
932 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
933 "mov{w}\t{$src, $dst|$dst, $src}",
934 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
935 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
936 "mov{l}\t{$src, $dst|$dst, $src}",
937 [(store (i32 imm:$src), addr:$dst)]>;
939 def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins i8imm:$src),
940 "mov{b}\t{$src, %al|%al, $src}", []>;
941 def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins i16imm:$src),
942 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
943 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins i32imm:$src),
944 "mov{l}\t{$src, %eax|%eax, $src}", []>;
946 def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs i8imm:$dst), (ins),
947 "mov{b}\t{%al, $dst|$dst, %al}", []>;
948 def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs i16imm:$dst), (ins),
949 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
950 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs i32imm:$dst), (ins),
951 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
953 // Moves to and from segment registers
954 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
955 "mov{w}\t{$src, $dst|$dst, $src}", []>;
956 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
957 "mov{w}\t{$src, $dst|$dst, $src}", []>;
958 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
959 "mov{w}\t{$src, $dst|$dst, $src}", []>;
960 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
961 "mov{w}\t{$src, $dst|$dst, $src}", []>;
963 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
964 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
965 "mov{b}\t{$src, $dst|$dst, $src}",
966 [(set GR8:$dst, (loadi8 addr:$src))]>;
967 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
968 "mov{w}\t{$src, $dst|$dst, $src}",
969 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
970 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
971 "mov{l}\t{$src, $dst|$dst, $src}",
972 [(set GR32:$dst, (loadi32 addr:$src))]>;
975 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
976 "mov{b}\t{$src, $dst|$dst, $src}",
977 [(store GR8:$src, addr:$dst)]>;
978 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
979 "mov{w}\t{$src, $dst|$dst, $src}",
980 [(store GR16:$src, addr:$dst)]>, OpSize;
981 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
982 "mov{l}\t{$src, $dst|$dst, $src}",
983 [(store GR32:$src, addr:$dst)]>;
985 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
986 // that they can be used for copying and storing h registers, which can't be
987 // encoded when a REX prefix is present.
988 let neverHasSideEffects = 1 in
989 def MOV8rr_NOREX : I<0x88, MRMDestReg,
990 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
991 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
993 def MOV8mr_NOREX : I<0x88, MRMDestMem,
994 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
995 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
997 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
998 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
999 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1000 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1002 //===----------------------------------------------------------------------===//
1003 // Fixed-Register Multiplication and Division Instructions...
1006 // Extra precision multiplication
1007 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1008 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
1009 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1010 // This probably ought to be moved to a def : Pat<> if the
1011 // syntax can be accepted.
1012 [(set AL, (mul AL, GR8:$src)),
1013 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1015 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1016 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1018 []>, OpSize; // AX,DX = AX*GR16
1020 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1021 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1023 []>; // EAX,EDX = EAX*GR32
1025 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1026 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1028 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1029 // This probably ought to be moved to a def : Pat<> if the
1030 // syntax can be accepted.
1031 [(set AL, (mul AL, (loadi8 addr:$src))),
1032 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1034 let mayLoad = 1, neverHasSideEffects = 1 in {
1035 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1036 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1038 []>, OpSize; // AX,DX = AX*[mem16]
1040 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1041 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1043 []>; // EAX,EDX = EAX*[mem32]
1046 let neverHasSideEffects = 1 in {
1047 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1048 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1050 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1051 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
1052 OpSize; // AX,DX = AX*GR16
1053 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1054 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1055 // EAX,EDX = EAX*GR32
1056 let mayLoad = 1 in {
1057 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1058 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1059 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
1060 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1061 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1062 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1063 let Defs = [EAX,EDX], Uses = [EAX] in
1064 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1065 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
1067 } // neverHasSideEffects
1069 // unsigned division/remainder
1070 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1071 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1072 "div{b}\t$src", []>;
1073 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1074 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1075 "div{w}\t$src", []>, OpSize;
1076 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1077 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1078 "div{l}\t$src", []>;
1079 let mayLoad = 1 in {
1080 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1081 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1082 "div{b}\t$src", []>;
1083 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1084 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1085 "div{w}\t$src", []>, OpSize;
1086 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1087 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
1088 "div{l}\t$src", []>;
1091 // Signed division/remainder.
1092 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1093 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1094 "idiv{b}\t$src", []>;
1095 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1096 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1097 "idiv{w}\t$src", []>, OpSize;
1098 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1099 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1100 "idiv{l}\t$src", []>;
1101 let mayLoad = 1, mayLoad = 1 in {
1102 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1103 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1104 "idiv{b}\t$src", []>;
1105 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1106 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1107 "idiv{w}\t$src", []>, OpSize;
1108 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1109 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
1110 "idiv{l}\t$src", []>;
1113 //===----------------------------------------------------------------------===//
1114 // Two address Instructions.
1116 let isTwoAddress = 1 in {
1118 // Conditional moves
1119 let Uses = [EFLAGS] in {
1121 // X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1122 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1123 // however that requires promoting the operands, and can induce additional
1124 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1125 // clobber EFLAGS, because if one of the operands is zero, the expansion
1126 // could involve an xor.
1127 let usesCustomDAGSchedInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
1128 def CMOV_GR8 : I<0, Pseudo,
1129 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1130 "#CMOV_GR8 PSEUDO!",
1131 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1132 imm:$cond, EFLAGS))]>;
1134 let isCommutable = 1 in {
1135 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1136 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1137 "cmovb\t{$src2, $dst|$dst, $src2}",
1138 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1139 X86_COND_B, EFLAGS))]>,
1141 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1142 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1143 "cmovb\t{$src2, $dst|$dst, $src2}",
1144 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1145 X86_COND_B, EFLAGS))]>,
1147 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1148 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1149 "cmovae\t{$src2, $dst|$dst, $src2}",
1150 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1151 X86_COND_AE, EFLAGS))]>,
1153 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1154 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1155 "cmovae\t{$src2, $dst|$dst, $src2}",
1156 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1157 X86_COND_AE, EFLAGS))]>,
1159 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1160 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1161 "cmove\t{$src2, $dst|$dst, $src2}",
1162 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1163 X86_COND_E, EFLAGS))]>,
1165 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1166 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1167 "cmove\t{$src2, $dst|$dst, $src2}",
1168 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1169 X86_COND_E, EFLAGS))]>,
1171 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1172 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1173 "cmovne\t{$src2, $dst|$dst, $src2}",
1174 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1175 X86_COND_NE, EFLAGS))]>,
1177 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1178 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1179 "cmovne\t{$src2, $dst|$dst, $src2}",
1180 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1181 X86_COND_NE, EFLAGS))]>,
1183 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1184 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1185 "cmovbe\t{$src2, $dst|$dst, $src2}",
1186 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1187 X86_COND_BE, EFLAGS))]>,
1189 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1190 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1191 "cmovbe\t{$src2, $dst|$dst, $src2}",
1192 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1193 X86_COND_BE, EFLAGS))]>,
1195 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1196 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1197 "cmova\t{$src2, $dst|$dst, $src2}",
1198 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1199 X86_COND_A, EFLAGS))]>,
1201 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1202 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1203 "cmova\t{$src2, $dst|$dst, $src2}",
1204 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1205 X86_COND_A, EFLAGS))]>,
1207 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1208 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1209 "cmovl\t{$src2, $dst|$dst, $src2}",
1210 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1211 X86_COND_L, EFLAGS))]>,
1213 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1214 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1215 "cmovl\t{$src2, $dst|$dst, $src2}",
1216 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1217 X86_COND_L, EFLAGS))]>,
1219 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1220 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1221 "cmovge\t{$src2, $dst|$dst, $src2}",
1222 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1223 X86_COND_GE, EFLAGS))]>,
1225 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1226 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1227 "cmovge\t{$src2, $dst|$dst, $src2}",
1228 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1229 X86_COND_GE, EFLAGS))]>,
1231 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1232 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1233 "cmovle\t{$src2, $dst|$dst, $src2}",
1234 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1235 X86_COND_LE, EFLAGS))]>,
1237 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1238 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1239 "cmovle\t{$src2, $dst|$dst, $src2}",
1240 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1241 X86_COND_LE, EFLAGS))]>,
1243 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1244 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1245 "cmovg\t{$src2, $dst|$dst, $src2}",
1246 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1247 X86_COND_G, EFLAGS))]>,
1249 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1250 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1251 "cmovg\t{$src2, $dst|$dst, $src2}",
1252 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1253 X86_COND_G, EFLAGS))]>,
1255 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1256 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1257 "cmovs\t{$src2, $dst|$dst, $src2}",
1258 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1259 X86_COND_S, EFLAGS))]>,
1261 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1262 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1263 "cmovs\t{$src2, $dst|$dst, $src2}",
1264 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1265 X86_COND_S, EFLAGS))]>,
1267 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1268 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1269 "cmovns\t{$src2, $dst|$dst, $src2}",
1270 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1271 X86_COND_NS, EFLAGS))]>,
1273 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1274 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1275 "cmovns\t{$src2, $dst|$dst, $src2}",
1276 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1277 X86_COND_NS, EFLAGS))]>,
1279 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1280 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1281 "cmovp\t{$src2, $dst|$dst, $src2}",
1282 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1283 X86_COND_P, EFLAGS))]>,
1285 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1286 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1287 "cmovp\t{$src2, $dst|$dst, $src2}",
1288 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1289 X86_COND_P, EFLAGS))]>,
1291 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1292 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1293 "cmovnp\t{$src2, $dst|$dst, $src2}",
1294 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1295 X86_COND_NP, EFLAGS))]>,
1297 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1298 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1299 "cmovnp\t{$src2, $dst|$dst, $src2}",
1300 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1301 X86_COND_NP, EFLAGS))]>,
1303 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1304 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1305 "cmovo\t{$src2, $dst|$dst, $src2}",
1306 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1307 X86_COND_O, EFLAGS))]>,
1309 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1310 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1311 "cmovo\t{$src2, $dst|$dst, $src2}",
1312 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1313 X86_COND_O, EFLAGS))]>,
1315 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1316 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1317 "cmovno\t{$src2, $dst|$dst, $src2}",
1318 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1319 X86_COND_NO, EFLAGS))]>,
1321 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1322 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1323 "cmovno\t{$src2, $dst|$dst, $src2}",
1324 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1325 X86_COND_NO, EFLAGS))]>,
1327 } // isCommutable = 1
1329 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1330 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1331 "cmovb\t{$src2, $dst|$dst, $src2}",
1332 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1333 X86_COND_B, EFLAGS))]>,
1335 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1336 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1337 "cmovb\t{$src2, $dst|$dst, $src2}",
1338 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1339 X86_COND_B, EFLAGS))]>,
1341 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1342 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1343 "cmovae\t{$src2, $dst|$dst, $src2}",
1344 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1345 X86_COND_AE, EFLAGS))]>,
1347 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1348 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1349 "cmovae\t{$src2, $dst|$dst, $src2}",
1350 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1351 X86_COND_AE, EFLAGS))]>,
1353 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1354 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1355 "cmove\t{$src2, $dst|$dst, $src2}",
1356 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1357 X86_COND_E, EFLAGS))]>,
1359 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1360 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1361 "cmove\t{$src2, $dst|$dst, $src2}",
1362 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1363 X86_COND_E, EFLAGS))]>,
1365 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1366 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1367 "cmovne\t{$src2, $dst|$dst, $src2}",
1368 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1369 X86_COND_NE, EFLAGS))]>,
1371 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1372 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1373 "cmovne\t{$src2, $dst|$dst, $src2}",
1374 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1375 X86_COND_NE, EFLAGS))]>,
1377 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1378 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1379 "cmovbe\t{$src2, $dst|$dst, $src2}",
1380 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1381 X86_COND_BE, EFLAGS))]>,
1383 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1384 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1385 "cmovbe\t{$src2, $dst|$dst, $src2}",
1386 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1387 X86_COND_BE, EFLAGS))]>,
1389 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1390 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1391 "cmova\t{$src2, $dst|$dst, $src2}",
1392 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1393 X86_COND_A, EFLAGS))]>,
1395 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1396 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1397 "cmova\t{$src2, $dst|$dst, $src2}",
1398 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1399 X86_COND_A, EFLAGS))]>,
1401 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1402 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1403 "cmovl\t{$src2, $dst|$dst, $src2}",
1404 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1405 X86_COND_L, EFLAGS))]>,
1407 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1408 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1409 "cmovl\t{$src2, $dst|$dst, $src2}",
1410 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1411 X86_COND_L, EFLAGS))]>,
1413 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1414 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1415 "cmovge\t{$src2, $dst|$dst, $src2}",
1416 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1417 X86_COND_GE, EFLAGS))]>,
1419 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1420 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1421 "cmovge\t{$src2, $dst|$dst, $src2}",
1422 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1423 X86_COND_GE, EFLAGS))]>,
1425 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1426 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1427 "cmovle\t{$src2, $dst|$dst, $src2}",
1428 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1429 X86_COND_LE, EFLAGS))]>,
1431 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1432 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1433 "cmovle\t{$src2, $dst|$dst, $src2}",
1434 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1435 X86_COND_LE, EFLAGS))]>,
1437 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1438 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1439 "cmovg\t{$src2, $dst|$dst, $src2}",
1440 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1441 X86_COND_G, EFLAGS))]>,
1443 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1444 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1445 "cmovg\t{$src2, $dst|$dst, $src2}",
1446 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1447 X86_COND_G, EFLAGS))]>,
1449 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1450 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1451 "cmovs\t{$src2, $dst|$dst, $src2}",
1452 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1453 X86_COND_S, EFLAGS))]>,
1455 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1456 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1457 "cmovs\t{$src2, $dst|$dst, $src2}",
1458 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1459 X86_COND_S, EFLAGS))]>,
1461 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1462 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1463 "cmovns\t{$src2, $dst|$dst, $src2}",
1464 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1465 X86_COND_NS, EFLAGS))]>,
1467 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1468 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1469 "cmovns\t{$src2, $dst|$dst, $src2}",
1470 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1471 X86_COND_NS, EFLAGS))]>,
1473 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1474 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1475 "cmovp\t{$src2, $dst|$dst, $src2}",
1476 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1477 X86_COND_P, EFLAGS))]>,
1479 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1480 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1481 "cmovp\t{$src2, $dst|$dst, $src2}",
1482 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1483 X86_COND_P, EFLAGS))]>,
1485 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1486 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1487 "cmovnp\t{$src2, $dst|$dst, $src2}",
1488 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1489 X86_COND_NP, EFLAGS))]>,
1491 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1492 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1493 "cmovnp\t{$src2, $dst|$dst, $src2}",
1494 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1495 X86_COND_NP, EFLAGS))]>,
1497 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1498 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1499 "cmovo\t{$src2, $dst|$dst, $src2}",
1500 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1501 X86_COND_O, EFLAGS))]>,
1503 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1504 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1505 "cmovo\t{$src2, $dst|$dst, $src2}",
1506 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1507 X86_COND_O, EFLAGS))]>,
1509 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1510 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1511 "cmovno\t{$src2, $dst|$dst, $src2}",
1512 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1513 X86_COND_NO, EFLAGS))]>,
1515 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1516 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1517 "cmovno\t{$src2, $dst|$dst, $src2}",
1518 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1519 X86_COND_NO, EFLAGS))]>,
1521 } // Uses = [EFLAGS]
1524 // unary instructions
1525 let CodeSize = 2 in {
1526 let Defs = [EFLAGS] in {
1527 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1528 [(set GR8:$dst, (ineg GR8:$src)),
1529 (implicit EFLAGS)]>;
1530 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1531 [(set GR16:$dst, (ineg GR16:$src)),
1532 (implicit EFLAGS)]>, OpSize;
1533 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1534 [(set GR32:$dst, (ineg GR32:$src)),
1535 (implicit EFLAGS)]>;
1536 let isTwoAddress = 0 in {
1537 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1538 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1539 (implicit EFLAGS)]>;
1540 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1541 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1542 (implicit EFLAGS)]>, OpSize;
1543 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1544 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1545 (implicit EFLAGS)]>;
1547 } // Defs = [EFLAGS]
1549 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1550 let AddedComplexity = 15 in {
1551 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1552 [(set GR8:$dst, (not GR8:$src))]>;
1553 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1554 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1555 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1556 [(set GR32:$dst, (not GR32:$src))]>;
1558 let isTwoAddress = 0 in {
1559 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1560 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1561 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1562 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1563 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1564 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1568 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1569 let Defs = [EFLAGS] in {
1571 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1572 [(set GR8:$dst, (add GR8:$src, 1)),
1573 (implicit EFLAGS)]>;
1574 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1575 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1576 [(set GR16:$dst, (add GR16:$src, 1)),
1577 (implicit EFLAGS)]>,
1578 OpSize, Requires<[In32BitMode]>;
1579 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1580 [(set GR32:$dst, (add GR32:$src, 1)),
1581 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1583 let isTwoAddress = 0, CodeSize = 2 in {
1584 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1585 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1586 (implicit EFLAGS)]>;
1587 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1588 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1589 (implicit EFLAGS)]>,
1590 OpSize, Requires<[In32BitMode]>;
1591 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1592 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1593 (implicit EFLAGS)]>,
1594 Requires<[In32BitMode]>;
1598 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1599 [(set GR8:$dst, (add GR8:$src, -1)),
1600 (implicit EFLAGS)]>;
1601 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1602 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1603 [(set GR16:$dst, (add GR16:$src, -1)),
1604 (implicit EFLAGS)]>,
1605 OpSize, Requires<[In32BitMode]>;
1606 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1607 [(set GR32:$dst, (add GR32:$src, -1)),
1608 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1611 let isTwoAddress = 0, CodeSize = 2 in {
1612 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1613 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1614 (implicit EFLAGS)]>;
1615 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1616 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1617 (implicit EFLAGS)]>,
1618 OpSize, Requires<[In32BitMode]>;
1619 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1620 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1621 (implicit EFLAGS)]>,
1622 Requires<[In32BitMode]>;
1624 } // Defs = [EFLAGS]
1626 // Logical operators...
1627 let Defs = [EFLAGS] in {
1628 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1629 def AND8rr : I<0x20, MRMDestReg,
1630 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1631 "and{b}\t{$src2, $dst|$dst, $src2}",
1632 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1633 (implicit EFLAGS)]>;
1634 def AND16rr : I<0x21, MRMDestReg,
1635 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1636 "and{w}\t{$src2, $dst|$dst, $src2}",
1637 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1638 (implicit EFLAGS)]>, OpSize;
1639 def AND32rr : I<0x21, MRMDestReg,
1640 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1641 "and{l}\t{$src2, $dst|$dst, $src2}",
1642 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1643 (implicit EFLAGS)]>;
1646 def AND8rm : I<0x22, MRMSrcMem,
1647 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1648 "and{b}\t{$src2, $dst|$dst, $src2}",
1649 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1650 (implicit EFLAGS)]>;
1651 def AND16rm : I<0x23, MRMSrcMem,
1652 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1653 "and{w}\t{$src2, $dst|$dst, $src2}",
1654 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1655 (implicit EFLAGS)]>, OpSize;
1656 def AND32rm : I<0x23, MRMSrcMem,
1657 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1658 "and{l}\t{$src2, $dst|$dst, $src2}",
1659 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1660 (implicit EFLAGS)]>;
1662 def AND8ri : Ii8<0x80, MRM4r,
1663 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1664 "and{b}\t{$src2, $dst|$dst, $src2}",
1665 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1666 (implicit EFLAGS)]>;
1667 def AND16ri : Ii16<0x81, MRM4r,
1668 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1669 "and{w}\t{$src2, $dst|$dst, $src2}",
1670 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1671 (implicit EFLAGS)]>, OpSize;
1672 def AND32ri : Ii32<0x81, MRM4r,
1673 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1674 "and{l}\t{$src2, $dst|$dst, $src2}",
1675 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1676 (implicit EFLAGS)]>;
1677 def AND16ri8 : Ii8<0x83, MRM4r,
1678 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1679 "and{w}\t{$src2, $dst|$dst, $src2}",
1680 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1681 (implicit EFLAGS)]>,
1683 def AND32ri8 : Ii8<0x83, MRM4r,
1684 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1685 "and{l}\t{$src2, $dst|$dst, $src2}",
1686 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1687 (implicit EFLAGS)]>;
1689 let isTwoAddress = 0 in {
1690 def AND8mr : I<0x20, MRMDestMem,
1691 (outs), (ins i8mem :$dst, GR8 :$src),
1692 "and{b}\t{$src, $dst|$dst, $src}",
1693 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1694 (implicit EFLAGS)]>;
1695 def AND16mr : I<0x21, MRMDestMem,
1696 (outs), (ins i16mem:$dst, GR16:$src),
1697 "and{w}\t{$src, $dst|$dst, $src}",
1698 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1699 (implicit EFLAGS)]>,
1701 def AND32mr : I<0x21, MRMDestMem,
1702 (outs), (ins i32mem:$dst, GR32:$src),
1703 "and{l}\t{$src, $dst|$dst, $src}",
1704 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1705 (implicit EFLAGS)]>;
1706 def AND8mi : Ii8<0x80, MRM4m,
1707 (outs), (ins i8mem :$dst, i8imm :$src),
1708 "and{b}\t{$src, $dst|$dst, $src}",
1709 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1710 (implicit EFLAGS)]>;
1711 def AND16mi : Ii16<0x81, MRM4m,
1712 (outs), (ins i16mem:$dst, i16imm:$src),
1713 "and{w}\t{$src, $dst|$dst, $src}",
1714 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1715 (implicit EFLAGS)]>,
1717 def AND32mi : Ii32<0x81, MRM4m,
1718 (outs), (ins i32mem:$dst, i32imm:$src),
1719 "and{l}\t{$src, $dst|$dst, $src}",
1720 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1721 (implicit EFLAGS)]>;
1722 def AND16mi8 : Ii8<0x83, MRM4m,
1723 (outs), (ins i16mem:$dst, i16i8imm :$src),
1724 "and{w}\t{$src, $dst|$dst, $src}",
1725 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1726 (implicit EFLAGS)]>,
1728 def AND32mi8 : Ii8<0x83, MRM4m,
1729 (outs), (ins i32mem:$dst, i32i8imm :$src),
1730 "and{l}\t{$src, $dst|$dst, $src}",
1731 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1732 (implicit EFLAGS)]>;
1734 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1735 "and{b}\t{$src, %al|%al, $src}", []>;
1736 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1737 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1738 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1739 "and{l}\t{$src, %eax|%eax, $src}", []>;
1744 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1745 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1746 "or{b}\t{$src2, $dst|$dst, $src2}",
1747 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1748 (implicit EFLAGS)]>;
1749 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1750 "or{w}\t{$src2, $dst|$dst, $src2}",
1751 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1752 (implicit EFLAGS)]>, OpSize;
1753 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1754 "or{l}\t{$src2, $dst|$dst, $src2}",
1755 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1756 (implicit EFLAGS)]>;
1758 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1759 "or{b}\t{$src2, $dst|$dst, $src2}",
1760 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1761 (implicit EFLAGS)]>;
1762 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1763 "or{w}\t{$src2, $dst|$dst, $src2}",
1764 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1765 (implicit EFLAGS)]>, OpSize;
1766 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1767 "or{l}\t{$src2, $dst|$dst, $src2}",
1768 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1769 (implicit EFLAGS)]>;
1771 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1772 "or{b}\t{$src2, $dst|$dst, $src2}",
1773 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1774 (implicit EFLAGS)]>;
1775 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1776 "or{w}\t{$src2, $dst|$dst, $src2}",
1777 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1778 (implicit EFLAGS)]>, OpSize;
1779 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1780 "or{l}\t{$src2, $dst|$dst, $src2}",
1781 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1782 (implicit EFLAGS)]>;
1784 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1785 "or{w}\t{$src2, $dst|$dst, $src2}",
1786 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1787 (implicit EFLAGS)]>, OpSize;
1788 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1789 "or{l}\t{$src2, $dst|$dst, $src2}",
1790 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1791 (implicit EFLAGS)]>;
1792 let isTwoAddress = 0 in {
1793 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1794 "or{b}\t{$src, $dst|$dst, $src}",
1795 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1796 (implicit EFLAGS)]>;
1797 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1798 "or{w}\t{$src, $dst|$dst, $src}",
1799 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1800 (implicit EFLAGS)]>, OpSize;
1801 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1802 "or{l}\t{$src, $dst|$dst, $src}",
1803 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1804 (implicit EFLAGS)]>;
1805 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1806 "or{b}\t{$src, $dst|$dst, $src}",
1807 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1808 (implicit EFLAGS)]>;
1809 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1810 "or{w}\t{$src, $dst|$dst, $src}",
1811 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1812 (implicit EFLAGS)]>,
1814 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1815 "or{l}\t{$src, $dst|$dst, $src}",
1816 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1817 (implicit EFLAGS)]>;
1818 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1819 "or{w}\t{$src, $dst|$dst, $src}",
1820 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1821 (implicit EFLAGS)]>,
1823 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1824 "or{l}\t{$src, $dst|$dst, $src}",
1825 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1826 (implicit EFLAGS)]>;
1828 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1829 "or{b}\t{$src, %al|%al, $src}", []>;
1830 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1831 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1832 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1833 "or{l}\t{$src, %eax|%eax, $src}", []>;
1834 } // isTwoAddress = 0
1837 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1838 def XOR8rr : I<0x30, MRMDestReg,
1839 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1840 "xor{b}\t{$src2, $dst|$dst, $src2}",
1841 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1842 (implicit EFLAGS)]>;
1843 def XOR16rr : I<0x31, MRMDestReg,
1844 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1845 "xor{w}\t{$src2, $dst|$dst, $src2}",
1846 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1847 (implicit EFLAGS)]>, OpSize;
1848 def XOR32rr : I<0x31, MRMDestReg,
1849 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1850 "xor{l}\t{$src2, $dst|$dst, $src2}",
1851 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1852 (implicit EFLAGS)]>;
1853 } // isCommutable = 1
1855 def XOR8rm : I<0x32, MRMSrcMem ,
1856 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1857 "xor{b}\t{$src2, $dst|$dst, $src2}",
1858 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1859 (implicit EFLAGS)]>;
1860 def XOR16rm : I<0x33, MRMSrcMem ,
1861 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1862 "xor{w}\t{$src2, $dst|$dst, $src2}",
1863 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1864 (implicit EFLAGS)]>,
1866 def XOR32rm : I<0x33, MRMSrcMem ,
1867 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1868 "xor{l}\t{$src2, $dst|$dst, $src2}",
1869 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1870 (implicit EFLAGS)]>;
1872 def XOR8ri : Ii8<0x80, MRM6r,
1873 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1874 "xor{b}\t{$src2, $dst|$dst, $src2}",
1875 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1876 (implicit EFLAGS)]>;
1877 def XOR16ri : Ii16<0x81, MRM6r,
1878 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1879 "xor{w}\t{$src2, $dst|$dst, $src2}",
1880 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1881 (implicit EFLAGS)]>, OpSize;
1882 def XOR32ri : Ii32<0x81, MRM6r,
1883 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1884 "xor{l}\t{$src2, $dst|$dst, $src2}",
1885 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1886 (implicit EFLAGS)]>;
1887 def XOR16ri8 : Ii8<0x83, MRM6r,
1888 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1889 "xor{w}\t{$src2, $dst|$dst, $src2}",
1890 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1891 (implicit EFLAGS)]>,
1893 def XOR32ri8 : Ii8<0x83, MRM6r,
1894 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1895 "xor{l}\t{$src2, $dst|$dst, $src2}",
1896 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1897 (implicit EFLAGS)]>;
1899 let isTwoAddress = 0 in {
1900 def XOR8mr : I<0x30, MRMDestMem,
1901 (outs), (ins i8mem :$dst, GR8 :$src),
1902 "xor{b}\t{$src, $dst|$dst, $src}",
1903 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1904 (implicit EFLAGS)]>;
1905 def XOR16mr : I<0x31, MRMDestMem,
1906 (outs), (ins i16mem:$dst, GR16:$src),
1907 "xor{w}\t{$src, $dst|$dst, $src}",
1908 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1909 (implicit EFLAGS)]>,
1911 def XOR32mr : I<0x31, MRMDestMem,
1912 (outs), (ins i32mem:$dst, GR32:$src),
1913 "xor{l}\t{$src, $dst|$dst, $src}",
1914 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1915 (implicit EFLAGS)]>;
1916 def XOR8mi : Ii8<0x80, MRM6m,
1917 (outs), (ins i8mem :$dst, i8imm :$src),
1918 "xor{b}\t{$src, $dst|$dst, $src}",
1919 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1920 (implicit EFLAGS)]>;
1921 def XOR16mi : Ii16<0x81, MRM6m,
1922 (outs), (ins i16mem:$dst, i16imm:$src),
1923 "xor{w}\t{$src, $dst|$dst, $src}",
1924 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1925 (implicit EFLAGS)]>,
1927 def XOR32mi : Ii32<0x81, MRM6m,
1928 (outs), (ins i32mem:$dst, i32imm:$src),
1929 "xor{l}\t{$src, $dst|$dst, $src}",
1930 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1931 (implicit EFLAGS)]>;
1932 def XOR16mi8 : Ii8<0x83, MRM6m,
1933 (outs), (ins i16mem:$dst, i16i8imm :$src),
1934 "xor{w}\t{$src, $dst|$dst, $src}",
1935 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1936 (implicit EFLAGS)]>,
1938 def XOR32mi8 : Ii8<0x83, MRM6m,
1939 (outs), (ins i32mem:$dst, i32i8imm :$src),
1940 "xor{l}\t{$src, $dst|$dst, $src}",
1941 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1942 (implicit EFLAGS)]>;
1944 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1945 "xor{b}\t{$src, %al|%al, $src}", []>;
1946 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
1947 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1948 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
1949 "xor{l}\t{$src, %eax|%eax, $src}", []>;
1950 } // isTwoAddress = 0
1951 } // Defs = [EFLAGS]
1953 // Shift instructions
1954 let Defs = [EFLAGS] in {
1955 let Uses = [CL] in {
1956 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1957 "shl{b}\t{%cl, $dst|$dst, CL}",
1958 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1959 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1960 "shl{w}\t{%cl, $dst|$dst, CL}",
1961 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1962 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1963 "shl{l}\t{%cl, $dst|$dst, CL}",
1964 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1967 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1968 "shl{b}\t{$src2, $dst|$dst, $src2}",
1969 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1970 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1971 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1972 "shl{w}\t{$src2, $dst|$dst, $src2}",
1973 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1974 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1975 "shl{l}\t{$src2, $dst|$dst, $src2}",
1976 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1977 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1979 } // isConvertibleToThreeAddress = 1
1981 let isTwoAddress = 0 in {
1982 let Uses = [CL] in {
1983 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1984 "shl{b}\t{%cl, $dst|$dst, CL}",
1985 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1986 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1987 "shl{w}\t{%cl, $dst|$dst, CL}",
1988 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1989 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1990 "shl{l}\t{%cl, $dst|$dst, CL}",
1991 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1993 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1994 "shl{b}\t{$src, $dst|$dst, $src}",
1995 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1996 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1997 "shl{w}\t{$src, $dst|$dst, $src}",
1998 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2000 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
2001 "shl{l}\t{$src, $dst|$dst, $src}",
2002 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2005 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2007 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2008 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2010 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2012 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2014 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2017 let Uses = [CL] in {
2018 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
2019 "shr{b}\t{%cl, $dst|$dst, CL}",
2020 [(set GR8:$dst, (srl GR8:$src, CL))]>;
2021 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
2022 "shr{w}\t{%cl, $dst|$dst, CL}",
2023 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
2024 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
2025 "shr{l}\t{%cl, $dst|$dst, CL}",
2026 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2029 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2030 "shr{b}\t{$src2, $dst|$dst, $src2}",
2031 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2032 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2033 "shr{w}\t{$src2, $dst|$dst, $src2}",
2034 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2035 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2036 "shr{l}\t{$src2, $dst|$dst, $src2}",
2037 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2040 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2042 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2043 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2045 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2046 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2048 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2050 let isTwoAddress = 0 in {
2051 let Uses = [CL] in {
2052 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2053 "shr{b}\t{%cl, $dst|$dst, CL}",
2054 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2055 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2056 "shr{w}\t{%cl, $dst|$dst, CL}",
2057 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2059 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2060 "shr{l}\t{%cl, $dst|$dst, CL}",
2061 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2063 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2064 "shr{b}\t{$src, $dst|$dst, $src}",
2065 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2066 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2067 "shr{w}\t{$src, $dst|$dst, $src}",
2068 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2070 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2071 "shr{l}\t{$src, $dst|$dst, $src}",
2072 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2075 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2077 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2078 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2080 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2081 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2083 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2086 let Uses = [CL] in {
2087 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
2088 "sar{b}\t{%cl, $dst|$dst, CL}",
2089 [(set GR8:$dst, (sra GR8:$src, CL))]>;
2090 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
2091 "sar{w}\t{%cl, $dst|$dst, CL}",
2092 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
2093 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
2094 "sar{l}\t{%cl, $dst|$dst, CL}",
2095 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2098 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2099 "sar{b}\t{$src2, $dst|$dst, $src2}",
2100 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2101 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2102 "sar{w}\t{$src2, $dst|$dst, $src2}",
2103 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2105 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2106 "sar{l}\t{$src2, $dst|$dst, $src2}",
2107 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2110 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2112 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2113 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2115 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2116 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2118 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2120 let isTwoAddress = 0 in {
2121 let Uses = [CL] in {
2122 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2123 "sar{b}\t{%cl, $dst|$dst, CL}",
2124 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2125 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2126 "sar{w}\t{%cl, $dst|$dst, CL}",
2127 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2128 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2129 "sar{l}\t{%cl, $dst|$dst, CL}",
2130 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2132 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2133 "sar{b}\t{$src, $dst|$dst, $src}",
2134 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2135 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2136 "sar{w}\t{$src, $dst|$dst, $src}",
2137 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2139 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2140 "sar{l}\t{$src, $dst|$dst, $src}",
2141 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2144 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2146 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2147 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2149 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2151 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2153 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2156 // Rotate instructions
2157 // FIXME: provide shorter instructions when imm8 == 1
2158 let Uses = [CL] in {
2159 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
2160 "rol{b}\t{%cl, $dst|$dst, CL}",
2161 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
2162 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
2163 "rol{w}\t{%cl, $dst|$dst, CL}",
2164 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
2165 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
2166 "rol{l}\t{%cl, $dst|$dst, CL}",
2167 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2170 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2171 "rol{b}\t{$src2, $dst|$dst, $src2}",
2172 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2173 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2174 "rol{w}\t{$src2, $dst|$dst, $src2}",
2175 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2176 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2177 "rol{l}\t{$src2, $dst|$dst, $src2}",
2178 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2181 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2183 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2184 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2186 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2187 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2189 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2191 let isTwoAddress = 0 in {
2192 let Uses = [CL] in {
2193 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2194 "rol{b}\t{%cl, $dst|$dst, CL}",
2195 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2196 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2197 "rol{w}\t{%cl, $dst|$dst, CL}",
2198 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2199 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2200 "rol{l}\t{%cl, $dst|$dst, CL}",
2201 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2203 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2204 "rol{b}\t{$src, $dst|$dst, $src}",
2205 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2206 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2207 "rol{w}\t{$src, $dst|$dst, $src}",
2208 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2210 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2211 "rol{l}\t{$src, $dst|$dst, $src}",
2212 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2215 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2217 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2218 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2220 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2222 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2224 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2227 let Uses = [CL] in {
2228 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2229 "ror{b}\t{%cl, $dst|$dst, CL}",
2230 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2231 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2232 "ror{w}\t{%cl, $dst|$dst, CL}",
2233 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2234 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2235 "ror{l}\t{%cl, $dst|$dst, CL}",
2236 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2239 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2240 "ror{b}\t{$src2, $dst|$dst, $src2}",
2241 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2242 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2243 "ror{w}\t{$src2, $dst|$dst, $src2}",
2244 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2245 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2246 "ror{l}\t{$src2, $dst|$dst, $src2}",
2247 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2250 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2252 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2253 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2255 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2256 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2258 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2260 let isTwoAddress = 0 in {
2261 let Uses = [CL] in {
2262 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2263 "ror{b}\t{%cl, $dst|$dst, CL}",
2264 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2265 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2266 "ror{w}\t{%cl, $dst|$dst, CL}",
2267 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2268 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2269 "ror{l}\t{%cl, $dst|$dst, CL}",
2270 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2272 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2273 "ror{b}\t{$src, $dst|$dst, $src}",
2274 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2275 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2276 "ror{w}\t{$src, $dst|$dst, $src}",
2277 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2279 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2280 "ror{l}\t{$src, $dst|$dst, $src}",
2281 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2284 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2286 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2287 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2289 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2291 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2293 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2298 // Double shift instructions (generalizations of rotate)
2299 let Uses = [CL] in {
2300 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2301 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2302 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2303 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2304 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2305 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2306 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2307 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2308 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2310 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2311 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2312 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2316 let isCommutable = 1 in { // These instructions commute to each other.
2317 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2318 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2319 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2320 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2323 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2324 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2325 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2326 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2329 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2330 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2331 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2332 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2335 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2336 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2337 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2338 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2343 let isTwoAddress = 0 in {
2344 let Uses = [CL] in {
2345 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2346 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2347 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2349 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2350 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2351 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2354 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2355 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2356 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2357 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2358 (i8 imm:$src3)), addr:$dst)]>,
2360 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2361 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2362 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2363 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2364 (i8 imm:$src3)), addr:$dst)]>,
2367 let Uses = [CL] in {
2368 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2369 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2370 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2371 addr:$dst)]>, TB, OpSize;
2372 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2373 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2374 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2375 addr:$dst)]>, TB, OpSize;
2377 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2378 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2379 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2380 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2381 (i8 imm:$src3)), addr:$dst)]>,
2383 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2384 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2385 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2386 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2387 (i8 imm:$src3)), addr:$dst)]>,
2390 } // Defs = [EFLAGS]
2394 let Defs = [EFLAGS] in {
2395 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2396 // Register-Register Addition
2397 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2398 (ins GR8 :$src1, GR8 :$src2),
2399 "add{b}\t{$src2, $dst|$dst, $src2}",
2400 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2401 (implicit EFLAGS)]>;
2403 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2404 // Register-Register Addition
2405 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2406 (ins GR16:$src1, GR16:$src2),
2407 "add{w}\t{$src2, $dst|$dst, $src2}",
2408 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2409 (implicit EFLAGS)]>, OpSize;
2410 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2411 (ins GR32:$src1, GR32:$src2),
2412 "add{l}\t{$src2, $dst|$dst, $src2}",
2413 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2414 (implicit EFLAGS)]>;
2415 } // end isConvertibleToThreeAddress
2416 } // end isCommutable
2418 // Register-Memory Addition
2419 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2420 (ins GR8 :$src1, i8mem :$src2),
2421 "add{b}\t{$src2, $dst|$dst, $src2}",
2422 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2423 (implicit EFLAGS)]>;
2424 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2425 (ins GR16:$src1, i16mem:$src2),
2426 "add{w}\t{$src2, $dst|$dst, $src2}",
2427 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2428 (implicit EFLAGS)]>, OpSize;
2429 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2430 (ins GR32:$src1, i32mem:$src2),
2431 "add{l}\t{$src2, $dst|$dst, $src2}",
2432 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2433 (implicit EFLAGS)]>;
2435 // Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2436 // ADD16rr, and ADD32rr), but differently encoded.
2437 def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2438 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2439 def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2440 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2441 def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2442 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2444 // Register-Integer Addition
2445 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2446 "add{b}\t{$src2, $dst|$dst, $src2}",
2447 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2448 (implicit EFLAGS)]>;
2450 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2451 // Register-Integer Addition
2452 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2453 (ins GR16:$src1, i16imm:$src2),
2454 "add{w}\t{$src2, $dst|$dst, $src2}",
2455 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2456 (implicit EFLAGS)]>, OpSize;
2457 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2458 (ins GR32:$src1, i32imm:$src2),
2459 "add{l}\t{$src2, $dst|$dst, $src2}",
2460 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2461 (implicit EFLAGS)]>;
2462 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2463 (ins GR16:$src1, i16i8imm:$src2),
2464 "add{w}\t{$src2, $dst|$dst, $src2}",
2465 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2466 (implicit EFLAGS)]>, OpSize;
2467 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2468 (ins GR32:$src1, i32i8imm:$src2),
2469 "add{l}\t{$src2, $dst|$dst, $src2}",
2470 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2471 (implicit EFLAGS)]>;
2474 let isTwoAddress = 0 in {
2475 // Memory-Register Addition
2476 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2477 "add{b}\t{$src2, $dst|$dst, $src2}",
2478 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2479 (implicit EFLAGS)]>;
2480 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2481 "add{w}\t{$src2, $dst|$dst, $src2}",
2482 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2483 (implicit EFLAGS)]>, OpSize;
2484 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2485 "add{l}\t{$src2, $dst|$dst, $src2}",
2486 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2487 (implicit EFLAGS)]>;
2488 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2489 "add{b}\t{$src2, $dst|$dst, $src2}",
2490 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2491 (implicit EFLAGS)]>;
2492 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2493 "add{w}\t{$src2, $dst|$dst, $src2}",
2494 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2495 (implicit EFLAGS)]>, OpSize;
2496 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2497 "add{l}\t{$src2, $dst|$dst, $src2}",
2498 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2499 (implicit EFLAGS)]>;
2500 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2501 "add{w}\t{$src2, $dst|$dst, $src2}",
2502 [(store (add (load addr:$dst), i16immSExt8:$src2),
2504 (implicit EFLAGS)]>, OpSize;
2505 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2506 "add{l}\t{$src2, $dst|$dst, $src2}",
2507 [(store (add (load addr:$dst), i32immSExt8:$src2),
2509 (implicit EFLAGS)]>;
2512 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2513 "add{b}\t{$src, %al|%al, $src}", []>;
2514 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2515 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2516 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2517 "add{l}\t{$src, %eax|%eax, $src}", []>;
2520 let Uses = [EFLAGS] in {
2521 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2522 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2523 "adc{b}\t{$src2, $dst|$dst, $src2}",
2524 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2525 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2526 (ins GR16:$src1, GR16:$src2),
2527 "adc{w}\t{$src2, $dst|$dst, $src2}",
2528 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2529 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2530 (ins GR32:$src1, GR32:$src2),
2531 "adc{l}\t{$src2, $dst|$dst, $src2}",
2532 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2534 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2535 (ins GR8:$src1, i8mem:$src2),
2536 "adc{b}\t{$src2, $dst|$dst, $src2}",
2537 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2538 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2539 (ins GR16:$src1, i16mem:$src2),
2540 "adc{w}\t{$src2, $dst|$dst, $src2}",
2541 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2543 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2544 (ins GR32:$src1, i32mem:$src2),
2545 "adc{l}\t{$src2, $dst|$dst, $src2}",
2546 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2547 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2548 "adc{b}\t{$src2, $dst|$dst, $src2}",
2549 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2550 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2551 (ins GR16:$src1, i16imm:$src2),
2552 "adc{w}\t{$src2, $dst|$dst, $src2}",
2553 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2554 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2555 (ins GR16:$src1, i16i8imm:$src2),
2556 "adc{w}\t{$src2, $dst|$dst, $src2}",
2557 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2559 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2560 (ins GR32:$src1, i32imm:$src2),
2561 "adc{l}\t{$src2, $dst|$dst, $src2}",
2562 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2563 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2564 (ins GR32:$src1, i32i8imm:$src2),
2565 "adc{l}\t{$src2, $dst|$dst, $src2}",
2566 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2568 let isTwoAddress = 0 in {
2569 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2570 "adc{b}\t{$src2, $dst|$dst, $src2}",
2571 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2572 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2573 "adc{w}\t{$src2, $dst|$dst, $src2}",
2574 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2576 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2577 "adc{l}\t{$src2, $dst|$dst, $src2}",
2578 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2579 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2580 "adc{b}\t{$src2, $dst|$dst, $src2}",
2581 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2582 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2583 "adc{w}\t{$src2, $dst|$dst, $src2}",
2584 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2586 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2587 "adc{w}\t{$src2, $dst|$dst, $src2}",
2588 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2590 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2591 "adc{l}\t{$src2, $dst|$dst, $src2}",
2592 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2593 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2594 "adc{l}\t{$src2, $dst|$dst, $src2}",
2595 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2597 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2598 "adc{b}\t{$src, %al|%al, $src}", []>;
2599 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2600 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2601 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2602 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2604 } // Uses = [EFLAGS]
2606 // Register-Register Subtraction
2607 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2608 "sub{b}\t{$src2, $dst|$dst, $src2}",
2609 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2610 (implicit EFLAGS)]>;
2611 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2612 "sub{w}\t{$src2, $dst|$dst, $src2}",
2613 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2614 (implicit EFLAGS)]>, OpSize;
2615 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2616 "sub{l}\t{$src2, $dst|$dst, $src2}",
2617 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2618 (implicit EFLAGS)]>;
2620 // Register-Memory Subtraction
2621 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2622 (ins GR8 :$src1, i8mem :$src2),
2623 "sub{b}\t{$src2, $dst|$dst, $src2}",
2624 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2625 (implicit EFLAGS)]>;
2626 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2627 (ins GR16:$src1, i16mem:$src2),
2628 "sub{w}\t{$src2, $dst|$dst, $src2}",
2629 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2630 (implicit EFLAGS)]>, OpSize;
2631 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2632 (ins GR32:$src1, i32mem:$src2),
2633 "sub{l}\t{$src2, $dst|$dst, $src2}",
2634 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2635 (implicit EFLAGS)]>;
2637 // Register-Integer Subtraction
2638 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2639 (ins GR8:$src1, i8imm:$src2),
2640 "sub{b}\t{$src2, $dst|$dst, $src2}",
2641 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2642 (implicit EFLAGS)]>;
2643 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2644 (ins GR16:$src1, i16imm:$src2),
2645 "sub{w}\t{$src2, $dst|$dst, $src2}",
2646 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2647 (implicit EFLAGS)]>, OpSize;
2648 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2649 (ins GR32:$src1, i32imm:$src2),
2650 "sub{l}\t{$src2, $dst|$dst, $src2}",
2651 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2652 (implicit EFLAGS)]>;
2653 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2654 (ins GR16:$src1, i16i8imm:$src2),
2655 "sub{w}\t{$src2, $dst|$dst, $src2}",
2656 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2657 (implicit EFLAGS)]>, OpSize;
2658 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2659 (ins GR32:$src1, i32i8imm:$src2),
2660 "sub{l}\t{$src2, $dst|$dst, $src2}",
2661 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2662 (implicit EFLAGS)]>;
2664 let isTwoAddress = 0 in {
2665 // Memory-Register Subtraction
2666 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2667 "sub{b}\t{$src2, $dst|$dst, $src2}",
2668 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2669 (implicit EFLAGS)]>;
2670 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2671 "sub{w}\t{$src2, $dst|$dst, $src2}",
2672 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2673 (implicit EFLAGS)]>, OpSize;
2674 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2675 "sub{l}\t{$src2, $dst|$dst, $src2}",
2676 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2677 (implicit EFLAGS)]>;
2679 // Memory-Integer Subtraction
2680 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2681 "sub{b}\t{$src2, $dst|$dst, $src2}",
2682 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2683 (implicit EFLAGS)]>;
2684 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2685 "sub{w}\t{$src2, $dst|$dst, $src2}",
2686 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2687 (implicit EFLAGS)]>, OpSize;
2688 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2689 "sub{l}\t{$src2, $dst|$dst, $src2}",
2690 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2691 (implicit EFLAGS)]>;
2692 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2693 "sub{w}\t{$src2, $dst|$dst, $src2}",
2694 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2696 (implicit EFLAGS)]>, OpSize;
2697 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2698 "sub{l}\t{$src2, $dst|$dst, $src2}",
2699 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2701 (implicit EFLAGS)]>;
2703 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2704 "sub{b}\t{$src, %al|%al, $src}", []>;
2705 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2706 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2707 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2708 "sub{l}\t{$src, %eax|%eax, $src}", []>;
2711 let Uses = [EFLAGS] in {
2712 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2713 (ins GR8:$src1, GR8:$src2),
2714 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2715 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2716 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2717 (ins GR16:$src1, GR16:$src2),
2718 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2719 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2720 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2721 (ins GR32:$src1, GR32:$src2),
2722 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2723 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2725 let isTwoAddress = 0 in {
2726 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2727 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2728 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2729 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2730 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2731 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2733 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2734 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2735 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2736 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2737 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2738 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2739 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2740 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2741 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2743 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2744 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2745 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2747 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2748 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2749 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2750 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2751 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2752 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2754 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2755 "sbb{b}\t{$src, %al|%al, $src}", []>;
2756 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2757 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2758 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2759 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
2761 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2762 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2763 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2764 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2765 (ins GR16:$src1, i16mem:$src2),
2766 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2767 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2769 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2770 (ins GR32:$src1, i32mem:$src2),
2771 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2772 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2773 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2774 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2775 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2776 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2777 (ins GR16:$src1, i16imm:$src2),
2778 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2779 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2780 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2781 (ins GR16:$src1, i16i8imm:$src2),
2782 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2783 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2785 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2786 (ins GR32:$src1, i32imm:$src2),
2787 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2788 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2789 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2790 (ins GR32:$src1, i32i8imm:$src2),
2791 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2792 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2793 } // Uses = [EFLAGS]
2794 } // Defs = [EFLAGS]
2796 let Defs = [EFLAGS] in {
2797 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2798 // Register-Register Signed Integer Multiply
2799 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2800 "imul{w}\t{$src2, $dst|$dst, $src2}",
2801 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2802 (implicit EFLAGS)]>, TB, OpSize;
2803 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2804 "imul{l}\t{$src2, $dst|$dst, $src2}",
2805 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2806 (implicit EFLAGS)]>, TB;
2809 // Register-Memory Signed Integer Multiply
2810 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2811 (ins GR16:$src1, i16mem:$src2),
2812 "imul{w}\t{$src2, $dst|$dst, $src2}",
2813 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2814 (implicit EFLAGS)]>, TB, OpSize;
2815 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2816 "imul{l}\t{$src2, $dst|$dst, $src2}",
2817 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2818 (implicit EFLAGS)]>, TB;
2819 } // Defs = [EFLAGS]
2820 } // end Two Address instructions
2822 // Suprisingly enough, these are not two address instructions!
2823 let Defs = [EFLAGS] in {
2824 // Register-Integer Signed Integer Multiply
2825 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2826 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2827 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2828 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2829 (implicit EFLAGS)]>, OpSize;
2830 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2831 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2832 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2833 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2834 (implicit EFLAGS)]>;
2835 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2836 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2837 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2838 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2839 (implicit EFLAGS)]>, OpSize;
2840 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2841 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2842 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2843 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2844 (implicit EFLAGS)]>;
2846 // Memory-Integer Signed Integer Multiply
2847 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2848 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2849 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2850 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2851 (implicit EFLAGS)]>, OpSize;
2852 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2853 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2854 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2855 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2856 (implicit EFLAGS)]>;
2857 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2858 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2859 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2860 [(set GR16:$dst, (mul (load addr:$src1),
2861 i16immSExt8:$src2)),
2862 (implicit EFLAGS)]>, OpSize;
2863 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2864 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2865 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2866 [(set GR32:$dst, (mul (load addr:$src1),
2867 i32immSExt8:$src2)),
2868 (implicit EFLAGS)]>;
2869 } // Defs = [EFLAGS]
2871 //===----------------------------------------------------------------------===//
2872 // Test instructions are just like AND, except they don't generate a result.
2874 let Defs = [EFLAGS] in {
2875 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2876 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2877 "test{b}\t{$src2, $src1|$src1, $src2}",
2878 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2879 (implicit EFLAGS)]>;
2880 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2881 "test{w}\t{$src2, $src1|$src1, $src2}",
2882 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2883 (implicit EFLAGS)]>,
2885 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2886 "test{l}\t{$src2, $src1|$src1, $src2}",
2887 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2888 (implicit EFLAGS)]>;
2891 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
2892 "test{b}\t{$src, %al|%al, $src}", []>;
2893 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
2894 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2895 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
2896 "test{l}\t{$src, %eax|%eax, $src}", []>;
2898 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2899 "test{b}\t{$src2, $src1|$src1, $src2}",
2900 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2901 (implicit EFLAGS)]>;
2902 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2903 "test{w}\t{$src2, $src1|$src1, $src2}",
2904 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2905 (implicit EFLAGS)]>, OpSize;
2906 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2907 "test{l}\t{$src2, $src1|$src1, $src2}",
2908 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2909 (implicit EFLAGS)]>;
2911 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2912 (outs), (ins GR8:$src1, i8imm:$src2),
2913 "test{b}\t{$src2, $src1|$src1, $src2}",
2914 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2915 (implicit EFLAGS)]>;
2916 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2917 (outs), (ins GR16:$src1, i16imm:$src2),
2918 "test{w}\t{$src2, $src1|$src1, $src2}",
2919 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2920 (implicit EFLAGS)]>, OpSize;
2921 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2922 (outs), (ins GR32:$src1, i32imm:$src2),
2923 "test{l}\t{$src2, $src1|$src1, $src2}",
2924 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2925 (implicit EFLAGS)]>;
2927 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2928 (outs), (ins i8mem:$src1, i8imm:$src2),
2929 "test{b}\t{$src2, $src1|$src1, $src2}",
2930 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2931 (implicit EFLAGS)]>;
2932 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2933 (outs), (ins i16mem:$src1, i16imm:$src2),
2934 "test{w}\t{$src2, $src1|$src1, $src2}",
2935 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2936 (implicit EFLAGS)]>, OpSize;
2937 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2938 (outs), (ins i32mem:$src1, i32imm:$src2),
2939 "test{l}\t{$src2, $src1|$src1, $src2}",
2940 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2941 (implicit EFLAGS)]>;
2942 } // Defs = [EFLAGS]
2945 // Condition code ops, incl. set if equal/not equal/...
2946 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2947 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2948 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2949 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2951 let Uses = [EFLAGS] in {
2952 def SETEr : I<0x94, MRM0r,
2953 (outs GR8 :$dst), (ins),
2955 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2957 def SETEm : I<0x94, MRM0m,
2958 (outs), (ins i8mem:$dst),
2960 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2963 def SETNEr : I<0x95, MRM0r,
2964 (outs GR8 :$dst), (ins),
2966 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2968 def SETNEm : I<0x95, MRM0m,
2969 (outs), (ins i8mem:$dst),
2971 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2974 def SETLr : I<0x9C, MRM0r,
2975 (outs GR8 :$dst), (ins),
2977 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2978 TB; // GR8 = < signed
2979 def SETLm : I<0x9C, MRM0m,
2980 (outs), (ins i8mem:$dst),
2982 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2983 TB; // [mem8] = < signed
2985 def SETGEr : I<0x9D, MRM0r,
2986 (outs GR8 :$dst), (ins),
2988 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2989 TB; // GR8 = >= signed
2990 def SETGEm : I<0x9D, MRM0m,
2991 (outs), (ins i8mem:$dst),
2993 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2994 TB; // [mem8] = >= signed
2996 def SETLEr : I<0x9E, MRM0r,
2997 (outs GR8 :$dst), (ins),
2999 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3000 TB; // GR8 = <= signed
3001 def SETLEm : I<0x9E, MRM0m,
3002 (outs), (ins i8mem:$dst),
3004 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3005 TB; // [mem8] = <= signed
3007 def SETGr : I<0x9F, MRM0r,
3008 (outs GR8 :$dst), (ins),
3010 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3011 TB; // GR8 = > signed
3012 def SETGm : I<0x9F, MRM0m,
3013 (outs), (ins i8mem:$dst),
3015 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3016 TB; // [mem8] = > signed
3018 def SETBr : I<0x92, MRM0r,
3019 (outs GR8 :$dst), (ins),
3021 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3022 TB; // GR8 = < unsign
3023 def SETBm : I<0x92, MRM0m,
3024 (outs), (ins i8mem:$dst),
3026 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3027 TB; // [mem8] = < unsign
3029 def SETAEr : I<0x93, MRM0r,
3030 (outs GR8 :$dst), (ins),
3032 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3033 TB; // GR8 = >= unsign
3034 def SETAEm : I<0x93, MRM0m,
3035 (outs), (ins i8mem:$dst),
3037 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3038 TB; // [mem8] = >= unsign
3040 def SETBEr : I<0x96, MRM0r,
3041 (outs GR8 :$dst), (ins),
3043 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3044 TB; // GR8 = <= unsign
3045 def SETBEm : I<0x96, MRM0m,
3046 (outs), (ins i8mem:$dst),
3048 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3049 TB; // [mem8] = <= unsign
3051 def SETAr : I<0x97, MRM0r,
3052 (outs GR8 :$dst), (ins),
3054 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3055 TB; // GR8 = > signed
3056 def SETAm : I<0x97, MRM0m,
3057 (outs), (ins i8mem:$dst),
3059 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3060 TB; // [mem8] = > signed
3062 def SETSr : I<0x98, MRM0r,
3063 (outs GR8 :$dst), (ins),
3065 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3066 TB; // GR8 = <sign bit>
3067 def SETSm : I<0x98, MRM0m,
3068 (outs), (ins i8mem:$dst),
3070 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3071 TB; // [mem8] = <sign bit>
3072 def SETNSr : I<0x99, MRM0r,
3073 (outs GR8 :$dst), (ins),
3075 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3076 TB; // GR8 = !<sign bit>
3077 def SETNSm : I<0x99, MRM0m,
3078 (outs), (ins i8mem:$dst),
3080 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3081 TB; // [mem8] = !<sign bit>
3083 def SETPr : I<0x9A, MRM0r,
3084 (outs GR8 :$dst), (ins),
3086 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3088 def SETPm : I<0x9A, MRM0m,
3089 (outs), (ins i8mem:$dst),
3091 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3092 TB; // [mem8] = parity
3093 def SETNPr : I<0x9B, MRM0r,
3094 (outs GR8 :$dst), (ins),
3096 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3097 TB; // GR8 = not parity
3098 def SETNPm : I<0x9B, MRM0m,
3099 (outs), (ins i8mem:$dst),
3101 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3102 TB; // [mem8] = not parity
3104 def SETOr : I<0x90, MRM0r,
3105 (outs GR8 :$dst), (ins),
3107 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3108 TB; // GR8 = overflow
3109 def SETOm : I<0x90, MRM0m,
3110 (outs), (ins i8mem:$dst),
3112 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3113 TB; // [mem8] = overflow
3114 def SETNOr : I<0x91, MRM0r,
3115 (outs GR8 :$dst), (ins),
3117 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3118 TB; // GR8 = not overflow
3119 def SETNOm : I<0x91, MRM0m,
3120 (outs), (ins i8mem:$dst),
3122 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3123 TB; // [mem8] = not overflow
3124 } // Uses = [EFLAGS]
3127 // Integer comparisons
3128 let Defs = [EFLAGS] in {
3129 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3130 "cmp{b}\t{$src, %al|%al, $src}", []>;
3131 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3132 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3133 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3134 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3136 def CMP8rr : I<0x38, MRMDestReg,
3137 (outs), (ins GR8 :$src1, GR8 :$src2),
3138 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3139 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
3140 def CMP16rr : I<0x39, MRMDestReg,
3141 (outs), (ins GR16:$src1, GR16:$src2),
3142 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3143 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
3144 def CMP32rr : I<0x39, MRMDestReg,
3145 (outs), (ins GR32:$src1, GR32:$src2),
3146 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3147 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
3148 def CMP8mr : I<0x38, MRMDestMem,
3149 (outs), (ins i8mem :$src1, GR8 :$src2),
3150 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3151 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3152 (implicit EFLAGS)]>;
3153 def CMP16mr : I<0x39, MRMDestMem,
3154 (outs), (ins i16mem:$src1, GR16:$src2),
3155 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3156 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3157 (implicit EFLAGS)]>, OpSize;
3158 def CMP32mr : I<0x39, MRMDestMem,
3159 (outs), (ins i32mem:$src1, GR32:$src2),
3160 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3161 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3162 (implicit EFLAGS)]>;
3163 def CMP8rm : I<0x3A, MRMSrcMem,
3164 (outs), (ins GR8 :$src1, i8mem :$src2),
3165 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3166 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3167 (implicit EFLAGS)]>;
3168 def CMP16rm : I<0x3B, MRMSrcMem,
3169 (outs), (ins GR16:$src1, i16mem:$src2),
3170 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3171 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3172 (implicit EFLAGS)]>, OpSize;
3173 def CMP32rm : I<0x3B, MRMSrcMem,
3174 (outs), (ins GR32:$src1, i32mem:$src2),
3175 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3176 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3177 (implicit EFLAGS)]>;
3178 def CMP8ri : Ii8<0x80, MRM7r,
3179 (outs), (ins GR8:$src1, i8imm:$src2),
3180 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3181 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
3182 def CMP16ri : Ii16<0x81, MRM7r,
3183 (outs), (ins GR16:$src1, i16imm:$src2),
3184 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3185 [(X86cmp GR16:$src1, imm:$src2),
3186 (implicit EFLAGS)]>, OpSize;
3187 def CMP32ri : Ii32<0x81, MRM7r,
3188 (outs), (ins GR32:$src1, i32imm:$src2),
3189 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3190 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
3191 def CMP8mi : Ii8 <0x80, MRM7m,
3192 (outs), (ins i8mem :$src1, i8imm :$src2),
3193 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3194 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3195 (implicit EFLAGS)]>;
3196 def CMP16mi : Ii16<0x81, MRM7m,
3197 (outs), (ins i16mem:$src1, i16imm:$src2),
3198 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3199 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3200 (implicit EFLAGS)]>, OpSize;
3201 def CMP32mi : Ii32<0x81, MRM7m,
3202 (outs), (ins i32mem:$src1, i32imm:$src2),
3203 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3204 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3205 (implicit EFLAGS)]>;
3206 def CMP16ri8 : Ii8<0x83, MRM7r,
3207 (outs), (ins GR16:$src1, i16i8imm:$src2),
3208 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3209 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3210 (implicit EFLAGS)]>, OpSize;
3211 def CMP16mi8 : Ii8<0x83, MRM7m,
3212 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3213 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3214 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3215 (implicit EFLAGS)]>, OpSize;
3216 def CMP32mi8 : Ii8<0x83, MRM7m,
3217 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3218 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3219 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3220 (implicit EFLAGS)]>;
3221 def CMP32ri8 : Ii8<0x83, MRM7r,
3222 (outs), (ins GR32:$src1, i32i8imm:$src2),
3223 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3224 [(X86cmp GR32:$src1, i32immSExt8:$src2),
3225 (implicit EFLAGS)]>;
3226 } // Defs = [EFLAGS]
3229 // TODO: BTC, BTR, and BTS
3230 let Defs = [EFLAGS] in {
3231 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3232 "bt{w}\t{$src2, $src1|$src1, $src2}",
3233 [(X86bt GR16:$src1, GR16:$src2),
3234 (implicit EFLAGS)]>, OpSize, TB;
3235 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3236 "bt{l}\t{$src2, $src1|$src1, $src2}",
3237 [(X86bt GR32:$src1, GR32:$src2),
3238 (implicit EFLAGS)]>, TB;
3240 // Unlike with the register+register form, the memory+register form of the
3241 // bt instruction does not ignore the high bits of the index. From ISel's
3242 // perspective, this is pretty bizarre. Disable these instructions for now.
3243 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3244 // "bt{w}\t{$src2, $src1|$src1, $src2}",
3245 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3246 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3247 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3248 // "bt{l}\t{$src2, $src1|$src1, $src2}",
3249 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3250 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
3252 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3253 "bt{w}\t{$src2, $src1|$src1, $src2}",
3254 [(X86bt GR16:$src1, i16immSExt8:$src2),
3255 (implicit EFLAGS)]>, OpSize, TB;
3256 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3257 "bt{l}\t{$src2, $src1|$src1, $src2}",
3258 [(X86bt GR32:$src1, i32immSExt8:$src2),
3259 (implicit EFLAGS)]>, TB;
3260 // Note that these instructions don't need FastBTMem because that
3261 // only applies when the other operand is in a register. When it's
3262 // an immediate, bt is still fast.
3263 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3264 "bt{w}\t{$src2, $src1|$src1, $src2}",
3265 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3266 (implicit EFLAGS)]>, OpSize, TB;
3267 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3268 "bt{l}\t{$src2, $src1|$src1, $src2}",
3269 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3270 (implicit EFLAGS)]>, TB;
3271 } // Defs = [EFLAGS]
3273 // Sign/Zero extenders
3274 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3275 // of the register here. This has a smaller encoding and avoids a
3276 // partial-register update.
3277 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3278 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3279 [(set GR16:$dst, (sext GR8:$src))]>, TB;
3280 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3281 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3282 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3283 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3284 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3285 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3286 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3287 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3288 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3289 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3290 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3291 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3292 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3293 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3294 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3296 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3297 // of the register here. This has a smaller encoding and avoids a
3298 // partial-register update.
3299 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3300 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3301 [(set GR16:$dst, (zext GR8:$src))]>, TB;
3302 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3303 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3304 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3305 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3306 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3307 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3308 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3309 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3310 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3311 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3312 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3313 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3314 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3315 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3316 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3318 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3319 // except that they use GR32_NOREX for the output operand register class
3320 // instead of GR32. This allows them to operate on h registers on x86-64.
3321 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3322 (outs GR32_NOREX:$dst), (ins GR8:$src),
3323 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3326 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3327 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3328 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3331 let neverHasSideEffects = 1 in {
3332 let Defs = [AX], Uses = [AL] in
3333 def CBW : I<0x98, RawFrm, (outs), (ins),
3334 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3335 let Defs = [EAX], Uses = [AX] in
3336 def CWDE : I<0x98, RawFrm, (outs), (ins),
3337 "{cwtl|cwde}", []>; // EAX = signext(AX)
3339 let Defs = [AX,DX], Uses = [AX] in
3340 def CWD : I<0x99, RawFrm, (outs), (ins),
3341 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3342 let Defs = [EAX,EDX], Uses = [EAX] in
3343 def CDQ : I<0x99, RawFrm, (outs), (ins),
3344 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3347 //===----------------------------------------------------------------------===//
3348 // Alias Instructions
3349 //===----------------------------------------------------------------------===//
3351 // Alias instructions that map movr0 to xor.
3352 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3353 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3354 isCodeGenOnly = 1 in {
3355 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
3356 "xor{b}\t$dst, $dst",
3357 [(set GR8:$dst, 0)]>;
3358 // Use xorl instead of xorw since we don't care about the high 16 bits,
3359 // it's smaller, and it avoids a partial-register update.
3360 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3361 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3362 [(set GR16:$dst, 0)]>;
3363 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3364 "xor{l}\t$dst, $dst",
3365 [(set GR32:$dst, 0)]>;
3368 //===----------------------------------------------------------------------===//
3369 // Thread Local Storage Instructions
3372 // All calls clobber the non-callee saved registers. ESP is marked as
3373 // a use to prevent stack-pointer assignments that appear immediately
3374 // before calls from potentially appearing dead.
3375 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3376 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3377 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3378 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3380 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3381 "leal\t$sym, %eax; "
3382 "call\t___tls_get_addr@PLT",
3383 [(X86tlsaddr tls32addr:$sym)]>,
3384 Requires<[In32BitMode]>;
3386 let AddedComplexity = 5, isCodeGenOnly = 1 in
3387 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3388 "movl\t%gs:$src, $dst",
3389 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3391 let AddedComplexity = 5, isCodeGenOnly = 1 in
3392 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3393 "movl\t%fs:$src, $dst",
3394 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3396 //===----------------------------------------------------------------------===//
3397 // DWARF Pseudo Instructions
3400 def DWARF_LOC : I<0, Pseudo, (outs),
3401 (ins i32imm:$line, i32imm:$col, i32imm:$file),
3402 ".loc\t$file $line $col",
3403 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3406 //===----------------------------------------------------------------------===//
3407 // EH Pseudo Instructions
3409 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3410 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3411 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3412 "ret\t#eh_return, addr: $addr",
3413 [(X86ehret GR32:$addr)]>;
3417 //===----------------------------------------------------------------------===//
3421 // Atomic swap. These are just normal xchg instructions. But since a memory
3422 // operand is referenced, the atomicity is ensured.
3423 let Constraints = "$val = $dst" in {
3424 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3425 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3426 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3427 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3428 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3429 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3431 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3432 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3433 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3436 // Atomic compare and swap.
3437 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3438 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3440 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3441 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3443 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3444 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3447 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3450 let Defs = [AX, EFLAGS], Uses = [AX] in {
3451 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3453 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3454 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3456 let Defs = [AL, EFLAGS], Uses = [AL] in {
3457 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3459 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3460 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3463 // Atomic exchange and add
3464 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3465 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3467 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3468 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3470 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3472 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3473 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3475 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3477 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3478 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3482 // Optimized codegen when the non-memory output is not used.
3483 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3484 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3486 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3487 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3489 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3490 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3492 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3493 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3495 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3496 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3498 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3499 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3501 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3502 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3504 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3505 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3507 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3509 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3511 "inc{b}\t$dst", []>, LOCK;
3512 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3514 "inc{w}\t$dst", []>, OpSize, LOCK;
3515 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3517 "inc{l}\t$dst", []>, LOCK;
3519 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3521 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3522 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3524 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3525 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3527 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3528 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3530 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3531 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3533 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3534 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3536 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3537 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3539 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3540 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3542 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3544 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3546 "dec{b}\t$dst", []>, LOCK;
3547 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3549 "dec{w}\t$dst", []>, OpSize, LOCK;
3550 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3552 "dec{l}\t$dst", []>, LOCK;
3554 // Atomic exchange, and, or, xor
3555 let Constraints = "$val = $dst", Defs = [EFLAGS],
3556 usesCustomDAGSchedInserter = 1 in {
3557 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3558 "#ATOMAND32 PSEUDO!",
3559 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3560 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3561 "#ATOMOR32 PSEUDO!",
3562 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3563 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3564 "#ATOMXOR32 PSEUDO!",
3565 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3566 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3567 "#ATOMNAND32 PSEUDO!",
3568 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3569 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3570 "#ATOMMIN32 PSEUDO!",
3571 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3572 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3573 "#ATOMMAX32 PSEUDO!",
3574 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3575 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3576 "#ATOMUMIN32 PSEUDO!",
3577 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3578 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3579 "#ATOMUMAX32 PSEUDO!",
3580 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3582 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3583 "#ATOMAND16 PSEUDO!",
3584 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3585 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3586 "#ATOMOR16 PSEUDO!",
3587 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3588 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3589 "#ATOMXOR16 PSEUDO!",
3590 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3591 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3592 "#ATOMNAND16 PSEUDO!",
3593 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3594 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3595 "#ATOMMIN16 PSEUDO!",
3596 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3597 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3598 "#ATOMMAX16 PSEUDO!",
3599 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3600 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3601 "#ATOMUMIN16 PSEUDO!",
3602 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3603 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3604 "#ATOMUMAX16 PSEUDO!",
3605 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3607 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3608 "#ATOMAND8 PSEUDO!",
3609 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3610 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3612 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3613 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3614 "#ATOMXOR8 PSEUDO!",
3615 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3616 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3617 "#ATOMNAND8 PSEUDO!",
3618 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3621 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3622 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3623 Uses = [EAX, EBX, ECX, EDX],
3624 mayLoad = 1, mayStore = 1,
3625 usesCustomDAGSchedInserter = 1 in {
3626 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3627 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3628 "#ATOMAND6432 PSEUDO!", []>;
3629 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3630 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3631 "#ATOMOR6432 PSEUDO!", []>;
3632 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3633 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3634 "#ATOMXOR6432 PSEUDO!", []>;
3635 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3636 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3637 "#ATOMNAND6432 PSEUDO!", []>;
3638 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3639 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3640 "#ATOMADD6432 PSEUDO!", []>;
3641 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3642 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3643 "#ATOMSUB6432 PSEUDO!", []>;
3644 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3645 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3646 "#ATOMSWAP6432 PSEUDO!", []>;
3649 //===----------------------------------------------------------------------===//
3650 // Non-Instruction Patterns
3651 //===----------------------------------------------------------------------===//
3653 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3654 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3655 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3656 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3657 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3658 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3660 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3661 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3662 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3663 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3664 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3665 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3666 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3667 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3669 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3670 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3671 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3672 (MOV32mi addr:$dst, texternalsym:$src)>;
3676 def : Pat<(X86tcret GR32:$dst, imm:$off),
3677 (TCRETURNri GR32:$dst, imm:$off)>;
3679 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3680 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3682 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3683 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3685 // Normal calls, with various flavors of addresses.
3686 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3687 (CALLpcrel32 tglobaladdr:$dst)>;
3688 def : Pat<(X86call (i32 texternalsym:$dst)),
3689 (CALLpcrel32 texternalsym:$dst)>;
3690 def : Pat<(X86call (i32 imm:$dst)),
3691 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
3693 // X86 specific add which produces a flag.
3694 def : Pat<(addc GR32:$src1, GR32:$src2),
3695 (ADD32rr GR32:$src1, GR32:$src2)>;
3696 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3697 (ADD32rm GR32:$src1, addr:$src2)>;
3698 def : Pat<(addc GR32:$src1, imm:$src2),
3699 (ADD32ri GR32:$src1, imm:$src2)>;
3700 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3701 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3703 def : Pat<(subc GR32:$src1, GR32:$src2),
3704 (SUB32rr GR32:$src1, GR32:$src2)>;
3705 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3706 (SUB32rm GR32:$src1, addr:$src2)>;
3707 def : Pat<(subc GR32:$src1, imm:$src2),
3708 (SUB32ri GR32:$src1, imm:$src2)>;
3709 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3710 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3714 // TEST R,R is smaller than CMP R,0
3715 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3716 (TEST8rr GR8:$src1, GR8:$src1)>;
3717 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3718 (TEST16rr GR16:$src1, GR16:$src1)>;
3719 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3720 (TEST32rr GR32:$src1, GR32:$src1)>;
3722 // Conditional moves with folded loads with operands swapped and conditions
3724 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3725 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3726 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3727 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3728 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3729 (CMOVB16rm GR16:$src2, addr:$src1)>;
3730 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3731 (CMOVB32rm GR32:$src2, addr:$src1)>;
3732 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3733 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3734 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3735 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3736 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3737 (CMOVE16rm GR16:$src2, addr:$src1)>;
3738 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3739 (CMOVE32rm GR32:$src2, addr:$src1)>;
3740 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3741 (CMOVA16rm GR16:$src2, addr:$src1)>;
3742 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3743 (CMOVA32rm GR32:$src2, addr:$src1)>;
3744 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3745 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3746 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3747 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3748 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3749 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3750 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3751 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3752 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3753 (CMOVL16rm GR16:$src2, addr:$src1)>;
3754 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3755 (CMOVL32rm GR32:$src2, addr:$src1)>;
3756 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3757 (CMOVG16rm GR16:$src2, addr:$src1)>;
3758 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3759 (CMOVG32rm GR32:$src2, addr:$src1)>;
3760 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3761 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3762 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3763 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3764 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3765 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3766 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3767 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3768 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3769 (CMOVP16rm GR16:$src2, addr:$src1)>;
3770 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3771 (CMOVP32rm GR32:$src2, addr:$src1)>;
3772 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3773 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3774 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3775 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3776 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3777 (CMOVS16rm GR16:$src2, addr:$src1)>;
3778 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3779 (CMOVS32rm GR32:$src2, addr:$src1)>;
3780 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3781 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3782 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3783 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3784 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3785 (CMOVO16rm GR16:$src2, addr:$src1)>;
3786 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3787 (CMOVO32rm GR32:$src2, addr:$src1)>;
3789 // zextload bool -> zextload byte
3790 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3791 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3792 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3794 // extload bool -> extload byte
3795 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3796 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3797 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3798 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
3799 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3800 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3802 // anyext. Define these to do an explicit zero-extend to
3803 // avoid partial-register updates.
3804 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3805 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3806 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
3808 // (and (i32 load), 255) -> (zextload i8)
3809 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3810 (MOVZX32rm8 addr:$src)>;
3811 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3812 (MOVZX32rm16 addr:$src)>;
3814 //===----------------------------------------------------------------------===//
3816 //===----------------------------------------------------------------------===//
3818 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3819 // +128 doesn't, so in this special case use a sub instead of an add.
3820 def : Pat<(add GR16:$src1, 128),
3821 (SUB16ri8 GR16:$src1, -128)>;
3822 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3823 (SUB16mi8 addr:$dst, -128)>;
3824 def : Pat<(add GR32:$src1, 128),
3825 (SUB32ri8 GR32:$src1, -128)>;
3826 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3827 (SUB32mi8 addr:$dst, -128)>;
3829 // r & (2^16-1) ==> movz
3830 def : Pat<(and GR32:$src1, 0xffff),
3831 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
3832 // r & (2^8-1) ==> movz
3833 def : Pat<(and GR32:$src1, 0xff),
3834 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
3836 Requires<[In32BitMode]>;
3837 // r & (2^8-1) ==> movz
3838 def : Pat<(and GR16:$src1, 0xff),
3839 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
3841 Requires<[In32BitMode]>;
3843 // sext_inreg patterns
3844 def : Pat<(sext_inreg GR32:$src, i16),
3845 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3846 def : Pat<(sext_inreg GR32:$src, i8),
3847 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3849 Requires<[In32BitMode]>;
3850 def : Pat<(sext_inreg GR16:$src, i8),
3851 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3853 Requires<[In32BitMode]>;
3856 def : Pat<(i16 (trunc GR32:$src)),
3857 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
3858 def : Pat<(i8 (trunc GR32:$src)),
3859 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3861 Requires<[In32BitMode]>;
3862 def : Pat<(i8 (trunc GR16:$src)),
3863 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3865 Requires<[In32BitMode]>;
3867 // h-register tricks
3868 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
3869 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3870 x86_subreg_8bit_hi)>,
3871 Requires<[In32BitMode]>;
3872 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
3873 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3874 x86_subreg_8bit_hi)>,
3875 Requires<[In32BitMode]>;
3876 def : Pat<(srl_su GR16:$src, (i8 8)),
3879 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3880 x86_subreg_8bit_hi)),
3882 Requires<[In32BitMode]>;
3883 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3884 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3885 x86_subreg_8bit_hi))>,
3886 Requires<[In32BitMode]>;
3887 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3888 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3889 x86_subreg_8bit_hi))>,
3890 Requires<[In32BitMode]>;
3891 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
3892 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3893 x86_subreg_8bit_hi))>,
3894 Requires<[In32BitMode]>;
3896 // (shl x, 1) ==> (add x, x)
3897 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3898 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3899 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3901 // (shl x (and y, 31)) ==> (shl x, y)
3902 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3903 (SHL8rCL GR8:$src1)>;
3904 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3905 (SHL16rCL GR16:$src1)>;
3906 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3907 (SHL32rCL GR32:$src1)>;
3908 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3909 (SHL8mCL addr:$dst)>;
3910 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3911 (SHL16mCL addr:$dst)>;
3912 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3913 (SHL32mCL addr:$dst)>;
3915 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3916 (SHR8rCL GR8:$src1)>;
3917 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3918 (SHR16rCL GR16:$src1)>;
3919 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3920 (SHR32rCL GR32:$src1)>;
3921 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3922 (SHR8mCL addr:$dst)>;
3923 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3924 (SHR16mCL addr:$dst)>;
3925 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3926 (SHR32mCL addr:$dst)>;
3928 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3929 (SAR8rCL GR8:$src1)>;
3930 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3931 (SAR16rCL GR16:$src1)>;
3932 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3933 (SAR32rCL GR32:$src1)>;
3934 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3935 (SAR8mCL addr:$dst)>;
3936 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3937 (SAR16mCL addr:$dst)>;
3938 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3939 (SAR32mCL addr:$dst)>;
3941 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3942 def : Pat<(or (srl GR32:$src1, CL:$amt),
3943 (shl GR32:$src2, (sub 32, CL:$amt))),
3944 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3946 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3947 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3948 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3950 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3951 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3952 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3954 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3955 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3957 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3959 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3960 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3962 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3963 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3964 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3966 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3967 def : Pat<(or (shl GR32:$src1, CL:$amt),
3968 (srl GR32:$src2, (sub 32, CL:$amt))),
3969 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3971 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3972 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3973 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3975 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3976 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3977 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3979 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3980 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3982 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3984 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3985 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3987 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3988 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3989 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3991 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3992 def : Pat<(or (srl GR16:$src1, CL:$amt),
3993 (shl GR16:$src2, (sub 16, CL:$amt))),
3994 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3996 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3997 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3998 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4000 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4001 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4002 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4004 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4005 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4007 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4009 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4010 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4012 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4013 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4014 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4016 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4017 def : Pat<(or (shl GR16:$src1, CL:$amt),
4018 (srl GR16:$src2, (sub 16, CL:$amt))),
4019 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4021 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4022 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4023 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4025 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4026 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4027 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4029 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4030 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4032 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4034 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4035 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4037 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4038 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4039 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4041 //===----------------------------------------------------------------------===//
4042 // EFLAGS-defining Patterns
4043 //===----------------------------------------------------------------------===//
4045 // Register-Register Addition with EFLAGS result
4046 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
4048 (ADD8rr GR8:$src1, GR8:$src2)>;
4049 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
4051 (ADD16rr GR16:$src1, GR16:$src2)>;
4052 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
4054 (ADD32rr GR32:$src1, GR32:$src2)>;
4056 // Register-Memory Addition with EFLAGS result
4057 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
4059 (ADD8rm GR8:$src1, addr:$src2)>;
4060 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
4062 (ADD16rm GR16:$src1, addr:$src2)>;
4063 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
4065 (ADD32rm GR32:$src1, addr:$src2)>;
4067 // Register-Integer Addition with EFLAGS result
4068 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
4070 (ADD8ri GR8:$src1, imm:$src2)>;
4071 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
4073 (ADD16ri GR16:$src1, imm:$src2)>;
4074 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
4076 (ADD32ri GR32:$src1, imm:$src2)>;
4077 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
4079 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4080 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
4082 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4084 // Memory-Register Addition with EFLAGS result
4085 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
4088 (ADD8mr addr:$dst, GR8:$src2)>;
4089 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
4092 (ADD16mr addr:$dst, GR16:$src2)>;
4093 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
4096 (ADD32mr addr:$dst, GR32:$src2)>;
4098 // Memory-Integer Addition with EFLAGS result
4099 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
4102 (ADD8mi addr:$dst, imm:$src2)>;
4103 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
4106 (ADD16mi addr:$dst, imm:$src2)>;
4107 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
4110 (ADD32mi addr:$dst, imm:$src2)>;
4111 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4114 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
4115 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4118 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4120 // Register-Register Subtraction with EFLAGS result
4121 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
4123 (SUB8rr GR8:$src1, GR8:$src2)>;
4124 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
4126 (SUB16rr GR16:$src1, GR16:$src2)>;
4127 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
4129 (SUB32rr GR32:$src1, GR32:$src2)>;
4131 // Register-Memory Subtraction with EFLAGS result
4132 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
4134 (SUB8rm GR8:$src1, addr:$src2)>;
4135 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
4137 (SUB16rm GR16:$src1, addr:$src2)>;
4138 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
4140 (SUB32rm GR32:$src1, addr:$src2)>;
4142 // Register-Integer Subtraction with EFLAGS result
4143 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
4145 (SUB8ri GR8:$src1, imm:$src2)>;
4146 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
4148 (SUB16ri GR16:$src1, imm:$src2)>;
4149 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
4151 (SUB32ri GR32:$src1, imm:$src2)>;
4152 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
4154 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4155 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
4157 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4159 // Memory-Register Subtraction with EFLAGS result
4160 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
4163 (SUB8mr addr:$dst, GR8:$src2)>;
4164 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
4167 (SUB16mr addr:$dst, GR16:$src2)>;
4168 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
4171 (SUB32mr addr:$dst, GR32:$src2)>;
4173 // Memory-Integer Subtraction with EFLAGS result
4174 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
4177 (SUB8mi addr:$dst, imm:$src2)>;
4178 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
4181 (SUB16mi addr:$dst, imm:$src2)>;
4182 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
4185 (SUB32mi addr:$dst, imm:$src2)>;
4186 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4189 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
4190 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4193 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4196 // Register-Register Signed Integer Multiply with EFLAGS result
4197 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
4199 (IMUL16rr GR16:$src1, GR16:$src2)>;
4200 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
4202 (IMUL32rr GR32:$src1, GR32:$src2)>;
4204 // Register-Memory Signed Integer Multiply with EFLAGS result
4205 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
4207 (IMUL16rm GR16:$src1, addr:$src2)>;
4208 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
4210 (IMUL32rm GR32:$src1, addr:$src2)>;
4212 // Register-Integer Signed Integer Multiply with EFLAGS result
4213 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
4215 (IMUL16rri GR16:$src1, imm:$src2)>;
4216 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
4218 (IMUL32rri GR32:$src1, imm:$src2)>;
4219 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
4221 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4222 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
4224 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4226 // Memory-Integer Signed Integer Multiply with EFLAGS result
4227 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
4229 (IMUL16rmi addr:$src1, imm:$src2)>;
4230 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
4232 (IMUL32rmi addr:$src1, imm:$src2)>;
4233 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
4235 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4236 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
4238 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4240 // Optimize multiply by 2 with EFLAGS result.
4241 let AddedComplexity = 2 in {
4242 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
4244 (ADD16rr GR16:$src1, GR16:$src1)>;
4246 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
4248 (ADD32rr GR32:$src1, GR32:$src1)>;
4251 // INC and DEC with EFLAGS result. Note that these do not set CF.
4252 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4254 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4257 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4259 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4263 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
4264 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4265 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4267 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
4268 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
4269 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4270 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4272 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
4274 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
4275 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4276 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4278 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
4279 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
4280 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4281 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4283 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
4285 // -disable-16bit support.
4286 def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
4287 (MOV16mi addr:$dst, imm:$src)>;
4288 def : Pat<(truncstorei16 GR32:$src, addr:$dst),
4289 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4290 def : Pat<(i32 (sextloadi16 addr:$dst)),
4291 (MOVSX32rm16 addr:$dst)>;
4292 def : Pat<(i32 (zextloadi16 addr:$dst)),
4293 (MOVZX32rm16 addr:$dst)>;
4294 def : Pat<(i32 (extloadi16 addr:$dst)),
4295 (MOVZX32rm16 addr:$dst)>;
4297 //===----------------------------------------------------------------------===//
4298 // Floating Point Stack Support
4299 //===----------------------------------------------------------------------===//
4301 include "X86InstrFPStack.td"
4303 //===----------------------------------------------------------------------===//
4305 //===----------------------------------------------------------------------===//
4307 include "X86Instr64bit.td"
4309 //===----------------------------------------------------------------------===//
4310 // XMM Floating point support (requires SSE / SSE2)
4311 //===----------------------------------------------------------------------===//
4313 include "X86InstrSSE.td"
4315 //===----------------------------------------------------------------------===//
4316 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4317 //===----------------------------------------------------------------------===//
4319 include "X86InstrMMX.td"