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 SDT_X86MEMBARRIER : SDTypeProfile<0, 0, []>;
84 def SDT_X86MEMBARRIERNoSSE : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
86 def X86MemBarrier : SDNode<"X86ISD::MEMBARRIER", SDT_X86MEMBARRIER,
88 def X86MemBarrierNoSSE : SDNode<"X86ISD::MEMBARRIER", SDT_X86MEMBARRIERNoSSE,
90 def X86MFence : SDNode<"X86ISD::MFENCE", SDT_X86MEMBARRIER,
92 def X86SFence : SDNode<"X86ISD::SFENCE", SDT_X86MEMBARRIER,
94 def X86LFence : SDNode<"X86ISD::LFENCE", SDT_X86MEMBARRIER,
98 def X86bsf : SDNode<"X86ISD::BSF", SDTUnaryArithWithFlags>;
99 def X86bsr : SDNode<"X86ISD::BSR", SDTUnaryArithWithFlags>;
100 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
101 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
103 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
104 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
106 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
107 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
109 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
110 def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
112 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
113 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
115 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
116 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
118 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
119 [SDNPHasChain, SDNPMayStore,
120 SDNPMayLoad, SDNPMemOperand]>;
121 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
122 [SDNPHasChain, SDNPMayStore,
123 SDNPMayLoad, SDNPMemOperand]>;
124 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
125 [SDNPHasChain, SDNPMayStore,
126 SDNPMayLoad, SDNPMemOperand]>;
127 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
128 [SDNPHasChain, SDNPMayStore,
129 SDNPMayLoad, SDNPMemOperand]>;
130 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
131 [SDNPHasChain, SDNPMayStore,
132 SDNPMayLoad, SDNPMemOperand]>;
133 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
134 [SDNPHasChain, SDNPMayStore,
135 SDNPMayLoad, SDNPMemOperand]>;
136 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
137 [SDNPHasChain, SDNPMayStore,
138 SDNPMayLoad, SDNPMemOperand]>;
139 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
140 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
142 def X86vastart_save_xmm_regs :
143 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
144 SDT_X86VASTART_SAVE_XMM_REGS,
145 [SDNPHasChain, SDNPVariadic]>;
147 def X86callseq_start :
148 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
149 [SDNPHasChain, SDNPOutFlag]>;
151 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
152 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
154 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
155 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag,
158 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
159 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
160 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
161 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
164 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
165 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
167 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
168 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
170 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
171 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
172 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
173 SDT_X86SegmentBaseAddress, []>;
175 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
178 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
179 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
181 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
183 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
184 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
186 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
189 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
190 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
191 def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
193 def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
195 def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
198 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
200 def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
201 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
203 def X86TLSCall : SDNode<"X86ISD::TLSCALL", SDT_X86TLSCALL,
206 //===----------------------------------------------------------------------===//
207 // X86 Operand Definitions.
210 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
211 // the index operand of an address, to conform to x86 encoding restrictions.
212 def ptr_rc_nosp : PointerLikeRegClass<1>;
214 // *mem - Operand definitions for the funky X86 addressing mode operands.
216 def X86MemAsmOperand : AsmOperandClass {
218 let SuperClasses = [];
220 def X86AbsMemAsmOperand : AsmOperandClass {
222 let SuperClasses = [X86MemAsmOperand];
224 class X86MemOperand<string printMethod> : Operand<iPTR> {
225 let PrintMethod = printMethod;
226 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
227 let ParserMatchClass = X86MemAsmOperand;
230 def opaque32mem : X86MemOperand<"printopaquemem">;
231 def opaque48mem : X86MemOperand<"printopaquemem">;
232 def opaque80mem : X86MemOperand<"printopaquemem">;
233 def opaque512mem : X86MemOperand<"printopaquemem">;
235 def i8mem : X86MemOperand<"printi8mem">;
236 def i16mem : X86MemOperand<"printi16mem">;
237 def i32mem : X86MemOperand<"printi32mem">;
238 def i64mem : X86MemOperand<"printi64mem">;
239 def i128mem : X86MemOperand<"printi128mem">;
240 def i256mem : X86MemOperand<"printi256mem">;
241 def f32mem : X86MemOperand<"printf32mem">;
242 def f64mem : X86MemOperand<"printf64mem">;
243 def f80mem : X86MemOperand<"printf80mem">;
244 def f128mem : X86MemOperand<"printf128mem">;
245 def f256mem : X86MemOperand<"printf256mem">;
247 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
248 // plain GR64, so that it doesn't potentially require a REX prefix.
249 def i8mem_NOREX : Operand<i64> {
250 let PrintMethod = "printi8mem";
251 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
252 let ParserMatchClass = X86MemAsmOperand;
255 // Special i32mem for addresses of load folding tail calls. These are not
256 // allowed to use callee-saved registers since they must be scheduled
257 // after callee-saved register are popped.
258 def i32mem_TC : Operand<i32> {
259 let PrintMethod = "printi32mem";
260 let MIOperandInfo = (ops GR32_TC, i8imm, GR32_TC, i32imm, i8imm);
261 let ParserMatchClass = X86MemAsmOperand;
265 let ParserMatchClass = X86AbsMemAsmOperand,
266 PrintMethod = "print_pcrel_imm" in {
267 def i32imm_pcrel : Operand<i32>;
268 def i16imm_pcrel : Operand<i16>;
270 def offset8 : Operand<i64>;
271 def offset16 : Operand<i64>;
272 def offset32 : Operand<i64>;
273 def offset64 : Operand<i64>;
275 // Branch targets have OtherVT type and print as pc-relative values.
276 def brtarget : Operand<OtherVT>;
277 def brtarget8 : Operand<OtherVT>;
281 def SSECC : Operand<i8> {
282 let PrintMethod = "printSSECC";
285 class ImmSExtAsmOperandClass : AsmOperandClass {
286 let SuperClasses = [ImmAsmOperand];
287 let RenderMethod = "addImmOperands";
290 // Sign-extended immediate classes. We don't need to define the full lattice
291 // here because there is no instruction with an ambiguity between ImmSExti64i32
294 // The strange ranges come from the fact that the assembler always works with
295 // 64-bit immediates, but for a 16-bit target value we want to accept both "-1"
296 // (which will be a -1ULL), and "0xFF" (-1 in 16-bits).
299 // [0xFFFFFFFF80000000, 0xFFFFFFFFFFFFFFFF]
300 def ImmSExti64i32AsmOperand : ImmSExtAsmOperandClass {
301 let Name = "ImmSExti64i32";
304 // [0, 0x0000007F] | [0x000000000000FF80, 0x000000000000FFFF] |
305 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
306 def ImmSExti16i8AsmOperand : ImmSExtAsmOperandClass {
307 let Name = "ImmSExti16i8";
308 let SuperClasses = [ImmSExti64i32AsmOperand];
311 // [0, 0x0000007F] | [0x00000000FFFFFF80, 0x00000000FFFFFFFF] |
312 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
313 def ImmSExti32i8AsmOperand : ImmSExtAsmOperandClass {
314 let Name = "ImmSExti32i8";
318 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
319 def ImmSExti64i8AsmOperand : ImmSExtAsmOperandClass {
320 let Name = "ImmSExti64i8";
321 let SuperClasses = [ImmSExti16i8AsmOperand, ImmSExti32i8AsmOperand,
322 ImmSExti64i32AsmOperand];
325 // A couple of more descriptive operand definitions.
326 // 16-bits but only 8 bits are significant.
327 def i16i8imm : Operand<i16> {
328 let ParserMatchClass = ImmSExti16i8AsmOperand;
330 // 32-bits but only 8 bits are significant.
331 def i32i8imm : Operand<i32> {
332 let ParserMatchClass = ImmSExti32i8AsmOperand;
335 //===----------------------------------------------------------------------===//
336 // X86 Complex Pattern Definitions.
339 // Define X86 specific addressing mode.
340 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
341 def lea32addr : ComplexPattern<i32, 5, "SelectLEAAddr",
342 [add, sub, mul, X86mul_imm, shl, or, frameindex],
344 def tls32addr : ComplexPattern<i32, 5, "SelectTLSADDRAddr",
345 [tglobaltlsaddr], []>;
347 //===----------------------------------------------------------------------===//
348 // X86 Instruction Predicate Definitions.
349 def HasCMov : Predicate<"Subtarget->hasCMov()">;
350 def NoCMov : Predicate<"!Subtarget->hasCMov()">;
352 // FIXME: temporary hack to let codegen assert or generate poor code in case
353 // no AVX version of the desired intructions is present, this is better for
354 // incremental dev (without fallbacks it's easier to spot what's missing)
355 def HasMMX : Predicate<"Subtarget->hasMMX() && !Subtarget->hasAVX()">;
356 def HasSSE1 : Predicate<"Subtarget->hasSSE1() && !Subtarget->hasAVX()">;
357 def HasSSE2 : Predicate<"Subtarget->hasSSE2() && !Subtarget->hasAVX()">;
358 def HasSSE3 : Predicate<"Subtarget->hasSSE3() && !Subtarget->hasAVX()">;
359 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3() && !Subtarget->hasAVX()">;
360 def HasSSE41 : Predicate<"Subtarget->hasSSE41() && !Subtarget->hasAVX()">;
361 def HasSSE42 : Predicate<"Subtarget->hasSSE42() && !Subtarget->hasAVX()">;
362 def HasSSE4A : Predicate<"Subtarget->hasSSE4A() && !Subtarget->hasAVX()">;
364 def HasAVX : Predicate<"Subtarget->hasAVX()">;
365 def HasCLMUL : Predicate<"Subtarget->hasCLMUL()">;
366 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
367 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
368 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
369 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
370 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
371 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
372 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
373 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
374 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
375 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
376 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
377 "TM.getCodeModel() != CodeModel::Kernel">;
378 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
379 "TM.getCodeModel() == CodeModel::Kernel">;
380 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
381 def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
382 def OptForSize : Predicate<"OptForSize">;
383 def OptForSpeed : Predicate<"!OptForSize">;
384 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
385 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
386 def HasAES : Predicate<"Subtarget->hasAES()">;
388 //===----------------------------------------------------------------------===//
389 // X86 Instruction Format Definitions.
392 include "X86InstrFormats.td"
394 //===----------------------------------------------------------------------===//
395 // Pattern fragments...
398 // X86 specific condition code. These correspond to CondCode in
399 // X86InstrInfo.h. They must be kept in synch.
400 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
401 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
402 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
403 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
404 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
405 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
406 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
407 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
408 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
409 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
410 def X86_COND_NO : PatLeaf<(i8 10)>;
411 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
412 def X86_COND_NS : PatLeaf<(i8 12)>;
413 def X86_COND_O : PatLeaf<(i8 13)>;
414 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
415 def X86_COND_S : PatLeaf<(i8 15)>;
417 def immSext8 : PatLeaf<(imm), [{ return immSext8(N); }]>;
419 def i16immSExt8 : PatLeaf<(i16 immSext8)>;
420 def i32immSExt8 : PatLeaf<(i32 immSext8)>;
422 /// Load patterns: these constraint the match to the right address space.
423 def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
424 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
425 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
426 if (PT->getAddressSpace() > 255)
431 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
432 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
433 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
434 return PT->getAddressSpace() == 256;
438 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
439 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
440 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
441 return PT->getAddressSpace() == 257;
446 // Helper fragments for loads.
447 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
448 // known to be 32-bit aligned or better. Ditto for i8 to i16.
449 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
450 LoadSDNode *LD = cast<LoadSDNode>(N);
451 if (const Value *Src = LD->getSrcValue())
452 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
453 if (PT->getAddressSpace() > 255)
455 ISD::LoadExtType ExtType = LD->getExtensionType();
456 if (ExtType == ISD::NON_EXTLOAD)
458 if (ExtType == ISD::EXTLOAD)
459 return LD->getAlignment() >= 2 && !LD->isVolatile();
463 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
464 LoadSDNode *LD = cast<LoadSDNode>(N);
465 if (const Value *Src = LD->getSrcValue())
466 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
467 if (PT->getAddressSpace() > 255)
469 ISD::LoadExtType ExtType = LD->getExtensionType();
470 if (ExtType == ISD::EXTLOAD)
471 return LD->getAlignment() >= 2 && !LD->isVolatile();
475 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
476 LoadSDNode *LD = cast<LoadSDNode>(N);
477 if (const Value *Src = LD->getSrcValue())
478 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
479 if (PT->getAddressSpace() > 255)
481 ISD::LoadExtType ExtType = LD->getExtensionType();
482 if (ExtType == ISD::NON_EXTLOAD)
484 if (ExtType == ISD::EXTLOAD)
485 return LD->getAlignment() >= 4 && !LD->isVolatile();
489 def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
490 def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
491 def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
492 def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
493 def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
495 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
496 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
497 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
499 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
500 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
501 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
502 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
503 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
504 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
506 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
507 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
508 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
509 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
510 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
511 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
514 // An 'and' node with a single use.
515 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
516 return N->hasOneUse();
518 // An 'srl' node with a single use.
519 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
520 return N->hasOneUse();
522 // An 'trunc' node with a single use.
523 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
524 return N->hasOneUse();
527 // Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
528 def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
529 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
530 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
532 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
533 APInt Mask = APInt::getAllOnesValue(BitWidth);
534 APInt KnownZero0, KnownOne0;
535 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
536 APInt KnownZero1, KnownOne1;
537 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
538 return (~KnownZero0 & ~KnownZero1) == 0;
541 //===----------------------------------------------------------------------===//
542 // Instruction list...
545 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
546 // a stack adjustment and the codegen must know that they may modify the stack
547 // pointer before prolog-epilog rewriting occurs.
548 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
549 // sub / add which can clobber EFLAGS.
550 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
551 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
553 [(X86callseq_start timm:$amt)]>,
554 Requires<[In32BitMode]>;
555 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
557 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
558 Requires<[In32BitMode]>;
561 // x86-64 va_start lowering magic.
562 let usesCustomInserter = 1 in {
563 def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
566 i64imm:$regsavefi, i64imm:$offset,
568 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
569 [(X86vastart_save_xmm_regs GR8:$al,
573 // Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls
574 // to _alloca is needed to probe the stack when allocating more than 4k bytes in
575 // one go. Touching the stack at 4K increments is necessary to ensure that the
576 // guard pages used by the OS virtual memory manager are allocated in correct
578 // The main point of having separate instruction are extra unmodelled effects
579 // (compared to ordinary calls) like stack pointer change.
581 let Defs = [EAX, ESP, EFLAGS], Uses = [ESP] in
582 def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
583 "# dynamic stack allocation",
588 let neverHasSideEffects = 1 in {
589 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
590 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
591 "nop{w}\t$zero", []>, TB, OpSize;
592 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
593 "nop{l}\t$zero", []>, TB;
597 let Uses = [EFLAGS] in {
598 def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>;
600 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3",
601 [(int_x86_int (i8 3))]>;
602 def INT : Ii8<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap",
603 [(int_x86_int imm:$trap)]>;
604 def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
605 def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
607 // PIC base construction. This expands to code that looks like this:
610 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
611 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
614 //===----------------------------------------------------------------------===//
615 // Control Flow Instructions.
618 // Return instructions.
619 let isTerminator = 1, isReturn = 1, isBarrier = 1,
620 hasCtrlDep = 1, FPForm = SpecialFP in {
621 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
624 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
626 [(X86retflag timm:$amt)]>;
627 def LRET : I <0xCB, RawFrm, (outs), (ins),
629 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
633 // Unconditional branches.
634 let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
635 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
636 "jmp\t$dst", [(br bb:$dst)]>;
637 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
641 // Conditional Branches.
642 let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
643 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
644 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
645 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
646 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
650 defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
651 defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
652 defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
653 defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
654 defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
655 defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
656 defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
657 defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
658 defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
659 defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
660 defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
661 defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
662 defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
663 defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
664 defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
665 defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
667 // FIXME: What about the CX/RCX versions of this instruction?
668 let Uses = [ECX], isBranch = 1, isTerminator = 1 in
669 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
674 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
675 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
676 [(brind GR32:$dst)]>, Requires<[In32BitMode]>;
677 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
678 [(brind (loadi32 addr:$dst))]>, Requires<[In32BitMode]>;
680 def FARJMP16i : Iseg16<0xEA, RawFrmImm16, (outs),
681 (ins i16imm:$off, i16imm:$seg),
682 "ljmp{w}\t{$seg, $off|$off, $seg}", []>, OpSize;
683 def FARJMP32i : Iseg32<0xEA, RawFrmImm16, (outs),
684 (ins i32imm:$off, i16imm:$seg),
685 "ljmp{l}\t{$seg, $off|$off, $seg}", []>;
687 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
688 "ljmp{w}\t{*}$dst", []>, OpSize;
689 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
690 "ljmp{l}\t{*}$dst", []>;
696 def LOOP : Ii8PCRel<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
697 def LOOPE : Ii8PCRel<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
698 def LOOPNE : Ii8PCRel<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;
700 //===----------------------------------------------------------------------===//
701 // Call Instructions...
704 // All calls clobber the non-callee saved registers. ESP is marked as
705 // a use to prevent stack-pointer assignments that appear immediately
706 // before calls from potentially appearing dead. Uses for argument
707 // registers are added manually.
708 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
709 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
710 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
711 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
713 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
714 (outs), (ins i32imm_pcrel:$dst,variable_ops),
716 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
717 "call\t{*}$dst", [(X86call GR32:$dst)]>;
718 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
719 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
721 def FARCALL16i : Iseg16<0x9A, RawFrmImm16, (outs),
722 (ins i16imm:$off, i16imm:$seg),
723 "lcall{w}\t{$seg, $off|$off, $seg}", []>, OpSize;
724 def FARCALL32i : Iseg32<0x9A, RawFrmImm16, (outs),
725 (ins i32imm:$off, i16imm:$seg),
726 "lcall{l}\t{$seg, $off|$off, $seg}", []>;
728 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
729 "lcall{w}\t{*}$dst", []>, OpSize;
730 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
731 "lcall{l}\t{*}$dst", []>;
733 // callw for 16 bit code for the assembler.
734 let isAsmParserOnly = 1 in
735 def CALLpcrel16 : Ii16PCRel<0xE8, RawFrm,
736 (outs), (ins i16imm_pcrel:$dst, variable_ops),
737 "callw\t$dst", []>, OpSize;
740 // Constructing a stack frame.
742 def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
743 "enter\t$len, $lvl", []>;
747 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1,
749 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
750 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
751 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
752 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
754 def TCRETURNdi : I<0, Pseudo, (outs),
755 (ins i32imm_pcrel:$dst, i32imm:$offset, variable_ops),
756 "#TC_RETURN $dst $offset", []>;
757 def TCRETURNri : I<0, Pseudo, (outs),
758 (ins GR32_TC:$dst, i32imm:$offset, variable_ops),
759 "#TC_RETURN $dst $offset", []>;
761 def TCRETURNmi : I<0, Pseudo, (outs),
762 (ins i32mem_TC:$dst, i32imm:$offset, variable_ops),
763 "#TC_RETURN $dst $offset", []>;
765 // FIXME: The should be pseudo instructions that are lowered when going to
767 def TAILJMPd : Ii32PCRel<0xE9, RawFrm, (outs),
768 (ins i32imm_pcrel:$dst, variable_ops),
769 "jmp\t$dst # TAILCALL",
771 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32_TC:$dst, variable_ops),
772 "", []>; // FIXME: Remove encoding when JIT is dead.
774 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
775 "jmp{l}\t{*}$dst # TAILCALL", []>;
778 //===----------------------------------------------------------------------===//
779 // Miscellaneous Instructions...
781 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
782 def LEAVE : I<0xC9, RawFrm,
783 (outs), (ins), "leave", []>, Requires<[In32BitMode]>;
785 def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
786 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
788 def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
789 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
790 def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
791 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
793 def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
794 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
796 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
798 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
800 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
801 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
803 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
805 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
806 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
809 let mayStore = 1 in {
810 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
812 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
813 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
815 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
817 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
818 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
822 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
823 def PUSHi8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
824 "push{l}\t$imm", []>;
825 def PUSHi16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
826 "push{w}\t$imm", []>, OpSize;
827 def PUSHi32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
828 "push{l}\t$imm", []>;
831 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
832 def POPF16 : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
833 def POPF32 : I<0x9D, RawFrm, (outs), (ins), "popf{l|d}", []>,
834 Requires<[In32BitMode]>;
836 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
837 def PUSHF16 : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
838 def PUSHF32 : I<0x9C, RawFrm, (outs), (ins), "pushf{l|d}", []>,
839 Requires<[In32BitMode]>;
842 let Defs = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], Uses = [ESP],
843 mayLoad=1, neverHasSideEffects=1 in {
844 def POPA32 : I<0x61, RawFrm, (outs), (ins), "popa{l}", []>,
845 Requires<[In32BitMode]>;
847 let Defs = [ESP], Uses = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP],
848 mayStore=1, neverHasSideEffects=1 in {
849 def PUSHA32 : I<0x60, RawFrm, (outs), (ins), "pusha{l}", []>,
850 Requires<[In32BitMode]>;
853 let Uses = [EFLAGS], Constraints = "$src = $dst" in // GR32 = bswap GR32
854 def BSWAP32r : I<0xC8, AddRegFrm,
855 (outs GR32:$dst), (ins GR32:$src),
857 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
860 // Bit scan instructions.
861 let Defs = [EFLAGS] in {
862 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
863 "bsf{w}\t{$src, $dst|$dst, $src}",
864 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB, OpSize;
865 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
866 "bsf{w}\t{$src, $dst|$dst, $src}",
867 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB,
869 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
870 "bsf{l}\t{$src, $dst|$dst, $src}",
871 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
872 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
873 "bsf{l}\t{$src, $dst|$dst, $src}",
874 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
876 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
877 "bsr{w}\t{$src, $dst|$dst, $src}",
878 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB, OpSize;
879 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
880 "bsr{w}\t{$src, $dst|$dst, $src}",
881 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB,
883 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
884 "bsr{l}\t{$src, $dst|$dst, $src}",
885 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
886 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
887 "bsr{l}\t{$src, $dst|$dst, $src}",
888 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
891 let neverHasSideEffects = 1 in
892 def LEA16r : I<0x8D, MRMSrcMem,
893 (outs GR16:$dst), (ins i32mem:$src),
894 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
895 let isReMaterializable = 1 in
896 def LEA32r : I<0x8D, MRMSrcMem,
897 (outs GR32:$dst), (ins i32mem:$src),
898 "lea{l}\t{$src|$dst}, {$dst|$src}",
899 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
901 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
902 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
903 [(X86rep_movs i8)]>, REP;
904 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
905 [(X86rep_movs i16)]>, REP, OpSize;
906 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
907 [(X86rep_movs i32)]>, REP;
910 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
911 let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
912 def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
913 def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
914 def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
917 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
918 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
919 [(X86rep_stos i8)]>, REP;
920 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
921 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
922 [(X86rep_stos i16)]>, REP, OpSize;
923 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
924 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
925 [(X86rep_stos i32)]>, REP;
927 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
928 let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
929 def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
930 let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
931 def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
932 let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
933 def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
935 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
936 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
937 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
939 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
940 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
941 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
943 let Defs = [RAX, RDX] in
944 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
947 let Defs = [RAX, RCX, RDX] in
948 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
950 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in {
951 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
954 def SYSCALL : I<0x05, RawFrm,
955 (outs), (ins), "syscall", []>, TB;
956 def SYSRET : I<0x07, RawFrm,
957 (outs), (ins), "sysret", []>, TB;
958 def SYSENTER : I<0x34, RawFrm,
959 (outs), (ins), "sysenter", []>, TB;
960 def SYSEXIT : I<0x35, RawFrm,
961 (outs), (ins), "sysexit", []>, TB, Requires<[In32BitMode]>;
963 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
966 //===----------------------------------------------------------------------===//
967 // Input/Output Instructions...
969 let Defs = [AL], Uses = [DX] in
970 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
971 "in{b}\t{%dx, %al|%AL, %DX}", []>;
972 let Defs = [AX], Uses = [DX] in
973 def IN16rr : I<0xED, RawFrm, (outs), (ins),
974 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
975 let Defs = [EAX], Uses = [DX] in
976 def IN32rr : I<0xED, RawFrm, (outs), (ins),
977 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
980 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i8imm:$port),
981 "in{b}\t{$port, %al|%AL, $port}", []>;
983 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i8imm:$port),
984 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
986 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i8imm:$port),
987 "in{l}\t{$port, %eax|%EAX, $port}", []>;
989 let Uses = [DX, AL] in
990 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
991 "out{b}\t{%al, %dx|%DX, %AL}", []>;
992 let Uses = [DX, AX] in
993 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
994 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
995 let Uses = [DX, EAX] in
996 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
997 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
1000 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i8imm:$port),
1001 "out{b}\t{%al, $port|$port, %AL}", []>;
1003 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i8imm:$port),
1004 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
1006 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i8imm:$port),
1007 "out{l}\t{%eax, $port|$port, %EAX}", []>;
1009 def IN8 : I<0x6C, RawFrm, (outs), (ins),
1011 def IN16 : I<0x6D, RawFrm, (outs), (ins),
1012 "ins{w}", []>, OpSize;
1013 def IN32 : I<0x6D, RawFrm, (outs), (ins),
1016 //===----------------------------------------------------------------------===//
1017 // Move Instructions...
1019 let neverHasSideEffects = 1 in {
1020 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
1021 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1022 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
1023 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1024 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
1025 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1027 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
1028 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
1029 "mov{b}\t{$src, $dst|$dst, $src}",
1030 [(set GR8:$dst, imm:$src)]>;
1031 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
1032 "mov{w}\t{$src, $dst|$dst, $src}",
1033 [(set GR16:$dst, imm:$src)]>, OpSize;
1034 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
1035 "mov{l}\t{$src, $dst|$dst, $src}",
1036 [(set GR32:$dst, imm:$src)]>;
1039 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
1040 "mov{b}\t{$src, $dst|$dst, $src}",
1041 [(store (i8 imm:$src), addr:$dst)]>;
1042 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
1043 "mov{w}\t{$src, $dst|$dst, $src}",
1044 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
1045 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
1046 "mov{l}\t{$src, $dst|$dst, $src}",
1047 [(store (i32 imm:$src), addr:$dst)]>;
1049 /// moffs8, moffs16 and moffs32 versions of moves. The immediate is a
1050 /// 32-bit offset from the PC. These are only valid in x86-32 mode.
1051 def MOV8o8a : Ii32 <0xA0, RawFrm, (outs), (ins offset8:$src),
1052 "mov{b}\t{$src, %al|%al, $src}", []>,
1053 Requires<[In32BitMode]>;
1054 def MOV16o16a : Ii32 <0xA1, RawFrm, (outs), (ins offset16:$src),
1055 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize,
1056 Requires<[In32BitMode]>;
1057 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
1058 "mov{l}\t{$src, %eax|%eax, $src}", []>,
1059 Requires<[In32BitMode]>;
1060 def MOV8ao8 : Ii32 <0xA2, RawFrm, (outs offset8:$dst), (ins),
1061 "mov{b}\t{%al, $dst|$dst, %al}", []>,
1062 Requires<[In32BitMode]>;
1063 def MOV16ao16 : Ii32 <0xA3, RawFrm, (outs offset16:$dst), (ins),
1064 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize,
1065 Requires<[In32BitMode]>;
1066 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
1067 "mov{l}\t{%eax, $dst|$dst, %eax}", []>,
1068 Requires<[In32BitMode]>;
1070 // Moves to and from segment registers
1071 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1072 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1073 def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
1074 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1075 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1076 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1077 def MOV32ms : I<0x8C, MRMDestMem, (outs i32mem:$dst), (ins SEGMENT_REG:$src),
1078 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1079 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1080 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1081 def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
1082 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1083 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1084 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1085 def MOV32sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i32mem:$src),
1086 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1088 let isCodeGenOnly = 1 in {
1089 def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1090 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1091 def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1092 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1093 def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1094 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1097 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1098 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
1099 "mov{b}\t{$src, $dst|$dst, $src}",
1100 [(set GR8:$dst, (loadi8 addr:$src))]>;
1101 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
1102 "mov{w}\t{$src, $dst|$dst, $src}",
1103 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
1104 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
1105 "mov{l}\t{$src, $dst|$dst, $src}",
1106 [(set GR32:$dst, (loadi32 addr:$src))]>;
1109 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
1110 "mov{b}\t{$src, $dst|$dst, $src}",
1111 [(store GR8:$src, addr:$dst)]>;
1112 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1113 "mov{w}\t{$src, $dst|$dst, $src}",
1114 [(store GR16:$src, addr:$dst)]>, OpSize;
1115 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1116 "mov{l}\t{$src, $dst|$dst, $src}",
1117 [(store GR32:$src, addr:$dst)]>;
1119 /// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
1120 let isCodeGenOnly = 1 in {
1121 let neverHasSideEffects = 1 in
1122 def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1123 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1126 canFoldAsLoad = 1, isReMaterializable = 1 in
1127 def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1128 "mov{l}\t{$src, $dst|$dst, $src}",
1132 def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1133 "mov{l}\t{$src, $dst|$dst, $src}",
1137 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1138 // that they can be used for copying and storing h registers, which can't be
1139 // encoded when a REX prefix is present.
1140 let isCodeGenOnly = 1 in {
1141 let neverHasSideEffects = 1 in
1142 def MOV8rr_NOREX : I<0x88, MRMDestReg,
1143 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
1144 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1146 def MOV8mr_NOREX : I<0x88, MRMDestMem,
1147 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1148 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1150 canFoldAsLoad = 1, isReMaterializable = 1 in
1151 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1152 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1153 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1156 // Moves to and from debug registers
1157 def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1158 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1159 def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1160 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1162 // Moves to and from control registers
1163 def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
1164 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1165 def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
1166 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1168 //===----------------------------------------------------------------------===//
1169 // Fixed-Register Multiplication and Division Instructions...
1172 // Extra precision multiplication
1174 // AL is really implied by AX, but the registers in Defs must match the
1175 // SDNode results (i8, i32).
1176 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1177 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
1178 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1179 // This probably ought to be moved to a def : Pat<> if the
1180 // syntax can be accepted.
1181 [(set AL, (mul AL, GR8:$src)),
1182 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1184 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1185 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1187 []>, OpSize; // AX,DX = AX*GR16
1189 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1190 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1192 []>; // EAX,EDX = EAX*GR32
1194 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1195 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1197 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1198 // This probably ought to be moved to a def : Pat<> if the
1199 // syntax can be accepted.
1200 [(set AL, (mul AL, (loadi8 addr:$src))),
1201 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1203 let mayLoad = 1, neverHasSideEffects = 1 in {
1204 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1205 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1207 []>, OpSize; // AX,DX = AX*[mem16]
1209 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1210 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1212 []>; // EAX,EDX = EAX*[mem32]
1215 let neverHasSideEffects = 1 in {
1216 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1217 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1219 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1220 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
1221 OpSize; // AX,DX = AX*GR16
1222 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1223 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1224 // EAX,EDX = EAX*GR32
1225 let mayLoad = 1 in {
1226 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1227 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1228 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
1229 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1230 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1231 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1232 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1233 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1234 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
1236 } // neverHasSideEffects
1238 // unsigned division/remainder
1239 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1240 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1241 "div{b}\t$src", []>;
1242 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1243 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1244 "div{w}\t$src", []>, OpSize;
1245 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1246 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1247 "div{l}\t$src", []>;
1248 let mayLoad = 1 in {
1249 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1250 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1251 "div{b}\t$src", []>;
1252 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1253 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1254 "div{w}\t$src", []>, OpSize;
1255 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1256 // EDX:EAX/[mem32] = EAX,EDX
1257 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
1258 "div{l}\t$src", []>;
1261 // Signed division/remainder.
1262 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1263 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1264 "idiv{b}\t$src", []>;
1265 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1266 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1267 "idiv{w}\t$src", []>, OpSize;
1268 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1269 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1270 "idiv{l}\t$src", []>;
1271 let mayLoad = 1, mayLoad = 1 in {
1272 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1273 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1274 "idiv{b}\t$src", []>;
1275 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1276 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1277 "idiv{w}\t$src", []>, OpSize;
1278 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1279 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1280 // EDX:EAX/[mem32] = EAX,EDX
1281 "idiv{l}\t$src", []>;
1284 //===----------------------------------------------------------------------===//
1285 // Two address Instructions.
1287 let Constraints = "$src1 = $dst" in {
1289 // Conditional moves
1290 let Uses = [EFLAGS] in {
1292 let Predicates = [HasCMov] in {
1293 let isCommutable = 1 in {
1294 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1295 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1296 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1297 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1298 X86_COND_B, EFLAGS))]>,
1300 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1301 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1302 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1303 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1304 X86_COND_B, EFLAGS))]>,
1306 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1307 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1308 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1309 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1310 X86_COND_AE, EFLAGS))]>,
1312 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1313 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1314 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1315 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1316 X86_COND_AE, EFLAGS))]>,
1318 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1319 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1320 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1321 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1322 X86_COND_E, EFLAGS))]>,
1324 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1325 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1326 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1327 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1328 X86_COND_E, EFLAGS))]>,
1330 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1331 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1332 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1333 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1334 X86_COND_NE, EFLAGS))]>,
1336 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1337 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1338 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1339 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1340 X86_COND_NE, EFLAGS))]>,
1342 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1343 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1344 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1345 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1346 X86_COND_BE, EFLAGS))]>,
1348 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1349 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1350 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1351 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1352 X86_COND_BE, EFLAGS))]>,
1354 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1355 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1356 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1357 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1358 X86_COND_A, EFLAGS))]>,
1360 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1361 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1362 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1363 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1364 X86_COND_A, EFLAGS))]>,
1366 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1367 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1368 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1369 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1370 X86_COND_L, EFLAGS))]>,
1372 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1373 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1374 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1375 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1376 X86_COND_L, EFLAGS))]>,
1378 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1379 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1380 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1381 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1382 X86_COND_GE, EFLAGS))]>,
1384 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1385 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1386 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1387 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1388 X86_COND_GE, EFLAGS))]>,
1390 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1391 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1392 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1393 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1394 X86_COND_LE, EFLAGS))]>,
1396 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1397 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1398 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1399 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1400 X86_COND_LE, EFLAGS))]>,
1402 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1403 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1404 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1405 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1406 X86_COND_G, EFLAGS))]>,
1408 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1409 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1410 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1411 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1412 X86_COND_G, EFLAGS))]>,
1414 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1415 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1416 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1417 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1418 X86_COND_S, EFLAGS))]>,
1420 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1421 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1422 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1423 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1424 X86_COND_S, EFLAGS))]>,
1426 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1427 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1428 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1429 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1430 X86_COND_NS, EFLAGS))]>,
1432 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1433 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1434 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1435 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1436 X86_COND_NS, EFLAGS))]>,
1438 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1439 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1440 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1441 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1442 X86_COND_P, EFLAGS))]>,
1444 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1445 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1446 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1447 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1448 X86_COND_P, EFLAGS))]>,
1450 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1451 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1452 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1453 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1454 X86_COND_NP, EFLAGS))]>,
1456 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1457 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1458 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1459 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1460 X86_COND_NP, EFLAGS))]>,
1462 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1463 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1464 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1465 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1466 X86_COND_O, EFLAGS))]>,
1468 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1469 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1470 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1471 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1472 X86_COND_O, EFLAGS))]>,
1474 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1475 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1476 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1477 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1478 X86_COND_NO, EFLAGS))]>,
1480 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1481 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1482 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1483 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1484 X86_COND_NO, EFLAGS))]>,
1486 } // isCommutable = 1
1488 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1489 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1490 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1491 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1492 X86_COND_B, EFLAGS))]>,
1494 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1495 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1496 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1497 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1498 X86_COND_B, EFLAGS))]>,
1500 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1501 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1502 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1503 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1504 X86_COND_AE, EFLAGS))]>,
1506 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1507 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1508 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1509 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1510 X86_COND_AE, EFLAGS))]>,
1512 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1513 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1514 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1515 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1516 X86_COND_E, EFLAGS))]>,
1518 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1519 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1520 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1521 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1522 X86_COND_E, EFLAGS))]>,
1524 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1525 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1526 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1527 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1528 X86_COND_NE, EFLAGS))]>,
1530 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1531 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1532 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1533 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1534 X86_COND_NE, EFLAGS))]>,
1536 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1537 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1538 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1539 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1540 X86_COND_BE, EFLAGS))]>,
1542 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1543 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1544 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1545 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1546 X86_COND_BE, EFLAGS))]>,
1548 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1549 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1550 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1551 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1552 X86_COND_A, EFLAGS))]>,
1554 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1555 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1556 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1557 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1558 X86_COND_A, EFLAGS))]>,
1560 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1561 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1562 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1563 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1564 X86_COND_L, EFLAGS))]>,
1566 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1567 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1568 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1569 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1570 X86_COND_L, EFLAGS))]>,
1572 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1573 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1574 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1575 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1576 X86_COND_GE, EFLAGS))]>,
1578 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1579 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1580 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1581 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1582 X86_COND_GE, EFLAGS))]>,
1584 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1585 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1586 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1587 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1588 X86_COND_LE, EFLAGS))]>,
1590 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1591 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1592 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1593 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1594 X86_COND_LE, EFLAGS))]>,
1596 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1597 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1598 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1599 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1600 X86_COND_G, EFLAGS))]>,
1602 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1603 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1604 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1605 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1606 X86_COND_G, EFLAGS))]>,
1608 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1609 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1610 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1611 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1612 X86_COND_S, EFLAGS))]>,
1614 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1615 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1616 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1617 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1618 X86_COND_S, EFLAGS))]>,
1620 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1621 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1622 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1623 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1624 X86_COND_NS, EFLAGS))]>,
1626 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1627 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1628 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1629 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1630 X86_COND_NS, EFLAGS))]>,
1632 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1633 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1634 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1635 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1636 X86_COND_P, EFLAGS))]>,
1638 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1639 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1640 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1641 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1642 X86_COND_P, EFLAGS))]>,
1644 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1645 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1646 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1647 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1648 X86_COND_NP, EFLAGS))]>,
1650 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1651 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1652 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1653 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1654 X86_COND_NP, EFLAGS))]>,
1656 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1657 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1658 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1659 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1660 X86_COND_O, EFLAGS))]>,
1662 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1663 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1664 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1665 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1666 X86_COND_O, EFLAGS))]>,
1668 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1669 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1670 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1671 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1672 X86_COND_NO, EFLAGS))]>,
1674 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1675 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1676 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1677 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1678 X86_COND_NO, EFLAGS))]>,
1680 } // Predicates = [HasCMov]
1682 // X86 doesn't have 8-bit conditional moves. Use a customInserter to
1683 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1684 // however that requires promoting the operands, and can induce additional
1685 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1686 // clobber EFLAGS, because if one of the operands is zero, the expansion
1687 // could involve an xor.
1688 let usesCustomInserter = 1, Constraints = "", Defs = [EFLAGS] in {
1689 def CMOV_GR8 : I<0, Pseudo,
1690 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1691 "#CMOV_GR8 PSEUDO!",
1692 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1693 imm:$cond, EFLAGS))]>;
1695 let Predicates = [NoCMov] in {
1696 def CMOV_GR32 : I<0, Pseudo,
1697 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1698 "#CMOV_GR32* PSEUDO!",
1700 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1701 def CMOV_GR16 : I<0, Pseudo,
1702 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1703 "#CMOV_GR16* PSEUDO!",
1705 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1706 def CMOV_RFP32 : I<0, Pseudo,
1708 (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
1709 "#CMOV_RFP32 PSEUDO!",
1711 (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
1713 def CMOV_RFP64 : I<0, Pseudo,
1715 (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
1716 "#CMOV_RFP64 PSEUDO!",
1718 (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
1720 def CMOV_RFP80 : I<0, Pseudo,
1722 (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
1723 "#CMOV_RFP80 PSEUDO!",
1725 (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
1727 } // Predicates = [NoCMov]
1728 } // UsesCustomInserter = 1, Constraints = "", Defs = [EFLAGS]
1729 } // Uses = [EFLAGS]
1732 // unary instructions
1733 let CodeSize = 2 in {
1734 let Defs = [EFLAGS] in {
1735 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src1),
1737 [(set GR8:$dst, (ineg GR8:$src1)),
1738 (implicit EFLAGS)]>;
1739 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
1741 [(set GR16:$dst, (ineg GR16:$src1)),
1742 (implicit EFLAGS)]>, OpSize;
1743 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
1745 [(set GR32:$dst, (ineg GR32:$src1)),
1746 (implicit EFLAGS)]>;
1748 let Constraints = "" in {
1749 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst),
1751 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1752 (implicit EFLAGS)]>;
1753 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst),
1755 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1756 (implicit EFLAGS)]>, OpSize;
1757 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst),
1759 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1760 (implicit EFLAGS)]>;
1761 } // Constraints = ""
1762 } // Defs = [EFLAGS]
1764 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1765 let AddedComplexity = 15 in {
1766 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src1),
1768 [(set GR8:$dst, (not GR8:$src1))]>;
1769 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
1771 [(set GR16:$dst, (not GR16:$src1))]>, OpSize;
1772 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
1774 [(set GR32:$dst, (not GR32:$src1))]>;
1776 let Constraints = "" in {
1777 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst),
1779 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1780 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst),
1782 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1783 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst),
1785 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1786 } // Constraints = ""
1789 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1790 let Defs = [EFLAGS] in {
1792 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1794 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src1))]>;
1796 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1797 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1799 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src1))]>,
1800 OpSize, Requires<[In32BitMode]>;
1801 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1803 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src1))]>,
1804 Requires<[In32BitMode]>;
1806 let Constraints = "", CodeSize = 2 in {
1807 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1808 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1809 (implicit EFLAGS)]>;
1810 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1811 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1812 (implicit EFLAGS)]>,
1813 OpSize, Requires<[In32BitMode]>;
1814 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1815 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1816 (implicit EFLAGS)]>,
1817 Requires<[In32BitMode]>;
1818 } // Constraints = "", CodeSize = 2
1821 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1823 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src1))]>;
1824 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1825 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1827 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src1))]>,
1828 OpSize, Requires<[In32BitMode]>;
1829 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1831 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src1))]>,
1832 Requires<[In32BitMode]>;
1835 let Constraints = "", CodeSize = 2 in {
1836 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1837 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1838 (implicit EFLAGS)]>;
1839 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1840 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1841 (implicit EFLAGS)]>,
1842 OpSize, Requires<[In32BitMode]>;
1843 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1844 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1845 (implicit EFLAGS)]>,
1846 Requires<[In32BitMode]>;
1847 } // Constraints = "", CodeSize = 2
1848 } // Defs = [EFLAGS]
1850 // Logical operators...
1851 let Defs = [EFLAGS] in {
1852 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1853 def AND8rr : I<0x20, MRMDestReg,
1854 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1855 "and{b}\t{$src2, $dst|$dst, $src2}",
1856 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1857 def AND16rr : I<0x21, MRMDestReg,
1858 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1859 "and{w}\t{$src2, $dst|$dst, $src2}",
1860 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1861 GR16:$src2))]>, OpSize;
1862 def AND32rr : I<0x21, MRMDestReg,
1863 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1864 "and{l}\t{$src2, $dst|$dst, $src2}",
1865 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1869 // AND instructions with the destination register in REG and the source register
1870 // in R/M. Included for the disassembler.
1871 let isCodeGenOnly = 1 in {
1872 def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1873 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1874 def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1875 (ins GR16:$src1, GR16:$src2),
1876 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1877 def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1878 (ins GR32:$src1, GR32:$src2),
1879 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1882 def AND8rm : I<0x22, MRMSrcMem,
1883 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1884 "and{b}\t{$src2, $dst|$dst, $src2}",
1885 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1886 (loadi8 addr:$src2)))]>;
1887 def AND16rm : I<0x23, MRMSrcMem,
1888 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1889 "and{w}\t{$src2, $dst|$dst, $src2}",
1890 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1891 (loadi16 addr:$src2)))]>,
1893 def AND32rm : I<0x23, MRMSrcMem,
1894 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1895 "and{l}\t{$src2, $dst|$dst, $src2}",
1896 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1897 (loadi32 addr:$src2)))]>;
1899 def AND8ri : Ii8<0x80, MRM4r,
1900 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1901 "and{b}\t{$src2, $dst|$dst, $src2}",
1902 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1904 def AND16ri : Ii16<0x81, MRM4r,
1905 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1906 "and{w}\t{$src2, $dst|$dst, $src2}",
1907 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1908 imm:$src2))]>, OpSize;
1909 def AND32ri : Ii32<0x81, MRM4r,
1910 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1911 "and{l}\t{$src2, $dst|$dst, $src2}",
1912 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1914 def AND16ri8 : Ii8<0x83, MRM4r,
1915 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1916 "and{w}\t{$src2, $dst|$dst, $src2}",
1917 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1918 i16immSExt8:$src2))]>,
1920 def AND32ri8 : Ii8<0x83, MRM4r,
1921 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1922 "and{l}\t{$src2, $dst|$dst, $src2}",
1923 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1924 i32immSExt8:$src2))]>;
1926 let Constraints = "" in {
1927 def AND8mr : I<0x20, MRMDestMem,
1928 (outs), (ins i8mem :$dst, GR8 :$src),
1929 "and{b}\t{$src, $dst|$dst, $src}",
1930 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1931 (implicit EFLAGS)]>;
1932 def AND16mr : I<0x21, MRMDestMem,
1933 (outs), (ins i16mem:$dst, GR16:$src),
1934 "and{w}\t{$src, $dst|$dst, $src}",
1935 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1936 (implicit EFLAGS)]>,
1938 def AND32mr : I<0x21, MRMDestMem,
1939 (outs), (ins i32mem:$dst, GR32:$src),
1940 "and{l}\t{$src, $dst|$dst, $src}",
1941 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1942 (implicit EFLAGS)]>;
1943 def AND8mi : Ii8<0x80, MRM4m,
1944 (outs), (ins i8mem :$dst, i8imm :$src),
1945 "and{b}\t{$src, $dst|$dst, $src}",
1946 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1947 (implicit EFLAGS)]>;
1948 def AND16mi : Ii16<0x81, MRM4m,
1949 (outs), (ins i16mem:$dst, i16imm:$src),
1950 "and{w}\t{$src, $dst|$dst, $src}",
1951 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1952 (implicit EFLAGS)]>,
1954 def AND32mi : Ii32<0x81, MRM4m,
1955 (outs), (ins i32mem:$dst, i32imm:$src),
1956 "and{l}\t{$src, $dst|$dst, $src}",
1957 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1958 (implicit EFLAGS)]>;
1959 def AND16mi8 : Ii8<0x83, MRM4m,
1960 (outs), (ins i16mem:$dst, i16i8imm :$src),
1961 "and{w}\t{$src, $dst|$dst, $src}",
1962 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1963 (implicit EFLAGS)]>,
1965 def AND32mi8 : Ii8<0x83, MRM4m,
1966 (outs), (ins i32mem:$dst, i32i8imm :$src),
1967 "and{l}\t{$src, $dst|$dst, $src}",
1968 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1969 (implicit EFLAGS)]>;
1971 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1972 "and{b}\t{$src, %al|%al, $src}", []>;
1973 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1974 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1975 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1976 "and{l}\t{$src, %eax|%eax, $src}", []>;
1978 } // Constraints = ""
1981 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1982 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1983 (ins GR8 :$src1, GR8 :$src2),
1984 "or{b}\t{$src2, $dst|$dst, $src2}",
1985 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
1986 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1987 (ins GR16:$src1, GR16:$src2),
1988 "or{w}\t{$src2, $dst|$dst, $src2}",
1989 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1991 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1992 (ins GR32:$src1, GR32:$src2),
1993 "or{l}\t{$src2, $dst|$dst, $src2}",
1994 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
1997 // OR instructions with the destination register in REG and the source register
1998 // in R/M. Included for the disassembler.
1999 let isCodeGenOnly = 1 in {
2000 def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2001 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
2002 def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
2003 (ins GR16:$src1, GR16:$src2),
2004 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2005 def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
2006 (ins GR32:$src1, GR32:$src2),
2007 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
2010 def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
2011 (ins GR8 :$src1, i8mem :$src2),
2012 "or{b}\t{$src2, $dst|$dst, $src2}",
2013 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
2014 (load addr:$src2)))]>;
2015 def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
2016 (ins GR16:$src1, i16mem:$src2),
2017 "or{w}\t{$src2, $dst|$dst, $src2}",
2018 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2019 (load addr:$src2)))]>,
2021 def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
2022 (ins GR32:$src1, i32mem:$src2),
2023 "or{l}\t{$src2, $dst|$dst, $src2}",
2024 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2025 (load addr:$src2)))]>;
2027 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
2028 (ins GR8 :$src1, i8imm:$src2),
2029 "or{b}\t{$src2, $dst|$dst, $src2}",
2030 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
2031 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
2032 (ins GR16:$src1, i16imm:$src2),
2033 "or{w}\t{$src2, $dst|$dst, $src2}",
2034 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2035 imm:$src2))]>, OpSize;
2036 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
2037 (ins GR32:$src1, i32imm:$src2),
2038 "or{l}\t{$src2, $dst|$dst, $src2}",
2039 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2042 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
2043 (ins GR16:$src1, i16i8imm:$src2),
2044 "or{w}\t{$src2, $dst|$dst, $src2}",
2045 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2046 i16immSExt8:$src2))]>, OpSize;
2047 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
2048 (ins GR32:$src1, i32i8imm:$src2),
2049 "or{l}\t{$src2, $dst|$dst, $src2}",
2050 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2051 i32immSExt8:$src2))]>;
2052 let Constraints = "" in {
2053 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
2054 "or{b}\t{$src, $dst|$dst, $src}",
2055 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
2056 (implicit EFLAGS)]>;
2057 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
2058 "or{w}\t{$src, $dst|$dst, $src}",
2059 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
2060 (implicit EFLAGS)]>, OpSize;
2061 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2062 "or{l}\t{$src, $dst|$dst, $src}",
2063 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
2064 (implicit EFLAGS)]>;
2065 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2066 "or{b}\t{$src, $dst|$dst, $src}",
2067 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
2068 (implicit EFLAGS)]>;
2069 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
2070 "or{w}\t{$src, $dst|$dst, $src}",
2071 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
2072 (implicit EFLAGS)]>,
2074 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
2075 "or{l}\t{$src, $dst|$dst, $src}",
2076 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
2077 (implicit EFLAGS)]>;
2078 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
2079 "or{w}\t{$src, $dst|$dst, $src}",
2080 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
2081 (implicit EFLAGS)]>,
2083 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
2084 "or{l}\t{$src, $dst|$dst, $src}",
2085 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
2086 (implicit EFLAGS)]>;
2088 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
2089 "or{b}\t{$src, %al|%al, $src}", []>;
2090 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
2091 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2092 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
2093 "or{l}\t{$src, %eax|%eax, $src}", []>;
2094 } // Constraints = ""
2097 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
2098 def XOR8rr : I<0x30, MRMDestReg,
2099 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
2100 "xor{b}\t{$src2, $dst|$dst, $src2}",
2101 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2103 def XOR16rr : I<0x31, MRMDestReg,
2104 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2105 "xor{w}\t{$src2, $dst|$dst, $src2}",
2106 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2107 GR16:$src2))]>, OpSize;
2108 def XOR32rr : I<0x31, MRMDestReg,
2109 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2110 "xor{l}\t{$src2, $dst|$dst, $src2}",
2111 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2113 } // isCommutable = 1
2115 // XOR instructions with the destination register in REG and the source register
2116 // in R/M. Included for the disassembler.
2117 let isCodeGenOnly = 1 in {
2118 def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2119 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2120 def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2121 (ins GR16:$src1, GR16:$src2),
2122 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2123 def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2124 (ins GR32:$src1, GR32:$src2),
2125 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
2128 def XOR8rm : I<0x32, MRMSrcMem,
2129 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
2130 "xor{b}\t{$src2, $dst|$dst, $src2}",
2131 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2132 (load addr:$src2)))]>;
2133 def XOR16rm : I<0x33, MRMSrcMem,
2134 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
2135 "xor{w}\t{$src2, $dst|$dst, $src2}",
2136 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2137 (load addr:$src2)))]>,
2139 def XOR32rm : I<0x33, MRMSrcMem,
2140 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2141 "xor{l}\t{$src2, $dst|$dst, $src2}",
2142 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2143 (load addr:$src2)))]>;
2145 def XOR8ri : Ii8<0x80, MRM6r,
2146 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2147 "xor{b}\t{$src2, $dst|$dst, $src2}",
2148 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
2149 def XOR16ri : Ii16<0x81, MRM6r,
2150 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2151 "xor{w}\t{$src2, $dst|$dst, $src2}",
2152 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2153 imm:$src2))]>, OpSize;
2154 def XOR32ri : Ii32<0x81, MRM6r,
2155 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2156 "xor{l}\t{$src2, $dst|$dst, $src2}",
2157 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2159 def XOR16ri8 : Ii8<0x83, MRM6r,
2160 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2161 "xor{w}\t{$src2, $dst|$dst, $src2}",
2162 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2163 i16immSExt8:$src2))]>,
2165 def XOR32ri8 : Ii8<0x83, MRM6r,
2166 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2167 "xor{l}\t{$src2, $dst|$dst, $src2}",
2168 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2169 i32immSExt8:$src2))]>;
2171 let Constraints = "" in {
2172 def XOR8mr : I<0x30, MRMDestMem,
2173 (outs), (ins i8mem :$dst, GR8 :$src),
2174 "xor{b}\t{$src, $dst|$dst, $src}",
2175 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2176 (implicit EFLAGS)]>;
2177 def XOR16mr : I<0x31, MRMDestMem,
2178 (outs), (ins i16mem:$dst, GR16:$src),
2179 "xor{w}\t{$src, $dst|$dst, $src}",
2180 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2181 (implicit EFLAGS)]>,
2183 def XOR32mr : I<0x31, MRMDestMem,
2184 (outs), (ins i32mem:$dst, GR32:$src),
2185 "xor{l}\t{$src, $dst|$dst, $src}",
2186 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2187 (implicit EFLAGS)]>;
2188 def XOR8mi : Ii8<0x80, MRM6m,
2189 (outs), (ins i8mem :$dst, i8imm :$src),
2190 "xor{b}\t{$src, $dst|$dst, $src}",
2191 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2192 (implicit EFLAGS)]>;
2193 def XOR16mi : Ii16<0x81, MRM6m,
2194 (outs), (ins i16mem:$dst, i16imm:$src),
2195 "xor{w}\t{$src, $dst|$dst, $src}",
2196 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2197 (implicit EFLAGS)]>,
2199 def XOR32mi : Ii32<0x81, MRM6m,
2200 (outs), (ins i32mem:$dst, i32imm:$src),
2201 "xor{l}\t{$src, $dst|$dst, $src}",
2202 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2203 (implicit EFLAGS)]>;
2204 def XOR16mi8 : Ii8<0x83, MRM6m,
2205 (outs), (ins i16mem:$dst, i16i8imm :$src),
2206 "xor{w}\t{$src, $dst|$dst, $src}",
2207 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2208 (implicit EFLAGS)]>,
2210 def XOR32mi8 : Ii8<0x83, MRM6m,
2211 (outs), (ins i32mem:$dst, i32i8imm :$src),
2212 "xor{l}\t{$src, $dst|$dst, $src}",
2213 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2214 (implicit EFLAGS)]>;
2216 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2217 "xor{b}\t{$src, %al|%al, $src}", []>;
2218 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
2219 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2220 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
2221 "xor{l}\t{$src, %eax|%eax, $src}", []>;
2222 } // Constraints = ""
2223 } // Defs = [EFLAGS]
2225 // Shift instructions
2226 let Defs = [EFLAGS] in {
2227 let Uses = [CL] in {
2228 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
2229 "shl{b}\t{%cl, $dst|$dst, CL}",
2230 [(set GR8:$dst, (shl GR8:$src1, CL))]>;
2231 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2232 "shl{w}\t{%cl, $dst|$dst, CL}",
2233 [(set GR16:$dst, (shl GR16:$src1, CL))]>, OpSize;
2234 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2235 "shl{l}\t{%cl, $dst|$dst, CL}",
2236 [(set GR32:$dst, (shl GR32:$src1, CL))]>;
2239 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2240 "shl{b}\t{$src2, $dst|$dst, $src2}",
2241 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2243 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2244 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2245 "shl{w}\t{$src2, $dst|$dst, $src2}",
2246 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2247 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2248 "shl{l}\t{$src2, $dst|$dst, $src2}",
2249 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
2251 // NOTE: We don't include patterns for shifts of a register by one, because
2252 // 'add reg,reg' is cheaper.
2254 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2255 "shl{b}\t$dst", []>;
2256 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2257 "shl{w}\t$dst", []>, OpSize;
2258 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2259 "shl{l}\t$dst", []>;
2261 } // isConvertibleToThreeAddress = 1
2263 let Constraints = "" in {
2264 let Uses = [CL] in {
2265 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
2266 "shl{b}\t{%cl, $dst|$dst, CL}",
2267 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
2268 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
2269 "shl{w}\t{%cl, $dst|$dst, CL}",
2270 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2271 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
2272 "shl{l}\t{%cl, $dst|$dst, CL}",
2273 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2275 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
2276 "shl{b}\t{$src, $dst|$dst, $src}",
2277 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2278 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
2279 "shl{w}\t{$src, $dst|$dst, $src}",
2280 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2282 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
2283 "shl{l}\t{$src, $dst|$dst, $src}",
2284 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2287 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2289 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2290 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2292 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2294 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2296 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2297 } // Constraints = ""
2299 let Uses = [CL] in {
2300 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1),
2301 "shr{b}\t{%cl, $dst|$dst, CL}",
2302 [(set GR8:$dst, (srl GR8:$src1, CL))]>;
2303 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2304 "shr{w}\t{%cl, $dst|$dst, CL}",
2305 [(set GR16:$dst, (srl GR16:$src1, CL))]>, OpSize;
2306 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2307 "shr{l}\t{%cl, $dst|$dst, CL}",
2308 [(set GR32:$dst, (srl GR32:$src1, CL))]>;
2311 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2312 "shr{b}\t{$src2, $dst|$dst, $src2}",
2313 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2314 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2315 "shr{w}\t{$src2, $dst|$dst, $src2}",
2316 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2317 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2318 "shr{l}\t{$src2, $dst|$dst, $src2}",
2319 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2322 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2324 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2325 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2327 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2328 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2330 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2332 let Constraints = "" in {
2333 let Uses = [CL] in {
2334 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2335 "shr{b}\t{%cl, $dst|$dst, CL}",
2336 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2337 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2338 "shr{w}\t{%cl, $dst|$dst, CL}",
2339 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2341 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2342 "shr{l}\t{%cl, $dst|$dst, CL}",
2343 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2345 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2346 "shr{b}\t{$src, $dst|$dst, $src}",
2347 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2348 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2349 "shr{w}\t{$src, $dst|$dst, $src}",
2350 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2352 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2353 "shr{l}\t{$src, $dst|$dst, $src}",
2354 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2357 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2359 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2360 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2362 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2363 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2365 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2366 } // Constraints = ""
2368 let Uses = [CL] in {
2369 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2370 "sar{b}\t{%cl, $dst|$dst, CL}",
2371 [(set GR8:$dst, (sra GR8:$src1, CL))]>;
2372 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2373 "sar{w}\t{%cl, $dst|$dst, CL}",
2374 [(set GR16:$dst, (sra GR16:$src1, CL))]>, OpSize;
2375 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2376 "sar{l}\t{%cl, $dst|$dst, CL}",
2377 [(set GR32:$dst, (sra GR32:$src1, CL))]>;
2380 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2381 "sar{b}\t{$src2, $dst|$dst, $src2}",
2382 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2383 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2384 "sar{w}\t{$src2, $dst|$dst, $src2}",
2385 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2387 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2388 "sar{l}\t{$src2, $dst|$dst, $src2}",
2389 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2392 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2394 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2395 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2397 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2398 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2400 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2402 let Constraints = "" in {
2403 let Uses = [CL] in {
2404 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2405 "sar{b}\t{%cl, $dst|$dst, CL}",
2406 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2407 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2408 "sar{w}\t{%cl, $dst|$dst, CL}",
2409 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2410 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2411 "sar{l}\t{%cl, $dst|$dst, CL}",
2412 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2414 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2415 "sar{b}\t{$src, $dst|$dst, $src}",
2416 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2417 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2418 "sar{w}\t{$src, $dst|$dst, $src}",
2419 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2421 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2422 "sar{l}\t{$src, $dst|$dst, $src}",
2423 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2426 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2428 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2429 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2431 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2433 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2435 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2436 } // Constraints = ""
2438 // Rotate instructions
2440 def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
2441 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2442 let Uses = [CL] in {
2443 def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
2444 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2446 def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
2447 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2449 def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
2450 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2451 let Uses = [CL] in {
2452 def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
2453 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2455 def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
2456 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2458 def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
2459 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2460 let Uses = [CL] in {
2461 def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
2462 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2464 def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
2465 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2467 def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
2468 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2469 let Uses = [CL] in {
2470 def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
2471 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2473 def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
2474 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2476 def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
2477 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2478 let Uses = [CL] in {
2479 def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
2480 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2482 def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
2483 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2485 def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
2486 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2487 let Uses = [CL] in {
2488 def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
2489 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2491 def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
2492 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2494 let Constraints = "" in {
2495 def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2496 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2497 def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2498 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2499 def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2500 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2501 def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2502 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2503 def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2504 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2505 def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2506 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2507 def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2508 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2509 def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2510 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2511 def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2512 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2513 def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2514 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2515 def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2516 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2517 def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2518 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2520 let Uses = [CL] in {
2521 def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2522 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2523 def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2524 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2525 def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2526 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2527 def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2528 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2529 def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2530 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2531 def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2532 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2534 } // Constraints = ""
2536 // FIXME: provide shorter instructions when imm8 == 1
2537 let Uses = [CL] in {
2538 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2539 "rol{b}\t{%cl, $dst|$dst, CL}",
2540 [(set GR8:$dst, (rotl GR8:$src1, CL))]>;
2541 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2542 "rol{w}\t{%cl, $dst|$dst, CL}",
2543 [(set GR16:$dst, (rotl GR16:$src1, CL))]>, OpSize;
2544 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2545 "rol{l}\t{%cl, $dst|$dst, CL}",
2546 [(set GR32:$dst, (rotl GR32:$src1, CL))]>;
2549 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2550 "rol{b}\t{$src2, $dst|$dst, $src2}",
2551 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2552 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2553 "rol{w}\t{$src2, $dst|$dst, $src2}",
2554 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2556 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2557 "rol{l}\t{$src2, $dst|$dst, $src2}",
2558 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2561 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2563 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2564 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2566 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2567 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2569 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2571 let Constraints = "" in {
2572 let Uses = [CL] in {
2573 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2574 "rol{b}\t{%cl, $dst|$dst, CL}",
2575 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2576 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2577 "rol{w}\t{%cl, $dst|$dst, CL}",
2578 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2579 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2580 "rol{l}\t{%cl, $dst|$dst, CL}",
2581 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2583 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2584 "rol{b}\t{$src, $dst|$dst, $src}",
2585 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2586 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2587 "rol{w}\t{$src, $dst|$dst, $src}",
2588 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2590 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2591 "rol{l}\t{$src, $dst|$dst, $src}",
2592 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2595 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2597 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2598 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2600 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2602 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2604 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2605 } // Constraints = ""
2607 let Uses = [CL] in {
2608 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2609 "ror{b}\t{%cl, $dst|$dst, CL}",
2610 [(set GR8:$dst, (rotr GR8:$src1, CL))]>;
2611 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2612 "ror{w}\t{%cl, $dst|$dst, CL}",
2613 [(set GR16:$dst, (rotr GR16:$src1, CL))]>, OpSize;
2614 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2615 "ror{l}\t{%cl, $dst|$dst, CL}",
2616 [(set GR32:$dst, (rotr GR32:$src1, CL))]>;
2619 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2620 "ror{b}\t{$src2, $dst|$dst, $src2}",
2621 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2622 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2623 "ror{w}\t{$src2, $dst|$dst, $src2}",
2624 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2626 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2627 "ror{l}\t{$src2, $dst|$dst, $src2}",
2628 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2631 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2633 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2634 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2636 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2637 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2639 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2641 let Constraints = "" in {
2642 let Uses = [CL] in {
2643 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2644 "ror{b}\t{%cl, $dst|$dst, CL}",
2645 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2646 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2647 "ror{w}\t{%cl, $dst|$dst, CL}",
2648 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2649 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2650 "ror{l}\t{%cl, $dst|$dst, CL}",
2651 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2653 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2654 "ror{b}\t{$src, $dst|$dst, $src}",
2655 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2656 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2657 "ror{w}\t{$src, $dst|$dst, $src}",
2658 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2660 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2661 "ror{l}\t{$src, $dst|$dst, $src}",
2662 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2665 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2667 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2668 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2670 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2672 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2674 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2675 } // Constraints = ""
2678 // Double shift instructions (generalizations of rotate)
2679 let Uses = [CL] in {
2680 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2681 (ins GR32:$src1, GR32:$src2),
2682 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2683 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2684 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2685 (ins GR32:$src1, GR32:$src2),
2686 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2687 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2688 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2689 (ins GR16:$src1, GR16:$src2),
2690 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2691 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2693 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2694 (ins GR16:$src1, GR16:$src2),
2695 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2696 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2700 let isCommutable = 1 in { // These instructions commute to each other.
2701 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2703 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2704 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2705 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2708 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2710 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2711 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2712 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2715 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2717 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2718 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2719 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2722 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2724 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2725 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2726 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2731 let Constraints = "" in {
2732 let Uses = [CL] in {
2733 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2734 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2735 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2737 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2738 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2739 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2742 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2743 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2744 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2745 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2746 (i8 imm:$src3)), addr:$dst)]>,
2748 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2749 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2750 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2751 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2752 (i8 imm:$src3)), addr:$dst)]>,
2755 let Uses = [CL] in {
2756 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2757 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2758 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2759 addr:$dst)]>, TB, OpSize;
2760 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2761 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2762 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2763 addr:$dst)]>, TB, OpSize;
2765 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2766 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2767 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2768 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2769 (i8 imm:$src3)), addr:$dst)]>,
2771 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2772 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2773 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2774 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2775 (i8 imm:$src3)), addr:$dst)]>,
2777 } // Constraints = ""
2778 } // Defs = [EFLAGS]
2782 let Defs = [EFLAGS] in {
2783 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2784 // Register-Register Addition
2785 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2786 (ins GR8 :$src1, GR8 :$src2),
2787 "add{b}\t{$src2, $dst|$dst, $src2}",
2788 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
2790 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2791 // Register-Register Addition
2792 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2793 (ins GR16:$src1, GR16:$src2),
2794 "add{w}\t{$src2, $dst|$dst, $src2}",
2795 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2796 GR16:$src2))]>, OpSize;
2797 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2798 (ins GR32:$src1, GR32:$src2),
2799 "add{l}\t{$src2, $dst|$dst, $src2}",
2800 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2802 } // end isConvertibleToThreeAddress
2803 } // end isCommutable
2805 // These are alternate spellings for use by the disassembler, we mark them as
2806 // code gen only to ensure they aren't matched by the assembler.
2807 let isCodeGenOnly = 1 in {
2808 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2809 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2810 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2811 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2812 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
2813 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2816 // Register-Memory Addition
2817 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2818 (ins GR8 :$src1, i8mem :$src2),
2819 "add{b}\t{$src2, $dst|$dst, $src2}",
2820 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2821 (load addr:$src2)))]>;
2822 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2823 (ins GR16:$src1, i16mem:$src2),
2824 "add{w}\t{$src2, $dst|$dst, $src2}",
2825 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2826 (load addr:$src2)))]>, OpSize;
2827 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2828 (ins GR32:$src1, i32mem:$src2),
2829 "add{l}\t{$src2, $dst|$dst, $src2}",
2830 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2831 (load addr:$src2)))]>;
2833 // Register-Integer Addition
2834 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2835 "add{b}\t{$src2, $dst|$dst, $src2}",
2836 [(set GR8:$dst, EFLAGS,
2837 (X86add_flag GR8:$src1, imm:$src2))]>;
2839 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2840 // Register-Integer Addition
2841 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2842 (ins GR16:$src1, i16imm:$src2),
2843 "add{w}\t{$src2, $dst|$dst, $src2}",
2844 [(set GR16:$dst, EFLAGS,
2845 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
2846 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2847 (ins GR32:$src1, i32imm:$src2),
2848 "add{l}\t{$src2, $dst|$dst, $src2}",
2849 [(set GR32:$dst, EFLAGS,
2850 (X86add_flag GR32:$src1, imm:$src2))]>;
2851 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2852 (ins GR16:$src1, i16i8imm:$src2),
2853 "add{w}\t{$src2, $dst|$dst, $src2}",
2854 [(set GR16:$dst, EFLAGS,
2855 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
2856 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2857 (ins GR32:$src1, i32i8imm:$src2),
2858 "add{l}\t{$src2, $dst|$dst, $src2}",
2859 [(set GR32:$dst, EFLAGS,
2860 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
2863 let Constraints = "" in {
2864 // Memory-Register Addition
2865 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2866 "add{b}\t{$src2, $dst|$dst, $src2}",
2867 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2868 (implicit EFLAGS)]>;
2869 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2870 "add{w}\t{$src2, $dst|$dst, $src2}",
2871 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2872 (implicit EFLAGS)]>, OpSize;
2873 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2874 "add{l}\t{$src2, $dst|$dst, $src2}",
2875 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2876 (implicit EFLAGS)]>;
2877 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2878 "add{b}\t{$src2, $dst|$dst, $src2}",
2879 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2880 (implicit EFLAGS)]>;
2881 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2882 "add{w}\t{$src2, $dst|$dst, $src2}",
2883 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2884 (implicit EFLAGS)]>, OpSize;
2885 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2886 "add{l}\t{$src2, $dst|$dst, $src2}",
2887 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2888 (implicit EFLAGS)]>;
2889 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2890 "add{w}\t{$src2, $dst|$dst, $src2}",
2891 [(store (add (load addr:$dst), i16immSExt8:$src2),
2893 (implicit EFLAGS)]>, OpSize;
2894 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2895 "add{l}\t{$src2, $dst|$dst, $src2}",
2896 [(store (add (load addr:$dst), i32immSExt8:$src2),
2898 (implicit EFLAGS)]>;
2901 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2902 "add{b}\t{$src, %al|%al, $src}", []>;
2903 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2904 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2905 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2906 "add{l}\t{$src, %eax|%eax, $src}", []>;
2907 } // Constraints = ""
2909 let Uses = [EFLAGS] in {
2910 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2911 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2912 "adc{b}\t{$src2, $dst|$dst, $src2}",
2913 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2914 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2915 (ins GR16:$src1, GR16:$src2),
2916 "adc{w}\t{$src2, $dst|$dst, $src2}",
2917 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2918 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2919 (ins GR32:$src1, GR32:$src2),
2920 "adc{l}\t{$src2, $dst|$dst, $src2}",
2921 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2924 let isCodeGenOnly = 1 in {
2925 def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2926 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2927 def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2928 (ins GR16:$src1, GR16:$src2),
2929 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2930 def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2931 (ins GR32:$src1, GR32:$src2),
2932 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2935 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2936 (ins GR8:$src1, i8mem:$src2),
2937 "adc{b}\t{$src2, $dst|$dst, $src2}",
2938 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2939 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2940 (ins GR16:$src1, i16mem:$src2),
2941 "adc{w}\t{$src2, $dst|$dst, $src2}",
2942 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2944 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2945 (ins GR32:$src1, i32mem:$src2),
2946 "adc{l}\t{$src2, $dst|$dst, $src2}",
2947 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2948 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2949 "adc{b}\t{$src2, $dst|$dst, $src2}",
2950 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2951 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2952 (ins GR16:$src1, i16imm:$src2),
2953 "adc{w}\t{$src2, $dst|$dst, $src2}",
2954 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2955 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2956 (ins GR16:$src1, i16i8imm:$src2),
2957 "adc{w}\t{$src2, $dst|$dst, $src2}",
2958 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2960 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2961 (ins GR32:$src1, i32imm:$src2),
2962 "adc{l}\t{$src2, $dst|$dst, $src2}",
2963 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2964 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2965 (ins GR32:$src1, i32i8imm:$src2),
2966 "adc{l}\t{$src2, $dst|$dst, $src2}",
2967 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2969 let Constraints = "" in {
2970 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2971 "adc{b}\t{$src2, $dst|$dst, $src2}",
2972 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2973 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2974 "adc{w}\t{$src2, $dst|$dst, $src2}",
2975 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2977 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2978 "adc{l}\t{$src2, $dst|$dst, $src2}",
2979 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2980 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2981 "adc{b}\t{$src2, $dst|$dst, $src2}",
2982 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2983 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2984 "adc{w}\t{$src2, $dst|$dst, $src2}",
2985 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2987 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2988 "adc{w}\t{$src2, $dst|$dst, $src2}",
2989 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2991 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2992 "adc{l}\t{$src2, $dst|$dst, $src2}",
2993 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2994 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2995 "adc{l}\t{$src2, $dst|$dst, $src2}",
2996 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2998 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2999 "adc{b}\t{$src, %al|%al, $src}", []>;
3000 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
3001 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3002 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
3003 "adc{l}\t{$src, %eax|%eax, $src}", []>;
3004 } // Constraints = ""
3005 } // Uses = [EFLAGS]
3007 // Register-Register Subtraction
3008 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3009 "sub{b}\t{$src2, $dst|$dst, $src2}",
3010 [(set GR8:$dst, EFLAGS,
3011 (X86sub_flag GR8:$src1, GR8:$src2))]>;
3012 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
3013 "sub{w}\t{$src2, $dst|$dst, $src2}",
3014 [(set GR16:$dst, EFLAGS,
3015 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
3016 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
3017 "sub{l}\t{$src2, $dst|$dst, $src2}",
3018 [(set GR32:$dst, EFLAGS,
3019 (X86sub_flag GR32:$src1, GR32:$src2))]>;
3021 let isCodeGenOnly = 1 in {
3022 def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3023 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
3024 def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
3025 (ins GR16:$src1, GR16:$src2),
3026 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3027 def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
3028 (ins GR32:$src1, GR32:$src2),
3029 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
3032 // Register-Memory Subtraction
3033 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
3034 (ins GR8 :$src1, i8mem :$src2),
3035 "sub{b}\t{$src2, $dst|$dst, $src2}",
3036 [(set GR8:$dst, EFLAGS,
3037 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
3038 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
3039 (ins GR16:$src1, i16mem:$src2),
3040 "sub{w}\t{$src2, $dst|$dst, $src2}",
3041 [(set GR16:$dst, EFLAGS,
3042 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
3043 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
3044 (ins GR32:$src1, i32mem:$src2),
3045 "sub{l}\t{$src2, $dst|$dst, $src2}",
3046 [(set GR32:$dst, EFLAGS,
3047 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
3049 // Register-Integer Subtraction
3050 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
3051 (ins GR8:$src1, i8imm:$src2),
3052 "sub{b}\t{$src2, $dst|$dst, $src2}",
3053 [(set GR8:$dst, EFLAGS,
3054 (X86sub_flag GR8:$src1, imm:$src2))]>;
3055 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
3056 (ins GR16:$src1, i16imm:$src2),
3057 "sub{w}\t{$src2, $dst|$dst, $src2}",
3058 [(set GR16:$dst, EFLAGS,
3059 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
3060 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
3061 (ins GR32:$src1, i32imm:$src2),
3062 "sub{l}\t{$src2, $dst|$dst, $src2}",
3063 [(set GR32:$dst, EFLAGS,
3064 (X86sub_flag GR32:$src1, imm:$src2))]>;
3065 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
3066 (ins GR16:$src1, i16i8imm:$src2),
3067 "sub{w}\t{$src2, $dst|$dst, $src2}",
3068 [(set GR16:$dst, EFLAGS,
3069 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
3070 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
3071 (ins GR32:$src1, i32i8imm:$src2),
3072 "sub{l}\t{$src2, $dst|$dst, $src2}",
3073 [(set GR32:$dst, EFLAGS,
3074 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
3076 let Constraints = "" in {
3077 // Memory-Register Subtraction
3078 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3079 "sub{b}\t{$src2, $dst|$dst, $src2}",
3080 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
3081 (implicit EFLAGS)]>;
3082 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3083 "sub{w}\t{$src2, $dst|$dst, $src2}",
3084 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
3085 (implicit EFLAGS)]>, OpSize;
3086 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3087 "sub{l}\t{$src2, $dst|$dst, $src2}",
3088 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
3089 (implicit EFLAGS)]>;
3091 // Memory-Integer Subtraction
3092 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3093 "sub{b}\t{$src2, $dst|$dst, $src2}",
3094 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
3095 (implicit EFLAGS)]>;
3096 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3097 "sub{w}\t{$src2, $dst|$dst, $src2}",
3098 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
3099 (implicit EFLAGS)]>, OpSize;
3100 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3101 "sub{l}\t{$src2, $dst|$dst, $src2}",
3102 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
3103 (implicit EFLAGS)]>;
3104 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3105 "sub{w}\t{$src2, $dst|$dst, $src2}",
3106 [(store (sub (load addr:$dst), i16immSExt8:$src2),
3108 (implicit EFLAGS)]>, OpSize;
3109 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3110 "sub{l}\t{$src2, $dst|$dst, $src2}",
3111 [(store (sub (load addr:$dst), i32immSExt8:$src2),
3113 (implicit EFLAGS)]>;
3115 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
3116 "sub{b}\t{$src, %al|%al, $src}", []>;
3117 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
3118 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3119 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
3120 "sub{l}\t{$src, %eax|%eax, $src}", []>;
3121 } // Constraints = ""
3123 let Uses = [EFLAGS] in {
3124 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
3125 (ins GR8:$src1, GR8:$src2),
3126 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3127 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
3128 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3129 (ins GR16:$src1, GR16:$src2),
3130 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3131 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
3132 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3133 (ins GR32:$src1, GR32:$src2),
3134 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3135 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
3137 let Constraints = "" in {
3138 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3139 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3140 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
3141 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3142 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3143 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
3145 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3146 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3147 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
3148 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3149 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3150 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
3151 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3152 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3153 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
3155 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3156 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3157 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
3159 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
3160 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3161 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
3162 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3163 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3164 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
3166 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3167 "sbb{b}\t{$src, %al|%al, $src}", []>;
3168 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3169 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3170 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3171 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
3172 } // Constraints = ""
3174 let isCodeGenOnly = 1 in {
3175 def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3176 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3177 def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3178 (ins GR16:$src1, GR16:$src2),
3179 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3180 def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3181 (ins GR32:$src1, GR32:$src2),
3182 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3185 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3186 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3187 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
3188 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3189 (ins GR16:$src1, i16mem:$src2),
3190 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3191 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
3193 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3194 (ins GR32:$src1, i32mem:$src2),
3195 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3196 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
3197 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3198 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3199 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
3200 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3201 (ins GR16:$src1, i16imm:$src2),
3202 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3203 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
3204 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3205 (ins GR16:$src1, i16i8imm:$src2),
3206 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3207 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3209 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3210 (ins GR32:$src1, i32imm:$src2),
3211 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3212 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
3213 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3214 (ins GR32:$src1, i32i8imm:$src2),
3215 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3216 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
3217 } // Uses = [EFLAGS]
3218 } // Defs = [EFLAGS]
3220 let Defs = [EFLAGS] in {
3221 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
3222 // Register-Register Signed Integer Multiply
3223 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
3224 "imul{w}\t{$src2, $dst|$dst, $src2}",
3225 [(set GR16:$dst, EFLAGS,
3226 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
3227 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
3228 "imul{l}\t{$src2, $dst|$dst, $src2}",
3229 [(set GR32:$dst, EFLAGS,
3230 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
3233 // Register-Memory Signed Integer Multiply
3234 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3235 (ins GR16:$src1, i16mem:$src2),
3236 "imul{w}\t{$src2, $dst|$dst, $src2}",
3237 [(set GR16:$dst, EFLAGS,
3238 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
3240 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3241 (ins GR32:$src1, i32mem:$src2),
3242 "imul{l}\t{$src2, $dst|$dst, $src2}",
3243 [(set GR32:$dst, EFLAGS,
3244 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
3245 } // Defs = [EFLAGS]
3246 } // end Two Address instructions
3248 // Suprisingly enough, these are not two address instructions!
3249 let Defs = [EFLAGS] in {
3250 // Register-Integer Signed Integer Multiply
3251 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
3252 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
3253 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3254 [(set GR16:$dst, EFLAGS,
3255 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
3256 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
3257 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
3258 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3259 [(set GR32:$dst, EFLAGS,
3260 (X86smul_flag GR32:$src1, imm:$src2))]>;
3261 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
3262 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
3263 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3264 [(set GR16:$dst, EFLAGS,
3265 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
3267 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
3268 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
3269 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3270 [(set GR32:$dst, EFLAGS,
3271 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
3273 // Memory-Integer Signed Integer Multiply
3274 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
3275 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
3276 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3277 [(set GR16:$dst, EFLAGS,
3278 (X86smul_flag (load addr:$src1), imm:$src2))]>,
3280 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
3281 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
3282 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3283 [(set GR32:$dst, EFLAGS,
3284 (X86smul_flag (load addr:$src1), imm:$src2))]>;
3285 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
3286 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
3287 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3288 [(set GR16:$dst, EFLAGS,
3289 (X86smul_flag (load addr:$src1),
3290 i16immSExt8:$src2))]>, OpSize;
3291 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
3292 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
3293 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3294 [(set GR32:$dst, EFLAGS,
3295 (X86smul_flag (load addr:$src1),
3296 i32immSExt8:$src2))]>;
3297 } // Defs = [EFLAGS]
3299 //===----------------------------------------------------------------------===//
3300 // Test instructions are just like AND, except they don't generate a result.
3302 let Defs = [EFLAGS] in {
3303 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
3304 def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3305 "test{b}\t{$src2, $src1|$src1, $src2}",
3306 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
3307 def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3308 "test{w}\t{$src2, $src1|$src1, $src2}",
3309 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
3312 def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3313 "test{l}\t{$src2, $src1|$src1, $src2}",
3314 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
3318 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3319 "test{b}\t{$src, %al|%al, $src}", []>;
3320 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3321 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3322 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3323 "test{l}\t{$src, %eax|%eax, $src}", []>;
3325 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
3326 "test{b}\t{$src2, $src1|$src1, $src2}",
3327 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
3329 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
3330 "test{w}\t{$src2, $src1|$src1, $src2}",
3331 [(set EFLAGS, (X86cmp (and GR16:$src1,
3332 (loadi16 addr:$src2)), 0))]>, OpSize;
3333 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
3334 "test{l}\t{$src2, $src1|$src1, $src2}",
3335 [(set EFLAGS, (X86cmp (and GR32:$src1,
3336 (loadi32 addr:$src2)), 0))]>;
3338 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
3339 (outs), (ins GR8:$src1, i8imm:$src2),
3340 "test{b}\t{$src2, $src1|$src1, $src2}",
3341 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
3342 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
3343 (outs), (ins GR16:$src1, i16imm:$src2),
3344 "test{w}\t{$src2, $src1|$src1, $src2}",
3345 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
3347 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
3348 (outs), (ins GR32:$src1, i32imm:$src2),
3349 "test{l}\t{$src2, $src1|$src1, $src2}",
3350 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
3352 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
3353 (outs), (ins i8mem:$src1, i8imm:$src2),
3354 "test{b}\t{$src2, $src1|$src1, $src2}",
3355 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
3357 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
3358 (outs), (ins i16mem:$src1, i16imm:$src2),
3359 "test{w}\t{$src2, $src1|$src1, $src2}",
3360 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
3362 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
3363 (outs), (ins i32mem:$src1, i32imm:$src2),
3364 "test{l}\t{$src2, $src1|$src1, $src2}",
3365 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
3367 } // Defs = [EFLAGS]
3370 // Condition code ops, incl. set if equal/not equal/...
3371 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
3372 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
3373 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
3374 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
3376 let Uses = [EFLAGS] in {
3377 // Use sbb to materialize carry bit.
3378 let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3379 // FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3380 // However, Pat<> can't replicate the destination reg into the inputs of the
3382 // FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3384 def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
3385 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3386 def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
3387 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
3389 def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
3390 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3393 def SETEr : I<0x94, MRM0r,
3394 (outs GR8 :$dst), (ins),
3396 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
3398 def SETEm : I<0x94, MRM0m,
3399 (outs), (ins i8mem:$dst),
3401 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
3404 def SETNEr : I<0x95, MRM0r,
3405 (outs GR8 :$dst), (ins),
3407 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
3409 def SETNEm : I<0x95, MRM0m,
3410 (outs), (ins i8mem:$dst),
3412 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
3415 def SETLr : I<0x9C, MRM0r,
3416 (outs GR8 :$dst), (ins),
3418 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
3419 TB; // GR8 = < signed
3420 def SETLm : I<0x9C, MRM0m,
3421 (outs), (ins i8mem:$dst),
3423 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
3424 TB; // [mem8] = < signed
3426 def SETGEr : I<0x9D, MRM0r,
3427 (outs GR8 :$dst), (ins),
3429 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
3430 TB; // GR8 = >= signed
3431 def SETGEm : I<0x9D, MRM0m,
3432 (outs), (ins i8mem:$dst),
3434 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
3435 TB; // [mem8] = >= signed
3437 def SETLEr : I<0x9E, MRM0r,
3438 (outs GR8 :$dst), (ins),
3440 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3441 TB; // GR8 = <= signed
3442 def SETLEm : I<0x9E, MRM0m,
3443 (outs), (ins i8mem:$dst),
3445 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3446 TB; // [mem8] = <= signed
3448 def SETGr : I<0x9F, MRM0r,
3449 (outs GR8 :$dst), (ins),
3451 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3452 TB; // GR8 = > signed
3453 def SETGm : I<0x9F, MRM0m,
3454 (outs), (ins i8mem:$dst),
3456 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3457 TB; // [mem8] = > signed
3459 def SETBr : I<0x92, MRM0r,
3460 (outs GR8 :$dst), (ins),
3462 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3463 TB; // GR8 = < unsign
3464 def SETBm : I<0x92, MRM0m,
3465 (outs), (ins i8mem:$dst),
3467 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3468 TB; // [mem8] = < unsign
3470 def SETAEr : I<0x93, MRM0r,
3471 (outs GR8 :$dst), (ins),
3473 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3474 TB; // GR8 = >= unsign
3475 def SETAEm : I<0x93, MRM0m,
3476 (outs), (ins i8mem:$dst),
3478 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3479 TB; // [mem8] = >= unsign
3481 def SETBEr : I<0x96, MRM0r,
3482 (outs GR8 :$dst), (ins),
3484 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3485 TB; // GR8 = <= unsign
3486 def SETBEm : I<0x96, MRM0m,
3487 (outs), (ins i8mem:$dst),
3489 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3490 TB; // [mem8] = <= unsign
3492 def SETAr : I<0x97, MRM0r,
3493 (outs GR8 :$dst), (ins),
3495 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3496 TB; // GR8 = > signed
3497 def SETAm : I<0x97, MRM0m,
3498 (outs), (ins i8mem:$dst),
3500 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3501 TB; // [mem8] = > signed
3503 def SETSr : I<0x98, MRM0r,
3504 (outs GR8 :$dst), (ins),
3506 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3507 TB; // GR8 = <sign bit>
3508 def SETSm : I<0x98, MRM0m,
3509 (outs), (ins i8mem:$dst),
3511 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3512 TB; // [mem8] = <sign bit>
3513 def SETNSr : I<0x99, MRM0r,
3514 (outs GR8 :$dst), (ins),
3516 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3517 TB; // GR8 = !<sign bit>
3518 def SETNSm : I<0x99, MRM0m,
3519 (outs), (ins i8mem:$dst),
3521 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3522 TB; // [mem8] = !<sign bit>
3524 def SETPr : I<0x9A, MRM0r,
3525 (outs GR8 :$dst), (ins),
3527 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3529 def SETPm : I<0x9A, MRM0m,
3530 (outs), (ins i8mem:$dst),
3532 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3533 TB; // [mem8] = parity
3534 def SETNPr : I<0x9B, MRM0r,
3535 (outs GR8 :$dst), (ins),
3537 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3538 TB; // GR8 = not parity
3539 def SETNPm : I<0x9B, MRM0m,
3540 (outs), (ins i8mem:$dst),
3542 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3543 TB; // [mem8] = not parity
3545 def SETOr : I<0x90, MRM0r,
3546 (outs GR8 :$dst), (ins),
3548 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3549 TB; // GR8 = overflow
3550 def SETOm : I<0x90, MRM0m,
3551 (outs), (ins i8mem:$dst),
3553 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3554 TB; // [mem8] = overflow
3555 def SETNOr : I<0x91, MRM0r,
3556 (outs GR8 :$dst), (ins),
3558 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3559 TB; // GR8 = not overflow
3560 def SETNOm : I<0x91, MRM0m,
3561 (outs), (ins i8mem:$dst),
3563 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3564 TB; // [mem8] = not overflow
3565 } // Uses = [EFLAGS]
3568 // Integer comparisons
3569 let Defs = [EFLAGS] in {
3570 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3571 "cmp{b}\t{$src, %al|%al, $src}", []>;
3572 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3573 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3574 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3575 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3577 def CMP8rr : I<0x38, MRMDestReg,
3578 (outs), (ins GR8 :$src1, GR8 :$src2),
3579 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3580 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
3581 def CMP16rr : I<0x39, MRMDestReg,
3582 (outs), (ins GR16:$src1, GR16:$src2),
3583 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3584 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
3585 def CMP32rr : I<0x39, MRMDestReg,
3586 (outs), (ins GR32:$src1, GR32:$src2),
3587 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3588 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
3589 def CMP8mr : I<0x38, MRMDestMem,
3590 (outs), (ins i8mem :$src1, GR8 :$src2),
3591 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3592 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
3593 def CMP16mr : I<0x39, MRMDestMem,
3594 (outs), (ins i16mem:$src1, GR16:$src2),
3595 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3596 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3598 def CMP32mr : I<0x39, MRMDestMem,
3599 (outs), (ins i32mem:$src1, GR32:$src2),
3600 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3601 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
3602 def CMP8rm : I<0x3A, MRMSrcMem,
3603 (outs), (ins GR8 :$src1, i8mem :$src2),
3604 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3605 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
3606 def CMP16rm : I<0x3B, MRMSrcMem,
3607 (outs), (ins GR16:$src1, i16mem:$src2),
3608 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3609 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3611 def CMP32rm : I<0x3B, MRMSrcMem,
3612 (outs), (ins GR32:$src1, i32mem:$src2),
3613 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3614 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
3616 // These are alternate spellings for use by the disassembler, we mark them as
3617 // code gen only to ensure they aren't matched by the assembler.
3618 let isCodeGenOnly = 1 in {
3619 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3620 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3621 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3622 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3623 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3624 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3627 def CMP8ri : Ii8<0x80, MRM7r,
3628 (outs), (ins GR8:$src1, i8imm:$src2),
3629 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3630 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
3631 def CMP16ri : Ii16<0x81, MRM7r,
3632 (outs), (ins GR16:$src1, i16imm:$src2),
3633 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3634 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
3635 def CMP32ri : Ii32<0x81, MRM7r,
3636 (outs), (ins GR32:$src1, i32imm:$src2),
3637 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3638 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
3639 def CMP8mi : Ii8 <0x80, MRM7m,
3640 (outs), (ins i8mem :$src1, i8imm :$src2),
3641 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3642 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
3643 def CMP16mi : Ii16<0x81, MRM7m,
3644 (outs), (ins i16mem:$src1, i16imm:$src2),
3645 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3646 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
3648 def CMP32mi : Ii32<0x81, MRM7m,
3649 (outs), (ins i32mem:$src1, i32imm:$src2),
3650 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3651 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
3652 def CMP16ri8 : Ii8<0x83, MRM7r,
3653 (outs), (ins GR16:$src1, i16i8imm:$src2),
3654 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3655 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3657 def CMP16mi8 : Ii8<0x83, MRM7m,
3658 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3659 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3660 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3661 i16immSExt8:$src2))]>, OpSize;
3662 def CMP32mi8 : Ii8<0x83, MRM7m,
3663 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3664 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3665 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3666 i32immSExt8:$src2))]>;
3667 def CMP32ri8 : Ii8<0x83, MRM7r,
3668 (outs), (ins GR32:$src1, i32i8imm:$src2),
3669 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3670 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
3671 } // Defs = [EFLAGS]
3674 // TODO: BTC, BTR, and BTS
3675 let Defs = [EFLAGS] in {
3676 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3677 "bt{w}\t{$src2, $src1|$src1, $src2}",
3678 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
3679 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3680 "bt{l}\t{$src2, $src1|$src1, $src2}",
3681 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
3683 // Unlike with the register+register form, the memory+register form of the
3684 // bt instruction does not ignore the high bits of the index. From ISel's
3685 // perspective, this is pretty bizarre. Make these instructions disassembly
3688 def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3689 "bt{w}\t{$src2, $src1|$src1, $src2}",
3690 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3691 // (implicit EFLAGS)]
3693 >, OpSize, TB, Requires<[FastBTMem]>;
3694 def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3695 "bt{l}\t{$src2, $src1|$src1, $src2}",
3696 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3697 // (implicit EFLAGS)]
3699 >, TB, Requires<[FastBTMem]>;
3701 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3702 "bt{w}\t{$src2, $src1|$src1, $src2}",
3703 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3705 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3706 "bt{l}\t{$src2, $src1|$src1, $src2}",
3707 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
3708 // Note that these instructions don't need FastBTMem because that
3709 // only applies when the other operand is in a register. When it's
3710 // an immediate, bt is still fast.
3711 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3712 "bt{w}\t{$src2, $src1|$src1, $src2}",
3713 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3715 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3716 "bt{l}\t{$src2, $src1|$src1, $src2}",
3717 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3720 def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3721 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3722 def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3723 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3724 def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3725 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3726 def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3727 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3728 def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3729 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3730 def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3731 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3732 def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3733 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3734 def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3735 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3737 def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3738 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3739 def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3740 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3741 def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3742 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3743 def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3744 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3745 def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3746 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3747 def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3748 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3749 def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3750 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3751 def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3752 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3754 def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3755 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3756 def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3757 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3758 def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3759 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3760 def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3761 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3762 def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3763 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3764 def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3765 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3766 def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3767 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3768 def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3769 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3770 } // Defs = [EFLAGS]
3772 // Sign/Zero extenders
3773 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3774 // of the register here. This has a smaller encoding and avoids a
3775 // partial-register update. Actual movsbw included for the disassembler.
3776 def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3777 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3778 def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3779 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3780 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3781 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
3782 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3783 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3784 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3785 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3786 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3787 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3788 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3789 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3790 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3791 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3792 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3793 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3794 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3795 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3797 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3798 // of the register here. This has a smaller encoding and avoids a
3799 // partial-register update. Actual movzbw included for the disassembler.
3800 def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3801 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3802 def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3803 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3804 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3805 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
3806 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3807 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3808 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3809 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3810 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3811 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3812 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3813 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3814 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3815 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3816 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3817 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3818 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3819 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3821 // These are the same as the regular MOVZX32rr8 and MOVZX32rm8
3822 // except that they use GR32_NOREX for the output operand register class
3823 // instead of GR32. This allows them to operate on h registers on x86-64.
3824 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3825 (outs GR32_NOREX:$dst), (ins GR8:$src),
3826 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3829 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3830 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3831 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3834 let neverHasSideEffects = 1 in {
3835 let Defs = [AX], Uses = [AL] in
3836 def CBW : I<0x98, RawFrm, (outs), (ins),
3837 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3838 let Defs = [EAX], Uses = [AX] in
3839 def CWDE : I<0x98, RawFrm, (outs), (ins),
3840 "{cwtl|cwde}", []>; // EAX = signext(AX)
3842 let Defs = [AX,DX], Uses = [AX] in
3843 def CWD : I<0x99, RawFrm, (outs), (ins),
3844 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3845 let Defs = [EAX,EDX], Uses = [EAX] in
3846 def CDQ : I<0x99, RawFrm, (outs), (ins),
3847 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3850 //===----------------------------------------------------------------------===//
3851 // Alias Instructions
3852 //===----------------------------------------------------------------------===//
3854 // Alias instructions that map movr0 to xor.
3855 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3856 // FIXME: Set encoding to pseudo.
3857 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3858 isCodeGenOnly = 1 in {
3859 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
3860 [(set GR8:$dst, 0)]>;
3862 // We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3863 // encoding and avoids a partial-register update sometimes, but doing so
3864 // at isel time interferes with rematerialization in the current register
3865 // allocator. For now, this is rewritten when the instruction is lowered
3867 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3869 [(set GR16:$dst, 0)]>, OpSize;
3871 // FIXME: Set encoding to pseudo.
3872 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
3873 [(set GR32:$dst, 0)]>;
3876 //===----------------------------------------------------------------------===//
3877 // Thread Local Storage Instructions
3881 // All calls clobber the non-callee saved registers. ESP is marked as
3882 // a use to prevent stack-pointer assignments that appear immediately
3883 // before calls from potentially appearing dead.
3884 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3885 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3886 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3887 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3889 def TLS_addr32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
3890 "leal\t$sym, %eax; "
3891 "call\t___tls_get_addr@PLT",
3892 [(X86tlsaddr tls32addr:$sym)]>,
3893 Requires<[In32BitMode]>;
3895 // Darwin TLS Support
3896 // For i386, the address of the thunk is passed on the stack, on return the
3897 // address of the variable is in %eax. %ecx is trashed during the function
3898 // call. All other registers are preserved.
3899 let Defs = [EAX, ECX],
3901 usesCustomInserter = 1 in
3902 def TLSCall_32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
3904 [(X86TLSCall addr:$sym)]>,
3905 Requires<[In32BitMode]>;
3907 let AddedComplexity = 5, isCodeGenOnly = 1 in
3908 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3909 "movl\t%gs:$src, $dst",
3910 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3912 let AddedComplexity = 5, isCodeGenOnly = 1 in
3913 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3914 "movl\t%fs:$src, $dst",
3915 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3917 //===----------------------------------------------------------------------===//
3918 // EH Pseudo Instructions
3920 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3921 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3922 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3923 "ret\t#eh_return, addr: $addr",
3924 [(X86ehret GR32:$addr)]>;
3928 //===----------------------------------------------------------------------===//
3934 // TODO: Get this to fold the constant into the instruction.
3935 def OR32mrLocked : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$zero),
3937 "or{l}\t{$zero, $dst|$dst, $zero}",
3938 []>, Requires<[In32BitMode]>, LOCK;
3940 let hasSideEffects = 1 in {
3941 def Int_MemBarrier : I<0, Pseudo, (outs), (ins),
3943 [(X86MemBarrier)]>, Requires<[HasSSE2]>;
3946 // Atomic swap. These are just normal xchg instructions. But since a memory
3947 // operand is referenced, the atomicity is ensured.
3948 let Constraints = "$val = $dst" in {
3949 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3950 (ins GR32:$val, i32mem:$ptr),
3951 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3952 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3953 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3954 (ins GR16:$val, i16mem:$ptr),
3955 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3956 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3958 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3959 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3960 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3962 def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3963 "xchg{l}\t{$val, $src|$src, $val}", []>;
3964 def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3965 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3966 def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3967 "xchg{b}\t{$val, $src|$src, $val}", []>;
3970 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3971 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3972 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3973 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3975 // Atomic compare and swap.
3976 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3977 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3979 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3980 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3982 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3983 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
3986 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3989 let Defs = [AX, EFLAGS], Uses = [AX] in {
3990 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3992 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3993 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3995 let Defs = [AL, EFLAGS], Uses = [AL] in {
3996 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3998 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3999 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
4002 // Atomic exchange and add
4003 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
4004 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
4006 "xadd{l}\t{$val, $ptr|$ptr, $val}",
4007 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
4009 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
4011 "xadd{w}\t{$val, $ptr|$ptr, $val}",
4012 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
4014 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
4016 "xadd{b}\t{$val, $ptr|$ptr, $val}",
4017 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
4021 def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
4022 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
4023 def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
4024 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4025 def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4026 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
4028 let mayLoad = 1, mayStore = 1 in {
4029 def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
4030 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
4031 def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
4032 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4033 def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
4034 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
4037 def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
4038 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
4039 def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
4040 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4041 def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4042 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
4044 let mayLoad = 1, mayStore = 1 in {
4045 def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
4046 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
4047 def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
4048 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4049 def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
4050 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
4053 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
4054 def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
4055 "cmpxchg8b\t$dst", []>, TB;
4057 // Optimized codegen when the non-memory output is not used.
4058 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
4059 let Defs = [EFLAGS], mayLoad = 1, mayStore = 1 in {
4060 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
4062 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4063 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4065 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4066 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4068 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4069 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
4071 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4072 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
4074 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4075 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
4077 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4078 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
4080 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4081 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4083 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4085 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
4087 "inc{b}\t$dst", []>, LOCK;
4088 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
4090 "inc{w}\t$dst", []>, OpSize, LOCK;
4091 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
4093 "inc{l}\t$dst", []>, LOCK;
4095 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
4097 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4098 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4100 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4101 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4103 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4104 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
4106 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4107 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
4109 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4110 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
4112 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4113 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
4115 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4116 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4118 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4120 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
4122 "dec{b}\t$dst", []>, LOCK;
4123 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
4125 "dec{w}\t$dst", []>, OpSize, LOCK;
4126 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
4128 "dec{l}\t$dst", []>, LOCK;
4131 // Atomic exchange, and, or, xor
4132 let Constraints = "$val = $dst", Defs = [EFLAGS],
4133 usesCustomInserter = 1 in {
4134 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4135 "#ATOMAND32 PSEUDO!",
4136 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
4137 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4138 "#ATOMOR32 PSEUDO!",
4139 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
4140 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4141 "#ATOMXOR32 PSEUDO!",
4142 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
4143 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4144 "#ATOMNAND32 PSEUDO!",
4145 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
4146 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
4147 "#ATOMMIN32 PSEUDO!",
4148 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
4149 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4150 "#ATOMMAX32 PSEUDO!",
4151 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
4152 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4153 "#ATOMUMIN32 PSEUDO!",
4154 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
4155 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4156 "#ATOMUMAX32 PSEUDO!",
4157 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
4159 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4160 "#ATOMAND16 PSEUDO!",
4161 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
4162 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4163 "#ATOMOR16 PSEUDO!",
4164 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
4165 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4166 "#ATOMXOR16 PSEUDO!",
4167 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
4168 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4169 "#ATOMNAND16 PSEUDO!",
4170 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
4171 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
4172 "#ATOMMIN16 PSEUDO!",
4173 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
4174 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4175 "#ATOMMAX16 PSEUDO!",
4176 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
4177 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4178 "#ATOMUMIN16 PSEUDO!",
4179 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
4180 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4181 "#ATOMUMAX16 PSEUDO!",
4182 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
4184 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4185 "#ATOMAND8 PSEUDO!",
4186 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
4187 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4189 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
4190 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4191 "#ATOMXOR8 PSEUDO!",
4192 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
4193 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4194 "#ATOMNAND8 PSEUDO!",
4195 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
4198 let Constraints = "$val1 = $dst1, $val2 = $dst2",
4199 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4200 Uses = [EAX, EBX, ECX, EDX],
4201 mayLoad = 1, mayStore = 1,
4202 usesCustomInserter = 1 in {
4203 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4204 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4205 "#ATOMAND6432 PSEUDO!", []>;
4206 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4207 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4208 "#ATOMOR6432 PSEUDO!", []>;
4209 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4210 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4211 "#ATOMXOR6432 PSEUDO!", []>;
4212 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4213 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4214 "#ATOMNAND6432 PSEUDO!", []>;
4215 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4216 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4217 "#ATOMADD6432 PSEUDO!", []>;
4218 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4219 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4220 "#ATOMSUB6432 PSEUDO!", []>;
4221 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4222 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4223 "#ATOMSWAP6432 PSEUDO!", []>;
4226 // Segmentation support instructions.
4228 def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4229 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4230 def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4231 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4233 // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4234 def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4235 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4236 def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4237 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4239 def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4240 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4241 def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4242 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4243 def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4244 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4245 def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4246 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4248 def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
4250 def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4251 "str{w}\t{$dst}", []>, TB;
4252 def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4253 "str{w}\t{$dst}", []>, TB;
4254 def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4255 "ltr{w}\t{$src}", []>, TB;
4256 def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4257 "ltr{w}\t{$src}", []>, TB;
4259 def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4260 "push{w}\t%fs", []>, OpSize, TB;
4261 def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4262 "push{l}\t%fs", []>, TB;
4263 def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4264 "push{w}\t%gs", []>, OpSize, TB;
4265 def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4266 "push{l}\t%gs", []>, TB;
4268 def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4269 "pop{w}\t%fs", []>, OpSize, TB;
4270 def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4271 "pop{l}\t%fs", []>, TB;
4272 def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4273 "pop{w}\t%gs", []>, OpSize, TB;
4274 def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4275 "pop{l}\t%gs", []>, TB;
4277 def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4278 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4279 def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4280 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4281 def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4282 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4283 def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4284 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4285 def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4286 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4287 def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4288 "les{l}\t{$src, $dst|$dst, $src}", []>;
4289 def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4290 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4291 def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4292 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4293 def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4294 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4295 def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4296 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4298 def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4299 "verr\t$seg", []>, TB;
4300 def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4301 "verr\t$seg", []>, TB;
4302 def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4303 "verw\t$seg", []>, TB;
4304 def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4305 "verw\t$seg", []>, TB;
4307 // Descriptor-table support instructions
4309 def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4310 "sgdt\t$dst", []>, TB;
4311 def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4312 "sidt\t$dst", []>, TB;
4313 def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4314 "sldt{w}\t$dst", []>, TB;
4315 def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4316 "sldt{w}\t$dst", []>, TB;
4317 def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4318 "lgdt\t$src", []>, TB;
4319 def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4320 "lidt\t$src", []>, TB;
4321 def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4322 "lldt{w}\t$src", []>, TB;
4323 def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4324 "lldt{w}\t$src", []>, TB;
4326 // Lock instruction prefix
4327 def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4329 // Repeat string operation instruction prefixes
4330 // These uses the DF flag in the EFLAGS register to inc or dec ECX
4331 let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4332 // Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4333 def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4334 // Repeat while not equal (used with CMPS and SCAS)
4335 def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4338 // Segment override instruction prefixes
4339 def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4340 def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4341 def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4342 def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4343 def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4344 def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4346 // String manipulation instructions
4348 def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4349 def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
4350 def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4352 def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4353 def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4354 def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4356 // CPU flow control instructions
4358 def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4359 def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4361 // FPU control instructions
4363 def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4365 // Flag instructions
4367 def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4368 def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4369 def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4370 def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4371 def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4372 def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4373 def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4375 def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4377 // Table lookup instructions
4379 def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4381 // Specialized register support
4383 def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4384 def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4385 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4387 def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4388 "smsw{w}\t$dst", []>, OpSize, TB;
4389 def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4390 "smsw{l}\t$dst", []>, TB;
4391 // For memory operands, there is only a 16-bit form
4392 def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4393 "smsw{w}\t$dst", []>, TB;
4395 def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4396 "lmsw{w}\t$src", []>, TB;
4397 def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4398 "lmsw{w}\t$src", []>, TB;
4400 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4402 // Cache instructions
4404 def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4405 def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4410 def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
4412 def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
4414 def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
4415 def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4416 "vmclear\t$vmcs", []>, OpSize, TB;
4418 def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
4420 def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
4421 def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4422 "vmptrld\t$vmcs", []>, TB;
4423 def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4424 "vmptrst\t$vmcs", []>, TB;
4425 def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4426 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4427 def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4428 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4429 def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4430 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4431 def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4432 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4433 def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4434 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4435 def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4436 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4437 def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4438 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4439 def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4440 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4442 def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
4443 def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4444 "vmxon\t{$vmxon}", []>, XS;
4446 //===----------------------------------------------------------------------===//
4447 // Non-Instruction Patterns
4448 //===----------------------------------------------------------------------===//
4450 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
4451 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4452 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
4453 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
4454 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4455 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
4456 def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
4458 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4459 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4460 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4461 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4462 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4463 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4464 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4465 (ADD32ri GR32:$src1, texternalsym:$src2)>;
4466 def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4467 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
4469 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4470 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4471 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4472 (MOV32mi addr:$dst, texternalsym:$src)>;
4473 def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4474 (MOV32mi addr:$dst, tblockaddress:$src)>;
4478 def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4479 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4480 Requires<[In32BitMode]>;
4482 // FIXME: This is disabled for 32-bit PIC mode because the global base
4483 // register which is part of the address mode may be assigned a
4484 // callee-saved register.
4485 def : Pat<(X86tcret (load addr:$dst), imm:$off),
4486 (TCRETURNmi addr:$dst, imm:$off)>,
4487 Requires<[In32BitMode, IsNotPIC]>;
4489 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4490 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4491 Requires<[In32BitMode]>;
4493 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4494 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4495 Requires<[In32BitMode]>;
4497 // Normal calls, with various flavors of addresses.
4498 def : Pat<(X86call (i32 tglobaladdr:$dst)),
4499 (CALLpcrel32 tglobaladdr:$dst)>;
4500 def : Pat<(X86call (i32 texternalsym:$dst)),
4501 (CALLpcrel32 texternalsym:$dst)>;
4502 def : Pat<(X86call (i32 imm:$dst)),
4503 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
4505 // X86 specific add which produces a flag.
4506 def : Pat<(addc GR32:$src1, GR32:$src2),
4507 (ADD32rr GR32:$src1, GR32:$src2)>;
4508 def : Pat<(addc GR32:$src1, (load addr:$src2)),
4509 (ADD32rm GR32:$src1, addr:$src2)>;
4510 def : Pat<(addc GR32:$src1, imm:$src2),
4511 (ADD32ri GR32:$src1, imm:$src2)>;
4512 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4513 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4515 def : Pat<(subc GR32:$src1, GR32:$src2),
4516 (SUB32rr GR32:$src1, GR32:$src2)>;
4517 def : Pat<(subc GR32:$src1, (load addr:$src2)),
4518 (SUB32rm GR32:$src1, addr:$src2)>;
4519 def : Pat<(subc GR32:$src1, imm:$src2),
4520 (SUB32ri GR32:$src1, imm:$src2)>;
4521 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4522 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4526 // TEST R,R is smaller than CMP R,0
4527 def : Pat<(X86cmp GR8:$src1, 0),
4528 (TEST8rr GR8:$src1, GR8:$src1)>;
4529 def : Pat<(X86cmp GR16:$src1, 0),
4530 (TEST16rr GR16:$src1, GR16:$src1)>;
4531 def : Pat<(X86cmp GR32:$src1, 0),
4532 (TEST32rr GR32:$src1, GR32:$src1)>;
4534 // Conditional moves with folded loads with operands swapped and conditions
4536 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4537 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4538 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4539 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4540 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4541 (CMOVB16rm GR16:$src2, addr:$src1)>;
4542 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4543 (CMOVB32rm GR32:$src2, addr:$src1)>;
4544 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4545 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4546 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4547 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4548 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4549 (CMOVE16rm GR16:$src2, addr:$src1)>;
4550 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4551 (CMOVE32rm GR32:$src2, addr:$src1)>;
4552 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4553 (CMOVA16rm GR16:$src2, addr:$src1)>;
4554 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4555 (CMOVA32rm GR32:$src2, addr:$src1)>;
4556 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4557 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4558 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4559 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4560 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4561 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4562 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4563 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4564 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4565 (CMOVL16rm GR16:$src2, addr:$src1)>;
4566 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4567 (CMOVL32rm GR32:$src2, addr:$src1)>;
4568 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4569 (CMOVG16rm GR16:$src2, addr:$src1)>;
4570 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4571 (CMOVG32rm GR32:$src2, addr:$src1)>;
4572 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4573 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4574 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4575 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4576 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4577 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4578 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4579 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4580 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4581 (CMOVP16rm GR16:$src2, addr:$src1)>;
4582 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4583 (CMOVP32rm GR32:$src2, addr:$src1)>;
4584 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4585 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4586 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4587 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4588 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4589 (CMOVS16rm GR16:$src2, addr:$src1)>;
4590 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4591 (CMOVS32rm GR32:$src2, addr:$src1)>;
4592 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4593 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4594 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4595 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4596 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4597 (CMOVO16rm GR16:$src2, addr:$src1)>;
4598 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4599 (CMOVO32rm GR32:$src2, addr:$src1)>;
4601 // zextload bool -> zextload byte
4602 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4603 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4604 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4606 // extload bool -> extload byte
4607 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4608 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4609 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4610 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
4611 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4612 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4614 // anyext. Define these to do an explicit zero-extend to
4615 // avoid partial-register updates.
4616 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4617 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4619 // Except for i16 -> i32 since isel expect i16 ops to be promoted to i32.
4620 def : Pat<(i32 (anyext GR16:$src)),
4621 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, sub_16bit)>;
4624 //===----------------------------------------------------------------------===//
4626 //===----------------------------------------------------------------------===//
4628 // Odd encoding trick: -128 fits into an 8-bit immediate field while
4629 // +128 doesn't, so in this special case use a sub instead of an add.
4630 def : Pat<(add GR16:$src1, 128),
4631 (SUB16ri8 GR16:$src1, -128)>;
4632 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4633 (SUB16mi8 addr:$dst, -128)>;
4634 def : Pat<(add GR32:$src1, 128),
4635 (SUB32ri8 GR32:$src1, -128)>;
4636 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4637 (SUB32mi8 addr:$dst, -128)>;
4639 // r & (2^16-1) ==> movz
4640 def : Pat<(and GR32:$src1, 0xffff),
4641 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, sub_16bit))>;
4642 // r & (2^8-1) ==> movz
4643 def : Pat<(and GR32:$src1, 0xff),
4644 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4647 Requires<[In32BitMode]>;
4648 // r & (2^8-1) ==> movz
4649 def : Pat<(and GR16:$src1, 0xff),
4650 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4653 Requires<[In32BitMode]>;
4655 // sext_inreg patterns
4656 def : Pat<(sext_inreg GR32:$src, i16),
4657 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, sub_16bit))>;
4658 def : Pat<(sext_inreg GR32:$src, i8),
4659 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4662 Requires<[In32BitMode]>;
4663 def : Pat<(sext_inreg GR16:$src, i8),
4664 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4667 Requires<[In32BitMode]>;
4670 def : Pat<(i16 (trunc GR32:$src)),
4671 (EXTRACT_SUBREG GR32:$src, sub_16bit)>;
4672 def : Pat<(i8 (trunc GR32:$src)),
4673 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4675 Requires<[In32BitMode]>;
4676 def : Pat<(i8 (trunc GR16:$src)),
4677 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4679 Requires<[In32BitMode]>;
4681 // h-register tricks
4682 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
4683 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4685 Requires<[In32BitMode]>;
4686 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
4687 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4689 Requires<[In32BitMode]>;
4690 def : Pat<(srl GR16:$src, (i8 8)),
4693 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4696 Requires<[In32BitMode]>;
4697 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
4698 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4701 Requires<[In32BitMode]>;
4702 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
4703 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4706 Requires<[In32BitMode]>;
4707 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
4708 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4711 Requires<[In32BitMode]>;
4712 def : Pat<(srl (and_su GR32:$src, 0xff00), (i8 8)),
4713 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4716 Requires<[In32BitMode]>;
4718 // (shl x, 1) ==> (add x, x)
4719 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4720 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4721 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4723 // (shl x (and y, 31)) ==> (shl x, y)
4724 def : Pat<(shl GR8:$src1, (and CL, 31)),
4725 (SHL8rCL GR8:$src1)>;
4726 def : Pat<(shl GR16:$src1, (and CL, 31)),
4727 (SHL16rCL GR16:$src1)>;
4728 def : Pat<(shl GR32:$src1, (and CL, 31)),
4729 (SHL32rCL GR32:$src1)>;
4730 def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4731 (SHL8mCL addr:$dst)>;
4732 def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4733 (SHL16mCL addr:$dst)>;
4734 def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4735 (SHL32mCL addr:$dst)>;
4737 def : Pat<(srl GR8:$src1, (and CL, 31)),
4738 (SHR8rCL GR8:$src1)>;
4739 def : Pat<(srl GR16:$src1, (and CL, 31)),
4740 (SHR16rCL GR16:$src1)>;
4741 def : Pat<(srl GR32:$src1, (and CL, 31)),
4742 (SHR32rCL GR32:$src1)>;
4743 def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4744 (SHR8mCL addr:$dst)>;
4745 def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4746 (SHR16mCL addr:$dst)>;
4747 def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4748 (SHR32mCL addr:$dst)>;
4750 def : Pat<(sra GR8:$src1, (and CL, 31)),
4751 (SAR8rCL GR8:$src1)>;
4752 def : Pat<(sra GR16:$src1, (and CL, 31)),
4753 (SAR16rCL GR16:$src1)>;
4754 def : Pat<(sra GR32:$src1, (and CL, 31)),
4755 (SAR32rCL GR32:$src1)>;
4756 def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4757 (SAR8mCL addr:$dst)>;
4758 def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4759 (SAR16mCL addr:$dst)>;
4760 def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4761 (SAR32mCL addr:$dst)>;
4763 // (anyext (setcc_carry)) -> (setcc_carry)
4764 def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4766 def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4768 def : Pat<(i32 (anyext (i16 (X86setcc_c X86_COND_B, EFLAGS)))),
4771 // (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
4772 let AddedComplexity = 5 in { // Try this before the selecting to OR
4773 def : Pat<(or_is_add GR16:$src1, imm:$src2),
4774 (ADD16ri GR16:$src1, imm:$src2)>;
4775 def : Pat<(or_is_add GR32:$src1, imm:$src2),
4776 (ADD32ri GR32:$src1, imm:$src2)>;
4777 def : Pat<(or_is_add GR16:$src1, i16immSExt8:$src2),
4778 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4779 def : Pat<(or_is_add GR32:$src1, i32immSExt8:$src2),
4780 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4781 def : Pat<(or_is_add GR16:$src1, GR16:$src2),
4782 (ADD16rr GR16:$src1, GR16:$src2)>;
4783 def : Pat<(or_is_add GR32:$src1, GR32:$src2),
4784 (ADD32rr GR32:$src1, GR32:$src2)>;
4785 } // AddedComplexity
4787 //===----------------------------------------------------------------------===//
4788 // EFLAGS-defining Patterns
4789 //===----------------------------------------------------------------------===//
4792 def : Pat<(add GR8 :$src1, GR8 :$src2), (ADD8rr GR8 :$src1, GR8 :$src2)>;
4793 def : Pat<(add GR16:$src1, GR16:$src2), (ADD16rr GR16:$src1, GR16:$src2)>;
4794 def : Pat<(add GR32:$src1, GR32:$src2), (ADD32rr GR32:$src1, GR32:$src2)>;
4797 def : Pat<(add GR8:$src1, (loadi8 addr:$src2)),
4798 (ADD8rm GR8:$src1, addr:$src2)>;
4799 def : Pat<(add GR16:$src1, (loadi16 addr:$src2)),
4800 (ADD16rm GR16:$src1, addr:$src2)>;
4801 def : Pat<(add GR32:$src1, (loadi32 addr:$src2)),
4802 (ADD32rm GR32:$src1, addr:$src2)>;
4805 def : Pat<(add GR8 :$src1, imm:$src2), (ADD8ri GR8:$src1 , imm:$src2)>;
4806 def : Pat<(add GR16:$src1, imm:$src2), (ADD16ri GR16:$src1, imm:$src2)>;
4807 def : Pat<(add GR32:$src1, imm:$src2), (ADD32ri GR32:$src1, imm:$src2)>;
4808 def : Pat<(add GR16:$src1, i16immSExt8:$src2),
4809 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4810 def : Pat<(add GR32:$src1, i32immSExt8:$src2),
4811 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4814 def : Pat<(sub GR8 :$src1, GR8 :$src2), (SUB8rr GR8 :$src1, GR8 :$src2)>;
4815 def : Pat<(sub GR16:$src1, GR16:$src2), (SUB16rr GR16:$src1, GR16:$src2)>;
4816 def : Pat<(sub GR32:$src1, GR32:$src2), (SUB32rr GR32:$src1, GR32:$src2)>;
4819 def : Pat<(sub GR8:$src1, (loadi8 addr:$src2)),
4820 (SUB8rm GR8:$src1, addr:$src2)>;
4821 def : Pat<(sub GR16:$src1, (loadi16 addr:$src2)),
4822 (SUB16rm GR16:$src1, addr:$src2)>;
4823 def : Pat<(sub GR32:$src1, (loadi32 addr:$src2)),
4824 (SUB32rm GR32:$src1, addr:$src2)>;
4827 def : Pat<(sub GR8:$src1, imm:$src2),
4828 (SUB8ri GR8:$src1, imm:$src2)>;
4829 def : Pat<(sub GR16:$src1, imm:$src2),
4830 (SUB16ri GR16:$src1, imm:$src2)>;
4831 def : Pat<(sub GR32:$src1, imm:$src2),
4832 (SUB32ri GR32:$src1, imm:$src2)>;
4833 def : Pat<(sub GR16:$src1, i16immSExt8:$src2),
4834 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4835 def : Pat<(sub GR32:$src1, i32immSExt8:$src2),
4836 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4839 def : Pat<(mul GR16:$src1, GR16:$src2),
4840 (IMUL16rr GR16:$src1, GR16:$src2)>;
4841 def : Pat<(mul GR32:$src1, GR32:$src2),
4842 (IMUL32rr GR32:$src1, GR32:$src2)>;
4845 def : Pat<(mul GR16:$src1, (loadi16 addr:$src2)),
4846 (IMUL16rm GR16:$src1, addr:$src2)>;
4847 def : Pat<(mul GR32:$src1, (loadi32 addr:$src2)),
4848 (IMUL32rm GR32:$src1, addr:$src2)>;
4851 def : Pat<(mul GR16:$src1, imm:$src2),
4852 (IMUL16rri GR16:$src1, imm:$src2)>;
4853 def : Pat<(mul GR32:$src1, imm:$src2),
4854 (IMUL32rri GR32:$src1, imm:$src2)>;
4855 def : Pat<(mul GR16:$src1, i16immSExt8:$src2),
4856 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4857 def : Pat<(mul GR32:$src1, i32immSExt8:$src2),
4858 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4860 // reg = mul mem, imm
4861 def : Pat<(mul (loadi16 addr:$src1), imm:$src2),
4862 (IMUL16rmi addr:$src1, imm:$src2)>;
4863 def : Pat<(mul (loadi32 addr:$src1), imm:$src2),
4864 (IMUL32rmi addr:$src1, imm:$src2)>;
4865 def : Pat<(mul (loadi16 addr:$src1), i16immSExt8:$src2),
4866 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4867 def : Pat<(mul (loadi32 addr:$src1), i32immSExt8:$src2),
4868 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4870 // Optimize multiply by 2 with EFLAGS result.
4871 let AddedComplexity = 2 in {
4872 def : Pat<(X86smul_flag GR16:$src1, 2), (ADD16rr GR16:$src1, GR16:$src1)>;
4873 def : Pat<(X86smul_flag GR32:$src1, 2), (ADD32rr GR32:$src1, GR32:$src1)>;
4876 // Patterns for nodes that do not produce flags, for instructions that do.
4879 def : Pat<(add GR8:$src1 , 1), (INC8r GR8:$src1)>;
4880 def : Pat<(add GR16:$src1, 1), (INC16r GR16:$src1)>, Requires<[In32BitMode]>;
4881 def : Pat<(add GR32:$src1, 1), (INC32r GR32:$src1)>, Requires<[In32BitMode]>;
4884 def : Pat<(add GR8:$src1 , -1), (DEC8r GR8:$src1)>;
4885 def : Pat<(add GR16:$src1, -1), (DEC16r GR16:$src1)>, Requires<[In32BitMode]>;
4886 def : Pat<(add GR32:$src1, -1), (DEC32r GR32:$src1)>, Requires<[In32BitMode]>;
4889 def : Pat<(or GR8 :$src1, GR8 :$src2), (OR8rr GR8 :$src1, GR8 :$src2)>;
4890 def : Pat<(or GR16:$src1, GR16:$src2), (OR16rr GR16:$src1, GR16:$src2)>;
4891 def : Pat<(or GR32:$src1, GR32:$src2), (OR32rr GR32:$src1, GR32:$src2)>;
4894 def : Pat<(or GR8:$src1, (loadi8 addr:$src2)),
4895 (OR8rm GR8:$src1, addr:$src2)>;
4896 def : Pat<(or GR16:$src1, (loadi16 addr:$src2)),
4897 (OR16rm GR16:$src1, addr:$src2)>;
4898 def : Pat<(or GR32:$src1, (loadi32 addr:$src2)),
4899 (OR32rm GR32:$src1, addr:$src2)>;
4902 def : Pat<(or GR8:$src1 , imm:$src2), (OR8ri GR8 :$src1, imm:$src2)>;
4903 def : Pat<(or GR16:$src1, imm:$src2), (OR16ri GR16:$src1, imm:$src2)>;
4904 def : Pat<(or GR32:$src1, imm:$src2), (OR32ri GR32:$src1, imm:$src2)>;
4905 def : Pat<(or GR16:$src1, i16immSExt8:$src2),
4906 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4907 def : Pat<(or GR32:$src1, i32immSExt8:$src2),
4908 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4911 def : Pat<(xor GR8 :$src1, GR8 :$src2), (XOR8rr GR8 :$src1, GR8 :$src2)>;
4912 def : Pat<(xor GR16:$src1, GR16:$src2), (XOR16rr GR16:$src1, GR16:$src2)>;
4913 def : Pat<(xor GR32:$src1, GR32:$src2), (XOR32rr GR32:$src1, GR32:$src2)>;
4916 def : Pat<(xor GR8:$src1, (loadi8 addr:$src2)),
4917 (XOR8rm GR8:$src1, addr:$src2)>;
4918 def : Pat<(xor GR16:$src1, (loadi16 addr:$src2)),
4919 (XOR16rm GR16:$src1, addr:$src2)>;
4920 def : Pat<(xor GR32:$src1, (loadi32 addr:$src2)),
4921 (XOR32rm GR32:$src1, addr:$src2)>;
4924 def : Pat<(xor GR8:$src1, imm:$src2),
4925 (XOR8ri GR8:$src1, imm:$src2)>;
4926 def : Pat<(xor GR16:$src1, imm:$src2),
4927 (XOR16ri GR16:$src1, imm:$src2)>;
4928 def : Pat<(xor GR32:$src1, imm:$src2),
4929 (XOR32ri GR32:$src1, imm:$src2)>;
4930 def : Pat<(xor GR16:$src1, i16immSExt8:$src2),
4931 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4932 def : Pat<(xor GR32:$src1, i32immSExt8:$src2),
4933 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4936 def : Pat<(and GR8 :$src1, GR8 :$src2), (AND8rr GR8 :$src1, GR8 :$src2)>;
4937 def : Pat<(and GR16:$src1, GR16:$src2), (AND16rr GR16:$src1, GR16:$src2)>;
4938 def : Pat<(and GR32:$src1, GR32:$src2), (AND32rr GR32:$src1, GR32:$src2)>;
4941 def : Pat<(and GR8:$src1, (loadi8 addr:$src2)),
4942 (AND8rm GR8:$src1, addr:$src2)>;
4943 def : Pat<(and GR16:$src1, (loadi16 addr:$src2)),
4944 (AND16rm GR16:$src1, addr:$src2)>;
4945 def : Pat<(and GR32:$src1, (loadi32 addr:$src2)),
4946 (AND32rm GR32:$src1, addr:$src2)>;
4949 def : Pat<(and GR8:$src1, imm:$src2),
4950 (AND8ri GR8:$src1, imm:$src2)>;
4951 def : Pat<(and GR16:$src1, imm:$src2),
4952 (AND16ri GR16:$src1, imm:$src2)>;
4953 def : Pat<(and GR32:$src1, imm:$src2),
4954 (AND32ri GR32:$src1, imm:$src2)>;
4955 def : Pat<(and GR16:$src1, i16immSExt8:$src2),
4956 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
4957 def : Pat<(and GR32:$src1, i32immSExt8:$src2),
4958 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4960 //===----------------------------------------------------------------------===//
4961 // Floating Point Stack Support
4962 //===----------------------------------------------------------------------===//
4964 include "X86InstrFPStack.td"
4966 //===----------------------------------------------------------------------===//
4968 //===----------------------------------------------------------------------===//
4970 include "X86Instr64bit.td"
4972 //===----------------------------------------------------------------------===//
4973 // SIMD support (SSE, MMX and AVX)
4974 //===----------------------------------------------------------------------===//
4976 include "X86InstrFragmentsSIMD.td"
4978 //===----------------------------------------------------------------------===//
4979 // FMA - Fused Multiply-Add support (requires FMA)
4980 //===----------------------------------------------------------------------===//
4982 include "X86InstrFMA.td"
4984 //===----------------------------------------------------------------------===//
4985 // XMM Floating point support (requires SSE / SSE2)
4986 //===----------------------------------------------------------------------===//
4988 include "X86InstrSSE.td"
4990 //===----------------------------------------------------------------------===//
4991 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4992 //===----------------------------------------------------------------------===//
4994 include "X86InstrMMX.td"