1 //===----------------------------------------------------------------------===//
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<1, 2, [SDTCisVT<0, i32>, SDTCisSameAs<1, 2>]>;
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<2, 1,
32 [SDTCisInt<0>, SDTCisVT<1, i32>]>;
34 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
37 SDTCisInt<0>, SDTCisVT<1, i32>]>;
38 def SDTX86BrCond : SDTypeProfile<0, 3,
39 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
42 def SDTX86SetCC : SDTypeProfile<1, 2,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
45 def SDTX86SetCC_C : SDTypeProfile<1, 2,
47 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
49 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
51 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
53 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
54 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
55 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
57 def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
58 def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
61 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
63 def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
67 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
69 def SDTX86Void : SDTypeProfile<0, 0, []>;
71 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
73 def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
75 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
77 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
79 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
81 def X86bsf : SDNode<"X86ISD::BSF", SDTUnaryArithWithFlags>;
82 def X86bsr : SDNode<"X86ISD::BSR", SDTUnaryArithWithFlags>;
83 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
84 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
86 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
87 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
89 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
90 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
92 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
93 def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
95 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
96 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
98 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
99 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
101 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
102 [SDNPHasChain, SDNPMayStore,
103 SDNPMayLoad, SDNPMemOperand]>;
104 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
105 [SDNPHasChain, SDNPMayStore,
106 SDNPMayLoad, SDNPMemOperand]>;
107 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
108 [SDNPHasChain, SDNPMayStore,
109 SDNPMayLoad, SDNPMemOperand]>;
110 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
111 [SDNPHasChain, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
113 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
114 [SDNPHasChain, SDNPMayStore,
115 SDNPMayLoad, SDNPMemOperand]>;
116 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
117 [SDNPHasChain, SDNPMayStore,
118 SDNPMayLoad, SDNPMemOperand]>;
119 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
120 [SDNPHasChain, SDNPMayStore,
121 SDNPMayLoad, SDNPMemOperand]>;
122 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
123 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
125 def X86vastart_save_xmm_regs :
126 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
127 SDT_X86VASTART_SAVE_XMM_REGS,
128 [SDNPHasChain, SDNPVariadic]>;
130 def X86callseq_start :
131 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
132 [SDNPHasChain, SDNPOutFlag]>;
134 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
135 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
137 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
138 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag,
141 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
142 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
143 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
144 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
147 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
148 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
150 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
151 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
153 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
154 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
155 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
156 SDT_X86SegmentBaseAddress, []>;
158 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
161 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
162 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
164 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
166 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
167 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
169 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
172 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
173 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
174 def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
176 def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
178 def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
181 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
183 def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
184 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
186 //===----------------------------------------------------------------------===//
187 // X86 Operand Definitions.
190 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
191 // the index operand of an address, to conform to x86 encoding restrictions.
192 def ptr_rc_nosp : PointerLikeRegClass<1>;
194 // *mem - Operand definitions for the funky X86 addressing mode operands.
196 def X86MemAsmOperand : AsmOperandClass {
200 def X86NoSegMemAsmOperand : AsmOperandClass {
201 let Name = "NoSegMem";
202 let SuperClass = X86MemAsmOperand;
204 def X86AbsMemAsmOperand : AsmOperandClass {
206 let SuperClass = X86NoSegMemAsmOperand;
208 class X86MemOperand<string printMethod> : Operand<iPTR> {
209 let PrintMethod = printMethod;
210 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
211 let ParserMatchClass = X86MemAsmOperand;
214 def opaque32mem : X86MemOperand<"printopaquemem">;
215 def opaque48mem : X86MemOperand<"printopaquemem">;
216 def opaque80mem : X86MemOperand<"printopaquemem">;
217 def opaque512mem : X86MemOperand<"printopaquemem">;
219 def i8mem : X86MemOperand<"printi8mem">;
220 def i16mem : X86MemOperand<"printi16mem">;
221 def i32mem : X86MemOperand<"printi32mem">;
222 def i64mem : X86MemOperand<"printi64mem">;
223 def i128mem : X86MemOperand<"printi128mem">;
224 //def i256mem : X86MemOperand<"printi256mem">;
225 def f32mem : X86MemOperand<"printf32mem">;
226 def f64mem : X86MemOperand<"printf64mem">;
227 def f80mem : X86MemOperand<"printf80mem">;
228 def f128mem : X86MemOperand<"printf128mem">;
229 //def f256mem : X86MemOperand<"printf256mem">;
231 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
232 // plain GR64, so that it doesn't potentially require a REX prefix.
233 def i8mem_NOREX : Operand<i64> {
234 let PrintMethod = "printi8mem";
235 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
236 let ParserMatchClass = X86MemAsmOperand;
239 // Special i32mem for addresses of load folding tail calls. These are not
240 // allowed to use callee-saved registers since they must be scheduled
241 // after callee-saved register are popped.
242 def i32mem_TC : Operand<i32> {
243 let PrintMethod = "printi32mem";
244 let MIOperandInfo = (ops GR32_TC, i8imm, GR32_TC, i32imm, i8imm);
245 let ParserMatchClass = X86MemAsmOperand;
248 def lea32mem : Operand<i32> {
249 let PrintMethod = "printlea32mem";
250 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
251 let ParserMatchClass = X86NoSegMemAsmOperand;
254 let ParserMatchClass = X86AbsMemAsmOperand,
255 PrintMethod = "print_pcrel_imm" in {
256 def i32imm_pcrel : Operand<i32>;
258 def offset8 : Operand<i64>;
259 def offset16 : Operand<i64>;
260 def offset32 : Operand<i64>;
261 def offset64 : Operand<i64>;
263 // Branch targets have OtherVT type and print as pc-relative values.
264 def brtarget : Operand<OtherVT>;
265 def brtarget8 : Operand<OtherVT>;
269 def SSECC : Operand<i8> {
270 let PrintMethod = "printSSECC";
273 def ImmSExt8AsmOperand : AsmOperandClass {
274 let Name = "ImmSExt8";
275 let SuperClass = ImmAsmOperand;
278 // A couple of more descriptive operand definitions.
279 // 16-bits but only 8 bits are significant.
280 def i16i8imm : Operand<i16> {
281 let ParserMatchClass = ImmSExt8AsmOperand;
283 // 32-bits but only 8 bits are significant.
284 def i32i8imm : Operand<i32> {
285 let ParserMatchClass = ImmSExt8AsmOperand;
288 //===----------------------------------------------------------------------===//
289 // X86 Complex Pattern Definitions.
292 // Define X86 specific addressing mode.
293 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
294 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
295 [add, sub, mul, X86mul_imm, shl, or, frameindex],
297 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
298 [tglobaltlsaddr], []>;
300 //===----------------------------------------------------------------------===//
301 // X86 Instruction Predicate Definitions.
302 def HasCMov : Predicate<"Subtarget->hasCMov()">;
303 def NoCMov : Predicate<"!Subtarget->hasCMov()">;
304 def HasMMX : Predicate<"Subtarget->hasMMX()">;
305 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
306 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
307 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
308 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
309 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
310 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
311 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
312 def HasAVX : Predicate<"Subtarget->hasAVX()">;
313 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
314 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
315 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
316 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
317 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
318 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
319 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
320 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
321 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
322 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
323 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
324 "TM.getCodeModel() != CodeModel::Kernel">;
325 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
326 "TM.getCodeModel() == CodeModel::Kernel">;
327 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
328 def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
329 def OptForSize : Predicate<"OptForSize">;
330 def OptForSpeed : Predicate<"!OptForSize">;
331 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
332 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
333 def HasAES : Predicate<"Subtarget->hasAES()">;
335 //===----------------------------------------------------------------------===//
336 // X86 Instruction Format Definitions.
339 include "X86InstrFormats.td"
341 //===----------------------------------------------------------------------===//
342 // Pattern fragments...
345 // X86 specific condition code. These correspond to CondCode in
346 // X86InstrInfo.h. They must be kept in synch.
347 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
348 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
349 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
350 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
351 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
352 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
353 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
354 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
355 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
356 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
357 def X86_COND_NO : PatLeaf<(i8 10)>;
358 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
359 def X86_COND_NS : PatLeaf<(i8 12)>;
360 def X86_COND_O : PatLeaf<(i8 13)>;
361 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
362 def X86_COND_S : PatLeaf<(i8 15)>;
364 def immSext8 : PatLeaf<(imm), [{
365 return N->getSExtValue() == (int8_t)N->getSExtValue();
368 def i16immSExt8 : PatLeaf<(i16 immSext8)>;
369 def i32immSExt8 : PatLeaf<(i32 immSext8)>;
371 /// Load patterns: these constraint the match to the right address space.
372 def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
373 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
374 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
375 if (PT->getAddressSpace() > 255)
380 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
381 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
382 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
383 return PT->getAddressSpace() == 256;
387 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
388 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
389 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
390 return PT->getAddressSpace() == 257;
395 // Helper fragments for loads.
396 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
397 // known to be 32-bit aligned or better. Ditto for i8 to i16.
398 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
399 LoadSDNode *LD = cast<LoadSDNode>(N);
400 if (const Value *Src = LD->getSrcValue())
401 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
402 if (PT->getAddressSpace() > 255)
404 ISD::LoadExtType ExtType = LD->getExtensionType();
405 if (ExtType == ISD::NON_EXTLOAD)
407 if (ExtType == ISD::EXTLOAD)
408 return LD->getAlignment() >= 2 && !LD->isVolatile();
412 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
413 LoadSDNode *LD = cast<LoadSDNode>(N);
414 if (const Value *Src = LD->getSrcValue())
415 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
416 if (PT->getAddressSpace() > 255)
418 ISD::LoadExtType ExtType = LD->getExtensionType();
419 if (ExtType == ISD::EXTLOAD)
420 return LD->getAlignment() >= 2 && !LD->isVolatile();
424 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
425 LoadSDNode *LD = cast<LoadSDNode>(N);
426 if (const Value *Src = LD->getSrcValue())
427 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
428 if (PT->getAddressSpace() > 255)
430 ISD::LoadExtType ExtType = LD->getExtensionType();
431 if (ExtType == ISD::NON_EXTLOAD)
433 if (ExtType == ISD::EXTLOAD)
434 return LD->getAlignment() >= 4 && !LD->isVolatile();
438 def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
439 def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
440 def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
441 def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
442 def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
444 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
445 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
446 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
448 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
449 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
450 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
451 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
452 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
453 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
455 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
456 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
457 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
458 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
459 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
460 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
463 // An 'and' node with a single use.
464 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
465 return N->hasOneUse();
467 // An 'srl' node with a single use.
468 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
469 return N->hasOneUse();
471 // An 'trunc' node with a single use.
472 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
473 return N->hasOneUse();
476 // Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
477 def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
478 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
479 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
481 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
482 APInt Mask = APInt::getAllOnesValue(BitWidth);
483 APInt KnownZero0, KnownOne0;
484 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
485 APInt KnownZero1, KnownOne1;
486 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
487 return (~KnownZero0 & ~KnownZero1) == 0;
490 //===----------------------------------------------------------------------===//
491 // Instruction list...
494 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
495 // a stack adjustment and the codegen must know that they may modify the stack
496 // pointer before prolog-epilog rewriting occurs.
497 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
498 // sub / add which can clobber EFLAGS.
499 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
500 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
502 [(X86callseq_start timm:$amt)]>,
503 Requires<[In32BitMode]>;
504 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
506 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
507 Requires<[In32BitMode]>;
510 // x86-64 va_start lowering magic.
511 let usesCustomInserter = 1 in {
512 def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
515 i64imm:$regsavefi, i64imm:$offset,
517 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
518 [(X86vastart_save_xmm_regs GR8:$al,
522 // Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls
523 // to _alloca is needed to probe the stack when allocating more than 4k bytes in
524 // one go. Touching the stack at 4K increments is necessary to ensure that the
525 // guard pages used by the OS virtual memory manager are allocated in correct
527 // The main point of having separate instruction are extra unmodelled effects
528 // (compared to ordinary calls) like stack pointer change.
530 def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
531 "# dynamic stack allocation",
536 let neverHasSideEffects = 1 in {
537 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
538 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
539 "nop{w}\t$zero", []>, TB, OpSize;
540 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
541 "nop{l}\t$zero", []>, TB;
545 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
546 def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
547 def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
548 def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
550 // PIC base construction. This expands to code that looks like this:
553 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
554 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
557 //===----------------------------------------------------------------------===//
558 // Control Flow Instructions.
561 // Return instructions.
562 let isTerminator = 1, isReturn = 1, isBarrier = 1,
563 hasCtrlDep = 1, FPForm = SpecialFP in {
564 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
567 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
569 [(X86retflag timm:$amt)]>;
570 def LRET : I <0xCB, RawFrm, (outs), (ins),
572 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
576 // Unconditional branches.
577 let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
578 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
579 "jmp\t$dst", [(br bb:$dst)]>;
580 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
584 // Conditional Branches.
585 let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
586 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
587 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
588 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
589 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
593 defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
594 defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
595 defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
596 defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
597 defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
598 defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
599 defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
600 defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
601 defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
602 defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
603 defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
604 defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
605 defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
606 defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
607 defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
608 defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
610 // FIXME: What about the CX/RCX versions of this instruction?
611 let Uses = [ECX], isBranch = 1, isTerminator = 1 in
612 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
617 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
618 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
619 [(brind GR32:$dst)]>;
620 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
621 [(brind (loadi32 addr:$dst))]>;
623 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
624 (ins i16imm:$seg, i16imm:$off),
625 "ljmp{w}\t$seg, $off", []>, OpSize;
626 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
627 (ins i16imm:$seg, i32imm:$off),
628 "ljmp{l}\t$seg, $off", []>;
630 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
631 "ljmp{w}\t{*}$dst", []>, OpSize;
632 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
633 "ljmp{l}\t{*}$dst", []>;
639 def LOOP : I<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
640 def LOOPE : I<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
641 def LOOPNE : I<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;
643 //===----------------------------------------------------------------------===//
644 // Call Instructions...
647 // All calls clobber the non-callee saved registers. ESP is marked as
648 // a use to prevent stack-pointer assignments that appear immediately
649 // before calls from potentially appearing dead. Uses for argument
650 // registers are added manually.
651 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
652 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
653 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
654 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
656 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
657 (outs), (ins i32imm_pcrel:$dst,variable_ops),
659 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
660 "call\t{*}$dst", [(X86call GR32:$dst)]>;
661 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
662 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
664 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
665 (ins i16imm:$seg, i16imm:$off),
666 "lcall{w}\t$seg, $off", []>, OpSize;
667 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
668 (ins i16imm:$seg, i32imm:$off),
669 "lcall{l}\t$seg, $off", []>;
671 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
672 "lcall{w}\t{*}$dst", []>, OpSize;
673 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
674 "lcall{l}\t{*}$dst", []>;
677 // Constructing a stack frame.
679 def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
680 "enter\t$len, $lvl", []>;
684 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
685 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
686 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
687 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
688 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
690 def TCRETURNdi : I<0, Pseudo, (outs),
691 (ins i32imm_pcrel:$dst, i32imm:$offset, variable_ops),
692 "#TC_RETURN $dst $offset", []>;
693 def TCRETURNri : I<0, Pseudo, (outs),
694 (ins GR32_TC:$dst, i32imm:$offset, variable_ops),
695 "#TC_RETURN $dst $offset", []>;
697 def TCRETURNmi : I<0, Pseudo, (outs),
698 (ins i32mem_TC:$dst, i32imm:$offset, variable_ops),
699 "#TC_RETURN $dst $offset", []>;
701 // FIXME: The should be pseudo instructions that are lowered when going to
703 def TAILJMPd : Ii32PCRel<0xE9, RawFrm, (outs),
704 (ins i32imm_pcrel:$dst, variable_ops),
705 "jmp\t$dst # TAILCALL",
707 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32_TC:$dst, variable_ops),
708 "jmp{l}\t{*}$dst # TAILCALL",
711 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
712 "jmp{l}\t{*}$dst # TAILCALL", []>;
715 //===----------------------------------------------------------------------===//
716 // Miscellaneous Instructions...
718 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
719 def LEAVE : I<0xC9, RawFrm,
720 (outs), (ins), "leave", []>;
722 def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
723 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
725 def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
726 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
727 def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
728 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
730 def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
731 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
733 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
735 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
737 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
738 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
740 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
742 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
743 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
746 let mayStore = 1 in {
747 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
749 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
750 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
752 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
754 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
755 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
759 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
760 def PUSHi8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
761 "push{l}\t$imm", []>;
762 def PUSHi16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
763 "push{w}\t$imm", []>, OpSize;
764 def PUSHi32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
765 "push{l}\t$imm", []>;
768 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
769 def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
770 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
772 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
773 def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
774 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
777 let isTwoAddress = 1 in // GR32 = bswap GR32
778 def BSWAP32r : I<0xC8, AddRegFrm,
779 (outs GR32:$dst), (ins GR32:$src),
781 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
784 // Bit scan instructions.
785 let Defs = [EFLAGS] in {
786 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
787 "bsf{w}\t{$src, $dst|$dst, $src}",
788 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB, OpSize;
789 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
790 "bsf{w}\t{$src, $dst|$dst, $src}",
791 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB,
793 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
794 "bsf{l}\t{$src, $dst|$dst, $src}",
795 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
796 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
797 "bsf{l}\t{$src, $dst|$dst, $src}",
798 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
800 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
801 "bsr{w}\t{$src, $dst|$dst, $src}",
802 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB, OpSize;
803 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
804 "bsr{w}\t{$src, $dst|$dst, $src}",
805 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB,
807 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
808 "bsr{l}\t{$src, $dst|$dst, $src}",
809 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
810 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
811 "bsr{l}\t{$src, $dst|$dst, $src}",
812 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
815 let neverHasSideEffects = 1 in
816 def LEA16r : I<0x8D, MRMSrcMem,
817 (outs GR16:$dst), (ins lea32mem:$src),
818 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
819 let isReMaterializable = 1 in
820 def LEA32r : I<0x8D, MRMSrcMem,
821 (outs GR32:$dst), (ins lea32mem:$src),
822 "lea{l}\t{$src|$dst}, {$dst|$src}",
823 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
825 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
826 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
827 [(X86rep_movs i8)]>, REP;
828 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
829 [(X86rep_movs i16)]>, REP, OpSize;
830 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
831 [(X86rep_movs i32)]>, REP;
834 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
835 let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
836 def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
837 def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
838 def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
841 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
842 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
843 [(X86rep_stos i8)]>, REP;
844 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
845 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
846 [(X86rep_stos i16)]>, REP, OpSize;
847 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
848 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
849 [(X86rep_stos i32)]>, REP;
851 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
852 let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
853 def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
854 let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
855 def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
856 let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
857 def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
859 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
860 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
861 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
863 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
864 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
865 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
867 let Defs = [RAX, RDX] in
868 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
871 let Defs = [RAX, RCX, RDX] in
872 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
874 let isBarrier = 1, hasCtrlDep = 1 in {
875 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
878 def SYSCALL : I<0x05, RawFrm,
879 (outs), (ins), "syscall", []>, TB;
880 def SYSRET : I<0x07, RawFrm,
881 (outs), (ins), "sysret", []>, TB;
882 def SYSENTER : I<0x34, RawFrm,
883 (outs), (ins), "sysenter", []>, TB;
884 def SYSEXIT : I<0x35, RawFrm,
885 (outs), (ins), "sysexit", []>, TB;
887 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
890 //===----------------------------------------------------------------------===//
891 // Input/Output Instructions...
893 let Defs = [AL], Uses = [DX] in
894 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
895 "in{b}\t{%dx, %al|%AL, %DX}", []>;
896 let Defs = [AX], Uses = [DX] in
897 def IN16rr : I<0xED, RawFrm, (outs), (ins),
898 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
899 let Defs = [EAX], Uses = [DX] in
900 def IN32rr : I<0xED, RawFrm, (outs), (ins),
901 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
904 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
905 "in{b}\t{$port, %al|%AL, $port}", []>;
907 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
908 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
910 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
911 "in{l}\t{$port, %eax|%EAX, $port}", []>;
913 let Uses = [DX, AL] in
914 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
915 "out{b}\t{%al, %dx|%DX, %AL}", []>;
916 let Uses = [DX, AX] in
917 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
918 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
919 let Uses = [DX, EAX] in
920 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
921 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
924 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
925 "out{b}\t{%al, $port|$port, %AL}", []>;
927 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
928 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
930 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
931 "out{l}\t{%eax, $port|$port, %EAX}", []>;
933 def IN8 : I<0x6C, RawFrm, (outs), (ins),
935 def IN16 : I<0x6D, RawFrm, (outs), (ins),
936 "ins{w}", []>, OpSize;
937 def IN32 : I<0x6D, RawFrm, (outs), (ins),
940 //===----------------------------------------------------------------------===//
941 // Move Instructions...
943 let neverHasSideEffects = 1 in {
944 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
945 "mov{b}\t{$src, $dst|$dst, $src}", []>;
946 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
947 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
948 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
949 "mov{l}\t{$src, $dst|$dst, $src}", []>;
951 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
952 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
953 "mov{b}\t{$src, $dst|$dst, $src}",
954 [(set GR8:$dst, imm:$src)]>;
955 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
956 "mov{w}\t{$src, $dst|$dst, $src}",
957 [(set GR16:$dst, imm:$src)]>, OpSize;
958 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
959 "mov{l}\t{$src, $dst|$dst, $src}",
960 [(set GR32:$dst, imm:$src)]>;
963 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
964 "mov{b}\t{$src, $dst|$dst, $src}",
965 [(store (i8 imm:$src), addr:$dst)]>;
966 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
967 "mov{w}\t{$src, $dst|$dst, $src}",
968 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
969 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
970 "mov{l}\t{$src, $dst|$dst, $src}",
971 [(store (i32 imm:$src), addr:$dst)]>;
973 /// moffs8, moffs16 and moffs32 versions of moves. The immediate is a
974 /// 32-bit offset from the PC. These are only valid in x86-32 mode.
975 def MOV8o8a : Ii32 <0xA0, RawFrm, (outs), (ins offset8:$src),
976 "mov{b}\t{$src, %al|%al, $src}", []>;
977 def MOV16o16a : Ii32 <0xA1, RawFrm, (outs), (ins offset16:$src),
978 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
979 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
980 "mov{l}\t{$src, %eax|%eax, $src}", []>;
981 def MOV8ao8 : Ii32 <0xA2, RawFrm, (outs offset8:$dst), (ins),
982 "mov{b}\t{%al, $dst|$dst, %al}", []>;
983 def MOV16ao16 : Ii32 <0xA3, RawFrm, (outs offset16:$dst), (ins),
984 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
985 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
986 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
988 // Moves to and from segment registers
989 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
990 "mov{w}\t{$src, $dst|$dst, $src}", []>;
991 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
992 "mov{w}\t{$src, $dst|$dst, $src}", []>;
993 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
994 "mov{w}\t{$src, $dst|$dst, $src}", []>;
995 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
996 "mov{w}\t{$src, $dst|$dst, $src}", []>;
998 def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
999 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1000 def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1001 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1002 def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1003 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1005 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1006 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
1007 "mov{b}\t{$src, $dst|$dst, $src}",
1008 [(set GR8:$dst, (loadi8 addr:$src))]>;
1009 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
1010 "mov{w}\t{$src, $dst|$dst, $src}",
1011 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
1012 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
1013 "mov{l}\t{$src, $dst|$dst, $src}",
1014 [(set GR32:$dst, (loadi32 addr:$src))]>;
1017 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
1018 "mov{b}\t{$src, $dst|$dst, $src}",
1019 [(store GR8:$src, addr:$dst)]>;
1020 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1021 "mov{w}\t{$src, $dst|$dst, $src}",
1022 [(store GR16:$src, addr:$dst)]>, OpSize;
1023 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1024 "mov{l}\t{$src, $dst|$dst, $src}",
1025 [(store GR32:$src, addr:$dst)]>;
1027 /// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
1028 let neverHasSideEffects = 1 in
1029 def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1030 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1033 canFoldAsLoad = 1, isReMaterializable = 1 in
1034 def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1035 "mov{l}\t{$src, $dst|$dst, $src}",
1039 def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1040 "mov{l}\t{$src, $dst|$dst, $src}",
1043 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1044 // that they can be used for copying and storing h registers, which can't be
1045 // encoded when a REX prefix is present.
1046 let neverHasSideEffects = 1 in
1047 def MOV8rr_NOREX : I<0x88, MRMDestReg,
1048 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
1049 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1051 def MOV8mr_NOREX : I<0x88, MRMDestMem,
1052 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1053 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1055 canFoldAsLoad = 1, isReMaterializable = 1 in
1056 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1057 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1058 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1060 // Moves to and from debug registers
1061 def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1062 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1063 def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1064 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1066 // Moves to and from control registers
1067 def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
1068 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1069 def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
1070 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1072 //===----------------------------------------------------------------------===//
1073 // Fixed-Register Multiplication and Division Instructions...
1076 // Extra precision multiplication
1078 // AL is really implied by AX, by the registers in Defs must match the
1079 // SDNode results (i8, i32).
1080 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1081 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
1082 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1083 // This probably ought to be moved to a def : Pat<> if the
1084 // syntax can be accepted.
1085 [(set AL, (mul AL, GR8:$src)),
1086 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1088 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1089 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1091 []>, OpSize; // AX,DX = AX*GR16
1093 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1094 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1096 []>; // EAX,EDX = EAX*GR32
1098 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1099 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1101 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1102 // This probably ought to be moved to a def : Pat<> if the
1103 // syntax can be accepted.
1104 [(set AL, (mul AL, (loadi8 addr:$src))),
1105 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1107 let mayLoad = 1, neverHasSideEffects = 1 in {
1108 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1109 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1111 []>, OpSize; // AX,DX = AX*[mem16]
1113 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1114 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1116 []>; // EAX,EDX = EAX*[mem32]
1119 let neverHasSideEffects = 1 in {
1120 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1121 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1123 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1124 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
1125 OpSize; // AX,DX = AX*GR16
1126 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1127 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1128 // EAX,EDX = EAX*GR32
1129 let mayLoad = 1 in {
1130 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1131 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1132 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
1133 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1134 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1135 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1136 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1137 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1138 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
1140 } // neverHasSideEffects
1142 // unsigned division/remainder
1143 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1144 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1145 "div{b}\t$src", []>;
1146 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1147 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1148 "div{w}\t$src", []>, OpSize;
1149 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1150 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1151 "div{l}\t$src", []>;
1152 let mayLoad = 1 in {
1153 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1154 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1155 "div{b}\t$src", []>;
1156 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1157 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1158 "div{w}\t$src", []>, OpSize;
1159 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1160 // EDX:EAX/[mem32] = EAX,EDX
1161 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
1162 "div{l}\t$src", []>;
1165 // Signed division/remainder.
1166 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1167 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1168 "idiv{b}\t$src", []>;
1169 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1170 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1171 "idiv{w}\t$src", []>, OpSize;
1172 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1173 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1174 "idiv{l}\t$src", []>;
1175 let mayLoad = 1, mayLoad = 1 in {
1176 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1177 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1178 "idiv{b}\t$src", []>;
1179 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1180 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1181 "idiv{w}\t$src", []>, OpSize;
1182 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1183 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1184 // EDX:EAX/[mem32] = EAX,EDX
1185 "idiv{l}\t$src", []>;
1188 //===----------------------------------------------------------------------===//
1189 // Two address Instructions.
1191 let isTwoAddress = 1 in {
1193 // Conditional moves
1194 let Uses = [EFLAGS] in {
1196 let Predicates = [HasCMov] in {
1197 let isCommutable = 1 in {
1198 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1199 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1200 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1201 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1202 X86_COND_B, EFLAGS))]>,
1204 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1205 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1206 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1207 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1208 X86_COND_B, EFLAGS))]>,
1210 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1211 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1212 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1213 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1214 X86_COND_AE, EFLAGS))]>,
1216 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1217 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1218 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1219 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1220 X86_COND_AE, EFLAGS))]>,
1222 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1223 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1224 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1225 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1226 X86_COND_E, EFLAGS))]>,
1228 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1229 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1230 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1231 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1232 X86_COND_E, EFLAGS))]>,
1234 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1235 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1236 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1237 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1238 X86_COND_NE, EFLAGS))]>,
1240 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1241 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1242 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1243 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1244 X86_COND_NE, EFLAGS))]>,
1246 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1247 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1248 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1249 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1250 X86_COND_BE, EFLAGS))]>,
1252 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1253 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1254 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1255 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1256 X86_COND_BE, EFLAGS))]>,
1258 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1259 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1260 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1261 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1262 X86_COND_A, EFLAGS))]>,
1264 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1265 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1266 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1267 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1268 X86_COND_A, EFLAGS))]>,
1270 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1271 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1272 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1273 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1274 X86_COND_L, EFLAGS))]>,
1276 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1277 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1278 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1279 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1280 X86_COND_L, EFLAGS))]>,
1282 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1283 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1284 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1285 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1286 X86_COND_GE, EFLAGS))]>,
1288 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1289 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1290 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1291 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1292 X86_COND_GE, EFLAGS))]>,
1294 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1295 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1296 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1297 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1298 X86_COND_LE, EFLAGS))]>,
1300 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1301 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1302 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1303 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1304 X86_COND_LE, EFLAGS))]>,
1306 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1307 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1308 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1309 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1310 X86_COND_G, EFLAGS))]>,
1312 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1313 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1314 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1315 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1316 X86_COND_G, EFLAGS))]>,
1318 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1319 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1320 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1321 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1322 X86_COND_S, EFLAGS))]>,
1324 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1325 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1326 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1327 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1328 X86_COND_S, EFLAGS))]>,
1330 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1331 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1332 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1333 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1334 X86_COND_NS, EFLAGS))]>,
1336 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1337 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1338 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1339 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1340 X86_COND_NS, EFLAGS))]>,
1342 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1343 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1344 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1345 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1346 X86_COND_P, EFLAGS))]>,
1348 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1349 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1350 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1351 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1352 X86_COND_P, EFLAGS))]>,
1354 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1355 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1356 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1357 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1358 X86_COND_NP, EFLAGS))]>,
1360 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1361 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1362 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1363 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1364 X86_COND_NP, EFLAGS))]>,
1366 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1367 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1368 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1369 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1370 X86_COND_O, EFLAGS))]>,
1372 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1373 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1374 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1375 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1376 X86_COND_O, EFLAGS))]>,
1378 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1379 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1380 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1381 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1382 X86_COND_NO, EFLAGS))]>,
1384 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1385 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1386 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1387 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1388 X86_COND_NO, EFLAGS))]>,
1390 } // isCommutable = 1
1392 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1393 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1394 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1395 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1396 X86_COND_B, EFLAGS))]>,
1398 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1399 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1400 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1401 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1402 X86_COND_B, EFLAGS))]>,
1404 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1405 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1406 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1407 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1408 X86_COND_AE, EFLAGS))]>,
1410 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1411 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1412 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1413 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1414 X86_COND_AE, EFLAGS))]>,
1416 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1417 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1418 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1419 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1420 X86_COND_E, EFLAGS))]>,
1422 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1423 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1424 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1425 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1426 X86_COND_E, EFLAGS))]>,
1428 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1429 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1430 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1431 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1432 X86_COND_NE, EFLAGS))]>,
1434 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1435 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1436 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1437 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1438 X86_COND_NE, EFLAGS))]>,
1440 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1441 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1442 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1443 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1444 X86_COND_BE, EFLAGS))]>,
1446 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1447 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1448 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1449 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1450 X86_COND_BE, EFLAGS))]>,
1452 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1453 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1454 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1455 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1456 X86_COND_A, EFLAGS))]>,
1458 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1459 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1460 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1461 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1462 X86_COND_A, EFLAGS))]>,
1464 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1465 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1466 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1467 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1468 X86_COND_L, EFLAGS))]>,
1470 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1471 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1472 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1473 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1474 X86_COND_L, EFLAGS))]>,
1476 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1477 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1478 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1479 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1480 X86_COND_GE, EFLAGS))]>,
1482 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1483 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1484 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1485 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1486 X86_COND_GE, EFLAGS))]>,
1488 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1489 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1490 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1491 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1492 X86_COND_LE, EFLAGS))]>,
1494 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1495 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1496 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1497 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1498 X86_COND_LE, EFLAGS))]>,
1500 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1501 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1502 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1503 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1504 X86_COND_G, EFLAGS))]>,
1506 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1507 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1508 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1509 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1510 X86_COND_G, EFLAGS))]>,
1512 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1513 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1514 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1515 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1516 X86_COND_S, EFLAGS))]>,
1518 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1519 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1520 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1521 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1522 X86_COND_S, EFLAGS))]>,
1524 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1525 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1526 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1527 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1528 X86_COND_NS, EFLAGS))]>,
1530 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1531 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1532 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1533 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1534 X86_COND_NS, EFLAGS))]>,
1536 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1537 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1538 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1539 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1540 X86_COND_P, EFLAGS))]>,
1542 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1543 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1544 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1545 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1546 X86_COND_P, EFLAGS))]>,
1548 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1549 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1550 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1551 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1552 X86_COND_NP, EFLAGS))]>,
1554 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1555 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1556 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1557 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1558 X86_COND_NP, EFLAGS))]>,
1560 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1561 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1562 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1563 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1564 X86_COND_O, EFLAGS))]>,
1566 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1567 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1568 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1569 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1570 X86_COND_O, EFLAGS))]>,
1572 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1573 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1574 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1575 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1576 X86_COND_NO, EFLAGS))]>,
1578 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1579 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1580 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1581 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1582 X86_COND_NO, EFLAGS))]>,
1584 } // Predicates = [HasCMov]
1586 // X86 doesn't have 8-bit conditional moves. Use a customInserter to
1587 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1588 // however that requires promoting the operands, and can induce additional
1589 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1590 // clobber EFLAGS, because if one of the operands is zero, the expansion
1591 // could involve an xor.
1592 let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in {
1593 def CMOV_GR8 : I<0, Pseudo,
1594 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1595 "#CMOV_GR8 PSEUDO!",
1596 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1597 imm:$cond, EFLAGS))]>;
1599 let Predicates = [NoCMov] in {
1600 def CMOV_GR32 : I<0, Pseudo,
1601 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1602 "#CMOV_GR32* PSEUDO!",
1604 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1605 def CMOV_GR16 : I<0, Pseudo,
1606 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1607 "#CMOV_GR16* PSEUDO!",
1609 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1610 def CMOV_RFP32 : I<0, Pseudo,
1611 (outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
1612 "#CMOV_RFP32 PSEUDO!",
1613 [(set RFP32:$dst, (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
1615 def CMOV_RFP64 : I<0, Pseudo,
1616 (outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
1617 "#CMOV_RFP64 PSEUDO!",
1618 [(set RFP64:$dst, (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
1620 def CMOV_RFP80 : I<0, Pseudo,
1621 (outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
1622 "#CMOV_RFP80 PSEUDO!",
1623 [(set RFP80:$dst, (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
1625 } // Predicates = [NoCMov]
1626 } // UsesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS]
1627 } // Uses = [EFLAGS]
1630 // unary instructions
1631 let CodeSize = 2 in {
1632 let Defs = [EFLAGS] in {
1633 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1634 [(set GR8:$dst, (ineg GR8:$src)),
1635 (implicit EFLAGS)]>;
1636 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1637 [(set GR16:$dst, (ineg GR16:$src)),
1638 (implicit EFLAGS)]>, OpSize;
1639 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1640 [(set GR32:$dst, (ineg GR32:$src)),
1641 (implicit EFLAGS)]>;
1642 let isTwoAddress = 0 in {
1643 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1644 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1645 (implicit EFLAGS)]>;
1646 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1647 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1648 (implicit EFLAGS)]>, OpSize;
1649 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1650 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1651 (implicit EFLAGS)]>;
1653 } // Defs = [EFLAGS]
1655 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1656 let AddedComplexity = 15 in {
1657 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1658 [(set GR8:$dst, (not GR8:$src))]>;
1659 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1660 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1661 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1662 [(set GR32:$dst, (not GR32:$src))]>;
1664 let isTwoAddress = 0 in {
1665 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1666 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1667 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1668 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1669 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1670 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1674 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1675 let Defs = [EFLAGS] in {
1677 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1678 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src))]>;
1680 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1681 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1683 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src))]>,
1684 OpSize, Requires<[In32BitMode]>;
1685 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1687 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src))]>,
1688 Requires<[In32BitMode]>;
1690 let isTwoAddress = 0, CodeSize = 2 in {
1691 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1692 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1693 (implicit EFLAGS)]>;
1694 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1695 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1696 (implicit EFLAGS)]>,
1697 OpSize, Requires<[In32BitMode]>;
1698 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1699 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1700 (implicit EFLAGS)]>,
1701 Requires<[In32BitMode]>;
1705 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1706 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src))]>;
1707 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1708 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1710 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src))]>,
1711 OpSize, Requires<[In32BitMode]>;
1712 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1714 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src))]>,
1715 Requires<[In32BitMode]>;
1718 let isTwoAddress = 0, CodeSize = 2 in {
1719 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1720 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1721 (implicit EFLAGS)]>;
1722 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1723 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1724 (implicit EFLAGS)]>,
1725 OpSize, Requires<[In32BitMode]>;
1726 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1727 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1728 (implicit EFLAGS)]>,
1729 Requires<[In32BitMode]>;
1731 } // Defs = [EFLAGS]
1733 // Logical operators...
1734 let Defs = [EFLAGS] in {
1735 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1736 def AND8rr : I<0x20, MRMDestReg,
1737 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1738 "and{b}\t{$src2, $dst|$dst, $src2}",
1739 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1740 def AND16rr : I<0x21, MRMDestReg,
1741 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1742 "and{w}\t{$src2, $dst|$dst, $src2}",
1743 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1744 GR16:$src2))]>, OpSize;
1745 def AND32rr : I<0x21, MRMDestReg,
1746 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1747 "and{l}\t{$src2, $dst|$dst, $src2}",
1748 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1752 // AND instructions with the destination register in REG and the source register
1753 // in R/M. Included for the disassembler.
1754 def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1755 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1756 def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1757 (ins GR16:$src1, GR16:$src2),
1758 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1759 def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1760 (ins GR32:$src1, GR32:$src2),
1761 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1763 def AND8rm : I<0x22, MRMSrcMem,
1764 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1765 "and{b}\t{$src2, $dst|$dst, $src2}",
1766 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1767 (loadi8 addr:$src2)))]>;
1768 def AND16rm : I<0x23, MRMSrcMem,
1769 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1770 "and{w}\t{$src2, $dst|$dst, $src2}",
1771 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1772 (loadi16 addr:$src2)))]>,
1774 def AND32rm : I<0x23, MRMSrcMem,
1775 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1776 "and{l}\t{$src2, $dst|$dst, $src2}",
1777 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1778 (loadi32 addr:$src2)))]>;
1780 def AND8ri : Ii8<0x80, MRM4r,
1781 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1782 "and{b}\t{$src2, $dst|$dst, $src2}",
1783 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1785 def AND16ri : Ii16<0x81, MRM4r,
1786 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1787 "and{w}\t{$src2, $dst|$dst, $src2}",
1788 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1789 imm:$src2))]>, OpSize;
1790 def AND32ri : Ii32<0x81, MRM4r,
1791 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1792 "and{l}\t{$src2, $dst|$dst, $src2}",
1793 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1795 def AND16ri8 : Ii8<0x83, MRM4r,
1796 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1797 "and{w}\t{$src2, $dst|$dst, $src2}",
1798 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1799 i16immSExt8:$src2))]>,
1801 def AND32ri8 : Ii8<0x83, MRM4r,
1802 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1803 "and{l}\t{$src2, $dst|$dst, $src2}",
1804 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1805 i32immSExt8:$src2))]>;
1807 let isTwoAddress = 0 in {
1808 def AND8mr : I<0x20, MRMDestMem,
1809 (outs), (ins i8mem :$dst, GR8 :$src),
1810 "and{b}\t{$src, $dst|$dst, $src}",
1811 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1812 (implicit EFLAGS)]>;
1813 def AND16mr : I<0x21, MRMDestMem,
1814 (outs), (ins i16mem:$dst, GR16:$src),
1815 "and{w}\t{$src, $dst|$dst, $src}",
1816 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1817 (implicit EFLAGS)]>,
1819 def AND32mr : I<0x21, MRMDestMem,
1820 (outs), (ins i32mem:$dst, GR32:$src),
1821 "and{l}\t{$src, $dst|$dst, $src}",
1822 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1823 (implicit EFLAGS)]>;
1824 def AND8mi : Ii8<0x80, MRM4m,
1825 (outs), (ins i8mem :$dst, i8imm :$src),
1826 "and{b}\t{$src, $dst|$dst, $src}",
1827 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1828 (implicit EFLAGS)]>;
1829 def AND16mi : Ii16<0x81, MRM4m,
1830 (outs), (ins i16mem:$dst, i16imm:$src),
1831 "and{w}\t{$src, $dst|$dst, $src}",
1832 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1833 (implicit EFLAGS)]>,
1835 def AND32mi : Ii32<0x81, MRM4m,
1836 (outs), (ins i32mem:$dst, i32imm:$src),
1837 "and{l}\t{$src, $dst|$dst, $src}",
1838 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1839 (implicit EFLAGS)]>;
1840 def AND16mi8 : Ii8<0x83, MRM4m,
1841 (outs), (ins i16mem:$dst, i16i8imm :$src),
1842 "and{w}\t{$src, $dst|$dst, $src}",
1843 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1844 (implicit EFLAGS)]>,
1846 def AND32mi8 : Ii8<0x83, MRM4m,
1847 (outs), (ins i32mem:$dst, i32i8imm :$src),
1848 "and{l}\t{$src, $dst|$dst, $src}",
1849 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1850 (implicit EFLAGS)]>;
1852 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1853 "and{b}\t{$src, %al|%al, $src}", []>;
1854 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1855 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1856 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1857 "and{l}\t{$src, %eax|%eax, $src}", []>;
1862 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1863 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1864 (ins GR8 :$src1, GR8 :$src2),
1865 "or{b}\t{$src2, $dst|$dst, $src2}",
1866 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
1867 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1868 (ins GR16:$src1, GR16:$src2),
1869 "or{w}\t{$src2, $dst|$dst, $src2}",
1870 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1872 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1873 (ins GR32:$src1, GR32:$src2),
1874 "or{l}\t{$src2, $dst|$dst, $src2}",
1875 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
1878 // OR instructions with the destination register in REG and the source register
1879 // in R/M. Included for the disassembler.
1880 def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1881 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1882 def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1883 (ins GR16:$src1, GR16:$src2),
1884 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1885 def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1886 (ins GR32:$src1, GR32:$src2),
1887 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1889 def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
1890 (ins GR8 :$src1, i8mem :$src2),
1891 "or{b}\t{$src2, $dst|$dst, $src2}",
1892 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
1893 (load addr:$src2)))]>;
1894 def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
1895 (ins GR16:$src1, i16mem:$src2),
1896 "or{w}\t{$src2, $dst|$dst, $src2}",
1897 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1898 (load addr:$src2)))]>,
1900 def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
1901 (ins GR32:$src1, i32mem:$src2),
1902 "or{l}\t{$src2, $dst|$dst, $src2}",
1903 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1904 (load addr:$src2)))]>;
1906 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1907 (ins GR8 :$src1, i8imm:$src2),
1908 "or{b}\t{$src2, $dst|$dst, $src2}",
1909 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
1910 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1911 (ins GR16:$src1, i16imm:$src2),
1912 "or{w}\t{$src2, $dst|$dst, $src2}",
1913 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1914 imm:$src2))]>, OpSize;
1915 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1916 (ins GR32:$src1, i32imm:$src2),
1917 "or{l}\t{$src2, $dst|$dst, $src2}",
1918 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1921 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1922 (ins GR16:$src1, i16i8imm:$src2),
1923 "or{w}\t{$src2, $dst|$dst, $src2}",
1924 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1925 i16immSExt8:$src2))]>, OpSize;
1926 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1927 (ins GR32:$src1, i32i8imm:$src2),
1928 "or{l}\t{$src2, $dst|$dst, $src2}",
1929 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1930 i32immSExt8:$src2))]>;
1931 let isTwoAddress = 0 in {
1932 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1933 "or{b}\t{$src, $dst|$dst, $src}",
1934 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1935 (implicit EFLAGS)]>;
1936 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1937 "or{w}\t{$src, $dst|$dst, $src}",
1938 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1939 (implicit EFLAGS)]>, OpSize;
1940 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1941 "or{l}\t{$src, $dst|$dst, $src}",
1942 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1943 (implicit EFLAGS)]>;
1944 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1945 "or{b}\t{$src, $dst|$dst, $src}",
1946 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1947 (implicit EFLAGS)]>;
1948 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1949 "or{w}\t{$src, $dst|$dst, $src}",
1950 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1951 (implicit EFLAGS)]>,
1953 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1954 "or{l}\t{$src, $dst|$dst, $src}",
1955 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1956 (implicit EFLAGS)]>;
1957 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1958 "or{w}\t{$src, $dst|$dst, $src}",
1959 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1960 (implicit EFLAGS)]>,
1962 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1963 "or{l}\t{$src, $dst|$dst, $src}",
1964 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1965 (implicit EFLAGS)]>;
1967 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1968 "or{b}\t{$src, %al|%al, $src}", []>;
1969 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1970 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1971 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1972 "or{l}\t{$src, %eax|%eax, $src}", []>;
1973 } // isTwoAddress = 0
1976 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1977 def XOR8rr : I<0x30, MRMDestReg,
1978 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1979 "xor{b}\t{$src2, $dst|$dst, $src2}",
1980 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
1982 def XOR16rr : I<0x31, MRMDestReg,
1983 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1984 "xor{w}\t{$src2, $dst|$dst, $src2}",
1985 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
1986 GR16:$src2))]>, OpSize;
1987 def XOR32rr : I<0x31, MRMDestReg,
1988 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1989 "xor{l}\t{$src2, $dst|$dst, $src2}",
1990 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
1992 } // isCommutable = 1
1994 // XOR instructions with the destination register in REG and the source register
1995 // in R/M. Included for the disassembler.
1996 def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1997 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1998 def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1999 (ins GR16:$src1, GR16:$src2),
2000 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2001 def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2002 (ins GR32:$src1, GR32:$src2),
2003 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
2005 def XOR8rm : I<0x32, MRMSrcMem,
2006 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
2007 "xor{b}\t{$src2, $dst|$dst, $src2}",
2008 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2009 (load addr:$src2)))]>;
2010 def XOR16rm : I<0x33, MRMSrcMem,
2011 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
2012 "xor{w}\t{$src2, $dst|$dst, $src2}",
2013 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2014 (load addr:$src2)))]>,
2016 def XOR32rm : I<0x33, MRMSrcMem,
2017 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2018 "xor{l}\t{$src2, $dst|$dst, $src2}",
2019 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2020 (load addr:$src2)))]>;
2022 def XOR8ri : Ii8<0x80, MRM6r,
2023 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2024 "xor{b}\t{$src2, $dst|$dst, $src2}",
2025 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
2026 def XOR16ri : Ii16<0x81, MRM6r,
2027 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2028 "xor{w}\t{$src2, $dst|$dst, $src2}",
2029 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2030 imm:$src2))]>, OpSize;
2031 def XOR32ri : Ii32<0x81, MRM6r,
2032 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2033 "xor{l}\t{$src2, $dst|$dst, $src2}",
2034 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2036 def XOR16ri8 : Ii8<0x83, MRM6r,
2037 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2038 "xor{w}\t{$src2, $dst|$dst, $src2}",
2039 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2040 i16immSExt8:$src2))]>,
2042 def XOR32ri8 : Ii8<0x83, MRM6r,
2043 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2044 "xor{l}\t{$src2, $dst|$dst, $src2}",
2045 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2046 i32immSExt8:$src2))]>;
2048 let isTwoAddress = 0 in {
2049 def XOR8mr : I<0x30, MRMDestMem,
2050 (outs), (ins i8mem :$dst, GR8 :$src),
2051 "xor{b}\t{$src, $dst|$dst, $src}",
2052 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2053 (implicit EFLAGS)]>;
2054 def XOR16mr : I<0x31, MRMDestMem,
2055 (outs), (ins i16mem:$dst, GR16:$src),
2056 "xor{w}\t{$src, $dst|$dst, $src}",
2057 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2058 (implicit EFLAGS)]>,
2060 def XOR32mr : I<0x31, MRMDestMem,
2061 (outs), (ins i32mem:$dst, GR32:$src),
2062 "xor{l}\t{$src, $dst|$dst, $src}",
2063 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2064 (implicit EFLAGS)]>;
2065 def XOR8mi : Ii8<0x80, MRM6m,
2066 (outs), (ins i8mem :$dst, i8imm :$src),
2067 "xor{b}\t{$src, $dst|$dst, $src}",
2068 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2069 (implicit EFLAGS)]>;
2070 def XOR16mi : Ii16<0x81, MRM6m,
2071 (outs), (ins i16mem:$dst, i16imm:$src),
2072 "xor{w}\t{$src, $dst|$dst, $src}",
2073 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2074 (implicit EFLAGS)]>,
2076 def XOR32mi : Ii32<0x81, MRM6m,
2077 (outs), (ins i32mem:$dst, i32imm:$src),
2078 "xor{l}\t{$src, $dst|$dst, $src}",
2079 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2080 (implicit EFLAGS)]>;
2081 def XOR16mi8 : Ii8<0x83, MRM6m,
2082 (outs), (ins i16mem:$dst, i16i8imm :$src),
2083 "xor{w}\t{$src, $dst|$dst, $src}",
2084 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2085 (implicit EFLAGS)]>,
2087 def XOR32mi8 : Ii8<0x83, MRM6m,
2088 (outs), (ins i32mem:$dst, i32i8imm :$src),
2089 "xor{l}\t{$src, $dst|$dst, $src}",
2090 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2091 (implicit EFLAGS)]>;
2093 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2094 "xor{b}\t{$src, %al|%al, $src}", []>;
2095 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
2096 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2097 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
2098 "xor{l}\t{$src, %eax|%eax, $src}", []>;
2099 } // isTwoAddress = 0
2100 } // Defs = [EFLAGS]
2102 // Shift instructions
2103 let Defs = [EFLAGS] in {
2104 let Uses = [CL] in {
2105 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
2106 "shl{b}\t{%cl, $dst|$dst, CL}",
2107 [(set GR8:$dst, (shl GR8:$src, CL))]>;
2108 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
2109 "shl{w}\t{%cl, $dst|$dst, CL}",
2110 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
2111 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
2112 "shl{l}\t{%cl, $dst|$dst, CL}",
2113 [(set GR32:$dst, (shl GR32:$src, CL))]>;
2116 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2117 "shl{b}\t{$src2, $dst|$dst, $src2}",
2118 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2119 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2120 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2121 "shl{w}\t{$src2, $dst|$dst, $src2}",
2122 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2123 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2124 "shl{l}\t{$src2, $dst|$dst, $src2}",
2125 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
2127 // NOTE: We don't include patterns for shifts of a register by one, because
2128 // 'add reg,reg' is cheaper.
2130 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2131 "shl{b}\t$dst", []>;
2132 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2133 "shl{w}\t$dst", []>, OpSize;
2134 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2135 "shl{l}\t$dst", []>;
2137 } // isConvertibleToThreeAddress = 1
2139 let isTwoAddress = 0 in {
2140 let Uses = [CL] in {
2141 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
2142 "shl{b}\t{%cl, $dst|$dst, CL}",
2143 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
2144 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
2145 "shl{w}\t{%cl, $dst|$dst, CL}",
2146 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2147 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
2148 "shl{l}\t{%cl, $dst|$dst, CL}",
2149 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2151 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
2152 "shl{b}\t{$src, $dst|$dst, $src}",
2153 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2154 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
2155 "shl{w}\t{$src, $dst|$dst, $src}",
2156 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2158 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
2159 "shl{l}\t{$src, $dst|$dst, $src}",
2160 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2163 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2165 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2166 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2168 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2170 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2172 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2175 let Uses = [CL] in {
2176 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
2177 "shr{b}\t{%cl, $dst|$dst, CL}",
2178 [(set GR8:$dst, (srl GR8:$src, CL))]>;
2179 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
2180 "shr{w}\t{%cl, $dst|$dst, CL}",
2181 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
2182 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
2183 "shr{l}\t{%cl, $dst|$dst, CL}",
2184 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2187 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2188 "shr{b}\t{$src2, $dst|$dst, $src2}",
2189 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2190 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2191 "shr{w}\t{$src2, $dst|$dst, $src2}",
2192 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2193 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2194 "shr{l}\t{$src2, $dst|$dst, $src2}",
2195 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2198 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2200 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2201 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2203 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2204 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2206 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2208 let isTwoAddress = 0 in {
2209 let Uses = [CL] in {
2210 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2211 "shr{b}\t{%cl, $dst|$dst, CL}",
2212 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2213 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2214 "shr{w}\t{%cl, $dst|$dst, CL}",
2215 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2217 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2218 "shr{l}\t{%cl, $dst|$dst, CL}",
2219 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2221 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2222 "shr{b}\t{$src, $dst|$dst, $src}",
2223 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2224 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2225 "shr{w}\t{$src, $dst|$dst, $src}",
2226 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2228 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2229 "shr{l}\t{$src, $dst|$dst, $src}",
2230 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2233 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2235 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2236 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2238 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2239 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2241 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2244 let Uses = [CL] in {
2245 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
2246 "sar{b}\t{%cl, $dst|$dst, CL}",
2247 [(set GR8:$dst, (sra GR8:$src, CL))]>;
2248 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
2249 "sar{w}\t{%cl, $dst|$dst, CL}",
2250 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
2251 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
2252 "sar{l}\t{%cl, $dst|$dst, CL}",
2253 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2256 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2257 "sar{b}\t{$src2, $dst|$dst, $src2}",
2258 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2259 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2260 "sar{w}\t{$src2, $dst|$dst, $src2}",
2261 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2263 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2264 "sar{l}\t{$src2, $dst|$dst, $src2}",
2265 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2268 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2270 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2271 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2273 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2274 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2276 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2278 let isTwoAddress = 0 in {
2279 let Uses = [CL] in {
2280 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2281 "sar{b}\t{%cl, $dst|$dst, CL}",
2282 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2283 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2284 "sar{w}\t{%cl, $dst|$dst, CL}",
2285 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2286 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2287 "sar{l}\t{%cl, $dst|$dst, CL}",
2288 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2290 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2291 "sar{b}\t{$src, $dst|$dst, $src}",
2292 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2293 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2294 "sar{w}\t{$src, $dst|$dst, $src}",
2295 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2297 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2298 "sar{l}\t{$src, $dst|$dst, $src}",
2299 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2302 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2304 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2305 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2307 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2309 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2311 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2314 // Rotate instructions
2316 def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2317 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2318 let Uses = [CL] in {
2319 def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2320 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2322 def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2323 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2325 def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2326 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2327 let Uses = [CL] in {
2328 def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2329 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2331 def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2332 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2334 def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2335 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2336 let Uses = [CL] in {
2337 def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2338 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2340 def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2341 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2343 def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2344 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2345 let Uses = [CL] in {
2346 def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2347 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2349 def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2350 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2352 def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2353 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2354 let Uses = [CL] in {
2355 def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2356 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2358 def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2359 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2361 def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2362 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2363 let Uses = [CL] in {
2364 def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2365 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2367 def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2368 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2370 let isTwoAddress = 0 in {
2371 def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2372 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2373 def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2374 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2375 def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2376 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2377 def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2378 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2379 def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2380 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2381 def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2382 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2383 def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2384 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2385 def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2386 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2387 def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2388 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2389 def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2390 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2391 def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2392 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2393 def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2394 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2396 let Uses = [CL] in {
2397 def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2398 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2399 def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2400 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2401 def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2402 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2403 def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2404 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2405 def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2406 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2407 def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2408 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2412 // FIXME: provide shorter instructions when imm8 == 1
2413 let Uses = [CL] in {
2414 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
2415 "rol{b}\t{%cl, $dst|$dst, CL}",
2416 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
2417 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
2418 "rol{w}\t{%cl, $dst|$dst, CL}",
2419 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
2420 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
2421 "rol{l}\t{%cl, $dst|$dst, CL}",
2422 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2425 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2426 "rol{b}\t{$src2, $dst|$dst, $src2}",
2427 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2428 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2429 "rol{w}\t{$src2, $dst|$dst, $src2}",
2430 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2432 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2433 "rol{l}\t{$src2, $dst|$dst, $src2}",
2434 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2437 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2439 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2440 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2442 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2443 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2445 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2447 let isTwoAddress = 0 in {
2448 let Uses = [CL] in {
2449 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2450 "rol{b}\t{%cl, $dst|$dst, CL}",
2451 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2452 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2453 "rol{w}\t{%cl, $dst|$dst, CL}",
2454 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2455 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2456 "rol{l}\t{%cl, $dst|$dst, CL}",
2457 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2459 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2460 "rol{b}\t{$src, $dst|$dst, $src}",
2461 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2462 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2463 "rol{w}\t{$src, $dst|$dst, $src}",
2464 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2466 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2467 "rol{l}\t{$src, $dst|$dst, $src}",
2468 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2471 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2473 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2474 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2476 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2478 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2480 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2483 let Uses = [CL] in {
2484 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2485 "ror{b}\t{%cl, $dst|$dst, CL}",
2486 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2487 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2488 "ror{w}\t{%cl, $dst|$dst, CL}",
2489 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2490 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2491 "ror{l}\t{%cl, $dst|$dst, CL}",
2492 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2495 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2496 "ror{b}\t{$src2, $dst|$dst, $src2}",
2497 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2498 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2499 "ror{w}\t{$src2, $dst|$dst, $src2}",
2500 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2502 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2503 "ror{l}\t{$src2, $dst|$dst, $src2}",
2504 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2507 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2509 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2510 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2512 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2513 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2515 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2517 let isTwoAddress = 0 in {
2518 let Uses = [CL] in {
2519 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2520 "ror{b}\t{%cl, $dst|$dst, CL}",
2521 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2522 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2523 "ror{w}\t{%cl, $dst|$dst, CL}",
2524 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2525 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2526 "ror{l}\t{%cl, $dst|$dst, CL}",
2527 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2529 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2530 "ror{b}\t{$src, $dst|$dst, $src}",
2531 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2532 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2533 "ror{w}\t{$src, $dst|$dst, $src}",
2534 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2536 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2537 "ror{l}\t{$src, $dst|$dst, $src}",
2538 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2541 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2543 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2544 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2546 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2548 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2550 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2555 // Double shift instructions (generalizations of rotate)
2556 let Uses = [CL] in {
2557 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2558 (ins GR32:$src1, GR32:$src2),
2559 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2560 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2561 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2562 (ins GR32:$src1, GR32:$src2),
2563 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2564 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2565 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2566 (ins GR16:$src1, GR16:$src2),
2567 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2568 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2570 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2571 (ins GR16:$src1, GR16:$src2),
2572 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2573 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2577 let isCommutable = 1 in { // These instructions commute to each other.
2578 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2580 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2581 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2582 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2585 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2587 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2588 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2589 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2592 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2594 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2595 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2596 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2599 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2601 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2602 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2603 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2608 let isTwoAddress = 0 in {
2609 let Uses = [CL] in {
2610 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2611 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2612 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2614 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2615 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2616 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2619 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2620 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2621 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2622 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2623 (i8 imm:$src3)), addr:$dst)]>,
2625 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2626 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2627 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2628 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2629 (i8 imm:$src3)), addr:$dst)]>,
2632 let Uses = [CL] in {
2633 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2634 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2635 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2636 addr:$dst)]>, TB, OpSize;
2637 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2638 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2639 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2640 addr:$dst)]>, TB, OpSize;
2642 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2643 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2644 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2645 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2646 (i8 imm:$src3)), addr:$dst)]>,
2648 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2649 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2650 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2651 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2652 (i8 imm:$src3)), addr:$dst)]>,
2655 } // Defs = [EFLAGS]
2659 let Defs = [EFLAGS] in {
2660 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2661 // Register-Register Addition
2662 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2663 (ins GR8 :$src1, GR8 :$src2),
2664 "add{b}\t{$src2, $dst|$dst, $src2}",
2665 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
2667 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2668 // Register-Register Addition
2669 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2670 (ins GR16:$src1, GR16:$src2),
2671 "add{w}\t{$src2, $dst|$dst, $src2}",
2672 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2673 GR16:$src2))]>, OpSize;
2674 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2675 (ins GR32:$src1, GR32:$src2),
2676 "add{l}\t{$src2, $dst|$dst, $src2}",
2677 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2679 } // end isConvertibleToThreeAddress
2680 } // end isCommutable
2682 // These are alternate spellings for use by the disassembler, we mark them as
2683 // code gen only to ensure they aren't matched by the assembler.
2684 let isCodeGenOnly = 1 in {
2685 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2686 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2687 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2688 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2689 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
2690 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2693 // Register-Memory Addition
2694 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2695 (ins GR8 :$src1, i8mem :$src2),
2696 "add{b}\t{$src2, $dst|$dst, $src2}",
2697 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2698 (load addr:$src2)))]>;
2699 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2700 (ins GR16:$src1, i16mem:$src2),
2701 "add{w}\t{$src2, $dst|$dst, $src2}",
2702 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2703 (load addr:$src2)))]>, OpSize;
2704 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2705 (ins GR32:$src1, i32mem:$src2),
2706 "add{l}\t{$src2, $dst|$dst, $src2}",
2707 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2708 (load addr:$src2)))]>;
2710 // Register-Integer Addition
2711 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2712 "add{b}\t{$src2, $dst|$dst, $src2}",
2713 [(set GR8:$dst, EFLAGS,
2714 (X86add_flag GR8:$src1, imm:$src2))]>;
2716 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2717 // Register-Integer Addition
2718 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2719 (ins GR16:$src1, i16imm:$src2),
2720 "add{w}\t{$src2, $dst|$dst, $src2}",
2721 [(set GR16:$dst, EFLAGS,
2722 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
2723 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2724 (ins GR32:$src1, i32imm:$src2),
2725 "add{l}\t{$src2, $dst|$dst, $src2}",
2726 [(set GR32:$dst, EFLAGS,
2727 (X86add_flag GR32:$src1, imm:$src2))]>;
2728 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2729 (ins GR16:$src1, i16i8imm:$src2),
2730 "add{w}\t{$src2, $dst|$dst, $src2}",
2731 [(set GR16:$dst, EFLAGS,
2732 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
2733 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2734 (ins GR32:$src1, i32i8imm:$src2),
2735 "add{l}\t{$src2, $dst|$dst, $src2}",
2736 [(set GR32:$dst, EFLAGS,
2737 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
2740 let isTwoAddress = 0 in {
2741 // Memory-Register Addition
2742 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2743 "add{b}\t{$src2, $dst|$dst, $src2}",
2744 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2745 (implicit EFLAGS)]>;
2746 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2747 "add{w}\t{$src2, $dst|$dst, $src2}",
2748 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2749 (implicit EFLAGS)]>, OpSize;
2750 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2751 "add{l}\t{$src2, $dst|$dst, $src2}",
2752 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2753 (implicit EFLAGS)]>;
2754 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2755 "add{b}\t{$src2, $dst|$dst, $src2}",
2756 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2757 (implicit EFLAGS)]>;
2758 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2759 "add{w}\t{$src2, $dst|$dst, $src2}",
2760 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2761 (implicit EFLAGS)]>, OpSize;
2762 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2763 "add{l}\t{$src2, $dst|$dst, $src2}",
2764 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2765 (implicit EFLAGS)]>;
2766 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2767 "add{w}\t{$src2, $dst|$dst, $src2}",
2768 [(store (add (load addr:$dst), i16immSExt8:$src2),
2770 (implicit EFLAGS)]>, OpSize;
2771 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2772 "add{l}\t{$src2, $dst|$dst, $src2}",
2773 [(store (add (load addr:$dst), i32immSExt8:$src2),
2775 (implicit EFLAGS)]>;
2778 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2779 "add{b}\t{$src, %al|%al, $src}", []>;
2780 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2781 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2782 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2783 "add{l}\t{$src, %eax|%eax, $src}", []>;
2786 let Uses = [EFLAGS] in {
2787 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2788 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2789 "adc{b}\t{$src2, $dst|$dst, $src2}",
2790 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2791 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2792 (ins GR16:$src1, GR16:$src2),
2793 "adc{w}\t{$src2, $dst|$dst, $src2}",
2794 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2795 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2796 (ins GR32:$src1, GR32:$src2),
2797 "adc{l}\t{$src2, $dst|$dst, $src2}",
2798 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2801 def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2802 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2803 def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2804 (ins GR16:$src1, GR16:$src2),
2805 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2806 def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2807 (ins GR32:$src1, GR32:$src2),
2808 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2810 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2811 (ins GR8:$src1, i8mem:$src2),
2812 "adc{b}\t{$src2, $dst|$dst, $src2}",
2813 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2814 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2815 (ins GR16:$src1, i16mem:$src2),
2816 "adc{w}\t{$src2, $dst|$dst, $src2}",
2817 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2819 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2820 (ins GR32:$src1, i32mem:$src2),
2821 "adc{l}\t{$src2, $dst|$dst, $src2}",
2822 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2823 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2824 "adc{b}\t{$src2, $dst|$dst, $src2}",
2825 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2826 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2827 (ins GR16:$src1, i16imm:$src2),
2828 "adc{w}\t{$src2, $dst|$dst, $src2}",
2829 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2830 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2831 (ins GR16:$src1, i16i8imm:$src2),
2832 "adc{w}\t{$src2, $dst|$dst, $src2}",
2833 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2835 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2836 (ins GR32:$src1, i32imm:$src2),
2837 "adc{l}\t{$src2, $dst|$dst, $src2}",
2838 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2839 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2840 (ins GR32:$src1, i32i8imm:$src2),
2841 "adc{l}\t{$src2, $dst|$dst, $src2}",
2842 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2844 let isTwoAddress = 0 in {
2845 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2846 "adc{b}\t{$src2, $dst|$dst, $src2}",
2847 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2848 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2849 "adc{w}\t{$src2, $dst|$dst, $src2}",
2850 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2852 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2853 "adc{l}\t{$src2, $dst|$dst, $src2}",
2854 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2855 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2856 "adc{b}\t{$src2, $dst|$dst, $src2}",
2857 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2858 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2859 "adc{w}\t{$src2, $dst|$dst, $src2}",
2860 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2862 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2863 "adc{w}\t{$src2, $dst|$dst, $src2}",
2864 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2866 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2867 "adc{l}\t{$src2, $dst|$dst, $src2}",
2868 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2869 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2870 "adc{l}\t{$src2, $dst|$dst, $src2}",
2871 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2873 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2874 "adc{b}\t{$src, %al|%al, $src}", []>;
2875 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2876 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2877 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2878 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2880 } // Uses = [EFLAGS]
2882 // Register-Register Subtraction
2883 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2884 "sub{b}\t{$src2, $dst|$dst, $src2}",
2885 [(set GR8:$dst, EFLAGS,
2886 (X86sub_flag GR8:$src1, GR8:$src2))]>;
2887 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2888 "sub{w}\t{$src2, $dst|$dst, $src2}",
2889 [(set GR16:$dst, EFLAGS,
2890 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
2891 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2892 "sub{l}\t{$src2, $dst|$dst, $src2}",
2893 [(set GR32:$dst, EFLAGS,
2894 (X86sub_flag GR32:$src1, GR32:$src2))]>;
2896 def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2897 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2898 def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2899 (ins GR16:$src1, GR16:$src2),
2900 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2901 def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2902 (ins GR32:$src1, GR32:$src2),
2903 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2905 // Register-Memory Subtraction
2906 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2907 (ins GR8 :$src1, i8mem :$src2),
2908 "sub{b}\t{$src2, $dst|$dst, $src2}",
2909 [(set GR8:$dst, EFLAGS,
2910 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
2911 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2912 (ins GR16:$src1, i16mem:$src2),
2913 "sub{w}\t{$src2, $dst|$dst, $src2}",
2914 [(set GR16:$dst, EFLAGS,
2915 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
2916 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2917 (ins GR32:$src1, i32mem:$src2),
2918 "sub{l}\t{$src2, $dst|$dst, $src2}",
2919 [(set GR32:$dst, EFLAGS,
2920 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
2922 // Register-Integer Subtraction
2923 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2924 (ins GR8:$src1, i8imm:$src2),
2925 "sub{b}\t{$src2, $dst|$dst, $src2}",
2926 [(set GR8:$dst, EFLAGS,
2927 (X86sub_flag GR8:$src1, imm:$src2))]>;
2928 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2929 (ins GR16:$src1, i16imm:$src2),
2930 "sub{w}\t{$src2, $dst|$dst, $src2}",
2931 [(set GR16:$dst, EFLAGS,
2932 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
2933 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2934 (ins GR32:$src1, i32imm:$src2),
2935 "sub{l}\t{$src2, $dst|$dst, $src2}",
2936 [(set GR32:$dst, EFLAGS,
2937 (X86sub_flag GR32:$src1, imm:$src2))]>;
2938 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2939 (ins GR16:$src1, i16i8imm:$src2),
2940 "sub{w}\t{$src2, $dst|$dst, $src2}",
2941 [(set GR16:$dst, EFLAGS,
2942 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
2943 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2944 (ins GR32:$src1, i32i8imm:$src2),
2945 "sub{l}\t{$src2, $dst|$dst, $src2}",
2946 [(set GR32:$dst, EFLAGS,
2947 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
2949 let isTwoAddress = 0 in {
2950 // Memory-Register Subtraction
2951 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2952 "sub{b}\t{$src2, $dst|$dst, $src2}",
2953 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2954 (implicit EFLAGS)]>;
2955 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2956 "sub{w}\t{$src2, $dst|$dst, $src2}",
2957 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2958 (implicit EFLAGS)]>, OpSize;
2959 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2960 "sub{l}\t{$src2, $dst|$dst, $src2}",
2961 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2962 (implicit EFLAGS)]>;
2964 // Memory-Integer Subtraction
2965 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2966 "sub{b}\t{$src2, $dst|$dst, $src2}",
2967 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2968 (implicit EFLAGS)]>;
2969 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2970 "sub{w}\t{$src2, $dst|$dst, $src2}",
2971 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2972 (implicit EFLAGS)]>, OpSize;
2973 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2974 "sub{l}\t{$src2, $dst|$dst, $src2}",
2975 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2976 (implicit EFLAGS)]>;
2977 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2978 "sub{w}\t{$src2, $dst|$dst, $src2}",
2979 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2981 (implicit EFLAGS)]>, OpSize;
2982 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2983 "sub{l}\t{$src2, $dst|$dst, $src2}",
2984 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2986 (implicit EFLAGS)]>;
2988 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2989 "sub{b}\t{$src, %al|%al, $src}", []>;
2990 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2991 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2992 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2993 "sub{l}\t{$src, %eax|%eax, $src}", []>;
2996 let Uses = [EFLAGS] in {
2997 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2998 (ins GR8:$src1, GR8:$src2),
2999 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3000 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
3001 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3002 (ins GR16:$src1, GR16:$src2),
3003 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3004 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
3005 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3006 (ins GR32:$src1, GR32:$src2),
3007 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3008 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
3010 let isTwoAddress = 0 in {
3011 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3012 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3013 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
3014 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3015 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3016 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
3018 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3019 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3020 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
3021 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3022 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3023 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
3024 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3025 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3026 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
3028 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3029 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3030 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
3032 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
3033 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3034 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
3035 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3036 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3037 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
3039 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3040 "sbb{b}\t{$src, %al|%al, $src}", []>;
3041 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3042 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3043 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3044 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
3047 def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3048 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3049 def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3050 (ins GR16:$src1, GR16:$src2),
3051 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3052 def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3053 (ins GR32:$src1, GR32:$src2),
3054 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3056 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3057 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3058 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
3059 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3060 (ins GR16:$src1, i16mem:$src2),
3061 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3062 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
3064 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3065 (ins GR32:$src1, i32mem:$src2),
3066 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3067 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
3068 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3069 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3070 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
3071 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3072 (ins GR16:$src1, i16imm:$src2),
3073 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3074 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
3075 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3076 (ins GR16:$src1, i16i8imm:$src2),
3077 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3078 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3080 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3081 (ins GR32:$src1, i32imm:$src2),
3082 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3083 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
3084 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3085 (ins GR32:$src1, i32i8imm:$src2),
3086 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3087 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
3088 } // Uses = [EFLAGS]
3089 } // Defs = [EFLAGS]
3091 let Defs = [EFLAGS] in {
3092 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
3093 // Register-Register Signed Integer Multiply
3094 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
3095 "imul{w}\t{$src2, $dst|$dst, $src2}",
3096 [(set GR16:$dst, EFLAGS,
3097 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
3098 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
3099 "imul{l}\t{$src2, $dst|$dst, $src2}",
3100 [(set GR32:$dst, EFLAGS,
3101 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
3104 // Register-Memory Signed Integer Multiply
3105 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3106 (ins GR16:$src1, i16mem:$src2),
3107 "imul{w}\t{$src2, $dst|$dst, $src2}",
3108 [(set GR16:$dst, EFLAGS,
3109 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
3111 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3112 (ins GR32:$src1, i32mem:$src2),
3113 "imul{l}\t{$src2, $dst|$dst, $src2}",
3114 [(set GR32:$dst, EFLAGS,
3115 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
3116 } // Defs = [EFLAGS]
3117 } // end Two Address instructions
3119 // Suprisingly enough, these are not two address instructions!
3120 let Defs = [EFLAGS] in {
3121 // Register-Integer Signed Integer Multiply
3122 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
3123 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
3124 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3125 [(set GR16:$dst, EFLAGS,
3126 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
3127 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
3128 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
3129 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3130 [(set GR32:$dst, EFLAGS,
3131 (X86smul_flag GR32:$src1, imm:$src2))]>;
3132 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
3133 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
3134 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3135 [(set GR16:$dst, EFLAGS,
3136 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
3138 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
3139 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
3140 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3141 [(set GR32:$dst, EFLAGS,
3142 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
3144 // Memory-Integer Signed Integer Multiply
3145 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
3146 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
3147 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3148 [(set GR16:$dst, EFLAGS,
3149 (X86smul_flag (load addr:$src1), imm:$src2))]>,
3151 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
3152 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
3153 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3154 [(set GR32:$dst, EFLAGS,
3155 (X86smul_flag (load addr:$src1), imm:$src2))]>;
3156 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
3157 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
3158 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3159 [(set GR16:$dst, EFLAGS,
3160 (X86smul_flag (load addr:$src1),
3161 i16immSExt8:$src2))]>, OpSize;
3162 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
3163 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
3164 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3165 [(set GR32:$dst, EFLAGS,
3166 (X86smul_flag (load addr:$src1),
3167 i32immSExt8:$src2))]>;
3168 } // Defs = [EFLAGS]
3170 //===----------------------------------------------------------------------===//
3171 // Test instructions are just like AND, except they don't generate a result.
3173 let Defs = [EFLAGS] in {
3174 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
3175 def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3176 "test{b}\t{$src2, $src1|$src1, $src2}",
3177 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
3178 def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3179 "test{w}\t{$src2, $src1|$src1, $src2}",
3180 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
3183 def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3184 "test{l}\t{$src2, $src1|$src1, $src2}",
3185 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
3189 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3190 "test{b}\t{$src, %al|%al, $src}", []>;
3191 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3192 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3193 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3194 "test{l}\t{$src, %eax|%eax, $src}", []>;
3196 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
3197 "test{b}\t{$src2, $src1|$src1, $src2}",
3198 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
3200 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
3201 "test{w}\t{$src2, $src1|$src1, $src2}",
3202 [(set EFLAGS, (X86cmp (and GR16:$src1,
3203 (loadi16 addr:$src2)), 0))]>, OpSize;
3204 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
3205 "test{l}\t{$src2, $src1|$src1, $src2}",
3206 [(set EFLAGS, (X86cmp (and GR32:$src1,
3207 (loadi32 addr:$src2)), 0))]>;
3209 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
3210 (outs), (ins GR8:$src1, i8imm:$src2),
3211 "test{b}\t{$src2, $src1|$src1, $src2}",
3212 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
3213 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
3214 (outs), (ins GR16:$src1, i16imm:$src2),
3215 "test{w}\t{$src2, $src1|$src1, $src2}",
3216 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
3218 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
3219 (outs), (ins GR32:$src1, i32imm:$src2),
3220 "test{l}\t{$src2, $src1|$src1, $src2}",
3221 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
3223 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
3224 (outs), (ins i8mem:$src1, i8imm:$src2),
3225 "test{b}\t{$src2, $src1|$src1, $src2}",
3226 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
3228 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
3229 (outs), (ins i16mem:$src1, i16imm:$src2),
3230 "test{w}\t{$src2, $src1|$src1, $src2}",
3231 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
3233 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
3234 (outs), (ins i32mem:$src1, i32imm:$src2),
3235 "test{l}\t{$src2, $src1|$src1, $src2}",
3236 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
3238 } // Defs = [EFLAGS]
3241 // Condition code ops, incl. set if equal/not equal/...
3242 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
3243 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
3244 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
3245 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
3247 let Uses = [EFLAGS] in {
3248 // Use sbb to materialize carry bit.
3249 let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3250 // FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3251 // However, Pat<> can't replicate the destination reg into the inputs of the
3253 // FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3255 def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
3256 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3257 def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
3258 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
3260 def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
3261 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3264 def SETEr : I<0x94, MRM0r,
3265 (outs GR8 :$dst), (ins),
3267 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
3269 def SETEm : I<0x94, MRM0m,
3270 (outs), (ins i8mem:$dst),
3272 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
3275 def SETNEr : I<0x95, MRM0r,
3276 (outs GR8 :$dst), (ins),
3278 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
3280 def SETNEm : I<0x95, MRM0m,
3281 (outs), (ins i8mem:$dst),
3283 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
3286 def SETLr : I<0x9C, MRM0r,
3287 (outs GR8 :$dst), (ins),
3289 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
3290 TB; // GR8 = < signed
3291 def SETLm : I<0x9C, MRM0m,
3292 (outs), (ins i8mem:$dst),
3294 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
3295 TB; // [mem8] = < signed
3297 def SETGEr : I<0x9D, MRM0r,
3298 (outs GR8 :$dst), (ins),
3300 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
3301 TB; // GR8 = >= signed
3302 def SETGEm : I<0x9D, MRM0m,
3303 (outs), (ins i8mem:$dst),
3305 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
3306 TB; // [mem8] = >= signed
3308 def SETLEr : I<0x9E, MRM0r,
3309 (outs GR8 :$dst), (ins),
3311 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3312 TB; // GR8 = <= signed
3313 def SETLEm : I<0x9E, MRM0m,
3314 (outs), (ins i8mem:$dst),
3316 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3317 TB; // [mem8] = <= signed
3319 def SETGr : I<0x9F, MRM0r,
3320 (outs GR8 :$dst), (ins),
3322 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3323 TB; // GR8 = > signed
3324 def SETGm : I<0x9F, MRM0m,
3325 (outs), (ins i8mem:$dst),
3327 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3328 TB; // [mem8] = > signed
3330 def SETBr : I<0x92, MRM0r,
3331 (outs GR8 :$dst), (ins),
3333 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3334 TB; // GR8 = < unsign
3335 def SETBm : I<0x92, MRM0m,
3336 (outs), (ins i8mem:$dst),
3338 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3339 TB; // [mem8] = < unsign
3341 def SETAEr : I<0x93, MRM0r,
3342 (outs GR8 :$dst), (ins),
3344 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3345 TB; // GR8 = >= unsign
3346 def SETAEm : I<0x93, MRM0m,
3347 (outs), (ins i8mem:$dst),
3349 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3350 TB; // [mem8] = >= unsign
3352 def SETBEr : I<0x96, MRM0r,
3353 (outs GR8 :$dst), (ins),
3355 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3356 TB; // GR8 = <= unsign
3357 def SETBEm : I<0x96, MRM0m,
3358 (outs), (ins i8mem:$dst),
3360 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3361 TB; // [mem8] = <= unsign
3363 def SETAr : I<0x97, MRM0r,
3364 (outs GR8 :$dst), (ins),
3366 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3367 TB; // GR8 = > signed
3368 def SETAm : I<0x97, MRM0m,
3369 (outs), (ins i8mem:$dst),
3371 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3372 TB; // [mem8] = > signed
3374 def SETSr : I<0x98, MRM0r,
3375 (outs GR8 :$dst), (ins),
3377 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3378 TB; // GR8 = <sign bit>
3379 def SETSm : I<0x98, MRM0m,
3380 (outs), (ins i8mem:$dst),
3382 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3383 TB; // [mem8] = <sign bit>
3384 def SETNSr : I<0x99, MRM0r,
3385 (outs GR8 :$dst), (ins),
3387 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3388 TB; // GR8 = !<sign bit>
3389 def SETNSm : I<0x99, MRM0m,
3390 (outs), (ins i8mem:$dst),
3392 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3393 TB; // [mem8] = !<sign bit>
3395 def SETPr : I<0x9A, MRM0r,
3396 (outs GR8 :$dst), (ins),
3398 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3400 def SETPm : I<0x9A, MRM0m,
3401 (outs), (ins i8mem:$dst),
3403 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3404 TB; // [mem8] = parity
3405 def SETNPr : I<0x9B, MRM0r,
3406 (outs GR8 :$dst), (ins),
3408 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3409 TB; // GR8 = not parity
3410 def SETNPm : I<0x9B, MRM0m,
3411 (outs), (ins i8mem:$dst),
3413 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3414 TB; // [mem8] = not parity
3416 def SETOr : I<0x90, MRM0r,
3417 (outs GR8 :$dst), (ins),
3419 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3420 TB; // GR8 = overflow
3421 def SETOm : I<0x90, MRM0m,
3422 (outs), (ins i8mem:$dst),
3424 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3425 TB; // [mem8] = overflow
3426 def SETNOr : I<0x91, MRM0r,
3427 (outs GR8 :$dst), (ins),
3429 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3430 TB; // GR8 = not overflow
3431 def SETNOm : I<0x91, MRM0m,
3432 (outs), (ins i8mem:$dst),
3434 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3435 TB; // [mem8] = not overflow
3436 } // Uses = [EFLAGS]
3439 // Integer comparisons
3440 let Defs = [EFLAGS] in {
3441 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3442 "cmp{b}\t{$src, %al|%al, $src}", []>;
3443 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3444 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3445 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3446 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3448 def CMP8rr : I<0x38, MRMDestReg,
3449 (outs), (ins GR8 :$src1, GR8 :$src2),
3450 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3451 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
3452 def CMP16rr : I<0x39, MRMDestReg,
3453 (outs), (ins GR16:$src1, GR16:$src2),
3454 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3455 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
3456 def CMP32rr : I<0x39, MRMDestReg,
3457 (outs), (ins GR32:$src1, GR32:$src2),
3458 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3459 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
3460 def CMP8mr : I<0x38, MRMDestMem,
3461 (outs), (ins i8mem :$src1, GR8 :$src2),
3462 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3463 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
3464 def CMP16mr : I<0x39, MRMDestMem,
3465 (outs), (ins i16mem:$src1, GR16:$src2),
3466 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3467 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3469 def CMP32mr : I<0x39, MRMDestMem,
3470 (outs), (ins i32mem:$src1, GR32:$src2),
3471 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3472 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
3473 def CMP8rm : I<0x3A, MRMSrcMem,
3474 (outs), (ins GR8 :$src1, i8mem :$src2),
3475 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3476 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
3477 def CMP16rm : I<0x3B, MRMSrcMem,
3478 (outs), (ins GR16:$src1, i16mem:$src2),
3479 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3480 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3482 def CMP32rm : I<0x3B, MRMSrcMem,
3483 (outs), (ins GR32:$src1, i32mem:$src2),
3484 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3485 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
3487 // These are alternate spellings for use by the disassembler, we mark them as
3488 // code gen only to ensure they aren't matched by the assembler.
3489 let isCodeGenOnly = 1 in {
3490 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3491 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3492 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3493 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3494 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3495 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3498 def CMP8ri : Ii8<0x80, MRM7r,
3499 (outs), (ins GR8:$src1, i8imm:$src2),
3500 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3501 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
3502 def CMP16ri : Ii16<0x81, MRM7r,
3503 (outs), (ins GR16:$src1, i16imm:$src2),
3504 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3505 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
3506 def CMP32ri : Ii32<0x81, MRM7r,
3507 (outs), (ins GR32:$src1, i32imm:$src2),
3508 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3509 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
3510 def CMP8mi : Ii8 <0x80, MRM7m,
3511 (outs), (ins i8mem :$src1, i8imm :$src2),
3512 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3513 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
3514 def CMP16mi : Ii16<0x81, MRM7m,
3515 (outs), (ins i16mem:$src1, i16imm:$src2),
3516 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3517 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
3519 def CMP32mi : Ii32<0x81, MRM7m,
3520 (outs), (ins i32mem:$src1, i32imm:$src2),
3521 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3522 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
3523 def CMP16ri8 : Ii8<0x83, MRM7r,
3524 (outs), (ins GR16:$src1, i16i8imm:$src2),
3525 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3526 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3528 def CMP16mi8 : Ii8<0x83, MRM7m,
3529 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3530 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3531 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3532 i16immSExt8:$src2))]>, OpSize;
3533 def CMP32mi8 : Ii8<0x83, MRM7m,
3534 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3535 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3536 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3537 i32immSExt8:$src2))]>;
3538 def CMP32ri8 : Ii8<0x83, MRM7r,
3539 (outs), (ins GR32:$src1, i32i8imm:$src2),
3540 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3541 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
3542 } // Defs = [EFLAGS]
3545 // TODO: BTC, BTR, and BTS
3546 let Defs = [EFLAGS] in {
3547 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3548 "bt{w}\t{$src2, $src1|$src1, $src2}",
3549 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
3550 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3551 "bt{l}\t{$src2, $src1|$src1, $src2}",
3552 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
3554 // Unlike with the register+register form, the memory+register form of the
3555 // bt instruction does not ignore the high bits of the index. From ISel's
3556 // perspective, this is pretty bizarre. Make these instructions disassembly
3559 def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3560 "bt{w}\t{$src2, $src1|$src1, $src2}",
3561 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3562 // (implicit EFLAGS)]
3564 >, OpSize, TB, Requires<[FastBTMem]>;
3565 def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3566 "bt{l}\t{$src2, $src1|$src1, $src2}",
3567 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3568 // (implicit EFLAGS)]
3570 >, TB, Requires<[FastBTMem]>;
3572 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3573 "bt{w}\t{$src2, $src1|$src1, $src2}",
3574 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3576 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3577 "bt{l}\t{$src2, $src1|$src1, $src2}",
3578 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
3579 // Note that these instructions don't need FastBTMem because that
3580 // only applies when the other operand is in a register. When it's
3581 // an immediate, bt is still fast.
3582 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3583 "bt{w}\t{$src2, $src1|$src1, $src2}",
3584 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3586 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3587 "bt{l}\t{$src2, $src1|$src1, $src2}",
3588 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3591 def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3592 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3593 def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3594 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3595 def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3596 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3597 def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3598 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3599 def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3600 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3601 def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3602 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3603 def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3604 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3605 def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3606 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3608 def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3609 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3610 def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3611 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3612 def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3613 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3614 def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3615 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3616 def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3617 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3618 def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3619 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3620 def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3621 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3622 def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3623 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3625 def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3626 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3627 def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3628 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3629 def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3630 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3631 def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3632 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3633 def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3634 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3635 def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3636 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3637 def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3638 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3639 def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3640 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3641 } // Defs = [EFLAGS]
3643 // Sign/Zero extenders
3644 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3645 // of the register here. This has a smaller encoding and avoids a
3646 // partial-register update. Actual movsbw included for the disassembler.
3647 def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3648 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3649 def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3650 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3651 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3652 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
3653 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3654 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3655 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3656 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3657 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3658 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3659 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3660 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3661 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3662 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3663 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3664 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3665 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3666 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3668 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3669 // of the register here. This has a smaller encoding and avoids a
3670 // partial-register update. Actual movzbw included for the disassembler.
3671 def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3672 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3673 def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3674 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3675 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3676 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
3677 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3678 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3679 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3680 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3681 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3682 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3683 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3684 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3685 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3686 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3687 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3688 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3689 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3690 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3692 // These are the same as the regular MOVZX32rr8 and MOVZX32rm8
3693 // except that they use GR32_NOREX for the output operand register class
3694 // instead of GR32. This allows them to operate on h registers on x86-64.
3695 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3696 (outs GR32_NOREX:$dst), (ins GR8:$src),
3697 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3700 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3701 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3702 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3705 let neverHasSideEffects = 1 in {
3706 let Defs = [AX], Uses = [AL] in
3707 def CBW : I<0x98, RawFrm, (outs), (ins),
3708 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3709 let Defs = [EAX], Uses = [AX] in
3710 def CWDE : I<0x98, RawFrm, (outs), (ins),
3711 "{cwtl|cwde}", []>; // EAX = signext(AX)
3713 let Defs = [AX,DX], Uses = [AX] in
3714 def CWD : I<0x99, RawFrm, (outs), (ins),
3715 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3716 let Defs = [EAX,EDX], Uses = [EAX] in
3717 def CDQ : I<0x99, RawFrm, (outs), (ins),
3718 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3721 //===----------------------------------------------------------------------===//
3722 // Alias Instructions
3723 //===----------------------------------------------------------------------===//
3725 // Alias instructions that map movr0 to xor.
3726 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3727 // FIXME: Set encoding to pseudo.
3728 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3729 isCodeGenOnly = 1 in {
3730 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
3731 [(set GR8:$dst, 0)]>;
3733 // We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3734 // encoding and avoids a partial-register update sometimes, but doing so
3735 // at isel time interferes with rematerialization in the current register
3736 // allocator. For now, this is rewritten when the instruction is lowered
3738 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3740 [(set GR16:$dst, 0)]>, OpSize;
3742 // FIXME: Set encoding to pseudo.
3743 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
3744 [(set GR32:$dst, 0)]>;
3747 //===----------------------------------------------------------------------===//
3748 // Thread Local Storage Instructions
3751 // All calls clobber the non-callee saved registers. ESP is marked as
3752 // a use to prevent stack-pointer assignments that appear immediately
3753 // before calls from potentially appearing dead.
3754 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3755 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3756 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3757 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3759 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3760 "leal\t$sym, %eax; "
3761 "call\t___tls_get_addr@PLT",
3762 [(X86tlsaddr tls32addr:$sym)]>,
3763 Requires<[In32BitMode]>;
3765 let AddedComplexity = 5, isCodeGenOnly = 1 in
3766 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3767 "movl\t%gs:$src, $dst",
3768 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3770 let AddedComplexity = 5, isCodeGenOnly = 1 in
3771 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3772 "movl\t%fs:$src, $dst",
3773 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3775 //===----------------------------------------------------------------------===//
3776 // EH Pseudo Instructions
3778 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3779 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3780 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3781 "ret\t#eh_return, addr: $addr",
3782 [(X86ehret GR32:$addr)]>;
3786 //===----------------------------------------------------------------------===//
3790 // Atomic swap. These are just normal xchg instructions. But since a memory
3791 // operand is referenced, the atomicity is ensured.
3792 let Constraints = "$val = $dst" in {
3793 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3794 (ins GR32:$val, i32mem:$ptr),
3795 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3796 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3797 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3798 (ins GR16:$val, i16mem:$ptr),
3799 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3800 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3802 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3803 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3804 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3806 def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3807 "xchg{l}\t{$val, $src|$src, $val}", []>;
3808 def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3809 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3810 def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3811 "xchg{b}\t{$val, $src|$src, $val}", []>;
3814 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3815 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3816 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3817 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3819 // Atomic compare and swap.
3820 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3821 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3823 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3824 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3826 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3827 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
3830 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3833 let Defs = [AX, EFLAGS], Uses = [AX] in {
3834 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3836 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3837 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3839 let Defs = [AL, EFLAGS], Uses = [AL] in {
3840 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3842 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3843 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3846 // Atomic exchange and add
3847 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3848 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
3850 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3851 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3853 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
3855 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3856 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3858 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3860 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3861 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3865 def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3866 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3867 def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3868 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3869 def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3870 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3872 let mayLoad = 1, mayStore = 1 in {
3873 def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3874 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3875 def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3876 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3877 def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3878 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3881 def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3882 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3883 def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3884 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3885 def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3886 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3888 let mayLoad = 1, mayStore = 1 in {
3889 def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3890 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3891 def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3892 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3893 def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3894 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3897 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
3898 def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3899 "cmpxchg8b\t$dst", []>, TB;
3901 // Optimized codegen when the non-memory output is not used.
3902 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3903 let Defs = [EFLAGS], mayLoad = 1, mayStore = 1 in {
3904 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3906 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3907 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3909 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3910 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3912 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3913 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3915 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3916 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3918 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3919 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3921 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3922 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3924 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3925 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3927 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3929 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3931 "inc{b}\t$dst", []>, LOCK;
3932 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3934 "inc{w}\t$dst", []>, OpSize, LOCK;
3935 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3937 "inc{l}\t$dst", []>, LOCK;
3939 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3941 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3942 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3944 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3945 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3947 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3948 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3950 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3951 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3953 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3954 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3956 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3957 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3959 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3960 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3962 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3964 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3966 "dec{b}\t$dst", []>, LOCK;
3967 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3969 "dec{w}\t$dst", []>, OpSize, LOCK;
3970 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3972 "dec{l}\t$dst", []>, LOCK;
3975 // Atomic exchange, and, or, xor
3976 let Constraints = "$val = $dst", Defs = [EFLAGS],
3977 usesCustomInserter = 1 in {
3978 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3979 "#ATOMAND32 PSEUDO!",
3980 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3981 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3982 "#ATOMOR32 PSEUDO!",
3983 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3984 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3985 "#ATOMXOR32 PSEUDO!",
3986 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3987 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3988 "#ATOMNAND32 PSEUDO!",
3989 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3990 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3991 "#ATOMMIN32 PSEUDO!",
3992 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3993 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3994 "#ATOMMAX32 PSEUDO!",
3995 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3996 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3997 "#ATOMUMIN32 PSEUDO!",
3998 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3999 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4000 "#ATOMUMAX32 PSEUDO!",
4001 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
4003 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4004 "#ATOMAND16 PSEUDO!",
4005 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
4006 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4007 "#ATOMOR16 PSEUDO!",
4008 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
4009 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4010 "#ATOMXOR16 PSEUDO!",
4011 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
4012 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4013 "#ATOMNAND16 PSEUDO!",
4014 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
4015 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
4016 "#ATOMMIN16 PSEUDO!",
4017 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
4018 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4019 "#ATOMMAX16 PSEUDO!",
4020 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
4021 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4022 "#ATOMUMIN16 PSEUDO!",
4023 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
4024 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4025 "#ATOMUMAX16 PSEUDO!",
4026 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
4028 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4029 "#ATOMAND8 PSEUDO!",
4030 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
4031 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4033 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
4034 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4035 "#ATOMXOR8 PSEUDO!",
4036 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
4037 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4038 "#ATOMNAND8 PSEUDO!",
4039 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
4042 let Constraints = "$val1 = $dst1, $val2 = $dst2",
4043 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4044 Uses = [EAX, EBX, ECX, EDX],
4045 mayLoad = 1, mayStore = 1,
4046 usesCustomInserter = 1 in {
4047 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4048 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4049 "#ATOMAND6432 PSEUDO!", []>;
4050 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4051 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4052 "#ATOMOR6432 PSEUDO!", []>;
4053 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4054 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4055 "#ATOMXOR6432 PSEUDO!", []>;
4056 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4057 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4058 "#ATOMNAND6432 PSEUDO!", []>;
4059 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4060 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4061 "#ATOMADD6432 PSEUDO!", []>;
4062 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4063 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4064 "#ATOMSUB6432 PSEUDO!", []>;
4065 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4066 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4067 "#ATOMSWAP6432 PSEUDO!", []>;
4070 // Segmentation support instructions.
4072 def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4073 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4074 def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4075 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4077 // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4078 def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4079 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4080 def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4081 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4083 def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4084 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4085 def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4086 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4087 def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4088 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4089 def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4090 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4092 def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
4094 def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4095 "str{w}\t{$dst}", []>, TB;
4096 def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4097 "str{w}\t{$dst}", []>, TB;
4098 def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4099 "ltr{w}\t{$src}", []>, TB;
4100 def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4101 "ltr{w}\t{$src}", []>, TB;
4103 def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4104 "push{w}\t%fs", []>, OpSize, TB;
4105 def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4106 "push{l}\t%fs", []>, TB;
4107 def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4108 "push{w}\t%gs", []>, OpSize, TB;
4109 def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4110 "push{l}\t%gs", []>, TB;
4112 def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4113 "pop{w}\t%fs", []>, OpSize, TB;
4114 def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4115 "pop{l}\t%fs", []>, TB;
4116 def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4117 "pop{w}\t%gs", []>, OpSize, TB;
4118 def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4119 "pop{l}\t%gs", []>, TB;
4121 def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4122 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4123 def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4124 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4125 def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4126 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4127 def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4128 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4129 def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4130 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4131 def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4132 "les{l}\t{$src, $dst|$dst, $src}", []>;
4133 def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4134 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4135 def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4136 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4137 def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4138 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4139 def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4140 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4142 def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4143 "verr\t$seg", []>, TB;
4144 def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4145 "verr\t$seg", []>, TB;
4146 def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4147 "verw\t$seg", []>, TB;
4148 def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4149 "verw\t$seg", []>, TB;
4151 // Descriptor-table support instructions
4153 def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4154 "sgdt\t$dst", []>, TB;
4155 def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4156 "sidt\t$dst", []>, TB;
4157 def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4158 "sldt{w}\t$dst", []>, TB;
4159 def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4160 "sldt{w}\t$dst", []>, TB;
4161 def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4162 "lgdt\t$src", []>, TB;
4163 def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4164 "lidt\t$src", []>, TB;
4165 def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4166 "lldt{w}\t$src", []>, TB;
4167 def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4168 "lldt{w}\t$src", []>, TB;
4170 // Lock instruction prefix
4171 def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4173 // Repeat string operation instruction prefixes
4174 // These uses the DF flag in the EFLAGS register to inc or dec ECX
4175 let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4176 // Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4177 def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4178 // Repeat while not equal (used with CMPS and SCAS)
4179 def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4182 // Segment override instruction prefixes
4183 def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4184 def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4185 def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4186 def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4187 def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4188 def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4190 // String manipulation instructions
4192 def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4193 def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
4194 def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4196 def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4197 def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4198 def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4200 // CPU flow control instructions
4202 def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4203 def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4205 // FPU control instructions
4207 def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4209 // Flag instructions
4211 def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4212 def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4213 def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4214 def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4215 def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4216 def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4217 def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4219 def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4221 // Table lookup instructions
4223 def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4225 // Specialized register support
4227 def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4228 def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4229 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4231 def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4232 "smsw{w}\t$dst", []>, OpSize, TB;
4233 def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4234 "smsw{l}\t$dst", []>, TB;
4235 // For memory operands, there is only a 16-bit form
4236 def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4237 "smsw{w}\t$dst", []>, TB;
4239 def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4240 "lmsw{w}\t$src", []>, TB;
4241 def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4242 "lmsw{w}\t$src", []>, TB;
4244 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4246 // Cache instructions
4248 def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4249 def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4254 def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
4256 def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
4258 def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
4259 def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4260 "vmclear\t$vmcs", []>, OpSize, TB;
4262 def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
4264 def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
4265 def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4266 "vmptrld\t$vmcs", []>, TB;
4267 def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4268 "vmptrst\t$vmcs", []>, TB;
4269 def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4270 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4271 def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4272 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4273 def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4274 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4275 def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4276 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4277 def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4278 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4279 def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4280 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4281 def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4282 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4283 def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4284 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4286 def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
4287 def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4288 "vmxon\t{$vmxon}", []>, XS;
4290 //===----------------------------------------------------------------------===//
4291 // Non-Instruction Patterns
4292 //===----------------------------------------------------------------------===//
4294 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
4295 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4296 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
4297 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
4298 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4299 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
4300 def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
4302 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4303 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4304 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4305 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4306 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4307 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4308 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4309 (ADD32ri GR32:$src1, texternalsym:$src2)>;
4310 def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4311 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
4313 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4314 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4315 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4316 (MOV32mi addr:$dst, texternalsym:$src)>;
4317 def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4318 (MOV32mi addr:$dst, tblockaddress:$src)>;
4322 def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4323 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4324 Requires<[In32BitMode]>;
4326 // FIXME: This is disabled for 32-bit PIC mode because the global base
4327 // register which is part of the address mode may be assigned a
4328 // callee-saved register.
4329 def : Pat<(X86tcret (load addr:$dst), imm:$off),
4330 (TCRETURNmi addr:$dst, imm:$off)>,
4331 Requires<[In32BitMode, IsNotPIC]>;
4333 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4334 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4335 Requires<[In32BitMode]>;
4337 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4338 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4339 Requires<[In32BitMode]>;
4341 // Normal calls, with various flavors of addresses.
4342 def : Pat<(X86call (i32 tglobaladdr:$dst)),
4343 (CALLpcrel32 tglobaladdr:$dst)>;
4344 def : Pat<(X86call (i32 texternalsym:$dst)),
4345 (CALLpcrel32 texternalsym:$dst)>;
4346 def : Pat<(X86call (i32 imm:$dst)),
4347 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
4349 // X86 specific add which produces a flag.
4350 def : Pat<(addc GR32:$src1, GR32:$src2),
4351 (ADD32rr GR32:$src1, GR32:$src2)>;
4352 def : Pat<(addc GR32:$src1, (load addr:$src2)),
4353 (ADD32rm GR32:$src1, addr:$src2)>;
4354 def : Pat<(addc GR32:$src1, imm:$src2),
4355 (ADD32ri GR32:$src1, imm:$src2)>;
4356 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4357 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4359 def : Pat<(subc GR32:$src1, GR32:$src2),
4360 (SUB32rr GR32:$src1, GR32:$src2)>;
4361 def : Pat<(subc GR32:$src1, (load addr:$src2)),
4362 (SUB32rm GR32:$src1, addr:$src2)>;
4363 def : Pat<(subc GR32:$src1, imm:$src2),
4364 (SUB32ri GR32:$src1, imm:$src2)>;
4365 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4366 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4370 // TEST R,R is smaller than CMP R,0
4371 def : Pat<(X86cmp GR8:$src1, 0),
4372 (TEST8rr GR8:$src1, GR8:$src1)>;
4373 def : Pat<(X86cmp GR16:$src1, 0),
4374 (TEST16rr GR16:$src1, GR16:$src1)>;
4375 def : Pat<(X86cmp GR32:$src1, 0),
4376 (TEST32rr GR32:$src1, GR32:$src1)>;
4378 // Conditional moves with folded loads with operands swapped and conditions
4380 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4381 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4382 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4383 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4384 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4385 (CMOVB16rm GR16:$src2, addr:$src1)>;
4386 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4387 (CMOVB32rm GR32:$src2, addr:$src1)>;
4388 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4389 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4390 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4391 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4392 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4393 (CMOVE16rm GR16:$src2, addr:$src1)>;
4394 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4395 (CMOVE32rm GR32:$src2, addr:$src1)>;
4396 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4397 (CMOVA16rm GR16:$src2, addr:$src1)>;
4398 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4399 (CMOVA32rm GR32:$src2, addr:$src1)>;
4400 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4401 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4402 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4403 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4404 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4405 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4406 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4407 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4408 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4409 (CMOVL16rm GR16:$src2, addr:$src1)>;
4410 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4411 (CMOVL32rm GR32:$src2, addr:$src1)>;
4412 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4413 (CMOVG16rm GR16:$src2, addr:$src1)>;
4414 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4415 (CMOVG32rm GR32:$src2, addr:$src1)>;
4416 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4417 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4418 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4419 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4420 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4421 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4422 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4423 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4424 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4425 (CMOVP16rm GR16:$src2, addr:$src1)>;
4426 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4427 (CMOVP32rm GR32:$src2, addr:$src1)>;
4428 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4429 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4430 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4431 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4432 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4433 (CMOVS16rm GR16:$src2, addr:$src1)>;
4434 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4435 (CMOVS32rm GR32:$src2, addr:$src1)>;
4436 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4437 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4438 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4439 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4440 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4441 (CMOVO16rm GR16:$src2, addr:$src1)>;
4442 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4443 (CMOVO32rm GR32:$src2, addr:$src1)>;
4445 // zextload bool -> zextload byte
4446 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4447 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4448 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4450 // extload bool -> extload byte
4451 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4452 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4453 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4454 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
4455 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4456 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4458 // anyext. Define these to do an explicit zero-extend to
4459 // avoid partial-register updates.
4460 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4461 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4463 // Except for i16 -> i32 since isel expect i16 ops to be promoted to i32.
4464 def : Pat<(i32 (anyext GR16:$src)),
4465 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
4468 //===----------------------------------------------------------------------===//
4470 //===----------------------------------------------------------------------===//
4472 // Odd encoding trick: -128 fits into an 8-bit immediate field while
4473 // +128 doesn't, so in this special case use a sub instead of an add.
4474 def : Pat<(add GR16:$src1, 128),
4475 (SUB16ri8 GR16:$src1, -128)>;
4476 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4477 (SUB16mi8 addr:$dst, -128)>;
4478 def : Pat<(add GR32:$src1, 128),
4479 (SUB32ri8 GR32:$src1, -128)>;
4480 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4481 (SUB32mi8 addr:$dst, -128)>;
4483 // r & (2^16-1) ==> movz
4484 def : Pat<(and GR32:$src1, 0xffff),
4485 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
4486 // r & (2^8-1) ==> movz
4487 def : Pat<(and GR32:$src1, 0xff),
4488 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4491 Requires<[In32BitMode]>;
4492 // r & (2^8-1) ==> movz
4493 def : Pat<(and GR16:$src1, 0xff),
4494 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4497 Requires<[In32BitMode]>;
4499 // sext_inreg patterns
4500 def : Pat<(sext_inreg GR32:$src, i16),
4501 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4502 def : Pat<(sext_inreg GR32:$src, i8),
4503 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4506 Requires<[In32BitMode]>;
4507 def : Pat<(sext_inreg GR16:$src, i8),
4508 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4511 Requires<[In32BitMode]>;
4514 def : Pat<(i16 (trunc GR32:$src)),
4515 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
4516 def : Pat<(i8 (trunc GR32:$src)),
4517 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4519 Requires<[In32BitMode]>;
4520 def : Pat<(i8 (trunc GR16:$src)),
4521 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4523 Requires<[In32BitMode]>;
4525 // h-register tricks
4526 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
4527 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4528 x86_subreg_8bit_hi)>,
4529 Requires<[In32BitMode]>;
4530 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
4531 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4532 x86_subreg_8bit_hi)>,
4533 Requires<[In32BitMode]>;
4534 def : Pat<(srl GR16:$src, (i8 8)),
4537 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4538 x86_subreg_8bit_hi)),
4540 Requires<[In32BitMode]>;
4541 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
4542 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4544 x86_subreg_8bit_hi))>,
4545 Requires<[In32BitMode]>;
4546 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
4547 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4549 x86_subreg_8bit_hi))>,
4550 Requires<[In32BitMode]>;
4551 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
4552 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4554 x86_subreg_8bit_hi))>,
4555 Requires<[In32BitMode]>;
4556 def : Pat<(srl (and_su GR32:$src, 0xff00), (i8 8)),
4557 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4559 x86_subreg_8bit_hi))>,
4560 Requires<[In32BitMode]>;
4562 // (shl x, 1) ==> (add x, x)
4563 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4564 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4565 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4567 // (shl x (and y, 31)) ==> (shl x, y)
4568 def : Pat<(shl GR8:$src1, (and CL, 31)),
4569 (SHL8rCL GR8:$src1)>;
4570 def : Pat<(shl GR16:$src1, (and CL, 31)),
4571 (SHL16rCL GR16:$src1)>;
4572 def : Pat<(shl GR32:$src1, (and CL, 31)),
4573 (SHL32rCL GR32:$src1)>;
4574 def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4575 (SHL8mCL addr:$dst)>;
4576 def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4577 (SHL16mCL addr:$dst)>;
4578 def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4579 (SHL32mCL addr:$dst)>;
4581 def : Pat<(srl GR8:$src1, (and CL, 31)),
4582 (SHR8rCL GR8:$src1)>;
4583 def : Pat<(srl GR16:$src1, (and CL, 31)),
4584 (SHR16rCL GR16:$src1)>;
4585 def : Pat<(srl GR32:$src1, (and CL, 31)),
4586 (SHR32rCL GR32:$src1)>;
4587 def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4588 (SHR8mCL addr:$dst)>;
4589 def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4590 (SHR16mCL addr:$dst)>;
4591 def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4592 (SHR32mCL addr:$dst)>;
4594 def : Pat<(sra GR8:$src1, (and CL, 31)),
4595 (SAR8rCL GR8:$src1)>;
4596 def : Pat<(sra GR16:$src1, (and CL, 31)),
4597 (SAR16rCL GR16:$src1)>;
4598 def : Pat<(sra GR32:$src1, (and CL, 31)),
4599 (SAR32rCL GR32:$src1)>;
4600 def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4601 (SAR8mCL addr:$dst)>;
4602 def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4603 (SAR16mCL addr:$dst)>;
4604 def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4605 (SAR32mCL addr:$dst)>;
4607 // (anyext (setcc_carry)) -> (setcc_carry)
4608 def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4610 def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4612 def : Pat<(i32 (anyext (i16 (X86setcc_c X86_COND_B, EFLAGS)))),
4615 // (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
4616 let AddedComplexity = 5 in { // Try this before the selecting to OR
4617 def : Pat<(or_is_add GR16:$src1, imm:$src2),
4618 (ADD16ri GR16:$src1, imm:$src2)>;
4619 def : Pat<(or_is_add GR32:$src1, imm:$src2),
4620 (ADD32ri GR32:$src1, imm:$src2)>;
4621 def : Pat<(or_is_add GR16:$src1, i16immSExt8:$src2),
4622 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4623 def : Pat<(or_is_add GR32:$src1, i32immSExt8:$src2),
4624 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4625 def : Pat<(or_is_add GR16:$src1, GR16:$src2),
4626 (ADD16rr GR16:$src1, GR16:$src2)>;
4627 def : Pat<(or_is_add GR32:$src1, GR32:$src2),
4628 (ADD32rr GR32:$src1, GR32:$src2)>;
4629 } // AddedComplexity
4631 //===----------------------------------------------------------------------===//
4632 // EFLAGS-defining Patterns
4633 //===----------------------------------------------------------------------===//
4636 def : Pat<(add GR8 :$src1, GR8 :$src2), (ADD8rr GR8 :$src1, GR8 :$src2)>;
4637 def : Pat<(add GR16:$src1, GR16:$src2), (ADD16rr GR16:$src1, GR16:$src2)>;
4638 def : Pat<(add GR32:$src1, GR32:$src2), (ADD32rr GR32:$src1, GR32:$src2)>;
4641 def : Pat<(add GR8:$src1, (loadi8 addr:$src2)),
4642 (ADD8rm GR8:$src1, addr:$src2)>;
4643 def : Pat<(add GR16:$src1, (loadi16 addr:$src2)),
4644 (ADD16rm GR16:$src1, addr:$src2)>;
4645 def : Pat<(add GR32:$src1, (loadi32 addr:$src2)),
4646 (ADD32rm GR32:$src1, addr:$src2)>;
4649 def : Pat<(add GR8 :$src1, imm:$src2), (ADD8ri GR8:$src1 , imm:$src2)>;
4650 def : Pat<(add GR16:$src1, imm:$src2), (ADD16ri GR16:$src1, imm:$src2)>;
4651 def : Pat<(add GR32:$src1, imm:$src2), (ADD32ri GR32:$src1, imm:$src2)>;
4652 def : Pat<(add GR16:$src1, i16immSExt8:$src2),
4653 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4654 def : Pat<(add GR32:$src1, i32immSExt8:$src2),
4655 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4658 def : Pat<(sub GR8 :$src1, GR8 :$src2), (SUB8rr GR8 :$src1, GR8 :$src2)>;
4659 def : Pat<(sub GR16:$src1, GR16:$src2), (SUB16rr GR16:$src1, GR16:$src2)>;
4660 def : Pat<(sub GR32:$src1, GR32:$src2), (SUB32rr GR32:$src1, GR32:$src2)>;
4663 def : Pat<(sub GR8:$src1, (loadi8 addr:$src2)),
4664 (SUB8rm GR8:$src1, addr:$src2)>;
4665 def : Pat<(sub GR16:$src1, (loadi16 addr:$src2)),
4666 (SUB16rm GR16:$src1, addr:$src2)>;
4667 def : Pat<(sub GR32:$src1, (loadi32 addr:$src2)),
4668 (SUB32rm GR32:$src1, addr:$src2)>;
4671 def : Pat<(sub GR8:$src1, imm:$src2),
4672 (SUB8ri GR8:$src1, imm:$src2)>;
4673 def : Pat<(sub GR16:$src1, imm:$src2),
4674 (SUB16ri GR16:$src1, imm:$src2)>;
4675 def : Pat<(sub GR32:$src1, imm:$src2),
4676 (SUB32ri GR32:$src1, imm:$src2)>;
4677 def : Pat<(sub GR16:$src1, i16immSExt8:$src2),
4678 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4679 def : Pat<(sub GR32:$src1, i32immSExt8:$src2),
4680 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4683 def : Pat<(mul GR16:$src1, GR16:$src2),
4684 (IMUL16rr GR16:$src1, GR16:$src2)>;
4685 def : Pat<(mul GR32:$src1, GR32:$src2),
4686 (IMUL32rr GR32:$src1, GR32:$src2)>;
4689 def : Pat<(mul GR16:$src1, (loadi16 addr:$src2)),
4690 (IMUL16rm GR16:$src1, addr:$src2)>;
4691 def : Pat<(mul GR32:$src1, (loadi32 addr:$src2)),
4692 (IMUL32rm GR32:$src1, addr:$src2)>;
4695 def : Pat<(mul GR16:$src1, imm:$src2),
4696 (IMUL16rri GR16:$src1, imm:$src2)>;
4697 def : Pat<(mul GR32:$src1, imm:$src2),
4698 (IMUL32rri GR32:$src1, imm:$src2)>;
4699 def : Pat<(mul GR16:$src1, i16immSExt8:$src2),
4700 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4701 def : Pat<(mul GR32:$src1, i32immSExt8:$src2),
4702 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4704 // reg = mul mem, imm
4705 def : Pat<(mul (loadi16 addr:$src1), imm:$src2),
4706 (IMUL16rmi addr:$src1, imm:$src2)>;
4707 def : Pat<(mul (loadi32 addr:$src1), imm:$src2),
4708 (IMUL32rmi addr:$src1, imm:$src2)>;
4709 def : Pat<(mul (loadi16 addr:$src1), i16immSExt8:$src2),
4710 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4711 def : Pat<(mul (loadi32 addr:$src1), i32immSExt8:$src2),
4712 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4714 // Optimize multiply by 2 with EFLAGS result.
4715 let AddedComplexity = 2 in {
4716 def : Pat<(X86smul_flag GR16:$src1, 2), (ADD16rr GR16:$src1, GR16:$src1)>;
4717 def : Pat<(X86smul_flag GR32:$src1, 2), (ADD32rr GR32:$src1, GR32:$src1)>;
4720 // Patterns for nodes that do not produce flags, for instructions that do.
4723 def : Pat<(add GR8:$src , 1), (INC8r GR8:$src)>;
4724 def : Pat<(add GR16:$src, 1), (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4725 def : Pat<(add GR32:$src, 1), (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4728 def : Pat<(add GR8:$src , -1), (DEC8r GR8:$src)>;
4729 def : Pat<(add GR16:$src, -1), (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4730 def : Pat<(add GR32:$src, -1), (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4733 def : Pat<(or GR8 :$src1, GR8 :$src2), (OR8rr GR8 :$src1, GR8 :$src2)>;
4734 def : Pat<(or GR16:$src1, GR16:$src2), (OR16rr GR16:$src1, GR16:$src2)>;
4735 def : Pat<(or GR32:$src1, GR32:$src2), (OR32rr GR32:$src1, GR32:$src2)>;
4738 def : Pat<(or GR8:$src1, (loadi8 addr:$src2)),
4739 (OR8rm GR8:$src1, addr:$src2)>;
4740 def : Pat<(or GR16:$src1, (loadi16 addr:$src2)),
4741 (OR16rm GR16:$src1, addr:$src2)>;
4742 def : Pat<(or GR32:$src1, (loadi32 addr:$src2)),
4743 (OR32rm GR32:$src1, addr:$src2)>;
4746 def : Pat<(or GR8:$src1 , imm:$src2), (OR8ri GR8 :$src1, imm:$src2)>;
4747 def : Pat<(or GR16:$src1, imm:$src2), (OR16ri GR16:$src1, imm:$src2)>;
4748 def : Pat<(or GR32:$src1, imm:$src2), (OR32ri GR32:$src1, imm:$src2)>;
4749 def : Pat<(or GR16:$src1, i16immSExt8:$src2),
4750 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4751 def : Pat<(or GR32:$src1, i32immSExt8:$src2),
4752 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4755 def : Pat<(xor GR8 :$src1, GR8 :$src2), (XOR8rr GR8 :$src1, GR8 :$src2)>;
4756 def : Pat<(xor GR16:$src1, GR16:$src2), (XOR16rr GR16:$src1, GR16:$src2)>;
4757 def : Pat<(xor GR32:$src1, GR32:$src2), (XOR32rr GR32:$src1, GR32:$src2)>;
4760 def : Pat<(xor GR8:$src1, (loadi8 addr:$src2)),
4761 (XOR8rm GR8:$src1, addr:$src2)>;
4762 def : Pat<(xor GR16:$src1, (loadi16 addr:$src2)),
4763 (XOR16rm GR16:$src1, addr:$src2)>;
4764 def : Pat<(xor GR32:$src1, (loadi32 addr:$src2)),
4765 (XOR32rm GR32:$src1, addr:$src2)>;
4768 def : Pat<(xor GR8:$src1, imm:$src2),
4769 (XOR8ri GR8:$src1, imm:$src2)>;
4770 def : Pat<(xor GR16:$src1, imm:$src2),
4771 (XOR16ri GR16:$src1, imm:$src2)>;
4772 def : Pat<(xor GR32:$src1, imm:$src2),
4773 (XOR32ri GR32:$src1, imm:$src2)>;
4774 def : Pat<(xor GR16:$src1, i16immSExt8:$src2),
4775 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4776 def : Pat<(xor GR32:$src1, i32immSExt8:$src2),
4777 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4780 def : Pat<(and GR8 :$src1, GR8 :$src2), (AND8rr GR8 :$src1, GR8 :$src2)>;
4781 def : Pat<(and GR16:$src1, GR16:$src2), (AND16rr GR16:$src1, GR16:$src2)>;
4782 def : Pat<(and GR32:$src1, GR32:$src2), (AND32rr GR32:$src1, GR32:$src2)>;
4785 def : Pat<(and GR8:$src1, (loadi8 addr:$src2)),
4786 (AND8rm GR8:$src1, addr:$src2)>;
4787 def : Pat<(and GR16:$src1, (loadi16 addr:$src2)),
4788 (AND16rm GR16:$src1, addr:$src2)>;
4789 def : Pat<(and GR32:$src1, (loadi32 addr:$src2)),
4790 (AND32rm GR32:$src1, addr:$src2)>;
4793 def : Pat<(and GR8:$src1, imm:$src2),
4794 (AND8ri GR8:$src1, imm:$src2)>;
4795 def : Pat<(and GR16:$src1, imm:$src2),
4796 (AND16ri GR16:$src1, imm:$src2)>;
4797 def : Pat<(and GR32:$src1, imm:$src2),
4798 (AND32ri GR32:$src1, imm:$src2)>;
4799 def : Pat<(and GR16:$src1, i16immSExt8:$src2),
4800 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
4801 def : Pat<(and GR32:$src1, i32immSExt8:$src2),
4802 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4804 //===----------------------------------------------------------------------===//
4805 // Floating Point Stack Support
4806 //===----------------------------------------------------------------------===//
4808 include "X86InstrFPStack.td"
4810 //===----------------------------------------------------------------------===//
4812 //===----------------------------------------------------------------------===//
4814 include "X86Instr64bit.td"
4816 //===----------------------------------------------------------------------===//
4817 // SIMD support (SSE, MMX and AVX)
4818 //===----------------------------------------------------------------------===//
4820 include "X86InstrFragmentsSIMD.td"
4822 //===----------------------------------------------------------------------===//
4823 // XMM Floating point support (requires SSE / SSE2)
4824 //===----------------------------------------------------------------------===//
4826 include "X86InstrSSE.td"
4828 //===----------------------------------------------------------------------===//
4829 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4830 //===----------------------------------------------------------------------===//
4832 include "X86InstrMMX.td"