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 "jmp{l}\t{*}$dst # TAILCALL",
751 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem_TC:$dst, variable_ops),
752 "jmp{l}\t{*}$dst # TAILCALL", []>;
754 // FIXME: This is a hack so that MCInst lowering can preserve the TAILCALL
755 // marker on instructions, while still being able to relax.
756 let isCodeGenOnly = 1 in {
757 def TAILJMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
758 "jmp\t$dst # TAILCALL", []>;
762 //===----------------------------------------------------------------------===//
763 // Miscellaneous Instructions...
765 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
766 def LEAVE : I<0xC9, RawFrm,
767 (outs), (ins), "leave", []>;
769 def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
770 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
772 def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
773 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
774 def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
775 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
777 def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
778 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
780 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
782 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
784 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
785 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
787 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
789 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
790 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
793 let mayStore = 1 in {
794 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
796 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
797 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
799 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
801 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
802 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
806 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
807 def PUSHi8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
808 "push{l}\t$imm", []>;
809 def PUSHi16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
810 "push{w}\t$imm", []>, OpSize;
811 def PUSHi32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
812 "push{l}\t$imm", []>;
815 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
816 def POPF16 : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
817 def POPF32 : I<0x9D, RawFrm, (outs), (ins), "popf{l|d}", []>,
818 Requires<[In32BitMode]>;
820 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
821 def PUSHF16 : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
822 def PUSHF32 : I<0x9C, RawFrm, (outs), (ins), "pushf{l|d}", []>,
823 Requires<[In32BitMode]>;
826 let Defs = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], Uses = [ESP],
827 mayLoad=1, neverHasSideEffects=1 in {
828 def POPA32 : I<0x61, RawFrm, (outs), (ins), "popa{l}", []>,
829 Requires<[In32BitMode]>;
831 let Defs = [ESP], Uses = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP],
832 mayStore=1, neverHasSideEffects=1 in {
833 def PUSHA32 : I<0x60, RawFrm, (outs), (ins), "pusha{l}", []>,
834 Requires<[In32BitMode]>;
837 let Uses = [EFLAGS], Constraints = "$src = $dst" in // GR32 = bswap GR32
838 def BSWAP32r : I<0xC8, AddRegFrm,
839 (outs GR32:$dst), (ins GR32:$src),
841 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
844 // Bit scan instructions.
845 let Defs = [EFLAGS] in {
846 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
847 "bsf{w}\t{$src, $dst|$dst, $src}",
848 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB, OpSize;
849 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
850 "bsf{w}\t{$src, $dst|$dst, $src}",
851 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB,
853 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
854 "bsf{l}\t{$src, $dst|$dst, $src}",
855 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
856 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
857 "bsf{l}\t{$src, $dst|$dst, $src}",
858 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
860 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
861 "bsr{w}\t{$src, $dst|$dst, $src}",
862 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB, OpSize;
863 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
864 "bsr{w}\t{$src, $dst|$dst, $src}",
865 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB,
867 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
868 "bsr{l}\t{$src, $dst|$dst, $src}",
869 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
870 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
871 "bsr{l}\t{$src, $dst|$dst, $src}",
872 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
875 let neverHasSideEffects = 1 in
876 def LEA16r : I<0x8D, MRMSrcMem,
877 (outs GR16:$dst), (ins i32mem:$src),
878 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
879 let isReMaterializable = 1 in
880 def LEA32r : I<0x8D, MRMSrcMem,
881 (outs GR32:$dst), (ins i32mem:$src),
882 "lea{l}\t{$src|$dst}, {$dst|$src}",
883 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
885 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
886 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
887 [(X86rep_movs i8)]>, REP;
888 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
889 [(X86rep_movs i16)]>, REP, OpSize;
890 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
891 [(X86rep_movs i32)]>, REP;
894 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
895 let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
896 def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
897 def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
898 def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
901 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
902 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
903 [(X86rep_stos i8)]>, REP;
904 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
905 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
906 [(X86rep_stos i16)]>, REP, OpSize;
907 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
908 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
909 [(X86rep_stos i32)]>, REP;
911 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
912 let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
913 def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
914 let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
915 def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
916 let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
917 def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
919 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
920 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
921 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
923 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
924 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
925 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
927 let Defs = [RAX, RDX] in
928 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
931 let Defs = [RAX, RCX, RDX] in
932 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
934 let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in {
935 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
938 def SYSCALL : I<0x05, RawFrm,
939 (outs), (ins), "syscall", []>, TB;
940 def SYSRET : I<0x07, RawFrm,
941 (outs), (ins), "sysret", []>, TB;
942 def SYSENTER : I<0x34, RawFrm,
943 (outs), (ins), "sysenter", []>, TB;
944 def SYSEXIT : I<0x35, RawFrm,
945 (outs), (ins), "sysexit", []>, TB;
947 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
950 //===----------------------------------------------------------------------===//
951 // Input/Output Instructions...
953 let Defs = [AL], Uses = [DX] in
954 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
955 "in{b}\t{%dx, %al|%AL, %DX}", []>;
956 let Defs = [AX], Uses = [DX] in
957 def IN16rr : I<0xED, RawFrm, (outs), (ins),
958 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
959 let Defs = [EAX], Uses = [DX] in
960 def IN32rr : I<0xED, RawFrm, (outs), (ins),
961 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
964 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
965 "in{b}\t{$port, %al|%AL, $port}", []>;
967 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
968 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
970 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
971 "in{l}\t{$port, %eax|%EAX, $port}", []>;
973 let Uses = [DX, AL] in
974 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
975 "out{b}\t{%al, %dx|%DX, %AL}", []>;
976 let Uses = [DX, AX] in
977 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
978 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
979 let Uses = [DX, EAX] in
980 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
981 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
984 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
985 "out{b}\t{%al, $port|$port, %AL}", []>;
987 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
988 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
990 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
991 "out{l}\t{%eax, $port|$port, %EAX}", []>;
993 def IN8 : I<0x6C, RawFrm, (outs), (ins),
995 def IN16 : I<0x6D, RawFrm, (outs), (ins),
996 "ins{w}", []>, OpSize;
997 def IN32 : I<0x6D, RawFrm, (outs), (ins),
1000 //===----------------------------------------------------------------------===//
1001 // Move Instructions...
1003 let neverHasSideEffects = 1 in {
1004 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
1005 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1006 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
1007 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1008 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
1009 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1011 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
1012 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
1013 "mov{b}\t{$src, $dst|$dst, $src}",
1014 [(set GR8:$dst, imm:$src)]>;
1015 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
1016 "mov{w}\t{$src, $dst|$dst, $src}",
1017 [(set GR16:$dst, imm:$src)]>, OpSize;
1018 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
1019 "mov{l}\t{$src, $dst|$dst, $src}",
1020 [(set GR32:$dst, imm:$src)]>;
1023 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
1024 "mov{b}\t{$src, $dst|$dst, $src}",
1025 [(store (i8 imm:$src), addr:$dst)]>;
1026 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
1027 "mov{w}\t{$src, $dst|$dst, $src}",
1028 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
1029 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
1030 "mov{l}\t{$src, $dst|$dst, $src}",
1031 [(store (i32 imm:$src), addr:$dst)]>;
1033 /// moffs8, moffs16 and moffs32 versions of moves. The immediate is a
1034 /// 32-bit offset from the PC. These are only valid in x86-32 mode.
1035 def MOV8o8a : Ii32 <0xA0, RawFrm, (outs), (ins offset8:$src),
1036 "mov{b}\t{$src, %al|%al, $src}", []>;
1037 def MOV16o16a : Ii32 <0xA1, RawFrm, (outs), (ins offset16:$src),
1038 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1039 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
1040 "mov{l}\t{$src, %eax|%eax, $src}", []>;
1041 def MOV8ao8 : Ii32 <0xA2, RawFrm, (outs offset8:$dst), (ins),
1042 "mov{b}\t{%al, $dst|$dst, %al}", []>;
1043 def MOV16ao16 : Ii32 <0xA3, RawFrm, (outs offset16:$dst), (ins),
1044 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
1045 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
1046 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1048 // Moves to and from segment registers
1049 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1050 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1051 def MOV32rs : I<0x8C, MRMDestReg, (outs GR32:$dst), (ins SEGMENT_REG:$src),
1052 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1053 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1054 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1055 def MOV32ms : I<0x8C, MRMDestMem, (outs i32mem:$dst), (ins SEGMENT_REG:$src),
1056 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1057 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1058 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1059 def MOV32sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR32:$src),
1060 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1061 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1062 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1063 def MOV32sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i32mem:$src),
1064 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1066 let isCodeGenOnly = 1 in {
1067 def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1068 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1069 def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1070 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1071 def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1072 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1075 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1076 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
1077 "mov{b}\t{$src, $dst|$dst, $src}",
1078 [(set GR8:$dst, (loadi8 addr:$src))]>;
1079 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
1080 "mov{w}\t{$src, $dst|$dst, $src}",
1081 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
1082 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
1083 "mov{l}\t{$src, $dst|$dst, $src}",
1084 [(set GR32:$dst, (loadi32 addr:$src))]>;
1087 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
1088 "mov{b}\t{$src, $dst|$dst, $src}",
1089 [(store GR8:$src, addr:$dst)]>;
1090 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1091 "mov{w}\t{$src, $dst|$dst, $src}",
1092 [(store GR16:$src, addr:$dst)]>, OpSize;
1093 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1094 "mov{l}\t{$src, $dst|$dst, $src}",
1095 [(store GR32:$src, addr:$dst)]>;
1097 /// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
1098 let neverHasSideEffects = 1 in
1099 def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
1100 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1103 canFoldAsLoad = 1, isReMaterializable = 1 in
1104 def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
1105 "mov{l}\t{$src, $dst|$dst, $src}",
1109 def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
1110 "mov{l}\t{$src, $dst|$dst, $src}",
1113 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1114 // that they can be used for copying and storing h registers, which can't be
1115 // encoded when a REX prefix is present.
1116 let neverHasSideEffects = 1 in
1117 def MOV8rr_NOREX : I<0x88, MRMDestReg,
1118 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
1119 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1121 def MOV8mr_NOREX : I<0x88, MRMDestMem,
1122 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1123 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1125 canFoldAsLoad = 1, isReMaterializable = 1 in
1126 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1127 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1128 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1130 // Moves to and from debug registers
1131 def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1132 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1133 def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1134 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1136 // Moves to and from control registers
1137 def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG:$src),
1138 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1139 def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG:$dst), (ins GR32:$src),
1140 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1142 //===----------------------------------------------------------------------===//
1143 // Fixed-Register Multiplication and Division Instructions...
1146 // Extra precision multiplication
1148 // AL is really implied by AX, by the registers in Defs must match the
1149 // SDNode results (i8, i32).
1150 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1151 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
1152 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1153 // This probably ought to be moved to a def : Pat<> if the
1154 // syntax can be accepted.
1155 [(set AL, (mul AL, GR8:$src)),
1156 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1158 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1159 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1161 []>, OpSize; // AX,DX = AX*GR16
1163 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1164 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1166 []>; // EAX,EDX = EAX*GR32
1168 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1169 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1171 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1172 // This probably ought to be moved to a def : Pat<> if the
1173 // syntax can be accepted.
1174 [(set AL, (mul AL, (loadi8 addr:$src))),
1175 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1177 let mayLoad = 1, neverHasSideEffects = 1 in {
1178 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1179 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1181 []>, OpSize; // AX,DX = AX*[mem16]
1183 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1184 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1186 []>; // EAX,EDX = EAX*[mem32]
1189 let neverHasSideEffects = 1 in {
1190 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1191 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1193 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1194 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
1195 OpSize; // AX,DX = AX*GR16
1196 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1197 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1198 // EAX,EDX = EAX*GR32
1199 let mayLoad = 1 in {
1200 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1201 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1202 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
1203 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1204 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1205 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1206 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1207 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1208 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
1210 } // neverHasSideEffects
1212 // unsigned division/remainder
1213 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1214 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1215 "div{b}\t$src", []>;
1216 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1217 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1218 "div{w}\t$src", []>, OpSize;
1219 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1220 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1221 "div{l}\t$src", []>;
1222 let mayLoad = 1 in {
1223 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1224 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1225 "div{b}\t$src", []>;
1226 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1227 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1228 "div{w}\t$src", []>, OpSize;
1229 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1230 // EDX:EAX/[mem32] = EAX,EDX
1231 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
1232 "div{l}\t$src", []>;
1235 // Signed division/remainder.
1236 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1237 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1238 "idiv{b}\t$src", []>;
1239 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1240 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1241 "idiv{w}\t$src", []>, OpSize;
1242 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1243 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1244 "idiv{l}\t$src", []>;
1245 let mayLoad = 1, mayLoad = 1 in {
1246 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1247 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1248 "idiv{b}\t$src", []>;
1249 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1250 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1251 "idiv{w}\t$src", []>, OpSize;
1252 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1253 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1254 // EDX:EAX/[mem32] = EAX,EDX
1255 "idiv{l}\t$src", []>;
1258 //===----------------------------------------------------------------------===//
1259 // Two address Instructions.
1261 let Constraints = "$src1 = $dst" in {
1263 // Conditional moves
1264 let Uses = [EFLAGS] in {
1266 let Predicates = [HasCMov] in {
1267 let isCommutable = 1 in {
1268 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1269 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1270 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1271 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1272 X86_COND_B, EFLAGS))]>,
1274 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1275 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1276 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1277 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1278 X86_COND_B, EFLAGS))]>,
1280 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1281 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1282 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1283 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1284 X86_COND_AE, EFLAGS))]>,
1286 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1287 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1288 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1289 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1290 X86_COND_AE, EFLAGS))]>,
1292 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1293 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1294 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1295 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1296 X86_COND_E, EFLAGS))]>,
1298 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1299 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1300 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1301 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1302 X86_COND_E, EFLAGS))]>,
1304 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1305 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1306 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1307 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1308 X86_COND_NE, EFLAGS))]>,
1310 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1311 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1312 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1313 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1314 X86_COND_NE, EFLAGS))]>,
1316 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1317 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1318 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1319 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1320 X86_COND_BE, EFLAGS))]>,
1322 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1323 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1324 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1325 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1326 X86_COND_BE, EFLAGS))]>,
1328 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1329 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1330 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1331 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1332 X86_COND_A, EFLAGS))]>,
1334 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1335 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1336 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1337 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1338 X86_COND_A, EFLAGS))]>,
1340 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1341 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1342 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1343 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1344 X86_COND_L, EFLAGS))]>,
1346 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1347 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1348 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1349 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1350 X86_COND_L, EFLAGS))]>,
1352 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1353 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1354 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1355 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1356 X86_COND_GE, EFLAGS))]>,
1358 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1359 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1360 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1361 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1362 X86_COND_GE, EFLAGS))]>,
1364 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1365 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1366 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1367 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1368 X86_COND_LE, EFLAGS))]>,
1370 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1371 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1372 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1373 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1374 X86_COND_LE, EFLAGS))]>,
1376 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1377 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1378 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1379 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1380 X86_COND_G, EFLAGS))]>,
1382 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1383 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1384 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1385 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1386 X86_COND_G, EFLAGS))]>,
1388 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1389 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1390 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1391 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1392 X86_COND_S, EFLAGS))]>,
1394 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1395 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1396 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1397 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1398 X86_COND_S, EFLAGS))]>,
1400 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1401 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1402 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1403 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1404 X86_COND_NS, EFLAGS))]>,
1406 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1407 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1408 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1409 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1410 X86_COND_NS, EFLAGS))]>,
1412 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1413 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1414 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1415 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1416 X86_COND_P, EFLAGS))]>,
1418 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1419 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1420 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1421 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1422 X86_COND_P, EFLAGS))]>,
1424 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1425 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1426 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1427 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1428 X86_COND_NP, EFLAGS))]>,
1430 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1431 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1432 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1433 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1434 X86_COND_NP, EFLAGS))]>,
1436 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1437 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1438 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1439 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1440 X86_COND_O, EFLAGS))]>,
1442 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1443 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1444 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1445 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1446 X86_COND_O, EFLAGS))]>,
1448 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1449 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1450 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1451 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1452 X86_COND_NO, EFLAGS))]>,
1454 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1455 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1456 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1457 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1458 X86_COND_NO, EFLAGS))]>,
1460 } // isCommutable = 1
1462 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1463 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1464 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1465 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1466 X86_COND_B, EFLAGS))]>,
1468 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1469 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1470 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1471 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1472 X86_COND_B, EFLAGS))]>,
1474 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1475 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1476 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1477 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1478 X86_COND_AE, EFLAGS))]>,
1480 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1481 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1482 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1483 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1484 X86_COND_AE, EFLAGS))]>,
1486 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1487 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1488 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1489 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1490 X86_COND_E, EFLAGS))]>,
1492 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1493 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1494 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1495 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1496 X86_COND_E, EFLAGS))]>,
1498 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1499 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1500 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1501 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1502 X86_COND_NE, EFLAGS))]>,
1504 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1505 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1506 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1507 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1508 X86_COND_NE, EFLAGS))]>,
1510 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1511 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1512 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1513 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1514 X86_COND_BE, EFLAGS))]>,
1516 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1517 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1518 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1519 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1520 X86_COND_BE, EFLAGS))]>,
1522 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1523 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1524 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1525 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1526 X86_COND_A, EFLAGS))]>,
1528 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1529 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1530 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1531 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1532 X86_COND_A, EFLAGS))]>,
1534 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1535 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1536 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1537 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1538 X86_COND_L, EFLAGS))]>,
1540 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1541 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1542 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1543 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1544 X86_COND_L, EFLAGS))]>,
1546 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1547 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1548 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1549 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1550 X86_COND_GE, EFLAGS))]>,
1552 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1553 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1554 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1555 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1556 X86_COND_GE, EFLAGS))]>,
1558 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1559 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1560 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1561 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1562 X86_COND_LE, EFLAGS))]>,
1564 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1565 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1566 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1567 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1568 X86_COND_LE, EFLAGS))]>,
1570 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1571 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1572 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1573 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1574 X86_COND_G, EFLAGS))]>,
1576 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1577 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1578 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1579 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1580 X86_COND_G, EFLAGS))]>,
1582 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1583 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1584 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1585 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1586 X86_COND_S, EFLAGS))]>,
1588 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1589 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1590 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1591 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1592 X86_COND_S, EFLAGS))]>,
1594 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1595 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1596 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1597 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1598 X86_COND_NS, EFLAGS))]>,
1600 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1601 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1602 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1603 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1604 X86_COND_NS, EFLAGS))]>,
1606 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1607 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1608 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1609 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1610 X86_COND_P, EFLAGS))]>,
1612 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1613 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1614 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1615 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1616 X86_COND_P, EFLAGS))]>,
1618 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1619 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1620 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1621 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1622 X86_COND_NP, EFLAGS))]>,
1624 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1625 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1626 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1627 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1628 X86_COND_NP, EFLAGS))]>,
1630 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1631 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1632 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1633 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1634 X86_COND_O, EFLAGS))]>,
1636 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1637 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1638 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1639 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1640 X86_COND_O, EFLAGS))]>,
1642 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1643 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1644 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1645 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1646 X86_COND_NO, EFLAGS))]>,
1648 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1649 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1650 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1651 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1652 X86_COND_NO, EFLAGS))]>,
1654 } // Predicates = [HasCMov]
1656 // X86 doesn't have 8-bit conditional moves. Use a customInserter to
1657 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1658 // however that requires promoting the operands, and can induce additional
1659 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1660 // clobber EFLAGS, because if one of the operands is zero, the expansion
1661 // could involve an xor.
1662 let usesCustomInserter = 1, Constraints = "", Defs = [EFLAGS] in {
1663 def CMOV_GR8 : I<0, Pseudo,
1664 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1665 "#CMOV_GR8 PSEUDO!",
1666 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1667 imm:$cond, EFLAGS))]>;
1669 let Predicates = [NoCMov] in {
1670 def CMOV_GR32 : I<0, Pseudo,
1671 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1672 "#CMOV_GR32* PSEUDO!",
1674 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1675 def CMOV_GR16 : I<0, Pseudo,
1676 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1677 "#CMOV_GR16* PSEUDO!",
1679 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1680 def CMOV_RFP32 : I<0, Pseudo,
1682 (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
1683 "#CMOV_RFP32 PSEUDO!",
1685 (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
1687 def CMOV_RFP64 : I<0, Pseudo,
1689 (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
1690 "#CMOV_RFP64 PSEUDO!",
1692 (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
1694 def CMOV_RFP80 : I<0, Pseudo,
1696 (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
1697 "#CMOV_RFP80 PSEUDO!",
1699 (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
1701 } // Predicates = [NoCMov]
1702 } // UsesCustomInserter = 1, Constraints = "", Defs = [EFLAGS]
1703 } // Uses = [EFLAGS]
1706 // unary instructions
1707 let CodeSize = 2 in {
1708 let Defs = [EFLAGS] in {
1709 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src1),
1711 [(set GR8:$dst, (ineg GR8:$src1)),
1712 (implicit EFLAGS)]>;
1713 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
1715 [(set GR16:$dst, (ineg GR16:$src1)),
1716 (implicit EFLAGS)]>, OpSize;
1717 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
1719 [(set GR32:$dst, (ineg GR32:$src1)),
1720 (implicit EFLAGS)]>;
1722 let Constraints = "" in {
1723 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst),
1725 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1726 (implicit EFLAGS)]>;
1727 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst),
1729 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1730 (implicit EFLAGS)]>, OpSize;
1731 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst),
1733 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1734 (implicit EFLAGS)]>;
1735 } // Constraints = ""
1736 } // Defs = [EFLAGS]
1738 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1739 let AddedComplexity = 15 in {
1740 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src1),
1742 [(set GR8:$dst, (not GR8:$src1))]>;
1743 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
1745 [(set GR16:$dst, (not GR16:$src1))]>, OpSize;
1746 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
1748 [(set GR32:$dst, (not GR32:$src1))]>;
1750 let Constraints = "" in {
1751 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst),
1753 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1754 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst),
1756 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1757 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst),
1759 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1760 } // Constraints = ""
1763 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1764 let Defs = [EFLAGS] in {
1766 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1768 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src1))]>;
1770 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1771 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1773 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src1))]>,
1774 OpSize, Requires<[In32BitMode]>;
1775 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1777 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src1))]>,
1778 Requires<[In32BitMode]>;
1780 let Constraints = "", CodeSize = 2 in {
1781 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1782 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1783 (implicit EFLAGS)]>;
1784 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1785 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1786 (implicit EFLAGS)]>,
1787 OpSize, Requires<[In32BitMode]>;
1788 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1789 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1790 (implicit EFLAGS)]>,
1791 Requires<[In32BitMode]>;
1792 } // Constraints = "", CodeSize = 2
1795 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1797 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src1))]>;
1798 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1799 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1801 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src1))]>,
1802 OpSize, Requires<[In32BitMode]>;
1803 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1805 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src1))]>,
1806 Requires<[In32BitMode]>;
1809 let Constraints = "", CodeSize = 2 in {
1810 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1811 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1812 (implicit EFLAGS)]>;
1813 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1814 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1815 (implicit EFLAGS)]>,
1816 OpSize, Requires<[In32BitMode]>;
1817 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1818 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1819 (implicit EFLAGS)]>,
1820 Requires<[In32BitMode]>;
1821 } // Constraints = "", CodeSize = 2
1822 } // Defs = [EFLAGS]
1824 // Logical operators...
1825 let Defs = [EFLAGS] in {
1826 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1827 def AND8rr : I<0x20, MRMDestReg,
1828 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1829 "and{b}\t{$src2, $dst|$dst, $src2}",
1830 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1831 def AND16rr : I<0x21, MRMDestReg,
1832 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1833 "and{w}\t{$src2, $dst|$dst, $src2}",
1834 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1835 GR16:$src2))]>, OpSize;
1836 def AND32rr : I<0x21, MRMDestReg,
1837 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1838 "and{l}\t{$src2, $dst|$dst, $src2}",
1839 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1843 // AND instructions with the destination register in REG and the source register
1844 // in R/M. Included for the disassembler.
1845 let isCodeGenOnly = 1 in {
1846 def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1847 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1848 def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1849 (ins GR16:$src1, GR16:$src2),
1850 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1851 def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1852 (ins GR32:$src1, GR32:$src2),
1853 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1856 def AND8rm : I<0x22, MRMSrcMem,
1857 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1858 "and{b}\t{$src2, $dst|$dst, $src2}",
1859 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1860 (loadi8 addr:$src2)))]>;
1861 def AND16rm : I<0x23, MRMSrcMem,
1862 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1863 "and{w}\t{$src2, $dst|$dst, $src2}",
1864 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1865 (loadi16 addr:$src2)))]>,
1867 def AND32rm : I<0x23, MRMSrcMem,
1868 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1869 "and{l}\t{$src2, $dst|$dst, $src2}",
1870 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1871 (loadi32 addr:$src2)))]>;
1873 def AND8ri : Ii8<0x80, MRM4r,
1874 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1875 "and{b}\t{$src2, $dst|$dst, $src2}",
1876 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1878 def AND16ri : Ii16<0x81, MRM4r,
1879 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1880 "and{w}\t{$src2, $dst|$dst, $src2}",
1881 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1882 imm:$src2))]>, OpSize;
1883 def AND32ri : Ii32<0x81, MRM4r,
1884 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1885 "and{l}\t{$src2, $dst|$dst, $src2}",
1886 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1888 def AND16ri8 : Ii8<0x83, MRM4r,
1889 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1890 "and{w}\t{$src2, $dst|$dst, $src2}",
1891 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1892 i16immSExt8:$src2))]>,
1894 def AND32ri8 : Ii8<0x83, MRM4r,
1895 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1896 "and{l}\t{$src2, $dst|$dst, $src2}",
1897 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1898 i32immSExt8:$src2))]>;
1900 let Constraints = "" in {
1901 def AND8mr : I<0x20, MRMDestMem,
1902 (outs), (ins i8mem :$dst, GR8 :$src),
1903 "and{b}\t{$src, $dst|$dst, $src}",
1904 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1905 (implicit EFLAGS)]>;
1906 def AND16mr : I<0x21, MRMDestMem,
1907 (outs), (ins i16mem:$dst, GR16:$src),
1908 "and{w}\t{$src, $dst|$dst, $src}",
1909 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1910 (implicit EFLAGS)]>,
1912 def AND32mr : I<0x21, MRMDestMem,
1913 (outs), (ins i32mem:$dst, GR32:$src),
1914 "and{l}\t{$src, $dst|$dst, $src}",
1915 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1916 (implicit EFLAGS)]>;
1917 def AND8mi : Ii8<0x80, MRM4m,
1918 (outs), (ins i8mem :$dst, i8imm :$src),
1919 "and{b}\t{$src, $dst|$dst, $src}",
1920 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1921 (implicit EFLAGS)]>;
1922 def AND16mi : Ii16<0x81, MRM4m,
1923 (outs), (ins i16mem:$dst, i16imm:$src),
1924 "and{w}\t{$src, $dst|$dst, $src}",
1925 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1926 (implicit EFLAGS)]>,
1928 def AND32mi : Ii32<0x81, MRM4m,
1929 (outs), (ins i32mem:$dst, i32imm:$src),
1930 "and{l}\t{$src, $dst|$dst, $src}",
1931 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1932 (implicit EFLAGS)]>;
1933 def AND16mi8 : Ii8<0x83, MRM4m,
1934 (outs), (ins i16mem:$dst, i16i8imm :$src),
1935 "and{w}\t{$src, $dst|$dst, $src}",
1936 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1937 (implicit EFLAGS)]>,
1939 def AND32mi8 : Ii8<0x83, MRM4m,
1940 (outs), (ins i32mem:$dst, i32i8imm :$src),
1941 "and{l}\t{$src, $dst|$dst, $src}",
1942 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1943 (implicit EFLAGS)]>;
1945 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1946 "and{b}\t{$src, %al|%al, $src}", []>;
1947 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1948 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1949 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1950 "and{l}\t{$src, %eax|%eax, $src}", []>;
1952 } // Constraints = ""
1955 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1956 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1957 (ins GR8 :$src1, GR8 :$src2),
1958 "or{b}\t{$src2, $dst|$dst, $src2}",
1959 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
1960 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1961 (ins GR16:$src1, GR16:$src2),
1962 "or{w}\t{$src2, $dst|$dst, $src2}",
1963 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1965 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1966 (ins GR32:$src1, GR32:$src2),
1967 "or{l}\t{$src2, $dst|$dst, $src2}",
1968 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
1971 // OR instructions with the destination register in REG and the source register
1972 // in R/M. Included for the disassembler.
1973 let isCodeGenOnly = 1 in {
1974 def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1975 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1976 def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1977 (ins GR16:$src1, GR16:$src2),
1978 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1979 def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1980 (ins GR32:$src1, GR32:$src2),
1981 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1984 def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
1985 (ins GR8 :$src1, i8mem :$src2),
1986 "or{b}\t{$src2, $dst|$dst, $src2}",
1987 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
1988 (load addr:$src2)))]>;
1989 def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
1990 (ins GR16:$src1, i16mem:$src2),
1991 "or{w}\t{$src2, $dst|$dst, $src2}",
1992 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1993 (load addr:$src2)))]>,
1995 def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
1996 (ins GR32:$src1, i32mem:$src2),
1997 "or{l}\t{$src2, $dst|$dst, $src2}",
1998 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1999 (load addr:$src2)))]>;
2001 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
2002 (ins GR8 :$src1, i8imm:$src2),
2003 "or{b}\t{$src2, $dst|$dst, $src2}",
2004 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
2005 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
2006 (ins GR16:$src1, i16imm:$src2),
2007 "or{w}\t{$src2, $dst|$dst, $src2}",
2008 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2009 imm:$src2))]>, OpSize;
2010 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
2011 (ins GR32:$src1, i32imm:$src2),
2012 "or{l}\t{$src2, $dst|$dst, $src2}",
2013 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2016 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
2017 (ins GR16:$src1, i16i8imm:$src2),
2018 "or{w}\t{$src2, $dst|$dst, $src2}",
2019 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
2020 i16immSExt8:$src2))]>, OpSize;
2021 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
2022 (ins GR32:$src1, i32i8imm:$src2),
2023 "or{l}\t{$src2, $dst|$dst, $src2}",
2024 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
2025 i32immSExt8:$src2))]>;
2026 let Constraints = "" in {
2027 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
2028 "or{b}\t{$src, $dst|$dst, $src}",
2029 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
2030 (implicit EFLAGS)]>;
2031 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
2032 "or{w}\t{$src, $dst|$dst, $src}",
2033 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
2034 (implicit EFLAGS)]>, OpSize;
2035 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2036 "or{l}\t{$src, $dst|$dst, $src}",
2037 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
2038 (implicit EFLAGS)]>;
2039 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2040 "or{b}\t{$src, $dst|$dst, $src}",
2041 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
2042 (implicit EFLAGS)]>;
2043 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
2044 "or{w}\t{$src, $dst|$dst, $src}",
2045 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
2046 (implicit EFLAGS)]>,
2048 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
2049 "or{l}\t{$src, $dst|$dst, $src}",
2050 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
2051 (implicit EFLAGS)]>;
2052 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
2053 "or{w}\t{$src, $dst|$dst, $src}",
2054 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
2055 (implicit EFLAGS)]>,
2057 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
2058 "or{l}\t{$src, $dst|$dst, $src}",
2059 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
2060 (implicit EFLAGS)]>;
2062 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
2063 "or{b}\t{$src, %al|%al, $src}", []>;
2064 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
2065 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2066 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
2067 "or{l}\t{$src, %eax|%eax, $src}", []>;
2068 } // Constraints = ""
2071 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
2072 def XOR8rr : I<0x30, MRMDestReg,
2073 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
2074 "xor{b}\t{$src2, $dst|$dst, $src2}",
2075 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2077 def XOR16rr : I<0x31, MRMDestReg,
2078 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2079 "xor{w}\t{$src2, $dst|$dst, $src2}",
2080 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2081 GR16:$src2))]>, OpSize;
2082 def XOR32rr : I<0x31, MRMDestReg,
2083 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2084 "xor{l}\t{$src2, $dst|$dst, $src2}",
2085 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2087 } // isCommutable = 1
2089 // XOR instructions with the destination register in REG and the source register
2090 // in R/M. Included for the disassembler.
2091 let isCodeGenOnly = 1 in {
2092 def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2093 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
2094 def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
2095 (ins GR16:$src1, GR16:$src2),
2096 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2097 def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
2098 (ins GR32:$src1, GR32:$src2),
2099 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
2102 def XOR8rm : I<0x32, MRMSrcMem,
2103 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
2104 "xor{b}\t{$src2, $dst|$dst, $src2}",
2105 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
2106 (load addr:$src2)))]>;
2107 def XOR16rm : I<0x33, MRMSrcMem,
2108 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
2109 "xor{w}\t{$src2, $dst|$dst, $src2}",
2110 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2111 (load addr:$src2)))]>,
2113 def XOR32rm : I<0x33, MRMSrcMem,
2114 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2115 "xor{l}\t{$src2, $dst|$dst, $src2}",
2116 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2117 (load addr:$src2)))]>;
2119 def XOR8ri : Ii8<0x80, MRM6r,
2120 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2121 "xor{b}\t{$src2, $dst|$dst, $src2}",
2122 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
2123 def XOR16ri : Ii16<0x81, MRM6r,
2124 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2125 "xor{w}\t{$src2, $dst|$dst, $src2}",
2126 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2127 imm:$src2))]>, OpSize;
2128 def XOR32ri : Ii32<0x81, MRM6r,
2129 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2130 "xor{l}\t{$src2, $dst|$dst, $src2}",
2131 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2133 def XOR16ri8 : Ii8<0x83, MRM6r,
2134 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2135 "xor{w}\t{$src2, $dst|$dst, $src2}",
2136 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
2137 i16immSExt8:$src2))]>,
2139 def XOR32ri8 : Ii8<0x83, MRM6r,
2140 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2141 "xor{l}\t{$src2, $dst|$dst, $src2}",
2142 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
2143 i32immSExt8:$src2))]>;
2145 let Constraints = "" in {
2146 def XOR8mr : I<0x30, MRMDestMem,
2147 (outs), (ins i8mem :$dst, GR8 :$src),
2148 "xor{b}\t{$src, $dst|$dst, $src}",
2149 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2150 (implicit EFLAGS)]>;
2151 def XOR16mr : I<0x31, MRMDestMem,
2152 (outs), (ins i16mem:$dst, GR16:$src),
2153 "xor{w}\t{$src, $dst|$dst, $src}",
2154 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2155 (implicit EFLAGS)]>,
2157 def XOR32mr : I<0x31, MRMDestMem,
2158 (outs), (ins i32mem:$dst, GR32:$src),
2159 "xor{l}\t{$src, $dst|$dst, $src}",
2160 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2161 (implicit EFLAGS)]>;
2162 def XOR8mi : Ii8<0x80, MRM6m,
2163 (outs), (ins i8mem :$dst, i8imm :$src),
2164 "xor{b}\t{$src, $dst|$dst, $src}",
2165 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2166 (implicit EFLAGS)]>;
2167 def XOR16mi : Ii16<0x81, MRM6m,
2168 (outs), (ins i16mem:$dst, i16imm:$src),
2169 "xor{w}\t{$src, $dst|$dst, $src}",
2170 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2171 (implicit EFLAGS)]>,
2173 def XOR32mi : Ii32<0x81, MRM6m,
2174 (outs), (ins i32mem:$dst, i32imm:$src),
2175 "xor{l}\t{$src, $dst|$dst, $src}",
2176 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2177 (implicit EFLAGS)]>;
2178 def XOR16mi8 : Ii8<0x83, MRM6m,
2179 (outs), (ins i16mem:$dst, i16i8imm :$src),
2180 "xor{w}\t{$src, $dst|$dst, $src}",
2181 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2182 (implicit EFLAGS)]>,
2184 def XOR32mi8 : Ii8<0x83, MRM6m,
2185 (outs), (ins i32mem:$dst, i32i8imm :$src),
2186 "xor{l}\t{$src, $dst|$dst, $src}",
2187 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2188 (implicit EFLAGS)]>;
2190 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2191 "xor{b}\t{$src, %al|%al, $src}", []>;
2192 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
2193 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2194 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
2195 "xor{l}\t{$src, %eax|%eax, $src}", []>;
2196 } // Constraints = ""
2197 } // Defs = [EFLAGS]
2199 // Shift instructions
2200 let Defs = [EFLAGS] in {
2201 let Uses = [CL] in {
2202 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
2203 "shl{b}\t{%cl, $dst|$dst, CL}",
2204 [(set GR8:$dst, (shl GR8:$src1, CL))]>;
2205 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2206 "shl{w}\t{%cl, $dst|$dst, CL}",
2207 [(set GR16:$dst, (shl GR16:$src1, CL))]>, OpSize;
2208 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2209 "shl{l}\t{%cl, $dst|$dst, CL}",
2210 [(set GR32:$dst, (shl GR32:$src1, CL))]>;
2213 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2214 "shl{b}\t{$src2, $dst|$dst, $src2}",
2215 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2217 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2218 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2219 "shl{w}\t{$src2, $dst|$dst, $src2}",
2220 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2221 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2222 "shl{l}\t{$src2, $dst|$dst, $src2}",
2223 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
2225 // NOTE: We don't include patterns for shifts of a register by one, because
2226 // 'add reg,reg' is cheaper.
2228 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2229 "shl{b}\t$dst", []>;
2230 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2231 "shl{w}\t$dst", []>, OpSize;
2232 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2233 "shl{l}\t$dst", []>;
2235 } // isConvertibleToThreeAddress = 1
2237 let Constraints = "" in {
2238 let Uses = [CL] in {
2239 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
2240 "shl{b}\t{%cl, $dst|$dst, CL}",
2241 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
2242 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
2243 "shl{w}\t{%cl, $dst|$dst, CL}",
2244 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2245 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
2246 "shl{l}\t{%cl, $dst|$dst, CL}",
2247 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2249 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
2250 "shl{b}\t{$src, $dst|$dst, $src}",
2251 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2252 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
2253 "shl{w}\t{$src, $dst|$dst, $src}",
2254 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2256 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
2257 "shl{l}\t{$src, $dst|$dst, $src}",
2258 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2261 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2263 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2264 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2266 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2268 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2270 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2271 } // Constraints = ""
2273 let Uses = [CL] in {
2274 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1),
2275 "shr{b}\t{%cl, $dst|$dst, CL}",
2276 [(set GR8:$dst, (srl GR8:$src1, CL))]>;
2277 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2278 "shr{w}\t{%cl, $dst|$dst, CL}",
2279 [(set GR16:$dst, (srl GR16:$src1, CL))]>, OpSize;
2280 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2281 "shr{l}\t{%cl, $dst|$dst, CL}",
2282 [(set GR32:$dst, (srl GR32:$src1, CL))]>;
2285 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2286 "shr{b}\t{$src2, $dst|$dst, $src2}",
2287 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2288 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2289 "shr{w}\t{$src2, $dst|$dst, $src2}",
2290 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2291 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2292 "shr{l}\t{$src2, $dst|$dst, $src2}",
2293 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2296 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2298 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2299 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2301 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2302 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2304 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2306 let Constraints = "" in {
2307 let Uses = [CL] in {
2308 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2309 "shr{b}\t{%cl, $dst|$dst, CL}",
2310 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2311 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2312 "shr{w}\t{%cl, $dst|$dst, CL}",
2313 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2315 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2316 "shr{l}\t{%cl, $dst|$dst, CL}",
2317 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2319 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2320 "shr{b}\t{$src, $dst|$dst, $src}",
2321 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2322 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2323 "shr{w}\t{$src, $dst|$dst, $src}",
2324 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2326 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2327 "shr{l}\t{$src, $dst|$dst, $src}",
2328 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2331 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2333 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2334 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2336 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2337 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2339 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2340 } // Constraints = ""
2342 let Uses = [CL] in {
2343 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2344 "sar{b}\t{%cl, $dst|$dst, CL}",
2345 [(set GR8:$dst, (sra GR8:$src1, CL))]>;
2346 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2347 "sar{w}\t{%cl, $dst|$dst, CL}",
2348 [(set GR16:$dst, (sra GR16:$src1, CL))]>, OpSize;
2349 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2350 "sar{l}\t{%cl, $dst|$dst, CL}",
2351 [(set GR32:$dst, (sra GR32:$src1, CL))]>;
2354 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2355 "sar{b}\t{$src2, $dst|$dst, $src2}",
2356 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2357 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2358 "sar{w}\t{$src2, $dst|$dst, $src2}",
2359 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2361 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2362 "sar{l}\t{$src2, $dst|$dst, $src2}",
2363 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2366 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2368 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2369 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2371 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2372 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2374 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2376 let Constraints = "" in {
2377 let Uses = [CL] in {
2378 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2379 "sar{b}\t{%cl, $dst|$dst, CL}",
2380 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2381 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2382 "sar{w}\t{%cl, $dst|$dst, CL}",
2383 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2384 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2385 "sar{l}\t{%cl, $dst|$dst, CL}",
2386 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2388 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2389 "sar{b}\t{$src, $dst|$dst, $src}",
2390 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2391 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2392 "sar{w}\t{$src, $dst|$dst, $src}",
2393 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2395 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2396 "sar{l}\t{$src, $dst|$dst, $src}",
2397 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2400 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2402 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2403 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2405 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2407 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2409 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2410 } // Constraints = ""
2412 // Rotate instructions
2414 def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
2415 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2416 let Uses = [CL] in {
2417 def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
2418 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2420 def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
2421 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2423 def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
2424 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2425 let Uses = [CL] in {
2426 def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
2427 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2429 def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
2430 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2432 def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
2433 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2434 let Uses = [CL] in {
2435 def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
2436 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2438 def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
2439 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2441 def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
2442 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2443 let Uses = [CL] in {
2444 def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
2445 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2447 def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
2448 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2450 def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
2451 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2452 let Uses = [CL] in {
2453 def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
2454 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2456 def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
2457 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2459 def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
2460 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2461 let Uses = [CL] in {
2462 def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
2463 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2465 def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
2466 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2468 let Constraints = "" in {
2469 def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2470 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2471 def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2472 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2473 def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2474 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2475 def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2476 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2477 def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2478 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2479 def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2480 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2481 def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2482 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2483 def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2484 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2485 def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2486 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2487 def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2488 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2489 def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2490 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2491 def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2492 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2494 let Uses = [CL] in {
2495 def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2496 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2497 def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2498 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2499 def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2500 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2501 def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2502 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2503 def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2504 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2505 def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2506 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2508 } // Constraints = ""
2510 // FIXME: provide shorter instructions when imm8 == 1
2511 let Uses = [CL] in {
2512 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2513 "rol{b}\t{%cl, $dst|$dst, CL}",
2514 [(set GR8:$dst, (rotl GR8:$src1, CL))]>;
2515 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2516 "rol{w}\t{%cl, $dst|$dst, CL}",
2517 [(set GR16:$dst, (rotl GR16:$src1, CL))]>, OpSize;
2518 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2519 "rol{l}\t{%cl, $dst|$dst, CL}",
2520 [(set GR32:$dst, (rotl GR32:$src1, CL))]>;
2523 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2524 "rol{b}\t{$src2, $dst|$dst, $src2}",
2525 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2526 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2527 "rol{w}\t{$src2, $dst|$dst, $src2}",
2528 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2530 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2531 "rol{l}\t{$src2, $dst|$dst, $src2}",
2532 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2535 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2537 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2538 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2540 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2541 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2543 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2545 let Constraints = "" in {
2546 let Uses = [CL] in {
2547 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2548 "rol{b}\t{%cl, $dst|$dst, CL}",
2549 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2550 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2551 "rol{w}\t{%cl, $dst|$dst, CL}",
2552 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2553 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2554 "rol{l}\t{%cl, $dst|$dst, CL}",
2555 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2557 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2558 "rol{b}\t{$src, $dst|$dst, $src}",
2559 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2560 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2561 "rol{w}\t{$src, $dst|$dst, $src}",
2562 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2564 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2565 "rol{l}\t{$src, $dst|$dst, $src}",
2566 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2569 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2571 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2572 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2574 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2576 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2578 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2579 } // Constraints = ""
2581 let Uses = [CL] in {
2582 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2583 "ror{b}\t{%cl, $dst|$dst, CL}",
2584 [(set GR8:$dst, (rotr GR8:$src1, CL))]>;
2585 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2586 "ror{w}\t{%cl, $dst|$dst, CL}",
2587 [(set GR16:$dst, (rotr GR16:$src1, CL))]>, OpSize;
2588 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2589 "ror{l}\t{%cl, $dst|$dst, CL}",
2590 [(set GR32:$dst, (rotr GR32:$src1, CL))]>;
2593 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2594 "ror{b}\t{$src2, $dst|$dst, $src2}",
2595 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2596 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2597 "ror{w}\t{$src2, $dst|$dst, $src2}",
2598 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2600 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2601 "ror{l}\t{$src2, $dst|$dst, $src2}",
2602 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2605 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2607 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2608 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2610 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2611 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2613 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2615 let Constraints = "" in {
2616 let Uses = [CL] in {
2617 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2618 "ror{b}\t{%cl, $dst|$dst, CL}",
2619 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2620 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2621 "ror{w}\t{%cl, $dst|$dst, CL}",
2622 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2623 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2624 "ror{l}\t{%cl, $dst|$dst, CL}",
2625 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2627 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2628 "ror{b}\t{$src, $dst|$dst, $src}",
2629 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2630 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2631 "ror{w}\t{$src, $dst|$dst, $src}",
2632 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2634 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2635 "ror{l}\t{$src, $dst|$dst, $src}",
2636 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2639 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2641 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2642 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2644 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2646 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2648 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2649 } // Constraints = ""
2652 // Double shift instructions (generalizations of rotate)
2653 let Uses = [CL] in {
2654 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2655 (ins GR32:$src1, GR32:$src2),
2656 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2657 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2658 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2659 (ins GR32:$src1, GR32:$src2),
2660 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2661 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2662 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2663 (ins GR16:$src1, GR16:$src2),
2664 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2665 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2667 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2668 (ins GR16:$src1, GR16:$src2),
2669 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2670 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2674 let isCommutable = 1 in { // These instructions commute to each other.
2675 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2677 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2678 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2679 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2682 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2684 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2685 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2686 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2689 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2691 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2692 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2693 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2696 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2698 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2699 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2700 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2705 let Constraints = "" in {
2706 let Uses = [CL] in {
2707 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2708 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2709 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2711 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2712 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2713 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2716 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2717 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2718 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2719 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2720 (i8 imm:$src3)), addr:$dst)]>,
2722 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2723 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2724 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2725 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2726 (i8 imm:$src3)), addr:$dst)]>,
2729 let Uses = [CL] in {
2730 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2731 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2732 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2733 addr:$dst)]>, TB, OpSize;
2734 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2735 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2736 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2737 addr:$dst)]>, TB, OpSize;
2739 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2740 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2741 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2742 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2743 (i8 imm:$src3)), addr:$dst)]>,
2745 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2746 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2747 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2748 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2749 (i8 imm:$src3)), addr:$dst)]>,
2751 } // Constraints = ""
2752 } // Defs = [EFLAGS]
2756 let Defs = [EFLAGS] in {
2757 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2758 // Register-Register Addition
2759 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2760 (ins GR8 :$src1, GR8 :$src2),
2761 "add{b}\t{$src2, $dst|$dst, $src2}",
2762 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
2764 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2765 // Register-Register Addition
2766 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2767 (ins GR16:$src1, GR16:$src2),
2768 "add{w}\t{$src2, $dst|$dst, $src2}",
2769 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2770 GR16:$src2))]>, OpSize;
2771 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2772 (ins GR32:$src1, GR32:$src2),
2773 "add{l}\t{$src2, $dst|$dst, $src2}",
2774 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2776 } // end isConvertibleToThreeAddress
2777 } // end isCommutable
2779 // These are alternate spellings for use by the disassembler, we mark them as
2780 // code gen only to ensure they aren't matched by the assembler.
2781 let isCodeGenOnly = 1 in {
2782 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2783 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2784 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2785 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2786 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
2787 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2790 // Register-Memory Addition
2791 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2792 (ins GR8 :$src1, i8mem :$src2),
2793 "add{b}\t{$src2, $dst|$dst, $src2}",
2794 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2795 (load addr:$src2)))]>;
2796 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2797 (ins GR16:$src1, i16mem:$src2),
2798 "add{w}\t{$src2, $dst|$dst, $src2}",
2799 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2800 (load addr:$src2)))]>, OpSize;
2801 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2802 (ins GR32:$src1, i32mem:$src2),
2803 "add{l}\t{$src2, $dst|$dst, $src2}",
2804 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2805 (load addr:$src2)))]>;
2807 // Register-Integer Addition
2808 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2809 "add{b}\t{$src2, $dst|$dst, $src2}",
2810 [(set GR8:$dst, EFLAGS,
2811 (X86add_flag GR8:$src1, imm:$src2))]>;
2813 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2814 // Register-Integer Addition
2815 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2816 (ins GR16:$src1, i16imm:$src2),
2817 "add{w}\t{$src2, $dst|$dst, $src2}",
2818 [(set GR16:$dst, EFLAGS,
2819 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
2820 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2821 (ins GR32:$src1, i32imm:$src2),
2822 "add{l}\t{$src2, $dst|$dst, $src2}",
2823 [(set GR32:$dst, EFLAGS,
2824 (X86add_flag GR32:$src1, imm:$src2))]>;
2825 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2826 (ins GR16:$src1, i16i8imm:$src2),
2827 "add{w}\t{$src2, $dst|$dst, $src2}",
2828 [(set GR16:$dst, EFLAGS,
2829 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
2830 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2831 (ins GR32:$src1, i32i8imm:$src2),
2832 "add{l}\t{$src2, $dst|$dst, $src2}",
2833 [(set GR32:$dst, EFLAGS,
2834 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
2837 let Constraints = "" in {
2838 // Memory-Register Addition
2839 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2840 "add{b}\t{$src2, $dst|$dst, $src2}",
2841 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2842 (implicit EFLAGS)]>;
2843 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2844 "add{w}\t{$src2, $dst|$dst, $src2}",
2845 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2846 (implicit EFLAGS)]>, OpSize;
2847 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2848 "add{l}\t{$src2, $dst|$dst, $src2}",
2849 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2850 (implicit EFLAGS)]>;
2851 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2852 "add{b}\t{$src2, $dst|$dst, $src2}",
2853 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2854 (implicit EFLAGS)]>;
2855 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2856 "add{w}\t{$src2, $dst|$dst, $src2}",
2857 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2858 (implicit EFLAGS)]>, OpSize;
2859 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2860 "add{l}\t{$src2, $dst|$dst, $src2}",
2861 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2862 (implicit EFLAGS)]>;
2863 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2864 "add{w}\t{$src2, $dst|$dst, $src2}",
2865 [(store (add (load addr:$dst), i16immSExt8:$src2),
2867 (implicit EFLAGS)]>, OpSize;
2868 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2869 "add{l}\t{$src2, $dst|$dst, $src2}",
2870 [(store (add (load addr:$dst), i32immSExt8:$src2),
2872 (implicit EFLAGS)]>;
2875 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2876 "add{b}\t{$src, %al|%al, $src}", []>;
2877 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2878 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2879 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2880 "add{l}\t{$src, %eax|%eax, $src}", []>;
2881 } // Constraints = ""
2883 let Uses = [EFLAGS] in {
2884 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2885 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2886 "adc{b}\t{$src2, $dst|$dst, $src2}",
2887 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2888 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2889 (ins GR16:$src1, GR16:$src2),
2890 "adc{w}\t{$src2, $dst|$dst, $src2}",
2891 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2892 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2893 (ins GR32:$src1, GR32:$src2),
2894 "adc{l}\t{$src2, $dst|$dst, $src2}",
2895 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2898 let isCodeGenOnly = 1 in {
2899 def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2900 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2901 def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2902 (ins GR16:$src1, GR16:$src2),
2903 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2904 def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2905 (ins GR32:$src1, GR32:$src2),
2906 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2909 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2910 (ins GR8:$src1, i8mem:$src2),
2911 "adc{b}\t{$src2, $dst|$dst, $src2}",
2912 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2913 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2914 (ins GR16:$src1, i16mem:$src2),
2915 "adc{w}\t{$src2, $dst|$dst, $src2}",
2916 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2918 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2919 (ins GR32:$src1, i32mem:$src2),
2920 "adc{l}\t{$src2, $dst|$dst, $src2}",
2921 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2922 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2923 "adc{b}\t{$src2, $dst|$dst, $src2}",
2924 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2925 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2926 (ins GR16:$src1, i16imm:$src2),
2927 "adc{w}\t{$src2, $dst|$dst, $src2}",
2928 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2929 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2930 (ins GR16:$src1, i16i8imm:$src2),
2931 "adc{w}\t{$src2, $dst|$dst, $src2}",
2932 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2934 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2935 (ins GR32:$src1, i32imm:$src2),
2936 "adc{l}\t{$src2, $dst|$dst, $src2}",
2937 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2938 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2939 (ins GR32:$src1, i32i8imm:$src2),
2940 "adc{l}\t{$src2, $dst|$dst, $src2}",
2941 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2943 let Constraints = "" in {
2944 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2945 "adc{b}\t{$src2, $dst|$dst, $src2}",
2946 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2947 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2948 "adc{w}\t{$src2, $dst|$dst, $src2}",
2949 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2951 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2952 "adc{l}\t{$src2, $dst|$dst, $src2}",
2953 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2954 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2955 "adc{b}\t{$src2, $dst|$dst, $src2}",
2956 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2957 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2958 "adc{w}\t{$src2, $dst|$dst, $src2}",
2959 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2961 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2962 "adc{w}\t{$src2, $dst|$dst, $src2}",
2963 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2965 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2966 "adc{l}\t{$src2, $dst|$dst, $src2}",
2967 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2968 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2969 "adc{l}\t{$src2, $dst|$dst, $src2}",
2970 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2972 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2973 "adc{b}\t{$src, %al|%al, $src}", []>;
2974 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2975 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2976 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2977 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2978 } // Constraints = ""
2979 } // Uses = [EFLAGS]
2981 // Register-Register Subtraction
2982 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2983 "sub{b}\t{$src2, $dst|$dst, $src2}",
2984 [(set GR8:$dst, EFLAGS,
2985 (X86sub_flag GR8:$src1, GR8:$src2))]>;
2986 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2987 "sub{w}\t{$src2, $dst|$dst, $src2}",
2988 [(set GR16:$dst, EFLAGS,
2989 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
2990 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2991 "sub{l}\t{$src2, $dst|$dst, $src2}",
2992 [(set GR32:$dst, EFLAGS,
2993 (X86sub_flag GR32:$src1, GR32:$src2))]>;
2995 let isCodeGenOnly = 1 in {
2996 def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2997 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2998 def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2999 (ins GR16:$src1, GR16:$src2),
3000 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3001 def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
3002 (ins GR32:$src1, GR32:$src2),
3003 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
3006 // Register-Memory Subtraction
3007 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
3008 (ins GR8 :$src1, i8mem :$src2),
3009 "sub{b}\t{$src2, $dst|$dst, $src2}",
3010 [(set GR8:$dst, EFLAGS,
3011 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
3012 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
3013 (ins GR16:$src1, i16mem:$src2),
3014 "sub{w}\t{$src2, $dst|$dst, $src2}",
3015 [(set GR16:$dst, EFLAGS,
3016 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
3017 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
3018 (ins GR32:$src1, i32mem:$src2),
3019 "sub{l}\t{$src2, $dst|$dst, $src2}",
3020 [(set GR32:$dst, EFLAGS,
3021 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
3023 // Register-Integer Subtraction
3024 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
3025 (ins GR8:$src1, i8imm:$src2),
3026 "sub{b}\t{$src2, $dst|$dst, $src2}",
3027 [(set GR8:$dst, EFLAGS,
3028 (X86sub_flag GR8:$src1, imm:$src2))]>;
3029 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
3030 (ins GR16:$src1, i16imm:$src2),
3031 "sub{w}\t{$src2, $dst|$dst, $src2}",
3032 [(set GR16:$dst, EFLAGS,
3033 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
3034 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
3035 (ins GR32:$src1, i32imm:$src2),
3036 "sub{l}\t{$src2, $dst|$dst, $src2}",
3037 [(set GR32:$dst, EFLAGS,
3038 (X86sub_flag GR32:$src1, imm:$src2))]>;
3039 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
3040 (ins GR16:$src1, i16i8imm:$src2),
3041 "sub{w}\t{$src2, $dst|$dst, $src2}",
3042 [(set GR16:$dst, EFLAGS,
3043 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
3044 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
3045 (ins GR32:$src1, i32i8imm:$src2),
3046 "sub{l}\t{$src2, $dst|$dst, $src2}",
3047 [(set GR32:$dst, EFLAGS,
3048 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
3050 let Constraints = "" in {
3051 // Memory-Register Subtraction
3052 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3053 "sub{b}\t{$src2, $dst|$dst, $src2}",
3054 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
3055 (implicit EFLAGS)]>;
3056 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3057 "sub{w}\t{$src2, $dst|$dst, $src2}",
3058 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
3059 (implicit EFLAGS)]>, OpSize;
3060 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3061 "sub{l}\t{$src2, $dst|$dst, $src2}",
3062 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
3063 (implicit EFLAGS)]>;
3065 // Memory-Integer Subtraction
3066 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3067 "sub{b}\t{$src2, $dst|$dst, $src2}",
3068 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
3069 (implicit EFLAGS)]>;
3070 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3071 "sub{w}\t{$src2, $dst|$dst, $src2}",
3072 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
3073 (implicit EFLAGS)]>, OpSize;
3074 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3075 "sub{l}\t{$src2, $dst|$dst, $src2}",
3076 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
3077 (implicit EFLAGS)]>;
3078 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3079 "sub{w}\t{$src2, $dst|$dst, $src2}",
3080 [(store (sub (load addr:$dst), i16immSExt8:$src2),
3082 (implicit EFLAGS)]>, OpSize;
3083 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3084 "sub{l}\t{$src2, $dst|$dst, $src2}",
3085 [(store (sub (load addr:$dst), i32immSExt8:$src2),
3087 (implicit EFLAGS)]>;
3089 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
3090 "sub{b}\t{$src, %al|%al, $src}", []>;
3091 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
3092 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3093 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
3094 "sub{l}\t{$src, %eax|%eax, $src}", []>;
3095 } // Constraints = ""
3097 let Uses = [EFLAGS] in {
3098 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
3099 (ins GR8:$src1, GR8:$src2),
3100 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3101 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
3102 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
3103 (ins GR16:$src1, GR16:$src2),
3104 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3105 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
3106 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
3107 (ins GR32:$src1, GR32:$src2),
3108 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3109 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
3111 let Constraints = "" in {
3112 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3113 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3114 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
3115 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3116 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3117 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
3119 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3120 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3121 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
3122 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
3123 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3124 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
3125 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
3126 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3127 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
3129 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3130 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3131 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
3133 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
3134 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3135 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
3136 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3137 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3138 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
3140 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3141 "sbb{b}\t{$src, %al|%al, $src}", []>;
3142 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3143 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3144 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3145 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
3146 } // Constraints = ""
3148 let isCodeGenOnly = 1 in {
3149 def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3150 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3151 def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3152 (ins GR16:$src1, GR16:$src2),
3153 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3154 def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3155 (ins GR32:$src1, GR32:$src2),
3156 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3159 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3160 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3161 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
3162 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3163 (ins GR16:$src1, i16mem:$src2),
3164 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3165 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
3167 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3168 (ins GR32:$src1, i32mem:$src2),
3169 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3170 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
3171 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3172 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3173 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
3174 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3175 (ins GR16:$src1, i16imm:$src2),
3176 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3177 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
3178 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3179 (ins GR16:$src1, i16i8imm:$src2),
3180 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3181 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3183 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3184 (ins GR32:$src1, i32imm:$src2),
3185 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3186 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
3187 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3188 (ins GR32:$src1, i32i8imm:$src2),
3189 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3190 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
3191 } // Uses = [EFLAGS]
3192 } // Defs = [EFLAGS]
3194 let Defs = [EFLAGS] in {
3195 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
3196 // Register-Register Signed Integer Multiply
3197 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
3198 "imul{w}\t{$src2, $dst|$dst, $src2}",
3199 [(set GR16:$dst, EFLAGS,
3200 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
3201 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
3202 "imul{l}\t{$src2, $dst|$dst, $src2}",
3203 [(set GR32:$dst, EFLAGS,
3204 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
3207 // Register-Memory Signed Integer Multiply
3208 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3209 (ins GR16:$src1, i16mem:$src2),
3210 "imul{w}\t{$src2, $dst|$dst, $src2}",
3211 [(set GR16:$dst, EFLAGS,
3212 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
3214 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3215 (ins GR32:$src1, i32mem:$src2),
3216 "imul{l}\t{$src2, $dst|$dst, $src2}",
3217 [(set GR32:$dst, EFLAGS,
3218 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
3219 } // Defs = [EFLAGS]
3220 } // end Two Address instructions
3222 // Suprisingly enough, these are not two address instructions!
3223 let Defs = [EFLAGS] in {
3224 // Register-Integer Signed Integer Multiply
3225 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
3226 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
3227 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3228 [(set GR16:$dst, EFLAGS,
3229 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
3230 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
3231 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
3232 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3233 [(set GR32:$dst, EFLAGS,
3234 (X86smul_flag GR32:$src1, imm:$src2))]>;
3235 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
3236 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
3237 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3238 [(set GR16:$dst, EFLAGS,
3239 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
3241 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
3242 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
3243 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3244 [(set GR32:$dst, EFLAGS,
3245 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
3247 // Memory-Integer Signed Integer Multiply
3248 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
3249 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
3250 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3251 [(set GR16:$dst, EFLAGS,
3252 (X86smul_flag (load addr:$src1), imm:$src2))]>,
3254 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
3255 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
3256 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3257 [(set GR32:$dst, EFLAGS,
3258 (X86smul_flag (load addr:$src1), imm:$src2))]>;
3259 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
3260 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
3261 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3262 [(set GR16:$dst, EFLAGS,
3263 (X86smul_flag (load addr:$src1),
3264 i16immSExt8:$src2))]>, OpSize;
3265 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
3266 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
3267 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3268 [(set GR32:$dst, EFLAGS,
3269 (X86smul_flag (load addr:$src1),
3270 i32immSExt8:$src2))]>;
3271 } // Defs = [EFLAGS]
3273 //===----------------------------------------------------------------------===//
3274 // Test instructions are just like AND, except they don't generate a result.
3276 let Defs = [EFLAGS] in {
3277 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
3278 def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3279 "test{b}\t{$src2, $src1|$src1, $src2}",
3280 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
3281 def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3282 "test{w}\t{$src2, $src1|$src1, $src2}",
3283 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
3286 def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3287 "test{l}\t{$src2, $src1|$src1, $src2}",
3288 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
3292 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3293 "test{b}\t{$src, %al|%al, $src}", []>;
3294 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3295 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3296 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3297 "test{l}\t{$src, %eax|%eax, $src}", []>;
3299 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
3300 "test{b}\t{$src2, $src1|$src1, $src2}",
3301 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
3303 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
3304 "test{w}\t{$src2, $src1|$src1, $src2}",
3305 [(set EFLAGS, (X86cmp (and GR16:$src1,
3306 (loadi16 addr:$src2)), 0))]>, OpSize;
3307 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
3308 "test{l}\t{$src2, $src1|$src1, $src2}",
3309 [(set EFLAGS, (X86cmp (and GR32:$src1,
3310 (loadi32 addr:$src2)), 0))]>;
3312 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
3313 (outs), (ins GR8:$src1, i8imm:$src2),
3314 "test{b}\t{$src2, $src1|$src1, $src2}",
3315 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
3316 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
3317 (outs), (ins GR16:$src1, i16imm:$src2),
3318 "test{w}\t{$src2, $src1|$src1, $src2}",
3319 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
3321 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
3322 (outs), (ins GR32:$src1, i32imm:$src2),
3323 "test{l}\t{$src2, $src1|$src1, $src2}",
3324 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
3326 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
3327 (outs), (ins i8mem:$src1, i8imm:$src2),
3328 "test{b}\t{$src2, $src1|$src1, $src2}",
3329 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
3331 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
3332 (outs), (ins i16mem:$src1, i16imm:$src2),
3333 "test{w}\t{$src2, $src1|$src1, $src2}",
3334 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
3336 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
3337 (outs), (ins i32mem:$src1, i32imm:$src2),
3338 "test{l}\t{$src2, $src1|$src1, $src2}",
3339 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
3341 } // Defs = [EFLAGS]
3344 // Condition code ops, incl. set if equal/not equal/...
3345 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
3346 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
3347 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
3348 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
3350 let Uses = [EFLAGS] in {
3351 // Use sbb to materialize carry bit.
3352 let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3353 // FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3354 // However, Pat<> can't replicate the destination reg into the inputs of the
3356 // FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3358 def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
3359 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3360 def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
3361 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
3363 def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
3364 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3367 def SETEr : I<0x94, MRM0r,
3368 (outs GR8 :$dst), (ins),
3370 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
3372 def SETEm : I<0x94, MRM0m,
3373 (outs), (ins i8mem:$dst),
3375 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
3378 def SETNEr : I<0x95, MRM0r,
3379 (outs GR8 :$dst), (ins),
3381 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
3383 def SETNEm : I<0x95, MRM0m,
3384 (outs), (ins i8mem:$dst),
3386 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
3389 def SETLr : I<0x9C, MRM0r,
3390 (outs GR8 :$dst), (ins),
3392 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
3393 TB; // GR8 = < signed
3394 def SETLm : I<0x9C, MRM0m,
3395 (outs), (ins i8mem:$dst),
3397 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
3398 TB; // [mem8] = < signed
3400 def SETGEr : I<0x9D, MRM0r,
3401 (outs GR8 :$dst), (ins),
3403 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
3404 TB; // GR8 = >= signed
3405 def SETGEm : I<0x9D, MRM0m,
3406 (outs), (ins i8mem:$dst),
3408 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
3409 TB; // [mem8] = >= signed
3411 def SETLEr : I<0x9E, MRM0r,
3412 (outs GR8 :$dst), (ins),
3414 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3415 TB; // GR8 = <= signed
3416 def SETLEm : I<0x9E, MRM0m,
3417 (outs), (ins i8mem:$dst),
3419 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3420 TB; // [mem8] = <= signed
3422 def SETGr : I<0x9F, MRM0r,
3423 (outs GR8 :$dst), (ins),
3425 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3426 TB; // GR8 = > signed
3427 def SETGm : I<0x9F, MRM0m,
3428 (outs), (ins i8mem:$dst),
3430 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3431 TB; // [mem8] = > signed
3433 def SETBr : I<0x92, MRM0r,
3434 (outs GR8 :$dst), (ins),
3436 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3437 TB; // GR8 = < unsign
3438 def SETBm : I<0x92, MRM0m,
3439 (outs), (ins i8mem:$dst),
3441 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3442 TB; // [mem8] = < unsign
3444 def SETAEr : I<0x93, MRM0r,
3445 (outs GR8 :$dst), (ins),
3447 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3448 TB; // GR8 = >= unsign
3449 def SETAEm : I<0x93, MRM0m,
3450 (outs), (ins i8mem:$dst),
3452 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3453 TB; // [mem8] = >= unsign
3455 def SETBEr : I<0x96, MRM0r,
3456 (outs GR8 :$dst), (ins),
3458 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3459 TB; // GR8 = <= unsign
3460 def SETBEm : I<0x96, MRM0m,
3461 (outs), (ins i8mem:$dst),
3463 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3464 TB; // [mem8] = <= unsign
3466 def SETAr : I<0x97, MRM0r,
3467 (outs GR8 :$dst), (ins),
3469 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3470 TB; // GR8 = > signed
3471 def SETAm : I<0x97, MRM0m,
3472 (outs), (ins i8mem:$dst),
3474 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3475 TB; // [mem8] = > signed
3477 def SETSr : I<0x98, MRM0r,
3478 (outs GR8 :$dst), (ins),
3480 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3481 TB; // GR8 = <sign bit>
3482 def SETSm : I<0x98, MRM0m,
3483 (outs), (ins i8mem:$dst),
3485 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3486 TB; // [mem8] = <sign bit>
3487 def SETNSr : I<0x99, MRM0r,
3488 (outs GR8 :$dst), (ins),
3490 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3491 TB; // GR8 = !<sign bit>
3492 def SETNSm : I<0x99, MRM0m,
3493 (outs), (ins i8mem:$dst),
3495 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3496 TB; // [mem8] = !<sign bit>
3498 def SETPr : I<0x9A, MRM0r,
3499 (outs GR8 :$dst), (ins),
3501 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3503 def SETPm : I<0x9A, MRM0m,
3504 (outs), (ins i8mem:$dst),
3506 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3507 TB; // [mem8] = parity
3508 def SETNPr : I<0x9B, MRM0r,
3509 (outs GR8 :$dst), (ins),
3511 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3512 TB; // GR8 = not parity
3513 def SETNPm : I<0x9B, MRM0m,
3514 (outs), (ins i8mem:$dst),
3516 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3517 TB; // [mem8] = not parity
3519 def SETOr : I<0x90, MRM0r,
3520 (outs GR8 :$dst), (ins),
3522 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3523 TB; // GR8 = overflow
3524 def SETOm : I<0x90, MRM0m,
3525 (outs), (ins i8mem:$dst),
3527 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3528 TB; // [mem8] = overflow
3529 def SETNOr : I<0x91, MRM0r,
3530 (outs GR8 :$dst), (ins),
3532 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3533 TB; // GR8 = not overflow
3534 def SETNOm : I<0x91, MRM0m,
3535 (outs), (ins i8mem:$dst),
3537 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3538 TB; // [mem8] = not overflow
3539 } // Uses = [EFLAGS]
3542 // Integer comparisons
3543 let Defs = [EFLAGS] in {
3544 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3545 "cmp{b}\t{$src, %al|%al, $src}", []>;
3546 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3547 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3548 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3549 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3551 def CMP8rr : I<0x38, MRMDestReg,
3552 (outs), (ins GR8 :$src1, GR8 :$src2),
3553 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3554 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
3555 def CMP16rr : I<0x39, MRMDestReg,
3556 (outs), (ins GR16:$src1, GR16:$src2),
3557 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3558 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
3559 def CMP32rr : I<0x39, MRMDestReg,
3560 (outs), (ins GR32:$src1, GR32:$src2),
3561 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3562 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
3563 def CMP8mr : I<0x38, MRMDestMem,
3564 (outs), (ins i8mem :$src1, GR8 :$src2),
3565 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3566 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
3567 def CMP16mr : I<0x39, MRMDestMem,
3568 (outs), (ins i16mem:$src1, GR16:$src2),
3569 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3570 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3572 def CMP32mr : I<0x39, MRMDestMem,
3573 (outs), (ins i32mem:$src1, GR32:$src2),
3574 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3575 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
3576 def CMP8rm : I<0x3A, MRMSrcMem,
3577 (outs), (ins GR8 :$src1, i8mem :$src2),
3578 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3579 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
3580 def CMP16rm : I<0x3B, MRMSrcMem,
3581 (outs), (ins GR16:$src1, i16mem:$src2),
3582 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3583 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3585 def CMP32rm : I<0x3B, MRMSrcMem,
3586 (outs), (ins GR32:$src1, i32mem:$src2),
3587 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3588 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
3590 // These are alternate spellings for use by the disassembler, we mark them as
3591 // code gen only to ensure they aren't matched by the assembler.
3592 let isCodeGenOnly = 1 in {
3593 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3594 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3595 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3596 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3597 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3598 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3601 def CMP8ri : Ii8<0x80, MRM7r,
3602 (outs), (ins GR8:$src1, i8imm:$src2),
3603 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3604 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
3605 def CMP16ri : Ii16<0x81, MRM7r,
3606 (outs), (ins GR16:$src1, i16imm:$src2),
3607 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3608 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
3609 def CMP32ri : Ii32<0x81, MRM7r,
3610 (outs), (ins GR32:$src1, i32imm:$src2),
3611 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3612 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
3613 def CMP8mi : Ii8 <0x80, MRM7m,
3614 (outs), (ins i8mem :$src1, i8imm :$src2),
3615 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3616 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
3617 def CMP16mi : Ii16<0x81, MRM7m,
3618 (outs), (ins i16mem:$src1, i16imm:$src2),
3619 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3620 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
3622 def CMP32mi : Ii32<0x81, MRM7m,
3623 (outs), (ins i32mem:$src1, i32imm:$src2),
3624 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3625 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
3626 def CMP16ri8 : Ii8<0x83, MRM7r,
3627 (outs), (ins GR16:$src1, i16i8imm:$src2),
3628 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3629 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3631 def CMP16mi8 : Ii8<0x83, MRM7m,
3632 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3633 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3634 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3635 i16immSExt8:$src2))]>, OpSize;
3636 def CMP32mi8 : Ii8<0x83, MRM7m,
3637 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3638 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3639 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3640 i32immSExt8:$src2))]>;
3641 def CMP32ri8 : Ii8<0x83, MRM7r,
3642 (outs), (ins GR32:$src1, i32i8imm:$src2),
3643 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3644 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
3645 } // Defs = [EFLAGS]
3648 // TODO: BTC, BTR, and BTS
3649 let Defs = [EFLAGS] in {
3650 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3651 "bt{w}\t{$src2, $src1|$src1, $src2}",
3652 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
3653 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3654 "bt{l}\t{$src2, $src1|$src1, $src2}",
3655 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
3657 // Unlike with the register+register form, the memory+register form of the
3658 // bt instruction does not ignore the high bits of the index. From ISel's
3659 // perspective, this is pretty bizarre. Make these instructions disassembly
3662 def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3663 "bt{w}\t{$src2, $src1|$src1, $src2}",
3664 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3665 // (implicit EFLAGS)]
3667 >, OpSize, TB, Requires<[FastBTMem]>;
3668 def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3669 "bt{l}\t{$src2, $src1|$src1, $src2}",
3670 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3671 // (implicit EFLAGS)]
3673 >, TB, Requires<[FastBTMem]>;
3675 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3676 "bt{w}\t{$src2, $src1|$src1, $src2}",
3677 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3679 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3680 "bt{l}\t{$src2, $src1|$src1, $src2}",
3681 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
3682 // Note that these instructions don't need FastBTMem because that
3683 // only applies when the other operand is in a register. When it's
3684 // an immediate, bt is still fast.
3685 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3686 "bt{w}\t{$src2, $src1|$src1, $src2}",
3687 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3689 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3690 "bt{l}\t{$src2, $src1|$src1, $src2}",
3691 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3694 def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3695 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3696 def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3697 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3698 def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3699 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3700 def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3701 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3702 def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3703 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3704 def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3705 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3706 def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3707 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3708 def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3709 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3711 def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3712 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3713 def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3714 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3715 def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3716 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3717 def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3718 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3719 def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3720 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3721 def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3722 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3723 def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3724 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3725 def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3726 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3728 def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3729 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3730 def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3731 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3732 def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3733 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3734 def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3735 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3736 def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3737 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3738 def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3739 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3740 def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3741 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3742 def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3743 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3744 } // Defs = [EFLAGS]
3746 // Sign/Zero extenders
3747 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3748 // of the register here. This has a smaller encoding and avoids a
3749 // partial-register update. Actual movsbw included for the disassembler.
3750 def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3751 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3752 def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3753 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3754 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3755 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
3756 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3757 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3758 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3759 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3760 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3761 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3762 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3763 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3764 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3765 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3766 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3767 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3768 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3769 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3771 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3772 // of the register here. This has a smaller encoding and avoids a
3773 // partial-register update. Actual movzbw included for the disassembler.
3774 def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3775 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3776 def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3777 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3778 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3779 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
3780 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3781 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3782 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3783 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3784 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3785 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3786 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3787 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3788 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3789 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3790 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3791 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3792 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3793 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3795 // These are the same as the regular MOVZX32rr8 and MOVZX32rm8
3796 // except that they use GR32_NOREX for the output operand register class
3797 // instead of GR32. This allows them to operate on h registers on x86-64.
3798 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3799 (outs GR32_NOREX:$dst), (ins GR8:$src),
3800 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3803 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3804 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3805 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3808 let neverHasSideEffects = 1 in {
3809 let Defs = [AX], Uses = [AL] in
3810 def CBW : I<0x98, RawFrm, (outs), (ins),
3811 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3812 let Defs = [EAX], Uses = [AX] in
3813 def CWDE : I<0x98, RawFrm, (outs), (ins),
3814 "{cwtl|cwde}", []>; // EAX = signext(AX)
3816 let Defs = [AX,DX], Uses = [AX] in
3817 def CWD : I<0x99, RawFrm, (outs), (ins),
3818 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3819 let Defs = [EAX,EDX], Uses = [EAX] in
3820 def CDQ : I<0x99, RawFrm, (outs), (ins),
3821 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3824 //===----------------------------------------------------------------------===//
3825 // Alias Instructions
3826 //===----------------------------------------------------------------------===//
3828 // Alias instructions that map movr0 to xor.
3829 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3830 // FIXME: Set encoding to pseudo.
3831 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3832 isCodeGenOnly = 1 in {
3833 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
3834 [(set GR8:$dst, 0)]>;
3836 // We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3837 // encoding and avoids a partial-register update sometimes, but doing so
3838 // at isel time interferes with rematerialization in the current register
3839 // allocator. For now, this is rewritten when the instruction is lowered
3841 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3843 [(set GR16:$dst, 0)]>, OpSize;
3845 // FIXME: Set encoding to pseudo.
3846 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
3847 [(set GR32:$dst, 0)]>;
3850 //===----------------------------------------------------------------------===//
3851 // Thread Local Storage Instructions
3855 // All calls clobber the non-callee saved registers. ESP is marked as
3856 // a use to prevent stack-pointer assignments that appear immediately
3857 // before calls from potentially appearing dead.
3858 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3859 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3860 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3861 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3863 def TLS_addr32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
3864 "leal\t$sym, %eax; "
3865 "call\t___tls_get_addr@PLT",
3866 [(X86tlsaddr tls32addr:$sym)]>,
3867 Requires<[In32BitMode]>;
3869 // Darwin TLS Support
3870 // For i386, the address of the thunk is passed on the stack, on return the
3871 // address of the variable is in %eax. %ecx is trashed during the function
3872 // call. All other registers are preserved.
3873 let Defs = [EAX, ECX],
3875 usesCustomInserter = 1 in
3876 def TLSCall_32 : I<0, Pseudo, (outs), (ins i32mem:$sym),
3878 [(X86TLSCall addr:$sym)]>,
3879 Requires<[In32BitMode]>;
3881 let AddedComplexity = 5, isCodeGenOnly = 1 in
3882 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3883 "movl\t%gs:$src, $dst",
3884 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3886 let AddedComplexity = 5, isCodeGenOnly = 1 in
3887 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3888 "movl\t%fs:$src, $dst",
3889 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3891 //===----------------------------------------------------------------------===//
3892 // EH Pseudo Instructions
3894 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3895 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3896 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3897 "ret\t#eh_return, addr: $addr",
3898 [(X86ehret GR32:$addr)]>;
3902 //===----------------------------------------------------------------------===//
3906 // Atomic swap. These are just normal xchg instructions. But since a memory
3907 // operand is referenced, the atomicity is ensured.
3908 let Constraints = "$val = $dst" in {
3909 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3910 (ins GR32:$val, i32mem:$ptr),
3911 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3912 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3913 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3914 (ins GR16:$val, i16mem:$ptr),
3915 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3916 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3918 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3919 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3920 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3922 def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3923 "xchg{l}\t{$val, $src|$src, $val}", []>;
3924 def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3925 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3926 def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3927 "xchg{b}\t{$val, $src|$src, $val}", []>;
3930 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3931 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3932 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3933 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3935 // Atomic compare and swap.
3936 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3937 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3939 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3940 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3942 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3943 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
3946 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3949 let Defs = [AX, EFLAGS], Uses = [AX] in {
3950 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3952 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3953 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3955 let Defs = [AL, EFLAGS], Uses = [AL] in {
3956 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3958 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3959 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3962 // Atomic exchange and add
3963 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3964 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
3966 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3967 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3969 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
3971 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3972 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3974 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3976 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3977 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3981 def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3982 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3983 def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3984 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3985 def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3986 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3988 let mayLoad = 1, mayStore = 1 in {
3989 def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3990 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3991 def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3992 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3993 def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3994 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3997 def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3998 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3999 def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
4000 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4001 def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4002 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
4004 let mayLoad = 1, mayStore = 1 in {
4005 def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
4006 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
4007 def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
4008 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4009 def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
4010 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
4013 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
4014 def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
4015 "cmpxchg8b\t$dst", []>, TB;
4017 // Optimized codegen when the non-memory output is not used.
4018 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
4019 let Defs = [EFLAGS], mayLoad = 1, mayStore = 1 in {
4020 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
4022 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4023 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4025 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4026 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4028 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4029 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
4031 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4032 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
4034 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4035 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
4037 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4038 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
4040 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4041 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4043 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4045 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
4047 "inc{b}\t$dst", []>, LOCK;
4048 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
4050 "inc{w}\t$dst", []>, OpSize, LOCK;
4051 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
4053 "inc{l}\t$dst", []>, LOCK;
4055 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
4057 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4058 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
4060 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4061 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
4063 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4064 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
4066 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4067 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
4069 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4070 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
4072 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4073 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
4075 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
4076 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
4078 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
4080 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
4082 "dec{b}\t$dst", []>, LOCK;
4083 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
4085 "dec{w}\t$dst", []>, OpSize, LOCK;
4086 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
4088 "dec{l}\t$dst", []>, LOCK;
4091 // Atomic exchange, and, or, xor
4092 let Constraints = "$val = $dst", Defs = [EFLAGS],
4093 usesCustomInserter = 1 in {
4094 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4095 "#ATOMAND32 PSEUDO!",
4096 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
4097 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4098 "#ATOMOR32 PSEUDO!",
4099 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
4100 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4101 "#ATOMXOR32 PSEUDO!",
4102 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
4103 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4104 "#ATOMNAND32 PSEUDO!",
4105 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
4106 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
4107 "#ATOMMIN32 PSEUDO!",
4108 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
4109 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4110 "#ATOMMAX32 PSEUDO!",
4111 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
4112 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4113 "#ATOMUMIN32 PSEUDO!",
4114 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
4115 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
4116 "#ATOMUMAX32 PSEUDO!",
4117 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
4119 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4120 "#ATOMAND16 PSEUDO!",
4121 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
4122 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4123 "#ATOMOR16 PSEUDO!",
4124 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
4125 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4126 "#ATOMXOR16 PSEUDO!",
4127 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
4128 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4129 "#ATOMNAND16 PSEUDO!",
4130 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
4131 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
4132 "#ATOMMIN16 PSEUDO!",
4133 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
4134 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4135 "#ATOMMAX16 PSEUDO!",
4136 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
4137 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4138 "#ATOMUMIN16 PSEUDO!",
4139 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
4140 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
4141 "#ATOMUMAX16 PSEUDO!",
4142 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
4144 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4145 "#ATOMAND8 PSEUDO!",
4146 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
4147 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4149 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
4150 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4151 "#ATOMXOR8 PSEUDO!",
4152 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
4153 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
4154 "#ATOMNAND8 PSEUDO!",
4155 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
4158 let Constraints = "$val1 = $dst1, $val2 = $dst2",
4159 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4160 Uses = [EAX, EBX, ECX, EDX],
4161 mayLoad = 1, mayStore = 1,
4162 usesCustomInserter = 1 in {
4163 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4164 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4165 "#ATOMAND6432 PSEUDO!", []>;
4166 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4167 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4168 "#ATOMOR6432 PSEUDO!", []>;
4169 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4170 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4171 "#ATOMXOR6432 PSEUDO!", []>;
4172 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4173 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4174 "#ATOMNAND6432 PSEUDO!", []>;
4175 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4176 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4177 "#ATOMADD6432 PSEUDO!", []>;
4178 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4179 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4180 "#ATOMSUB6432 PSEUDO!", []>;
4181 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4182 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4183 "#ATOMSWAP6432 PSEUDO!", []>;
4186 // Segmentation support instructions.
4188 def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4189 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4190 def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4191 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4193 // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4194 def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4195 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4196 def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4197 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4199 def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4200 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4201 def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4202 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4203 def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4204 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4205 def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4206 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4208 def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
4210 def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4211 "str{w}\t{$dst}", []>, TB;
4212 def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4213 "str{w}\t{$dst}", []>, TB;
4214 def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4215 "ltr{w}\t{$src}", []>, TB;
4216 def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4217 "ltr{w}\t{$src}", []>, TB;
4219 def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4220 "push{w}\t%fs", []>, OpSize, TB;
4221 def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4222 "push{l}\t%fs", []>, TB;
4223 def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4224 "push{w}\t%gs", []>, OpSize, TB;
4225 def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4226 "push{l}\t%gs", []>, TB;
4228 def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4229 "pop{w}\t%fs", []>, OpSize, TB;
4230 def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4231 "pop{l}\t%fs", []>, TB;
4232 def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4233 "pop{w}\t%gs", []>, OpSize, TB;
4234 def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4235 "pop{l}\t%gs", []>, TB;
4237 def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4238 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4239 def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4240 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4241 def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4242 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4243 def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4244 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4245 def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4246 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4247 def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4248 "les{l}\t{$src, $dst|$dst, $src}", []>;
4249 def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4250 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4251 def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4252 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4253 def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4254 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4255 def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4256 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4258 def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4259 "verr\t$seg", []>, TB;
4260 def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4261 "verr\t$seg", []>, TB;
4262 def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4263 "verw\t$seg", []>, TB;
4264 def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4265 "verw\t$seg", []>, TB;
4267 // Descriptor-table support instructions
4269 def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4270 "sgdt\t$dst", []>, TB;
4271 def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4272 "sidt\t$dst", []>, TB;
4273 def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4274 "sldt{w}\t$dst", []>, TB;
4275 def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4276 "sldt{w}\t$dst", []>, TB;
4277 def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4278 "lgdt\t$src", []>, TB;
4279 def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4280 "lidt\t$src", []>, TB;
4281 def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4282 "lldt{w}\t$src", []>, TB;
4283 def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4284 "lldt{w}\t$src", []>, TB;
4286 // Lock instruction prefix
4287 def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4289 // Repeat string operation instruction prefixes
4290 // These uses the DF flag in the EFLAGS register to inc or dec ECX
4291 let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4292 // Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4293 def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4294 // Repeat while not equal (used with CMPS and SCAS)
4295 def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4298 // Segment override instruction prefixes
4299 def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4300 def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4301 def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4302 def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4303 def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4304 def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4306 // String manipulation instructions
4308 def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4309 def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
4310 def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4312 def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4313 def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4314 def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4316 // CPU flow control instructions
4318 def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4319 def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4321 // FPU control instructions
4323 def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4325 // Flag instructions
4327 def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4328 def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4329 def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4330 def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4331 def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4332 def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4333 def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4335 def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4337 // Table lookup instructions
4339 def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4341 // Specialized register support
4343 def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4344 def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4345 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4347 def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4348 "smsw{w}\t$dst", []>, OpSize, TB;
4349 def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4350 "smsw{l}\t$dst", []>, TB;
4351 // For memory operands, there is only a 16-bit form
4352 def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4353 "smsw{w}\t$dst", []>, TB;
4355 def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4356 "lmsw{w}\t$src", []>, TB;
4357 def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4358 "lmsw{w}\t$src", []>, TB;
4360 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4362 // Cache instructions
4364 def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4365 def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4370 def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
4372 def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
4374 def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
4375 def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4376 "vmclear\t$vmcs", []>, OpSize, TB;
4378 def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
4380 def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
4381 def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4382 "vmptrld\t$vmcs", []>, TB;
4383 def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4384 "vmptrst\t$vmcs", []>, TB;
4385 def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4386 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4387 def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4388 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4389 def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4390 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4391 def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4392 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4393 def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4394 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4395 def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4396 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4397 def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4398 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4399 def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4400 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4402 def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
4403 def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4404 "vmxon\t{$vmxon}", []>, XS;
4406 //===----------------------------------------------------------------------===//
4407 // Non-Instruction Patterns
4408 //===----------------------------------------------------------------------===//
4410 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
4411 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4412 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
4413 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
4414 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4415 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
4416 def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
4418 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4419 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4420 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4421 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4422 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4423 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4424 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4425 (ADD32ri GR32:$src1, texternalsym:$src2)>;
4426 def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4427 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
4429 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4430 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4431 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4432 (MOV32mi addr:$dst, texternalsym:$src)>;
4433 def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4434 (MOV32mi addr:$dst, tblockaddress:$src)>;
4438 def : Pat<(X86tcret GR32_TC:$dst, imm:$off),
4439 (TCRETURNri GR32_TC:$dst, imm:$off)>,
4440 Requires<[In32BitMode]>;
4442 // FIXME: This is disabled for 32-bit PIC mode because the global base
4443 // register which is part of the address mode may be assigned a
4444 // callee-saved register.
4445 def : Pat<(X86tcret (load addr:$dst), imm:$off),
4446 (TCRETURNmi addr:$dst, imm:$off)>,
4447 Requires<[In32BitMode, IsNotPIC]>;
4449 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4450 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4451 Requires<[In32BitMode]>;
4453 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4454 (TCRETURNdi texternalsym:$dst, imm:$off)>,
4455 Requires<[In32BitMode]>;
4457 // Normal calls, with various flavors of addresses.
4458 def : Pat<(X86call (i32 tglobaladdr:$dst)),
4459 (CALLpcrel32 tglobaladdr:$dst)>;
4460 def : Pat<(X86call (i32 texternalsym:$dst)),
4461 (CALLpcrel32 texternalsym:$dst)>;
4462 def : Pat<(X86call (i32 imm:$dst)),
4463 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
4465 // X86 specific add which produces a flag.
4466 def : Pat<(addc GR32:$src1, GR32:$src2),
4467 (ADD32rr GR32:$src1, GR32:$src2)>;
4468 def : Pat<(addc GR32:$src1, (load addr:$src2)),
4469 (ADD32rm GR32:$src1, addr:$src2)>;
4470 def : Pat<(addc GR32:$src1, imm:$src2),
4471 (ADD32ri GR32:$src1, imm:$src2)>;
4472 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4473 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4475 def : Pat<(subc GR32:$src1, GR32:$src2),
4476 (SUB32rr GR32:$src1, GR32:$src2)>;
4477 def : Pat<(subc GR32:$src1, (load addr:$src2)),
4478 (SUB32rm GR32:$src1, addr:$src2)>;
4479 def : Pat<(subc GR32:$src1, imm:$src2),
4480 (SUB32ri GR32:$src1, imm:$src2)>;
4481 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4482 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4486 // TEST R,R is smaller than CMP R,0
4487 def : Pat<(X86cmp GR8:$src1, 0),
4488 (TEST8rr GR8:$src1, GR8:$src1)>;
4489 def : Pat<(X86cmp GR16:$src1, 0),
4490 (TEST16rr GR16:$src1, GR16:$src1)>;
4491 def : Pat<(X86cmp GR32:$src1, 0),
4492 (TEST32rr GR32:$src1, GR32:$src1)>;
4494 // Conditional moves with folded loads with operands swapped and conditions
4496 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4497 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4498 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4499 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4500 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4501 (CMOVB16rm GR16:$src2, addr:$src1)>;
4502 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4503 (CMOVB32rm GR32:$src2, addr:$src1)>;
4504 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4505 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4506 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4507 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4508 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4509 (CMOVE16rm GR16:$src2, addr:$src1)>;
4510 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4511 (CMOVE32rm GR32:$src2, addr:$src1)>;
4512 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4513 (CMOVA16rm GR16:$src2, addr:$src1)>;
4514 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4515 (CMOVA32rm GR32:$src2, addr:$src1)>;
4516 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4517 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4518 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4519 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4520 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4521 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4522 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4523 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4524 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4525 (CMOVL16rm GR16:$src2, addr:$src1)>;
4526 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4527 (CMOVL32rm GR32:$src2, addr:$src1)>;
4528 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4529 (CMOVG16rm GR16:$src2, addr:$src1)>;
4530 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4531 (CMOVG32rm GR32:$src2, addr:$src1)>;
4532 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4533 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4534 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4535 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4536 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4537 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4538 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4539 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4540 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4541 (CMOVP16rm GR16:$src2, addr:$src1)>;
4542 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4543 (CMOVP32rm GR32:$src2, addr:$src1)>;
4544 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4545 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4546 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4547 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4548 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4549 (CMOVS16rm GR16:$src2, addr:$src1)>;
4550 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4551 (CMOVS32rm GR32:$src2, addr:$src1)>;
4552 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4553 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4554 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4555 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4556 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4557 (CMOVO16rm GR16:$src2, addr:$src1)>;
4558 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4559 (CMOVO32rm GR32:$src2, addr:$src1)>;
4561 // zextload bool -> zextload byte
4562 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4563 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4564 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4566 // extload bool -> extload byte
4567 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4568 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4569 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4570 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
4571 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4572 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4574 // anyext. Define these to do an explicit zero-extend to
4575 // avoid partial-register updates.
4576 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4577 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4579 // Except for i16 -> i32 since isel expect i16 ops to be promoted to i32.
4580 def : Pat<(i32 (anyext GR16:$src)),
4581 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, sub_16bit)>;
4584 //===----------------------------------------------------------------------===//
4586 //===----------------------------------------------------------------------===//
4588 // Odd encoding trick: -128 fits into an 8-bit immediate field while
4589 // +128 doesn't, so in this special case use a sub instead of an add.
4590 def : Pat<(add GR16:$src1, 128),
4591 (SUB16ri8 GR16:$src1, -128)>;
4592 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4593 (SUB16mi8 addr:$dst, -128)>;
4594 def : Pat<(add GR32:$src1, 128),
4595 (SUB32ri8 GR32:$src1, -128)>;
4596 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4597 (SUB32mi8 addr:$dst, -128)>;
4599 // r & (2^16-1) ==> movz
4600 def : Pat<(and GR32:$src1, 0xffff),
4601 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, sub_16bit))>;
4602 // r & (2^8-1) ==> movz
4603 def : Pat<(and GR32:$src1, 0xff),
4604 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4607 Requires<[In32BitMode]>;
4608 // r & (2^8-1) ==> movz
4609 def : Pat<(and GR16:$src1, 0xff),
4610 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4613 Requires<[In32BitMode]>;
4615 // sext_inreg patterns
4616 def : Pat<(sext_inreg GR32:$src, i16),
4617 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, sub_16bit))>;
4618 def : Pat<(sext_inreg GR32:$src, i8),
4619 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4622 Requires<[In32BitMode]>;
4623 def : Pat<(sext_inreg GR16:$src, i8),
4624 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4627 Requires<[In32BitMode]>;
4630 def : Pat<(i16 (trunc GR32:$src)),
4631 (EXTRACT_SUBREG GR32:$src, sub_16bit)>;
4632 def : Pat<(i8 (trunc GR32:$src)),
4633 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4635 Requires<[In32BitMode]>;
4636 def : Pat<(i8 (trunc GR16:$src)),
4637 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4639 Requires<[In32BitMode]>;
4641 // h-register tricks
4642 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
4643 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4645 Requires<[In32BitMode]>;
4646 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
4647 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4649 Requires<[In32BitMode]>;
4650 def : Pat<(srl GR16:$src, (i8 8)),
4653 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4656 Requires<[In32BitMode]>;
4657 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
4658 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4661 Requires<[In32BitMode]>;
4662 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
4663 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4666 Requires<[In32BitMode]>;
4667 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
4668 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4671 Requires<[In32BitMode]>;
4672 def : Pat<(srl (and_su GR32:$src, 0xff00), (i8 8)),
4673 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4676 Requires<[In32BitMode]>;
4678 // (shl x, 1) ==> (add x, x)
4679 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4680 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4681 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4683 // (shl x (and y, 31)) ==> (shl x, y)
4684 def : Pat<(shl GR8:$src1, (and CL, 31)),
4685 (SHL8rCL GR8:$src1)>;
4686 def : Pat<(shl GR16:$src1, (and CL, 31)),
4687 (SHL16rCL GR16:$src1)>;
4688 def : Pat<(shl GR32:$src1, (and CL, 31)),
4689 (SHL32rCL GR32:$src1)>;
4690 def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4691 (SHL8mCL addr:$dst)>;
4692 def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4693 (SHL16mCL addr:$dst)>;
4694 def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4695 (SHL32mCL addr:$dst)>;
4697 def : Pat<(srl GR8:$src1, (and CL, 31)),
4698 (SHR8rCL GR8:$src1)>;
4699 def : Pat<(srl GR16:$src1, (and CL, 31)),
4700 (SHR16rCL GR16:$src1)>;
4701 def : Pat<(srl GR32:$src1, (and CL, 31)),
4702 (SHR32rCL GR32:$src1)>;
4703 def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4704 (SHR8mCL addr:$dst)>;
4705 def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4706 (SHR16mCL addr:$dst)>;
4707 def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4708 (SHR32mCL addr:$dst)>;
4710 def : Pat<(sra GR8:$src1, (and CL, 31)),
4711 (SAR8rCL GR8:$src1)>;
4712 def : Pat<(sra GR16:$src1, (and CL, 31)),
4713 (SAR16rCL GR16:$src1)>;
4714 def : Pat<(sra GR32:$src1, (and CL, 31)),
4715 (SAR32rCL GR32:$src1)>;
4716 def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4717 (SAR8mCL addr:$dst)>;
4718 def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4719 (SAR16mCL addr:$dst)>;
4720 def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4721 (SAR32mCL addr:$dst)>;
4723 // (anyext (setcc_carry)) -> (setcc_carry)
4724 def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4726 def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4728 def : Pat<(i32 (anyext (i16 (X86setcc_c X86_COND_B, EFLAGS)))),
4731 // (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
4732 let AddedComplexity = 5 in { // Try this before the selecting to OR
4733 def : Pat<(or_is_add GR16:$src1, imm:$src2),
4734 (ADD16ri GR16:$src1, imm:$src2)>;
4735 def : Pat<(or_is_add GR32:$src1, imm:$src2),
4736 (ADD32ri GR32:$src1, imm:$src2)>;
4737 def : Pat<(or_is_add GR16:$src1, i16immSExt8:$src2),
4738 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4739 def : Pat<(or_is_add GR32:$src1, i32immSExt8:$src2),
4740 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4741 def : Pat<(or_is_add GR16:$src1, GR16:$src2),
4742 (ADD16rr GR16:$src1, GR16:$src2)>;
4743 def : Pat<(or_is_add GR32:$src1, GR32:$src2),
4744 (ADD32rr GR32:$src1, GR32:$src2)>;
4745 } // AddedComplexity
4747 //===----------------------------------------------------------------------===//
4748 // EFLAGS-defining Patterns
4749 //===----------------------------------------------------------------------===//
4752 def : Pat<(add GR8 :$src1, GR8 :$src2), (ADD8rr GR8 :$src1, GR8 :$src2)>;
4753 def : Pat<(add GR16:$src1, GR16:$src2), (ADD16rr GR16:$src1, GR16:$src2)>;
4754 def : Pat<(add GR32:$src1, GR32:$src2), (ADD32rr GR32:$src1, GR32:$src2)>;
4757 def : Pat<(add GR8:$src1, (loadi8 addr:$src2)),
4758 (ADD8rm GR8:$src1, addr:$src2)>;
4759 def : Pat<(add GR16:$src1, (loadi16 addr:$src2)),
4760 (ADD16rm GR16:$src1, addr:$src2)>;
4761 def : Pat<(add GR32:$src1, (loadi32 addr:$src2)),
4762 (ADD32rm GR32:$src1, addr:$src2)>;
4765 def : Pat<(add GR8 :$src1, imm:$src2), (ADD8ri GR8:$src1 , imm:$src2)>;
4766 def : Pat<(add GR16:$src1, imm:$src2), (ADD16ri GR16:$src1, imm:$src2)>;
4767 def : Pat<(add GR32:$src1, imm:$src2), (ADD32ri GR32:$src1, imm:$src2)>;
4768 def : Pat<(add GR16:$src1, i16immSExt8:$src2),
4769 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4770 def : Pat<(add GR32:$src1, i32immSExt8:$src2),
4771 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4774 def : Pat<(sub GR8 :$src1, GR8 :$src2), (SUB8rr GR8 :$src1, GR8 :$src2)>;
4775 def : Pat<(sub GR16:$src1, GR16:$src2), (SUB16rr GR16:$src1, GR16:$src2)>;
4776 def : Pat<(sub GR32:$src1, GR32:$src2), (SUB32rr GR32:$src1, GR32:$src2)>;
4779 def : Pat<(sub GR8:$src1, (loadi8 addr:$src2)),
4780 (SUB8rm GR8:$src1, addr:$src2)>;
4781 def : Pat<(sub GR16:$src1, (loadi16 addr:$src2)),
4782 (SUB16rm GR16:$src1, addr:$src2)>;
4783 def : Pat<(sub GR32:$src1, (loadi32 addr:$src2)),
4784 (SUB32rm GR32:$src1, addr:$src2)>;
4787 def : Pat<(sub GR8:$src1, imm:$src2),
4788 (SUB8ri GR8:$src1, imm:$src2)>;
4789 def : Pat<(sub GR16:$src1, imm:$src2),
4790 (SUB16ri GR16:$src1, imm:$src2)>;
4791 def : Pat<(sub GR32:$src1, imm:$src2),
4792 (SUB32ri GR32:$src1, imm:$src2)>;
4793 def : Pat<(sub GR16:$src1, i16immSExt8:$src2),
4794 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4795 def : Pat<(sub GR32:$src1, i32immSExt8:$src2),
4796 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4799 def : Pat<(mul GR16:$src1, GR16:$src2),
4800 (IMUL16rr GR16:$src1, GR16:$src2)>;
4801 def : Pat<(mul GR32:$src1, GR32:$src2),
4802 (IMUL32rr GR32:$src1, GR32:$src2)>;
4805 def : Pat<(mul GR16:$src1, (loadi16 addr:$src2)),
4806 (IMUL16rm GR16:$src1, addr:$src2)>;
4807 def : Pat<(mul GR32:$src1, (loadi32 addr:$src2)),
4808 (IMUL32rm GR32:$src1, addr:$src2)>;
4811 def : Pat<(mul GR16:$src1, imm:$src2),
4812 (IMUL16rri GR16:$src1, imm:$src2)>;
4813 def : Pat<(mul GR32:$src1, imm:$src2),
4814 (IMUL32rri GR32:$src1, imm:$src2)>;
4815 def : Pat<(mul GR16:$src1, i16immSExt8:$src2),
4816 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4817 def : Pat<(mul GR32:$src1, i32immSExt8:$src2),
4818 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4820 // reg = mul mem, imm
4821 def : Pat<(mul (loadi16 addr:$src1), imm:$src2),
4822 (IMUL16rmi addr:$src1, imm:$src2)>;
4823 def : Pat<(mul (loadi32 addr:$src1), imm:$src2),
4824 (IMUL32rmi addr:$src1, imm:$src2)>;
4825 def : Pat<(mul (loadi16 addr:$src1), i16immSExt8:$src2),
4826 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4827 def : Pat<(mul (loadi32 addr:$src1), i32immSExt8:$src2),
4828 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4830 // Optimize multiply by 2 with EFLAGS result.
4831 let AddedComplexity = 2 in {
4832 def : Pat<(X86smul_flag GR16:$src1, 2), (ADD16rr GR16:$src1, GR16:$src1)>;
4833 def : Pat<(X86smul_flag GR32:$src1, 2), (ADD32rr GR32:$src1, GR32:$src1)>;
4836 // Patterns for nodes that do not produce flags, for instructions that do.
4839 def : Pat<(add GR8:$src1 , 1), (INC8r GR8:$src1)>;
4840 def : Pat<(add GR16:$src1, 1), (INC16r GR16:$src1)>, Requires<[In32BitMode]>;
4841 def : Pat<(add GR32:$src1, 1), (INC32r GR32:$src1)>, Requires<[In32BitMode]>;
4844 def : Pat<(add GR8:$src1 , -1), (DEC8r GR8:$src1)>;
4845 def : Pat<(add GR16:$src1, -1), (DEC16r GR16:$src1)>, Requires<[In32BitMode]>;
4846 def : Pat<(add GR32:$src1, -1), (DEC32r GR32:$src1)>, Requires<[In32BitMode]>;
4849 def : Pat<(or GR8 :$src1, GR8 :$src2), (OR8rr GR8 :$src1, GR8 :$src2)>;
4850 def : Pat<(or GR16:$src1, GR16:$src2), (OR16rr GR16:$src1, GR16:$src2)>;
4851 def : Pat<(or GR32:$src1, GR32:$src2), (OR32rr GR32:$src1, GR32:$src2)>;
4854 def : Pat<(or GR8:$src1, (loadi8 addr:$src2)),
4855 (OR8rm GR8:$src1, addr:$src2)>;
4856 def : Pat<(or GR16:$src1, (loadi16 addr:$src2)),
4857 (OR16rm GR16:$src1, addr:$src2)>;
4858 def : Pat<(or GR32:$src1, (loadi32 addr:$src2)),
4859 (OR32rm GR32:$src1, addr:$src2)>;
4862 def : Pat<(or GR8:$src1 , imm:$src2), (OR8ri GR8 :$src1, imm:$src2)>;
4863 def : Pat<(or GR16:$src1, imm:$src2), (OR16ri GR16:$src1, imm:$src2)>;
4864 def : Pat<(or GR32:$src1, imm:$src2), (OR32ri GR32:$src1, imm:$src2)>;
4865 def : Pat<(or GR16:$src1, i16immSExt8:$src2),
4866 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4867 def : Pat<(or GR32:$src1, i32immSExt8:$src2),
4868 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4871 def : Pat<(xor GR8 :$src1, GR8 :$src2), (XOR8rr GR8 :$src1, GR8 :$src2)>;
4872 def : Pat<(xor GR16:$src1, GR16:$src2), (XOR16rr GR16:$src1, GR16:$src2)>;
4873 def : Pat<(xor GR32:$src1, GR32:$src2), (XOR32rr GR32:$src1, GR32:$src2)>;
4876 def : Pat<(xor GR8:$src1, (loadi8 addr:$src2)),
4877 (XOR8rm GR8:$src1, addr:$src2)>;
4878 def : Pat<(xor GR16:$src1, (loadi16 addr:$src2)),
4879 (XOR16rm GR16:$src1, addr:$src2)>;
4880 def : Pat<(xor GR32:$src1, (loadi32 addr:$src2)),
4881 (XOR32rm GR32:$src1, addr:$src2)>;
4884 def : Pat<(xor GR8:$src1, imm:$src2),
4885 (XOR8ri GR8:$src1, imm:$src2)>;
4886 def : Pat<(xor GR16:$src1, imm:$src2),
4887 (XOR16ri GR16:$src1, imm:$src2)>;
4888 def : Pat<(xor GR32:$src1, imm:$src2),
4889 (XOR32ri GR32:$src1, imm:$src2)>;
4890 def : Pat<(xor GR16:$src1, i16immSExt8:$src2),
4891 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4892 def : Pat<(xor GR32:$src1, i32immSExt8:$src2),
4893 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4896 def : Pat<(and GR8 :$src1, GR8 :$src2), (AND8rr GR8 :$src1, GR8 :$src2)>;
4897 def : Pat<(and GR16:$src1, GR16:$src2), (AND16rr GR16:$src1, GR16:$src2)>;
4898 def : Pat<(and GR32:$src1, GR32:$src2), (AND32rr GR32:$src1, GR32:$src2)>;
4901 def : Pat<(and GR8:$src1, (loadi8 addr:$src2)),
4902 (AND8rm GR8:$src1, addr:$src2)>;
4903 def : Pat<(and GR16:$src1, (loadi16 addr:$src2)),
4904 (AND16rm GR16:$src1, addr:$src2)>;
4905 def : Pat<(and GR32:$src1, (loadi32 addr:$src2)),
4906 (AND32rm GR32:$src1, addr:$src2)>;
4909 def : Pat<(and GR8:$src1, imm:$src2),
4910 (AND8ri GR8:$src1, imm:$src2)>;
4911 def : Pat<(and GR16:$src1, imm:$src2),
4912 (AND16ri GR16:$src1, imm:$src2)>;
4913 def : Pat<(and GR32:$src1, imm:$src2),
4914 (AND32ri GR32:$src1, imm:$src2)>;
4915 def : Pat<(and GR16:$src1, i16immSExt8:$src2),
4916 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
4917 def : Pat<(and GR32:$src1, i32immSExt8:$src2),
4918 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4920 //===----------------------------------------------------------------------===//
4921 // Floating Point Stack Support
4922 //===----------------------------------------------------------------------===//
4924 include "X86InstrFPStack.td"
4926 //===----------------------------------------------------------------------===//
4928 //===----------------------------------------------------------------------===//
4930 include "X86Instr64bit.td"
4932 //===----------------------------------------------------------------------===//
4933 // SIMD support (SSE, MMX and AVX)
4934 //===----------------------------------------------------------------------===//
4936 include "X86InstrFragmentsSIMD.td"
4938 //===----------------------------------------------------------------------===//
4939 // XMM Floating point support (requires SSE / SSE2)
4940 //===----------------------------------------------------------------------===//
4942 include "X86InstrSSE.td"
4944 //===----------------------------------------------------------------------===//
4945 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4946 //===----------------------------------------------------------------------===//
4948 include "X86InstrMMX.td"