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_X86TLSCALL : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
77 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
79 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
81 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
83 def X86bsf : SDNode<"X86ISD::BSF", SDTUnaryArithWithFlags>;
84 def X86bsr : SDNode<"X86ISD::BSR", SDTUnaryArithWithFlags>;
85 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
86 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
88 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
89 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
91 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
92 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
94 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
95 def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
97 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
98 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
100 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
101 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
103 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
112 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
115 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
116 [SDNPHasChain, SDNPMayStore,
117 SDNPMayLoad, SDNPMemOperand]>;
118 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
119 [SDNPHasChain, SDNPMayStore,
120 SDNPMayLoad, SDNPMemOperand]>;
121 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
122 [SDNPHasChain, SDNPMayStore,
123 SDNPMayLoad, SDNPMemOperand]>;
124 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
125 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
127 def X86vastart_save_xmm_regs :
128 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
129 SDT_X86VASTART_SAVE_XMM_REGS,
130 [SDNPHasChain, SDNPVariadic]>;
132 def X86callseq_start :
133 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
134 [SDNPHasChain, SDNPOutFlag]>;
136 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
137 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
139 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
140 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag,
143 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
144 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
145 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
146 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
149 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
150 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
152 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
153 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
155 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
156 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
157 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
158 SDT_X86SegmentBaseAddress, []>;
160 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
163 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
164 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
166 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
168 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
169 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
171 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
174 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
175 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
176 def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
178 def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
180 def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
183 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
185 def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
186 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
188 def X86TLSCall : SDNode<"X86ISD::TLSCALL", SDT_X86TLSCALL,
191 //===----------------------------------------------------------------------===//
192 // X86 Operand Definitions.
195 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
196 // the index operand of an address, to conform to x86 encoding restrictions.
197 def ptr_rc_nosp : PointerLikeRegClass<1>;
199 // *mem - Operand definitions for the funky X86 addressing mode operands.
201 def X86MemAsmOperand : AsmOperandClass {
203 let SuperClasses = [];
205 def X86NoSegMemAsmOperand : AsmOperandClass {
206 let Name = "NoSegMem";
207 let SuperClasses = [X86MemAsmOperand];
209 def X86AbsMemAsmOperand : AsmOperandClass {
211 let SuperClasses = [X86NoSegMemAsmOperand];
213 class X86MemOperand<string printMethod> : Operand<iPTR> {
214 let PrintMethod = printMethod;
215 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
216 let ParserMatchClass = X86MemAsmOperand;
219 def opaque32mem : X86MemOperand<"printopaquemem">;
220 def opaque48mem : X86MemOperand<"printopaquemem">;
221 def opaque80mem : X86MemOperand<"printopaquemem">;
222 def opaque512mem : X86MemOperand<"printopaquemem">;
224 def i8mem : X86MemOperand<"printi8mem">;
225 def i16mem : X86MemOperand<"printi16mem">;
226 def i32mem : X86MemOperand<"printi32mem">;
227 def i64mem : X86MemOperand<"printi64mem">;
228 def i128mem : X86MemOperand<"printi128mem">;
229 //def i256mem : X86MemOperand<"printi256mem">;
230 def f32mem : X86MemOperand<"printf32mem">;
231 def f64mem : X86MemOperand<"printf64mem">;
232 def f80mem : X86MemOperand<"printf80mem">;
233 def f128mem : X86MemOperand<"printf128mem">;
234 //def f256mem : X86MemOperand<"printf256mem">;
236 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
237 // plain GR64, so that it doesn't potentially require a REX prefix.
238 def i8mem_NOREX : Operand<i64> {
239 let PrintMethod = "printi8mem";
240 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
241 let ParserMatchClass = X86MemAsmOperand;
244 // Special i32mem for addresses of load folding tail calls. These are not
245 // allowed to use callee-saved registers since they must be scheduled
246 // after callee-saved register are popped.
247 def i32mem_TC : Operand<i32> {
248 let PrintMethod = "printi32mem";
249 let MIOperandInfo = (ops GR32_TC, i8imm, GR32_TC, i32imm, i8imm);
250 let ParserMatchClass = X86MemAsmOperand;
253 def lea32mem : Operand<i32> {
254 let PrintMethod = "printlea32mem";
255 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
256 let ParserMatchClass = X86NoSegMemAsmOperand;
259 let ParserMatchClass = X86AbsMemAsmOperand,
260 PrintMethod = "print_pcrel_imm" in {
261 def i32imm_pcrel : Operand<i32>;
263 def offset8 : Operand<i64>;
264 def offset16 : Operand<i64>;
265 def offset32 : Operand<i64>;
266 def offset64 : Operand<i64>;
268 // Branch targets have OtherVT type and print as pc-relative values.
269 def brtarget : Operand<OtherVT>;
270 def brtarget8 : Operand<OtherVT>;
274 def SSECC : Operand<i8> {
275 let PrintMethod = "printSSECC";
278 class ImmSExtAsmOperandClass : AsmOperandClass {
279 let SuperClasses = [ImmAsmOperand];
280 let RenderMethod = "addImmOperands";
283 // Sign-extended immediate classes. We don't need to define the full lattice
284 // here because there is no instruction with an ambiguity between ImmSExti64i32
287 // The strange ranges come from the fact that the assembler always works with
288 // 64-bit immediates, but for a 16-bit target value we want to accept both "-1"
289 // (which will be a -1ULL), and "0xFF" (-1 in 16-bits).
291 // [0, 0x7FFFFFFF] | [0xFFFFFFFF80000000, 0xFFFFFFFFFFFFFFFF]
292 def ImmSExti64i32AsmOperand : ImmSExtAsmOperandClass {
293 let Name = "ImmSExti64i32";
296 // [0, 0x0000007F] | [0x000000000000FF80, 0x000000000000FFFF] | [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
297 def ImmSExti16i8AsmOperand : ImmSExtAsmOperandClass {
298 let Name = "ImmSExti16i8";
299 let SuperClasses = [ImmSExti64i32AsmOperand];
302 // [0, 0x0000007F] | [0x00000000FFFFFF80, 0x00000000FFFFFFFF] | [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
303 def ImmSExti32i8AsmOperand : ImmSExtAsmOperandClass {
304 let Name = "ImmSExti32i8";
307 // [0, 0x0000007F] | [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
308 def ImmSExti64i8AsmOperand : ImmSExtAsmOperandClass {
309 let Name = "ImmSExti64i8";
310 let SuperClasses = [ImmSExti16i8AsmOperand, ImmSExti32i8AsmOperand, ImmSExti64i32AsmOperand];
313 // A couple of more descriptive operand definitions.
314 // 16-bits but only 8 bits are significant.
315 def i16i8imm : Operand<i16> {
316 let ParserMatchClass = ImmSExti16i8AsmOperand;
318 // 32-bits but only 8 bits are significant.
319 def i32i8imm : Operand<i32> {
320 let ParserMatchClass = ImmSExti32i8AsmOperand;
323 //===----------------------------------------------------------------------===//
324 // X86 Complex Pattern Definitions.
327 // Define X86 specific addressing mode.
328 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
329 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
330 [add, sub, mul, X86mul_imm, shl, or, frameindex],
332 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
333 [tglobaltlsaddr], []>;
335 //===----------------------------------------------------------------------===//
336 // X86 Instruction Predicate Definitions.
337 def HasCMov : Predicate<"Subtarget->hasCMov()">;
338 def NoCMov : Predicate<"!Subtarget->hasCMov()">;
339 def HasMMX : Predicate<"Subtarget->hasMMX()">;
340 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
341 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
342 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
343 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
344 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
345 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
346 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
347 def HasAVX : Predicate<"Subtarget->hasAVX()">;
348 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
349 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
350 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
351 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
352 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
353 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
354 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
355 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
356 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
357 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
358 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
359 "TM.getCodeModel() != CodeModel::Kernel">;
360 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
361 "TM.getCodeModel() == CodeModel::Kernel">;
362 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
363 def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
364 def OptForSize : Predicate<"OptForSize">;
365 def OptForSpeed : Predicate<"!OptForSize">;
366 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
367 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
368 def HasAES : Predicate<"Subtarget->hasAES()">;
370 //===----------------------------------------------------------------------===//
371 // X86 Instruction Format Definitions.
374 include "X86InstrFormats.td"
376 //===----------------------------------------------------------------------===//
377 // Pattern fragments...
380 // X86 specific condition code. These correspond to CondCode in
381 // X86InstrInfo.h. They must be kept in synch.
382 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
383 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
384 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
385 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
386 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
387 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
388 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
389 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
390 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
391 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
392 def X86_COND_NO : PatLeaf<(i8 10)>;
393 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
394 def X86_COND_NS : PatLeaf<(i8 12)>;
395 def X86_COND_O : PatLeaf<(i8 13)>;
396 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
397 def X86_COND_S : PatLeaf<(i8 15)>;
399 def immSext8 : PatLeaf<(imm), [{
400 return N->getSExtValue() == (int8_t)N->getSExtValue();
403 def i16immSExt8 : PatLeaf<(i16 immSext8)>;
404 def i32immSExt8 : PatLeaf<(i32 immSext8)>;
406 /// Load patterns: these constraint the match to the right address space.
407 def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
408 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
409 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
410 if (PT->getAddressSpace() > 255)
415 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
416 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
417 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
418 return PT->getAddressSpace() == 256;
422 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
423 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
424 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
425 return PT->getAddressSpace() == 257;
430 // Helper fragments for loads.
431 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
432 // known to be 32-bit aligned or better. Ditto for i8 to i16.
433 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
434 LoadSDNode *LD = cast<LoadSDNode>(N);
435 if (const Value *Src = LD->getSrcValue())
436 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
437 if (PT->getAddressSpace() > 255)
439 ISD::LoadExtType ExtType = LD->getExtensionType();
440 if (ExtType == ISD::NON_EXTLOAD)
442 if (ExtType == ISD::EXTLOAD)
443 return LD->getAlignment() >= 2 && !LD->isVolatile();
447 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
448 LoadSDNode *LD = cast<LoadSDNode>(N);
449 if (const Value *Src = LD->getSrcValue())
450 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
451 if (PT->getAddressSpace() > 255)
453 ISD::LoadExtType ExtType = LD->getExtensionType();
454 if (ExtType == ISD::EXTLOAD)
455 return LD->getAlignment() >= 2 && !LD->isVolatile();
459 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
460 LoadSDNode *LD = cast<LoadSDNode>(N);
461 if (const Value *Src = LD->getSrcValue())
462 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
463 if (PT->getAddressSpace() > 255)
465 ISD::LoadExtType ExtType = LD->getExtensionType();
466 if (ExtType == ISD::NON_EXTLOAD)
468 if (ExtType == ISD::EXTLOAD)
469 return LD->getAlignment() >= 4 && !LD->isVolatile();
473 def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
474 def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
475 def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
476 def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
477 def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
479 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
480 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
481 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
483 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
484 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
485 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
486 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
487 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
488 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
490 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
491 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
492 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
493 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
494 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
495 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
498 // An 'and' node with a single use.
499 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
500 return N->hasOneUse();
502 // An 'srl' node with a single use.
503 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
504 return N->hasOneUse();
506 // An 'trunc' node with a single use.
507 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
508 return N->hasOneUse();
511 // Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
512 def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
513 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
514 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
516 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
517 APInt Mask = APInt::getAllOnesValue(BitWidth);
518 APInt KnownZero0, KnownOne0;
519 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
520 APInt KnownZero1, KnownOne1;
521 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
522 return (~KnownZero0 & ~KnownZero1) == 0;
525 //===----------------------------------------------------------------------===//
526 // Instruction list...
529 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
530 // a stack adjustment and the codegen must know that they may modify the stack
531 // pointer before prolog-epilog rewriting occurs.
532 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
533 // sub / add which can clobber EFLAGS.
534 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
535 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
537 [(X86callseq_start timm:$amt)]>,
538 Requires<[In32BitMode]>;
539 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
541 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
542 Requires<[In32BitMode]>;
545 // x86-64 va_start lowering magic.
546 let usesCustomInserter = 1 in {
547 def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
550 i64imm:$regsavefi, i64imm:$offset,
552 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
553 [(X86vastart_save_xmm_regs GR8:$al,
557 // Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls
558 // to _alloca is needed to probe the stack when allocating more than 4k bytes in
559 // one go. Touching the stack at 4K increments is necessary to ensure that the
560 // guard pages used by the OS virtual memory manager are allocated in correct
562 // The main point of having separate instruction are extra unmodelled effects
563 // (compared to ordinary calls) like stack pointer change.
565 def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
566 "# dynamic stack allocation",
571 let neverHasSideEffects = 1 in {
572 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
573 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
574 "nop{w}\t$zero", []>, TB, OpSize;
575 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
576 "nop{l}\t$zero", []>, TB;
580 def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>;
581 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", []>;
582 // FIXME: need to make sure that "int $3" matches int3
583 def INT : Ii8<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
584 def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
585 def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
587 // PIC base construction. This expands to code that looks like this:
590 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
591 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
594 //===----------------------------------------------------------------------===//
595 // Control Flow Instructions.
598 // Return instructions.
599 let isTerminator = 1, isReturn = 1, isBarrier = 1,
600 hasCtrlDep = 1, FPForm = SpecialFP in {
601 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
604 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
606 [(X86retflag timm:$amt)]>;
607 def LRET : I <0xCB, RawFrm, (outs), (ins),
609 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
613 // Unconditional branches.
614 let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
615 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
616 "jmp\t$dst", [(br bb:$dst)]>;
617 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
621 // Conditional Branches.
622 let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
623 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
624 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
625 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
626 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
630 defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
631 defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
632 defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
633 defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
634 defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
635 defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
636 defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
637 defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
638 defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
639 defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
640 defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
641 defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
642 defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
643 defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
644 defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
645 defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
647 // FIXME: What about the CX/RCX versions of this instruction?
648 let Uses = [ECX], isBranch = 1, isTerminator = 1 in
649 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
654 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
655 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
656 [(brind GR32:$dst)]>;
657 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
658 [(brind (loadi32 addr:$dst))]>;
660 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
661 (ins i16imm:$seg, i16imm:$off),
662 "ljmp{w}\t$seg, $off", []>, OpSize;
663 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
664 (ins i16imm:$seg, i32imm:$off),
665 "ljmp{l}\t$seg, $off", []>;
667 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
668 "ljmp{w}\t{*}$dst", []>, OpSize;
669 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
670 "ljmp{l}\t{*}$dst", []>;
676 def LOOP : I<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
677 def LOOPE : I<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
678 def LOOPNE : I<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;
680 //===----------------------------------------------------------------------===//
681 // Call Instructions...
684 // All calls clobber the non-callee saved registers. ESP is marked as
685 // a use to prevent stack-pointer assignments that appear immediately
686 // before calls from potentially appearing dead. Uses for argument
687 // registers are added manually.
688 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
689 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
690 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
691 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
693 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
694 (outs), (ins i32imm_pcrel:$dst,variable_ops),
696 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
697 "call\t{*}$dst", [(X86call GR32:$dst)]>;
698 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
699 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
701 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
702 (ins i16imm:$seg, i16imm:$off),
703 "lcall{w}\t$seg, $off", []>, OpSize;
704 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
705 (ins i16imm:$seg, i32imm:$off),
706 "lcall{l}\t$seg, $off", []>;
708 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
709 "lcall{w}\t{*}$dst", []>, OpSize;
710 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
711 "lcall{l}\t{*}$dst", []>;
714 // Constructing a stack frame.
716 def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
717 "enter\t$len, $lvl", []>;
721 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
722 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
723 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
724 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
725 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
727 def TCRETURNdi : I<0, Pseudo, (outs),
728 (ins i32imm_pcrel:$dst, i32imm:$offset, variable_ops),
729 "#TC_RETURN $dst $offset", []>;
730 def TCRETURNri : I<0, Pseudo, (outs),
731 (ins GR32_TC:$dst, i32imm:$offset, variable_ops),
732 "#TC_RETURN $dst $offset", []>;
734 def TCRETURNmi : I<0, Pseudo, (outs),
735 (ins i32mem_TC:$dst, i32imm:$offset, variable_ops),
736 "#TC_RETURN $dst $offset", []>;
738 // FIXME: The should be pseudo instructions that are lowered when going to
740 def TAILJMPd : Ii32PCRel<0xE9, RawFrm, (outs),
741 (ins i32imm_pcrel:$dst, variable_ops),
742 "jmp\t$dst # TAILCALL",
744 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32_TC:$dst, variable_ops),
745 "jmp{l}\t{*}$dst # TAILCALL",
748 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
749 "jmp{l}\t{*}$dst # TAILCALL", []>;
751 // FIXME: This is a hack so that MCInst lowering can preserve the TAILCALL
752 // marker on instructions, while still being able to relax.
753 let isCodeGenOnly = 1 in {
754 def TAILJMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
755 "jmp\t$dst # TAILCALL", []>;
759 //===----------------------------------------------------------------------===//
760 // Miscellaneous Instructions...
762 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
763 def LEAVE : I<0xC9, RawFrm,
764 (outs), (ins), "leave", []>;
766 def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
767 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
769 def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
770 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
771 def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
772 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
774 def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
775 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
777 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
779 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
781 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
782 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
784 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
786 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
787 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
790 let mayStore = 1 in {
791 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
793 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
794 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
796 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
798 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
799 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
803 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
804 def PUSHi8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
805 "push{l}\t$imm", []>;
806 def PUSHi16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
807 "push{w}\t$imm", []>, OpSize;
808 def PUSHi32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
809 "push{l}\t$imm", []>;
812 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
813 def POPF16 : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
814 def POPF32 : I<0x9D, RawFrm, (outs), (ins), "popf{l|d}", []>,
815 Requires<[In32BitMode]>;
817 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
818 def PUSHF16 : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
819 def PUSHF32 : I<0x9C, RawFrm, (outs), (ins), "pushf{l|d}", []>,
820 Requires<[In32BitMode]>;
823 let Defs = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], Uses = [ESP],
824 mayLoad=1, neverHasSideEffects=1 in {
825 def POPA32 : I<0x61, RawFrm, (outs), (ins), "popa{l}", []>,
826 Requires<[In32BitMode]>;
828 let Defs = [ESP], Uses = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP],
829 mayStore=1, neverHasSideEffects=1 in {
830 def PUSHA32 : I<0x60, RawFrm, (outs), (ins), "pusha{l}", []>,
831 Requires<[In32BitMode]>;
834 let Uses = [EFLAGS], Constraints = "$src = $dst" in // GR32 = bswap GR32
835 def BSWAP32r : I<0xC8, AddRegFrm,
836 (outs GR32:$dst), (ins GR32:$src),
838 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
841 // Bit scan instructions.
842 let Defs = [EFLAGS] in {
843 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
844 "bsf{w}\t{$src, $dst|$dst, $src}",
845 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB, OpSize;
846 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
847 "bsf{w}\t{$src, $dst|$dst, $src}",
848 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB,
850 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
851 "bsf{l}\t{$src, $dst|$dst, $src}",
852 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
853 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
854 "bsf{l}\t{$src, $dst|$dst, $src}",
855 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
857 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
858 "bsr{w}\t{$src, $dst|$dst, $src}",
859 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB, OpSize;
860 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
861 "bsr{w}\t{$src, $dst|$dst, $src}",
862 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB,
864 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
865 "bsr{l}\t{$src, $dst|$dst, $src}",
866 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
867 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
868 "bsr{l}\t{$src, $dst|$dst, $src}",
869 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
872 let neverHasSideEffects = 1 in
873 def LEA16r : I<0x8D, MRMSrcMem,
874 (outs GR16:$dst), (ins lea32mem:$src),
875 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
876 let isReMaterializable = 1 in
877 def LEA32r : I<0x8D, MRMSrcMem,
878 (outs GR32:$dst), (ins lea32mem:$src),
879 "lea{l}\t{$src|$dst}, {$dst|$src}",
880 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
882 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
883 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
884 [(X86rep_movs i8)]>, REP;
885 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
886 [(X86rep_movs i16)]>, REP, OpSize;
887 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
888 [(X86rep_movs i32)]>, REP;
891 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
892 let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
893 def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
894 def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
895 def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
898 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
899 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
900 [(X86rep_stos i8)]>, REP;
901 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
902 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
903 [(X86rep_stos i16)]>, REP, OpSize;
904 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
905 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
906 [(X86rep_stos i32)]>, REP;
908 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
909 let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
910 def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
911 let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
912 def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
913 let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
914 def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
916 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
917 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
918 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
920 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
921 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
922 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
924 let Defs = [RAX, RDX] in
925 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
928 let Defs = [RAX, RCX, RDX] in
929 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
931 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in {
932 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
935 def SYSCALL : I<0x05, RawFrm,
936 (outs), (ins), "syscall", []>, TB;
937 def SYSRET : I<0x07, RawFrm,
938 (outs), (ins), "sysret", []>, TB;
939 def SYSENTER : I<0x34, RawFrm,
940 (outs), (ins), "sysenter", []>, TB;
941 def SYSEXIT : I<0x35, RawFrm,
942 (outs), (ins), "sysexit", []>, TB;
944 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
947 //===----------------------------------------------------------------------===//
948 // Input/Output Instructions...
950 let Defs = [AL], Uses = [DX] in
951 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
952 "in{b}\t{%dx, %al|%AL, %DX}", []>;
953 let Defs = [AX], Uses = [DX] in
954 def IN16rr : I<0xED, RawFrm, (outs), (ins),
955 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
956 let Defs = [EAX], Uses = [DX] in
957 def IN32rr : I<0xED, RawFrm, (outs), (ins),
958 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
961 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
962 "in{b}\t{$port, %al|%AL, $port}", []>;
964 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
965 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
967 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
968 "in{l}\t{$port, %eax|%EAX, $port}", []>;
970 let Uses = [DX, AL] in
971 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
972 "out{b}\t{%al, %dx|%DX, %AL}", []>;
973 let Uses = [DX, AX] in
974 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
975 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
976 let Uses = [DX, EAX] in
977 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
978 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
981 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
982 "out{b}\t{%al, $port|$port, %AL}", []>;
984 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
985 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
987 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
988 "out{l}\t{%eax, $port|$port, %EAX}", []>;
990 def IN8 : I<0x6C, RawFrm, (outs), (ins),
992 def IN16 : I<0x6D, RawFrm, (outs), (ins),
993 "ins{w}", []>, OpSize;
994 def IN32 : I<0x6D, RawFrm, (outs), (ins),
997 //===----------------------------------------------------------------------===//
998 // Move Instructions...
1000 let neverHasSideEffects = 1 in {
1001 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
1002 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1003 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
1004 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1005 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
1006 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1008 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
1009 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
1010 "mov{b}\t{$src, $dst|$dst, $src}",
1011 [(set GR8:$dst, imm:$src)]>;
1012 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
1013 "mov{w}\t{$src, $dst|$dst, $src}",
1014 [(set GR16:$dst, imm:$src)]>, OpSize;
1015 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
1016 "mov{l}\t{$src, $dst|$dst, $src}",
1017 [(set GR32:$dst, imm:$src)]>;
1020 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
1021 "mov{b}\t{$src, $dst|$dst, $src}",
1022 [(store (i8 imm:$src), addr:$dst)]>;
1023 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
1024 "mov{w}\t{$src, $dst|$dst, $src}",
1025 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
1026 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
1027 "mov{l}\t{$src, $dst|$dst, $src}",
1028 [(store (i32 imm:$src), addr:$dst)]>;
1030 /// moffs8, moffs16 and moffs32 versions of moves. The immediate is a
1031 /// 32-bit offset from the PC. These are only valid in x86-32 mode.
1032 def MOV8o8a : Ii32 <0xA0, RawFrm, (outs), (ins offset8:$src),
1033 "mov{b}\t{$src, %al|%al, $src}", []>;
1034 def MOV16o16a : Ii32 <0xA1, RawFrm, (outs), (ins offset16:$src),
1035 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1036 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
1037 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1038 def MOV8ao8 : Ii32 <0xA2, RawFrm, (outs offset8:$dst), (ins),
1039 "mov{b}\t{%al, $dst|$dst, %al}", []>;
1040 def MOV16ao16 : Ii32 <0xA3, RawFrm, (outs offset16:$dst), (ins),
1041 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
1042 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
1043 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1045 // Moves to and from segment registers
1046 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1047 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1048 def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
1049 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1050 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1051 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1052 def MOV32ms : I<0x8C, MRMDestMem, (outs i32mem:$dst), (ins SEGMENT_REG:$src),
1053 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1054 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1055 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1056 def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
1057 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1058 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1059 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1060 def MOV32sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i32mem:$src),
1061 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1063 let isCodeGenOnly = 1 in {
1064 def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1065 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1066 def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1067 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1068 def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1069 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1072 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1073 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
1074 "mov{b}\t{$src, $dst|$dst, $src}",
1075 [(set GR8:$dst, (loadi8 addr:$src))]>;
1076 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
1077 "mov{w}\t{$src, $dst|$dst, $src}",
1078 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
1079 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
1080 "mov{l}\t{$src, $dst|$dst, $src}",
1081 [(set GR32:$dst, (loadi32 addr:$src))]>;
1084 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
1085 "mov{b}\t{$src, $dst|$dst, $src}",
1086 [(store GR8:$src, addr:$dst)]>;
1087 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1088 "mov{w}\t{$src, $dst|$dst, $src}",
1089 [(store GR16:$src, addr:$dst)]>, OpSize;
1090 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1091 "mov{l}\t{$src, $dst|$dst, $src}",
1092 [(store GR32:$src, addr:$dst)]>;
1094 /// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
1095 let neverHasSideEffects = 1 in
1096 def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1097 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1100 canFoldAsLoad = 1, isReMaterializable = 1 in
1101 def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1102 "mov{l}\t{$src, $dst|$dst, $src}",
1106 def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1107 "mov{l}\t{$src, $dst|$dst, $src}",
1110 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1111 // that they can be used for copying and storing h registers, which can't be
1112 // encoded when a REX prefix is present.
1113 let neverHasSideEffects = 1 in
1114 def MOV8rr_NOREX : I<0x88, MRMDestReg,
1115 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
1116 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1118 def MOV8mr_NOREX : I<0x88, MRMDestMem,
1119 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1120 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1122 canFoldAsLoad = 1, isReMaterializable = 1 in
1123 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1124 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1125 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1127 // Moves to and from debug registers
1128 def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1129 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1130 def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1131 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1133 // Moves to and from control registers
1134 def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
1135 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1136 def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
1137 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1139 //===----------------------------------------------------------------------===//
1140 // Fixed-Register Multiplication and Division Instructions...
1143 // Extra precision multiplication
1145 // AL is really implied by AX, by the registers in Defs must match the
1146 // SDNode results (i8, i32).
1147 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1148 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
1149 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1150 // This probably ought to be moved to a def : Pat<> if the
1151 // syntax can be accepted.
1152 [(set AL, (mul AL, GR8:$src)),
1153 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1155 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1156 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1158 []>, OpSize; // AX,DX = AX*GR16
1160 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1161 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1163 []>; // EAX,EDX = EAX*GR32
1165 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1166 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1168 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1169 // This probably ought to be moved to a def : Pat<> if the
1170 // syntax can be accepted.
1171 [(set AL, (mul AL, (loadi8 addr:$src))),
1172 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1174 let mayLoad = 1, neverHasSideEffects = 1 in {
1175 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1176 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1178 []>, OpSize; // AX,DX = AX*[mem16]
1180 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1181 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1183 []>; // EAX,EDX = EAX*[mem32]
1186 let neverHasSideEffects = 1 in {
1187 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1188 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1190 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1191 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
1192 OpSize; // AX,DX = AX*GR16
1193 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1194 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1195 // EAX,EDX = EAX*GR32
1196 let mayLoad = 1 in {
1197 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1198 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1199 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
1200 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1201 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1202 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1203 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1204 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1205 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
1207 } // neverHasSideEffects
1209 // unsigned division/remainder
1210 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1211 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1212 "div{b}\t$src", []>;
1213 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1214 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1215 "div{w}\t$src", []>, OpSize;
1216 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1217 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1218 "div{l}\t$src", []>;
1219 let mayLoad = 1 in {
1220 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1221 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1222 "div{b}\t$src", []>;
1223 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1224 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1225 "div{w}\t$src", []>, OpSize;
1226 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1227 // EDX:EAX/[mem32] = EAX,EDX
1228 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
1229 "div{l}\t$src", []>;
1232 // Signed division/remainder.
1233 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1234 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1235 "idiv{b}\t$src", []>;
1236 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1237 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1238 "idiv{w}\t$src", []>, OpSize;
1239 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1240 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1241 "idiv{l}\t$src", []>;
1242 let mayLoad = 1, mayLoad = 1 in {
1243 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1244 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1245 "idiv{b}\t$src", []>;
1246 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1247 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1248 "idiv{w}\t$src", []>, OpSize;
1249 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1250 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1251 // EDX:EAX/[mem32] = EAX,EDX
1252 "idiv{l}\t$src", []>;
1255 //===----------------------------------------------------------------------===//
1256 // Two address Instructions.
1258 let Constraints = "$src1 = $dst" in {
1260 // Conditional moves
1261 let Uses = [EFLAGS] in {
1263 let Predicates = [HasCMov] in {
1264 let isCommutable = 1 in {
1265 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1266 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1267 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1268 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1269 X86_COND_B, EFLAGS))]>,
1271 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1272 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1273 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1274 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1275 X86_COND_B, EFLAGS))]>,
1277 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1278 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1279 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1280 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1281 X86_COND_AE, EFLAGS))]>,
1283 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1284 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1285 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1286 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1287 X86_COND_AE, EFLAGS))]>,
1289 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1290 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1291 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1292 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1293 X86_COND_E, EFLAGS))]>,
1295 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1296 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1297 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1298 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1299 X86_COND_E, EFLAGS))]>,
1301 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1302 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1303 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1304 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1305 X86_COND_NE, EFLAGS))]>,
1307 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1308 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1309 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1310 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1311 X86_COND_NE, EFLAGS))]>,
1313 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1314 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1315 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1316 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1317 X86_COND_BE, EFLAGS))]>,
1319 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1320 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1321 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1322 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1323 X86_COND_BE, EFLAGS))]>,
1325 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1326 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1327 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1328 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1329 X86_COND_A, EFLAGS))]>,
1331 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1332 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1333 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1334 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1335 X86_COND_A, EFLAGS))]>,
1337 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1338 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1339 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1340 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1341 X86_COND_L, EFLAGS))]>,
1343 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1344 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1345 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1346 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1347 X86_COND_L, EFLAGS))]>,
1349 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1350 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1351 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1352 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1353 X86_COND_GE, EFLAGS))]>,
1355 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1356 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1357 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1358 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1359 X86_COND_GE, EFLAGS))]>,
1361 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1362 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1363 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1364 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1365 X86_COND_LE, EFLAGS))]>,
1367 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1368 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1369 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1370 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1371 X86_COND_LE, EFLAGS))]>,
1373 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1374 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1375 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1376 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1377 X86_COND_G, EFLAGS))]>,
1379 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1380 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1381 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1382 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1383 X86_COND_G, EFLAGS))]>,
1385 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1386 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1387 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1388 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1389 X86_COND_S, EFLAGS))]>,
1391 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1392 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1393 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1394 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1395 X86_COND_S, EFLAGS))]>,
1397 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1398 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1399 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1400 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1401 X86_COND_NS, EFLAGS))]>,
1403 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1404 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1405 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1406 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1407 X86_COND_NS, EFLAGS))]>,
1409 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1410 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1411 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1412 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1413 X86_COND_P, EFLAGS))]>,
1415 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1416 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1417 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1418 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1419 X86_COND_P, EFLAGS))]>,
1421 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1422 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1423 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1424 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1425 X86_COND_NP, EFLAGS))]>,
1427 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1428 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1429 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1430 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1431 X86_COND_NP, EFLAGS))]>,
1433 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1434 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1435 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1436 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1437 X86_COND_O, EFLAGS))]>,
1439 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1440 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1441 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1442 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1443 X86_COND_O, EFLAGS))]>,
1445 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1446 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1447 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1448 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1449 X86_COND_NO, EFLAGS))]>,
1451 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1452 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1453 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1454 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1455 X86_COND_NO, EFLAGS))]>,
1457 } // isCommutable = 1
1459 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1460 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1461 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1462 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1463 X86_COND_B, EFLAGS))]>,
1465 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1466 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1467 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1468 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1469 X86_COND_B, EFLAGS))]>,
1471 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1472 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1473 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1474 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1475 X86_COND_AE, EFLAGS))]>,
1477 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1478 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1479 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1480 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1481 X86_COND_AE, EFLAGS))]>,
1483 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1484 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1485 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1486 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1487 X86_COND_E, EFLAGS))]>,
1489 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1490 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1491 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1492 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1493 X86_COND_E, EFLAGS))]>,
1495 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1496 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1497 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1498 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1499 X86_COND_NE, EFLAGS))]>,
1501 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1502 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1503 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1504 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1505 X86_COND_NE, EFLAGS))]>,
1507 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1508 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1509 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1510 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1511 X86_COND_BE, EFLAGS))]>,
1513 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1514 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1515 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1516 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1517 X86_COND_BE, EFLAGS))]>,
1519 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1520 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1521 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1522 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1523 X86_COND_A, EFLAGS))]>,
1525 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1526 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1527 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1528 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1529 X86_COND_A, EFLAGS))]>,
1531 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1532 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1533 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1534 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1535 X86_COND_L, EFLAGS))]>,
1537 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1538 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1539 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1540 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1541 X86_COND_L, EFLAGS))]>,
1543 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1544 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1545 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1546 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1547 X86_COND_GE, EFLAGS))]>,
1549 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1550 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1551 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1552 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1553 X86_COND_GE, EFLAGS))]>,
1555 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1556 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1557 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1558 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1559 X86_COND_LE, EFLAGS))]>,
1561 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1562 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1563 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1564 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1565 X86_COND_LE, EFLAGS))]>,
1567 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1568 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1569 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1570 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1571 X86_COND_G, EFLAGS))]>,
1573 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1574 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1575 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1576 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1577 X86_COND_G, EFLAGS))]>,
1579 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1580 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1581 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1582 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1583 X86_COND_S, EFLAGS))]>,
1585 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1586 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1587 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1588 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1589 X86_COND_S, EFLAGS))]>,
1591 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1592 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1593 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1594 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1595 X86_COND_NS, EFLAGS))]>,
1597 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1598 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1599 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1600 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1601 X86_COND_NS, EFLAGS))]>,
1603 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1604 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1605 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1606 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1607 X86_COND_P, EFLAGS))]>,
1609 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1610 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1611 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1612 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1613 X86_COND_P, EFLAGS))]>,
1615 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1616 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1617 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1618 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1619 X86_COND_NP, EFLAGS))]>,
1621 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1622 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1623 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1624 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1625 X86_COND_NP, EFLAGS))]>,
1627 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1628 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1629 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1630 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1631 X86_COND_O, EFLAGS))]>,
1633 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1634 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1635 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1636 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1637 X86_COND_O, EFLAGS))]>,
1639 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1640 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1641 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1642 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1643 X86_COND_NO, EFLAGS))]>,
1645 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1646 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1647 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1648 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1649 X86_COND_NO, EFLAGS))]>,
1651 } // Predicates = [HasCMov]
1653 // X86 doesn't have 8-bit conditional moves. Use a customInserter to
1654 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1655 // however that requires promoting the operands, and can induce additional
1656 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1657 // clobber EFLAGS, because if one of the operands is zero, the expansion
1658 // could involve an xor.
1659 let usesCustomInserter = 1, Constraints = "", Defs = [EFLAGS] in {
1660 def CMOV_GR8 : I<0, Pseudo,
1661 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1662 "#CMOV_GR8 PSEUDO!",
1663 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1664 imm:$cond, EFLAGS))]>;
1666 let Predicates = [NoCMov] in {
1667 def CMOV_GR32 : I<0, Pseudo,
1668 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1669 "#CMOV_GR32* PSEUDO!",
1671 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1672 def CMOV_GR16 : I<0, Pseudo,
1673 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1674 "#CMOV_GR16* PSEUDO!",
1676 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1677 def CMOV_RFP32 : I<0, Pseudo,
1679 (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
1680 "#CMOV_RFP32 PSEUDO!",
1682 (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
1684 def CMOV_RFP64 : I<0, Pseudo,
1686 (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
1687 "#CMOV_RFP64 PSEUDO!",
1689 (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
1691 def CMOV_RFP80 : I<0, Pseudo,
1693 (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
1694 "#CMOV_RFP80 PSEUDO!",
1696 (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
1698 } // Predicates = [NoCMov]
1699 } // UsesCustomInserter = 1, Constraints = "", Defs = [EFLAGS]
1700 } // Uses = [EFLAGS]
1703 // unary instructions
1704 let CodeSize = 2 in {
1705 let Defs = [EFLAGS] in {
1706 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src1),
1708 [(set GR8:$dst, (ineg GR8:$src1)),
1709 (implicit EFLAGS)]>;
1710 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
1712 [(set GR16:$dst, (ineg GR16:$src1)),
1713 (implicit EFLAGS)]>, OpSize;
1714 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
1716 [(set GR32:$dst, (ineg GR32:$src1)),
1717 (implicit EFLAGS)]>;
1719 let Constraints = "" in {
1720 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst),
1722 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1723 (implicit EFLAGS)]>;
1724 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst),
1726 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1727 (implicit EFLAGS)]>, OpSize;
1728 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst),
1730 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1731 (implicit EFLAGS)]>;
1732 } // Constraints = ""
1733 } // Defs = [EFLAGS]
1735 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1736 let AddedComplexity = 15 in {
1737 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src1),
1739 [(set GR8:$dst, (not GR8:$src1))]>;
1740 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
1742 [(set GR16:$dst, (not GR16:$src1))]>, OpSize;
1743 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
1745 [(set GR32:$dst, (not GR32:$src1))]>;
1747 let Constraints = "" in {
1748 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst),
1750 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1751 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst),
1753 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1754 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst),
1756 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1757 } // Constraints = ""
1760 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1761 let Defs = [EFLAGS] in {
1763 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1765 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src1))]>;
1767 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1768 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1770 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src1))]>,
1771 OpSize, Requires<[In32BitMode]>;
1772 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1774 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src1))]>,
1775 Requires<[In32BitMode]>;
1777 let Constraints = "", CodeSize = 2 in {
1778 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1779 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1780 (implicit EFLAGS)]>;
1781 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1782 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1783 (implicit EFLAGS)]>,
1784 OpSize, Requires<[In32BitMode]>;
1785 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1786 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1787 (implicit EFLAGS)]>,
1788 Requires<[In32BitMode]>;
1789 } // Constraints = "", CodeSize = 2
1792 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1794 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src1))]>;
1795 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1796 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1798 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src1))]>,
1799 OpSize, Requires<[In32BitMode]>;
1800 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1802 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src1))]>,
1803 Requires<[In32BitMode]>;
1806 let Constraints = "", CodeSize = 2 in {
1807 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1808 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1809 (implicit EFLAGS)]>;
1810 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1811 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1812 (implicit EFLAGS)]>,
1813 OpSize, Requires<[In32BitMode]>;
1814 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1815 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1816 (implicit EFLAGS)]>,
1817 Requires<[In32BitMode]>;
1818 } // Constraints = "", CodeSize = 2
1819 } // Defs = [EFLAGS]
1821 // Logical operators...
1822 let Defs = [EFLAGS] in {
1823 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1824 def AND8rr : I<0x20, MRMDestReg,
1825 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1826 "and{b}\t{$src2, $dst|$dst, $src2}",
1827 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1828 def AND16rr : I<0x21, MRMDestReg,
1829 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1830 "and{w}\t{$src2, $dst|$dst, $src2}",
1831 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1832 GR16:$src2))]>, OpSize;
1833 def AND32rr : I<0x21, MRMDestReg,
1834 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1835 "and{l}\t{$src2, $dst|$dst, $src2}",
1836 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1840 // AND instructions with the destination register in REG and the source register
1841 // in R/M. Included for the disassembler.
1842 let isCodeGenOnly = 1 in {
1843 def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1844 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1845 def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1846 (ins GR16:$src1, GR16:$src2),
1847 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1848 def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1849 (ins GR32:$src1, GR32:$src2),
1850 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1853 def AND8rm : I<0x22, MRMSrcMem,
1854 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1855 "and{b}\t{$src2, $dst|$dst, $src2}",
1856 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1857 (loadi8 addr:$src2)))]>;
1858 def AND16rm : I<0x23, MRMSrcMem,
1859 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1860 "and{w}\t{$src2, $dst|$dst, $src2}",
1861 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1862 (loadi16 addr:$src2)))]>,
1864 def AND32rm : I<0x23, MRMSrcMem,
1865 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1866 "and{l}\t{$src2, $dst|$dst, $src2}",
1867 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1868 (loadi32 addr:$src2)))]>;
1870 def AND8ri : Ii8<0x80, MRM4r,
1871 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1872 "and{b}\t{$src2, $dst|$dst, $src2}",
1873 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1875 def AND16ri : Ii16<0x81, MRM4r,
1876 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1877 "and{w}\t{$src2, $dst|$dst, $src2}",
1878 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1879 imm:$src2))]>, OpSize;
1880 def AND32ri : Ii32<0x81, MRM4r,
1881 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1882 "and{l}\t{$src2, $dst|$dst, $src2}",
1883 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1885 def AND16ri8 : Ii8<0x83, MRM4r,
1886 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1887 "and{w}\t{$src2, $dst|$dst, $src2}",
1888 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1889 i16immSExt8:$src2))]>,
1891 def AND32ri8 : Ii8<0x83, MRM4r,
1892 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1893 "and{l}\t{$src2, $dst|$dst, $src2}",
1894 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1895 i32immSExt8:$src2))]>;
1897 let Constraints = "" in {
1898 def AND8mr : I<0x20, MRMDestMem,
1899 (outs), (ins i8mem :$dst, GR8 :$src),
1900 "and{b}\t{$src, $dst|$dst, $src}",
1901 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1902 (implicit EFLAGS)]>;
1903 def AND16mr : I<0x21, MRMDestMem,
1904 (outs), (ins i16mem:$dst, GR16:$src),
1905 "and{w}\t{$src, $dst|$dst, $src}",
1906 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1907 (implicit EFLAGS)]>,
1909 def AND32mr : I<0x21, MRMDestMem,
1910 (outs), (ins i32mem:$dst, GR32:$src),
1911 "and{l}\t{$src, $dst|$dst, $src}",
1912 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1913 (implicit EFLAGS)]>;
1914 def AND8mi : Ii8<0x80, MRM4m,
1915 (outs), (ins i8mem :$dst, i8imm :$src),
1916 "and{b}\t{$src, $dst|$dst, $src}",
1917 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1918 (implicit EFLAGS)]>;
1919 def AND16mi : Ii16<0x81, MRM4m,
1920 (outs), (ins i16mem:$dst, i16imm:$src),
1921 "and{w}\t{$src, $dst|$dst, $src}",
1922 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1923 (implicit EFLAGS)]>,
1925 def AND32mi : Ii32<0x81, MRM4m,
1926 (outs), (ins i32mem:$dst, i32imm:$src),
1927 "and{l}\t{$src, $dst|$dst, $src}",
1928 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1929 (implicit EFLAGS)]>;
1930 def AND16mi8 : Ii8<0x83, MRM4m,
1931 (outs), (ins i16mem:$dst, i16i8imm :$src),
1932 "and{w}\t{$src, $dst|$dst, $src}",
1933 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1934 (implicit EFLAGS)]>,
1936 def AND32mi8 : Ii8<0x83, MRM4m,
1937 (outs), (ins i32mem:$dst, i32i8imm :$src),
1938 "and{l}\t{$src, $dst|$dst, $src}",
1939 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1940 (implicit EFLAGS)]>;
1942 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1943 "and{b}\t{$src, %al|%al, $src}", []>;
1944 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1945 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1946 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1947 "and{l}\t{$src, %eax|%eax, $src}", []>;
1949 } // Constraints = ""
1952 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1953 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1954 (ins GR8 :$src1, GR8 :$src2),
1955 "or{b}\t{$src2, $dst|$dst, $src2}",
1956 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
1957 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1958 (ins GR16:$src1, GR16:$src2),
1959 "or{w}\t{$src2, $dst|$dst, $src2}",
1960 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1962 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1963 (ins GR32:$src1, GR32:$src2),
1964 "or{l}\t{$src2, $dst|$dst, $src2}",
1965 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
1968 // OR instructions with the destination register in REG and the source register
1969 // in R/M. Included for the disassembler.
1970 let isCodeGenOnly = 1 in {
1971 def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1972 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1973 def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1974 (ins GR16:$src1, GR16:$src2),
1975 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1976 def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1977 (ins GR32:$src1, GR32:$src2),
1978 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1981 def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
1982 (ins GR8 :$src1, i8mem :$src2),
1983 "or{b}\t{$src2, $dst|$dst, $src2}",
1984 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
1985 (load addr:$src2)))]>;
1986 def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
1987 (ins GR16:$src1, i16mem:$src2),
1988 "or{w}\t{$src2, $dst|$dst, $src2}",
1989 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1990 (load addr:$src2)))]>,
1992 def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
1993 (ins GR32:$src1, i32mem:$src2),
1994 "or{l}\t{$src2, $dst|$dst, $src2}",
1995 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1996 (load addr:$src2)))]>;
1998 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1999 (ins GR8 :$src1, i8imm:$src2),
2000 "or{b}\t{$src2, $dst|$dst, $src2}",
2001 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
2002 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
2003 (ins GR16:$src1, i16imm:$src2),
2004 "or{w}\t{$src2, $dst|$dst, $src2}",
2005 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2006 imm:$src2))]>, OpSize;
2007 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
2008 (ins GR32:$src1, i32imm:$src2),
2009 "or{l}\t{$src2, $dst|$dst, $src2}",
2010 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2013 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
2014 (ins GR16:$src1, i16i8imm:$src2),
2015 "or{w}\t{$src2, $dst|$dst, $src2}",
2016 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2017 i16immSExt8:$src2))]>, OpSize;
2018 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
2019 (ins GR32:$src1, i32i8imm:$src2),
2020 "or{l}\t{$src2, $dst|$dst, $src2}",
2021 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2022 i32immSExt8:$src2))]>;
2023 let Constraints = "" in {
2024 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
2025 "or{b}\t{$src, $dst|$dst, $src}",
2026 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
2027 (implicit EFLAGS)]>;
2028 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
2029 "or{w}\t{$src, $dst|$dst, $src}",
2030 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
2031 (implicit EFLAGS)]>, OpSize;
2032 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2033 "or{l}\t{$src, $dst|$dst, $src}",
2034 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
2035 (implicit EFLAGS)]>;
2036 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2037 "or{b}\t{$src, $dst|$dst, $src}",
2038 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
2039 (implicit EFLAGS)]>;
2040 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
2041 "or{w}\t{$src, $dst|$dst, $src}",
2042 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
2043 (implicit EFLAGS)]>,
2045 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
2046 "or{l}\t{$src, $dst|$dst, $src}",
2047 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
2048 (implicit EFLAGS)]>;
2049 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
2050 "or{w}\t{$src, $dst|$dst, $src}",
2051 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
2052 (implicit EFLAGS)]>,
2054 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
2055 "or{l}\t{$src, $dst|$dst, $src}",
2056 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
2057 (implicit EFLAGS)]>;
2059 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
2060 "or{b}\t{$src, %al|%al, $src}", []>;
2061 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
2062 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2063 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
2064 "or{l}\t{$src, %eax|%eax, $src}", []>;
2065 } // Constraints = ""
2068 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
2069 def XOR8rr : I<0x30, MRMDestReg,
2070 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
2071 "xor{b}\t{$src2, $dst|$dst, $src2}",
2072 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2074 def XOR16rr : I<0x31, MRMDestReg,
2075 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2076 "xor{w}\t{$src2, $dst|$dst, $src2}",
2077 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2078 GR16:$src2))]>, OpSize;
2079 def XOR32rr : I<0x31, MRMDestReg,
2080 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2081 "xor{l}\t{$src2, $dst|$dst, $src2}",
2082 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2084 } // isCommutable = 1
2086 // XOR instructions with the destination register in REG and the source register
2087 // in R/M. Included for the disassembler.
2088 let isCodeGenOnly = 1 in {
2089 def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2090 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2091 def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2092 (ins GR16:$src1, GR16:$src2),
2093 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2094 def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2095 (ins GR32:$src1, GR32:$src2),
2096 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
2099 def XOR8rm : I<0x32, MRMSrcMem,
2100 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
2101 "xor{b}\t{$src2, $dst|$dst, $src2}",
2102 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2103 (load addr:$src2)))]>;
2104 def XOR16rm : I<0x33, MRMSrcMem,
2105 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
2106 "xor{w}\t{$src2, $dst|$dst, $src2}",
2107 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2108 (load addr:$src2)))]>,
2110 def XOR32rm : I<0x33, MRMSrcMem,
2111 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2112 "xor{l}\t{$src2, $dst|$dst, $src2}",
2113 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2114 (load addr:$src2)))]>;
2116 def XOR8ri : Ii8<0x80, MRM6r,
2117 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2118 "xor{b}\t{$src2, $dst|$dst, $src2}",
2119 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
2120 def XOR16ri : Ii16<0x81, MRM6r,
2121 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2122 "xor{w}\t{$src2, $dst|$dst, $src2}",
2123 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2124 imm:$src2))]>, OpSize;
2125 def XOR32ri : Ii32<0x81, MRM6r,
2126 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2127 "xor{l}\t{$src2, $dst|$dst, $src2}",
2128 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2130 def XOR16ri8 : Ii8<0x83, MRM6r,
2131 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2132 "xor{w}\t{$src2, $dst|$dst, $src2}",
2133 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2134 i16immSExt8:$src2))]>,
2136 def XOR32ri8 : Ii8<0x83, MRM6r,
2137 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2138 "xor{l}\t{$src2, $dst|$dst, $src2}",
2139 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2140 i32immSExt8:$src2))]>;
2142 let Constraints = "" in {
2143 def XOR8mr : I<0x30, MRMDestMem,
2144 (outs), (ins i8mem :$dst, GR8 :$src),
2145 "xor{b}\t{$src, $dst|$dst, $src}",
2146 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2147 (implicit EFLAGS)]>;
2148 def XOR16mr : I<0x31, MRMDestMem,
2149 (outs), (ins i16mem:$dst, GR16:$src),
2150 "xor{w}\t{$src, $dst|$dst, $src}",
2151 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2152 (implicit EFLAGS)]>,
2154 def XOR32mr : I<0x31, MRMDestMem,
2155 (outs), (ins i32mem:$dst, GR32:$src),
2156 "xor{l}\t{$src, $dst|$dst, $src}",
2157 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2158 (implicit EFLAGS)]>;
2159 def XOR8mi : Ii8<0x80, MRM6m,
2160 (outs), (ins i8mem :$dst, i8imm :$src),
2161 "xor{b}\t{$src, $dst|$dst, $src}",
2162 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2163 (implicit EFLAGS)]>;
2164 def XOR16mi : Ii16<0x81, MRM6m,
2165 (outs), (ins i16mem:$dst, i16imm:$src),
2166 "xor{w}\t{$src, $dst|$dst, $src}",
2167 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2168 (implicit EFLAGS)]>,
2170 def XOR32mi : Ii32<0x81, MRM6m,
2171 (outs), (ins i32mem:$dst, i32imm:$src),
2172 "xor{l}\t{$src, $dst|$dst, $src}",
2173 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2174 (implicit EFLAGS)]>;
2175 def XOR16mi8 : Ii8<0x83, MRM6m,
2176 (outs), (ins i16mem:$dst, i16i8imm :$src),
2177 "xor{w}\t{$src, $dst|$dst, $src}",
2178 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2179 (implicit EFLAGS)]>,
2181 def XOR32mi8 : Ii8<0x83, MRM6m,
2182 (outs), (ins i32mem:$dst, i32i8imm :$src),
2183 "xor{l}\t{$src, $dst|$dst, $src}",
2184 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2185 (implicit EFLAGS)]>;
2187 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2188 "xor{b}\t{$src, %al|%al, $src}", []>;
2189 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
2190 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2191 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
2192 "xor{l}\t{$src, %eax|%eax, $src}", []>;
2193 } // Constraints = ""
2194 } // Defs = [EFLAGS]
2196 // Shift instructions
2197 let Defs = [EFLAGS] in {
2198 let Uses = [CL] in {
2199 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
2200 "shl{b}\t{%cl, $dst|$dst, CL}",
2201 [(set GR8:$dst, (shl GR8:$src1, CL))]>;
2202 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2203 "shl{w}\t{%cl, $dst|$dst, CL}",
2204 [(set GR16:$dst, (shl GR16:$src1, CL))]>, OpSize;
2205 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2206 "shl{l}\t{%cl, $dst|$dst, CL}",
2207 [(set GR32:$dst, (shl GR32:$src1, CL))]>;
2210 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2211 "shl{b}\t{$src2, $dst|$dst, $src2}",
2212 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2214 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2215 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2216 "shl{w}\t{$src2, $dst|$dst, $src2}",
2217 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2218 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2219 "shl{l}\t{$src2, $dst|$dst, $src2}",
2220 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
2222 // NOTE: We don't include patterns for shifts of a register by one, because
2223 // 'add reg,reg' is cheaper.
2225 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2226 "shl{b}\t$dst", []>;
2227 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2228 "shl{w}\t$dst", []>, OpSize;
2229 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2230 "shl{l}\t$dst", []>;
2232 } // isConvertibleToThreeAddress = 1
2234 let Constraints = "" in {
2235 let Uses = [CL] in {
2236 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
2237 "shl{b}\t{%cl, $dst|$dst, CL}",
2238 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
2239 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
2240 "shl{w}\t{%cl, $dst|$dst, CL}",
2241 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2242 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
2243 "shl{l}\t{%cl, $dst|$dst, CL}",
2244 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2246 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
2247 "shl{b}\t{$src, $dst|$dst, $src}",
2248 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2249 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
2250 "shl{w}\t{$src, $dst|$dst, $src}",
2251 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2253 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
2254 "shl{l}\t{$src, $dst|$dst, $src}",
2255 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2258 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2260 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2261 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2263 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2265 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2267 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2268 } // Constraints = ""
2270 let Uses = [CL] in {
2271 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1),
2272 "shr{b}\t{%cl, $dst|$dst, CL}",
2273 [(set GR8:$dst, (srl GR8:$src1, CL))]>;
2274 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2275 "shr{w}\t{%cl, $dst|$dst, CL}",
2276 [(set GR16:$dst, (srl GR16:$src1, CL))]>, OpSize;
2277 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2278 "shr{l}\t{%cl, $dst|$dst, CL}",
2279 [(set GR32:$dst, (srl GR32:$src1, CL))]>;
2282 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2283 "shr{b}\t{$src2, $dst|$dst, $src2}",
2284 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2285 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2286 "shr{w}\t{$src2, $dst|$dst, $src2}",
2287 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2288 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2289 "shr{l}\t{$src2, $dst|$dst, $src2}",
2290 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2293 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2295 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2296 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2298 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2299 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2301 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2303 let Constraints = "" in {
2304 let Uses = [CL] in {
2305 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2306 "shr{b}\t{%cl, $dst|$dst, CL}",
2307 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2308 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2309 "shr{w}\t{%cl, $dst|$dst, CL}",
2310 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2312 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2313 "shr{l}\t{%cl, $dst|$dst, CL}",
2314 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2316 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2317 "shr{b}\t{$src, $dst|$dst, $src}",
2318 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2319 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2320 "shr{w}\t{$src, $dst|$dst, $src}",
2321 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2323 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2324 "shr{l}\t{$src, $dst|$dst, $src}",
2325 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2328 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2330 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2331 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2333 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2334 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2336 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2337 } // Constraints = ""
2339 let Uses = [CL] in {
2340 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2341 "sar{b}\t{%cl, $dst|$dst, CL}",
2342 [(set GR8:$dst, (sra GR8:$src1, CL))]>;
2343 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2344 "sar{w}\t{%cl, $dst|$dst, CL}",
2345 [(set GR16:$dst, (sra GR16:$src1, CL))]>, OpSize;
2346 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2347 "sar{l}\t{%cl, $dst|$dst, CL}",
2348 [(set GR32:$dst, (sra GR32:$src1, CL))]>;
2351 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2352 "sar{b}\t{$src2, $dst|$dst, $src2}",
2353 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2354 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2355 "sar{w}\t{$src2, $dst|$dst, $src2}",
2356 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2358 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2359 "sar{l}\t{$src2, $dst|$dst, $src2}",
2360 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2363 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2365 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2366 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2368 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2369 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2371 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2373 let Constraints = "" in {
2374 let Uses = [CL] in {
2375 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2376 "sar{b}\t{%cl, $dst|$dst, CL}",
2377 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2378 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2379 "sar{w}\t{%cl, $dst|$dst, CL}",
2380 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2381 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2382 "sar{l}\t{%cl, $dst|$dst, CL}",
2383 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2385 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2386 "sar{b}\t{$src, $dst|$dst, $src}",
2387 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2388 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2389 "sar{w}\t{$src, $dst|$dst, $src}",
2390 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2392 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2393 "sar{l}\t{$src, $dst|$dst, $src}",
2394 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2397 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2399 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2400 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2402 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2404 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2406 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2407 } // Constraints = ""
2409 // Rotate instructions
2411 def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
2412 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2413 let Uses = [CL] in {
2414 def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
2415 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2417 def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
2418 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2420 def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
2421 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2422 let Uses = [CL] in {
2423 def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
2424 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2426 def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
2427 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2429 def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
2430 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2431 let Uses = [CL] in {
2432 def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
2433 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2435 def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
2436 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2438 def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
2439 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2440 let Uses = [CL] in {
2441 def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
2442 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2444 def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
2445 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2447 def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
2448 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2449 let Uses = [CL] in {
2450 def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
2451 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2453 def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
2454 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2456 def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
2457 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2458 let Uses = [CL] in {
2459 def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
2460 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2462 def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
2463 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2465 let Constraints = "" in {
2466 def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2467 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2468 def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2469 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2470 def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2471 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2472 def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2473 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2474 def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2475 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2476 def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2477 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2478 def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2479 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2480 def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2481 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2482 def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2483 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2484 def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2485 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2486 def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2487 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2488 def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2489 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2491 let Uses = [CL] in {
2492 def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2493 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2494 def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2495 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2496 def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2497 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2498 def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2499 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2500 def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2501 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2502 def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2503 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2505 } // Constraints = ""
2507 // FIXME: provide shorter instructions when imm8 == 1
2508 let Uses = [CL] in {
2509 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2510 "rol{b}\t{%cl, $dst|$dst, CL}",
2511 [(set GR8:$dst, (rotl GR8:$src1, CL))]>;
2512 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2513 "rol{w}\t{%cl, $dst|$dst, CL}",
2514 [(set GR16:$dst, (rotl GR16:$src1, CL))]>, OpSize;
2515 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2516 "rol{l}\t{%cl, $dst|$dst, CL}",
2517 [(set GR32:$dst, (rotl GR32:$src1, CL))]>;
2520 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2521 "rol{b}\t{$src2, $dst|$dst, $src2}",
2522 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2523 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2524 "rol{w}\t{$src2, $dst|$dst, $src2}",
2525 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2527 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2528 "rol{l}\t{$src2, $dst|$dst, $src2}",
2529 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2532 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2534 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2535 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2537 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2538 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2540 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2542 let Constraints = "" in {
2543 let Uses = [CL] in {
2544 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2545 "rol{b}\t{%cl, $dst|$dst, CL}",
2546 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2547 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2548 "rol{w}\t{%cl, $dst|$dst, CL}",
2549 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2550 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2551 "rol{l}\t{%cl, $dst|$dst, CL}",
2552 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2554 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2555 "rol{b}\t{$src, $dst|$dst, $src}",
2556 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2557 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2558 "rol{w}\t{$src, $dst|$dst, $src}",
2559 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2561 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2562 "rol{l}\t{$src, $dst|$dst, $src}",
2563 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2566 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2568 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2569 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2571 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2573 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2575 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2576 } // Constraints = ""
2578 let Uses = [CL] in {
2579 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2580 "ror{b}\t{%cl, $dst|$dst, CL}",
2581 [(set GR8:$dst, (rotr GR8:$src1, CL))]>;
2582 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2583 "ror{w}\t{%cl, $dst|$dst, CL}",
2584 [(set GR16:$dst, (rotr GR16:$src1, CL))]>, OpSize;
2585 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2586 "ror{l}\t{%cl, $dst|$dst, CL}",
2587 [(set GR32:$dst, (rotr GR32:$src1, CL))]>;
2590 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2591 "ror{b}\t{$src2, $dst|$dst, $src2}",
2592 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2593 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2594 "ror{w}\t{$src2, $dst|$dst, $src2}",
2595 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2597 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2598 "ror{l}\t{$src2, $dst|$dst, $src2}",
2599 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2602 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2604 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2605 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2607 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2608 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2610 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2612 let Constraints = "" in {
2613 let Uses = [CL] in {
2614 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2615 "ror{b}\t{%cl, $dst|$dst, CL}",
2616 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2617 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2618 "ror{w}\t{%cl, $dst|$dst, CL}",
2619 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2620 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2621 "ror{l}\t{%cl, $dst|$dst, CL}",
2622 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2624 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2625 "ror{b}\t{$src, $dst|$dst, $src}",
2626 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2627 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2628 "ror{w}\t{$src, $dst|$dst, $src}",
2629 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2631 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2632 "ror{l}\t{$src, $dst|$dst, $src}",
2633 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2636 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2638 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2639 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2641 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2643 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2645 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2646 } // Constraints = ""
2649 // Double shift instructions (generalizations of rotate)
2650 let Uses = [CL] in {
2651 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2652 (ins GR32:$src1, GR32:$src2),
2653 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2654 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2655 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2656 (ins GR32:$src1, GR32:$src2),
2657 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2658 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2659 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2660 (ins GR16:$src1, GR16:$src2),
2661 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2662 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2664 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2665 (ins GR16:$src1, GR16:$src2),
2666 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2667 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2671 let isCommutable = 1 in { // These instructions commute to each other.
2672 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2674 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2675 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2676 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2679 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2681 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2682 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2683 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2686 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2688 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2689 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2690 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2693 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2695 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2696 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2697 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2702 let Constraints = "" in {
2703 let Uses = [CL] in {
2704 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2705 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2706 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2708 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2709 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2710 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2713 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2714 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2715 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2716 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2717 (i8 imm:$src3)), addr:$dst)]>,
2719 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2720 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2721 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2722 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2723 (i8 imm:$src3)), addr:$dst)]>,
2726 let Uses = [CL] in {
2727 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2728 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2729 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2730 addr:$dst)]>, TB, OpSize;
2731 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2732 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2733 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2734 addr:$dst)]>, TB, OpSize;
2736 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2737 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2738 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2739 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2740 (i8 imm:$src3)), addr:$dst)]>,
2742 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2743 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2744 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2745 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2746 (i8 imm:$src3)), addr:$dst)]>,
2748 } // Constraints = ""
2749 } // Defs = [EFLAGS]
2753 let Defs = [EFLAGS] in {
2754 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2755 // Register-Register Addition
2756 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2757 (ins GR8 :$src1, GR8 :$src2),
2758 "add{b}\t{$src2, $dst|$dst, $src2}",
2759 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
2761 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2762 // Register-Register Addition
2763 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2764 (ins GR16:$src1, GR16:$src2),
2765 "add{w}\t{$src2, $dst|$dst, $src2}",
2766 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2767 GR16:$src2))]>, OpSize;
2768 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2769 (ins GR32:$src1, GR32:$src2),
2770 "add{l}\t{$src2, $dst|$dst, $src2}",
2771 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2773 } // end isConvertibleToThreeAddress
2774 } // end isCommutable
2776 // These are alternate spellings for use by the disassembler, we mark them as
2777 // code gen only to ensure they aren't matched by the assembler.
2778 let isCodeGenOnly = 1 in {
2779 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2780 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2781 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2782 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2783 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
2784 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2787 // Register-Memory Addition
2788 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2789 (ins GR8 :$src1, i8mem :$src2),
2790 "add{b}\t{$src2, $dst|$dst, $src2}",
2791 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2792 (load addr:$src2)))]>;
2793 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2794 (ins GR16:$src1, i16mem:$src2),
2795 "add{w}\t{$src2, $dst|$dst, $src2}",
2796 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2797 (load addr:$src2)))]>, OpSize;
2798 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2799 (ins GR32:$src1, i32mem:$src2),
2800 "add{l}\t{$src2, $dst|$dst, $src2}",
2801 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2802 (load addr:$src2)))]>;
2804 // Register-Integer Addition
2805 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2806 "add{b}\t{$src2, $dst|$dst, $src2}",
2807 [(set GR8:$dst, EFLAGS,
2808 (X86add_flag GR8:$src1, imm:$src2))]>;
2810 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2811 // Register-Integer Addition
2812 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2813 (ins GR16:$src1, i16imm:$src2),
2814 "add{w}\t{$src2, $dst|$dst, $src2}",
2815 [(set GR16:$dst, EFLAGS,
2816 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
2817 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2818 (ins GR32:$src1, i32imm:$src2),
2819 "add{l}\t{$src2, $dst|$dst, $src2}",
2820 [(set GR32:$dst, EFLAGS,
2821 (X86add_flag GR32:$src1, imm:$src2))]>;
2822 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2823 (ins GR16:$src1, i16i8imm:$src2),
2824 "add{w}\t{$src2, $dst|$dst, $src2}",
2825 [(set GR16:$dst, EFLAGS,
2826 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
2827 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2828 (ins GR32:$src1, i32i8imm:$src2),
2829 "add{l}\t{$src2, $dst|$dst, $src2}",
2830 [(set GR32:$dst, EFLAGS,
2831 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
2834 let Constraints = "" in {
2835 // Memory-Register Addition
2836 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2837 "add{b}\t{$src2, $dst|$dst, $src2}",
2838 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2839 (implicit EFLAGS)]>;
2840 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2841 "add{w}\t{$src2, $dst|$dst, $src2}",
2842 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2843 (implicit EFLAGS)]>, OpSize;
2844 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2845 "add{l}\t{$src2, $dst|$dst, $src2}",
2846 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2847 (implicit EFLAGS)]>;
2848 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2849 "add{b}\t{$src2, $dst|$dst, $src2}",
2850 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2851 (implicit EFLAGS)]>;
2852 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2853 "add{w}\t{$src2, $dst|$dst, $src2}",
2854 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2855 (implicit EFLAGS)]>, OpSize;
2856 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2857 "add{l}\t{$src2, $dst|$dst, $src2}",
2858 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2859 (implicit EFLAGS)]>;
2860 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2861 "add{w}\t{$src2, $dst|$dst, $src2}",
2862 [(store (add (load addr:$dst), i16immSExt8:$src2),
2864 (implicit EFLAGS)]>, OpSize;
2865 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2866 "add{l}\t{$src2, $dst|$dst, $src2}",
2867 [(store (add (load addr:$dst), i32immSExt8:$src2),
2869 (implicit EFLAGS)]>;
2872 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2873 "add{b}\t{$src, %al|%al, $src}", []>;
2874 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2875 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2876 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2877 "add{l}\t{$src, %eax|%eax, $src}", []>;
2878 } // Constraints = ""
2880 let Uses = [EFLAGS] in {
2881 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2882 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2883 "adc{b}\t{$src2, $dst|$dst, $src2}",
2884 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2885 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2886 (ins GR16:$src1, GR16:$src2),
2887 "adc{w}\t{$src2, $dst|$dst, $src2}",
2888 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2889 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2890 (ins GR32:$src1, GR32:$src2),
2891 "adc{l}\t{$src2, $dst|$dst, $src2}",
2892 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2895 let isCodeGenOnly = 1 in {
2896 def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2897 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2898 def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2899 (ins GR16:$src1, GR16:$src2),
2900 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2901 def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2902 (ins GR32:$src1, GR32:$src2),
2903 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2906 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2907 (ins GR8:$src1, i8mem:$src2),
2908 "adc{b}\t{$src2, $dst|$dst, $src2}",
2909 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2910 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2911 (ins GR16:$src1, i16mem:$src2),
2912 "adc{w}\t{$src2, $dst|$dst, $src2}",
2913 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2915 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2916 (ins GR32:$src1, i32mem:$src2),
2917 "adc{l}\t{$src2, $dst|$dst, $src2}",
2918 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2919 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2920 "adc{b}\t{$src2, $dst|$dst, $src2}",
2921 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2922 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2923 (ins GR16:$src1, i16imm:$src2),
2924 "adc{w}\t{$src2, $dst|$dst, $src2}",
2925 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2926 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2927 (ins GR16:$src1, i16i8imm:$src2),
2928 "adc{w}\t{$src2, $dst|$dst, $src2}",
2929 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2931 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2932 (ins GR32:$src1, i32imm:$src2),
2933 "adc{l}\t{$src2, $dst|$dst, $src2}",
2934 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2935 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2936 (ins GR32:$src1, i32i8imm:$src2),
2937 "adc{l}\t{$src2, $dst|$dst, $src2}",
2938 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2940 let Constraints = "" in {
2941 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2942 "adc{b}\t{$src2, $dst|$dst, $src2}",
2943 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2944 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2945 "adc{w}\t{$src2, $dst|$dst, $src2}",
2946 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2948 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2949 "adc{l}\t{$src2, $dst|$dst, $src2}",
2950 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2951 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2952 "adc{b}\t{$src2, $dst|$dst, $src2}",
2953 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2954 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2955 "adc{w}\t{$src2, $dst|$dst, $src2}",
2956 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2958 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2959 "adc{w}\t{$src2, $dst|$dst, $src2}",
2960 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2962 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2963 "adc{l}\t{$src2, $dst|$dst, $src2}",
2964 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2965 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2966 "adc{l}\t{$src2, $dst|$dst, $src2}",
2967 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2969 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2970 "adc{b}\t{$src, %al|%al, $src}", []>;
2971 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2972 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2973 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2974 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2975 } // Constraints = ""
2976 } // Uses = [EFLAGS]
2978 // Register-Register Subtraction
2979 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2980 "sub{b}\t{$src2, $dst|$dst, $src2}",
2981 [(set GR8:$dst, EFLAGS,
2982 (X86sub_flag GR8:$src1, GR8:$src2))]>;
2983 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2984 "sub{w}\t{$src2, $dst|$dst, $src2}",
2985 [(set GR16:$dst, EFLAGS,
2986 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
2987 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2988 "sub{l}\t{$src2, $dst|$dst, $src2}",
2989 [(set GR32:$dst, EFLAGS,
2990 (X86sub_flag GR32:$src1, GR32:$src2))]>;
2992 let isCodeGenOnly = 1 in {
2993 def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2994 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2995 def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2996 (ins GR16:$src1, GR16:$src2),
2997 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2998 def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2999 (ins GR32:$src1, GR32:$src2),
3000 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
3003 // Register-Memory Subtraction
3004 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
3005 (ins GR8 :$src1, i8mem :$src2),
3006 "sub{b}\t{$src2, $dst|$dst, $src2}",
3007 [(set GR8:$dst, EFLAGS,
3008 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
3009 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
3010 (ins GR16:$src1, i16mem:$src2),
3011 "sub{w}\t{$src2, $dst|$dst, $src2}",
3012 [(set GR16:$dst, EFLAGS,
3013 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
3014 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
3015 (ins GR32:$src1, i32mem:$src2),
3016 "sub{l}\t{$src2, $dst|$dst, $src2}",
3017 [(set GR32:$dst, EFLAGS,
3018 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
3020 // Register-Integer Subtraction
3021 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
3022 (ins GR8:$src1, i8imm:$src2),
3023 "sub{b}\t{$src2, $dst|$dst, $src2}",
3024 [(set GR8:$dst, EFLAGS,
3025 (X86sub_flag GR8:$src1, imm:$src2))]>;
3026 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
3027 (ins GR16:$src1, i16imm:$src2),
3028 "sub{w}\t{$src2, $dst|$dst, $src2}",
3029 [(set GR16:$dst, EFLAGS,
3030 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
3031 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
3032 (ins GR32:$src1, i32imm:$src2),
3033 "sub{l}\t{$src2, $dst|$dst, $src2}",
3034 [(set GR32:$dst, EFLAGS,
3035 (X86sub_flag GR32:$src1, imm:$src2))]>;
3036 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
3037 (ins GR16:$src1, i16i8imm:$src2),
3038 "sub{w}\t{$src2, $dst|$dst, $src2}",
3039 [(set GR16:$dst, EFLAGS,
3040 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
3041 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
3042 (ins GR32:$src1, i32i8imm:$src2),
3043 "sub{l}\t{$src2, $dst|$dst, $src2}",
3044 [(set GR32:$dst, EFLAGS,
3045 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
3047 let Constraints = "" in {
3048 // Memory-Register Subtraction
3049 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3050 "sub{b}\t{$src2, $dst|$dst, $src2}",
3051 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
3052 (implicit EFLAGS)]>;
3053 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3054 "sub{w}\t{$src2, $dst|$dst, $src2}",
3055 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
3056 (implicit EFLAGS)]>, OpSize;
3057 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3058 "sub{l}\t{$src2, $dst|$dst, $src2}",
3059 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
3060 (implicit EFLAGS)]>;
3062 // Memory-Integer Subtraction
3063 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3064 "sub{b}\t{$src2, $dst|$dst, $src2}",
3065 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
3066 (implicit EFLAGS)]>;
3067 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3068 "sub{w}\t{$src2, $dst|$dst, $src2}",
3069 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
3070 (implicit EFLAGS)]>, OpSize;
3071 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3072 "sub{l}\t{$src2, $dst|$dst, $src2}",
3073 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
3074 (implicit EFLAGS)]>;
3075 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3076 "sub{w}\t{$src2, $dst|$dst, $src2}",
3077 [(store (sub (load addr:$dst), i16immSExt8:$src2),
3079 (implicit EFLAGS)]>, OpSize;
3080 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3081 "sub{l}\t{$src2, $dst|$dst, $src2}",
3082 [(store (sub (load addr:$dst), i32immSExt8:$src2),
3084 (implicit EFLAGS)]>;
3086 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
3087 "sub{b}\t{$src, %al|%al, $src}", []>;
3088 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
3089 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3090 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
3091 "sub{l}\t{$src, %eax|%eax, $src}", []>;
3092 } // Constraints = ""
3094 let Uses = [EFLAGS] in {
3095 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
3096 (ins GR8:$src1, GR8:$src2),
3097 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3098 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
3099 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3100 (ins GR16:$src1, GR16:$src2),
3101 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3102 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
3103 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3104 (ins GR32:$src1, GR32:$src2),
3105 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3106 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
3108 let Constraints = "" in {
3109 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3110 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3111 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
3112 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3113 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3114 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
3116 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3117 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3118 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
3119 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3120 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3121 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
3122 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3123 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3124 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
3126 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3127 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3128 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
3130 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
3131 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3132 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
3133 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3134 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3135 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
3137 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3138 "sbb{b}\t{$src, %al|%al, $src}", []>;
3139 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3140 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3141 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3142 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
3143 } // Constraints = ""
3145 let isCodeGenOnly = 1 in {
3146 def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3147 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3148 def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3149 (ins GR16:$src1, GR16:$src2),
3150 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3151 def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3152 (ins GR32:$src1, GR32:$src2),
3153 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3156 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3157 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3158 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
3159 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3160 (ins GR16:$src1, i16mem:$src2),
3161 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3162 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
3164 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3165 (ins GR32:$src1, i32mem:$src2),
3166 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3167 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
3168 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3169 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3170 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
3171 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3172 (ins GR16:$src1, i16imm:$src2),
3173 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3174 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
3175 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3176 (ins GR16:$src1, i16i8imm:$src2),
3177 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3178 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3180 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3181 (ins GR32:$src1, i32imm:$src2),
3182 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3183 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
3184 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3185 (ins GR32:$src1, i32i8imm:$src2),
3186 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3187 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
3188 } // Uses = [EFLAGS]
3189 } // Defs = [EFLAGS]
3191 let Defs = [EFLAGS] in {
3192 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
3193 // Register-Register Signed Integer Multiply
3194 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
3195 "imul{w}\t{$src2, $dst|$dst, $src2}",
3196 [(set GR16:$dst, EFLAGS,
3197 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
3198 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
3199 "imul{l}\t{$src2, $dst|$dst, $src2}",
3200 [(set GR32:$dst, EFLAGS,
3201 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
3204 // Register-Memory Signed Integer Multiply
3205 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3206 (ins GR16:$src1, i16mem:$src2),
3207 "imul{w}\t{$src2, $dst|$dst, $src2}",
3208 [(set GR16:$dst, EFLAGS,
3209 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
3211 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3212 (ins GR32:$src1, i32mem:$src2),
3213 "imul{l}\t{$src2, $dst|$dst, $src2}",
3214 [(set GR32:$dst, EFLAGS,
3215 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
3216 } // Defs = [EFLAGS]
3217 } // end Two Address instructions
3219 // Suprisingly enough, these are not two address instructions!
3220 let Defs = [EFLAGS] in {
3221 // Register-Integer Signed Integer Multiply
3222 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
3223 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
3224 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3225 [(set GR16:$dst, EFLAGS,
3226 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
3227 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
3228 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
3229 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3230 [(set GR32:$dst, EFLAGS,
3231 (X86smul_flag GR32:$src1, imm:$src2))]>;
3232 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
3233 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
3234 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3235 [(set GR16:$dst, EFLAGS,
3236 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
3238 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
3239 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
3240 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3241 [(set GR32:$dst, EFLAGS,
3242 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
3244 // Memory-Integer Signed Integer Multiply
3245 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
3246 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
3247 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3248 [(set GR16:$dst, EFLAGS,
3249 (X86smul_flag (load addr:$src1), imm:$src2))]>,
3251 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
3252 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
3253 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3254 [(set GR32:$dst, EFLAGS,
3255 (X86smul_flag (load addr:$src1), imm:$src2))]>;
3256 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
3257 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
3258 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3259 [(set GR16:$dst, EFLAGS,
3260 (X86smul_flag (load addr:$src1),
3261 i16immSExt8:$src2))]>, OpSize;
3262 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
3263 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
3264 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3265 [(set GR32:$dst, EFLAGS,
3266 (X86smul_flag (load addr:$src1),
3267 i32immSExt8:$src2))]>;
3268 } // Defs = [EFLAGS]
3270 //===----------------------------------------------------------------------===//
3271 // Test instructions are just like AND, except they don't generate a result.
3273 let Defs = [EFLAGS] in {
3274 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
3275 def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3276 "test{b}\t{$src2, $src1|$src1, $src2}",
3277 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
3278 def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3279 "test{w}\t{$src2, $src1|$src1, $src2}",
3280 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
3283 def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3284 "test{l}\t{$src2, $src1|$src1, $src2}",
3285 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
3289 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3290 "test{b}\t{$src, %al|%al, $src}", []>;
3291 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3292 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3293 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3294 "test{l}\t{$src, %eax|%eax, $src}", []>;
3296 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
3297 "test{b}\t{$src2, $src1|$src1, $src2}",
3298 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
3300 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
3301 "test{w}\t{$src2, $src1|$src1, $src2}",
3302 [(set EFLAGS, (X86cmp (and GR16:$src1,
3303 (loadi16 addr:$src2)), 0))]>, OpSize;
3304 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
3305 "test{l}\t{$src2, $src1|$src1, $src2}",
3306 [(set EFLAGS, (X86cmp (and GR32:$src1,
3307 (loadi32 addr:$src2)), 0))]>;
3309 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
3310 (outs), (ins GR8:$src1, i8imm:$src2),
3311 "test{b}\t{$src2, $src1|$src1, $src2}",
3312 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
3313 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
3314 (outs), (ins GR16:$src1, i16imm:$src2),
3315 "test{w}\t{$src2, $src1|$src1, $src2}",
3316 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
3318 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
3319 (outs), (ins GR32:$src1, i32imm:$src2),
3320 "test{l}\t{$src2, $src1|$src1, $src2}",
3321 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
3323 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
3324 (outs), (ins i8mem:$src1, i8imm:$src2),
3325 "test{b}\t{$src2, $src1|$src1, $src2}",
3326 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
3328 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
3329 (outs), (ins i16mem:$src1, i16imm:$src2),
3330 "test{w}\t{$src2, $src1|$src1, $src2}",
3331 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
3333 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
3334 (outs), (ins i32mem:$src1, i32imm:$src2),
3335 "test{l}\t{$src2, $src1|$src1, $src2}",
3336 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
3338 } // Defs = [EFLAGS]
3341 // Condition code ops, incl. set if equal/not equal/...
3342 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
3343 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
3344 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
3345 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
3347 let Uses = [EFLAGS] in {
3348 // Use sbb to materialize carry bit.
3349 let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3350 // FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3351 // However, Pat<> can't replicate the destination reg into the inputs of the
3353 // FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3355 def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
3356 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3357 def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
3358 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
3360 def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
3361 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3364 def SETEr : I<0x94, MRM0r,
3365 (outs GR8 :$dst), (ins),
3367 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
3369 def SETEm : I<0x94, MRM0m,
3370 (outs), (ins i8mem:$dst),
3372 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
3375 def SETNEr : I<0x95, MRM0r,
3376 (outs GR8 :$dst), (ins),
3378 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
3380 def SETNEm : I<0x95, MRM0m,
3381 (outs), (ins i8mem:$dst),
3383 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
3386 def SETLr : I<0x9C, MRM0r,
3387 (outs GR8 :$dst), (ins),
3389 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
3390 TB; // GR8 = < signed
3391 def SETLm : I<0x9C, MRM0m,
3392 (outs), (ins i8mem:$dst),
3394 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
3395 TB; // [mem8] = < signed
3397 def SETGEr : I<0x9D, MRM0r,
3398 (outs GR8 :$dst), (ins),
3400 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
3401 TB; // GR8 = >= signed
3402 def SETGEm : I<0x9D, MRM0m,
3403 (outs), (ins i8mem:$dst),
3405 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
3406 TB; // [mem8] = >= signed
3408 def SETLEr : I<0x9E, MRM0r,
3409 (outs GR8 :$dst), (ins),
3411 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3412 TB; // GR8 = <= signed
3413 def SETLEm : I<0x9E, MRM0m,
3414 (outs), (ins i8mem:$dst),
3416 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3417 TB; // [mem8] = <= signed
3419 def SETGr : I<0x9F, MRM0r,
3420 (outs GR8 :$dst), (ins),
3422 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3423 TB; // GR8 = > signed
3424 def SETGm : I<0x9F, MRM0m,
3425 (outs), (ins i8mem:$dst),
3427 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3428 TB; // [mem8] = > signed
3430 def SETBr : I<0x92, MRM0r,
3431 (outs GR8 :$dst), (ins),
3433 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3434 TB; // GR8 = < unsign
3435 def SETBm : I<0x92, MRM0m,
3436 (outs), (ins i8mem:$dst),
3438 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3439 TB; // [mem8] = < unsign
3441 def SETAEr : I<0x93, MRM0r,
3442 (outs GR8 :$dst), (ins),
3444 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3445 TB; // GR8 = >= unsign
3446 def SETAEm : I<0x93, MRM0m,
3447 (outs), (ins i8mem:$dst),
3449 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3450 TB; // [mem8] = >= unsign
3452 def SETBEr : I<0x96, MRM0r,
3453 (outs GR8 :$dst), (ins),
3455 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3456 TB; // GR8 = <= unsign
3457 def SETBEm : I<0x96, MRM0m,
3458 (outs), (ins i8mem:$dst),
3460 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3461 TB; // [mem8] = <= unsign
3463 def SETAr : I<0x97, MRM0r,
3464 (outs GR8 :$dst), (ins),
3466 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3467 TB; // GR8 = > signed
3468 def SETAm : I<0x97, MRM0m,
3469 (outs), (ins i8mem:$dst),
3471 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3472 TB; // [mem8] = > signed
3474 def SETSr : I<0x98, MRM0r,
3475 (outs GR8 :$dst), (ins),
3477 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3478 TB; // GR8 = <sign bit>
3479 def SETSm : I<0x98, MRM0m,
3480 (outs), (ins i8mem:$dst),
3482 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3483 TB; // [mem8] = <sign bit>
3484 def SETNSr : I<0x99, MRM0r,
3485 (outs GR8 :$dst), (ins),
3487 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3488 TB; // GR8 = !<sign bit>
3489 def SETNSm : I<0x99, MRM0m,
3490 (outs), (ins i8mem:$dst),
3492 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3493 TB; // [mem8] = !<sign bit>
3495 def SETPr : I<0x9A, MRM0r,
3496 (outs GR8 :$dst), (ins),
3498 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3500 def SETPm : I<0x9A, MRM0m,
3501 (outs), (ins i8mem:$dst),
3503 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3504 TB; // [mem8] = parity
3505 def SETNPr : I<0x9B, MRM0r,
3506 (outs GR8 :$dst), (ins),
3508 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3509 TB; // GR8 = not parity
3510 def SETNPm : I<0x9B, MRM0m,
3511 (outs), (ins i8mem:$dst),
3513 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3514 TB; // [mem8] = not parity
3516 def SETOr : I<0x90, MRM0r,
3517 (outs GR8 :$dst), (ins),
3519 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3520 TB; // GR8 = overflow
3521 def SETOm : I<0x90, MRM0m,
3522 (outs), (ins i8mem:$dst),
3524 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3525 TB; // [mem8] = overflow
3526 def SETNOr : I<0x91, MRM0r,
3527 (outs GR8 :$dst), (ins),
3529 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3530 TB; // GR8 = not overflow
3531 def SETNOm : I<0x91, MRM0m,
3532 (outs), (ins i8mem:$dst),
3534 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3535 TB; // [mem8] = not overflow
3536 } // Uses = [EFLAGS]
3539 // Integer comparisons
3540 let Defs = [EFLAGS] in {
3541 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3542 "cmp{b}\t{$src, %al|%al, $src}", []>;
3543 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3544 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3545 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3546 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3548 def CMP8rr : I<0x38, MRMDestReg,
3549 (outs), (ins GR8 :$src1, GR8 :$src2),
3550 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3551 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
3552 def CMP16rr : I<0x39, MRMDestReg,
3553 (outs), (ins GR16:$src1, GR16:$src2),
3554 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3555 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
3556 def CMP32rr : I<0x39, MRMDestReg,
3557 (outs), (ins GR32:$src1, GR32:$src2),
3558 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3559 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
3560 def CMP8mr : I<0x38, MRMDestMem,
3561 (outs), (ins i8mem :$src1, GR8 :$src2),
3562 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3563 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
3564 def CMP16mr : I<0x39, MRMDestMem,
3565 (outs), (ins i16mem:$src1, GR16:$src2),
3566 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3567 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3569 def CMP32mr : I<0x39, MRMDestMem,
3570 (outs), (ins i32mem:$src1, GR32:$src2),
3571 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3572 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
3573 def CMP8rm : I<0x3A, MRMSrcMem,
3574 (outs), (ins GR8 :$src1, i8mem :$src2),
3575 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3576 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
3577 def CMP16rm : I<0x3B, MRMSrcMem,
3578 (outs), (ins GR16:$src1, i16mem:$src2),
3579 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3580 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3582 def CMP32rm : I<0x3B, MRMSrcMem,
3583 (outs), (ins GR32:$src1, i32mem:$src2),
3584 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3585 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
3587 // These are alternate spellings for use by the disassembler, we mark them as
3588 // code gen only to ensure they aren't matched by the assembler.
3589 let isCodeGenOnly = 1 in {
3590 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3591 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3592 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3593 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3594 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3595 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3598 def CMP8ri : Ii8<0x80, MRM7r,
3599 (outs), (ins GR8:$src1, i8imm:$src2),
3600 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3601 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
3602 def CMP16ri : Ii16<0x81, MRM7r,
3603 (outs), (ins GR16:$src1, i16imm:$src2),
3604 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3605 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
3606 def CMP32ri : Ii32<0x81, MRM7r,
3607 (outs), (ins GR32:$src1, i32imm:$src2),
3608 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3609 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
3610 def CMP8mi : Ii8 <0x80, MRM7m,
3611 (outs), (ins i8mem :$src1, i8imm :$src2),
3612 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3613 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
3614 def CMP16mi : Ii16<0x81, MRM7m,
3615 (outs), (ins i16mem:$src1, i16imm:$src2),
3616 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3617 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
3619 def CMP32mi : Ii32<0x81, MRM7m,
3620 (outs), (ins i32mem:$src1, i32imm:$src2),
3621 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3622 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
3623 def CMP16ri8 : Ii8<0x83, MRM7r,
3624 (outs), (ins GR16:$src1, i16i8imm:$src2),
3625 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3626 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3628 def CMP16mi8 : Ii8<0x83, MRM7m,
3629 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3630 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3631 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3632 i16immSExt8:$src2))]>, OpSize;
3633 def CMP32mi8 : Ii8<0x83, MRM7m,
3634 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3635 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3636 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3637 i32immSExt8:$src2))]>;
3638 def CMP32ri8 : Ii8<0x83, MRM7r,
3639 (outs), (ins GR32:$src1, i32i8imm:$src2),
3640 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3641 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
3642 } // Defs = [EFLAGS]
3645 // TODO: BTC, BTR, and BTS
3646 let Defs = [EFLAGS] in {
3647 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3648 "bt{w}\t{$src2, $src1|$src1, $src2}",
3649 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
3650 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3651 "bt{l}\t{$src2, $src1|$src1, $src2}",
3652 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
3654 // Unlike with the register+register form, the memory+register form of the
3655 // bt instruction does not ignore the high bits of the index. From ISel's
3656 // perspective, this is pretty bizarre. Make these instructions disassembly
3659 def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3660 "bt{w}\t{$src2, $src1|$src1, $src2}",
3661 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3662 // (implicit EFLAGS)]
3664 >, OpSize, TB, Requires<[FastBTMem]>;
3665 def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3666 "bt{l}\t{$src2, $src1|$src1, $src2}",
3667 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3668 // (implicit EFLAGS)]
3670 >, TB, Requires<[FastBTMem]>;
3672 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3673 "bt{w}\t{$src2, $src1|$src1, $src2}",
3674 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3676 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3677 "bt{l}\t{$src2, $src1|$src1, $src2}",
3678 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
3679 // Note that these instructions don't need FastBTMem because that
3680 // only applies when the other operand is in a register. When it's
3681 // an immediate, bt is still fast.
3682 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3683 "bt{w}\t{$src2, $src1|$src1, $src2}",
3684 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3686 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3687 "bt{l}\t{$src2, $src1|$src1, $src2}",
3688 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3691 def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3692 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3693 def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3694 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3695 def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3696 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3697 def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3698 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3699 def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3700 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3701 def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3702 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3703 def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3704 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3705 def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3706 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3708 def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3709 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3710 def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3711 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3712 def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3713 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3714 def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3715 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3716 def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3717 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3718 def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3719 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3720 def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3721 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3722 def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3723 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3725 def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3726 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3727 def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3728 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3729 def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3730 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3731 def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3732 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3733 def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3734 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3735 def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3736 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3737 def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3738 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3739 def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3740 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3741 } // Defs = [EFLAGS]
3743 // Sign/Zero extenders
3744 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3745 // of the register here. This has a smaller encoding and avoids a
3746 // partial-register update. Actual movsbw included for the disassembler.
3747 def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3748 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3749 def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3750 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3751 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3752 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
3753 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3754 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3755 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3756 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3757 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3758 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3759 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3760 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3761 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3762 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3763 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3764 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3765 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3766 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3768 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3769 // of the register here. This has a smaller encoding and avoids a
3770 // partial-register update. Actual movzbw included for the disassembler.
3771 def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3772 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3773 def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3774 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3775 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3776 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
3777 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3778 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3779 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3780 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3781 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3782 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3783 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3784 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3785 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3786 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3787 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3788 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3789 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3790 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3792 // These are the same as the regular MOVZX32rr8 and MOVZX32rm8
3793 // except that they use GR32_NOREX for the output operand register class
3794 // instead of GR32. This allows them to operate on h registers on x86-64.
3795 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3796 (outs GR32_NOREX:$dst), (ins GR8:$src),
3797 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3800 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3801 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3802 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3805 let neverHasSideEffects = 1 in {
3806 let Defs = [AX], Uses = [AL] in
3807 def CBW : I<0x98, RawFrm, (outs), (ins),
3808 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3809 let Defs = [EAX], Uses = [AX] in
3810 def CWDE : I<0x98, RawFrm, (outs), (ins),
3811 "{cwtl|cwde}", []>; // EAX = signext(AX)
3813 let Defs = [AX,DX], Uses = [AX] in
3814 def CWD : I<0x99, RawFrm, (outs), (ins),
3815 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3816 let Defs = [EAX,EDX], Uses = [EAX] in
3817 def CDQ : I<0x99, RawFrm, (outs), (ins),
3818 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3821 //===----------------------------------------------------------------------===//
3822 // Alias Instructions
3823 //===----------------------------------------------------------------------===//
3825 // Alias instructions that map movr0 to xor.
3826 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3827 // FIXME: Set encoding to pseudo.
3828 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3829 isCodeGenOnly = 1 in {
3830 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
3831 [(set GR8:$dst, 0)]>;
3833 // We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3834 // encoding and avoids a partial-register update sometimes, but doing so
3835 // at isel time interferes with rematerialization in the current register
3836 // allocator. For now, this is rewritten when the instruction is lowered
3838 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3840 [(set GR16:$dst, 0)]>, OpSize;
3842 // FIXME: Set encoding to pseudo.
3843 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
3844 [(set GR32:$dst, 0)]>;
3847 //===----------------------------------------------------------------------===//
3848 // Thread Local Storage Instructions
3851 // All calls clobber the non-callee saved registers. ESP is marked as
3852 // a use to prevent stack-pointer assignments that appear immediately
3853 // before calls from potentially appearing dead.
3854 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3855 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3856 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3857 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3859 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3860 "leal\t$sym, %eax; "
3861 "call\t___tls_get_addr@PLT",
3862 [(X86tlsaddr tls32addr:$sym)]>,
3863 Requires<[In32BitMode]>;
3865 // For i386, the address of the thunk is passed on the stack, on return the
3866 // address of the variable is in %eax. %ecx is trashed during the function
3867 // call. All other registers are preserved.
3868 let Defs = [EAX, ECX],
3870 usesCustomInserter = 1 in
3871 def TLSCall_32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
3873 [(X86TLSCall addr:$sym)]>,
3874 Requires<[In32BitMode]>;
3876 let AddedComplexity = 5, isCodeGenOnly = 1 in
3877 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3878 "movl\t%gs:$src, $dst",
3879 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3881 let AddedComplexity = 5, isCodeGenOnly = 1 in
3882 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3883 "movl\t%fs:$src, $dst",
3884 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3886 //===----------------------------------------------------------------------===//
3887 // EH Pseudo Instructions
3889 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3890 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3891 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3892 "ret\t#eh_return, addr: $addr",
3893 [(X86ehret GR32:$addr)]>;
3897 //===----------------------------------------------------------------------===//
3901 // Atomic swap. These are just normal xchg instructions. But since a memory
3902 // operand is referenced, the atomicity is ensured.
3903 let Constraints = "$val = $dst" in {
3904 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3905 (ins GR32:$val, i32mem:$ptr),
3906 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3907 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3908 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3909 (ins GR16:$val, i16mem:$ptr),
3910 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3911 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3913 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3914 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3915 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3917 def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3918 "xchg{l}\t{$val, $src|$src, $val}", []>;
3919 def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3920 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3921 def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3922 "xchg{b}\t{$val, $src|$src, $val}", []>;
3925 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3926 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3927 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3928 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3930 // Atomic compare and swap.
3931 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3932 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3934 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3935 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3937 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3938 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
3941 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3944 let Defs = [AX, EFLAGS], Uses = [AX] in {
3945 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3947 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3948 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3950 let Defs = [AL, EFLAGS], Uses = [AL] in {
3951 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3953 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3954 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3957 // Atomic exchange and add
3958 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3959 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
3961 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3962 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3964 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
3966 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3967 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3969 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3971 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3972 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3976 def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3977 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3978 def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3979 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3980 def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3981 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3983 let mayLoad = 1, mayStore = 1 in {
3984 def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3985 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3986 def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3987 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3988 def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3989 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3992 def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3993 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3994 def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3995 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3996 def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3997 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3999 let mayLoad = 1, mayStore = 1 in {
4000 def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
4001 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
4002 def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
4003 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4004 def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
4005 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
4008 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
4009 def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
4010 "cmpxchg8b\t$dst", []>, TB;
4012 // Optimized codegen when the non-memory output is not used.
4013 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
4014 let Defs = [EFLAGS], mayLoad = 1, mayStore = 1 in {
4015 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
4017 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4018 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4020 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4021 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4023 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4024 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
4026 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4027 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
4029 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4030 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
4032 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4033 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
4035 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4036 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4038 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4040 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
4042 "inc{b}\t$dst", []>, LOCK;
4043 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
4045 "inc{w}\t$dst", []>, OpSize, LOCK;
4046 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
4048 "inc{l}\t$dst", []>, LOCK;
4050 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
4052 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4053 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4055 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4056 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4058 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4059 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
4061 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4062 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
4064 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4065 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
4067 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4068 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
4070 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4071 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4073 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4075 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
4077 "dec{b}\t$dst", []>, LOCK;
4078 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
4080 "dec{w}\t$dst", []>, OpSize, LOCK;
4081 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
4083 "dec{l}\t$dst", []>, LOCK;
4086 // Atomic exchange, and, or, xor
4087 let Constraints = "$val = $dst", Defs = [EFLAGS],
4088 usesCustomInserter = 1 in {
4089 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4090 "#ATOMAND32 PSEUDO!",
4091 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
4092 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4093 "#ATOMOR32 PSEUDO!",
4094 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
4095 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4096 "#ATOMXOR32 PSEUDO!",
4097 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
4098 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4099 "#ATOMNAND32 PSEUDO!",
4100 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
4101 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
4102 "#ATOMMIN32 PSEUDO!",
4103 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
4104 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4105 "#ATOMMAX32 PSEUDO!",
4106 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
4107 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4108 "#ATOMUMIN32 PSEUDO!",
4109 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
4110 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4111 "#ATOMUMAX32 PSEUDO!",
4112 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
4114 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4115 "#ATOMAND16 PSEUDO!",
4116 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
4117 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4118 "#ATOMOR16 PSEUDO!",
4119 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
4120 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4121 "#ATOMXOR16 PSEUDO!",
4122 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
4123 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4124 "#ATOMNAND16 PSEUDO!",
4125 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
4126 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
4127 "#ATOMMIN16 PSEUDO!",
4128 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
4129 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4130 "#ATOMMAX16 PSEUDO!",
4131 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
4132 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4133 "#ATOMUMIN16 PSEUDO!",
4134 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
4135 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4136 "#ATOMUMAX16 PSEUDO!",
4137 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
4139 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4140 "#ATOMAND8 PSEUDO!",
4141 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
4142 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4144 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
4145 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4146 "#ATOMXOR8 PSEUDO!",
4147 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
4148 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4149 "#ATOMNAND8 PSEUDO!",
4150 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
4153 let Constraints = "$val1 = $dst1, $val2 = $dst2",
4154 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4155 Uses = [EAX, EBX, ECX, EDX],
4156 mayLoad = 1, mayStore = 1,
4157 usesCustomInserter = 1 in {
4158 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4159 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4160 "#ATOMAND6432 PSEUDO!", []>;
4161 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4162 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4163 "#ATOMOR6432 PSEUDO!", []>;
4164 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4165 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4166 "#ATOMXOR6432 PSEUDO!", []>;
4167 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4168 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4169 "#ATOMNAND6432 PSEUDO!", []>;
4170 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4171 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4172 "#ATOMADD6432 PSEUDO!", []>;
4173 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4174 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4175 "#ATOMSUB6432 PSEUDO!", []>;
4176 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4177 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4178 "#ATOMSWAP6432 PSEUDO!", []>;
4181 // Segmentation support instructions.
4183 def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4184 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4185 def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4186 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4188 // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4189 def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4190 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4191 def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4192 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4194 def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4195 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4196 def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4197 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4198 def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4199 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4200 def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4201 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4203 def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
4205 def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4206 "str{w}\t{$dst}", []>, TB;
4207 def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4208 "str{w}\t{$dst}", []>, TB;
4209 def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4210 "ltr{w}\t{$src}", []>, TB;
4211 def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4212 "ltr{w}\t{$src}", []>, TB;
4214 def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4215 "push{w}\t%fs", []>, OpSize, TB;
4216 def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4217 "push{l}\t%fs", []>, TB;
4218 def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4219 "push{w}\t%gs", []>, OpSize, TB;
4220 def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4221 "push{l}\t%gs", []>, TB;
4223 def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4224 "pop{w}\t%fs", []>, OpSize, TB;
4225 def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4226 "pop{l}\t%fs", []>, TB;
4227 def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4228 "pop{w}\t%gs", []>, OpSize, TB;
4229 def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4230 "pop{l}\t%gs", []>, TB;
4232 def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4233 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4234 def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4235 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4236 def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4237 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4238 def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4239 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4240 def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4241 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4242 def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4243 "les{l}\t{$src, $dst|$dst, $src}", []>;
4244 def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4245 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4246 def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4247 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4248 def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4249 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4250 def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4251 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4253 def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4254 "verr\t$seg", []>, TB;
4255 def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4256 "verr\t$seg", []>, TB;
4257 def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4258 "verw\t$seg", []>, TB;
4259 def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4260 "verw\t$seg", []>, TB;
4262 // Descriptor-table support instructions
4264 def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4265 "sgdt\t$dst", []>, TB;
4266 def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4267 "sidt\t$dst", []>, TB;
4268 def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4269 "sldt{w}\t$dst", []>, TB;
4270 def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4271 "sldt{w}\t$dst", []>, TB;
4272 def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4273 "lgdt\t$src", []>, TB;
4274 def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4275 "lidt\t$src", []>, TB;
4276 def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4277 "lldt{w}\t$src", []>, TB;
4278 def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4279 "lldt{w}\t$src", []>, TB;
4281 // Lock instruction prefix
4282 def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4284 // Repeat string operation instruction prefixes
4285 // These uses the DF flag in the EFLAGS register to inc or dec ECX
4286 let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4287 // Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4288 def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4289 // Repeat while not equal (used with CMPS and SCAS)
4290 def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4293 // Segment override instruction prefixes
4294 def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4295 def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4296 def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4297 def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4298 def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4299 def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4301 // String manipulation instructions
4303 def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4304 def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
4305 def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4307 def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4308 def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4309 def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4311 // CPU flow control instructions
4313 def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4314 def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4316 // FPU control instructions
4318 def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4320 // Flag instructions
4322 def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4323 def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4324 def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4325 def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4326 def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4327 def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4328 def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4330 def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4332 // Table lookup instructions
4334 def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4336 // Specialized register support
4338 def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4339 def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4340 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4342 def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4343 "smsw{w}\t$dst", []>, OpSize, TB;
4344 def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4345 "smsw{l}\t$dst", []>, TB;
4346 // For memory operands, there is only a 16-bit form
4347 def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4348 "smsw{w}\t$dst", []>, TB;
4350 def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4351 "lmsw{w}\t$src", []>, TB;
4352 def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4353 "lmsw{w}\t$src", []>, TB;
4355 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4357 // Cache instructions
4359 def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4360 def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4365 def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
4367 def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
4369 def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
4370 def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4371 "vmclear\t$vmcs", []>, OpSize, TB;
4373 def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
4375 def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
4376 def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4377 "vmptrld\t$vmcs", []>, TB;
4378 def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4379 "vmptrst\t$vmcs", []>, TB;
4380 def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4381 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4382 def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4383 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4384 def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4385 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4386 def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4387 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4388 def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4389 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4390 def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4391 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4392 def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4393 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4394 def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4395 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4397 def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
4398 def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4399 "vmxon\t{$vmxon}", []>, XS;
4401 //===----------------------------------------------------------------------===//
4402 // Non-Instruction Patterns
4403 //===----------------------------------------------------------------------===//
4405 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
4406 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4407 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
4408 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
4409 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4410 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
4411 def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
4413 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4414 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4415 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4416 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4417 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4418 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4419 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4420 (ADD32ri GR32:$src1, texternalsym:$src2)>;
4421 def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4422 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
4424 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4425 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4426 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4427 (MOV32mi addr:$dst, texternalsym:$src)>;
4428 def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4429 (MOV32mi addr:$dst, tblockaddress:$src)>;
4433 def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4434 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4435 Requires<[In32BitMode]>;
4437 // FIXME: This is disabled for 32-bit PIC mode because the global base
4438 // register which is part of the address mode may be assigned a
4439 // callee-saved register.
4440 def : Pat<(X86tcret (load addr:$dst), imm:$off),
4441 (TCRETURNmi addr:$dst, imm:$off)>,
4442 Requires<[In32BitMode, IsNotPIC]>;
4444 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4445 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4446 Requires<[In32BitMode]>;
4448 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4449 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4450 Requires<[In32BitMode]>;
4452 // Normal calls, with various flavors of addresses.
4453 def : Pat<(X86call (i32 tglobaladdr:$dst)),
4454 (CALLpcrel32 tglobaladdr:$dst)>;
4455 def : Pat<(X86call (i32 texternalsym:$dst)),
4456 (CALLpcrel32 texternalsym:$dst)>;
4457 def : Pat<(X86call (i32 imm:$dst)),
4458 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
4460 // X86 specific add which produces a flag.
4461 def : Pat<(addc GR32:$src1, GR32:$src2),
4462 (ADD32rr GR32:$src1, GR32:$src2)>;
4463 def : Pat<(addc GR32:$src1, (load addr:$src2)),
4464 (ADD32rm GR32:$src1, addr:$src2)>;
4465 def : Pat<(addc GR32:$src1, imm:$src2),
4466 (ADD32ri GR32:$src1, imm:$src2)>;
4467 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4468 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4470 def : Pat<(subc GR32:$src1, GR32:$src2),
4471 (SUB32rr GR32:$src1, GR32:$src2)>;
4472 def : Pat<(subc GR32:$src1, (load addr:$src2)),
4473 (SUB32rm GR32:$src1, addr:$src2)>;
4474 def : Pat<(subc GR32:$src1, imm:$src2),
4475 (SUB32ri GR32:$src1, imm:$src2)>;
4476 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4477 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4481 // TEST R,R is smaller than CMP R,0
4482 def : Pat<(X86cmp GR8:$src1, 0),
4483 (TEST8rr GR8:$src1, GR8:$src1)>;
4484 def : Pat<(X86cmp GR16:$src1, 0),
4485 (TEST16rr GR16:$src1, GR16:$src1)>;
4486 def : Pat<(X86cmp GR32:$src1, 0),
4487 (TEST32rr GR32:$src1, GR32:$src1)>;
4489 // Conditional moves with folded loads with operands swapped and conditions
4491 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4492 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4493 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4494 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4495 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4496 (CMOVB16rm GR16:$src2, addr:$src1)>;
4497 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4498 (CMOVB32rm GR32:$src2, addr:$src1)>;
4499 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4500 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4501 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4502 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4503 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4504 (CMOVE16rm GR16:$src2, addr:$src1)>;
4505 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4506 (CMOVE32rm GR32:$src2, addr:$src1)>;
4507 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4508 (CMOVA16rm GR16:$src2, addr:$src1)>;
4509 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4510 (CMOVA32rm GR32:$src2, addr:$src1)>;
4511 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4512 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4513 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4514 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4515 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4516 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4517 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4518 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4519 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4520 (CMOVL16rm GR16:$src2, addr:$src1)>;
4521 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4522 (CMOVL32rm GR32:$src2, addr:$src1)>;
4523 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4524 (CMOVG16rm GR16:$src2, addr:$src1)>;
4525 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4526 (CMOVG32rm GR32:$src2, addr:$src1)>;
4527 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4528 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4529 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4530 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4531 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4532 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4533 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4534 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4535 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4536 (CMOVP16rm GR16:$src2, addr:$src1)>;
4537 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4538 (CMOVP32rm GR32:$src2, addr:$src1)>;
4539 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4540 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4541 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4542 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4543 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4544 (CMOVS16rm GR16:$src2, addr:$src1)>;
4545 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4546 (CMOVS32rm GR32:$src2, addr:$src1)>;
4547 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4548 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4549 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4550 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4551 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4552 (CMOVO16rm GR16:$src2, addr:$src1)>;
4553 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4554 (CMOVO32rm GR32:$src2, addr:$src1)>;
4556 // zextload bool -> zextload byte
4557 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4558 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4559 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4561 // extload bool -> extload byte
4562 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4563 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4564 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4565 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
4566 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4567 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4569 // anyext. Define these to do an explicit zero-extend to
4570 // avoid partial-register updates.
4571 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4572 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4574 // Except for i16 -> i32 since isel expect i16 ops to be promoted to i32.
4575 def : Pat<(i32 (anyext GR16:$src)),
4576 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, sub_16bit)>;
4579 //===----------------------------------------------------------------------===//
4581 //===----------------------------------------------------------------------===//
4583 // Odd encoding trick: -128 fits into an 8-bit immediate field while
4584 // +128 doesn't, so in this special case use a sub instead of an add.
4585 def : Pat<(add GR16:$src1, 128),
4586 (SUB16ri8 GR16:$src1, -128)>;
4587 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4588 (SUB16mi8 addr:$dst, -128)>;
4589 def : Pat<(add GR32:$src1, 128),
4590 (SUB32ri8 GR32:$src1, -128)>;
4591 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4592 (SUB32mi8 addr:$dst, -128)>;
4594 // r & (2^16-1) ==> movz
4595 def : Pat<(and GR32:$src1, 0xffff),
4596 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, sub_16bit))>;
4597 // r & (2^8-1) ==> movz
4598 def : Pat<(and GR32:$src1, 0xff),
4599 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4602 Requires<[In32BitMode]>;
4603 // r & (2^8-1) ==> movz
4604 def : Pat<(and GR16:$src1, 0xff),
4605 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4608 Requires<[In32BitMode]>;
4610 // sext_inreg patterns
4611 def : Pat<(sext_inreg GR32:$src, i16),
4612 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, sub_16bit))>;
4613 def : Pat<(sext_inreg GR32:$src, i8),
4614 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4617 Requires<[In32BitMode]>;
4618 def : Pat<(sext_inreg GR16:$src, i8),
4619 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4622 Requires<[In32BitMode]>;
4625 def : Pat<(i16 (trunc GR32:$src)),
4626 (EXTRACT_SUBREG GR32:$src, sub_16bit)>;
4627 def : Pat<(i8 (trunc GR32:$src)),
4628 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4630 Requires<[In32BitMode]>;
4631 def : Pat<(i8 (trunc GR16:$src)),
4632 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4634 Requires<[In32BitMode]>;
4636 // h-register tricks
4637 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
4638 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4640 Requires<[In32BitMode]>;
4641 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
4642 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4644 Requires<[In32BitMode]>;
4645 def : Pat<(srl GR16:$src, (i8 8)),
4648 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4651 Requires<[In32BitMode]>;
4652 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
4653 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4656 Requires<[In32BitMode]>;
4657 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
4658 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4661 Requires<[In32BitMode]>;
4662 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
4663 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4666 Requires<[In32BitMode]>;
4667 def : Pat<(srl (and_su GR32:$src, 0xff00), (i8 8)),
4668 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4671 Requires<[In32BitMode]>;
4673 // (shl x, 1) ==> (add x, x)
4674 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4675 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4676 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4678 // (shl x (and y, 31)) ==> (shl x, y)
4679 def : Pat<(shl GR8:$src1, (and CL, 31)),
4680 (SHL8rCL GR8:$src1)>;
4681 def : Pat<(shl GR16:$src1, (and CL, 31)),
4682 (SHL16rCL GR16:$src1)>;
4683 def : Pat<(shl GR32:$src1, (and CL, 31)),
4684 (SHL32rCL GR32:$src1)>;
4685 def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4686 (SHL8mCL addr:$dst)>;
4687 def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4688 (SHL16mCL addr:$dst)>;
4689 def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4690 (SHL32mCL addr:$dst)>;
4692 def : Pat<(srl GR8:$src1, (and CL, 31)),
4693 (SHR8rCL GR8:$src1)>;
4694 def : Pat<(srl GR16:$src1, (and CL, 31)),
4695 (SHR16rCL GR16:$src1)>;
4696 def : Pat<(srl GR32:$src1, (and CL, 31)),
4697 (SHR32rCL GR32:$src1)>;
4698 def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4699 (SHR8mCL addr:$dst)>;
4700 def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4701 (SHR16mCL addr:$dst)>;
4702 def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4703 (SHR32mCL addr:$dst)>;
4705 def : Pat<(sra GR8:$src1, (and CL, 31)),
4706 (SAR8rCL GR8:$src1)>;
4707 def : Pat<(sra GR16:$src1, (and CL, 31)),
4708 (SAR16rCL GR16:$src1)>;
4709 def : Pat<(sra GR32:$src1, (and CL, 31)),
4710 (SAR32rCL GR32:$src1)>;
4711 def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4712 (SAR8mCL addr:$dst)>;
4713 def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4714 (SAR16mCL addr:$dst)>;
4715 def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4716 (SAR32mCL addr:$dst)>;
4718 // (anyext (setcc_carry)) -> (setcc_carry)
4719 def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4721 def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4723 def : Pat<(i32 (anyext (i16 (X86setcc_c X86_COND_B, EFLAGS)))),
4726 // (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
4727 let AddedComplexity = 5 in { // Try this before the selecting to OR
4728 def : Pat<(or_is_add GR16:$src1, imm:$src2),
4729 (ADD16ri GR16:$src1, imm:$src2)>;
4730 def : Pat<(or_is_add GR32:$src1, imm:$src2),
4731 (ADD32ri GR32:$src1, imm:$src2)>;
4732 def : Pat<(or_is_add GR16:$src1, i16immSExt8:$src2),
4733 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4734 def : Pat<(or_is_add GR32:$src1, i32immSExt8:$src2),
4735 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4736 def : Pat<(or_is_add GR16:$src1, GR16:$src2),
4737 (ADD16rr GR16:$src1, GR16:$src2)>;
4738 def : Pat<(or_is_add GR32:$src1, GR32:$src2),
4739 (ADD32rr GR32:$src1, GR32:$src2)>;
4740 } // AddedComplexity
4742 //===----------------------------------------------------------------------===//
4743 // EFLAGS-defining Patterns
4744 //===----------------------------------------------------------------------===//
4747 def : Pat<(add GR8 :$src1, GR8 :$src2), (ADD8rr GR8 :$src1, GR8 :$src2)>;
4748 def : Pat<(add GR16:$src1, GR16:$src2), (ADD16rr GR16:$src1, GR16:$src2)>;
4749 def : Pat<(add GR32:$src1, GR32:$src2), (ADD32rr GR32:$src1, GR32:$src2)>;
4752 def : Pat<(add GR8:$src1, (loadi8 addr:$src2)),
4753 (ADD8rm GR8:$src1, addr:$src2)>;
4754 def : Pat<(add GR16:$src1, (loadi16 addr:$src2)),
4755 (ADD16rm GR16:$src1, addr:$src2)>;
4756 def : Pat<(add GR32:$src1, (loadi32 addr:$src2)),
4757 (ADD32rm GR32:$src1, addr:$src2)>;
4760 def : Pat<(add GR8 :$src1, imm:$src2), (ADD8ri GR8:$src1 , imm:$src2)>;
4761 def : Pat<(add GR16:$src1, imm:$src2), (ADD16ri GR16:$src1, imm:$src2)>;
4762 def : Pat<(add GR32:$src1, imm:$src2), (ADD32ri GR32:$src1, imm:$src2)>;
4763 def : Pat<(add GR16:$src1, i16immSExt8:$src2),
4764 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4765 def : Pat<(add GR32:$src1, i32immSExt8:$src2),
4766 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4769 def : Pat<(sub GR8 :$src1, GR8 :$src2), (SUB8rr GR8 :$src1, GR8 :$src2)>;
4770 def : Pat<(sub GR16:$src1, GR16:$src2), (SUB16rr GR16:$src1, GR16:$src2)>;
4771 def : Pat<(sub GR32:$src1, GR32:$src2), (SUB32rr GR32:$src1, GR32:$src2)>;
4774 def : Pat<(sub GR8:$src1, (loadi8 addr:$src2)),
4775 (SUB8rm GR8:$src1, addr:$src2)>;
4776 def : Pat<(sub GR16:$src1, (loadi16 addr:$src2)),
4777 (SUB16rm GR16:$src1, addr:$src2)>;
4778 def : Pat<(sub GR32:$src1, (loadi32 addr:$src2)),
4779 (SUB32rm GR32:$src1, addr:$src2)>;
4782 def : Pat<(sub GR8:$src1, imm:$src2),
4783 (SUB8ri GR8:$src1, imm:$src2)>;
4784 def : Pat<(sub GR16:$src1, imm:$src2),
4785 (SUB16ri GR16:$src1, imm:$src2)>;
4786 def : Pat<(sub GR32:$src1, imm:$src2),
4787 (SUB32ri GR32:$src1, imm:$src2)>;
4788 def : Pat<(sub GR16:$src1, i16immSExt8:$src2),
4789 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4790 def : Pat<(sub GR32:$src1, i32immSExt8:$src2),
4791 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4794 def : Pat<(mul GR16:$src1, GR16:$src2),
4795 (IMUL16rr GR16:$src1, GR16:$src2)>;
4796 def : Pat<(mul GR32:$src1, GR32:$src2),
4797 (IMUL32rr GR32:$src1, GR32:$src2)>;
4800 def : Pat<(mul GR16:$src1, (loadi16 addr:$src2)),
4801 (IMUL16rm GR16:$src1, addr:$src2)>;
4802 def : Pat<(mul GR32:$src1, (loadi32 addr:$src2)),
4803 (IMUL32rm GR32:$src1, addr:$src2)>;
4806 def : Pat<(mul GR16:$src1, imm:$src2),
4807 (IMUL16rri GR16:$src1, imm:$src2)>;
4808 def : Pat<(mul GR32:$src1, imm:$src2),
4809 (IMUL32rri GR32:$src1, imm:$src2)>;
4810 def : Pat<(mul GR16:$src1, i16immSExt8:$src2),
4811 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4812 def : Pat<(mul GR32:$src1, i32immSExt8:$src2),
4813 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4815 // reg = mul mem, imm
4816 def : Pat<(mul (loadi16 addr:$src1), imm:$src2),
4817 (IMUL16rmi addr:$src1, imm:$src2)>;
4818 def : Pat<(mul (loadi32 addr:$src1), imm:$src2),
4819 (IMUL32rmi addr:$src1, imm:$src2)>;
4820 def : Pat<(mul (loadi16 addr:$src1), i16immSExt8:$src2),
4821 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4822 def : Pat<(mul (loadi32 addr:$src1), i32immSExt8:$src2),
4823 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4825 // Optimize multiply by 2 with EFLAGS result.
4826 let AddedComplexity = 2 in {
4827 def : Pat<(X86smul_flag GR16:$src1, 2), (ADD16rr GR16:$src1, GR16:$src1)>;
4828 def : Pat<(X86smul_flag GR32:$src1, 2), (ADD32rr GR32:$src1, GR32:$src1)>;
4831 // Patterns for nodes that do not produce flags, for instructions that do.
4834 def : Pat<(add GR8:$src1 , 1), (INC8r GR8:$src1)>;
4835 def : Pat<(add GR16:$src1, 1), (INC16r GR16:$src1)>, Requires<[In32BitMode]>;
4836 def : Pat<(add GR32:$src1, 1), (INC32r GR32:$src1)>, Requires<[In32BitMode]>;
4839 def : Pat<(add GR8:$src1 , -1), (DEC8r GR8:$src1)>;
4840 def : Pat<(add GR16:$src1, -1), (DEC16r GR16:$src1)>, Requires<[In32BitMode]>;
4841 def : Pat<(add GR32:$src1, -1), (DEC32r GR32:$src1)>, Requires<[In32BitMode]>;
4844 def : Pat<(or GR8 :$src1, GR8 :$src2), (OR8rr GR8 :$src1, GR8 :$src2)>;
4845 def : Pat<(or GR16:$src1, GR16:$src2), (OR16rr GR16:$src1, GR16:$src2)>;
4846 def : Pat<(or GR32:$src1, GR32:$src2), (OR32rr GR32:$src1, GR32:$src2)>;
4849 def : Pat<(or GR8:$src1, (loadi8 addr:$src2)),
4850 (OR8rm GR8:$src1, addr:$src2)>;
4851 def : Pat<(or GR16:$src1, (loadi16 addr:$src2)),
4852 (OR16rm GR16:$src1, addr:$src2)>;
4853 def : Pat<(or GR32:$src1, (loadi32 addr:$src2)),
4854 (OR32rm GR32:$src1, addr:$src2)>;
4857 def : Pat<(or GR8:$src1 , imm:$src2), (OR8ri GR8 :$src1, imm:$src2)>;
4858 def : Pat<(or GR16:$src1, imm:$src2), (OR16ri GR16:$src1, imm:$src2)>;
4859 def : Pat<(or GR32:$src1, imm:$src2), (OR32ri GR32:$src1, imm:$src2)>;
4860 def : Pat<(or GR16:$src1, i16immSExt8:$src2),
4861 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4862 def : Pat<(or GR32:$src1, i32immSExt8:$src2),
4863 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4866 def : Pat<(xor GR8 :$src1, GR8 :$src2), (XOR8rr GR8 :$src1, GR8 :$src2)>;
4867 def : Pat<(xor GR16:$src1, GR16:$src2), (XOR16rr GR16:$src1, GR16:$src2)>;
4868 def : Pat<(xor GR32:$src1, GR32:$src2), (XOR32rr GR32:$src1, GR32:$src2)>;
4871 def : Pat<(xor GR8:$src1, (loadi8 addr:$src2)),
4872 (XOR8rm GR8:$src1, addr:$src2)>;
4873 def : Pat<(xor GR16:$src1, (loadi16 addr:$src2)),
4874 (XOR16rm GR16:$src1, addr:$src2)>;
4875 def : Pat<(xor GR32:$src1, (loadi32 addr:$src2)),
4876 (XOR32rm GR32:$src1, addr:$src2)>;
4879 def : Pat<(xor GR8:$src1, imm:$src2),
4880 (XOR8ri GR8:$src1, imm:$src2)>;
4881 def : Pat<(xor GR16:$src1, imm:$src2),
4882 (XOR16ri GR16:$src1, imm:$src2)>;
4883 def : Pat<(xor GR32:$src1, imm:$src2),
4884 (XOR32ri GR32:$src1, imm:$src2)>;
4885 def : Pat<(xor GR16:$src1, i16immSExt8:$src2),
4886 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4887 def : Pat<(xor GR32:$src1, i32immSExt8:$src2),
4888 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4891 def : Pat<(and GR8 :$src1, GR8 :$src2), (AND8rr GR8 :$src1, GR8 :$src2)>;
4892 def : Pat<(and GR16:$src1, GR16:$src2), (AND16rr GR16:$src1, GR16:$src2)>;
4893 def : Pat<(and GR32:$src1, GR32:$src2), (AND32rr GR32:$src1, GR32:$src2)>;
4896 def : Pat<(and GR8:$src1, (loadi8 addr:$src2)),
4897 (AND8rm GR8:$src1, addr:$src2)>;
4898 def : Pat<(and GR16:$src1, (loadi16 addr:$src2)),
4899 (AND16rm GR16:$src1, addr:$src2)>;
4900 def : Pat<(and GR32:$src1, (loadi32 addr:$src2)),
4901 (AND32rm GR32:$src1, addr:$src2)>;
4904 def : Pat<(and GR8:$src1, imm:$src2),
4905 (AND8ri GR8:$src1, imm:$src2)>;
4906 def : Pat<(and GR16:$src1, imm:$src2),
4907 (AND16ri GR16:$src1, imm:$src2)>;
4908 def : Pat<(and GR32:$src1, imm:$src2),
4909 (AND32ri GR32:$src1, imm:$src2)>;
4910 def : Pat<(and GR16:$src1, i16immSExt8:$src2),
4911 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
4912 def : Pat<(and GR32:$src1, i32immSExt8:$src2),
4913 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4915 //===----------------------------------------------------------------------===//
4916 // Floating Point Stack Support
4917 //===----------------------------------------------------------------------===//
4919 include "X86InstrFPStack.td"
4921 //===----------------------------------------------------------------------===//
4923 //===----------------------------------------------------------------------===//
4925 include "X86Instr64bit.td"
4927 //===----------------------------------------------------------------------===//
4928 // SIMD support (SSE, MMX and AVX)
4929 //===----------------------------------------------------------------------===//
4931 include "X86InstrFragmentsSIMD.td"
4933 //===----------------------------------------------------------------------===//
4934 // XMM Floating point support (requires SSE / SSE2)
4935 //===----------------------------------------------------------------------===//
4937 include "X86InstrSSE.td"
4939 //===----------------------------------------------------------------------===//
4940 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4941 //===----------------------------------------------------------------------===//
4943 include "X86InstrMMX.td"