1 //===- X86InstrInfo.td - Main X86 Instruction Definition ---*- tablegen -*-===//
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_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
79 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
81 def SDT_X86MEMBARRIER : SDTypeProfile<0, 0, []>;
82 def SDT_X86MEMBARRIERNoSSE : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
84 def X86MemBarrier : SDNode<"X86ISD::MEMBARRIER", SDT_X86MEMBARRIER,
86 def X86MemBarrierNoSSE : SDNode<"X86ISD::MEMBARRIER", SDT_X86MEMBARRIERNoSSE,
88 def X86MFence : SDNode<"X86ISD::MFENCE", SDT_X86MEMBARRIER,
90 def X86SFence : SDNode<"X86ISD::SFENCE", SDT_X86MEMBARRIER,
92 def X86LFence : SDNode<"X86ISD::LFENCE", SDT_X86MEMBARRIER,
96 def X86bsf : SDNode<"X86ISD::BSF", SDTUnaryArithWithFlags>;
97 def X86bsr : SDNode<"X86ISD::BSR", SDTUnaryArithWithFlags>;
98 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
99 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
101 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
102 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
104 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
105 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
107 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
108 def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
110 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
111 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
113 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
114 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
115 SDNPMayLoad, SDNPMemOperand]>;
116 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
117 [SDNPHasChain, SDNPMayStore,
118 SDNPMayLoad, SDNPMemOperand]>;
119 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
120 [SDNPHasChain, SDNPMayStore,
121 SDNPMayLoad, SDNPMemOperand]>;
122 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
123 [SDNPHasChain, SDNPMayStore,
124 SDNPMayLoad, SDNPMemOperand]>;
125 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
126 [SDNPHasChain, SDNPMayStore,
127 SDNPMayLoad, SDNPMemOperand]>;
128 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
129 [SDNPHasChain, SDNPMayStore,
130 SDNPMayLoad, SDNPMemOperand]>;
131 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
132 [SDNPHasChain, SDNPMayStore,
133 SDNPMayLoad, SDNPMemOperand]>;
134 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
135 [SDNPHasChain, SDNPMayStore,
136 SDNPMayLoad, SDNPMemOperand]>;
137 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
138 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
140 def X86vastart_save_xmm_regs :
141 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
142 SDT_X86VASTART_SAVE_XMM_REGS,
143 [SDNPHasChain, SDNPVariadic]>;
145 def X86callseq_start :
146 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
147 [SDNPHasChain, SDNPOutFlag]>;
149 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
150 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
152 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
153 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag,
156 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
157 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
158 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
159 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
162 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
163 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
165 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
166 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
168 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
169 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
171 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
174 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
175 [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>;
177 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
179 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
180 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
182 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
185 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
186 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
187 def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
189 def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
191 def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
194 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
196 def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
197 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
199 def X86TLSCall : SDNode<"X86ISD::TLSCALL", SDT_X86TLSCALL,
202 //===----------------------------------------------------------------------===//
203 // X86 Operand Definitions.
206 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
207 // the index operand of an address, to conform to x86 encoding restrictions.
208 def ptr_rc_nosp : PointerLikeRegClass<1>;
210 // *mem - Operand definitions for the funky X86 addressing mode operands.
212 def X86MemAsmOperand : AsmOperandClass {
214 let SuperClasses = [];
216 def X86AbsMemAsmOperand : AsmOperandClass {
218 let SuperClasses = [X86MemAsmOperand];
220 class X86MemOperand<string printMethod> : Operand<iPTR> {
221 let PrintMethod = printMethod;
222 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
223 let ParserMatchClass = X86MemAsmOperand;
226 def opaque32mem : X86MemOperand<"printopaquemem">;
227 def opaque48mem : X86MemOperand<"printopaquemem">;
228 def opaque80mem : X86MemOperand<"printopaquemem">;
229 def opaque512mem : X86MemOperand<"printopaquemem">;
231 def i8mem : X86MemOperand<"printi8mem">;
232 def i16mem : X86MemOperand<"printi16mem">;
233 def i32mem : X86MemOperand<"printi32mem">;
234 def i64mem : X86MemOperand<"printi64mem">;
235 def i128mem : X86MemOperand<"printi128mem">;
236 def i256mem : X86MemOperand<"printi256mem">;
237 def f32mem : X86MemOperand<"printf32mem">;
238 def f64mem : X86MemOperand<"printf64mem">;
239 def f80mem : X86MemOperand<"printf80mem">;
240 def f128mem : X86MemOperand<"printf128mem">;
241 def f256mem : X86MemOperand<"printf256mem">;
243 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
244 // plain GR64, so that it doesn't potentially require a REX prefix.
245 def i8mem_NOREX : Operand<i64> {
246 let PrintMethod = "printi8mem";
247 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
248 let ParserMatchClass = X86MemAsmOperand;
251 // Special i32mem for addresses of load folding tail calls. These are not
252 // allowed to use callee-saved registers since they must be scheduled
253 // after callee-saved register are popped.
254 def i32mem_TC : Operand<i32> {
255 let PrintMethod = "printi32mem";
256 let MIOperandInfo = (ops GR32_TC, i8imm, GR32_TC, i32imm, i8imm);
257 let ParserMatchClass = X86MemAsmOperand;
260 // Special i64mem for addresses of load folding tail calls. These are not
261 // allowed to use callee-saved registers since they must be scheduled
262 // after callee-saved register are popped.
263 def i64mem_TC : Operand<i64> {
264 let PrintMethod = "printi64mem";
265 let MIOperandInfo = (ops GR64_TC, i8imm, GR64_TC, i32imm, i8imm);
266 let ParserMatchClass = X86MemAsmOperand;
269 let ParserMatchClass = X86AbsMemAsmOperand,
270 PrintMethod = "print_pcrel_imm" in {
271 def i32imm_pcrel : Operand<i32>;
272 def i16imm_pcrel : Operand<i16>;
274 def offset8 : Operand<i64>;
275 def offset16 : Operand<i64>;
276 def offset32 : Operand<i64>;
277 def offset64 : Operand<i64>;
279 // Branch targets have OtherVT type and print as pc-relative values.
280 def brtarget : Operand<OtherVT>;
281 def brtarget8 : Operand<OtherVT>;
285 def SSECC : Operand<i8> {
286 let PrintMethod = "printSSECC";
289 class ImmSExtAsmOperandClass : AsmOperandClass {
290 let SuperClasses = [ImmAsmOperand];
291 let RenderMethod = "addImmOperands";
294 // Sign-extended immediate classes. We don't need to define the full lattice
295 // here because there is no instruction with an ambiguity between ImmSExti64i32
298 // The strange ranges come from the fact that the assembler always works with
299 // 64-bit immediates, but for a 16-bit target value we want to accept both "-1"
300 // (which will be a -1ULL), and "0xFF" (-1 in 16-bits).
303 // [0xFFFFFFFF80000000, 0xFFFFFFFFFFFFFFFF]
304 def ImmSExti64i32AsmOperand : ImmSExtAsmOperandClass {
305 let Name = "ImmSExti64i32";
308 // [0, 0x0000007F] | [0x000000000000FF80, 0x000000000000FFFF] |
309 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
310 def ImmSExti16i8AsmOperand : ImmSExtAsmOperandClass {
311 let Name = "ImmSExti16i8";
312 let SuperClasses = [ImmSExti64i32AsmOperand];
315 // [0, 0x0000007F] | [0x00000000FFFFFF80, 0x00000000FFFFFFFF] |
316 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
317 def ImmSExti32i8AsmOperand : ImmSExtAsmOperandClass {
318 let Name = "ImmSExti32i8";
322 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
323 def ImmSExti64i8AsmOperand : ImmSExtAsmOperandClass {
324 let Name = "ImmSExti64i8";
325 let SuperClasses = [ImmSExti16i8AsmOperand, ImmSExti32i8AsmOperand,
326 ImmSExti64i32AsmOperand];
329 // A couple of more descriptive operand definitions.
330 // 16-bits but only 8 bits are significant.
331 def i16i8imm : Operand<i16> {
332 let ParserMatchClass = ImmSExti16i8AsmOperand;
334 // 32-bits but only 8 bits are significant.
335 def i32i8imm : Operand<i32> {
336 let ParserMatchClass = ImmSExti32i8AsmOperand;
339 // 64-bits but only 32 bits are significant.
340 def i64i32imm : Operand<i64> {
341 let ParserMatchClass = ImmSExti64i32AsmOperand;
344 // 64-bits but only 32 bits are significant, and those bits are treated as being
346 def i64i32imm_pcrel : Operand<i64> {
347 let PrintMethod = "print_pcrel_imm";
348 let ParserMatchClass = X86AbsMemAsmOperand;
351 // 64-bits but only 8 bits are significant.
352 def i64i8imm : Operand<i64> {
353 let ParserMatchClass = ImmSExti64i8AsmOperand;
356 def lea64_32mem : Operand<i32> {
357 let PrintMethod = "printi32mem";
358 let AsmOperandLowerMethod = "lower_lea64_32mem";
359 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm, i8imm);
360 let ParserMatchClass = X86MemAsmOperand;
364 //===----------------------------------------------------------------------===//
365 // X86 Complex Pattern Definitions.
368 // Define X86 specific addressing mode.
369 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], [SDNPWantParent]>;
370 def lea32addr : ComplexPattern<i32, 5, "SelectLEAAddr",
371 [add, sub, mul, X86mul_imm, shl, or, frameindex],
373 def tls32addr : ComplexPattern<i32, 5, "SelectTLSADDRAddr",
374 [tglobaltlsaddr], []>;
376 def lea64addr : ComplexPattern<i64, 5, "SelectLEAAddr",
377 [add, sub, mul, X86mul_imm, shl, or, frameindex,
380 def tls64addr : ComplexPattern<i64, 5, "SelectTLSADDRAddr",
381 [tglobaltlsaddr], []>;
383 //===----------------------------------------------------------------------===//
384 // X86 Instruction Predicate Definitions.
385 def HasCMov : Predicate<"Subtarget->hasCMov()">;
386 def NoCMov : Predicate<"!Subtarget->hasCMov()">;
388 // FIXME: temporary hack to let codegen assert or generate poor code in case
389 // no AVX version of the desired intructions is present, this is better for
390 // incremental dev (without fallbacks it's easier to spot what's missing)
391 def HasMMX : Predicate<"Subtarget->hasMMX() && !Subtarget->hasAVX()">;
392 def Has3DNow : Predicate<"Subtarget->has3DNow()">;
393 def Has3DNowA : Predicate<"Subtarget->has3DNowA()">;
394 def HasSSE1 : Predicate<"Subtarget->hasSSE1() && !Subtarget->hasAVX()">;
395 def HasSSE2 : Predicate<"Subtarget->hasSSE2() && !Subtarget->hasAVX()">;
396 def HasSSE3 : Predicate<"Subtarget->hasSSE3() && !Subtarget->hasAVX()">;
397 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3() && !Subtarget->hasAVX()">;
398 def HasSSE41 : Predicate<"Subtarget->hasSSE41() && !Subtarget->hasAVX()">;
399 def HasSSE42 : Predicate<"Subtarget->hasSSE42() && !Subtarget->hasAVX()">;
400 def HasSSE4A : Predicate<"Subtarget->hasSSE4A() && !Subtarget->hasAVX()">;
402 def HasAVX : Predicate<"Subtarget->hasAVX()">;
403 def HasCLMUL : Predicate<"Subtarget->hasCLMUL()">;
404 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
405 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
406 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
407 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
408 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
409 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
410 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
411 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
412 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
413 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
414 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
415 "TM.getCodeModel() != CodeModel::Kernel">;
416 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
417 "TM.getCodeModel() == CodeModel::Kernel">;
418 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
419 def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
420 def OptForSize : Predicate<"OptForSize">;
421 def OptForSpeed : Predicate<"!OptForSize">;
422 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
423 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
424 def HasAES : Predicate<"Subtarget->hasAES()">;
426 //===----------------------------------------------------------------------===//
427 // X86 Instruction Format Definitions.
430 include "X86InstrFormats.td"
432 //===----------------------------------------------------------------------===//
433 // Pattern fragments...
436 // X86 specific condition code. These correspond to CondCode in
437 // X86InstrInfo.h. They must be kept in synch.
438 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
439 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
440 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
441 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
442 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
443 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
444 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
445 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
446 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
447 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
448 def X86_COND_NO : PatLeaf<(i8 10)>;
449 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
450 def X86_COND_NS : PatLeaf<(i8 12)>;
451 def X86_COND_O : PatLeaf<(i8 13)>;
452 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
453 def X86_COND_S : PatLeaf<(i8 15)>;
455 def immSext8 : PatLeaf<(imm), [{ return immSext8(N); }]>;
457 def i16immSExt8 : PatLeaf<(i16 immSext8)>;
458 def i32immSExt8 : PatLeaf<(i32 immSext8)>;
459 def i64immSExt8 : PatLeaf<(i64 immSext8)>;
460 def i64immSExt32 : PatLeaf<(i64 imm), [{ return i64immSExt32(N); }]>;
461 def i64immZExt32 : PatLeaf<(i64 imm), [{
462 // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit
463 // unsignedsign extended field.
464 return (uint64_t)N->getZExtValue() == (uint32_t)N->getZExtValue();
467 // Helper fragments for loads.
468 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
469 // known to be 32-bit aligned or better. Ditto for i8 to i16.
470 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
471 LoadSDNode *LD = cast<LoadSDNode>(N);
472 ISD::LoadExtType ExtType = LD->getExtensionType();
473 if (ExtType == ISD::NON_EXTLOAD)
475 if (ExtType == ISD::EXTLOAD)
476 return LD->getAlignment() >= 2 && !LD->isVolatile();
480 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
481 LoadSDNode *LD = cast<LoadSDNode>(N);
482 ISD::LoadExtType ExtType = LD->getExtensionType();
483 if (ExtType == ISD::EXTLOAD)
484 return LD->getAlignment() >= 2 && !LD->isVolatile();
488 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
489 LoadSDNode *LD = cast<LoadSDNode>(N);
490 ISD::LoadExtType ExtType = LD->getExtensionType();
491 if (ExtType == ISD::NON_EXTLOAD)
493 if (ExtType == ISD::EXTLOAD)
494 return LD->getAlignment() >= 4 && !LD->isVolatile();
498 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
499 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
500 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
501 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
502 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
504 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
505 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
506 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
507 def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>;
508 def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>;
509 def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>;
511 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
512 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
513 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
514 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
515 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
516 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
517 def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>;
518 def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>;
519 def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>;
520 def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>;
522 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
523 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
524 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
525 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
526 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
527 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
528 def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>;
529 def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>;
530 def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>;
531 def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>;
534 // An 'and' node with a single use.
535 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
536 return N->hasOneUse();
538 // An 'srl' node with a single use.
539 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
540 return N->hasOneUse();
542 // An 'trunc' node with a single use.
543 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
544 return N->hasOneUse();
547 // Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
548 def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
549 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
550 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
552 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
553 APInt Mask = APInt::getAllOnesValue(BitWidth);
554 APInt KnownZero0, KnownOne0;
555 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
556 APInt KnownZero1, KnownOne1;
557 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
558 return (~KnownZero0 & ~KnownZero1) == 0;
561 //===----------------------------------------------------------------------===//
566 let neverHasSideEffects = 1 in {
567 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
568 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
569 "nop{w}\t$zero", []>, TB, OpSize;
570 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
571 "nop{l}\t$zero", []>, TB;
575 // Constructing a stack frame.
576 def ENTER : Ii16<0xC8, RawFrmImm8, (outs), (ins i16imm:$len, i8imm:$lvl),
577 "enter\t$len, $lvl", []>;
579 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
580 def LEAVE : I<0xC9, RawFrm,
581 (outs), (ins), "leave", []>, Requires<[In32BitMode]>;
583 //===----------------------------------------------------------------------===//
584 // Miscellaneous Instructions...
586 def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
587 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
589 def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
590 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
591 def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
592 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
594 def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
595 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
597 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
599 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
601 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
602 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
604 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
606 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
607 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
610 let mayStore = 1 in {
611 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
613 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
614 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
616 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
618 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
619 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
623 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
624 def PUSHi8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
625 "push{l}\t$imm", []>;
626 def PUSHi16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
627 "push{w}\t$imm", []>, OpSize;
628 def PUSHi32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
629 "push{l}\t$imm", []>;
632 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
633 def POPF16 : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
634 def POPF32 : I<0x9D, RawFrm, (outs), (ins), "popf{l|d}", []>,
635 Requires<[In32BitMode]>;
637 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
638 def PUSHF16 : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
639 def PUSHF32 : I<0x9C, RawFrm, (outs), (ins), "pushf{l|d}", []>,
640 Requires<[In32BitMode]>;
643 let Defs = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], Uses = [ESP],
644 mayLoad=1, neverHasSideEffects=1 in {
645 def POPA32 : I<0x61, RawFrm, (outs), (ins), "popa{l}", []>,
646 Requires<[In32BitMode]>;
648 let Defs = [ESP], Uses = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP],
649 mayStore=1, neverHasSideEffects=1 in {
650 def PUSHA32 : I<0x60, RawFrm, (outs), (ins), "pusha{l}", []>,
651 Requires<[In32BitMode]>;
654 let Uses = [EFLAGS], Constraints = "$src = $dst" in // GR32 = bswap GR32
655 def BSWAP32r : I<0xC8, AddRegFrm,
656 (outs GR32:$dst), (ins GR32:$src),
658 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
661 // Bit scan instructions.
662 let Defs = [EFLAGS] in {
663 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
664 "bsf{w}\t{$src, $dst|$dst, $src}",
665 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB, OpSize;
666 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
667 "bsf{w}\t{$src, $dst|$dst, $src}",
668 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB,
670 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
671 "bsf{l}\t{$src, $dst|$dst, $src}",
672 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
673 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
674 "bsf{l}\t{$src, $dst|$dst, $src}",
675 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
677 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
678 "bsr{w}\t{$src, $dst|$dst, $src}",
679 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB, OpSize;
680 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
681 "bsr{w}\t{$src, $dst|$dst, $src}",
682 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB,
684 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
685 "bsr{l}\t{$src, $dst|$dst, $src}",
686 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
687 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
688 "bsr{l}\t{$src, $dst|$dst, $src}",
689 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
692 let neverHasSideEffects = 1 in
693 def LEA16r : I<0x8D, MRMSrcMem,
694 (outs GR16:$dst), (ins i32mem:$src),
695 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
696 let isReMaterializable = 1 in
697 def LEA32r : I<0x8D, MRMSrcMem,
698 (outs GR32:$dst), (ins i32mem:$src),
699 "lea{l}\t{$src|$dst}, {$dst|$src}",
700 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
703 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
704 let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
705 def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
706 def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
707 def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
708 def MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "movsq", []>;
711 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
712 let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
713 def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
714 let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
715 def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
716 let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
717 def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
718 let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI,EFLAGS] in
719 def STOSQ : RI<0xAB, RawFrm, (outs), (ins), "stosq", []>;
721 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
722 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
723 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
724 def SCAS64 : RI<0xAF, RawFrm, (outs), (ins), "scasq", []>;
726 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
727 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
728 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
729 def CMPS64 : RI<0xA7, RawFrm, (outs), (ins), "cmpsq", []>;
732 //===----------------------------------------------------------------------===//
733 // Move Instructions.
735 let neverHasSideEffects = 1 in {
736 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
737 "mov{b}\t{$src, $dst|$dst, $src}", []>;
738 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
739 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
740 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
741 "mov{l}\t{$src, $dst|$dst, $src}", []>;
743 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
744 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
745 "mov{b}\t{$src, $dst|$dst, $src}",
746 [(set GR8:$dst, imm:$src)]>;
747 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
748 "mov{w}\t{$src, $dst|$dst, $src}",
749 [(set GR16:$dst, imm:$src)]>, OpSize;
750 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
751 "mov{l}\t{$src, $dst|$dst, $src}",
752 [(set GR32:$dst, imm:$src)]>;
755 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
756 "mov{b}\t{$src, $dst|$dst, $src}",
757 [(store (i8 imm:$src), addr:$dst)]>;
758 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
759 "mov{w}\t{$src, $dst|$dst, $src}",
760 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
761 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
762 "mov{l}\t{$src, $dst|$dst, $src}",
763 [(store (i32 imm:$src), addr:$dst)]>;
765 /// moffs8, moffs16 and moffs32 versions of moves. The immediate is a
766 /// 32-bit offset from the PC. These are only valid in x86-32 mode.
767 def MOV8o8a : Ii32 <0xA0, RawFrm, (outs), (ins offset8:$src),
768 "mov{b}\t{$src, %al|%al, $src}", []>,
769 Requires<[In32BitMode]>;
770 def MOV16o16a : Ii32 <0xA1, RawFrm, (outs), (ins offset16:$src),
771 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize,
772 Requires<[In32BitMode]>;
773 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
774 "mov{l}\t{$src, %eax|%eax, $src}", []>,
775 Requires<[In32BitMode]>;
776 def MOV8ao8 : Ii32 <0xA2, RawFrm, (outs offset8:$dst), (ins),
777 "mov{b}\t{%al, $dst|$dst, %al}", []>,
778 Requires<[In32BitMode]>;
779 def MOV16ao16 : Ii32 <0xA3, RawFrm, (outs offset16:$dst), (ins),
780 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize,
781 Requires<[In32BitMode]>;
782 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
783 "mov{l}\t{%eax, $dst|$dst, %eax}", []>,
784 Requires<[In32BitMode]>;
787 let isCodeGenOnly = 1 in {
788 def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
789 "mov{b}\t{$src, $dst|$dst, $src}", []>;
790 def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
791 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
792 def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
793 "mov{l}\t{$src, $dst|$dst, $src}", []>;
796 let canFoldAsLoad = 1, isReMaterializable = 1 in {
797 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
798 "mov{b}\t{$src, $dst|$dst, $src}",
799 [(set GR8:$dst, (loadi8 addr:$src))]>;
800 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
801 "mov{w}\t{$src, $dst|$dst, $src}",
802 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
803 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
804 "mov{l}\t{$src, $dst|$dst, $src}",
805 [(set GR32:$dst, (loadi32 addr:$src))]>;
808 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
809 "mov{b}\t{$src, $dst|$dst, $src}",
810 [(store GR8:$src, addr:$dst)]>;
811 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
812 "mov{w}\t{$src, $dst|$dst, $src}",
813 [(store GR16:$src, addr:$dst)]>, OpSize;
814 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
815 "mov{l}\t{$src, $dst|$dst, $src}",
816 [(store GR32:$src, addr:$dst)]>;
818 /// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
819 let isCodeGenOnly = 1 in {
820 let neverHasSideEffects = 1 in
821 def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
822 "mov{l}\t{$src, $dst|$dst, $src}", []>;
825 canFoldAsLoad = 1, isReMaterializable = 1 in
826 def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
827 "mov{l}\t{$src, $dst|$dst, $src}",
831 def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
832 "mov{l}\t{$src, $dst|$dst, $src}",
836 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
837 // that they can be used for copying and storing h registers, which can't be
838 // encoded when a REX prefix is present.
839 let isCodeGenOnly = 1 in {
840 let neverHasSideEffects = 1 in
841 def MOV8rr_NOREX : I<0x88, MRMDestReg,
842 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
843 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
845 def MOV8mr_NOREX : I<0x88, MRMDestMem,
846 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
847 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
849 canFoldAsLoad = 1, isReMaterializable = 1 in
850 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
851 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
852 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
855 //===----------------------------------------------------------------------===//
856 // Fixed-Register Multiplication and Division Instructions...
859 // Extra precision multiplication
861 // AL is really implied by AX, but the registers in Defs must match the
862 // SDNode results (i8, i32).
863 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
864 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
865 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
866 // This probably ought to be moved to a def : Pat<> if the
867 // syntax can be accepted.
868 [(set AL, (mul AL, GR8:$src)),
869 (implicit EFLAGS)]>; // AL,AH = AL*GR8
871 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
872 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
874 []>, OpSize; // AX,DX = AX*GR16
876 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
877 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
879 []>; // EAX,EDX = EAX*GR32
881 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
882 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
884 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
885 // This probably ought to be moved to a def : Pat<> if the
886 // syntax can be accepted.
887 [(set AL, (mul AL, (loadi8 addr:$src))),
888 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
890 let mayLoad = 1, neverHasSideEffects = 1 in {
891 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
892 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
894 []>, OpSize; // AX,DX = AX*[mem16]
896 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
897 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
899 []>; // EAX,EDX = EAX*[mem32]
902 let neverHasSideEffects = 1 in {
903 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
904 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
906 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
907 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
908 OpSize; // AX,DX = AX*GR16
909 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
910 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
911 // EAX,EDX = EAX*GR32
913 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
914 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
915 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
916 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
917 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
918 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
919 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
920 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
921 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
923 } // neverHasSideEffects
925 // unsigned division/remainder
926 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
927 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
929 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
930 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
931 "div{w}\t$src", []>, OpSize;
932 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
933 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
936 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
937 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
939 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
940 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
941 "div{w}\t$src", []>, OpSize;
942 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
943 // EDX:EAX/[mem32] = EAX,EDX
944 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
948 // Signed division/remainder.
949 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
950 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
951 "idiv{b}\t$src", []>;
952 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
953 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
954 "idiv{w}\t$src", []>, OpSize;
955 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
956 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
957 "idiv{l}\t$src", []>;
958 let mayLoad = 1, mayLoad = 1 in {
959 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
960 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
961 "idiv{b}\t$src", []>;
962 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
963 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
964 "idiv{w}\t$src", []>, OpSize;
965 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
966 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
967 // EDX:EAX/[mem32] = EAX,EDX
968 "idiv{l}\t$src", []>;
971 //===----------------------------------------------------------------------===//
972 // Two address Instructions.
974 let Constraints = "$src1 = $dst" in {
976 // unary instructions
977 let CodeSize = 2 in {
978 let Defs = [EFLAGS] in {
979 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src1),
981 [(set GR8:$dst, (ineg GR8:$src1)),
983 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
985 [(set GR16:$dst, (ineg GR16:$src1)),
986 (implicit EFLAGS)]>, OpSize;
987 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
989 [(set GR32:$dst, (ineg GR32:$src1)),
992 let Constraints = "" in {
993 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst),
995 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
997 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst),
999 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1000 (implicit EFLAGS)]>, OpSize;
1001 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst),
1003 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1004 (implicit EFLAGS)]>;
1005 } // Constraints = ""
1006 } // Defs = [EFLAGS]
1008 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1009 let AddedComplexity = 15 in {
1010 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src1),
1012 [(set GR8:$dst, (not GR8:$src1))]>;
1013 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
1015 [(set GR16:$dst, (not GR16:$src1))]>, OpSize;
1016 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
1018 [(set GR32:$dst, (not GR32:$src1))]>;
1020 let Constraints = "" in {
1021 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst),
1023 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1024 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst),
1026 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1027 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst),
1029 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1030 } // Constraints = ""
1033 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1034 let Defs = [EFLAGS] in {
1036 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1038 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src1))]>;
1040 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1041 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1043 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src1))]>,
1044 OpSize, Requires<[In32BitMode]>;
1045 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1047 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src1))]>,
1048 Requires<[In32BitMode]>;
1050 let Constraints = "", CodeSize = 2 in {
1051 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1052 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1053 (implicit EFLAGS)]>;
1054 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1055 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1056 (implicit EFLAGS)]>,
1057 OpSize, Requires<[In32BitMode]>;
1058 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1059 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1060 (implicit EFLAGS)]>,
1061 Requires<[In32BitMode]>;
1062 } // Constraints = "", CodeSize = 2
1065 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1067 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src1))]>;
1068 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1069 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1071 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src1))]>,
1072 OpSize, Requires<[In32BitMode]>;
1073 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1075 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src1))]>,
1076 Requires<[In32BitMode]>;
1079 let Constraints = "", CodeSize = 2 in {
1080 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1081 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1082 (implicit EFLAGS)]>;
1083 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1084 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1085 (implicit EFLAGS)]>,
1086 OpSize, Requires<[In32BitMode]>;
1087 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1088 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1089 (implicit EFLAGS)]>,
1090 Requires<[In32BitMode]>;
1091 } // Constraints = "", CodeSize = 2
1092 } // Defs = [EFLAGS]
1094 // Logical operators...
1095 let Defs = [EFLAGS] in {
1096 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1097 def AND8rr : I<0x20, MRMDestReg,
1098 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1099 "and{b}\t{$src2, $dst|$dst, $src2}",
1100 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1101 def AND16rr : I<0x21, MRMDestReg,
1102 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1103 "and{w}\t{$src2, $dst|$dst, $src2}",
1104 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1105 GR16:$src2))]>, OpSize;
1106 def AND32rr : I<0x21, MRMDestReg,
1107 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1108 "and{l}\t{$src2, $dst|$dst, $src2}",
1109 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1113 // AND instructions with the destination register in REG and the source register
1114 // in R/M. Included for the disassembler.
1115 let isCodeGenOnly = 1 in {
1116 def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1117 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1118 def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1119 (ins GR16:$src1, GR16:$src2),
1120 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1121 def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1122 (ins GR32:$src1, GR32:$src2),
1123 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1126 def AND8rm : I<0x22, MRMSrcMem,
1127 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1128 "and{b}\t{$src2, $dst|$dst, $src2}",
1129 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1130 (loadi8 addr:$src2)))]>;
1131 def AND16rm : I<0x23, MRMSrcMem,
1132 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1133 "and{w}\t{$src2, $dst|$dst, $src2}",
1134 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1135 (loadi16 addr:$src2)))]>,
1137 def AND32rm : I<0x23, MRMSrcMem,
1138 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1139 "and{l}\t{$src2, $dst|$dst, $src2}",
1140 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1141 (loadi32 addr:$src2)))]>;
1143 def AND8ri : Ii8<0x80, MRM4r,
1144 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1145 "and{b}\t{$src2, $dst|$dst, $src2}",
1146 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1148 def AND16ri : Ii16<0x81, MRM4r,
1149 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1150 "and{w}\t{$src2, $dst|$dst, $src2}",
1151 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1152 imm:$src2))]>, OpSize;
1153 def AND32ri : Ii32<0x81, MRM4r,
1154 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1155 "and{l}\t{$src2, $dst|$dst, $src2}",
1156 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1158 def AND16ri8 : Ii8<0x83, MRM4r,
1159 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1160 "and{w}\t{$src2, $dst|$dst, $src2}",
1161 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1162 i16immSExt8:$src2))]>,
1164 def AND32ri8 : Ii8<0x83, MRM4r,
1165 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1166 "and{l}\t{$src2, $dst|$dst, $src2}",
1167 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1168 i32immSExt8:$src2))]>;
1170 let Constraints = "" in {
1171 def AND8mr : I<0x20, MRMDestMem,
1172 (outs), (ins i8mem :$dst, GR8 :$src),
1173 "and{b}\t{$src, $dst|$dst, $src}",
1174 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1175 (implicit EFLAGS)]>;
1176 def AND16mr : I<0x21, MRMDestMem,
1177 (outs), (ins i16mem:$dst, GR16:$src),
1178 "and{w}\t{$src, $dst|$dst, $src}",
1179 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1180 (implicit EFLAGS)]>,
1182 def AND32mr : I<0x21, MRMDestMem,
1183 (outs), (ins i32mem:$dst, GR32:$src),
1184 "and{l}\t{$src, $dst|$dst, $src}",
1185 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1186 (implicit EFLAGS)]>;
1187 def AND8mi : Ii8<0x80, MRM4m,
1188 (outs), (ins i8mem :$dst, i8imm :$src),
1189 "and{b}\t{$src, $dst|$dst, $src}",
1190 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1191 (implicit EFLAGS)]>;
1192 def AND16mi : Ii16<0x81, MRM4m,
1193 (outs), (ins i16mem:$dst, i16imm:$src),
1194 "and{w}\t{$src, $dst|$dst, $src}",
1195 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1196 (implicit EFLAGS)]>,
1198 def AND32mi : Ii32<0x81, MRM4m,
1199 (outs), (ins i32mem:$dst, i32imm:$src),
1200 "and{l}\t{$src, $dst|$dst, $src}",
1201 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1202 (implicit EFLAGS)]>;
1203 def AND16mi8 : Ii8<0x83, MRM4m,
1204 (outs), (ins i16mem:$dst, i16i8imm :$src),
1205 "and{w}\t{$src, $dst|$dst, $src}",
1206 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1207 (implicit EFLAGS)]>,
1209 def AND32mi8 : Ii8<0x83, MRM4m,
1210 (outs), (ins i32mem:$dst, i32i8imm :$src),
1211 "and{l}\t{$src, $dst|$dst, $src}",
1212 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1213 (implicit EFLAGS)]>;
1215 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1216 "and{b}\t{$src, %al|%al, $src}", []>;
1217 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1218 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1219 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1220 "and{l}\t{$src, %eax|%eax, $src}", []>;
1222 } // Constraints = ""
1225 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1226 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1227 (ins GR8 :$src1, GR8 :$src2),
1228 "or{b}\t{$src2, $dst|$dst, $src2}",
1229 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
1230 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1231 (ins GR16:$src1, GR16:$src2),
1232 "or{w}\t{$src2, $dst|$dst, $src2}",
1233 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1235 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1236 (ins GR32:$src1, GR32:$src2),
1237 "or{l}\t{$src2, $dst|$dst, $src2}",
1238 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
1241 // OR instructions with the destination register in REG and the source register
1242 // in R/M. Included for the disassembler.
1243 let isCodeGenOnly = 1 in {
1244 def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1245 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1246 def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1247 (ins GR16:$src1, GR16:$src2),
1248 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1249 def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1250 (ins GR32:$src1, GR32:$src2),
1251 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1254 def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
1255 (ins GR8 :$src1, i8mem :$src2),
1256 "or{b}\t{$src2, $dst|$dst, $src2}",
1257 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
1258 (load addr:$src2)))]>;
1259 def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
1260 (ins GR16:$src1, i16mem:$src2),
1261 "or{w}\t{$src2, $dst|$dst, $src2}",
1262 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1263 (load addr:$src2)))]>,
1265 def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
1266 (ins GR32:$src1, i32mem:$src2),
1267 "or{l}\t{$src2, $dst|$dst, $src2}",
1268 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1269 (load addr:$src2)))]>;
1271 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1272 (ins GR8 :$src1, i8imm:$src2),
1273 "or{b}\t{$src2, $dst|$dst, $src2}",
1274 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
1275 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1276 (ins GR16:$src1, i16imm:$src2),
1277 "or{w}\t{$src2, $dst|$dst, $src2}",
1278 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1279 imm:$src2))]>, OpSize;
1280 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1281 (ins GR32:$src1, i32imm:$src2),
1282 "or{l}\t{$src2, $dst|$dst, $src2}",
1283 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1286 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1287 (ins GR16:$src1, i16i8imm:$src2),
1288 "or{w}\t{$src2, $dst|$dst, $src2}",
1289 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1290 i16immSExt8:$src2))]>, OpSize;
1291 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1292 (ins GR32:$src1, i32i8imm:$src2),
1293 "or{l}\t{$src2, $dst|$dst, $src2}",
1294 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1295 i32immSExt8:$src2))]>;
1296 let Constraints = "" in {
1297 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1298 "or{b}\t{$src, $dst|$dst, $src}",
1299 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1300 (implicit EFLAGS)]>;
1301 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1302 "or{w}\t{$src, $dst|$dst, $src}",
1303 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1304 (implicit EFLAGS)]>, OpSize;
1305 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1306 "or{l}\t{$src, $dst|$dst, $src}",
1307 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1308 (implicit EFLAGS)]>;
1309 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1310 "or{b}\t{$src, $dst|$dst, $src}",
1311 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1312 (implicit EFLAGS)]>;
1313 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1314 "or{w}\t{$src, $dst|$dst, $src}",
1315 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1316 (implicit EFLAGS)]>,
1318 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1319 "or{l}\t{$src, $dst|$dst, $src}",
1320 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1321 (implicit EFLAGS)]>;
1322 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1323 "or{w}\t{$src, $dst|$dst, $src}",
1324 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1325 (implicit EFLAGS)]>,
1327 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1328 "or{l}\t{$src, $dst|$dst, $src}",
1329 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1330 (implicit EFLAGS)]>;
1332 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1333 "or{b}\t{$src, %al|%al, $src}", []>;
1334 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1335 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1336 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1337 "or{l}\t{$src, %eax|%eax, $src}", []>;
1338 } // Constraints = ""
1341 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1342 def XOR8rr : I<0x30, MRMDestReg,
1343 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1344 "xor{b}\t{$src2, $dst|$dst, $src2}",
1345 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
1347 def XOR16rr : I<0x31, MRMDestReg,
1348 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1349 "xor{w}\t{$src2, $dst|$dst, $src2}",
1350 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
1351 GR16:$src2))]>, OpSize;
1352 def XOR32rr : I<0x31, MRMDestReg,
1353 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1354 "xor{l}\t{$src2, $dst|$dst, $src2}",
1355 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
1357 } // isCommutable = 1
1359 // XOR instructions with the destination register in REG and the source register
1360 // in R/M. Included for the disassembler.
1361 let isCodeGenOnly = 1 in {
1362 def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1363 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1364 def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1365 (ins GR16:$src1, GR16:$src2),
1366 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1367 def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1368 (ins GR32:$src1, GR32:$src2),
1369 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1372 def XOR8rm : I<0x32, MRMSrcMem,
1373 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1374 "xor{b}\t{$src2, $dst|$dst, $src2}",
1375 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
1376 (load addr:$src2)))]>;
1377 def XOR16rm : I<0x33, MRMSrcMem,
1378 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1379 "xor{w}\t{$src2, $dst|$dst, $src2}",
1380 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
1381 (load addr:$src2)))]>,
1383 def XOR32rm : I<0x33, MRMSrcMem,
1384 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1385 "xor{l}\t{$src2, $dst|$dst, $src2}",
1386 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
1387 (load addr:$src2)))]>;
1389 def XOR8ri : Ii8<0x80, MRM6r,
1390 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1391 "xor{b}\t{$src2, $dst|$dst, $src2}",
1392 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
1393 def XOR16ri : Ii16<0x81, MRM6r,
1394 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1395 "xor{w}\t{$src2, $dst|$dst, $src2}",
1396 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
1397 imm:$src2))]>, OpSize;
1398 def XOR32ri : Ii32<0x81, MRM6r,
1399 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1400 "xor{l}\t{$src2, $dst|$dst, $src2}",
1401 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
1403 def XOR16ri8 : Ii8<0x83, MRM6r,
1404 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1405 "xor{w}\t{$src2, $dst|$dst, $src2}",
1406 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
1407 i16immSExt8:$src2))]>,
1409 def XOR32ri8 : Ii8<0x83, MRM6r,
1410 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1411 "xor{l}\t{$src2, $dst|$dst, $src2}",
1412 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
1413 i32immSExt8:$src2))]>;
1415 let Constraints = "" in {
1416 def XOR8mr : I<0x30, MRMDestMem,
1417 (outs), (ins i8mem :$dst, GR8 :$src),
1418 "xor{b}\t{$src, $dst|$dst, $src}",
1419 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1420 (implicit EFLAGS)]>;
1421 def XOR16mr : I<0x31, MRMDestMem,
1422 (outs), (ins i16mem:$dst, GR16:$src),
1423 "xor{w}\t{$src, $dst|$dst, $src}",
1424 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1425 (implicit EFLAGS)]>,
1427 def XOR32mr : I<0x31, MRMDestMem,
1428 (outs), (ins i32mem:$dst, GR32:$src),
1429 "xor{l}\t{$src, $dst|$dst, $src}",
1430 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1431 (implicit EFLAGS)]>;
1432 def XOR8mi : Ii8<0x80, MRM6m,
1433 (outs), (ins i8mem :$dst, i8imm :$src),
1434 "xor{b}\t{$src, $dst|$dst, $src}",
1435 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1436 (implicit EFLAGS)]>;
1437 def XOR16mi : Ii16<0x81, MRM6m,
1438 (outs), (ins i16mem:$dst, i16imm:$src),
1439 "xor{w}\t{$src, $dst|$dst, $src}",
1440 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1441 (implicit EFLAGS)]>,
1443 def XOR32mi : Ii32<0x81, MRM6m,
1444 (outs), (ins i32mem:$dst, i32imm:$src),
1445 "xor{l}\t{$src, $dst|$dst, $src}",
1446 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1447 (implicit EFLAGS)]>;
1448 def XOR16mi8 : Ii8<0x83, MRM6m,
1449 (outs), (ins i16mem:$dst, i16i8imm :$src),
1450 "xor{w}\t{$src, $dst|$dst, $src}",
1451 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1452 (implicit EFLAGS)]>,
1454 def XOR32mi8 : Ii8<0x83, MRM6m,
1455 (outs), (ins i32mem:$dst, i32i8imm :$src),
1456 "xor{l}\t{$src, $dst|$dst, $src}",
1457 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1458 (implicit EFLAGS)]>;
1460 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1461 "xor{b}\t{$src, %al|%al, $src}", []>;
1462 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
1463 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1464 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
1465 "xor{l}\t{$src, %eax|%eax, $src}", []>;
1466 } // Constraints = ""
1467 } // Defs = [EFLAGS]
1469 // Shift instructions
1470 let Defs = [EFLAGS] in {
1471 let Uses = [CL] in {
1472 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
1473 "shl{b}\t{%cl, $dst|$dst, CL}",
1474 [(set GR8:$dst, (shl GR8:$src1, CL))]>;
1475 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1476 "shl{w}\t{%cl, $dst|$dst, CL}",
1477 [(set GR16:$dst, (shl GR16:$src1, CL))]>, OpSize;
1478 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1479 "shl{l}\t{%cl, $dst|$dst, CL}",
1480 [(set GR32:$dst, (shl GR32:$src1, CL))]>;
1483 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1484 "shl{b}\t{$src2, $dst|$dst, $src2}",
1485 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1487 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1488 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1489 "shl{w}\t{$src2, $dst|$dst, $src2}",
1490 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1491 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1492 "shl{l}\t{$src2, $dst|$dst, $src2}",
1493 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1495 // NOTE: We don't include patterns for shifts of a register by one, because
1496 // 'add reg,reg' is cheaper.
1498 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
1499 "shl{b}\t$dst", []>;
1500 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1501 "shl{w}\t$dst", []>, OpSize;
1502 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1503 "shl{l}\t$dst", []>;
1505 } // isConvertibleToThreeAddress = 1
1507 let Constraints = "" in {
1508 let Uses = [CL] in {
1509 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1510 "shl{b}\t{%cl, $dst|$dst, CL}",
1511 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1512 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1513 "shl{w}\t{%cl, $dst|$dst, CL}",
1514 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1515 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1516 "shl{l}\t{%cl, $dst|$dst, CL}",
1517 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1519 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1520 "shl{b}\t{$src, $dst|$dst, $src}",
1521 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1522 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1523 "shl{w}\t{$src, $dst|$dst, $src}",
1524 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1526 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1527 "shl{l}\t{$src, $dst|$dst, $src}",
1528 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1531 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1533 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1534 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1536 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1538 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1540 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1541 } // Constraints = ""
1543 let Uses = [CL] in {
1544 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1),
1545 "shr{b}\t{%cl, $dst|$dst, CL}",
1546 [(set GR8:$dst, (srl GR8:$src1, CL))]>;
1547 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1548 "shr{w}\t{%cl, $dst|$dst, CL}",
1549 [(set GR16:$dst, (srl GR16:$src1, CL))]>, OpSize;
1550 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1551 "shr{l}\t{%cl, $dst|$dst, CL}",
1552 [(set GR32:$dst, (srl GR32:$src1, CL))]>;
1555 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1556 "shr{b}\t{$src2, $dst|$dst, $src2}",
1557 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1558 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1559 "shr{w}\t{$src2, $dst|$dst, $src2}",
1560 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1561 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1562 "shr{l}\t{$src2, $dst|$dst, $src2}",
1563 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1566 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1568 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1569 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1571 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1572 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1574 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1576 let Constraints = "" in {
1577 let Uses = [CL] in {
1578 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1579 "shr{b}\t{%cl, $dst|$dst, CL}",
1580 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1581 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1582 "shr{w}\t{%cl, $dst|$dst, CL}",
1583 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1585 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1586 "shr{l}\t{%cl, $dst|$dst, CL}",
1587 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1589 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1590 "shr{b}\t{$src, $dst|$dst, $src}",
1591 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1592 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1593 "shr{w}\t{$src, $dst|$dst, $src}",
1594 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1596 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1597 "shr{l}\t{$src, $dst|$dst, $src}",
1598 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1601 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1603 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1604 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1606 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1607 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1609 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1610 } // Constraints = ""
1612 let Uses = [CL] in {
1613 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1614 "sar{b}\t{%cl, $dst|$dst, CL}",
1615 [(set GR8:$dst, (sra GR8:$src1, CL))]>;
1616 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1617 "sar{w}\t{%cl, $dst|$dst, CL}",
1618 [(set GR16:$dst, (sra GR16:$src1, CL))]>, OpSize;
1619 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1620 "sar{l}\t{%cl, $dst|$dst, CL}",
1621 [(set GR32:$dst, (sra GR32:$src1, CL))]>;
1624 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1625 "sar{b}\t{$src2, $dst|$dst, $src2}",
1626 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1627 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1628 "sar{w}\t{$src2, $dst|$dst, $src2}",
1629 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1631 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1632 "sar{l}\t{$src2, $dst|$dst, $src2}",
1633 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1636 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1638 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1639 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1641 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1642 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1644 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1646 let Constraints = "" in {
1647 let Uses = [CL] in {
1648 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1649 "sar{b}\t{%cl, $dst|$dst, CL}",
1650 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1651 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1652 "sar{w}\t{%cl, $dst|$dst, CL}",
1653 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1654 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1655 "sar{l}\t{%cl, $dst|$dst, CL}",
1656 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1658 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1659 "sar{b}\t{$src, $dst|$dst, $src}",
1660 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1661 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1662 "sar{w}\t{$src, $dst|$dst, $src}",
1663 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1665 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1666 "sar{l}\t{$src, $dst|$dst, $src}",
1667 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1670 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1672 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1673 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1675 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1677 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1679 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1680 } // Constraints = ""
1682 // Rotate instructions
1684 def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
1685 "rcl{b}\t{1, $dst|$dst, 1}", []>;
1686 let Uses = [CL] in {
1687 def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
1688 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
1690 def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
1691 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
1693 def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
1694 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
1695 let Uses = [CL] in {
1696 def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
1697 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
1699 def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
1700 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
1702 def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
1703 "rcl{l}\t{1, $dst|$dst, 1}", []>;
1704 let Uses = [CL] in {
1705 def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
1706 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
1708 def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
1709 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
1711 def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
1712 "rcr{b}\t{1, $dst|$dst, 1}", []>;
1713 let Uses = [CL] in {
1714 def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
1715 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
1717 def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
1718 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
1720 def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
1721 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
1722 let Uses = [CL] in {
1723 def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
1724 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
1726 def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
1727 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
1729 def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
1730 "rcr{l}\t{1, $dst|$dst, 1}", []>;
1731 let Uses = [CL] in {
1732 def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
1733 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
1735 def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
1736 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
1738 let Constraints = "" in {
1739 def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
1740 "rcl{b}\t{1, $dst|$dst, 1}", []>;
1741 def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
1742 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
1743 def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
1744 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
1745 def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
1746 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
1747 def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
1748 "rcl{l}\t{1, $dst|$dst, 1}", []>;
1749 def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
1750 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
1751 def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
1752 "rcr{b}\t{1, $dst|$dst, 1}", []>;
1753 def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
1754 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
1755 def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
1756 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
1757 def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
1758 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
1759 def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
1760 "rcr{l}\t{1, $dst|$dst, 1}", []>;
1761 def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
1762 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
1764 let Uses = [CL] in {
1765 def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
1766 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
1767 def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
1768 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
1769 def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
1770 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
1771 def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
1772 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
1773 def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
1774 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
1775 def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
1776 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
1778 } // Constraints = ""
1780 // FIXME: provide shorter instructions when imm8 == 1
1781 let Uses = [CL] in {
1782 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1783 "rol{b}\t{%cl, $dst|$dst, CL}",
1784 [(set GR8:$dst, (rotl GR8:$src1, CL))]>;
1785 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1786 "rol{w}\t{%cl, $dst|$dst, CL}",
1787 [(set GR16:$dst, (rotl GR16:$src1, CL))]>, OpSize;
1788 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1789 "rol{l}\t{%cl, $dst|$dst, CL}",
1790 [(set GR32:$dst, (rotl GR32:$src1, CL))]>;
1793 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1794 "rol{b}\t{$src2, $dst|$dst, $src2}",
1795 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1796 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1797 "rol{w}\t{$src2, $dst|$dst, $src2}",
1798 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
1800 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1801 "rol{l}\t{$src2, $dst|$dst, $src2}",
1802 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1805 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1807 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1808 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1810 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1811 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1813 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1815 let Constraints = "" in {
1816 let Uses = [CL] in {
1817 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1818 "rol{b}\t{%cl, $dst|$dst, CL}",
1819 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
1820 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1821 "rol{w}\t{%cl, $dst|$dst, CL}",
1822 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1823 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1824 "rol{l}\t{%cl, $dst|$dst, CL}",
1825 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1827 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
1828 "rol{b}\t{$src, $dst|$dst, $src}",
1829 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1830 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
1831 "rol{w}\t{$src, $dst|$dst, $src}",
1832 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1834 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
1835 "rol{l}\t{$src, $dst|$dst, $src}",
1836 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1839 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
1841 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1842 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
1844 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1846 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
1848 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1849 } // Constraints = ""
1851 let Uses = [CL] in {
1852 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1853 "ror{b}\t{%cl, $dst|$dst, CL}",
1854 [(set GR8:$dst, (rotr GR8:$src1, CL))]>;
1855 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
1856 "ror{w}\t{%cl, $dst|$dst, CL}",
1857 [(set GR16:$dst, (rotr GR16:$src1, CL))]>, OpSize;
1858 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
1859 "ror{l}\t{%cl, $dst|$dst, CL}",
1860 [(set GR32:$dst, (rotr GR32:$src1, CL))]>;
1863 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1864 "ror{b}\t{$src2, $dst|$dst, $src2}",
1865 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1866 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1867 "ror{w}\t{$src2, $dst|$dst, $src2}",
1868 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
1870 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1871 "ror{l}\t{$src2, $dst|$dst, $src2}",
1872 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1875 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1877 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1878 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
1880 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1881 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
1883 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1885 let Constraints = "" in {
1886 let Uses = [CL] in {
1887 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
1888 "ror{b}\t{%cl, $dst|$dst, CL}",
1889 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
1890 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
1891 "ror{w}\t{%cl, $dst|$dst, CL}",
1892 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1893 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
1894 "ror{l}\t{%cl, $dst|$dst, CL}",
1895 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1897 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1898 "ror{b}\t{$src, $dst|$dst, $src}",
1899 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1900 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
1901 "ror{w}\t{$src, $dst|$dst, $src}",
1902 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1904 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
1905 "ror{l}\t{$src, $dst|$dst, $src}",
1906 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1909 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
1911 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1912 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
1914 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1916 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
1918 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1919 } // Constraints = ""
1922 // Double shift instructions (generalizations of rotate)
1923 let Uses = [CL] in {
1924 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
1925 (ins GR32:$src1, GR32:$src2),
1926 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
1927 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
1928 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
1929 (ins GR32:$src1, GR32:$src2),
1930 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
1931 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
1932 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
1933 (ins GR16:$src1, GR16:$src2),
1934 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
1935 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1937 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
1938 (ins GR16:$src1, GR16:$src2),
1939 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
1940 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1944 let isCommutable = 1 in { // These instructions commute to each other.
1945 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1947 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1948 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1949 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1952 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1954 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1955 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1956 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1959 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1961 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1962 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1963 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1966 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1968 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1969 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1970 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1975 let Constraints = "" in {
1976 let Uses = [CL] in {
1977 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1978 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
1979 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1981 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1982 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
1983 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1986 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1987 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1988 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1989 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1990 (i8 imm:$src3)), addr:$dst)]>,
1992 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1993 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1994 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1995 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1996 (i8 imm:$src3)), addr:$dst)]>,
1999 let Uses = [CL] in {
2000 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2001 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2002 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2003 addr:$dst)]>, TB, OpSize;
2004 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2005 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2006 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2007 addr:$dst)]>, TB, OpSize;
2009 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2010 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2011 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2012 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2013 (i8 imm:$src3)), addr:$dst)]>,
2015 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2016 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2017 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2018 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2019 (i8 imm:$src3)), addr:$dst)]>,
2021 } // Constraints = ""
2022 } // Defs = [EFLAGS]
2026 let Defs = [EFLAGS] in {
2027 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2028 // Register-Register Addition
2029 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2030 (ins GR8 :$src1, GR8 :$src2),
2031 "add{b}\t{$src2, $dst|$dst, $src2}",
2032 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
2034 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2035 // Register-Register Addition
2036 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2037 (ins GR16:$src1, GR16:$src2),
2038 "add{w}\t{$src2, $dst|$dst, $src2}",
2039 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2040 GR16:$src2))]>, OpSize;
2041 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2042 (ins GR32:$src1, GR32:$src2),
2043 "add{l}\t{$src2, $dst|$dst, $src2}",
2044 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2046 } // end isConvertibleToThreeAddress
2047 } // end isCommutable
2049 // These are alternate spellings for use by the disassembler, we mark them as
2050 // code gen only to ensure they aren't matched by the assembler.
2051 let isCodeGenOnly = 1 in {
2052 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2053 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2054 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2055 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2056 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
2057 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2060 // Register-Memory Addition
2061 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2062 (ins GR8 :$src1, i8mem :$src2),
2063 "add{b}\t{$src2, $dst|$dst, $src2}",
2064 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2065 (load addr:$src2)))]>;
2066 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2067 (ins GR16:$src1, i16mem:$src2),
2068 "add{w}\t{$src2, $dst|$dst, $src2}",
2069 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2070 (load addr:$src2)))]>, OpSize;
2071 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2072 (ins GR32:$src1, i32mem:$src2),
2073 "add{l}\t{$src2, $dst|$dst, $src2}",
2074 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2075 (load addr:$src2)))]>;
2077 // Register-Integer Addition
2078 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2079 "add{b}\t{$src2, $dst|$dst, $src2}",
2080 [(set GR8:$dst, EFLAGS,
2081 (X86add_flag GR8:$src1, imm:$src2))]>;
2083 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2084 // Register-Integer Addition
2085 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2086 (ins GR16:$src1, i16imm:$src2),
2087 "add{w}\t{$src2, $dst|$dst, $src2}",
2088 [(set GR16:$dst, EFLAGS,
2089 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
2090 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2091 (ins GR32:$src1, i32imm:$src2),
2092 "add{l}\t{$src2, $dst|$dst, $src2}",
2093 [(set GR32:$dst, EFLAGS,
2094 (X86add_flag GR32:$src1, imm:$src2))]>;
2095 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2096 (ins GR16:$src1, i16i8imm:$src2),
2097 "add{w}\t{$src2, $dst|$dst, $src2}",
2098 [(set GR16:$dst, EFLAGS,
2099 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
2100 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2101 (ins GR32:$src1, i32i8imm:$src2),
2102 "add{l}\t{$src2, $dst|$dst, $src2}",
2103 [(set GR32:$dst, EFLAGS,
2104 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
2107 let Constraints = "" in {
2108 // Memory-Register Addition
2109 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2110 "add{b}\t{$src2, $dst|$dst, $src2}",
2111 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2112 (implicit EFLAGS)]>;
2113 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2114 "add{w}\t{$src2, $dst|$dst, $src2}",
2115 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2116 (implicit EFLAGS)]>, OpSize;
2117 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2118 "add{l}\t{$src2, $dst|$dst, $src2}",
2119 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2120 (implicit EFLAGS)]>;
2121 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2122 "add{b}\t{$src2, $dst|$dst, $src2}",
2123 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2124 (implicit EFLAGS)]>;
2125 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2126 "add{w}\t{$src2, $dst|$dst, $src2}",
2127 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2128 (implicit EFLAGS)]>, OpSize;
2129 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2130 "add{l}\t{$src2, $dst|$dst, $src2}",
2131 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2132 (implicit EFLAGS)]>;
2133 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2134 "add{w}\t{$src2, $dst|$dst, $src2}",
2135 [(store (add (load addr:$dst), i16immSExt8:$src2),
2137 (implicit EFLAGS)]>, OpSize;
2138 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2139 "add{l}\t{$src2, $dst|$dst, $src2}",
2140 [(store (add (load addr:$dst), i32immSExt8:$src2),
2142 (implicit EFLAGS)]>;
2145 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2146 "add{b}\t{$src, %al|%al, $src}", []>;
2147 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2148 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2149 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2150 "add{l}\t{$src, %eax|%eax, $src}", []>;
2151 } // Constraints = ""
2153 let Uses = [EFLAGS] in {
2154 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2155 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2156 "adc{b}\t{$src2, $dst|$dst, $src2}",
2157 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2158 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2159 (ins GR16:$src1, GR16:$src2),
2160 "adc{w}\t{$src2, $dst|$dst, $src2}",
2161 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2162 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2163 (ins GR32:$src1, GR32:$src2),
2164 "adc{l}\t{$src2, $dst|$dst, $src2}",
2165 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2168 let isCodeGenOnly = 1 in {
2169 def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2170 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2171 def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2172 (ins GR16:$src1, GR16:$src2),
2173 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2174 def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2175 (ins GR32:$src1, GR32:$src2),
2176 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2179 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2180 (ins GR8:$src1, i8mem:$src2),
2181 "adc{b}\t{$src2, $dst|$dst, $src2}",
2182 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2183 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2184 (ins GR16:$src1, i16mem:$src2),
2185 "adc{w}\t{$src2, $dst|$dst, $src2}",
2186 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2188 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2189 (ins GR32:$src1, i32mem:$src2),
2190 "adc{l}\t{$src2, $dst|$dst, $src2}",
2191 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2192 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2193 "adc{b}\t{$src2, $dst|$dst, $src2}",
2194 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2195 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2196 (ins GR16:$src1, i16imm:$src2),
2197 "adc{w}\t{$src2, $dst|$dst, $src2}",
2198 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2199 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2200 (ins GR16:$src1, i16i8imm:$src2),
2201 "adc{w}\t{$src2, $dst|$dst, $src2}",
2202 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2204 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2205 (ins GR32:$src1, i32imm:$src2),
2206 "adc{l}\t{$src2, $dst|$dst, $src2}",
2207 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2208 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2209 (ins GR32:$src1, i32i8imm:$src2),
2210 "adc{l}\t{$src2, $dst|$dst, $src2}",
2211 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2213 let Constraints = "" in {
2214 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2215 "adc{b}\t{$src2, $dst|$dst, $src2}",
2216 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2217 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2218 "adc{w}\t{$src2, $dst|$dst, $src2}",
2219 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2221 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2222 "adc{l}\t{$src2, $dst|$dst, $src2}",
2223 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2224 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2225 "adc{b}\t{$src2, $dst|$dst, $src2}",
2226 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2227 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2228 "adc{w}\t{$src2, $dst|$dst, $src2}",
2229 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2231 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2232 "adc{w}\t{$src2, $dst|$dst, $src2}",
2233 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2235 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2236 "adc{l}\t{$src2, $dst|$dst, $src2}",
2237 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2238 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2239 "adc{l}\t{$src2, $dst|$dst, $src2}",
2240 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2242 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2243 "adc{b}\t{$src, %al|%al, $src}", []>;
2244 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2245 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2246 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2247 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2248 } // Constraints = ""
2249 } // Uses = [EFLAGS]
2251 // Register-Register Subtraction
2252 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2253 "sub{b}\t{$src2, $dst|$dst, $src2}",
2254 [(set GR8:$dst, EFLAGS,
2255 (X86sub_flag GR8:$src1, GR8:$src2))]>;
2256 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2257 "sub{w}\t{$src2, $dst|$dst, $src2}",
2258 [(set GR16:$dst, EFLAGS,
2259 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
2260 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2261 "sub{l}\t{$src2, $dst|$dst, $src2}",
2262 [(set GR32:$dst, EFLAGS,
2263 (X86sub_flag GR32:$src1, GR32:$src2))]>;
2265 let isCodeGenOnly = 1 in {
2266 def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2267 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2268 def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2269 (ins GR16:$src1, GR16:$src2),
2270 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2271 def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2272 (ins GR32:$src1, GR32:$src2),
2273 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2276 // Register-Memory Subtraction
2277 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2278 (ins GR8 :$src1, i8mem :$src2),
2279 "sub{b}\t{$src2, $dst|$dst, $src2}",
2280 [(set GR8:$dst, EFLAGS,
2281 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
2282 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2283 (ins GR16:$src1, i16mem:$src2),
2284 "sub{w}\t{$src2, $dst|$dst, $src2}",
2285 [(set GR16:$dst, EFLAGS,
2286 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
2287 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2288 (ins GR32:$src1, i32mem:$src2),
2289 "sub{l}\t{$src2, $dst|$dst, $src2}",
2290 [(set GR32:$dst, EFLAGS,
2291 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
2293 // Register-Integer Subtraction
2294 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2295 (ins GR8:$src1, i8imm:$src2),
2296 "sub{b}\t{$src2, $dst|$dst, $src2}",
2297 [(set GR8:$dst, EFLAGS,
2298 (X86sub_flag GR8:$src1, imm:$src2))]>;
2299 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2300 (ins GR16:$src1, i16imm:$src2),
2301 "sub{w}\t{$src2, $dst|$dst, $src2}",
2302 [(set GR16:$dst, EFLAGS,
2303 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
2304 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2305 (ins GR32:$src1, i32imm:$src2),
2306 "sub{l}\t{$src2, $dst|$dst, $src2}",
2307 [(set GR32:$dst, EFLAGS,
2308 (X86sub_flag GR32:$src1, imm:$src2))]>;
2309 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2310 (ins GR16:$src1, i16i8imm:$src2),
2311 "sub{w}\t{$src2, $dst|$dst, $src2}",
2312 [(set GR16:$dst, EFLAGS,
2313 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
2314 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2315 (ins GR32:$src1, i32i8imm:$src2),
2316 "sub{l}\t{$src2, $dst|$dst, $src2}",
2317 [(set GR32:$dst, EFLAGS,
2318 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
2320 let Constraints = "" in {
2321 // Memory-Register Subtraction
2322 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2323 "sub{b}\t{$src2, $dst|$dst, $src2}",
2324 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2325 (implicit EFLAGS)]>;
2326 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2327 "sub{w}\t{$src2, $dst|$dst, $src2}",
2328 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2329 (implicit EFLAGS)]>, OpSize;
2330 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2331 "sub{l}\t{$src2, $dst|$dst, $src2}",
2332 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2333 (implicit EFLAGS)]>;
2335 // Memory-Integer Subtraction
2336 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2337 "sub{b}\t{$src2, $dst|$dst, $src2}",
2338 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2339 (implicit EFLAGS)]>;
2340 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2341 "sub{w}\t{$src2, $dst|$dst, $src2}",
2342 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2343 (implicit EFLAGS)]>, OpSize;
2344 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2345 "sub{l}\t{$src2, $dst|$dst, $src2}",
2346 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2347 (implicit EFLAGS)]>;
2348 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2349 "sub{w}\t{$src2, $dst|$dst, $src2}",
2350 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2352 (implicit EFLAGS)]>, OpSize;
2353 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2354 "sub{l}\t{$src2, $dst|$dst, $src2}",
2355 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2357 (implicit EFLAGS)]>;
2359 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2360 "sub{b}\t{$src, %al|%al, $src}", []>;
2361 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2362 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2363 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2364 "sub{l}\t{$src, %eax|%eax, $src}", []>;
2365 } // Constraints = ""
2367 let Uses = [EFLAGS] in {
2368 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2369 (ins GR8:$src1, GR8:$src2),
2370 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2371 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2372 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2373 (ins GR16:$src1, GR16:$src2),
2374 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2375 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2376 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2377 (ins GR32:$src1, GR32:$src2),
2378 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2379 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2381 let Constraints = "" in {
2382 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2383 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2384 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2385 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2386 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2387 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2389 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2390 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2391 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2392 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2393 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2394 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2395 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2396 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2397 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2399 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2400 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2401 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2403 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2404 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2405 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2406 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2407 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2408 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2410 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2411 "sbb{b}\t{$src, %al|%al, $src}", []>;
2412 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2413 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2414 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2415 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
2416 } // Constraints = ""
2418 let isCodeGenOnly = 1 in {
2419 def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2420 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
2421 def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
2422 (ins GR16:$src1, GR16:$src2),
2423 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2424 def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
2425 (ins GR32:$src1, GR32:$src2),
2426 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
2429 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2430 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2431 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2432 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2433 (ins GR16:$src1, i16mem:$src2),
2434 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2435 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2437 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2438 (ins GR32:$src1, i32mem:$src2),
2439 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2440 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2441 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2442 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2443 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2444 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2445 (ins GR16:$src1, i16imm:$src2),
2446 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2447 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2448 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2449 (ins GR16:$src1, i16i8imm:$src2),
2450 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2451 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2453 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2454 (ins GR32:$src1, i32imm:$src2),
2455 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2456 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2457 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2458 (ins GR32:$src1, i32i8imm:$src2),
2459 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2460 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2461 } // Uses = [EFLAGS]
2462 } // Defs = [EFLAGS]
2464 let Defs = [EFLAGS] in {
2465 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2466 // Register-Register Signed Integer Multiply
2467 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2468 "imul{w}\t{$src2, $dst|$dst, $src2}",
2469 [(set GR16:$dst, EFLAGS,
2470 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
2471 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2472 "imul{l}\t{$src2, $dst|$dst, $src2}",
2473 [(set GR32:$dst, EFLAGS,
2474 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
2477 // Register-Memory Signed Integer Multiply
2478 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2479 (ins GR16:$src1, i16mem:$src2),
2480 "imul{w}\t{$src2, $dst|$dst, $src2}",
2481 [(set GR16:$dst, EFLAGS,
2482 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
2484 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
2485 (ins GR32:$src1, i32mem:$src2),
2486 "imul{l}\t{$src2, $dst|$dst, $src2}",
2487 [(set GR32:$dst, EFLAGS,
2488 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
2489 } // Defs = [EFLAGS]
2490 } // end Two Address instructions
2492 // Suprisingly enough, these are not two address instructions!
2493 let Defs = [EFLAGS] in {
2494 // Register-Integer Signed Integer Multiply
2495 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2496 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2497 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2498 [(set GR16:$dst, EFLAGS,
2499 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
2500 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2501 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2502 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2503 [(set GR32:$dst, EFLAGS,
2504 (X86smul_flag GR32:$src1, imm:$src2))]>;
2505 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2506 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2507 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2508 [(set GR16:$dst, EFLAGS,
2509 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
2511 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2512 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2513 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2514 [(set GR32:$dst, EFLAGS,
2515 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
2517 // Memory-Integer Signed Integer Multiply
2518 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2519 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2520 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2521 [(set GR16:$dst, EFLAGS,
2522 (X86smul_flag (load addr:$src1), imm:$src2))]>,
2524 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2525 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2526 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2527 [(set GR32:$dst, EFLAGS,
2528 (X86smul_flag (load addr:$src1), imm:$src2))]>;
2529 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2530 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2531 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2532 [(set GR16:$dst, EFLAGS,
2533 (X86smul_flag (load addr:$src1),
2534 i16immSExt8:$src2))]>, OpSize;
2535 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2536 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2537 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2538 [(set GR32:$dst, EFLAGS,
2539 (X86smul_flag (load addr:$src1),
2540 i32immSExt8:$src2))]>;
2541 } // Defs = [EFLAGS]
2543 //===----------------------------------------------------------------------===//
2544 // Test instructions are just like AND, except they don't generate a result.
2546 let Defs = [EFLAGS] in {
2547 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2548 def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
2549 "test{b}\t{$src2, $src1|$src1, $src2}",
2550 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
2551 def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
2552 "test{w}\t{$src2, $src1|$src1, $src2}",
2553 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
2556 def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
2557 "test{l}\t{$src2, $src1|$src1, $src2}",
2558 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
2562 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
2563 "test{b}\t{$src, %al|%al, $src}", []>;
2564 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
2565 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2566 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
2567 "test{l}\t{$src, %eax|%eax, $src}", []>;
2569 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2570 "test{b}\t{$src2, $src1|$src1, $src2}",
2571 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
2573 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2574 "test{w}\t{$src2, $src1|$src1, $src2}",
2575 [(set EFLAGS, (X86cmp (and GR16:$src1,
2576 (loadi16 addr:$src2)), 0))]>, OpSize;
2577 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2578 "test{l}\t{$src2, $src1|$src1, $src2}",
2579 [(set EFLAGS, (X86cmp (and GR32:$src1,
2580 (loadi32 addr:$src2)), 0))]>;
2582 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2583 (outs), (ins GR8:$src1, i8imm:$src2),
2584 "test{b}\t{$src2, $src1|$src1, $src2}",
2585 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
2586 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2587 (outs), (ins GR16:$src1, i16imm:$src2),
2588 "test{w}\t{$src2, $src1|$src1, $src2}",
2589 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
2591 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2592 (outs), (ins GR32:$src1, i32imm:$src2),
2593 "test{l}\t{$src2, $src1|$src1, $src2}",
2594 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
2596 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2597 (outs), (ins i8mem:$src1, i8imm:$src2),
2598 "test{b}\t{$src2, $src1|$src1, $src2}",
2599 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
2601 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2602 (outs), (ins i16mem:$src1, i16imm:$src2),
2603 "test{w}\t{$src2, $src1|$src1, $src2}",
2604 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
2606 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2607 (outs), (ins i32mem:$src1, i32imm:$src2),
2608 "test{l}\t{$src2, $src1|$src1, $src2}",
2609 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
2611 } // Defs = [EFLAGS]
2614 // Condition code ops, incl. set if equal/not equal/...
2615 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2616 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2617 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2618 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2620 // Integer comparisons
2621 let Defs = [EFLAGS] in {
2622 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
2623 "cmp{b}\t{$src, %al|%al, $src}", []>;
2624 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
2625 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2626 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
2627 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
2629 def CMP8rr : I<0x38, MRMDestReg,
2630 (outs), (ins GR8 :$src1, GR8 :$src2),
2631 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2632 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
2633 def CMP16rr : I<0x39, MRMDestReg,
2634 (outs), (ins GR16:$src1, GR16:$src2),
2635 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2636 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
2637 def CMP32rr : I<0x39, MRMDestReg,
2638 (outs), (ins GR32:$src1, GR32:$src2),
2639 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2640 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
2641 def CMP8mr : I<0x38, MRMDestMem,
2642 (outs), (ins i8mem :$src1, GR8 :$src2),
2643 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2644 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
2645 def CMP16mr : I<0x39, MRMDestMem,
2646 (outs), (ins i16mem:$src1, GR16:$src2),
2647 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2648 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
2650 def CMP32mr : I<0x39, MRMDestMem,
2651 (outs), (ins i32mem:$src1, GR32:$src2),
2652 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2653 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
2654 def CMP8rm : I<0x3A, MRMSrcMem,
2655 (outs), (ins GR8 :$src1, i8mem :$src2),
2656 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2657 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
2658 def CMP16rm : I<0x3B, MRMSrcMem,
2659 (outs), (ins GR16:$src1, i16mem:$src2),
2660 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2661 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
2663 def CMP32rm : I<0x3B, MRMSrcMem,
2664 (outs), (ins GR32:$src1, i32mem:$src2),
2665 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2666 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
2668 // These are alternate spellings for use by the disassembler, we mark them as
2669 // code gen only to ensure they aren't matched by the assembler.
2670 let isCodeGenOnly = 1 in {
2671 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
2672 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
2673 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
2674 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
2675 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
2676 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
2679 def CMP8ri : Ii8<0x80, MRM7r,
2680 (outs), (ins GR8:$src1, i8imm:$src2),
2681 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2682 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
2683 def CMP16ri : Ii16<0x81, MRM7r,
2684 (outs), (ins GR16:$src1, i16imm:$src2),
2685 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2686 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
2687 def CMP32ri : Ii32<0x81, MRM7r,
2688 (outs), (ins GR32:$src1, i32imm:$src2),
2689 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2690 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
2691 def CMP8mi : Ii8 <0x80, MRM7m,
2692 (outs), (ins i8mem :$src1, i8imm :$src2),
2693 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2694 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
2695 def CMP16mi : Ii16<0x81, MRM7m,
2696 (outs), (ins i16mem:$src1, i16imm:$src2),
2697 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2698 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
2700 def CMP32mi : Ii32<0x81, MRM7m,
2701 (outs), (ins i32mem:$src1, i32imm:$src2),
2702 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2703 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
2704 def CMP16ri8 : Ii8<0x83, MRM7r,
2705 (outs), (ins GR16:$src1, i16i8imm:$src2),
2706 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2707 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
2709 def CMP16mi8 : Ii8<0x83, MRM7m,
2710 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2711 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2712 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
2713 i16immSExt8:$src2))]>, OpSize;
2714 def CMP32mi8 : Ii8<0x83, MRM7m,
2715 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2716 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2717 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
2718 i32immSExt8:$src2))]>;
2719 def CMP32ri8 : Ii8<0x83, MRM7r,
2720 (outs), (ins GR32:$src1, i32i8imm:$src2),
2721 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2722 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
2723 } // Defs = [EFLAGS]
2726 // TODO: BTC, BTR, and BTS
2727 let Defs = [EFLAGS] in {
2728 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2729 "bt{w}\t{$src2, $src1|$src1, $src2}",
2730 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
2731 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2732 "bt{l}\t{$src2, $src1|$src1, $src2}",
2733 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
2735 // Unlike with the register+register form, the memory+register form of the
2736 // bt instruction does not ignore the high bits of the index. From ISel's
2737 // perspective, this is pretty bizarre. Make these instructions disassembly
2740 def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2741 "bt{w}\t{$src2, $src1|$src1, $src2}",
2742 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
2743 // (implicit EFLAGS)]
2745 >, OpSize, TB, Requires<[FastBTMem]>;
2746 def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2747 "bt{l}\t{$src2, $src1|$src1, $src2}",
2748 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
2749 // (implicit EFLAGS)]
2751 >, TB, Requires<[FastBTMem]>;
2753 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2754 "bt{w}\t{$src2, $src1|$src1, $src2}",
2755 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
2757 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2758 "bt{l}\t{$src2, $src1|$src1, $src2}",
2759 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
2760 // Note that these instructions don't need FastBTMem because that
2761 // only applies when the other operand is in a register. When it's
2762 // an immediate, bt is still fast.
2763 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2764 "bt{w}\t{$src2, $src1|$src1, $src2}",
2765 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
2767 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2768 "bt{l}\t{$src2, $src1|$src1, $src2}",
2769 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
2772 def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2773 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2774 def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2775 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2776 def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2777 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2778 def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2779 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2780 def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2781 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2782 def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2783 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2784 def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2785 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2786 def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2787 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2789 def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2790 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2791 def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2792 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2793 def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2794 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2795 def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2796 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2797 def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2798 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2799 def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2800 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2801 def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2802 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2803 def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2804 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2806 def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2807 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2808 def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2809 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2810 def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2811 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2812 def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2813 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2814 def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2815 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2816 def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2817 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2818 def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2819 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
2820 def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2821 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
2822 } // Defs = [EFLAGS]
2824 // Sign/Zero extenders
2825 // Use movsbl intead of movsbw; we don't care about the high 16 bits
2826 // of the register here. This has a smaller encoding and avoids a
2827 // partial-register update. Actual movsbw included for the disassembler.
2828 def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
2829 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
2830 def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
2831 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
2832 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2833 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
2834 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2835 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
2836 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2837 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2838 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2839 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2840 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2841 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2842 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2843 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2844 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2845 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2846 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2847 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2849 // Use movzbl intead of movzbw; we don't care about the high 16 bits
2850 // of the register here. This has a smaller encoding and avoids a
2851 // partial-register update. Actual movzbw included for the disassembler.
2852 def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
2853 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
2854 def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
2855 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
2856 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2857 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
2858 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2859 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
2860 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2861 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2862 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2863 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2864 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2865 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2866 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2867 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2868 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2869 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2870 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2871 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2873 // These are the same as the regular MOVZX32rr8 and MOVZX32rm8
2874 // except that they use GR32_NOREX for the output operand register class
2875 // instead of GR32. This allows them to operate on h registers on x86-64.
2876 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
2877 (outs GR32_NOREX:$dst), (ins GR8:$src),
2878 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
2881 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
2882 (outs GR32_NOREX:$dst), (ins i8mem:$src),
2883 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
2886 let neverHasSideEffects = 1 in {
2887 let Defs = [AX], Uses = [AL] in
2888 def CBW : I<0x98, RawFrm, (outs), (ins),
2889 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2890 let Defs = [EAX], Uses = [AX] in
2891 def CWDE : I<0x98, RawFrm, (outs), (ins),
2892 "{cwtl|cwde}", []>; // EAX = signext(AX)
2894 let Defs = [AX,DX], Uses = [AX] in
2895 def CWD : I<0x99, RawFrm, (outs), (ins),
2896 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2897 let Defs = [EAX,EDX], Uses = [EAX] in
2898 def CDQ : I<0x99, RawFrm, (outs), (ins),
2899 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2904 //===----------------------------------------------------------------------===//
2909 // Atomic swap. These are just normal xchg instructions. But since a memory
2910 // operand is referenced, the atomicity is ensured.
2911 let Constraints = "$val = $dst" in {
2912 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
2913 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2914 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2915 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
2916 (ins GR16:$val, i16mem:$ptr),
2917 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2918 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2920 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
2921 (ins GR32:$val, i32mem:$ptr),
2922 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2923 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2924 def XCHG64rm : RI<0x87, MRMSrcMem, (outs GR64:$dst),
2925 (ins GR64:$val,i64mem:$ptr),
2926 "xchg{q}\t{$val, $ptr|$ptr, $val}",
2927 [(set GR64:$dst, (atomic_swap_64 addr:$ptr, GR64:$val))]>;
2929 def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
2930 "xchg{b}\t{$val, $src|$src, $val}", []>;
2931 def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
2932 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
2933 def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
2934 "xchg{l}\t{$val, $src|$src, $val}", []>;
2935 def XCHG64rr : RI<0x87, MRMSrcReg, (outs GR64:$dst), (ins GR64:$val,GR64:$src),
2936 "xchg{q}\t{$val, $src|$src, $val}", []>;
2939 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
2940 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2941 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
2942 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
2943 def XCHG64ar : RI<0x90, AddRegFrm, (outs), (ins GR64:$src),
2944 "xchg{q}\t{$src, %rax|%rax, $src}", []>;
2948 def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
2949 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
2950 def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
2951 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
2952 def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
2953 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
2954 def XADD64rr : RI<0xC1, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
2955 "xadd{q}\t{$src, $dst|$dst, $src}", []>, TB;
2957 let mayLoad = 1, mayStore = 1 in {
2958 def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
2959 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
2960 def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
2961 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
2962 def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2963 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
2964 def XADD64rm : RI<0xC1, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
2965 "xadd{q}\t{$src, $dst|$dst, $src}", []>, TB;
2969 def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
2970 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
2971 def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
2972 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
2973 def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
2974 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
2975 def CMPXCHG64rr : RI<0xB1, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
2976 "cmpxchg{q}\t{$src, $dst|$dst, $src}", []>, TB;
2978 let mayLoad = 1, mayStore = 1 in {
2979 def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
2980 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
2981 def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
2982 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
2983 def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
2984 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
2985 def CMPXCHG64rm : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
2986 "cmpxchg{q}\t{$src, $dst|$dst, $src}", []>, TB;
2989 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
2990 def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
2991 "cmpxchg8b\t$dst", []>, TB;
2993 let Defs = [RAX, RDX, EFLAGS], Uses = [RAX, RBX, RCX, RDX] in
2994 def CMPXCHG16B : RI<0xC7, MRM1m, (outs), (ins i128mem:$dst),
2995 "cmpxchg16b\t$dst", []>, TB;
2999 // Lock instruction prefix
3000 def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
3002 // Repeat string operation instruction prefixes
3003 // These uses the DF flag in the EFLAGS register to inc or dec ECX
3004 let Defs = [ECX], Uses = [ECX,EFLAGS] in {
3005 // Repeat (used with INS, OUTS, MOVS, LODS and STOS)
3006 def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
3007 // Repeat while not equal (used with CMPS and SCAS)
3008 def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
3012 // String manipulation instructions
3014 def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
3015 def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
3016 def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
3017 def LODSQ : RI<0xAD, RawFrm, (outs), (ins), "lodsq", []>;
3019 def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
3020 def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
3021 def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
3024 // Flag instructions
3025 def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
3026 def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
3027 def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
3028 def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
3029 def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
3030 def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
3031 def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
3033 def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
3035 // Table lookup instructions
3036 def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
3040 //===----------------------------------------------------------------------===//
3042 //===----------------------------------------------------------------------===//
3044 // Floating Point Stack Support
3045 include "X86InstrFPStack.td"
3048 include "X86Instr64bit.td"
3050 include "X86InstrCMovSetCC.td"
3051 include "X86InstrControl.td"
3053 // SIMD support (SSE, MMX and AVX)
3054 include "X86InstrFragmentsSIMD.td"
3056 // FMA - Fused Multiply-Add support (requires FMA)
3057 include "X86InstrFMA.td"
3059 // SSE, MMX and 3DNow! vector support.
3060 include "X86InstrSSE.td"
3061 include "X86InstrMMX.td"
3062 include "X86Instr3DNow.td"
3064 include "X86InstrVMX.td"
3066 // System instructions.
3067 include "X86InstrSystem.td"
3069 // Compiler Pseudo Instructions and Pat Patterns
3070 include "X86InstrCompiler.td"