1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86 instruction set, defining the instructions, and
11 // properties of the instructions which are needed for code generation, machine
12 // code emission, and analysis.
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
17 // X86 specific DAG Nodes.
20 def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
24 def SDTX86CmpTest : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisSameAs<1, 2>]>;
26 def SDTX86Cmov : SDTypeProfile<1, 4,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
30 // Unary and binary operator instructions that set EFLAGS as a side-effect.
31 def SDTUnaryArithWithFlags : SDTypeProfile<2, 1,
32 [SDTCisInt<0>, SDTCisVT<1, i32>]>;
34 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
37 SDTCisInt<0>, SDTCisVT<1, i32>]>;
38 def SDTX86BrCond : SDTypeProfile<0, 3,
39 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
42 def SDTX86SetCC : SDTypeProfile<1, 2,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
45 def SDTX86SetCC_C : SDTypeProfile<1, 2,
47 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
49 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
51 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
53 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
54 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
55 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
57 def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
58 def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
61 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
63 def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
67 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
69 def SDTX86Void : SDTypeProfile<0, 0, []>;
71 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
73 def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
75 def SDT_X86TLSCALL : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
77 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
79 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
81 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
83 def X86bsf : SDNode<"X86ISD::BSF", SDTUnaryArithWithFlags>;
84 def X86bsr : SDNode<"X86ISD::BSR", SDTUnaryArithWithFlags>;
85 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
86 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
88 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
89 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
91 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
92 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
94 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
95 def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
97 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
98 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
100 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
101 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
103 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
112 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
115 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
116 [SDNPHasChain, SDNPMayStore,
117 SDNPMayLoad, SDNPMemOperand]>;
118 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
119 [SDNPHasChain, SDNPMayStore,
120 SDNPMayLoad, SDNPMemOperand]>;
121 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
122 [SDNPHasChain, SDNPMayStore,
123 SDNPMayLoad, SDNPMemOperand]>;
124 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
125 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
127 def X86vastart_save_xmm_regs :
128 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
129 SDT_X86VASTART_SAVE_XMM_REGS,
130 [SDNPHasChain, SDNPVariadic]>;
132 def X86callseq_start :
133 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
134 [SDNPHasChain, SDNPOutFlag]>;
136 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
137 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
139 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
140 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag,
143 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
144 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
145 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
146 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
149 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
150 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
152 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
153 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
155 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
156 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
157 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
158 SDT_X86SegmentBaseAddress, []>;
160 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
163 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
164 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
166 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
168 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
169 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
171 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
174 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
175 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
176 def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
178 def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
180 def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
183 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
185 def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
186 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
188 def X86TLSCall : SDNode<"X86ISD::TLSCALL", SDT_X86TLSCALL,
191 //===----------------------------------------------------------------------===//
192 // X86 Operand Definitions.
195 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
196 // the index operand of an address, to conform to x86 encoding restrictions.
197 def ptr_rc_nosp : PointerLikeRegClass<1>;
199 // *mem - Operand definitions for the funky X86 addressing mode operands.
201 def X86MemAsmOperand : AsmOperandClass {
203 let SuperClasses = [];
205 def X86AbsMemAsmOperand : AsmOperandClass {
207 let SuperClasses = [X86MemAsmOperand];
209 class X86MemOperand<string printMethod> : Operand<iPTR> {
210 let PrintMethod = printMethod;
211 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
212 let ParserMatchClass = X86MemAsmOperand;
215 def opaque32mem : X86MemOperand<"printopaquemem">;
216 def opaque48mem : X86MemOperand<"printopaquemem">;
217 def opaque80mem : X86MemOperand<"printopaquemem">;
218 def opaque512mem : X86MemOperand<"printopaquemem">;
220 def i8mem : X86MemOperand<"printi8mem">;
221 def i16mem : X86MemOperand<"printi16mem">;
222 def i32mem : X86MemOperand<"printi32mem">;
223 def i64mem : X86MemOperand<"printi64mem">;
224 def i128mem : X86MemOperand<"printi128mem">;
225 //def i256mem : X86MemOperand<"printi256mem">;
226 def f32mem : X86MemOperand<"printf32mem">;
227 def f64mem : X86MemOperand<"printf64mem">;
228 def f80mem : X86MemOperand<"printf80mem">;
229 def f128mem : X86MemOperand<"printf128mem">;
230 def f256mem : X86MemOperand<"printf256mem">;
232 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
233 // plain GR64, so that it doesn't potentially require a REX prefix.
234 def i8mem_NOREX : Operand<i64> {
235 let PrintMethod = "printi8mem";
236 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
237 let ParserMatchClass = X86MemAsmOperand;
240 // Special i32mem for addresses of load folding tail calls. These are not
241 // allowed to use callee-saved registers since they must be scheduled
242 // after callee-saved register are popped.
243 def i32mem_TC : Operand<i32> {
244 let PrintMethod = "printi32mem";
245 let MIOperandInfo = (ops GR32_TC, i8imm, GR32_TC, i32imm, i8imm);
246 let ParserMatchClass = X86MemAsmOperand;
250 let ParserMatchClass = X86AbsMemAsmOperand,
251 PrintMethod = "print_pcrel_imm" in {
252 def i32imm_pcrel : Operand<i32>;
253 def i16imm_pcrel : Operand<i16>;
255 def offset8 : Operand<i64>;
256 def offset16 : Operand<i64>;
257 def offset32 : Operand<i64>;
258 def offset64 : Operand<i64>;
260 // Branch targets have OtherVT type and print as pc-relative values.
261 def brtarget : Operand<OtherVT>;
262 def brtarget8 : Operand<OtherVT>;
266 def SSECC : Operand<i8> {
267 let PrintMethod = "printSSECC";
270 class ImmSExtAsmOperandClass : AsmOperandClass {
271 let SuperClasses = [ImmAsmOperand];
272 let RenderMethod = "addImmOperands";
275 // Sign-extended immediate classes. We don't need to define the full lattice
276 // here because there is no instruction with an ambiguity between ImmSExti64i32
279 // The strange ranges come from the fact that the assembler always works with
280 // 64-bit immediates, but for a 16-bit target value we want to accept both "-1"
281 // (which will be a -1ULL), and "0xFF" (-1 in 16-bits).
284 // [0xFFFFFFFF80000000, 0xFFFFFFFFFFFFFFFF]
285 def ImmSExti64i32AsmOperand : ImmSExtAsmOperandClass {
286 let Name = "ImmSExti64i32";
289 // [0, 0x0000007F] | [0x000000000000FF80, 0x000000000000FFFF] |
290 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
291 def ImmSExti16i8AsmOperand : ImmSExtAsmOperandClass {
292 let Name = "ImmSExti16i8";
293 let SuperClasses = [ImmSExti64i32AsmOperand];
296 // [0, 0x0000007F] | [0x00000000FFFFFF80, 0x00000000FFFFFFFF] |
297 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
298 def ImmSExti32i8AsmOperand : ImmSExtAsmOperandClass {
299 let Name = "ImmSExti32i8";
303 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
304 def ImmSExti64i8AsmOperand : ImmSExtAsmOperandClass {
305 let Name = "ImmSExti64i8";
306 let SuperClasses = [ImmSExti16i8AsmOperand, ImmSExti32i8AsmOperand,
307 ImmSExti64i32AsmOperand];
310 // A couple of more descriptive operand definitions.
311 // 16-bits but only 8 bits are significant.
312 def i16i8imm : Operand<i16> {
313 let ParserMatchClass = ImmSExti16i8AsmOperand;
315 // 32-bits but only 8 bits are significant.
316 def i32i8imm : Operand<i32> {
317 let ParserMatchClass = ImmSExti32i8AsmOperand;
320 //===----------------------------------------------------------------------===//
321 // X86 Complex Pattern Definitions.
324 // Define X86 specific addressing mode.
325 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
326 def lea32addr : ComplexPattern<i32, 5, "SelectLEAAddr",
327 [add, sub, mul, X86mul_imm, shl, or, frameindex],
329 def tls32addr : ComplexPattern<i32, 5, "SelectTLSADDRAddr",
330 [tglobaltlsaddr], []>;
332 //===----------------------------------------------------------------------===//
333 // X86 Instruction Predicate Definitions.
334 def HasCMov : Predicate<"Subtarget->hasCMov()">;
335 def NoCMov : Predicate<"!Subtarget->hasCMov()">;
336 def HasMMX : Predicate<"Subtarget->hasMMX()">;
337 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
338 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
339 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
340 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
341 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
342 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
343 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
344 def HasAVX : Predicate<"Subtarget->hasAVX()">;
345 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
346 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
347 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
348 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
349 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
350 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
351 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
352 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
353 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
354 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
355 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
356 "TM.getCodeModel() != CodeModel::Kernel">;
357 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
358 "TM.getCodeModel() == CodeModel::Kernel">;
359 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
360 def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
361 def OptForSize : Predicate<"OptForSize">;
362 def OptForSpeed : Predicate<"!OptForSize">;
363 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
364 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
365 def HasAES : Predicate<"Subtarget->hasAES()">;
367 //===----------------------------------------------------------------------===//
368 // X86 Instruction Format Definitions.
371 include "X86InstrFormats.td"
373 //===----------------------------------------------------------------------===//
374 // Pattern fragments...
377 // X86 specific condition code. These correspond to CondCode in
378 // X86InstrInfo.h. They must be kept in synch.
379 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
380 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
381 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
382 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
383 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
384 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
385 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
386 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
387 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
388 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
389 def X86_COND_NO : PatLeaf<(i8 10)>;
390 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
391 def X86_COND_NS : PatLeaf<(i8 12)>;
392 def X86_COND_O : PatLeaf<(i8 13)>;
393 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
394 def X86_COND_S : PatLeaf<(i8 15)>;
396 def immSext8 : PatLeaf<(imm), [{
397 return N->getSExtValue() == (int8_t)N->getSExtValue();
400 def i16immSExt8 : PatLeaf<(i16 immSext8)>;
401 def i32immSExt8 : PatLeaf<(i32 immSext8)>;
403 /// Load patterns: these constraint the match to the right address space.
404 def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
405 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
406 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
407 if (PT->getAddressSpace() > 255)
412 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
413 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
414 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
415 return PT->getAddressSpace() == 256;
419 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
420 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
421 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
422 return PT->getAddressSpace() == 257;
427 // Helper fragments for loads.
428 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
429 // known to be 32-bit aligned or better. Ditto for i8 to i16.
430 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
431 LoadSDNode *LD = cast<LoadSDNode>(N);
432 if (const Value *Src = LD->getSrcValue())
433 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
434 if (PT->getAddressSpace() > 255)
436 ISD::LoadExtType ExtType = LD->getExtensionType();
437 if (ExtType == ISD::NON_EXTLOAD)
439 if (ExtType == ISD::EXTLOAD)
440 return LD->getAlignment() >= 2 && !LD->isVolatile();
444 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
445 LoadSDNode *LD = cast<LoadSDNode>(N);
446 if (const Value *Src = LD->getSrcValue())
447 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
448 if (PT->getAddressSpace() > 255)
450 ISD::LoadExtType ExtType = LD->getExtensionType();
451 if (ExtType == ISD::EXTLOAD)
452 return LD->getAlignment() >= 2 && !LD->isVolatile();
456 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
457 LoadSDNode *LD = cast<LoadSDNode>(N);
458 if (const Value *Src = LD->getSrcValue())
459 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
460 if (PT->getAddressSpace() > 255)
462 ISD::LoadExtType ExtType = LD->getExtensionType();
463 if (ExtType == ISD::NON_EXTLOAD)
465 if (ExtType == ISD::EXTLOAD)
466 return LD->getAlignment() >= 4 && !LD->isVolatile();
470 def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
471 def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
472 def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
473 def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
474 def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
476 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
477 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
478 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
480 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
481 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
482 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
483 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
484 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
485 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
487 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
488 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
489 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
490 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
491 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
492 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
495 // An 'and' node with a single use.
496 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
497 return N->hasOneUse();
499 // An 'srl' node with a single use.
500 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
501 return N->hasOneUse();
503 // An 'trunc' node with a single use.
504 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
505 return N->hasOneUse();
508 // Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
509 def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
510 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
511 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
513 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
514 APInt Mask = APInt::getAllOnesValue(BitWidth);
515 APInt KnownZero0, KnownOne0;
516 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
517 APInt KnownZero1, KnownOne1;
518 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
519 return (~KnownZero0 & ~KnownZero1) == 0;
522 //===----------------------------------------------------------------------===//
523 // Instruction list...
526 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
527 // a stack adjustment and the codegen must know that they may modify the stack
528 // pointer before prolog-epilog rewriting occurs.
529 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
530 // sub / add which can clobber EFLAGS.
531 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
532 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
534 [(X86callseq_start timm:$amt)]>,
535 Requires<[In32BitMode]>;
536 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
538 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
539 Requires<[In32BitMode]>;
542 // x86-64 va_start lowering magic.
543 let usesCustomInserter = 1 in {
544 def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
547 i64imm:$regsavefi, i64imm:$offset,
549 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
550 [(X86vastart_save_xmm_regs GR8:$al,
554 // Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls
555 // to _alloca is needed to probe the stack when allocating more than 4k bytes in
556 // one go. Touching the stack at 4K increments is necessary to ensure that the
557 // guard pages used by the OS virtual memory manager are allocated in correct
559 // The main point of having separate instruction are extra unmodelled effects
560 // (compared to ordinary calls) like stack pointer change.
562 def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
563 "# dynamic stack allocation",
568 let neverHasSideEffects = 1 in {
569 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
570 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
571 "nop{w}\t$zero", []>, TB, OpSize;
572 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
573 "nop{l}\t$zero", []>, TB;
577 def INTO : I<0xce, RawFrm, (outs), (ins), "into", []>;
578 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int3", []>;
579 // FIXME: need to make sure that "int $3" matches int3
580 def INT : Ii8<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
581 def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
582 def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
584 // PIC base construction. This expands to code that looks like this:
587 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
588 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
591 //===----------------------------------------------------------------------===//
592 // Control Flow Instructions.
595 // Return instructions.
596 let isTerminator = 1, isReturn = 1, isBarrier = 1,
597 hasCtrlDep = 1, FPForm = SpecialFP in {
598 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
601 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
603 [(X86retflag timm:$amt)]>;
604 def LRET : I <0xCB, RawFrm, (outs), (ins),
606 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
610 // Unconditional branches.
611 let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
612 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
613 "jmp\t$dst", [(br bb:$dst)]>;
614 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
618 // Conditional Branches.
619 let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
620 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
621 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
622 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
623 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
627 defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
628 defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
629 defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
630 defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
631 defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
632 defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
633 defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
634 defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
635 defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
636 defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
637 defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
638 defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
639 defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
640 defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
641 defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
642 defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
644 // FIXME: What about the CX/RCX versions of this instruction?
645 let Uses = [ECX], isBranch = 1, isTerminator = 1 in
646 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
651 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
652 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
653 [(brind GR32:$dst)]>;
654 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
655 [(brind (loadi32 addr:$dst))]>;
657 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
658 (ins i16imm:$seg, i16imm:$off),
659 "ljmp{w}\t$seg, $off", []>, OpSize;
660 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
661 (ins i16imm:$seg, i32imm:$off),
662 "ljmp{l}\t$seg, $off", []>;
664 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
665 "ljmp{w}\t{*}$dst", []>, OpSize;
666 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
667 "ljmp{l}\t{*}$dst", []>;
673 def LOOP : I<0xE2, RawFrm, (outs), (ins brtarget8:$dst), "loop\t$dst", []>;
674 def LOOPE : I<0xE1, RawFrm, (outs), (ins brtarget8:$dst), "loope\t$dst", []>;
675 def LOOPNE : I<0xE0, RawFrm, (outs), (ins brtarget8:$dst), "loopne\t$dst", []>;
677 //===----------------------------------------------------------------------===//
678 // Call Instructions...
681 // All calls clobber the non-callee saved registers. ESP is marked as
682 // a use to prevent stack-pointer assignments that appear immediately
683 // before calls from potentially appearing dead. Uses for argument
684 // registers are added manually.
685 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
686 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
687 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
688 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
690 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
691 (outs), (ins i32imm_pcrel:$dst,variable_ops),
693 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
694 "call\t{*}$dst", [(X86call GR32:$dst)]>;
695 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
696 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
698 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
699 (ins i16imm:$seg, i16imm:$off),
700 "lcall{w}\t$seg, $off", []>, OpSize;
701 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
702 (ins i16imm:$seg, i32imm:$off),
703 "lcall{l}\t$seg, $off", []>;
705 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
706 "lcall{w}\t{*}$dst", []>, OpSize;
707 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
708 "lcall{l}\t{*}$dst", []>;
710 // callw for 16 bit code for the assembler.
711 let isAsmParserOnly = 1 in
712 def CALLpcrel16 : Ii16PCRel<0xE8, RawFrm,
713 (outs), (ins i16imm_pcrel:$dst, variable_ops),
714 "callw\t$dst", []>, OpSize;
717 // Constructing a stack frame.
719 def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
720 "enter\t$len, $lvl", []>;
724 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
725 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
726 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
727 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
728 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
730 def TCRETURNdi : I<0, Pseudo, (outs),
731 (ins i32imm_pcrel:$dst, i32imm:$offset, variable_ops),
732 "#TC_RETURN $dst $offset", []>;
733 def TCRETURNri : I<0, Pseudo, (outs),
734 (ins GR32_TC:$dst, i32imm:$offset, variable_ops),
735 "#TC_RETURN $dst $offset", []>;
737 def TCRETURNmi : I<0, Pseudo, (outs),
738 (ins i32mem_TC:$dst, i32imm:$offset, variable_ops),
739 "#TC_RETURN $dst $offset", []>;
741 // FIXME: The should be pseudo instructions that are lowered when going to
743 def TAILJMPd : Ii32PCRel<0xE9, RawFrm, (outs),
744 (ins i32imm_pcrel:$dst, variable_ops),
745 "jmp\t$dst # TAILCALL",
747 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32_TC:$dst, variable_ops),
748 "", []>; // FIXME: Remove encoding when JIT is dead.
750 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
751 "jmp{l}\t{*}$dst # TAILCALL", []>;
754 //===----------------------------------------------------------------------===//
755 // Miscellaneous Instructions...
757 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
758 def LEAVE : I<0xC9, RawFrm,
759 (outs), (ins), "leave", []>;
761 def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
762 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
764 def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
765 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
766 def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
767 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
769 def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
770 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
772 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
774 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
776 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
777 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
779 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
781 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
782 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
785 let mayStore = 1 in {
786 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
788 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
789 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
791 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
793 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
794 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
798 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
799 def PUSHi8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
800 "push{l}\t$imm", []>;
801 def PUSHi16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
802 "push{w}\t$imm", []>, OpSize;
803 def PUSHi32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
804 "push{l}\t$imm", []>;
807 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
808 def POPF16 : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
809 def POPF32 : I<0x9D, RawFrm, (outs), (ins), "popf{l|d}", []>,
810 Requires<[In32BitMode]>;
812 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
813 def PUSHF16 : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
814 def PUSHF32 : I<0x9C, RawFrm, (outs), (ins), "pushf{l|d}", []>,
815 Requires<[In32BitMode]>;
818 let Defs = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], Uses = [ESP],
819 mayLoad=1, neverHasSideEffects=1 in {
820 def POPA32 : I<0x61, RawFrm, (outs), (ins), "popa{l}", []>,
821 Requires<[In32BitMode]>;
823 let Defs = [ESP], Uses = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP],
824 mayStore=1, neverHasSideEffects=1 in {
825 def PUSHA32 : I<0x60, RawFrm, (outs), (ins), "pusha{l}", []>,
826 Requires<[In32BitMode]>;
829 let Uses = [EFLAGS], Constraints = "$src = $dst" in // GR32 = bswap GR32
830 def BSWAP32r : I<0xC8, AddRegFrm,
831 (outs GR32:$dst), (ins GR32:$src),
833 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
836 // Bit scan instructions.
837 let Defs = [EFLAGS] in {
838 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
839 "bsf{w}\t{$src, $dst|$dst, $src}",
840 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB, OpSize;
841 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
842 "bsf{w}\t{$src, $dst|$dst, $src}",
843 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB,
845 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
846 "bsf{l}\t{$src, $dst|$dst, $src}",
847 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
848 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
849 "bsf{l}\t{$src, $dst|$dst, $src}",
850 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
852 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
853 "bsr{w}\t{$src, $dst|$dst, $src}",
854 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB, OpSize;
855 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
856 "bsr{w}\t{$src, $dst|$dst, $src}",
857 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB,
859 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
860 "bsr{l}\t{$src, $dst|$dst, $src}",
861 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
862 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
863 "bsr{l}\t{$src, $dst|$dst, $src}",
864 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
867 let neverHasSideEffects = 1 in
868 def LEA16r : I<0x8D, MRMSrcMem,
869 (outs GR16:$dst), (ins i32mem:$src),
870 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
871 let isReMaterializable = 1 in
872 def LEA32r : I<0x8D, MRMSrcMem,
873 (outs GR32:$dst), (ins i32mem:$src),
874 "lea{l}\t{$src|$dst}, {$dst|$src}",
875 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
877 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
878 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
879 [(X86rep_movs i8)]>, REP;
880 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
881 [(X86rep_movs i16)]>, REP, OpSize;
882 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
883 [(X86rep_movs i32)]>, REP;
886 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
887 let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
888 def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
889 def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
890 def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
893 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
894 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
895 [(X86rep_stos i8)]>, REP;
896 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
897 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
898 [(X86rep_stos i16)]>, REP, OpSize;
899 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
900 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
901 [(X86rep_stos i32)]>, REP;
903 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
904 let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
905 def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
906 let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
907 def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
908 let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
909 def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
911 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
912 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
913 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
915 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
916 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
917 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
919 let Defs = [RAX, RDX] in
920 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
923 let Defs = [RAX, RCX, RDX] in
924 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
926 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in {
927 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
930 def SYSCALL : I<0x05, RawFrm,
931 (outs), (ins), "syscall", []>, TB;
932 def SYSRET : I<0x07, RawFrm,
933 (outs), (ins), "sysret", []>, TB;
934 def SYSENTER : I<0x34, RawFrm,
935 (outs), (ins), "sysenter", []>, TB;
936 def SYSEXIT : I<0x35, RawFrm,
937 (outs), (ins), "sysexit", []>, TB;
939 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
942 //===----------------------------------------------------------------------===//
943 // Input/Output Instructions...
945 let Defs = [AL], Uses = [DX] in
946 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
947 "in{b}\t{%dx, %al|%AL, %DX}", []>;
948 let Defs = [AX], Uses = [DX] in
949 def IN16rr : I<0xED, RawFrm, (outs), (ins),
950 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
951 let Defs = [EAX], Uses = [DX] in
952 def IN32rr : I<0xED, RawFrm, (outs), (ins),
953 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
956 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
957 "in{b}\t{$port, %al|%AL, $port}", []>;
959 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
960 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
962 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
963 "in{l}\t{$port, %eax|%EAX, $port}", []>;
965 let Uses = [DX, AL] in
966 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
967 "out{b}\t{%al, %dx|%DX, %AL}", []>;
968 let Uses = [DX, AX] in
969 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
970 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
971 let Uses = [DX, EAX] in
972 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
973 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
976 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
977 "out{b}\t{%al, $port|$port, %AL}", []>;
979 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
980 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
982 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
983 "out{l}\t{%eax, $port|$port, %EAX}", []>;
985 def IN8 : I<0x6C, RawFrm, (outs), (ins),
987 def IN16 : I<0x6D, RawFrm, (outs), (ins),
988 "ins{w}", []>, OpSize;
989 def IN32 : I<0x6D, RawFrm, (outs), (ins),
992 //===----------------------------------------------------------------------===//
993 // Move Instructions...
995 let neverHasSideEffects = 1 in {
996 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
997 "mov{b}\t{$src, $dst|$dst, $src}", []>;
998 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
999 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1000 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
1001 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1003 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
1004 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
1005 "mov{b}\t{$src, $dst|$dst, $src}",
1006 [(set GR8:$dst, imm:$src)]>;
1007 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
1008 "mov{w}\t{$src, $dst|$dst, $src}",
1009 [(set GR16:$dst, imm:$src)]>, OpSize;
1010 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
1011 "mov{l}\t{$src, $dst|$dst, $src}",
1012 [(set GR32:$dst, imm:$src)]>;
1015 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
1016 "mov{b}\t{$src, $dst|$dst, $src}",
1017 [(store (i8 imm:$src), addr:$dst)]>;
1018 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
1019 "mov{w}\t{$src, $dst|$dst, $src}",
1020 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
1021 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
1022 "mov{l}\t{$src, $dst|$dst, $src}",
1023 [(store (i32 imm:$src), addr:$dst)]>;
1025 /// moffs8, moffs16 and moffs32 versions of moves. The immediate is a
1026 /// 32-bit offset from the PC. These are only valid in x86-32 mode.
1027 def MOV8o8a : Ii32 <0xA0, RawFrm, (outs), (ins offset8:$src),
1028 "mov{b}\t{$src, %al|%al, $src}", []>;
1029 def MOV16o16a : Ii32 <0xA1, RawFrm, (outs), (ins offset16:$src),
1030 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1031 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
1032 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1033 def MOV8ao8 : Ii32 <0xA2, RawFrm, (outs offset8:$dst), (ins),
1034 "mov{b}\t{%al, $dst|$dst, %al}", []>;
1035 def MOV16ao16 : Ii32 <0xA3, RawFrm, (outs offset16:$dst), (ins),
1036 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
1037 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
1038 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1040 // Moves to and from segment registers
1041 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1042 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1043 def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
1044 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1045 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1046 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1047 def MOV32ms : I<0x8C, MRMDestMem, (outs i32mem:$dst), (ins SEGMENT_REG:$src),
1048 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1049 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1050 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1051 def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
1052 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1053 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1054 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1055 def MOV32sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i32mem:$src),
1056 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1058 let isCodeGenOnly = 1 in {
1059 def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1060 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1061 def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1062 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1063 def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1064 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1067 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1068 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
1069 "mov{b}\t{$src, $dst|$dst, $src}",
1070 [(set GR8:$dst, (loadi8 addr:$src))]>;
1071 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
1072 "mov{w}\t{$src, $dst|$dst, $src}",
1073 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
1074 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
1075 "mov{l}\t{$src, $dst|$dst, $src}",
1076 [(set GR32:$dst, (loadi32 addr:$src))]>;
1079 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
1080 "mov{b}\t{$src, $dst|$dst, $src}",
1081 [(store GR8:$src, addr:$dst)]>;
1082 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1083 "mov{w}\t{$src, $dst|$dst, $src}",
1084 [(store GR16:$src, addr:$dst)]>, OpSize;
1085 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1086 "mov{l}\t{$src, $dst|$dst, $src}",
1087 [(store GR32:$src, addr:$dst)]>;
1089 /// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
1090 let neverHasSideEffects = 1 in
1091 def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1092 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1095 canFoldAsLoad = 1, isReMaterializable = 1 in
1096 def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1097 "mov{l}\t{$src, $dst|$dst, $src}",
1101 def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1102 "mov{l}\t{$src, $dst|$dst, $src}",
1105 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1106 // that they can be used for copying and storing h registers, which can't be
1107 // encoded when a REX prefix is present.
1108 let neverHasSideEffects = 1 in
1109 def MOV8rr_NOREX : I<0x88, MRMDestReg,
1110 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
1111 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1113 def MOV8mr_NOREX : I<0x88, MRMDestMem,
1114 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1115 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1117 canFoldAsLoad = 1, isReMaterializable = 1 in
1118 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1119 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1120 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1122 // Moves to and from debug registers
1123 def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1124 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1125 def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1126 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1128 // Moves to and from control registers
1129 def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
1130 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1131 def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
1132 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1134 //===----------------------------------------------------------------------===//
1135 // Fixed-Register Multiplication and Division Instructions...
1138 // Extra precision multiplication
1140 // AL is really implied by AX, by the registers in Defs must match the
1141 // SDNode results (i8, i32).
1142 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1143 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
1144 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1145 // This probably ought to be moved to a def : Pat<> if the
1146 // syntax can be accepted.
1147 [(set AL, (mul AL, GR8:$src)),
1148 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1150 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1151 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1153 []>, OpSize; // AX,DX = AX*GR16
1155 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1156 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1158 []>; // EAX,EDX = EAX*GR32
1160 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1161 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1163 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1164 // This probably ought to be moved to a def : Pat<> if the
1165 // syntax can be accepted.
1166 [(set AL, (mul AL, (loadi8 addr:$src))),
1167 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1169 let mayLoad = 1, neverHasSideEffects = 1 in {
1170 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1171 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1173 []>, OpSize; // AX,DX = AX*[mem16]
1175 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1176 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1178 []>; // EAX,EDX = EAX*[mem32]
1181 let neverHasSideEffects = 1 in {
1182 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1183 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1185 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1186 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
1187 OpSize; // AX,DX = AX*GR16
1188 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1189 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1190 // EAX,EDX = EAX*GR32
1191 let mayLoad = 1 in {
1192 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1193 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1194 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
1195 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1196 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1197 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1198 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1199 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1200 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
1202 } // neverHasSideEffects
1204 // unsigned division/remainder
1205 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1206 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1207 "div{b}\t$src", []>;
1208 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1209 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1210 "div{w}\t$src", []>, OpSize;
1211 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1212 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1213 "div{l}\t$src", []>;
1214 let mayLoad = 1 in {
1215 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1216 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1217 "div{b}\t$src", []>;
1218 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1219 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1220 "div{w}\t$src", []>, OpSize;
1221 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1222 // EDX:EAX/[mem32] = EAX,EDX
1223 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
1224 "div{l}\t$src", []>;
1227 // Signed division/remainder.
1228 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1229 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1230 "idiv{b}\t$src", []>;
1231 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1232 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1233 "idiv{w}\t$src", []>, OpSize;
1234 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1235 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1236 "idiv{l}\t$src", []>;
1237 let mayLoad = 1, mayLoad = 1 in {
1238 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1239 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1240 "idiv{b}\t$src", []>;
1241 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1242 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1243 "idiv{w}\t$src", []>, OpSize;
1244 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1245 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1246 // EDX:EAX/[mem32] = EAX,EDX
1247 "idiv{l}\t$src", []>;
1250 //===----------------------------------------------------------------------===//
1251 // Two address Instructions.
1253 let Constraints = "$src1 = $dst" in {
1255 // Conditional moves
1256 let Uses = [EFLAGS] in {
1258 let Predicates = [HasCMov] in {
1259 let isCommutable = 1 in {
1260 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1261 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1262 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1263 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1264 X86_COND_B, EFLAGS))]>,
1266 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1267 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1268 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1269 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1270 X86_COND_B, EFLAGS))]>,
1272 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1273 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1274 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1275 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1276 X86_COND_AE, EFLAGS))]>,
1278 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1279 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1280 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1281 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1282 X86_COND_AE, EFLAGS))]>,
1284 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1285 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1286 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1287 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1288 X86_COND_E, EFLAGS))]>,
1290 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1291 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1292 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1293 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1294 X86_COND_E, EFLAGS))]>,
1296 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1297 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1298 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1299 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1300 X86_COND_NE, EFLAGS))]>,
1302 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1303 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1304 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1305 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1306 X86_COND_NE, EFLAGS))]>,
1308 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1309 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1310 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1311 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1312 X86_COND_BE, EFLAGS))]>,
1314 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1315 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1316 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1317 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1318 X86_COND_BE, EFLAGS))]>,
1320 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1321 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1322 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1323 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1324 X86_COND_A, EFLAGS))]>,
1326 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1327 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1328 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1329 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1330 X86_COND_A, EFLAGS))]>,
1332 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1333 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1334 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1335 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1336 X86_COND_L, EFLAGS))]>,
1338 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1339 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1340 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1341 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1342 X86_COND_L, EFLAGS))]>,
1344 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1345 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1346 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1347 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1348 X86_COND_GE, EFLAGS))]>,
1350 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1351 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1352 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1353 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1354 X86_COND_GE, EFLAGS))]>,
1356 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1357 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1358 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1359 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1360 X86_COND_LE, EFLAGS))]>,
1362 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1363 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1364 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1365 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1366 X86_COND_LE, EFLAGS))]>,
1368 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1369 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1370 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1371 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1372 X86_COND_G, EFLAGS))]>,
1374 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1375 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1376 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1377 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1378 X86_COND_G, EFLAGS))]>,
1380 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1381 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1382 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1383 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1384 X86_COND_S, EFLAGS))]>,
1386 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1387 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1388 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1389 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1390 X86_COND_S, EFLAGS))]>,
1392 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1393 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1394 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1395 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1396 X86_COND_NS, EFLAGS))]>,
1398 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1399 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1400 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1401 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1402 X86_COND_NS, EFLAGS))]>,
1404 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1405 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1406 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1407 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1408 X86_COND_P, EFLAGS))]>,
1410 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1411 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1412 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1413 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1414 X86_COND_P, EFLAGS))]>,
1416 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1417 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1418 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1419 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1420 X86_COND_NP, EFLAGS))]>,
1422 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1423 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1424 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1425 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1426 X86_COND_NP, EFLAGS))]>,
1428 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1429 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1430 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1431 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1432 X86_COND_O, EFLAGS))]>,
1434 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1435 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1436 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1437 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1438 X86_COND_O, EFLAGS))]>,
1440 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1441 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1442 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1443 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1444 X86_COND_NO, EFLAGS))]>,
1446 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1447 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1448 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1449 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1450 X86_COND_NO, EFLAGS))]>,
1452 } // isCommutable = 1
1454 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1455 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1456 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1457 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1458 X86_COND_B, EFLAGS))]>,
1460 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1461 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1462 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1463 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1464 X86_COND_B, EFLAGS))]>,
1466 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1467 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1468 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1469 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1470 X86_COND_AE, EFLAGS))]>,
1472 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1473 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1474 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1475 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1476 X86_COND_AE, EFLAGS))]>,
1478 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1479 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1480 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1481 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1482 X86_COND_E, EFLAGS))]>,
1484 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1485 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1486 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1487 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1488 X86_COND_E, EFLAGS))]>,
1490 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1491 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1492 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1493 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1494 X86_COND_NE, EFLAGS))]>,
1496 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1497 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1498 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1499 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1500 X86_COND_NE, EFLAGS))]>,
1502 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1503 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1504 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1505 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1506 X86_COND_BE, EFLAGS))]>,
1508 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1509 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1510 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1511 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1512 X86_COND_BE, EFLAGS))]>,
1514 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1515 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1516 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1517 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1518 X86_COND_A, EFLAGS))]>,
1520 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1521 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1522 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1523 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1524 X86_COND_A, EFLAGS))]>,
1526 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1527 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1528 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1529 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1530 X86_COND_L, EFLAGS))]>,
1532 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1533 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1534 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1535 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1536 X86_COND_L, EFLAGS))]>,
1538 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1539 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1540 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1541 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1542 X86_COND_GE, EFLAGS))]>,
1544 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1545 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1546 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1547 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1548 X86_COND_GE, EFLAGS))]>,
1550 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1551 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1552 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1553 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1554 X86_COND_LE, EFLAGS))]>,
1556 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1557 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1558 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1559 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1560 X86_COND_LE, EFLAGS))]>,
1562 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1563 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1564 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1565 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1566 X86_COND_G, EFLAGS))]>,
1568 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1569 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1570 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1571 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1572 X86_COND_G, EFLAGS))]>,
1574 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1575 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1576 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1577 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1578 X86_COND_S, EFLAGS))]>,
1580 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1581 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1582 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1583 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1584 X86_COND_S, EFLAGS))]>,
1586 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1587 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1588 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1589 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1590 X86_COND_NS, EFLAGS))]>,
1592 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1593 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1594 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1595 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1596 X86_COND_NS, EFLAGS))]>,
1598 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1599 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1600 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1601 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1602 X86_COND_P, EFLAGS))]>,
1604 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1605 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1606 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1607 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1608 X86_COND_P, EFLAGS))]>,
1610 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1611 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1612 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1613 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1614 X86_COND_NP, EFLAGS))]>,
1616 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1617 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1618 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1619 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1620 X86_COND_NP, EFLAGS))]>,
1622 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1623 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1624 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1625 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1626 X86_COND_O, EFLAGS))]>,
1628 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1629 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1630 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1631 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1632 X86_COND_O, EFLAGS))]>,
1634 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1635 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1636 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1637 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1638 X86_COND_NO, EFLAGS))]>,
1640 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1641 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1642 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1643 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1644 X86_COND_NO, EFLAGS))]>,
1646 } // Predicates = [HasCMov]
1648 // X86 doesn't have 8-bit conditional moves. Use a customInserter to
1649 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1650 // however that requires promoting the operands, and can induce additional
1651 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1652 // clobber EFLAGS, because if one of the operands is zero, the expansion
1653 // could involve an xor.
1654 let usesCustomInserter = 1, Constraints = "", Defs = [EFLAGS] in {
1655 def CMOV_GR8 : I<0, Pseudo,
1656 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1657 "#CMOV_GR8 PSEUDO!",
1658 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1659 imm:$cond, EFLAGS))]>;
1661 let Predicates = [NoCMov] in {
1662 def CMOV_GR32 : I<0, Pseudo,
1663 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1664 "#CMOV_GR32* PSEUDO!",
1666 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1667 def CMOV_GR16 : I<0, Pseudo,
1668 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1669 "#CMOV_GR16* PSEUDO!",
1671 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1672 def CMOV_RFP32 : I<0, Pseudo,
1674 (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
1675 "#CMOV_RFP32 PSEUDO!",
1677 (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
1679 def CMOV_RFP64 : I<0, Pseudo,
1681 (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
1682 "#CMOV_RFP64 PSEUDO!",
1684 (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
1686 def CMOV_RFP80 : I<0, Pseudo,
1688 (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
1689 "#CMOV_RFP80 PSEUDO!",
1691 (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
1693 } // Predicates = [NoCMov]
1694 } // UsesCustomInserter = 1, Constraints = "", Defs = [EFLAGS]
1695 } // Uses = [EFLAGS]
1698 // unary instructions
1699 let CodeSize = 2 in {
1700 let Defs = [EFLAGS] in {
1701 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src1),
1703 [(set GR8:$dst, (ineg GR8:$src1)),
1704 (implicit EFLAGS)]>;
1705 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
1707 [(set GR16:$dst, (ineg GR16:$src1)),
1708 (implicit EFLAGS)]>, OpSize;
1709 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
1711 [(set GR32:$dst, (ineg GR32:$src1)),
1712 (implicit EFLAGS)]>;
1714 let Constraints = "" in {
1715 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst),
1717 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1718 (implicit EFLAGS)]>;
1719 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst),
1721 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1722 (implicit EFLAGS)]>, OpSize;
1723 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst),
1725 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1726 (implicit EFLAGS)]>;
1727 } // Constraints = ""
1728 } // Defs = [EFLAGS]
1730 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1731 let AddedComplexity = 15 in {
1732 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src1),
1734 [(set GR8:$dst, (not GR8:$src1))]>;
1735 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
1737 [(set GR16:$dst, (not GR16:$src1))]>, OpSize;
1738 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
1740 [(set GR32:$dst, (not GR32:$src1))]>;
1742 let Constraints = "" in {
1743 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst),
1745 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1746 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst),
1748 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1749 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst),
1751 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1752 } // Constraints = ""
1755 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1756 let Defs = [EFLAGS] in {
1758 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1760 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src1))]>;
1762 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1763 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1765 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src1))]>,
1766 OpSize, Requires<[In32BitMode]>;
1767 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1769 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src1))]>,
1770 Requires<[In32BitMode]>;
1772 let Constraints = "", CodeSize = 2 in {
1773 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1774 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1775 (implicit EFLAGS)]>;
1776 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1777 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1778 (implicit EFLAGS)]>,
1779 OpSize, Requires<[In32BitMode]>;
1780 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1781 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1782 (implicit EFLAGS)]>,
1783 Requires<[In32BitMode]>;
1784 } // Constraints = "", CodeSize = 2
1787 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1789 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src1))]>;
1790 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1791 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1793 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src1))]>,
1794 OpSize, Requires<[In32BitMode]>;
1795 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1797 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src1))]>,
1798 Requires<[In32BitMode]>;
1801 let Constraints = "", CodeSize = 2 in {
1802 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1803 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1804 (implicit EFLAGS)]>;
1805 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1806 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1807 (implicit EFLAGS)]>,
1808 OpSize, Requires<[In32BitMode]>;
1809 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1810 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1811 (implicit EFLAGS)]>,
1812 Requires<[In32BitMode]>;
1813 } // Constraints = "", CodeSize = 2
1814 } // Defs = [EFLAGS]
1816 // Logical operators...
1817 let Defs = [EFLAGS] in {
1818 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1819 def AND8rr : I<0x20, MRMDestReg,
1820 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1821 "and{b}\t{$src2, $dst|$dst, $src2}",
1822 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1823 def AND16rr : I<0x21, MRMDestReg,
1824 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1825 "and{w}\t{$src2, $dst|$dst, $src2}",
1826 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1827 GR16:$src2))]>, OpSize;
1828 def AND32rr : I<0x21, MRMDestReg,
1829 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1830 "and{l}\t{$src2, $dst|$dst, $src2}",
1831 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1835 // AND instructions with the destination register in REG and the source register
1836 // in R/M. Included for the disassembler.
1837 let isCodeGenOnly = 1 in {
1838 def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1839 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1840 def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1841 (ins GR16:$src1, GR16:$src2),
1842 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1843 def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1844 (ins GR32:$src1, GR32:$src2),
1845 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1848 def AND8rm : I<0x22, MRMSrcMem,
1849 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1850 "and{b}\t{$src2, $dst|$dst, $src2}",
1851 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1852 (loadi8 addr:$src2)))]>;
1853 def AND16rm : I<0x23, MRMSrcMem,
1854 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1855 "and{w}\t{$src2, $dst|$dst, $src2}",
1856 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1857 (loadi16 addr:$src2)))]>,
1859 def AND32rm : I<0x23, MRMSrcMem,
1860 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1861 "and{l}\t{$src2, $dst|$dst, $src2}",
1862 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1863 (loadi32 addr:$src2)))]>;
1865 def AND8ri : Ii8<0x80, MRM4r,
1866 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1867 "and{b}\t{$src2, $dst|$dst, $src2}",
1868 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1870 def AND16ri : Ii16<0x81, MRM4r,
1871 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1872 "and{w}\t{$src2, $dst|$dst, $src2}",
1873 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1874 imm:$src2))]>, OpSize;
1875 def AND32ri : Ii32<0x81, MRM4r,
1876 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1877 "and{l}\t{$src2, $dst|$dst, $src2}",
1878 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1880 def AND16ri8 : Ii8<0x83, MRM4r,
1881 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1882 "and{w}\t{$src2, $dst|$dst, $src2}",
1883 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1884 i16immSExt8:$src2))]>,
1886 def AND32ri8 : Ii8<0x83, MRM4r,
1887 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1888 "and{l}\t{$src2, $dst|$dst, $src2}",
1889 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1890 i32immSExt8:$src2))]>;
1892 let Constraints = "" in {
1893 def AND8mr : I<0x20, MRMDestMem,
1894 (outs), (ins i8mem :$dst, GR8 :$src),
1895 "and{b}\t{$src, $dst|$dst, $src}",
1896 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1897 (implicit EFLAGS)]>;
1898 def AND16mr : I<0x21, MRMDestMem,
1899 (outs), (ins i16mem:$dst, GR16:$src),
1900 "and{w}\t{$src, $dst|$dst, $src}",
1901 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1902 (implicit EFLAGS)]>,
1904 def AND32mr : I<0x21, MRMDestMem,
1905 (outs), (ins i32mem:$dst, GR32:$src),
1906 "and{l}\t{$src, $dst|$dst, $src}",
1907 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1908 (implicit EFLAGS)]>;
1909 def AND8mi : Ii8<0x80, MRM4m,
1910 (outs), (ins i8mem :$dst, i8imm :$src),
1911 "and{b}\t{$src, $dst|$dst, $src}",
1912 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1913 (implicit EFLAGS)]>;
1914 def AND16mi : Ii16<0x81, MRM4m,
1915 (outs), (ins i16mem:$dst, i16imm:$src),
1916 "and{w}\t{$src, $dst|$dst, $src}",
1917 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1918 (implicit EFLAGS)]>,
1920 def AND32mi : Ii32<0x81, MRM4m,
1921 (outs), (ins i32mem:$dst, i32imm:$src),
1922 "and{l}\t{$src, $dst|$dst, $src}",
1923 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1924 (implicit EFLAGS)]>;
1925 def AND16mi8 : Ii8<0x83, MRM4m,
1926 (outs), (ins i16mem:$dst, i16i8imm :$src),
1927 "and{w}\t{$src, $dst|$dst, $src}",
1928 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1929 (implicit EFLAGS)]>,
1931 def AND32mi8 : Ii8<0x83, MRM4m,
1932 (outs), (ins i32mem:$dst, i32i8imm :$src),
1933 "and{l}\t{$src, $dst|$dst, $src}",
1934 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1935 (implicit EFLAGS)]>;
1937 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1938 "and{b}\t{$src, %al|%al, $src}", []>;
1939 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1940 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1941 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1942 "and{l}\t{$src, %eax|%eax, $src}", []>;
1944 } // Constraints = ""
1947 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1948 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1949 (ins GR8 :$src1, GR8 :$src2),
1950 "or{b}\t{$src2, $dst|$dst, $src2}",
1951 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
1952 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1953 (ins GR16:$src1, GR16:$src2),
1954 "or{w}\t{$src2, $dst|$dst, $src2}",
1955 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1957 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1958 (ins GR32:$src1, GR32:$src2),
1959 "or{l}\t{$src2, $dst|$dst, $src2}",
1960 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
1963 // OR instructions with the destination register in REG and the source register
1964 // in R/M. Included for the disassembler.
1965 let isCodeGenOnly = 1 in {
1966 def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1967 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1968 def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1969 (ins GR16:$src1, GR16:$src2),
1970 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1971 def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1972 (ins GR32:$src1, GR32:$src2),
1973 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1976 def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
1977 (ins GR8 :$src1, i8mem :$src2),
1978 "or{b}\t{$src2, $dst|$dst, $src2}",
1979 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
1980 (load addr:$src2)))]>;
1981 def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
1982 (ins GR16:$src1, i16mem:$src2),
1983 "or{w}\t{$src2, $dst|$dst, $src2}",
1984 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1985 (load addr:$src2)))]>,
1987 def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
1988 (ins GR32:$src1, i32mem:$src2),
1989 "or{l}\t{$src2, $dst|$dst, $src2}",
1990 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1991 (load addr:$src2)))]>;
1993 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1994 (ins GR8 :$src1, i8imm:$src2),
1995 "or{b}\t{$src2, $dst|$dst, $src2}",
1996 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
1997 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1998 (ins GR16:$src1, i16imm:$src2),
1999 "or{w}\t{$src2, $dst|$dst, $src2}",
2000 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2001 imm:$src2))]>, OpSize;
2002 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
2003 (ins GR32:$src1, i32imm:$src2),
2004 "or{l}\t{$src2, $dst|$dst, $src2}",
2005 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2008 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
2009 (ins GR16:$src1, i16i8imm:$src2),
2010 "or{w}\t{$src2, $dst|$dst, $src2}",
2011 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2012 i16immSExt8:$src2))]>, OpSize;
2013 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
2014 (ins GR32:$src1, i32i8imm:$src2),
2015 "or{l}\t{$src2, $dst|$dst, $src2}",
2016 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2017 i32immSExt8:$src2))]>;
2018 let Constraints = "" in {
2019 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
2020 "or{b}\t{$src, $dst|$dst, $src}",
2021 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
2022 (implicit EFLAGS)]>;
2023 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
2024 "or{w}\t{$src, $dst|$dst, $src}",
2025 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
2026 (implicit EFLAGS)]>, OpSize;
2027 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2028 "or{l}\t{$src, $dst|$dst, $src}",
2029 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
2030 (implicit EFLAGS)]>;
2031 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2032 "or{b}\t{$src, $dst|$dst, $src}",
2033 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
2034 (implicit EFLAGS)]>;
2035 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
2036 "or{w}\t{$src, $dst|$dst, $src}",
2037 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
2038 (implicit EFLAGS)]>,
2040 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
2041 "or{l}\t{$src, $dst|$dst, $src}",
2042 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
2043 (implicit EFLAGS)]>;
2044 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
2045 "or{w}\t{$src, $dst|$dst, $src}",
2046 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
2047 (implicit EFLAGS)]>,
2049 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
2050 "or{l}\t{$src, $dst|$dst, $src}",
2051 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
2052 (implicit EFLAGS)]>;
2054 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
2055 "or{b}\t{$src, %al|%al, $src}", []>;
2056 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
2057 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2058 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
2059 "or{l}\t{$src, %eax|%eax, $src}", []>;
2060 } // Constraints = ""
2063 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
2064 def XOR8rr : I<0x30, MRMDestReg,
2065 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
2066 "xor{b}\t{$src2, $dst|$dst, $src2}",
2067 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2069 def XOR16rr : I<0x31, MRMDestReg,
2070 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2071 "xor{w}\t{$src2, $dst|$dst, $src2}",
2072 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2073 GR16:$src2))]>, OpSize;
2074 def XOR32rr : I<0x31, MRMDestReg,
2075 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2076 "xor{l}\t{$src2, $dst|$dst, $src2}",
2077 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2079 } // isCommutable = 1
2081 // XOR instructions with the destination register in REG and the source register
2082 // in R/M. Included for the disassembler.
2083 let isCodeGenOnly = 1 in {
2084 def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2085 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2086 def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2087 (ins GR16:$src1, GR16:$src2),
2088 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2089 def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2090 (ins GR32:$src1, GR32:$src2),
2091 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
2094 def XOR8rm : I<0x32, MRMSrcMem,
2095 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
2096 "xor{b}\t{$src2, $dst|$dst, $src2}",
2097 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2098 (load addr:$src2)))]>;
2099 def XOR16rm : I<0x33, MRMSrcMem,
2100 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
2101 "xor{w}\t{$src2, $dst|$dst, $src2}",
2102 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2103 (load addr:$src2)))]>,
2105 def XOR32rm : I<0x33, MRMSrcMem,
2106 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2107 "xor{l}\t{$src2, $dst|$dst, $src2}",
2108 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2109 (load addr:$src2)))]>;
2111 def XOR8ri : Ii8<0x80, MRM6r,
2112 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2113 "xor{b}\t{$src2, $dst|$dst, $src2}",
2114 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
2115 def XOR16ri : Ii16<0x81, MRM6r,
2116 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2117 "xor{w}\t{$src2, $dst|$dst, $src2}",
2118 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2119 imm:$src2))]>, OpSize;
2120 def XOR32ri : Ii32<0x81, MRM6r,
2121 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2122 "xor{l}\t{$src2, $dst|$dst, $src2}",
2123 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2125 def XOR16ri8 : Ii8<0x83, MRM6r,
2126 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2127 "xor{w}\t{$src2, $dst|$dst, $src2}",
2128 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2129 i16immSExt8:$src2))]>,
2131 def XOR32ri8 : Ii8<0x83, MRM6r,
2132 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2133 "xor{l}\t{$src2, $dst|$dst, $src2}",
2134 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2135 i32immSExt8:$src2))]>;
2137 let Constraints = "" in {
2138 def XOR8mr : I<0x30, MRMDestMem,
2139 (outs), (ins i8mem :$dst, GR8 :$src),
2140 "xor{b}\t{$src, $dst|$dst, $src}",
2141 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2142 (implicit EFLAGS)]>;
2143 def XOR16mr : I<0x31, MRMDestMem,
2144 (outs), (ins i16mem:$dst, GR16:$src),
2145 "xor{w}\t{$src, $dst|$dst, $src}",
2146 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2147 (implicit EFLAGS)]>,
2149 def XOR32mr : I<0x31, MRMDestMem,
2150 (outs), (ins i32mem:$dst, GR32:$src),
2151 "xor{l}\t{$src, $dst|$dst, $src}",
2152 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2153 (implicit EFLAGS)]>;
2154 def XOR8mi : Ii8<0x80, MRM6m,
2155 (outs), (ins i8mem :$dst, i8imm :$src),
2156 "xor{b}\t{$src, $dst|$dst, $src}",
2157 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2158 (implicit EFLAGS)]>;
2159 def XOR16mi : Ii16<0x81, MRM6m,
2160 (outs), (ins i16mem:$dst, i16imm:$src),
2161 "xor{w}\t{$src, $dst|$dst, $src}",
2162 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2163 (implicit EFLAGS)]>,
2165 def XOR32mi : Ii32<0x81, MRM6m,
2166 (outs), (ins i32mem:$dst, i32imm:$src),
2167 "xor{l}\t{$src, $dst|$dst, $src}",
2168 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2169 (implicit EFLAGS)]>;
2170 def XOR16mi8 : Ii8<0x83, MRM6m,
2171 (outs), (ins i16mem:$dst, i16i8imm :$src),
2172 "xor{w}\t{$src, $dst|$dst, $src}",
2173 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2174 (implicit EFLAGS)]>,
2176 def XOR32mi8 : Ii8<0x83, MRM6m,
2177 (outs), (ins i32mem:$dst, i32i8imm :$src),
2178 "xor{l}\t{$src, $dst|$dst, $src}",
2179 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2180 (implicit EFLAGS)]>;
2182 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2183 "xor{b}\t{$src, %al|%al, $src}", []>;
2184 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
2185 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2186 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
2187 "xor{l}\t{$src, %eax|%eax, $src}", []>;
2188 } // Constraints = ""
2189 } // Defs = [EFLAGS]
2191 // Shift instructions
2192 let Defs = [EFLAGS] in {
2193 let Uses = [CL] in {
2194 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
2195 "shl{b}\t{%cl, $dst|$dst, CL}",
2196 [(set GR8:$dst, (shl GR8:$src1, CL))]>;
2197 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2198 "shl{w}\t{%cl, $dst|$dst, CL}",
2199 [(set GR16:$dst, (shl GR16:$src1, CL))]>, OpSize;
2200 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2201 "shl{l}\t{%cl, $dst|$dst, CL}",
2202 [(set GR32:$dst, (shl GR32:$src1, CL))]>;
2205 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2206 "shl{b}\t{$src2, $dst|$dst, $src2}",
2207 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2209 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2210 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2211 "shl{w}\t{$src2, $dst|$dst, $src2}",
2212 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2213 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2214 "shl{l}\t{$src2, $dst|$dst, $src2}",
2215 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
2217 // NOTE: We don't include patterns for shifts of a register by one, because
2218 // 'add reg,reg' is cheaper.
2220 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2221 "shl{b}\t$dst", []>;
2222 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2223 "shl{w}\t$dst", []>, OpSize;
2224 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2225 "shl{l}\t$dst", []>;
2227 } // isConvertibleToThreeAddress = 1
2229 let Constraints = "" in {
2230 let Uses = [CL] in {
2231 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
2232 "shl{b}\t{%cl, $dst|$dst, CL}",
2233 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
2234 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
2235 "shl{w}\t{%cl, $dst|$dst, CL}",
2236 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2237 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
2238 "shl{l}\t{%cl, $dst|$dst, CL}",
2239 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2241 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
2242 "shl{b}\t{$src, $dst|$dst, $src}",
2243 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2244 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
2245 "shl{w}\t{$src, $dst|$dst, $src}",
2246 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2248 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
2249 "shl{l}\t{$src, $dst|$dst, $src}",
2250 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2253 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2255 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2256 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2258 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2260 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2262 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2263 } // Constraints = ""
2265 let Uses = [CL] in {
2266 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1),
2267 "shr{b}\t{%cl, $dst|$dst, CL}",
2268 [(set GR8:$dst, (srl GR8:$src1, CL))]>;
2269 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2270 "shr{w}\t{%cl, $dst|$dst, CL}",
2271 [(set GR16:$dst, (srl GR16:$src1, CL))]>, OpSize;
2272 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2273 "shr{l}\t{%cl, $dst|$dst, CL}",
2274 [(set GR32:$dst, (srl GR32:$src1, CL))]>;
2277 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2278 "shr{b}\t{$src2, $dst|$dst, $src2}",
2279 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2280 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2281 "shr{w}\t{$src2, $dst|$dst, $src2}",
2282 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2283 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2284 "shr{l}\t{$src2, $dst|$dst, $src2}",
2285 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2288 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2290 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2291 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2293 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2294 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2296 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2298 let Constraints = "" in {
2299 let Uses = [CL] in {
2300 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2301 "shr{b}\t{%cl, $dst|$dst, CL}",
2302 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2303 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2304 "shr{w}\t{%cl, $dst|$dst, CL}",
2305 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2307 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2308 "shr{l}\t{%cl, $dst|$dst, CL}",
2309 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2311 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2312 "shr{b}\t{$src, $dst|$dst, $src}",
2313 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2314 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2315 "shr{w}\t{$src, $dst|$dst, $src}",
2316 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2318 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2319 "shr{l}\t{$src, $dst|$dst, $src}",
2320 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2323 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2325 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2326 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2328 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2329 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2331 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2332 } // Constraints = ""
2334 let Uses = [CL] in {
2335 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2336 "sar{b}\t{%cl, $dst|$dst, CL}",
2337 [(set GR8:$dst, (sra GR8:$src1, CL))]>;
2338 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2339 "sar{w}\t{%cl, $dst|$dst, CL}",
2340 [(set GR16:$dst, (sra GR16:$src1, CL))]>, OpSize;
2341 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2342 "sar{l}\t{%cl, $dst|$dst, CL}",
2343 [(set GR32:$dst, (sra GR32:$src1, CL))]>;
2346 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2347 "sar{b}\t{$src2, $dst|$dst, $src2}",
2348 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2349 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2350 "sar{w}\t{$src2, $dst|$dst, $src2}",
2351 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2353 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2354 "sar{l}\t{$src2, $dst|$dst, $src2}",
2355 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2358 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2360 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2361 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2363 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2364 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2366 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2368 let Constraints = "" in {
2369 let Uses = [CL] in {
2370 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2371 "sar{b}\t{%cl, $dst|$dst, CL}",
2372 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2373 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2374 "sar{w}\t{%cl, $dst|$dst, CL}",
2375 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2376 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2377 "sar{l}\t{%cl, $dst|$dst, CL}",
2378 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2380 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2381 "sar{b}\t{$src, $dst|$dst, $src}",
2382 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2383 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2384 "sar{w}\t{$src, $dst|$dst, $src}",
2385 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2387 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2388 "sar{l}\t{$src, $dst|$dst, $src}",
2389 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2392 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2394 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2395 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2397 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2399 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2401 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2402 } // Constraints = ""
2404 // Rotate instructions
2406 def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
2407 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2408 let Uses = [CL] in {
2409 def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
2410 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2412 def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
2413 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2415 def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
2416 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2417 let Uses = [CL] in {
2418 def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
2419 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2421 def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
2422 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2424 def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
2425 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2426 let Uses = [CL] in {
2427 def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
2428 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2430 def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
2431 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2433 def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
2434 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2435 let Uses = [CL] in {
2436 def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
2437 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2439 def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
2440 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2442 def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
2443 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2444 let Uses = [CL] in {
2445 def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
2446 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2448 def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
2449 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2451 def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
2452 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2453 let Uses = [CL] in {
2454 def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
2455 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2457 def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
2458 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2460 let Constraints = "" in {
2461 def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2462 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2463 def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2464 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2465 def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2466 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2467 def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2468 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2469 def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2470 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2471 def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2472 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2473 def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2474 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2475 def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2476 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2477 def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2478 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2479 def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2480 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2481 def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2482 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2483 def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2484 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2486 let Uses = [CL] in {
2487 def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2488 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2489 def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2490 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2491 def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2492 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2493 def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2494 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2495 def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2496 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2497 def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2498 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2500 } // Constraints = ""
2502 // FIXME: provide shorter instructions when imm8 == 1
2503 let Uses = [CL] in {
2504 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2505 "rol{b}\t{%cl, $dst|$dst, CL}",
2506 [(set GR8:$dst, (rotl GR8:$src1, CL))]>;
2507 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2508 "rol{w}\t{%cl, $dst|$dst, CL}",
2509 [(set GR16:$dst, (rotl GR16:$src1, CL))]>, OpSize;
2510 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2511 "rol{l}\t{%cl, $dst|$dst, CL}",
2512 [(set GR32:$dst, (rotl GR32:$src1, CL))]>;
2515 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2516 "rol{b}\t{$src2, $dst|$dst, $src2}",
2517 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2518 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2519 "rol{w}\t{$src2, $dst|$dst, $src2}",
2520 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2522 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2523 "rol{l}\t{$src2, $dst|$dst, $src2}",
2524 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2527 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2529 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2530 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2532 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2533 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2535 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2537 let Constraints = "" in {
2538 let Uses = [CL] in {
2539 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2540 "rol{b}\t{%cl, $dst|$dst, CL}",
2541 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2542 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2543 "rol{w}\t{%cl, $dst|$dst, CL}",
2544 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2545 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2546 "rol{l}\t{%cl, $dst|$dst, CL}",
2547 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2549 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2550 "rol{b}\t{$src, $dst|$dst, $src}",
2551 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2552 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2553 "rol{w}\t{$src, $dst|$dst, $src}",
2554 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2556 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2557 "rol{l}\t{$src, $dst|$dst, $src}",
2558 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2561 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2563 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2564 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2566 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2568 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2570 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2571 } // Constraints = ""
2573 let Uses = [CL] in {
2574 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2575 "ror{b}\t{%cl, $dst|$dst, CL}",
2576 [(set GR8:$dst, (rotr GR8:$src1, CL))]>;
2577 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2578 "ror{w}\t{%cl, $dst|$dst, CL}",
2579 [(set GR16:$dst, (rotr GR16:$src1, CL))]>, OpSize;
2580 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2581 "ror{l}\t{%cl, $dst|$dst, CL}",
2582 [(set GR32:$dst, (rotr GR32:$src1, CL))]>;
2585 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2586 "ror{b}\t{$src2, $dst|$dst, $src2}",
2587 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2588 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2589 "ror{w}\t{$src2, $dst|$dst, $src2}",
2590 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2592 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2593 "ror{l}\t{$src2, $dst|$dst, $src2}",
2594 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2597 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2599 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2600 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2602 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2603 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2605 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2607 let Constraints = "" in {
2608 let Uses = [CL] in {
2609 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2610 "ror{b}\t{%cl, $dst|$dst, CL}",
2611 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2612 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2613 "ror{w}\t{%cl, $dst|$dst, CL}",
2614 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2615 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2616 "ror{l}\t{%cl, $dst|$dst, CL}",
2617 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2619 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2620 "ror{b}\t{$src, $dst|$dst, $src}",
2621 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2622 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2623 "ror{w}\t{$src, $dst|$dst, $src}",
2624 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2626 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2627 "ror{l}\t{$src, $dst|$dst, $src}",
2628 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2631 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2633 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2634 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2636 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2638 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2640 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2641 } // Constraints = ""
2644 // Double shift instructions (generalizations of rotate)
2645 let Uses = [CL] in {
2646 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2647 (ins GR32:$src1, GR32:$src2),
2648 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2649 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2650 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2651 (ins GR32:$src1, GR32:$src2),
2652 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2653 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2654 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2655 (ins GR16:$src1, GR16:$src2),
2656 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2657 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2659 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2660 (ins GR16:$src1, GR16:$src2),
2661 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2662 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2666 let isCommutable = 1 in { // These instructions commute to each other.
2667 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2669 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2670 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2671 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2674 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2676 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2677 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2678 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2681 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2683 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2684 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2685 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2688 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2690 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2691 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2692 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2697 let Constraints = "" in {
2698 let Uses = [CL] in {
2699 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2700 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2701 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2703 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2704 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2705 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2708 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2709 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2710 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2711 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2712 (i8 imm:$src3)), addr:$dst)]>,
2714 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2715 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2716 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2717 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2718 (i8 imm:$src3)), addr:$dst)]>,
2721 let Uses = [CL] in {
2722 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2723 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2724 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2725 addr:$dst)]>, TB, OpSize;
2726 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2727 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2728 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2729 addr:$dst)]>, TB, OpSize;
2731 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2732 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2733 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2734 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2735 (i8 imm:$src3)), addr:$dst)]>,
2737 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2738 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2739 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2740 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2741 (i8 imm:$src3)), addr:$dst)]>,
2743 } // Constraints = ""
2744 } // Defs = [EFLAGS]
2748 let Defs = [EFLAGS] in {
2749 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2750 // Register-Register Addition
2751 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2752 (ins GR8 :$src1, GR8 :$src2),
2753 "add{b}\t{$src2, $dst|$dst, $src2}",
2754 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
2756 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2757 // Register-Register Addition
2758 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2759 (ins GR16:$src1, GR16:$src2),
2760 "add{w}\t{$src2, $dst|$dst, $src2}",
2761 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2762 GR16:$src2))]>, OpSize;
2763 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2764 (ins GR32:$src1, GR32:$src2),
2765 "add{l}\t{$src2, $dst|$dst, $src2}",
2766 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2768 } // end isConvertibleToThreeAddress
2769 } // end isCommutable
2771 // These are alternate spellings for use by the disassembler, we mark them as
2772 // code gen only to ensure they aren't matched by the assembler.
2773 let isCodeGenOnly = 1 in {
2774 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2775 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2776 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2777 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2778 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
2779 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2782 // Register-Memory Addition
2783 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2784 (ins GR8 :$src1, i8mem :$src2),
2785 "add{b}\t{$src2, $dst|$dst, $src2}",
2786 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2787 (load addr:$src2)))]>;
2788 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2789 (ins GR16:$src1, i16mem:$src2),
2790 "add{w}\t{$src2, $dst|$dst, $src2}",
2791 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2792 (load addr:$src2)))]>, OpSize;
2793 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2794 (ins GR32:$src1, i32mem:$src2),
2795 "add{l}\t{$src2, $dst|$dst, $src2}",
2796 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2797 (load addr:$src2)))]>;
2799 // Register-Integer Addition
2800 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2801 "add{b}\t{$src2, $dst|$dst, $src2}",
2802 [(set GR8:$dst, EFLAGS,
2803 (X86add_flag GR8:$src1, imm:$src2))]>;
2805 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2806 // Register-Integer Addition
2807 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2808 (ins GR16:$src1, i16imm:$src2),
2809 "add{w}\t{$src2, $dst|$dst, $src2}",
2810 [(set GR16:$dst, EFLAGS,
2811 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
2812 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2813 (ins GR32:$src1, i32imm:$src2),
2814 "add{l}\t{$src2, $dst|$dst, $src2}",
2815 [(set GR32:$dst, EFLAGS,
2816 (X86add_flag GR32:$src1, imm:$src2))]>;
2817 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2818 (ins GR16:$src1, i16i8imm:$src2),
2819 "add{w}\t{$src2, $dst|$dst, $src2}",
2820 [(set GR16:$dst, EFLAGS,
2821 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
2822 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2823 (ins GR32:$src1, i32i8imm:$src2),
2824 "add{l}\t{$src2, $dst|$dst, $src2}",
2825 [(set GR32:$dst, EFLAGS,
2826 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
2829 let Constraints = "" in {
2830 // Memory-Register Addition
2831 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2832 "add{b}\t{$src2, $dst|$dst, $src2}",
2833 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2834 (implicit EFLAGS)]>;
2835 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2836 "add{w}\t{$src2, $dst|$dst, $src2}",
2837 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2838 (implicit EFLAGS)]>, OpSize;
2839 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2840 "add{l}\t{$src2, $dst|$dst, $src2}",
2841 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2842 (implicit EFLAGS)]>;
2843 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2844 "add{b}\t{$src2, $dst|$dst, $src2}",
2845 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2846 (implicit EFLAGS)]>;
2847 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2848 "add{w}\t{$src2, $dst|$dst, $src2}",
2849 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2850 (implicit EFLAGS)]>, OpSize;
2851 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2852 "add{l}\t{$src2, $dst|$dst, $src2}",
2853 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2854 (implicit EFLAGS)]>;
2855 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2856 "add{w}\t{$src2, $dst|$dst, $src2}",
2857 [(store (add (load addr:$dst), i16immSExt8:$src2),
2859 (implicit EFLAGS)]>, OpSize;
2860 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2861 "add{l}\t{$src2, $dst|$dst, $src2}",
2862 [(store (add (load addr:$dst), i32immSExt8:$src2),
2864 (implicit EFLAGS)]>;
2867 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2868 "add{b}\t{$src, %al|%al, $src}", []>;
2869 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2870 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2871 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2872 "add{l}\t{$src, %eax|%eax, $src}", []>;
2873 } // Constraints = ""
2875 let Uses = [EFLAGS] in {
2876 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2877 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2878 "adc{b}\t{$src2, $dst|$dst, $src2}",
2879 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2880 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2881 (ins GR16:$src1, GR16:$src2),
2882 "adc{w}\t{$src2, $dst|$dst, $src2}",
2883 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2884 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2885 (ins GR32:$src1, GR32:$src2),
2886 "adc{l}\t{$src2, $dst|$dst, $src2}",
2887 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2890 let isCodeGenOnly = 1 in {
2891 def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2892 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2893 def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2894 (ins GR16:$src1, GR16:$src2),
2895 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2896 def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2897 (ins GR32:$src1, GR32:$src2),
2898 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2901 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2902 (ins GR8:$src1, i8mem:$src2),
2903 "adc{b}\t{$src2, $dst|$dst, $src2}",
2904 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2905 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2906 (ins GR16:$src1, i16mem:$src2),
2907 "adc{w}\t{$src2, $dst|$dst, $src2}",
2908 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2910 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2911 (ins GR32:$src1, i32mem:$src2),
2912 "adc{l}\t{$src2, $dst|$dst, $src2}",
2913 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2914 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2915 "adc{b}\t{$src2, $dst|$dst, $src2}",
2916 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2917 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2918 (ins GR16:$src1, i16imm:$src2),
2919 "adc{w}\t{$src2, $dst|$dst, $src2}",
2920 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2921 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2922 (ins GR16:$src1, i16i8imm:$src2),
2923 "adc{w}\t{$src2, $dst|$dst, $src2}",
2924 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2926 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2927 (ins GR32:$src1, i32imm:$src2),
2928 "adc{l}\t{$src2, $dst|$dst, $src2}",
2929 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2930 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2931 (ins GR32:$src1, i32i8imm:$src2),
2932 "adc{l}\t{$src2, $dst|$dst, $src2}",
2933 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2935 let Constraints = "" in {
2936 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2937 "adc{b}\t{$src2, $dst|$dst, $src2}",
2938 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2939 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2940 "adc{w}\t{$src2, $dst|$dst, $src2}",
2941 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2943 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2944 "adc{l}\t{$src2, $dst|$dst, $src2}",
2945 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2946 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2947 "adc{b}\t{$src2, $dst|$dst, $src2}",
2948 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2949 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2950 "adc{w}\t{$src2, $dst|$dst, $src2}",
2951 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2953 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2954 "adc{w}\t{$src2, $dst|$dst, $src2}",
2955 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2957 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2958 "adc{l}\t{$src2, $dst|$dst, $src2}",
2959 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2960 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2961 "adc{l}\t{$src2, $dst|$dst, $src2}",
2962 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2964 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2965 "adc{b}\t{$src, %al|%al, $src}", []>;
2966 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2967 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2968 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2969 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2970 } // Constraints = ""
2971 } // Uses = [EFLAGS]
2973 // Register-Register Subtraction
2974 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2975 "sub{b}\t{$src2, $dst|$dst, $src2}",
2976 [(set GR8:$dst, EFLAGS,
2977 (X86sub_flag GR8:$src1, GR8:$src2))]>;
2978 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2979 "sub{w}\t{$src2, $dst|$dst, $src2}",
2980 [(set GR16:$dst, EFLAGS,
2981 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
2982 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2983 "sub{l}\t{$src2, $dst|$dst, $src2}",
2984 [(set GR32:$dst, EFLAGS,
2985 (X86sub_flag GR32:$src1, GR32:$src2))]>;
2987 let isCodeGenOnly = 1 in {
2988 def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2989 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2990 def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2991 (ins GR16:$src1, GR16:$src2),
2992 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2993 def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2994 (ins GR32:$src1, GR32:$src2),
2995 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2998 // Register-Memory Subtraction
2999 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
3000 (ins GR8 :$src1, i8mem :$src2),
3001 "sub{b}\t{$src2, $dst|$dst, $src2}",
3002 [(set GR8:$dst, EFLAGS,
3003 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
3004 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
3005 (ins GR16:$src1, i16mem:$src2),
3006 "sub{w}\t{$src2, $dst|$dst, $src2}",
3007 [(set GR16:$dst, EFLAGS,
3008 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
3009 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
3010 (ins GR32:$src1, i32mem:$src2),
3011 "sub{l}\t{$src2, $dst|$dst, $src2}",
3012 [(set GR32:$dst, EFLAGS,
3013 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
3015 // Register-Integer Subtraction
3016 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
3017 (ins GR8:$src1, i8imm:$src2),
3018 "sub{b}\t{$src2, $dst|$dst, $src2}",
3019 [(set GR8:$dst, EFLAGS,
3020 (X86sub_flag GR8:$src1, imm:$src2))]>;
3021 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
3022 (ins GR16:$src1, i16imm:$src2),
3023 "sub{w}\t{$src2, $dst|$dst, $src2}",
3024 [(set GR16:$dst, EFLAGS,
3025 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
3026 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
3027 (ins GR32:$src1, i32imm:$src2),
3028 "sub{l}\t{$src2, $dst|$dst, $src2}",
3029 [(set GR32:$dst, EFLAGS,
3030 (X86sub_flag GR32:$src1, imm:$src2))]>;
3031 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
3032 (ins GR16:$src1, i16i8imm:$src2),
3033 "sub{w}\t{$src2, $dst|$dst, $src2}",
3034 [(set GR16:$dst, EFLAGS,
3035 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
3036 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
3037 (ins GR32:$src1, i32i8imm:$src2),
3038 "sub{l}\t{$src2, $dst|$dst, $src2}",
3039 [(set GR32:$dst, EFLAGS,
3040 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
3042 let Constraints = "" in {
3043 // Memory-Register Subtraction
3044 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3045 "sub{b}\t{$src2, $dst|$dst, $src2}",
3046 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
3047 (implicit EFLAGS)]>;
3048 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3049 "sub{w}\t{$src2, $dst|$dst, $src2}",
3050 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
3051 (implicit EFLAGS)]>, OpSize;
3052 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3053 "sub{l}\t{$src2, $dst|$dst, $src2}",
3054 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
3055 (implicit EFLAGS)]>;
3057 // Memory-Integer Subtraction
3058 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3059 "sub{b}\t{$src2, $dst|$dst, $src2}",
3060 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
3061 (implicit EFLAGS)]>;
3062 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3063 "sub{w}\t{$src2, $dst|$dst, $src2}",
3064 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
3065 (implicit EFLAGS)]>, OpSize;
3066 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3067 "sub{l}\t{$src2, $dst|$dst, $src2}",
3068 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
3069 (implicit EFLAGS)]>;
3070 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3071 "sub{w}\t{$src2, $dst|$dst, $src2}",
3072 [(store (sub (load addr:$dst), i16immSExt8:$src2),
3074 (implicit EFLAGS)]>, OpSize;
3075 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3076 "sub{l}\t{$src2, $dst|$dst, $src2}",
3077 [(store (sub (load addr:$dst), i32immSExt8:$src2),
3079 (implicit EFLAGS)]>;
3081 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
3082 "sub{b}\t{$src, %al|%al, $src}", []>;
3083 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
3084 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3085 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
3086 "sub{l}\t{$src, %eax|%eax, $src}", []>;
3087 } // Constraints = ""
3089 let Uses = [EFLAGS] in {
3090 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
3091 (ins GR8:$src1, GR8:$src2),
3092 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3093 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
3094 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3095 (ins GR16:$src1, GR16:$src2),
3096 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3097 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
3098 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3099 (ins GR32:$src1, GR32:$src2),
3100 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3101 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
3103 let Constraints = "" in {
3104 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3105 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3106 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
3107 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3108 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3109 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
3111 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3112 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3113 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
3114 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3115 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3116 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
3117 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3118 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3119 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
3121 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3122 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3123 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
3125 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
3126 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3127 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
3128 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3129 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3130 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
3132 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3133 "sbb{b}\t{$src, %al|%al, $src}", []>;
3134 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3135 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3136 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3137 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
3138 } // Constraints = ""
3140 let isCodeGenOnly = 1 in {
3141 def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3142 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3143 def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3144 (ins GR16:$src1, GR16:$src2),
3145 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3146 def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3147 (ins GR32:$src1, GR32:$src2),
3148 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3151 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3152 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3153 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
3154 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3155 (ins GR16:$src1, i16mem:$src2),
3156 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3157 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
3159 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3160 (ins GR32:$src1, i32mem:$src2),
3161 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3162 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
3163 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3164 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3165 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
3166 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3167 (ins GR16:$src1, i16imm:$src2),
3168 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3169 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
3170 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3171 (ins GR16:$src1, i16i8imm:$src2),
3172 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3173 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3175 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3176 (ins GR32:$src1, i32imm:$src2),
3177 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3178 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
3179 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3180 (ins GR32:$src1, i32i8imm:$src2),
3181 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3182 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
3183 } // Uses = [EFLAGS]
3184 } // Defs = [EFLAGS]
3186 let Defs = [EFLAGS] in {
3187 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
3188 // Register-Register Signed Integer Multiply
3189 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
3190 "imul{w}\t{$src2, $dst|$dst, $src2}",
3191 [(set GR16:$dst, EFLAGS,
3192 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
3193 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
3194 "imul{l}\t{$src2, $dst|$dst, $src2}",
3195 [(set GR32:$dst, EFLAGS,
3196 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
3199 // Register-Memory Signed Integer Multiply
3200 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3201 (ins GR16:$src1, i16mem:$src2),
3202 "imul{w}\t{$src2, $dst|$dst, $src2}",
3203 [(set GR16:$dst, EFLAGS,
3204 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
3206 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3207 (ins GR32:$src1, i32mem:$src2),
3208 "imul{l}\t{$src2, $dst|$dst, $src2}",
3209 [(set GR32:$dst, EFLAGS,
3210 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
3211 } // Defs = [EFLAGS]
3212 } // end Two Address instructions
3214 // Suprisingly enough, these are not two address instructions!
3215 let Defs = [EFLAGS] in {
3216 // Register-Integer Signed Integer Multiply
3217 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
3218 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
3219 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3220 [(set GR16:$dst, EFLAGS,
3221 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
3222 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
3223 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
3224 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3225 [(set GR32:$dst, EFLAGS,
3226 (X86smul_flag GR32:$src1, imm:$src2))]>;
3227 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
3228 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
3229 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3230 [(set GR16:$dst, EFLAGS,
3231 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
3233 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
3234 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
3235 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3236 [(set GR32:$dst, EFLAGS,
3237 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
3239 // Memory-Integer Signed Integer Multiply
3240 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
3241 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
3242 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3243 [(set GR16:$dst, EFLAGS,
3244 (X86smul_flag (load addr:$src1), imm:$src2))]>,
3246 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
3247 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
3248 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3249 [(set GR32:$dst, EFLAGS,
3250 (X86smul_flag (load addr:$src1), imm:$src2))]>;
3251 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
3252 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
3253 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3254 [(set GR16:$dst, EFLAGS,
3255 (X86smul_flag (load addr:$src1),
3256 i16immSExt8:$src2))]>, OpSize;
3257 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
3258 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
3259 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3260 [(set GR32:$dst, EFLAGS,
3261 (X86smul_flag (load addr:$src1),
3262 i32immSExt8:$src2))]>;
3263 } // Defs = [EFLAGS]
3265 //===----------------------------------------------------------------------===//
3266 // Test instructions are just like AND, except they don't generate a result.
3268 let Defs = [EFLAGS] in {
3269 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
3270 def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3271 "test{b}\t{$src2, $src1|$src1, $src2}",
3272 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
3273 def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3274 "test{w}\t{$src2, $src1|$src1, $src2}",
3275 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
3278 def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3279 "test{l}\t{$src2, $src1|$src1, $src2}",
3280 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
3284 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3285 "test{b}\t{$src, %al|%al, $src}", []>;
3286 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3287 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3288 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3289 "test{l}\t{$src, %eax|%eax, $src}", []>;
3291 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
3292 "test{b}\t{$src2, $src1|$src1, $src2}",
3293 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
3295 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
3296 "test{w}\t{$src2, $src1|$src1, $src2}",
3297 [(set EFLAGS, (X86cmp (and GR16:$src1,
3298 (loadi16 addr:$src2)), 0))]>, OpSize;
3299 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
3300 "test{l}\t{$src2, $src1|$src1, $src2}",
3301 [(set EFLAGS, (X86cmp (and GR32:$src1,
3302 (loadi32 addr:$src2)), 0))]>;
3304 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
3305 (outs), (ins GR8:$src1, i8imm:$src2),
3306 "test{b}\t{$src2, $src1|$src1, $src2}",
3307 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
3308 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
3309 (outs), (ins GR16:$src1, i16imm:$src2),
3310 "test{w}\t{$src2, $src1|$src1, $src2}",
3311 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
3313 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
3314 (outs), (ins GR32:$src1, i32imm:$src2),
3315 "test{l}\t{$src2, $src1|$src1, $src2}",
3316 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
3318 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
3319 (outs), (ins i8mem:$src1, i8imm:$src2),
3320 "test{b}\t{$src2, $src1|$src1, $src2}",
3321 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
3323 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
3324 (outs), (ins i16mem:$src1, i16imm:$src2),
3325 "test{w}\t{$src2, $src1|$src1, $src2}",
3326 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
3328 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
3329 (outs), (ins i32mem:$src1, i32imm:$src2),
3330 "test{l}\t{$src2, $src1|$src1, $src2}",
3331 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
3333 } // Defs = [EFLAGS]
3336 // Condition code ops, incl. set if equal/not equal/...
3337 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
3338 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
3339 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
3340 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
3342 let Uses = [EFLAGS] in {
3343 // Use sbb to materialize carry bit.
3344 let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3345 // FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3346 // However, Pat<> can't replicate the destination reg into the inputs of the
3348 // FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3350 def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
3351 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3352 def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
3353 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
3355 def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
3356 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3359 def SETEr : I<0x94, MRM0r,
3360 (outs GR8 :$dst), (ins),
3362 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
3364 def SETEm : I<0x94, MRM0m,
3365 (outs), (ins i8mem:$dst),
3367 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
3370 def SETNEr : I<0x95, MRM0r,
3371 (outs GR8 :$dst), (ins),
3373 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
3375 def SETNEm : I<0x95, MRM0m,
3376 (outs), (ins i8mem:$dst),
3378 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
3381 def SETLr : I<0x9C, MRM0r,
3382 (outs GR8 :$dst), (ins),
3384 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
3385 TB; // GR8 = < signed
3386 def SETLm : I<0x9C, MRM0m,
3387 (outs), (ins i8mem:$dst),
3389 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
3390 TB; // [mem8] = < signed
3392 def SETGEr : I<0x9D, MRM0r,
3393 (outs GR8 :$dst), (ins),
3395 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
3396 TB; // GR8 = >= signed
3397 def SETGEm : I<0x9D, MRM0m,
3398 (outs), (ins i8mem:$dst),
3400 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
3401 TB; // [mem8] = >= signed
3403 def SETLEr : I<0x9E, MRM0r,
3404 (outs GR8 :$dst), (ins),
3406 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3407 TB; // GR8 = <= signed
3408 def SETLEm : I<0x9E, MRM0m,
3409 (outs), (ins i8mem:$dst),
3411 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3412 TB; // [mem8] = <= signed
3414 def SETGr : I<0x9F, MRM0r,
3415 (outs GR8 :$dst), (ins),
3417 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3418 TB; // GR8 = > signed
3419 def SETGm : I<0x9F, MRM0m,
3420 (outs), (ins i8mem:$dst),
3422 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3423 TB; // [mem8] = > signed
3425 def SETBr : I<0x92, MRM0r,
3426 (outs GR8 :$dst), (ins),
3428 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3429 TB; // GR8 = < unsign
3430 def SETBm : I<0x92, MRM0m,
3431 (outs), (ins i8mem:$dst),
3433 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3434 TB; // [mem8] = < unsign
3436 def SETAEr : I<0x93, MRM0r,
3437 (outs GR8 :$dst), (ins),
3439 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3440 TB; // GR8 = >= unsign
3441 def SETAEm : I<0x93, MRM0m,
3442 (outs), (ins i8mem:$dst),
3444 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3445 TB; // [mem8] = >= unsign
3447 def SETBEr : I<0x96, MRM0r,
3448 (outs GR8 :$dst), (ins),
3450 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3451 TB; // GR8 = <= unsign
3452 def SETBEm : I<0x96, MRM0m,
3453 (outs), (ins i8mem:$dst),
3455 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3456 TB; // [mem8] = <= unsign
3458 def SETAr : I<0x97, MRM0r,
3459 (outs GR8 :$dst), (ins),
3461 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3462 TB; // GR8 = > signed
3463 def SETAm : I<0x97, MRM0m,
3464 (outs), (ins i8mem:$dst),
3466 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3467 TB; // [mem8] = > signed
3469 def SETSr : I<0x98, MRM0r,
3470 (outs GR8 :$dst), (ins),
3472 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3473 TB; // GR8 = <sign bit>
3474 def SETSm : I<0x98, MRM0m,
3475 (outs), (ins i8mem:$dst),
3477 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3478 TB; // [mem8] = <sign bit>
3479 def SETNSr : I<0x99, MRM0r,
3480 (outs GR8 :$dst), (ins),
3482 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3483 TB; // GR8 = !<sign bit>
3484 def SETNSm : I<0x99, MRM0m,
3485 (outs), (ins i8mem:$dst),
3487 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3488 TB; // [mem8] = !<sign bit>
3490 def SETPr : I<0x9A, MRM0r,
3491 (outs GR8 :$dst), (ins),
3493 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3495 def SETPm : I<0x9A, MRM0m,
3496 (outs), (ins i8mem:$dst),
3498 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3499 TB; // [mem8] = parity
3500 def SETNPr : I<0x9B, MRM0r,
3501 (outs GR8 :$dst), (ins),
3503 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3504 TB; // GR8 = not parity
3505 def SETNPm : I<0x9B, MRM0m,
3506 (outs), (ins i8mem:$dst),
3508 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3509 TB; // [mem8] = not parity
3511 def SETOr : I<0x90, MRM0r,
3512 (outs GR8 :$dst), (ins),
3514 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3515 TB; // GR8 = overflow
3516 def SETOm : I<0x90, MRM0m,
3517 (outs), (ins i8mem:$dst),
3519 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3520 TB; // [mem8] = overflow
3521 def SETNOr : I<0x91, MRM0r,
3522 (outs GR8 :$dst), (ins),
3524 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3525 TB; // GR8 = not overflow
3526 def SETNOm : I<0x91, MRM0m,
3527 (outs), (ins i8mem:$dst),
3529 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3530 TB; // [mem8] = not overflow
3531 } // Uses = [EFLAGS]
3534 // Integer comparisons
3535 let Defs = [EFLAGS] in {
3536 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3537 "cmp{b}\t{$src, %al|%al, $src}", []>;
3538 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3539 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3540 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3541 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3543 def CMP8rr : I<0x38, MRMDestReg,
3544 (outs), (ins GR8 :$src1, GR8 :$src2),
3545 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3546 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
3547 def CMP16rr : I<0x39, MRMDestReg,
3548 (outs), (ins GR16:$src1, GR16:$src2),
3549 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3550 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
3551 def CMP32rr : I<0x39, MRMDestReg,
3552 (outs), (ins GR32:$src1, GR32:$src2),
3553 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3554 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
3555 def CMP8mr : I<0x38, MRMDestMem,
3556 (outs), (ins i8mem :$src1, GR8 :$src2),
3557 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3558 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
3559 def CMP16mr : I<0x39, MRMDestMem,
3560 (outs), (ins i16mem:$src1, GR16:$src2),
3561 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3562 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3564 def CMP32mr : I<0x39, MRMDestMem,
3565 (outs), (ins i32mem:$src1, GR32:$src2),
3566 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3567 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
3568 def CMP8rm : I<0x3A, MRMSrcMem,
3569 (outs), (ins GR8 :$src1, i8mem :$src2),
3570 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3571 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
3572 def CMP16rm : I<0x3B, MRMSrcMem,
3573 (outs), (ins GR16:$src1, i16mem:$src2),
3574 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3575 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3577 def CMP32rm : I<0x3B, MRMSrcMem,
3578 (outs), (ins GR32:$src1, i32mem:$src2),
3579 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3580 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
3582 // These are alternate spellings for use by the disassembler, we mark them as
3583 // code gen only to ensure they aren't matched by the assembler.
3584 let isCodeGenOnly = 1 in {
3585 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3586 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3587 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3588 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3589 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3590 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3593 def CMP8ri : Ii8<0x80, MRM7r,
3594 (outs), (ins GR8:$src1, i8imm:$src2),
3595 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3596 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
3597 def CMP16ri : Ii16<0x81, MRM7r,
3598 (outs), (ins GR16:$src1, i16imm:$src2),
3599 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3600 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
3601 def CMP32ri : Ii32<0x81, MRM7r,
3602 (outs), (ins GR32:$src1, i32imm:$src2),
3603 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3604 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
3605 def CMP8mi : Ii8 <0x80, MRM7m,
3606 (outs), (ins i8mem :$src1, i8imm :$src2),
3607 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3608 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
3609 def CMP16mi : Ii16<0x81, MRM7m,
3610 (outs), (ins i16mem:$src1, i16imm:$src2),
3611 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3612 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
3614 def CMP32mi : Ii32<0x81, MRM7m,
3615 (outs), (ins i32mem:$src1, i32imm:$src2),
3616 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3617 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
3618 def CMP16ri8 : Ii8<0x83, MRM7r,
3619 (outs), (ins GR16:$src1, i16i8imm:$src2),
3620 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3621 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3623 def CMP16mi8 : Ii8<0x83, MRM7m,
3624 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3625 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3626 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3627 i16immSExt8:$src2))]>, OpSize;
3628 def CMP32mi8 : Ii8<0x83, MRM7m,
3629 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3630 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3631 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3632 i32immSExt8:$src2))]>;
3633 def CMP32ri8 : Ii8<0x83, MRM7r,
3634 (outs), (ins GR32:$src1, i32i8imm:$src2),
3635 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3636 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
3637 } // Defs = [EFLAGS]
3640 // TODO: BTC, BTR, and BTS
3641 let Defs = [EFLAGS] in {
3642 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3643 "bt{w}\t{$src2, $src1|$src1, $src2}",
3644 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
3645 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3646 "bt{l}\t{$src2, $src1|$src1, $src2}",
3647 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
3649 // Unlike with the register+register form, the memory+register form of the
3650 // bt instruction does not ignore the high bits of the index. From ISel's
3651 // perspective, this is pretty bizarre. Make these instructions disassembly
3654 def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3655 "bt{w}\t{$src2, $src1|$src1, $src2}",
3656 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3657 // (implicit EFLAGS)]
3659 >, OpSize, TB, Requires<[FastBTMem]>;
3660 def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3661 "bt{l}\t{$src2, $src1|$src1, $src2}",
3662 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3663 // (implicit EFLAGS)]
3665 >, TB, Requires<[FastBTMem]>;
3667 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3668 "bt{w}\t{$src2, $src1|$src1, $src2}",
3669 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3671 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3672 "bt{l}\t{$src2, $src1|$src1, $src2}",
3673 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
3674 // Note that these instructions don't need FastBTMem because that
3675 // only applies when the other operand is in a register. When it's
3676 // an immediate, bt is still fast.
3677 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3678 "bt{w}\t{$src2, $src1|$src1, $src2}",
3679 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3681 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3682 "bt{l}\t{$src2, $src1|$src1, $src2}",
3683 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3686 def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3687 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3688 def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3689 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3690 def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3691 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3692 def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3693 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3694 def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3695 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3696 def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3697 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3698 def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3699 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3700 def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3701 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3703 def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3704 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3705 def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3706 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3707 def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3708 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3709 def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3710 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3711 def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3712 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3713 def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3714 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3715 def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3716 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3717 def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3718 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3720 def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3721 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3722 def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3723 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3724 def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3725 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3726 def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3727 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3728 def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3729 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3730 def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3731 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3732 def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3733 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3734 def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3735 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3736 } // Defs = [EFLAGS]
3738 // Sign/Zero extenders
3739 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3740 // of the register here. This has a smaller encoding and avoids a
3741 // partial-register update. Actual movsbw included for the disassembler.
3742 def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3743 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3744 def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3745 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3746 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3747 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
3748 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3749 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3750 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3751 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3752 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3753 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3754 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3755 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3756 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3757 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3758 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3759 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3760 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3761 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3763 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3764 // of the register here. This has a smaller encoding and avoids a
3765 // partial-register update. Actual movzbw included for the disassembler.
3766 def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3767 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3768 def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3769 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3770 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3771 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
3772 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3773 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3774 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3775 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3776 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3777 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3778 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3779 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3780 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3781 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3782 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3783 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3784 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3785 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3787 // These are the same as the regular MOVZX32rr8 and MOVZX32rm8
3788 // except that they use GR32_NOREX for the output operand register class
3789 // instead of GR32. This allows them to operate on h registers on x86-64.
3790 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3791 (outs GR32_NOREX:$dst), (ins GR8:$src),
3792 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3795 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3796 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3797 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3800 let neverHasSideEffects = 1 in {
3801 let Defs = [AX], Uses = [AL] in
3802 def CBW : I<0x98, RawFrm, (outs), (ins),
3803 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3804 let Defs = [EAX], Uses = [AX] in
3805 def CWDE : I<0x98, RawFrm, (outs), (ins),
3806 "{cwtl|cwde}", []>; // EAX = signext(AX)
3808 let Defs = [AX,DX], Uses = [AX] in
3809 def CWD : I<0x99, RawFrm, (outs), (ins),
3810 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3811 let Defs = [EAX,EDX], Uses = [EAX] in
3812 def CDQ : I<0x99, RawFrm, (outs), (ins),
3813 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3816 //===----------------------------------------------------------------------===//
3817 // Alias Instructions
3818 //===----------------------------------------------------------------------===//
3820 // Alias instructions that map movr0 to xor.
3821 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3822 // FIXME: Set encoding to pseudo.
3823 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3824 isCodeGenOnly = 1 in {
3825 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
3826 [(set GR8:$dst, 0)]>;
3828 // We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3829 // encoding and avoids a partial-register update sometimes, but doing so
3830 // at isel time interferes with rematerialization in the current register
3831 // allocator. For now, this is rewritten when the instruction is lowered
3833 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3835 [(set GR16:$dst, 0)]>, OpSize;
3837 // FIXME: Set encoding to pseudo.
3838 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
3839 [(set GR32:$dst, 0)]>;
3842 //===----------------------------------------------------------------------===//
3843 // Thread Local Storage Instructions
3847 // All calls clobber the non-callee saved registers. ESP is marked as
3848 // a use to prevent stack-pointer assignments that appear immediately
3849 // before calls from potentially appearing dead.
3850 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3851 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3852 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3853 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3855 def TLS_addr32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
3856 "leal\t$sym, %eax; "
3857 "call\t___tls_get_addr@PLT",
3858 [(X86tlsaddr tls32addr:$sym)]>,
3859 Requires<[In32BitMode]>;
3861 // Darwin TLS Support
3862 // For i386, the address of the thunk is passed on the stack, on return the
3863 // address of the variable is in %eax. %ecx is trashed during the function
3864 // call. All other registers are preserved.
3865 let Defs = [EAX, ECX],
3867 usesCustomInserter = 1 in
3868 def TLSCall_32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
3870 [(X86TLSCall addr:$sym)]>,
3871 Requires<[In32BitMode]>;
3873 let AddedComplexity = 5, isCodeGenOnly = 1 in
3874 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3875 "movl\t%gs:$src, $dst",
3876 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3878 let AddedComplexity = 5, isCodeGenOnly = 1 in
3879 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3880 "movl\t%fs:$src, $dst",
3881 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3883 //===----------------------------------------------------------------------===//
3884 // EH Pseudo Instructions
3886 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3887 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3888 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3889 "ret\t#eh_return, addr: $addr",
3890 [(X86ehret GR32:$addr)]>;
3894 //===----------------------------------------------------------------------===//
3898 // Atomic swap. These are just normal xchg instructions. But since a memory
3899 // operand is referenced, the atomicity is ensured.
3900 let Constraints = "$val = $dst" in {
3901 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3902 (ins GR32:$val, i32mem:$ptr),
3903 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3904 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3905 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3906 (ins GR16:$val, i16mem:$ptr),
3907 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3908 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3910 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3911 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3912 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3914 def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3915 "xchg{l}\t{$val, $src|$src, $val}", []>;
3916 def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3917 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3918 def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3919 "xchg{b}\t{$val, $src|$src, $val}", []>;
3922 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3923 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3924 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3925 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3927 // Atomic compare and swap.
3928 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3929 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3931 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3932 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3934 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3935 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
3938 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3941 let Defs = [AX, EFLAGS], Uses = [AX] in {
3942 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3944 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3945 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3947 let Defs = [AL, EFLAGS], Uses = [AL] in {
3948 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3950 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3951 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3954 // Atomic exchange and add
3955 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3956 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
3958 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3959 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3961 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
3963 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3964 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3966 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3968 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3969 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3973 def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3974 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3975 def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3976 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3977 def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3978 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3980 let mayLoad = 1, mayStore = 1 in {
3981 def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3982 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3983 def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3984 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3985 def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3986 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3989 def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3990 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3991 def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3992 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3993 def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3994 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3996 let mayLoad = 1, mayStore = 1 in {
3997 def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3998 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3999 def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
4000 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4001 def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
4002 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
4005 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
4006 def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
4007 "cmpxchg8b\t$dst", []>, TB;
4009 // Optimized codegen when the non-memory output is not used.
4010 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
4011 let Defs = [EFLAGS], mayLoad = 1, mayStore = 1 in {
4012 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
4014 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4015 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4017 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4018 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4020 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4021 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
4023 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4024 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
4026 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4027 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
4029 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4030 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
4032 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4033 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4035 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4037 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
4039 "inc{b}\t$dst", []>, LOCK;
4040 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
4042 "inc{w}\t$dst", []>, OpSize, LOCK;
4043 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
4045 "inc{l}\t$dst", []>, LOCK;
4047 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
4049 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4050 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4052 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4053 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4055 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4056 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
4058 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4059 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
4061 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4062 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
4064 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4065 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
4067 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4068 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4070 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4072 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
4074 "dec{b}\t$dst", []>, LOCK;
4075 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
4077 "dec{w}\t$dst", []>, OpSize, LOCK;
4078 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
4080 "dec{l}\t$dst", []>, LOCK;
4083 // Atomic exchange, and, or, xor
4084 let Constraints = "$val = $dst", Defs = [EFLAGS],
4085 usesCustomInserter = 1 in {
4086 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4087 "#ATOMAND32 PSEUDO!",
4088 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
4089 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4090 "#ATOMOR32 PSEUDO!",
4091 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
4092 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4093 "#ATOMXOR32 PSEUDO!",
4094 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
4095 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4096 "#ATOMNAND32 PSEUDO!",
4097 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
4098 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
4099 "#ATOMMIN32 PSEUDO!",
4100 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
4101 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4102 "#ATOMMAX32 PSEUDO!",
4103 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
4104 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4105 "#ATOMUMIN32 PSEUDO!",
4106 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
4107 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4108 "#ATOMUMAX32 PSEUDO!",
4109 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
4111 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4112 "#ATOMAND16 PSEUDO!",
4113 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
4114 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4115 "#ATOMOR16 PSEUDO!",
4116 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
4117 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4118 "#ATOMXOR16 PSEUDO!",
4119 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
4120 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4121 "#ATOMNAND16 PSEUDO!",
4122 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
4123 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
4124 "#ATOMMIN16 PSEUDO!",
4125 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
4126 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4127 "#ATOMMAX16 PSEUDO!",
4128 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
4129 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4130 "#ATOMUMIN16 PSEUDO!",
4131 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
4132 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4133 "#ATOMUMAX16 PSEUDO!",
4134 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
4136 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4137 "#ATOMAND8 PSEUDO!",
4138 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
4139 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4141 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
4142 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4143 "#ATOMXOR8 PSEUDO!",
4144 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
4145 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4146 "#ATOMNAND8 PSEUDO!",
4147 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
4150 let Constraints = "$val1 = $dst1, $val2 = $dst2",
4151 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4152 Uses = [EAX, EBX, ECX, EDX],
4153 mayLoad = 1, mayStore = 1,
4154 usesCustomInserter = 1 in {
4155 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4156 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4157 "#ATOMAND6432 PSEUDO!", []>;
4158 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4159 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4160 "#ATOMOR6432 PSEUDO!", []>;
4161 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4162 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4163 "#ATOMXOR6432 PSEUDO!", []>;
4164 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4165 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4166 "#ATOMNAND6432 PSEUDO!", []>;
4167 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4168 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4169 "#ATOMADD6432 PSEUDO!", []>;
4170 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4171 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4172 "#ATOMSUB6432 PSEUDO!", []>;
4173 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4174 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4175 "#ATOMSWAP6432 PSEUDO!", []>;
4178 // Segmentation support instructions.
4180 def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4181 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4182 def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4183 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4185 // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4186 def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4187 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4188 def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4189 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4191 def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4192 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4193 def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4194 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4195 def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4196 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4197 def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4198 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4200 def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
4202 def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4203 "str{w}\t{$dst}", []>, TB;
4204 def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4205 "str{w}\t{$dst}", []>, TB;
4206 def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4207 "ltr{w}\t{$src}", []>, TB;
4208 def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4209 "ltr{w}\t{$src}", []>, TB;
4211 def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4212 "push{w}\t%fs", []>, OpSize, TB;
4213 def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4214 "push{l}\t%fs", []>, TB;
4215 def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4216 "push{w}\t%gs", []>, OpSize, TB;
4217 def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4218 "push{l}\t%gs", []>, TB;
4220 def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4221 "pop{w}\t%fs", []>, OpSize, TB;
4222 def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4223 "pop{l}\t%fs", []>, TB;
4224 def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4225 "pop{w}\t%gs", []>, OpSize, TB;
4226 def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4227 "pop{l}\t%gs", []>, TB;
4229 def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4230 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4231 def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4232 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4233 def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4234 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4235 def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4236 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4237 def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4238 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4239 def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4240 "les{l}\t{$src, $dst|$dst, $src}", []>;
4241 def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4242 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4243 def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4244 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4245 def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4246 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4247 def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4248 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4250 def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4251 "verr\t$seg", []>, TB;
4252 def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4253 "verr\t$seg", []>, TB;
4254 def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4255 "verw\t$seg", []>, TB;
4256 def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4257 "verw\t$seg", []>, TB;
4259 // Descriptor-table support instructions
4261 def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4262 "sgdt\t$dst", []>, TB;
4263 def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4264 "sidt\t$dst", []>, TB;
4265 def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4266 "sldt{w}\t$dst", []>, TB;
4267 def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4268 "sldt{w}\t$dst", []>, TB;
4269 def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4270 "lgdt\t$src", []>, TB;
4271 def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4272 "lidt\t$src", []>, TB;
4273 def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4274 "lldt{w}\t$src", []>, TB;
4275 def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4276 "lldt{w}\t$src", []>, TB;
4278 // Lock instruction prefix
4279 def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4281 // Repeat string operation instruction prefixes
4282 // These uses the DF flag in the EFLAGS register to inc or dec ECX
4283 let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4284 // Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4285 def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4286 // Repeat while not equal (used with CMPS and SCAS)
4287 def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4290 // Segment override instruction prefixes
4291 def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4292 def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4293 def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4294 def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4295 def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4296 def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4298 // String manipulation instructions
4300 def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4301 def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
4302 def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4304 def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4305 def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4306 def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4308 // CPU flow control instructions
4310 def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4311 def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4313 // FPU control instructions
4315 def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4317 // Flag instructions
4319 def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4320 def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4321 def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4322 def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4323 def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4324 def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4325 def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4327 def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4329 // Table lookup instructions
4331 def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4333 // Specialized register support
4335 def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4336 def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4337 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4339 def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4340 "smsw{w}\t$dst", []>, OpSize, TB;
4341 def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4342 "smsw{l}\t$dst", []>, TB;
4343 // For memory operands, there is only a 16-bit form
4344 def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4345 "smsw{w}\t$dst", []>, TB;
4347 def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4348 "lmsw{w}\t$src", []>, TB;
4349 def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4350 "lmsw{w}\t$src", []>, TB;
4352 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4354 // Cache instructions
4356 def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4357 def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4362 def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
4364 def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
4366 def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
4367 def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4368 "vmclear\t$vmcs", []>, OpSize, TB;
4370 def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
4372 def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
4373 def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4374 "vmptrld\t$vmcs", []>, TB;
4375 def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4376 "vmptrst\t$vmcs", []>, TB;
4377 def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4378 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4379 def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4380 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4381 def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4382 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4383 def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4384 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4385 def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4386 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4387 def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4388 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4389 def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4390 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4391 def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4392 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4394 def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
4395 def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4396 "vmxon\t{$vmxon}", []>, XS;
4398 //===----------------------------------------------------------------------===//
4399 // Non-Instruction Patterns
4400 //===----------------------------------------------------------------------===//
4402 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
4403 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4404 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
4405 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
4406 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4407 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
4408 def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
4410 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4411 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4412 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4413 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4414 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4415 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4416 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4417 (ADD32ri GR32:$src1, texternalsym:$src2)>;
4418 def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4419 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
4421 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4422 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4423 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4424 (MOV32mi addr:$dst, texternalsym:$src)>;
4425 def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4426 (MOV32mi addr:$dst, tblockaddress:$src)>;
4430 def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4431 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4432 Requires<[In32BitMode]>;
4434 // FIXME: This is disabled for 32-bit PIC mode because the global base
4435 // register which is part of the address mode may be assigned a
4436 // callee-saved register.
4437 def : Pat<(X86tcret (load addr:$dst), imm:$off),
4438 (TCRETURNmi addr:$dst, imm:$off)>,
4439 Requires<[In32BitMode, IsNotPIC]>;
4441 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4442 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4443 Requires<[In32BitMode]>;
4445 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4446 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4447 Requires<[In32BitMode]>;
4449 // Normal calls, with various flavors of addresses.
4450 def : Pat<(X86call (i32 tglobaladdr:$dst)),
4451 (CALLpcrel32 tglobaladdr:$dst)>;
4452 def : Pat<(X86call (i32 texternalsym:$dst)),
4453 (CALLpcrel32 texternalsym:$dst)>;
4454 def : Pat<(X86call (i32 imm:$dst)),
4455 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
4457 // X86 specific add which produces a flag.
4458 def : Pat<(addc GR32:$src1, GR32:$src2),
4459 (ADD32rr GR32:$src1, GR32:$src2)>;
4460 def : Pat<(addc GR32:$src1, (load addr:$src2)),
4461 (ADD32rm GR32:$src1, addr:$src2)>;
4462 def : Pat<(addc GR32:$src1, imm:$src2),
4463 (ADD32ri GR32:$src1, imm:$src2)>;
4464 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4465 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4467 def : Pat<(subc GR32:$src1, GR32:$src2),
4468 (SUB32rr GR32:$src1, GR32:$src2)>;
4469 def : Pat<(subc GR32:$src1, (load addr:$src2)),
4470 (SUB32rm GR32:$src1, addr:$src2)>;
4471 def : Pat<(subc GR32:$src1, imm:$src2),
4472 (SUB32ri GR32:$src1, imm:$src2)>;
4473 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4474 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4478 // TEST R,R is smaller than CMP R,0
4479 def : Pat<(X86cmp GR8:$src1, 0),
4480 (TEST8rr GR8:$src1, GR8:$src1)>;
4481 def : Pat<(X86cmp GR16:$src1, 0),
4482 (TEST16rr GR16:$src1, GR16:$src1)>;
4483 def : Pat<(X86cmp GR32:$src1, 0),
4484 (TEST32rr GR32:$src1, GR32:$src1)>;
4486 // Conditional moves with folded loads with operands swapped and conditions
4488 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4489 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4490 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4491 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4492 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4493 (CMOVB16rm GR16:$src2, addr:$src1)>;
4494 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4495 (CMOVB32rm GR32:$src2, addr:$src1)>;
4496 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4497 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4498 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4499 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4500 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4501 (CMOVE16rm GR16:$src2, addr:$src1)>;
4502 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4503 (CMOVE32rm GR32:$src2, addr:$src1)>;
4504 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4505 (CMOVA16rm GR16:$src2, addr:$src1)>;
4506 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4507 (CMOVA32rm GR32:$src2, addr:$src1)>;
4508 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4509 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4510 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4511 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4512 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4513 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4514 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4515 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4516 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4517 (CMOVL16rm GR16:$src2, addr:$src1)>;
4518 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4519 (CMOVL32rm GR32:$src2, addr:$src1)>;
4520 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4521 (CMOVG16rm GR16:$src2, addr:$src1)>;
4522 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4523 (CMOVG32rm GR32:$src2, addr:$src1)>;
4524 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4525 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4526 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4527 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4528 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4529 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4530 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4531 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4532 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4533 (CMOVP16rm GR16:$src2, addr:$src1)>;
4534 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4535 (CMOVP32rm GR32:$src2, addr:$src1)>;
4536 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4537 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4538 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4539 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4540 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4541 (CMOVS16rm GR16:$src2, addr:$src1)>;
4542 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4543 (CMOVS32rm GR32:$src2, addr:$src1)>;
4544 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4545 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4546 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4547 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4548 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4549 (CMOVO16rm GR16:$src2, addr:$src1)>;
4550 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4551 (CMOVO32rm GR32:$src2, addr:$src1)>;
4553 // zextload bool -> zextload byte
4554 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4555 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4556 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4558 // extload bool -> extload byte
4559 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4560 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4561 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4562 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
4563 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4564 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4566 // anyext. Define these to do an explicit zero-extend to
4567 // avoid partial-register updates.
4568 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4569 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4571 // Except for i16 -> i32 since isel expect i16 ops to be promoted to i32.
4572 def : Pat<(i32 (anyext GR16:$src)),
4573 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, sub_16bit)>;
4576 //===----------------------------------------------------------------------===//
4578 //===----------------------------------------------------------------------===//
4580 // Odd encoding trick: -128 fits into an 8-bit immediate field while
4581 // +128 doesn't, so in this special case use a sub instead of an add.
4582 def : Pat<(add GR16:$src1, 128),
4583 (SUB16ri8 GR16:$src1, -128)>;
4584 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4585 (SUB16mi8 addr:$dst, -128)>;
4586 def : Pat<(add GR32:$src1, 128),
4587 (SUB32ri8 GR32:$src1, -128)>;
4588 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4589 (SUB32mi8 addr:$dst, -128)>;
4591 // r & (2^16-1) ==> movz
4592 def : Pat<(and GR32:$src1, 0xffff),
4593 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, sub_16bit))>;
4594 // r & (2^8-1) ==> movz
4595 def : Pat<(and GR32:$src1, 0xff),
4596 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4599 Requires<[In32BitMode]>;
4600 // r & (2^8-1) ==> movz
4601 def : Pat<(and GR16:$src1, 0xff),
4602 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4605 Requires<[In32BitMode]>;
4607 // sext_inreg patterns
4608 def : Pat<(sext_inreg GR32:$src, i16),
4609 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, sub_16bit))>;
4610 def : Pat<(sext_inreg GR32:$src, i8),
4611 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4614 Requires<[In32BitMode]>;
4615 def : Pat<(sext_inreg GR16:$src, i8),
4616 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4619 Requires<[In32BitMode]>;
4622 def : Pat<(i16 (trunc GR32:$src)),
4623 (EXTRACT_SUBREG GR32:$src, sub_16bit)>;
4624 def : Pat<(i8 (trunc GR32:$src)),
4625 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4627 Requires<[In32BitMode]>;
4628 def : Pat<(i8 (trunc GR16:$src)),
4629 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4631 Requires<[In32BitMode]>;
4633 // h-register tricks
4634 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
4635 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4637 Requires<[In32BitMode]>;
4638 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
4639 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4641 Requires<[In32BitMode]>;
4642 def : Pat<(srl GR16:$src, (i8 8)),
4645 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4648 Requires<[In32BitMode]>;
4649 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
4650 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4653 Requires<[In32BitMode]>;
4654 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
4655 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4658 Requires<[In32BitMode]>;
4659 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
4660 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4663 Requires<[In32BitMode]>;
4664 def : Pat<(srl (and_su GR32:$src, 0xff00), (i8 8)),
4665 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4668 Requires<[In32BitMode]>;
4670 // (shl x, 1) ==> (add x, x)
4671 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4672 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4673 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4675 // (shl x (and y, 31)) ==> (shl x, y)
4676 def : Pat<(shl GR8:$src1, (and CL, 31)),
4677 (SHL8rCL GR8:$src1)>;
4678 def : Pat<(shl GR16:$src1, (and CL, 31)),
4679 (SHL16rCL GR16:$src1)>;
4680 def : Pat<(shl GR32:$src1, (and CL, 31)),
4681 (SHL32rCL GR32:$src1)>;
4682 def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4683 (SHL8mCL addr:$dst)>;
4684 def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4685 (SHL16mCL addr:$dst)>;
4686 def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4687 (SHL32mCL addr:$dst)>;
4689 def : Pat<(srl GR8:$src1, (and CL, 31)),
4690 (SHR8rCL GR8:$src1)>;
4691 def : Pat<(srl GR16:$src1, (and CL, 31)),
4692 (SHR16rCL GR16:$src1)>;
4693 def : Pat<(srl GR32:$src1, (and CL, 31)),
4694 (SHR32rCL GR32:$src1)>;
4695 def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4696 (SHR8mCL addr:$dst)>;
4697 def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4698 (SHR16mCL addr:$dst)>;
4699 def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4700 (SHR32mCL addr:$dst)>;
4702 def : Pat<(sra GR8:$src1, (and CL, 31)),
4703 (SAR8rCL GR8:$src1)>;
4704 def : Pat<(sra GR16:$src1, (and CL, 31)),
4705 (SAR16rCL GR16:$src1)>;
4706 def : Pat<(sra GR32:$src1, (and CL, 31)),
4707 (SAR32rCL GR32:$src1)>;
4708 def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4709 (SAR8mCL addr:$dst)>;
4710 def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4711 (SAR16mCL addr:$dst)>;
4712 def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4713 (SAR32mCL addr:$dst)>;
4715 // (anyext (setcc_carry)) -> (setcc_carry)
4716 def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4718 def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4720 def : Pat<(i32 (anyext (i16 (X86setcc_c X86_COND_B, EFLAGS)))),
4723 // (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
4724 let AddedComplexity = 5 in { // Try this before the selecting to OR
4725 def : Pat<(or_is_add GR16:$src1, imm:$src2),
4726 (ADD16ri GR16:$src1, imm:$src2)>;
4727 def : Pat<(or_is_add GR32:$src1, imm:$src2),
4728 (ADD32ri GR32:$src1, imm:$src2)>;
4729 def : Pat<(or_is_add GR16:$src1, i16immSExt8:$src2),
4730 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4731 def : Pat<(or_is_add GR32:$src1, i32immSExt8:$src2),
4732 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4733 def : Pat<(or_is_add GR16:$src1, GR16:$src2),
4734 (ADD16rr GR16:$src1, GR16:$src2)>;
4735 def : Pat<(or_is_add GR32:$src1, GR32:$src2),
4736 (ADD32rr GR32:$src1, GR32:$src2)>;
4737 } // AddedComplexity
4739 //===----------------------------------------------------------------------===//
4740 // EFLAGS-defining Patterns
4741 //===----------------------------------------------------------------------===//
4744 def : Pat<(add GR8 :$src1, GR8 :$src2), (ADD8rr GR8 :$src1, GR8 :$src2)>;
4745 def : Pat<(add GR16:$src1, GR16:$src2), (ADD16rr GR16:$src1, GR16:$src2)>;
4746 def : Pat<(add GR32:$src1, GR32:$src2), (ADD32rr GR32:$src1, GR32:$src2)>;
4749 def : Pat<(add GR8:$src1, (loadi8 addr:$src2)),
4750 (ADD8rm GR8:$src1, addr:$src2)>;
4751 def : Pat<(add GR16:$src1, (loadi16 addr:$src2)),
4752 (ADD16rm GR16:$src1, addr:$src2)>;
4753 def : Pat<(add GR32:$src1, (loadi32 addr:$src2)),
4754 (ADD32rm GR32:$src1, addr:$src2)>;
4757 def : Pat<(add GR8 :$src1, imm:$src2), (ADD8ri GR8:$src1 , imm:$src2)>;
4758 def : Pat<(add GR16:$src1, imm:$src2), (ADD16ri GR16:$src1, imm:$src2)>;
4759 def : Pat<(add GR32:$src1, imm:$src2), (ADD32ri GR32:$src1, imm:$src2)>;
4760 def : Pat<(add GR16:$src1, i16immSExt8:$src2),
4761 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4762 def : Pat<(add GR32:$src1, i32immSExt8:$src2),
4763 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4766 def : Pat<(sub GR8 :$src1, GR8 :$src2), (SUB8rr GR8 :$src1, GR8 :$src2)>;
4767 def : Pat<(sub GR16:$src1, GR16:$src2), (SUB16rr GR16:$src1, GR16:$src2)>;
4768 def : Pat<(sub GR32:$src1, GR32:$src2), (SUB32rr GR32:$src1, GR32:$src2)>;
4771 def : Pat<(sub GR8:$src1, (loadi8 addr:$src2)),
4772 (SUB8rm GR8:$src1, addr:$src2)>;
4773 def : Pat<(sub GR16:$src1, (loadi16 addr:$src2)),
4774 (SUB16rm GR16:$src1, addr:$src2)>;
4775 def : Pat<(sub GR32:$src1, (loadi32 addr:$src2)),
4776 (SUB32rm GR32:$src1, addr:$src2)>;
4779 def : Pat<(sub GR8:$src1, imm:$src2),
4780 (SUB8ri GR8:$src1, imm:$src2)>;
4781 def : Pat<(sub GR16:$src1, imm:$src2),
4782 (SUB16ri GR16:$src1, imm:$src2)>;
4783 def : Pat<(sub GR32:$src1, imm:$src2),
4784 (SUB32ri GR32:$src1, imm:$src2)>;
4785 def : Pat<(sub GR16:$src1, i16immSExt8:$src2),
4786 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4787 def : Pat<(sub GR32:$src1, i32immSExt8:$src2),
4788 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4791 def : Pat<(mul GR16:$src1, GR16:$src2),
4792 (IMUL16rr GR16:$src1, GR16:$src2)>;
4793 def : Pat<(mul GR32:$src1, GR32:$src2),
4794 (IMUL32rr GR32:$src1, GR32:$src2)>;
4797 def : Pat<(mul GR16:$src1, (loadi16 addr:$src2)),
4798 (IMUL16rm GR16:$src1, addr:$src2)>;
4799 def : Pat<(mul GR32:$src1, (loadi32 addr:$src2)),
4800 (IMUL32rm GR32:$src1, addr:$src2)>;
4803 def : Pat<(mul GR16:$src1, imm:$src2),
4804 (IMUL16rri GR16:$src1, imm:$src2)>;
4805 def : Pat<(mul GR32:$src1, imm:$src2),
4806 (IMUL32rri GR32:$src1, imm:$src2)>;
4807 def : Pat<(mul GR16:$src1, i16immSExt8:$src2),
4808 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4809 def : Pat<(mul GR32:$src1, i32immSExt8:$src2),
4810 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4812 // reg = mul mem, imm
4813 def : Pat<(mul (loadi16 addr:$src1), imm:$src2),
4814 (IMUL16rmi addr:$src1, imm:$src2)>;
4815 def : Pat<(mul (loadi32 addr:$src1), imm:$src2),
4816 (IMUL32rmi addr:$src1, imm:$src2)>;
4817 def : Pat<(mul (loadi16 addr:$src1), i16immSExt8:$src2),
4818 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4819 def : Pat<(mul (loadi32 addr:$src1), i32immSExt8:$src2),
4820 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4822 // Optimize multiply by 2 with EFLAGS result.
4823 let AddedComplexity = 2 in {
4824 def : Pat<(X86smul_flag GR16:$src1, 2), (ADD16rr GR16:$src1, GR16:$src1)>;
4825 def : Pat<(X86smul_flag GR32:$src1, 2), (ADD32rr GR32:$src1, GR32:$src1)>;
4828 // Patterns for nodes that do not produce flags, for instructions that do.
4831 def : Pat<(add GR8:$src1 , 1), (INC8r GR8:$src1)>;
4832 def : Pat<(add GR16:$src1, 1), (INC16r GR16:$src1)>, Requires<[In32BitMode]>;
4833 def : Pat<(add GR32:$src1, 1), (INC32r GR32:$src1)>, Requires<[In32BitMode]>;
4836 def : Pat<(add GR8:$src1 , -1), (DEC8r GR8:$src1)>;
4837 def : Pat<(add GR16:$src1, -1), (DEC16r GR16:$src1)>, Requires<[In32BitMode]>;
4838 def : Pat<(add GR32:$src1, -1), (DEC32r GR32:$src1)>, Requires<[In32BitMode]>;
4841 def : Pat<(or GR8 :$src1, GR8 :$src2), (OR8rr GR8 :$src1, GR8 :$src2)>;
4842 def : Pat<(or GR16:$src1, GR16:$src2), (OR16rr GR16:$src1, GR16:$src2)>;
4843 def : Pat<(or GR32:$src1, GR32:$src2), (OR32rr GR32:$src1, GR32:$src2)>;
4846 def : Pat<(or GR8:$src1, (loadi8 addr:$src2)),
4847 (OR8rm GR8:$src1, addr:$src2)>;
4848 def : Pat<(or GR16:$src1, (loadi16 addr:$src2)),
4849 (OR16rm GR16:$src1, addr:$src2)>;
4850 def : Pat<(or GR32:$src1, (loadi32 addr:$src2)),
4851 (OR32rm GR32:$src1, addr:$src2)>;
4854 def : Pat<(or GR8:$src1 , imm:$src2), (OR8ri GR8 :$src1, imm:$src2)>;
4855 def : Pat<(or GR16:$src1, imm:$src2), (OR16ri GR16:$src1, imm:$src2)>;
4856 def : Pat<(or GR32:$src1, imm:$src2), (OR32ri GR32:$src1, imm:$src2)>;
4857 def : Pat<(or GR16:$src1, i16immSExt8:$src2),
4858 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4859 def : Pat<(or GR32:$src1, i32immSExt8:$src2),
4860 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4863 def : Pat<(xor GR8 :$src1, GR8 :$src2), (XOR8rr GR8 :$src1, GR8 :$src2)>;
4864 def : Pat<(xor GR16:$src1, GR16:$src2), (XOR16rr GR16:$src1, GR16:$src2)>;
4865 def : Pat<(xor GR32:$src1, GR32:$src2), (XOR32rr GR32:$src1, GR32:$src2)>;
4868 def : Pat<(xor GR8:$src1, (loadi8 addr:$src2)),
4869 (XOR8rm GR8:$src1, addr:$src2)>;
4870 def : Pat<(xor GR16:$src1, (loadi16 addr:$src2)),
4871 (XOR16rm GR16:$src1, addr:$src2)>;
4872 def : Pat<(xor GR32:$src1, (loadi32 addr:$src2)),
4873 (XOR32rm GR32:$src1, addr:$src2)>;
4876 def : Pat<(xor GR8:$src1, imm:$src2),
4877 (XOR8ri GR8:$src1, imm:$src2)>;
4878 def : Pat<(xor GR16:$src1, imm:$src2),
4879 (XOR16ri GR16:$src1, imm:$src2)>;
4880 def : Pat<(xor GR32:$src1, imm:$src2),
4881 (XOR32ri GR32:$src1, imm:$src2)>;
4882 def : Pat<(xor GR16:$src1, i16immSExt8:$src2),
4883 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4884 def : Pat<(xor GR32:$src1, i32immSExt8:$src2),
4885 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4888 def : Pat<(and GR8 :$src1, GR8 :$src2), (AND8rr GR8 :$src1, GR8 :$src2)>;
4889 def : Pat<(and GR16:$src1, GR16:$src2), (AND16rr GR16:$src1, GR16:$src2)>;
4890 def : Pat<(and GR32:$src1, GR32:$src2), (AND32rr GR32:$src1, GR32:$src2)>;
4893 def : Pat<(and GR8:$src1, (loadi8 addr:$src2)),
4894 (AND8rm GR8:$src1, addr:$src2)>;
4895 def : Pat<(and GR16:$src1, (loadi16 addr:$src2)),
4896 (AND16rm GR16:$src1, addr:$src2)>;
4897 def : Pat<(and GR32:$src1, (loadi32 addr:$src2)),
4898 (AND32rm GR32:$src1, addr:$src2)>;
4901 def : Pat<(and GR8:$src1, imm:$src2),
4902 (AND8ri GR8:$src1, imm:$src2)>;
4903 def : Pat<(and GR16:$src1, imm:$src2),
4904 (AND16ri GR16:$src1, imm:$src2)>;
4905 def : Pat<(and GR32:$src1, imm:$src2),
4906 (AND32ri GR32:$src1, imm:$src2)>;
4907 def : Pat<(and GR16:$src1, i16immSExt8:$src2),
4908 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
4909 def : Pat<(and GR32:$src1, i32immSExt8:$src2),
4910 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4912 //===----------------------------------------------------------------------===//
4913 // Floating Point Stack Support
4914 //===----------------------------------------------------------------------===//
4916 include "X86InstrFPStack.td"
4918 //===----------------------------------------------------------------------===//
4920 //===----------------------------------------------------------------------===//
4922 include "X86Instr64bit.td"
4924 //===----------------------------------------------------------------------===//
4925 // SIMD support (SSE, MMX and AVX)
4926 //===----------------------------------------------------------------------===//
4928 include "X86InstrFragmentsSIMD.td"
4930 //===----------------------------------------------------------------------===//
4931 // XMM Floating point support (requires SSE / SSE2)
4932 //===----------------------------------------------------------------------===//
4934 include "X86InstrSSE.td"
4936 //===----------------------------------------------------------------------===//
4937 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4938 //===----------------------------------------------------------------------===//
4940 include "X86InstrMMX.td"