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;
261 let ParserMatchClass = X86AbsMemAsmOperand,
262 PrintMethod = "print_pcrel_imm" in {
263 def i32imm_pcrel : Operand<i32>;
264 def i16imm_pcrel : Operand<i16>;
266 def offset8 : Operand<i64>;
267 def offset16 : Operand<i64>;
268 def offset32 : Operand<i64>;
269 def offset64 : Operand<i64>;
271 // Branch targets have OtherVT type and print as pc-relative values.
272 def brtarget : Operand<OtherVT>;
273 def brtarget8 : Operand<OtherVT>;
277 def SSECC : Operand<i8> {
278 let PrintMethod = "printSSECC";
281 class ImmSExtAsmOperandClass : AsmOperandClass {
282 let SuperClasses = [ImmAsmOperand];
283 let RenderMethod = "addImmOperands";
286 // Sign-extended immediate classes. We don't need to define the full lattice
287 // here because there is no instruction with an ambiguity between ImmSExti64i32
290 // The strange ranges come from the fact that the assembler always works with
291 // 64-bit immediates, but for a 16-bit target value we want to accept both "-1"
292 // (which will be a -1ULL), and "0xFF" (-1 in 16-bits).
295 // [0xFFFFFFFF80000000, 0xFFFFFFFFFFFFFFFF]
296 def ImmSExti64i32AsmOperand : ImmSExtAsmOperandClass {
297 let Name = "ImmSExti64i32";
300 // [0, 0x0000007F] | [0x000000000000FF80, 0x000000000000FFFF] |
301 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
302 def ImmSExti16i8AsmOperand : ImmSExtAsmOperandClass {
303 let Name = "ImmSExti16i8";
304 let SuperClasses = [ImmSExti64i32AsmOperand];
307 // [0, 0x0000007F] | [0x00000000FFFFFF80, 0x00000000FFFFFFFF] |
308 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
309 def ImmSExti32i8AsmOperand : ImmSExtAsmOperandClass {
310 let Name = "ImmSExti32i8";
314 // [0xFFFFFFFFFFFFFF80, 0xFFFFFFFFFFFFFFFF]
315 def ImmSExti64i8AsmOperand : ImmSExtAsmOperandClass {
316 let Name = "ImmSExti64i8";
317 let SuperClasses = [ImmSExti16i8AsmOperand, ImmSExti32i8AsmOperand,
318 ImmSExti64i32AsmOperand];
321 // A couple of more descriptive operand definitions.
322 // 16-bits but only 8 bits are significant.
323 def i16i8imm : Operand<i16> {
324 let ParserMatchClass = ImmSExti16i8AsmOperand;
326 // 32-bits but only 8 bits are significant.
327 def i32i8imm : Operand<i32> {
328 let ParserMatchClass = ImmSExti32i8AsmOperand;
331 //===----------------------------------------------------------------------===//
332 // X86 Complex Pattern Definitions.
335 // Define X86 specific addressing mode.
336 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], [SDNPWantParent]>;
337 def lea32addr : ComplexPattern<i32, 5, "SelectLEAAddr",
338 [add, sub, mul, X86mul_imm, shl, or, frameindex],
340 def tls32addr : ComplexPattern<i32, 5, "SelectTLSADDRAddr",
341 [tglobaltlsaddr], []>;
343 //===----------------------------------------------------------------------===//
344 // X86 Instruction Predicate Definitions.
345 def HasCMov : Predicate<"Subtarget->hasCMov()">;
346 def NoCMov : Predicate<"!Subtarget->hasCMov()">;
348 // FIXME: temporary hack to let codegen assert or generate poor code in case
349 // no AVX version of the desired intructions is present, this is better for
350 // incremental dev (without fallbacks it's easier to spot what's missing)
351 def HasMMX : Predicate<"Subtarget->hasMMX() && !Subtarget->hasAVX()">;
352 def Has3DNow : Predicate<"Subtarget->has3DNow()">;
353 def Has3DNowA : Predicate<"Subtarget->has3DNowA()">;
354 def HasSSE1 : Predicate<"Subtarget->hasSSE1() && !Subtarget->hasAVX()">;
355 def HasSSE2 : Predicate<"Subtarget->hasSSE2() && !Subtarget->hasAVX()">;
356 def HasSSE3 : Predicate<"Subtarget->hasSSE3() && !Subtarget->hasAVX()">;
357 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3() && !Subtarget->hasAVX()">;
358 def HasSSE41 : Predicate<"Subtarget->hasSSE41() && !Subtarget->hasAVX()">;
359 def HasSSE42 : Predicate<"Subtarget->hasSSE42() && !Subtarget->hasAVX()">;
360 def HasSSE4A : Predicate<"Subtarget->hasSSE4A() && !Subtarget->hasAVX()">;
362 def HasAVX : Predicate<"Subtarget->hasAVX()">;
363 def HasCLMUL : Predicate<"Subtarget->hasCLMUL()">;
364 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
365 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
366 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
367 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
368 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
369 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
370 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
371 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
372 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
373 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
374 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
375 "TM.getCodeModel() != CodeModel::Kernel">;
376 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
377 "TM.getCodeModel() == CodeModel::Kernel">;
378 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
379 def IsNotPIC : Predicate<"TM.getRelocationModel() != Reloc::PIC_">;
380 def OptForSize : Predicate<"OptForSize">;
381 def OptForSpeed : Predicate<"!OptForSize">;
382 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
383 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
384 def HasAES : Predicate<"Subtarget->hasAES()">;
386 //===----------------------------------------------------------------------===//
387 // X86 Instruction Format Definitions.
390 include "X86InstrFormats.td"
392 //===----------------------------------------------------------------------===//
393 // Pattern fragments...
396 // X86 specific condition code. These correspond to CondCode in
397 // X86InstrInfo.h. They must be kept in synch.
398 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
399 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
400 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
401 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
402 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
403 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
404 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
405 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
406 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
407 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
408 def X86_COND_NO : PatLeaf<(i8 10)>;
409 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
410 def X86_COND_NS : PatLeaf<(i8 12)>;
411 def X86_COND_O : PatLeaf<(i8 13)>;
412 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
413 def X86_COND_S : PatLeaf<(i8 15)>;
415 def immSext8 : PatLeaf<(imm), [{ return immSext8(N); }]>;
417 def i16immSExt8 : PatLeaf<(i16 immSext8)>;
418 def i32immSExt8 : PatLeaf<(i32 immSext8)>;
420 // Helper fragments for loads.
421 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
422 // known to be 32-bit aligned or better. Ditto for i8 to i16.
423 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
424 LoadSDNode *LD = cast<LoadSDNode>(N);
425 ISD::LoadExtType ExtType = LD->getExtensionType();
426 if (ExtType == ISD::NON_EXTLOAD)
428 if (ExtType == ISD::EXTLOAD)
429 return LD->getAlignment() >= 2 && !LD->isVolatile();
433 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
434 LoadSDNode *LD = cast<LoadSDNode>(N);
435 ISD::LoadExtType ExtType = LD->getExtensionType();
436 if (ExtType == ISD::EXTLOAD)
437 return LD->getAlignment() >= 2 && !LD->isVolatile();
441 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
442 LoadSDNode *LD = cast<LoadSDNode>(N);
443 ISD::LoadExtType ExtType = LD->getExtensionType();
444 if (ExtType == ISD::NON_EXTLOAD)
446 if (ExtType == ISD::EXTLOAD)
447 return LD->getAlignment() >= 4 && !LD->isVolatile();
451 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
452 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
453 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
454 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
455 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
457 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
458 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
459 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
461 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
462 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
463 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
464 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
465 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
466 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
468 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
469 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
470 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
471 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
472 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
473 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
476 // An 'and' node with a single use.
477 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
478 return N->hasOneUse();
480 // An 'srl' node with a single use.
481 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
482 return N->hasOneUse();
484 // An 'trunc' node with a single use.
485 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
486 return N->hasOneUse();
489 // Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
490 def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
491 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
492 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
494 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
495 APInt Mask = APInt::getAllOnesValue(BitWidth);
496 APInt KnownZero0, KnownOne0;
497 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
498 APInt KnownZero1, KnownOne1;
499 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
500 return (~KnownZero0 & ~KnownZero1) == 0;
503 //===----------------------------------------------------------------------===//
508 let neverHasSideEffects = 1 in {
509 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
510 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
511 "nop{w}\t$zero", []>, TB, OpSize;
512 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
513 "nop{l}\t$zero", []>, TB;
517 // Constructing a stack frame.
518 def ENTER : Ii16<0xC8, RawFrmImm8, (outs), (ins i16imm:$len, i8imm:$lvl),
519 "enter\t$len, $lvl", []>;
521 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
522 def LEAVE : I<0xC9, RawFrm,
523 (outs), (ins), "leave", []>, Requires<[In32BitMode]>;
525 //===----------------------------------------------------------------------===//
526 // Miscellaneous Instructions...
528 def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
529 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
531 def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
532 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
533 def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
534 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
536 def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
537 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
539 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
541 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
543 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
544 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
546 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
548 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
549 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
552 let mayStore = 1 in {
553 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
555 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
556 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
558 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
560 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
561 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
565 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
566 def PUSHi8 : Ii8<0x6a, RawFrm, (outs), (ins i32i8imm:$imm),
567 "push{l}\t$imm", []>;
568 def PUSHi16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
569 "push{w}\t$imm", []>, OpSize;
570 def PUSHi32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
571 "push{l}\t$imm", []>;
574 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
575 def POPF16 : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
576 def POPF32 : I<0x9D, RawFrm, (outs), (ins), "popf{l|d}", []>,
577 Requires<[In32BitMode]>;
579 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
580 def PUSHF16 : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
581 def PUSHF32 : I<0x9C, RawFrm, (outs), (ins), "pushf{l|d}", []>,
582 Requires<[In32BitMode]>;
585 let Defs = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP], Uses = [ESP],
586 mayLoad=1, neverHasSideEffects=1 in {
587 def POPA32 : I<0x61, RawFrm, (outs), (ins), "popa{l}", []>,
588 Requires<[In32BitMode]>;
590 let Defs = [ESP], Uses = [EDI, ESI, EBP, EBX, EDX, ECX, EAX, ESP],
591 mayStore=1, neverHasSideEffects=1 in {
592 def PUSHA32 : I<0x60, RawFrm, (outs), (ins), "pusha{l}", []>,
593 Requires<[In32BitMode]>;
596 let Uses = [EFLAGS], Constraints = "$src = $dst" in // GR32 = bswap GR32
597 def BSWAP32r : I<0xC8, AddRegFrm,
598 (outs GR32:$dst), (ins GR32:$src),
600 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
603 // Bit scan instructions.
604 let Defs = [EFLAGS] in {
605 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
606 "bsf{w}\t{$src, $dst|$dst, $src}",
607 [(set GR16:$dst, EFLAGS, (X86bsf GR16:$src))]>, TB, OpSize;
608 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
609 "bsf{w}\t{$src, $dst|$dst, $src}",
610 [(set GR16:$dst, EFLAGS, (X86bsf (loadi16 addr:$src)))]>, TB,
612 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
613 "bsf{l}\t{$src, $dst|$dst, $src}",
614 [(set GR32:$dst, EFLAGS, (X86bsf GR32:$src))]>, TB;
615 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
616 "bsf{l}\t{$src, $dst|$dst, $src}",
617 [(set GR32:$dst, EFLAGS, (X86bsf (loadi32 addr:$src)))]>, TB;
619 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
620 "bsr{w}\t{$src, $dst|$dst, $src}",
621 [(set GR16:$dst, EFLAGS, (X86bsr GR16:$src))]>, TB, OpSize;
622 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
623 "bsr{w}\t{$src, $dst|$dst, $src}",
624 [(set GR16:$dst, EFLAGS, (X86bsr (loadi16 addr:$src)))]>, TB,
626 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
627 "bsr{l}\t{$src, $dst|$dst, $src}",
628 [(set GR32:$dst, EFLAGS, (X86bsr GR32:$src))]>, TB;
629 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
630 "bsr{l}\t{$src, $dst|$dst, $src}",
631 [(set GR32:$dst, EFLAGS, (X86bsr (loadi32 addr:$src)))]>, TB;
634 let neverHasSideEffects = 1 in
635 def LEA16r : I<0x8D, MRMSrcMem,
636 (outs GR16:$dst), (ins i32mem:$src),
637 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
638 let isReMaterializable = 1 in
639 def LEA32r : I<0x8D, MRMSrcMem,
640 (outs GR32:$dst), (ins i32mem:$src),
641 "lea{l}\t{$src|$dst}, {$dst|$src}",
642 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
645 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
646 let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
647 def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
648 def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
649 def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
650 def MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "movsq", []>;
653 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
654 let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
655 def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
656 let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
657 def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
658 let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
659 def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
660 let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI,EFLAGS] in
661 def STOSQ : RI<0xAB, RawFrm, (outs), (ins), "stosq", []>;
663 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
664 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
665 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
666 def SCAS64 : RI<0xAF, RawFrm, (outs), (ins), "scasq", []>;
668 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
669 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
670 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
671 def CMPS64 : RI<0xA7, RawFrm, (outs), (ins), "cmpsq", []>;
674 //===----------------------------------------------------------------------===//
675 // Move Instructions.
677 let neverHasSideEffects = 1 in {
678 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
679 "mov{b}\t{$src, $dst|$dst, $src}", []>;
680 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
681 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
682 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
683 "mov{l}\t{$src, $dst|$dst, $src}", []>;
685 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
686 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
687 "mov{b}\t{$src, $dst|$dst, $src}",
688 [(set GR8:$dst, imm:$src)]>;
689 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
690 "mov{w}\t{$src, $dst|$dst, $src}",
691 [(set GR16:$dst, imm:$src)]>, OpSize;
692 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
693 "mov{l}\t{$src, $dst|$dst, $src}",
694 [(set GR32:$dst, imm:$src)]>;
697 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
698 "mov{b}\t{$src, $dst|$dst, $src}",
699 [(store (i8 imm:$src), addr:$dst)]>;
700 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
701 "mov{w}\t{$src, $dst|$dst, $src}",
702 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
703 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
704 "mov{l}\t{$src, $dst|$dst, $src}",
705 [(store (i32 imm:$src), addr:$dst)]>;
707 /// moffs8, moffs16 and moffs32 versions of moves. The immediate is a
708 /// 32-bit offset from the PC. These are only valid in x86-32 mode.
709 def MOV8o8a : Ii32 <0xA0, RawFrm, (outs), (ins offset8:$src),
710 "mov{b}\t{$src, %al|%al, $src}", []>,
711 Requires<[In32BitMode]>;
712 def MOV16o16a : Ii32 <0xA1, RawFrm, (outs), (ins offset16:$src),
713 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize,
714 Requires<[In32BitMode]>;
715 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
716 "mov{l}\t{$src, %eax|%eax, $src}", []>,
717 Requires<[In32BitMode]>;
718 def MOV8ao8 : Ii32 <0xA2, RawFrm, (outs offset8:$dst), (ins),
719 "mov{b}\t{%al, $dst|$dst, %al}", []>,
720 Requires<[In32BitMode]>;
721 def MOV16ao16 : Ii32 <0xA3, RawFrm, (outs offset16:$dst), (ins),
722 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize,
723 Requires<[In32BitMode]>;
724 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
725 "mov{l}\t{%eax, $dst|$dst, %eax}", []>,
726 Requires<[In32BitMode]>;
729 let isCodeGenOnly = 1 in {
730 def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
731 "mov{b}\t{$src, $dst|$dst, $src}", []>;
732 def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
733 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
734 def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
735 "mov{l}\t{$src, $dst|$dst, $src}", []>;
738 let canFoldAsLoad = 1, isReMaterializable = 1 in {
739 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
740 "mov{b}\t{$src, $dst|$dst, $src}",
741 [(set GR8:$dst, (loadi8 addr:$src))]>;
742 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
743 "mov{w}\t{$src, $dst|$dst, $src}",
744 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
745 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
746 "mov{l}\t{$src, $dst|$dst, $src}",
747 [(set GR32:$dst, (loadi32 addr:$src))]>;
750 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
751 "mov{b}\t{$src, $dst|$dst, $src}",
752 [(store GR8:$src, addr:$dst)]>;
753 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
754 "mov{w}\t{$src, $dst|$dst, $src}",
755 [(store GR16:$src, addr:$dst)]>, OpSize;
756 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
757 "mov{l}\t{$src, $dst|$dst, $src}",
758 [(store GR32:$src, addr:$dst)]>;
760 /// Versions of MOV32rr, MOV32rm, and MOV32mr for i32mem_TC and GR32_TC.
761 let isCodeGenOnly = 1 in {
762 let neverHasSideEffects = 1 in
763 def MOV32rr_TC : I<0x89, MRMDestReg, (outs GR32_TC:$dst), (ins GR32_TC:$src),
764 "mov{l}\t{$src, $dst|$dst, $src}", []>;
767 canFoldAsLoad = 1, isReMaterializable = 1 in
768 def MOV32rm_TC : I<0x8B, MRMSrcMem, (outs GR32_TC:$dst), (ins i32mem_TC:$src),
769 "mov{l}\t{$src, $dst|$dst, $src}",
773 def MOV32mr_TC : I<0x89, MRMDestMem, (outs), (ins i32mem_TC:$dst, GR32_TC:$src),
774 "mov{l}\t{$src, $dst|$dst, $src}",
778 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
779 // that they can be used for copying and storing h registers, which can't be
780 // encoded when a REX prefix is present.
781 let isCodeGenOnly = 1 in {
782 let neverHasSideEffects = 1 in
783 def MOV8rr_NOREX : I<0x88, MRMDestReg,
784 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
785 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
787 def MOV8mr_NOREX : I<0x88, MRMDestMem,
788 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
789 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
791 canFoldAsLoad = 1, isReMaterializable = 1 in
792 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
793 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
794 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
797 //===----------------------------------------------------------------------===//
798 // Fixed-Register Multiplication and Division Instructions...
801 // Extra precision multiplication
803 // AL is really implied by AX, but the registers in Defs must match the
804 // SDNode results (i8, i32).
805 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
806 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
807 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
808 // This probably ought to be moved to a def : Pat<> if the
809 // syntax can be accepted.
810 [(set AL, (mul AL, GR8:$src)),
811 (implicit EFLAGS)]>; // AL,AH = AL*GR8
813 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
814 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
816 []>, OpSize; // AX,DX = AX*GR16
818 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
819 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
821 []>; // EAX,EDX = EAX*GR32
823 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
824 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
826 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
827 // This probably ought to be moved to a def : Pat<> if the
828 // syntax can be accepted.
829 [(set AL, (mul AL, (loadi8 addr:$src))),
830 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
832 let mayLoad = 1, neverHasSideEffects = 1 in {
833 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
834 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
836 []>, OpSize; // AX,DX = AX*[mem16]
838 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
839 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
841 []>; // EAX,EDX = EAX*[mem32]
844 let neverHasSideEffects = 1 in {
845 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
846 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
848 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
849 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
850 OpSize; // AX,DX = AX*GR16
851 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
852 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
853 // EAX,EDX = EAX*GR32
855 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
856 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
857 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
858 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
859 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
860 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
861 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
862 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
863 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
865 } // neverHasSideEffects
867 // unsigned division/remainder
868 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
869 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
871 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
872 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
873 "div{w}\t$src", []>, OpSize;
874 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
875 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
878 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
879 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
881 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
882 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
883 "div{w}\t$src", []>, OpSize;
884 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
885 // EDX:EAX/[mem32] = EAX,EDX
886 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
890 // Signed division/remainder.
891 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
892 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
893 "idiv{b}\t$src", []>;
894 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
895 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
896 "idiv{w}\t$src", []>, OpSize;
897 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
898 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
899 "idiv{l}\t$src", []>;
900 let mayLoad = 1, mayLoad = 1 in {
901 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
902 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
903 "idiv{b}\t$src", []>;
904 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
905 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
906 "idiv{w}\t$src", []>, OpSize;
907 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
908 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
909 // EDX:EAX/[mem32] = EAX,EDX
910 "idiv{l}\t$src", []>;
913 //===----------------------------------------------------------------------===//
914 // Two address Instructions.
916 let Constraints = "$src1 = $dst" in {
919 let Uses = [EFLAGS] in {
921 let Predicates = [HasCMov] in {
922 let isCommutable = 1 in {
923 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
924 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
925 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
926 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
927 X86_COND_B, EFLAGS))]>,
929 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
930 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
931 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
932 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
933 X86_COND_B, EFLAGS))]>,
935 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
936 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
937 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
938 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
939 X86_COND_AE, EFLAGS))]>,
941 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
942 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
943 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
944 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
945 X86_COND_AE, EFLAGS))]>,
947 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
948 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
949 "cmove{w}\t{$src2, $dst|$dst, $src2}",
950 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
951 X86_COND_E, EFLAGS))]>,
953 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
954 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
955 "cmove{l}\t{$src2, $dst|$dst, $src2}",
956 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
957 X86_COND_E, EFLAGS))]>,
959 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
960 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
961 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
962 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
963 X86_COND_NE, EFLAGS))]>,
965 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
966 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
967 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
968 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
969 X86_COND_NE, EFLAGS))]>,
971 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
972 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
973 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
974 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
975 X86_COND_BE, EFLAGS))]>,
977 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
978 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
979 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
980 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
981 X86_COND_BE, EFLAGS))]>,
983 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
984 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
985 "cmova{w}\t{$src2, $dst|$dst, $src2}",
986 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
987 X86_COND_A, EFLAGS))]>,
989 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
990 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
991 "cmova{l}\t{$src2, $dst|$dst, $src2}",
992 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
993 X86_COND_A, EFLAGS))]>,
995 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
996 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
997 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
998 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
999 X86_COND_L, EFLAGS))]>,
1001 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1002 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1003 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1004 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1005 X86_COND_L, EFLAGS))]>,
1007 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1008 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1009 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1010 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1011 X86_COND_GE, EFLAGS))]>,
1013 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1014 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1015 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1016 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1017 X86_COND_GE, EFLAGS))]>,
1019 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1020 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1021 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1022 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1023 X86_COND_LE, EFLAGS))]>,
1025 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1026 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1027 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1028 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1029 X86_COND_LE, EFLAGS))]>,
1031 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1032 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1033 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1034 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1035 X86_COND_G, EFLAGS))]>,
1037 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1038 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1039 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1040 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1041 X86_COND_G, EFLAGS))]>,
1043 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1044 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1045 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1046 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1047 X86_COND_S, EFLAGS))]>,
1049 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1050 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1051 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1052 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1053 X86_COND_S, EFLAGS))]>,
1055 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1056 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1057 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1058 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1059 X86_COND_NS, EFLAGS))]>,
1061 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1062 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1063 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1064 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1065 X86_COND_NS, EFLAGS))]>,
1067 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1068 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1069 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1070 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1071 X86_COND_P, EFLAGS))]>,
1073 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1074 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1075 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1076 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1077 X86_COND_P, EFLAGS))]>,
1079 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1080 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1081 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1082 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1083 X86_COND_NP, EFLAGS))]>,
1085 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1086 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1087 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1088 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1089 X86_COND_NP, EFLAGS))]>,
1091 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1092 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1093 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1094 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1095 X86_COND_O, EFLAGS))]>,
1097 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1098 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1099 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1100 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1101 X86_COND_O, EFLAGS))]>,
1103 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1104 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1105 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1106 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1107 X86_COND_NO, EFLAGS))]>,
1109 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1110 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1111 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1112 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1113 X86_COND_NO, EFLAGS))]>,
1115 } // isCommutable = 1
1117 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1118 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1119 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1120 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1121 X86_COND_B, EFLAGS))]>,
1123 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1124 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1125 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1126 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1127 X86_COND_B, EFLAGS))]>,
1129 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1130 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1131 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1132 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1133 X86_COND_AE, EFLAGS))]>,
1135 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1136 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1137 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1138 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1139 X86_COND_AE, EFLAGS))]>,
1141 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1142 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1143 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1144 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1145 X86_COND_E, EFLAGS))]>,
1147 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1148 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1149 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1150 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1151 X86_COND_E, EFLAGS))]>,
1153 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1154 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1155 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1156 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1157 X86_COND_NE, EFLAGS))]>,
1159 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1160 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1161 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1162 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1163 X86_COND_NE, EFLAGS))]>,
1165 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1166 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1167 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1168 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1169 X86_COND_BE, EFLAGS))]>,
1171 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1172 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1173 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1174 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1175 X86_COND_BE, EFLAGS))]>,
1177 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1178 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1179 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1180 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1181 X86_COND_A, EFLAGS))]>,
1183 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1184 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1185 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1186 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1187 X86_COND_A, EFLAGS))]>,
1189 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1190 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1191 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1192 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1193 X86_COND_L, EFLAGS))]>,
1195 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1196 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1197 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1198 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1199 X86_COND_L, EFLAGS))]>,
1201 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1202 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1203 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1204 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1205 X86_COND_GE, EFLAGS))]>,
1207 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1208 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1209 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1210 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1211 X86_COND_GE, EFLAGS))]>,
1213 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1214 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1215 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1216 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1217 X86_COND_LE, EFLAGS))]>,
1219 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1220 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1221 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1222 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1223 X86_COND_LE, EFLAGS))]>,
1225 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1226 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1227 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1228 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1229 X86_COND_G, EFLAGS))]>,
1231 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1232 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1233 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1234 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1235 X86_COND_G, EFLAGS))]>,
1237 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1238 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1239 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1240 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1241 X86_COND_S, EFLAGS))]>,
1243 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1244 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1245 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1246 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1247 X86_COND_S, EFLAGS))]>,
1249 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1250 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1251 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1252 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1253 X86_COND_NS, EFLAGS))]>,
1255 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1256 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1257 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1258 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1259 X86_COND_NS, EFLAGS))]>,
1261 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1262 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1263 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1264 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1265 X86_COND_P, EFLAGS))]>,
1267 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1268 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1269 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1270 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1271 X86_COND_P, EFLAGS))]>,
1273 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1274 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1275 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1276 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1277 X86_COND_NP, EFLAGS))]>,
1279 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1280 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1281 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1282 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1283 X86_COND_NP, EFLAGS))]>,
1285 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1286 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1287 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1288 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1289 X86_COND_O, EFLAGS))]>,
1291 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1292 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1293 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1294 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1295 X86_COND_O, EFLAGS))]>,
1297 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1298 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1299 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1300 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1301 X86_COND_NO, EFLAGS))]>,
1303 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1304 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1305 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1306 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1307 X86_COND_NO, EFLAGS))]>,
1309 } // Predicates = [HasCMov]
1311 // X86 doesn't have 8-bit conditional moves. Use a customInserter to
1312 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1313 // however that requires promoting the operands, and can induce additional
1314 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1315 // clobber EFLAGS, because if one of the operands is zero, the expansion
1316 // could involve an xor.
1317 let usesCustomInserter = 1, Constraints = "", Defs = [EFLAGS] in {
1318 def CMOV_GR8 : I<0, Pseudo,
1319 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1320 "#CMOV_GR8 PSEUDO!",
1321 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1322 imm:$cond, EFLAGS))]>;
1324 let Predicates = [NoCMov] in {
1325 def CMOV_GR32 : I<0, Pseudo,
1326 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond),
1327 "#CMOV_GR32* PSEUDO!",
1329 (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>;
1330 def CMOV_GR16 : I<0, Pseudo,
1331 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond),
1332 "#CMOV_GR16* PSEUDO!",
1334 (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>;
1335 def CMOV_RFP32 : I<0, Pseudo,
1337 (ins RFP32:$src1, RFP32:$src2, i8imm:$cond),
1338 "#CMOV_RFP32 PSEUDO!",
1340 (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond,
1342 def CMOV_RFP64 : I<0, Pseudo,
1344 (ins RFP64:$src1, RFP64:$src2, i8imm:$cond),
1345 "#CMOV_RFP64 PSEUDO!",
1347 (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond,
1349 def CMOV_RFP80 : I<0, Pseudo,
1351 (ins RFP80:$src1, RFP80:$src2, i8imm:$cond),
1352 "#CMOV_RFP80 PSEUDO!",
1354 (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond,
1356 } // Predicates = [NoCMov]
1357 } // UsesCustomInserter = 1, Constraints = "", Defs = [EFLAGS]
1358 } // Uses = [EFLAGS]
1361 // unary instructions
1362 let CodeSize = 2 in {
1363 let Defs = [EFLAGS] in {
1364 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src1),
1366 [(set GR8:$dst, (ineg GR8:$src1)),
1367 (implicit EFLAGS)]>;
1368 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
1370 [(set GR16:$dst, (ineg GR16:$src1)),
1371 (implicit EFLAGS)]>, OpSize;
1372 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
1374 [(set GR32:$dst, (ineg GR32:$src1)),
1375 (implicit EFLAGS)]>;
1377 let Constraints = "" in {
1378 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst),
1380 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1381 (implicit EFLAGS)]>;
1382 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst),
1384 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1385 (implicit EFLAGS)]>, OpSize;
1386 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst),
1388 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1389 (implicit EFLAGS)]>;
1390 } // Constraints = ""
1391 } // Defs = [EFLAGS]
1393 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1394 let AddedComplexity = 15 in {
1395 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src1),
1397 [(set GR8:$dst, (not GR8:$src1))]>;
1398 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
1400 [(set GR16:$dst, (not GR16:$src1))]>, OpSize;
1401 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
1403 [(set GR32:$dst, (not GR32:$src1))]>;
1405 let Constraints = "" in {
1406 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst),
1408 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1409 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst),
1411 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1412 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst),
1414 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1415 } // Constraints = ""
1418 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1419 let Defs = [EFLAGS] in {
1421 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1423 [(set GR8:$dst, EFLAGS, (X86inc_flag GR8:$src1))]>;
1425 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1426 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1428 [(set GR16:$dst, EFLAGS, (X86inc_flag GR16:$src1))]>,
1429 OpSize, Requires<[In32BitMode]>;
1430 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1432 [(set GR32:$dst, EFLAGS, (X86inc_flag GR32:$src1))]>,
1433 Requires<[In32BitMode]>;
1435 let Constraints = "", CodeSize = 2 in {
1436 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1437 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1438 (implicit EFLAGS)]>;
1439 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1440 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1441 (implicit EFLAGS)]>,
1442 OpSize, Requires<[In32BitMode]>;
1443 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1444 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1445 (implicit EFLAGS)]>,
1446 Requires<[In32BitMode]>;
1447 } // Constraints = "", CodeSize = 2
1450 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1452 [(set GR8:$dst, EFLAGS, (X86dec_flag GR8:$src1))]>;
1453 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1454 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src1),
1456 [(set GR16:$dst, EFLAGS, (X86dec_flag GR16:$src1))]>,
1457 OpSize, Requires<[In32BitMode]>;
1458 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src1),
1460 [(set GR32:$dst, EFLAGS, (X86dec_flag GR32:$src1))]>,
1461 Requires<[In32BitMode]>;
1464 let Constraints = "", CodeSize = 2 in {
1465 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1466 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1467 (implicit EFLAGS)]>;
1468 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1469 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1470 (implicit EFLAGS)]>,
1471 OpSize, Requires<[In32BitMode]>;
1472 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1473 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1474 (implicit EFLAGS)]>,
1475 Requires<[In32BitMode]>;
1476 } // Constraints = "", CodeSize = 2
1477 } // Defs = [EFLAGS]
1479 // Logical operators...
1480 let Defs = [EFLAGS] in {
1481 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1482 def AND8rr : I<0x20, MRMDestReg,
1483 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1484 "and{b}\t{$src2, $dst|$dst, $src2}",
1485 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1, GR8:$src2))]>;
1486 def AND16rr : I<0x21, MRMDestReg,
1487 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1488 "and{w}\t{$src2, $dst|$dst, $src2}",
1489 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1490 GR16:$src2))]>, OpSize;
1491 def AND32rr : I<0x21, MRMDestReg,
1492 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1493 "and{l}\t{$src2, $dst|$dst, $src2}",
1494 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1498 // AND instructions with the destination register in REG and the source register
1499 // in R/M. Included for the disassembler.
1500 let isCodeGenOnly = 1 in {
1501 def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1502 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1503 def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1504 (ins GR16:$src1, GR16:$src2),
1505 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1506 def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1507 (ins GR32:$src1, GR32:$src2),
1508 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1511 def AND8rm : I<0x22, MRMSrcMem,
1512 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1513 "and{b}\t{$src2, $dst|$dst, $src2}",
1514 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1515 (loadi8 addr:$src2)))]>;
1516 def AND16rm : I<0x23, MRMSrcMem,
1517 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1518 "and{w}\t{$src2, $dst|$dst, $src2}",
1519 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1520 (loadi16 addr:$src2)))]>,
1522 def AND32rm : I<0x23, MRMSrcMem,
1523 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1524 "and{l}\t{$src2, $dst|$dst, $src2}",
1525 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1526 (loadi32 addr:$src2)))]>;
1528 def AND8ri : Ii8<0x80, MRM4r,
1529 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1530 "and{b}\t{$src2, $dst|$dst, $src2}",
1531 [(set GR8:$dst, EFLAGS, (X86and_flag GR8:$src1,
1533 def AND16ri : Ii16<0x81, MRM4r,
1534 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1535 "and{w}\t{$src2, $dst|$dst, $src2}",
1536 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1537 imm:$src2))]>, OpSize;
1538 def AND32ri : Ii32<0x81, MRM4r,
1539 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1540 "and{l}\t{$src2, $dst|$dst, $src2}",
1541 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1543 def AND16ri8 : Ii8<0x83, MRM4r,
1544 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1545 "and{w}\t{$src2, $dst|$dst, $src2}",
1546 [(set GR16:$dst, EFLAGS, (X86and_flag GR16:$src1,
1547 i16immSExt8:$src2))]>,
1549 def AND32ri8 : Ii8<0x83, MRM4r,
1550 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1551 "and{l}\t{$src2, $dst|$dst, $src2}",
1552 [(set GR32:$dst, EFLAGS, (X86and_flag GR32:$src1,
1553 i32immSExt8:$src2))]>;
1555 let Constraints = "" in {
1556 def AND8mr : I<0x20, MRMDestMem,
1557 (outs), (ins i8mem :$dst, GR8 :$src),
1558 "and{b}\t{$src, $dst|$dst, $src}",
1559 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1560 (implicit EFLAGS)]>;
1561 def AND16mr : I<0x21, MRMDestMem,
1562 (outs), (ins i16mem:$dst, GR16:$src),
1563 "and{w}\t{$src, $dst|$dst, $src}",
1564 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1565 (implicit EFLAGS)]>,
1567 def AND32mr : I<0x21, MRMDestMem,
1568 (outs), (ins i32mem:$dst, GR32:$src),
1569 "and{l}\t{$src, $dst|$dst, $src}",
1570 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1571 (implicit EFLAGS)]>;
1572 def AND8mi : Ii8<0x80, MRM4m,
1573 (outs), (ins i8mem :$dst, i8imm :$src),
1574 "and{b}\t{$src, $dst|$dst, $src}",
1575 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1576 (implicit EFLAGS)]>;
1577 def AND16mi : Ii16<0x81, MRM4m,
1578 (outs), (ins i16mem:$dst, i16imm:$src),
1579 "and{w}\t{$src, $dst|$dst, $src}",
1580 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1581 (implicit EFLAGS)]>,
1583 def AND32mi : Ii32<0x81, MRM4m,
1584 (outs), (ins i32mem:$dst, i32imm:$src),
1585 "and{l}\t{$src, $dst|$dst, $src}",
1586 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1587 (implicit EFLAGS)]>;
1588 def AND16mi8 : Ii8<0x83, MRM4m,
1589 (outs), (ins i16mem:$dst, i16i8imm :$src),
1590 "and{w}\t{$src, $dst|$dst, $src}",
1591 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1592 (implicit EFLAGS)]>,
1594 def AND32mi8 : Ii8<0x83, MRM4m,
1595 (outs), (ins i32mem:$dst, i32i8imm :$src),
1596 "and{l}\t{$src, $dst|$dst, $src}",
1597 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1598 (implicit EFLAGS)]>;
1600 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1601 "and{b}\t{$src, %al|%al, $src}", []>;
1602 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1603 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1604 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1605 "and{l}\t{$src, %eax|%eax, $src}", []>;
1607 } // Constraints = ""
1610 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1611 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1612 (ins GR8 :$src1, GR8 :$src2),
1613 "or{b}\t{$src2, $dst|$dst, $src2}",
1614 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1, GR8:$src2))]>;
1615 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1616 (ins GR16:$src1, GR16:$src2),
1617 "or{w}\t{$src2, $dst|$dst, $src2}",
1618 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,GR16:$src2))]>,
1620 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1621 (ins GR32:$src1, GR32:$src2),
1622 "or{l}\t{$src2, $dst|$dst, $src2}",
1623 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,GR32:$src2))]>;
1626 // OR instructions with the destination register in REG and the source register
1627 // in R/M. Included for the disassembler.
1628 let isCodeGenOnly = 1 in {
1629 def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1630 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1631 def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1632 (ins GR16:$src1, GR16:$src2),
1633 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1634 def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1635 (ins GR32:$src1, GR32:$src2),
1636 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1639 def OR8rm : I<0x0A, MRMSrcMem, (outs GR8 :$dst),
1640 (ins GR8 :$src1, i8mem :$src2),
1641 "or{b}\t{$src2, $dst|$dst, $src2}",
1642 [(set GR8:$dst, EFLAGS, (X86or_flag GR8:$src1,
1643 (load addr:$src2)))]>;
1644 def OR16rm : I<0x0B, MRMSrcMem, (outs GR16:$dst),
1645 (ins GR16:$src1, i16mem:$src2),
1646 "or{w}\t{$src2, $dst|$dst, $src2}",
1647 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1648 (load addr:$src2)))]>,
1650 def OR32rm : I<0x0B, MRMSrcMem, (outs GR32:$dst),
1651 (ins GR32:$src1, i32mem:$src2),
1652 "or{l}\t{$src2, $dst|$dst, $src2}",
1653 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1654 (load addr:$src2)))]>;
1656 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1657 (ins GR8 :$src1, i8imm:$src2),
1658 "or{b}\t{$src2, $dst|$dst, $src2}",
1659 [(set GR8:$dst,EFLAGS, (X86or_flag GR8:$src1, imm:$src2))]>;
1660 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1661 (ins GR16:$src1, i16imm:$src2),
1662 "or{w}\t{$src2, $dst|$dst, $src2}",
1663 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1664 imm:$src2))]>, OpSize;
1665 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1666 (ins GR32:$src1, i32imm:$src2),
1667 "or{l}\t{$src2, $dst|$dst, $src2}",
1668 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1671 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1672 (ins GR16:$src1, i16i8imm:$src2),
1673 "or{w}\t{$src2, $dst|$dst, $src2}",
1674 [(set GR16:$dst, EFLAGS, (X86or_flag GR16:$src1,
1675 i16immSExt8:$src2))]>, OpSize;
1676 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1677 (ins GR32:$src1, i32i8imm:$src2),
1678 "or{l}\t{$src2, $dst|$dst, $src2}",
1679 [(set GR32:$dst, EFLAGS, (X86or_flag GR32:$src1,
1680 i32immSExt8:$src2))]>;
1681 let Constraints = "" in {
1682 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1683 "or{b}\t{$src, $dst|$dst, $src}",
1684 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1685 (implicit EFLAGS)]>;
1686 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1687 "or{w}\t{$src, $dst|$dst, $src}",
1688 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1689 (implicit EFLAGS)]>, OpSize;
1690 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1691 "or{l}\t{$src, $dst|$dst, $src}",
1692 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1693 (implicit EFLAGS)]>;
1694 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1695 "or{b}\t{$src, $dst|$dst, $src}",
1696 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1697 (implicit EFLAGS)]>;
1698 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1699 "or{w}\t{$src, $dst|$dst, $src}",
1700 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1701 (implicit EFLAGS)]>,
1703 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1704 "or{l}\t{$src, $dst|$dst, $src}",
1705 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1706 (implicit EFLAGS)]>;
1707 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1708 "or{w}\t{$src, $dst|$dst, $src}",
1709 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1710 (implicit EFLAGS)]>,
1712 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1713 "or{l}\t{$src, $dst|$dst, $src}",
1714 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1715 (implicit EFLAGS)]>;
1717 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1718 "or{b}\t{$src, %al|%al, $src}", []>;
1719 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1720 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1721 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1722 "or{l}\t{$src, %eax|%eax, $src}", []>;
1723 } // Constraints = ""
1726 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1727 def XOR8rr : I<0x30, MRMDestReg,
1728 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1729 "xor{b}\t{$src2, $dst|$dst, $src2}",
1730 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
1732 def XOR16rr : I<0x31, MRMDestReg,
1733 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1734 "xor{w}\t{$src2, $dst|$dst, $src2}",
1735 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
1736 GR16:$src2))]>, OpSize;
1737 def XOR32rr : I<0x31, MRMDestReg,
1738 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1739 "xor{l}\t{$src2, $dst|$dst, $src2}",
1740 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
1742 } // isCommutable = 1
1744 // XOR instructions with the destination register in REG and the source register
1745 // in R/M. Included for the disassembler.
1746 let isCodeGenOnly = 1 in {
1747 def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1748 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1749 def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1750 (ins GR16:$src1, GR16:$src2),
1751 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1752 def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1753 (ins GR32:$src1, GR32:$src2),
1754 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1757 def XOR8rm : I<0x32, MRMSrcMem,
1758 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1759 "xor{b}\t{$src2, $dst|$dst, $src2}",
1760 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1,
1761 (load addr:$src2)))]>;
1762 def XOR16rm : I<0x33, MRMSrcMem,
1763 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1764 "xor{w}\t{$src2, $dst|$dst, $src2}",
1765 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
1766 (load addr:$src2)))]>,
1768 def XOR32rm : I<0x33, MRMSrcMem,
1769 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1770 "xor{l}\t{$src2, $dst|$dst, $src2}",
1771 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
1772 (load addr:$src2)))]>;
1774 def XOR8ri : Ii8<0x80, MRM6r,
1775 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1776 "xor{b}\t{$src2, $dst|$dst, $src2}",
1777 [(set GR8:$dst, EFLAGS, (X86xor_flag GR8:$src1, imm:$src2))]>;
1778 def XOR16ri : Ii16<0x81, MRM6r,
1779 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1780 "xor{w}\t{$src2, $dst|$dst, $src2}",
1781 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
1782 imm:$src2))]>, OpSize;
1783 def XOR32ri : Ii32<0x81, MRM6r,
1784 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1785 "xor{l}\t{$src2, $dst|$dst, $src2}",
1786 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
1788 def XOR16ri8 : Ii8<0x83, MRM6r,
1789 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1790 "xor{w}\t{$src2, $dst|$dst, $src2}",
1791 [(set GR16:$dst, EFLAGS, (X86xor_flag GR16:$src1,
1792 i16immSExt8:$src2))]>,
1794 def XOR32ri8 : Ii8<0x83, MRM6r,
1795 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1796 "xor{l}\t{$src2, $dst|$dst, $src2}",
1797 [(set GR32:$dst, EFLAGS, (X86xor_flag GR32:$src1,
1798 i32immSExt8:$src2))]>;
1800 let Constraints = "" in {
1801 def XOR8mr : I<0x30, MRMDestMem,
1802 (outs), (ins i8mem :$dst, GR8 :$src),
1803 "xor{b}\t{$src, $dst|$dst, $src}",
1804 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1805 (implicit EFLAGS)]>;
1806 def XOR16mr : I<0x31, MRMDestMem,
1807 (outs), (ins i16mem:$dst, GR16:$src),
1808 "xor{w}\t{$src, $dst|$dst, $src}",
1809 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1810 (implicit EFLAGS)]>,
1812 def XOR32mr : I<0x31, MRMDestMem,
1813 (outs), (ins i32mem:$dst, GR32:$src),
1814 "xor{l}\t{$src, $dst|$dst, $src}",
1815 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1816 (implicit EFLAGS)]>;
1817 def XOR8mi : Ii8<0x80, MRM6m,
1818 (outs), (ins i8mem :$dst, i8imm :$src),
1819 "xor{b}\t{$src, $dst|$dst, $src}",
1820 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1821 (implicit EFLAGS)]>;
1822 def XOR16mi : Ii16<0x81, MRM6m,
1823 (outs), (ins i16mem:$dst, i16imm:$src),
1824 "xor{w}\t{$src, $dst|$dst, $src}",
1825 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1826 (implicit EFLAGS)]>,
1828 def XOR32mi : Ii32<0x81, MRM6m,
1829 (outs), (ins i32mem:$dst, i32imm:$src),
1830 "xor{l}\t{$src, $dst|$dst, $src}",
1831 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1832 (implicit EFLAGS)]>;
1833 def XOR16mi8 : Ii8<0x83, MRM6m,
1834 (outs), (ins i16mem:$dst, i16i8imm :$src),
1835 "xor{w}\t{$src, $dst|$dst, $src}",
1836 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1837 (implicit EFLAGS)]>,
1839 def XOR32mi8 : Ii8<0x83, MRM6m,
1840 (outs), (ins i32mem:$dst, i32i8imm :$src),
1841 "xor{l}\t{$src, $dst|$dst, $src}",
1842 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1843 (implicit EFLAGS)]>;
1845 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1846 "xor{b}\t{$src, %al|%al, $src}", []>;
1847 def XOR16i16 : Ii16<0x35, RawFrm, (outs), (ins i16imm:$src),
1848 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1849 def XOR32i32 : Ii32<0x35, RawFrm, (outs), (ins i32imm:$src),
1850 "xor{l}\t{$src, %eax|%eax, $src}", []>;
1851 } // Constraints = ""
1852 } // Defs = [EFLAGS]
1854 // Shift instructions
1855 let Defs = [EFLAGS] in {
1856 let Uses = [CL] in {
1857 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
1858 "shl{b}\t{%cl, $dst|$dst, CL}",
1859 [(set GR8:$dst, (shl GR8:$src1, CL))]>;
1860 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1861 "shl{w}\t{%cl, $dst|$dst, CL}",
1862 [(set GR16:$dst, (shl GR16:$src1, CL))]>, OpSize;
1863 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1864 "shl{l}\t{%cl, $dst|$dst, CL}",
1865 [(set GR32:$dst, (shl GR32:$src1, CL))]>;
1868 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1869 "shl{b}\t{$src2, $dst|$dst, $src2}",
1870 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1872 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1873 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1874 "shl{w}\t{$src2, $dst|$dst, $src2}",
1875 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1876 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1877 "shl{l}\t{$src2, $dst|$dst, $src2}",
1878 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1880 // NOTE: We don't include patterns for shifts of a register by one, because
1881 // 'add reg,reg' is cheaper.
1883 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
1884 "shl{b}\t$dst", []>;
1885 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1886 "shl{w}\t$dst", []>, OpSize;
1887 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1888 "shl{l}\t$dst", []>;
1890 } // isConvertibleToThreeAddress = 1
1892 let Constraints = "" in {
1893 let Uses = [CL] in {
1894 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1895 "shl{b}\t{%cl, $dst|$dst, CL}",
1896 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1897 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1898 "shl{w}\t{%cl, $dst|$dst, CL}",
1899 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1900 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1901 "shl{l}\t{%cl, $dst|$dst, CL}",
1902 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1904 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1905 "shl{b}\t{$src, $dst|$dst, $src}",
1906 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1907 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1908 "shl{w}\t{$src, $dst|$dst, $src}",
1909 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1911 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1912 "shl{l}\t{$src, $dst|$dst, $src}",
1913 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1916 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1918 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1919 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1921 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1923 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1925 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1926 } // Constraints = ""
1928 let Uses = [CL] in {
1929 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src1),
1930 "shr{b}\t{%cl, $dst|$dst, CL}",
1931 [(set GR8:$dst, (srl GR8:$src1, CL))]>;
1932 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1933 "shr{w}\t{%cl, $dst|$dst, CL}",
1934 [(set GR16:$dst, (srl GR16:$src1, CL))]>, OpSize;
1935 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1936 "shr{l}\t{%cl, $dst|$dst, CL}",
1937 [(set GR32:$dst, (srl GR32:$src1, CL))]>;
1940 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1941 "shr{b}\t{$src2, $dst|$dst, $src2}",
1942 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1943 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1944 "shr{w}\t{$src2, $dst|$dst, $src2}",
1945 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1946 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1947 "shr{l}\t{$src2, $dst|$dst, $src2}",
1948 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1951 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1953 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1954 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1956 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1957 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1959 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1961 let Constraints = "" in {
1962 let Uses = [CL] in {
1963 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1964 "shr{b}\t{%cl, $dst|$dst, CL}",
1965 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1966 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1967 "shr{w}\t{%cl, $dst|$dst, CL}",
1968 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1970 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1971 "shr{l}\t{%cl, $dst|$dst, CL}",
1972 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1974 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1975 "shr{b}\t{$src, $dst|$dst, $src}",
1976 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1977 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1978 "shr{w}\t{$src, $dst|$dst, $src}",
1979 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1981 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1982 "shr{l}\t{$src, $dst|$dst, $src}",
1983 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1986 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1988 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1989 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1991 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1992 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1994 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1995 } // Constraints = ""
1997 let Uses = [CL] in {
1998 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1999 "sar{b}\t{%cl, $dst|$dst, CL}",
2000 [(set GR8:$dst, (sra GR8:$src1, CL))]>;
2001 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2002 "sar{w}\t{%cl, $dst|$dst, CL}",
2003 [(set GR16:$dst, (sra GR16:$src1, CL))]>, OpSize;
2004 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2005 "sar{l}\t{%cl, $dst|$dst, CL}",
2006 [(set GR32:$dst, (sra GR32:$src1, CL))]>;
2009 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2010 "sar{b}\t{$src2, $dst|$dst, $src2}",
2011 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2012 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2013 "sar{w}\t{$src2, $dst|$dst, $src2}",
2014 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2016 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2017 "sar{l}\t{$src2, $dst|$dst, $src2}",
2018 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2021 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2023 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2024 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2026 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2027 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2029 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2031 let Constraints = "" in {
2032 let Uses = [CL] in {
2033 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2034 "sar{b}\t{%cl, $dst|$dst, CL}",
2035 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2036 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2037 "sar{w}\t{%cl, $dst|$dst, CL}",
2038 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2039 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2040 "sar{l}\t{%cl, $dst|$dst, CL}",
2041 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2043 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2044 "sar{b}\t{$src, $dst|$dst, $src}",
2045 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2046 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2047 "sar{w}\t{$src, $dst|$dst, $src}",
2048 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2050 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2051 "sar{l}\t{$src, $dst|$dst, $src}",
2052 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2055 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2057 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2058 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2060 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2062 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2064 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2065 } // Constraints = ""
2067 // Rotate instructions
2069 def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
2070 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2071 let Uses = [CL] in {
2072 def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1),
2073 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2075 def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
2076 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2078 def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
2079 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2080 let Uses = [CL] in {
2081 def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1),
2082 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2084 def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
2085 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2087 def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
2088 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2089 let Uses = [CL] in {
2090 def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1),
2091 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2093 def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
2094 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2096 def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
2097 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2098 let Uses = [CL] in {
2099 def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1),
2100 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2102 def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt),
2103 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2105 def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
2106 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2107 let Uses = [CL] in {
2108 def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1),
2109 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2111 def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt),
2112 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2114 def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
2115 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2116 let Uses = [CL] in {
2117 def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1),
2118 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2120 def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt),
2121 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2123 let Constraints = "" in {
2124 def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2125 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2126 def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2127 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2128 def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2129 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2130 def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2131 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2132 def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2133 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2134 def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2135 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2136 def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2137 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2138 def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2139 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2140 def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2141 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2142 def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2143 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2144 def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2145 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2146 def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2147 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2149 let Uses = [CL] in {
2150 def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2151 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2152 def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2153 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2154 def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2155 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2156 def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2157 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2158 def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2159 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2160 def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2161 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2163 } // Constraints = ""
2165 // FIXME: provide shorter instructions when imm8 == 1
2166 let Uses = [CL] in {
2167 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2168 "rol{b}\t{%cl, $dst|$dst, CL}",
2169 [(set GR8:$dst, (rotl GR8:$src1, CL))]>;
2170 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2171 "rol{w}\t{%cl, $dst|$dst, CL}",
2172 [(set GR16:$dst, (rotl GR16:$src1, CL))]>, OpSize;
2173 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2174 "rol{l}\t{%cl, $dst|$dst, CL}",
2175 [(set GR32:$dst, (rotl GR32:$src1, CL))]>;
2178 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2179 "rol{b}\t{$src2, $dst|$dst, $src2}",
2180 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2181 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2182 "rol{w}\t{$src2, $dst|$dst, $src2}",
2183 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2185 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2186 "rol{l}\t{$src2, $dst|$dst, $src2}",
2187 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2190 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2192 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2193 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2195 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2196 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2198 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2200 let Constraints = "" in {
2201 let Uses = [CL] in {
2202 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2203 "rol{b}\t{%cl, $dst|$dst, CL}",
2204 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2205 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2206 "rol{w}\t{%cl, $dst|$dst, CL}",
2207 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2208 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2209 "rol{l}\t{%cl, $dst|$dst, CL}",
2210 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2212 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2213 "rol{b}\t{$src, $dst|$dst, $src}",
2214 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2215 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2216 "rol{w}\t{$src, $dst|$dst, $src}",
2217 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2219 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2220 "rol{l}\t{$src, $dst|$dst, $src}",
2221 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2224 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2226 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2227 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2229 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2231 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2233 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2234 } // Constraints = ""
2236 let Uses = [CL] in {
2237 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2238 "ror{b}\t{%cl, $dst|$dst, CL}",
2239 [(set GR8:$dst, (rotr GR8:$src1, CL))]>;
2240 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2241 "ror{w}\t{%cl, $dst|$dst, CL}",
2242 [(set GR16:$dst, (rotr GR16:$src1, CL))]>, OpSize;
2243 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2244 "ror{l}\t{%cl, $dst|$dst, CL}",
2245 [(set GR32:$dst, (rotr GR32:$src1, CL))]>;
2248 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2249 "ror{b}\t{$src2, $dst|$dst, $src2}",
2250 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2251 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2252 "ror{w}\t{$src2, $dst|$dst, $src2}",
2253 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2255 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2256 "ror{l}\t{$src2, $dst|$dst, $src2}",
2257 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2260 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2262 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2263 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2265 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2266 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2268 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2270 let Constraints = "" in {
2271 let Uses = [CL] in {
2272 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2273 "ror{b}\t{%cl, $dst|$dst, CL}",
2274 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2275 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2276 "ror{w}\t{%cl, $dst|$dst, CL}",
2277 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2278 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2279 "ror{l}\t{%cl, $dst|$dst, CL}",
2280 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2282 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2283 "ror{b}\t{$src, $dst|$dst, $src}",
2284 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2285 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2286 "ror{w}\t{$src, $dst|$dst, $src}",
2287 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2289 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2290 "ror{l}\t{$src, $dst|$dst, $src}",
2291 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2294 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2296 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2297 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2299 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2301 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2303 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2304 } // Constraints = ""
2307 // Double shift instructions (generalizations of rotate)
2308 let Uses = [CL] in {
2309 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2310 (ins GR32:$src1, GR32:$src2),
2311 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2312 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2313 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2314 (ins GR32:$src1, GR32:$src2),
2315 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2316 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2317 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2318 (ins GR16:$src1, GR16:$src2),
2319 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2320 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2322 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2323 (ins GR16:$src1, GR16:$src2),
2324 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2325 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2329 let isCommutable = 1 in { // These instructions commute to each other.
2330 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2332 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2333 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2334 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2337 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2339 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2340 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2341 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2344 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2346 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2347 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2348 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2351 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2353 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2354 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2355 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2360 let Constraints = "" in {
2361 let Uses = [CL] in {
2362 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2363 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2364 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2366 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2367 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2368 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2371 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2372 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2373 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2374 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2375 (i8 imm:$src3)), addr:$dst)]>,
2377 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2378 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2379 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2380 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2381 (i8 imm:$src3)), addr:$dst)]>,
2384 let Uses = [CL] in {
2385 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2386 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2387 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2388 addr:$dst)]>, TB, OpSize;
2389 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2390 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2391 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2392 addr:$dst)]>, TB, OpSize;
2394 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2395 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2396 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2397 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2398 (i8 imm:$src3)), addr:$dst)]>,
2400 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2401 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2402 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2403 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2404 (i8 imm:$src3)), addr:$dst)]>,
2406 } // Constraints = ""
2407 } // Defs = [EFLAGS]
2411 let Defs = [EFLAGS] in {
2412 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2413 // Register-Register Addition
2414 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2415 (ins GR8 :$src1, GR8 :$src2),
2416 "add{b}\t{$src2, $dst|$dst, $src2}",
2417 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1, GR8:$src2))]>;
2419 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2420 // Register-Register Addition
2421 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2422 (ins GR16:$src1, GR16:$src2),
2423 "add{w}\t{$src2, $dst|$dst, $src2}",
2424 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2425 GR16:$src2))]>, OpSize;
2426 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2427 (ins GR32:$src1, GR32:$src2),
2428 "add{l}\t{$src2, $dst|$dst, $src2}",
2429 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2431 } // end isConvertibleToThreeAddress
2432 } // end isCommutable
2434 // These are alternate spellings for use by the disassembler, we mark them as
2435 // code gen only to ensure they aren't matched by the assembler.
2436 let isCodeGenOnly = 1 in {
2437 def ADD8rr_alt: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2438 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2439 def ADD16rr_alt: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2440 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2441 def ADD32rr_alt: I<0x03, MRMSrcReg,(outs GR32:$dst),(ins GR32:$src1, GR32:$src2),
2442 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2445 // Register-Memory Addition
2446 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2447 (ins GR8 :$src1, i8mem :$src2),
2448 "add{b}\t{$src2, $dst|$dst, $src2}",
2449 [(set GR8:$dst, EFLAGS, (X86add_flag GR8:$src1,
2450 (load addr:$src2)))]>;
2451 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2452 (ins GR16:$src1, i16mem:$src2),
2453 "add{w}\t{$src2, $dst|$dst, $src2}",
2454 [(set GR16:$dst, EFLAGS, (X86add_flag GR16:$src1,
2455 (load addr:$src2)))]>, OpSize;
2456 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2457 (ins GR32:$src1, i32mem:$src2),
2458 "add{l}\t{$src2, $dst|$dst, $src2}",
2459 [(set GR32:$dst, EFLAGS, (X86add_flag GR32:$src1,
2460 (load addr:$src2)))]>;
2462 // Register-Integer Addition
2463 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2464 "add{b}\t{$src2, $dst|$dst, $src2}",
2465 [(set GR8:$dst, EFLAGS,
2466 (X86add_flag GR8:$src1, imm:$src2))]>;
2468 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2469 // Register-Integer Addition
2470 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2471 (ins GR16:$src1, i16imm:$src2),
2472 "add{w}\t{$src2, $dst|$dst, $src2}",
2473 [(set GR16:$dst, EFLAGS,
2474 (X86add_flag GR16:$src1, imm:$src2))]>, OpSize;
2475 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2476 (ins GR32:$src1, i32imm:$src2),
2477 "add{l}\t{$src2, $dst|$dst, $src2}",
2478 [(set GR32:$dst, EFLAGS,
2479 (X86add_flag GR32:$src1, imm:$src2))]>;
2480 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2481 (ins GR16:$src1, i16i8imm:$src2),
2482 "add{w}\t{$src2, $dst|$dst, $src2}",
2483 [(set GR16:$dst, EFLAGS,
2484 (X86add_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
2485 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2486 (ins GR32:$src1, i32i8imm:$src2),
2487 "add{l}\t{$src2, $dst|$dst, $src2}",
2488 [(set GR32:$dst, EFLAGS,
2489 (X86add_flag GR32:$src1, i32immSExt8:$src2))]>;
2492 let Constraints = "" in {
2493 // Memory-Register Addition
2494 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2495 "add{b}\t{$src2, $dst|$dst, $src2}",
2496 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2497 (implicit EFLAGS)]>;
2498 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2499 "add{w}\t{$src2, $dst|$dst, $src2}",
2500 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2501 (implicit EFLAGS)]>, OpSize;
2502 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2503 "add{l}\t{$src2, $dst|$dst, $src2}",
2504 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2505 (implicit EFLAGS)]>;
2506 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2507 "add{b}\t{$src2, $dst|$dst, $src2}",
2508 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2509 (implicit EFLAGS)]>;
2510 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2511 "add{w}\t{$src2, $dst|$dst, $src2}",
2512 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2513 (implicit EFLAGS)]>, OpSize;
2514 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2515 "add{l}\t{$src2, $dst|$dst, $src2}",
2516 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2517 (implicit EFLAGS)]>;
2518 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2519 "add{w}\t{$src2, $dst|$dst, $src2}",
2520 [(store (add (load addr:$dst), i16immSExt8:$src2),
2522 (implicit EFLAGS)]>, OpSize;
2523 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2524 "add{l}\t{$src2, $dst|$dst, $src2}",
2525 [(store (add (load addr:$dst), i32immSExt8:$src2),
2527 (implicit EFLAGS)]>;
2530 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2531 "add{b}\t{$src, %al|%al, $src}", []>;
2532 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2533 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2534 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2535 "add{l}\t{$src, %eax|%eax, $src}", []>;
2536 } // Constraints = ""
2538 let Uses = [EFLAGS] in {
2539 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2540 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2541 "adc{b}\t{$src2, $dst|$dst, $src2}",
2542 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2543 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2544 (ins GR16:$src1, GR16:$src2),
2545 "adc{w}\t{$src2, $dst|$dst, $src2}",
2546 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2547 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2548 (ins GR32:$src1, GR32:$src2),
2549 "adc{l}\t{$src2, $dst|$dst, $src2}",
2550 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2553 let isCodeGenOnly = 1 in {
2554 def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2555 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2556 def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2557 (ins GR16:$src1, GR16:$src2),
2558 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2559 def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2560 (ins GR32:$src1, GR32:$src2),
2561 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2564 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2565 (ins GR8:$src1, i8mem:$src2),
2566 "adc{b}\t{$src2, $dst|$dst, $src2}",
2567 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2568 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2569 (ins GR16:$src1, i16mem:$src2),
2570 "adc{w}\t{$src2, $dst|$dst, $src2}",
2571 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2573 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2574 (ins GR32:$src1, i32mem:$src2),
2575 "adc{l}\t{$src2, $dst|$dst, $src2}",
2576 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2577 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2578 "adc{b}\t{$src2, $dst|$dst, $src2}",
2579 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2580 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2581 (ins GR16:$src1, i16imm:$src2),
2582 "adc{w}\t{$src2, $dst|$dst, $src2}",
2583 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2584 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2585 (ins GR16:$src1, i16i8imm:$src2),
2586 "adc{w}\t{$src2, $dst|$dst, $src2}",
2587 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2589 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2590 (ins GR32:$src1, i32imm:$src2),
2591 "adc{l}\t{$src2, $dst|$dst, $src2}",
2592 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2593 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2594 (ins GR32:$src1, i32i8imm:$src2),
2595 "adc{l}\t{$src2, $dst|$dst, $src2}",
2596 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2598 let Constraints = "" in {
2599 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2600 "adc{b}\t{$src2, $dst|$dst, $src2}",
2601 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2602 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2603 "adc{w}\t{$src2, $dst|$dst, $src2}",
2604 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2606 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2607 "adc{l}\t{$src2, $dst|$dst, $src2}",
2608 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2609 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2610 "adc{b}\t{$src2, $dst|$dst, $src2}",
2611 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2612 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2613 "adc{w}\t{$src2, $dst|$dst, $src2}",
2614 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2616 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2617 "adc{w}\t{$src2, $dst|$dst, $src2}",
2618 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2620 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2621 "adc{l}\t{$src2, $dst|$dst, $src2}",
2622 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2623 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2624 "adc{l}\t{$src2, $dst|$dst, $src2}",
2625 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2627 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2628 "adc{b}\t{$src, %al|%al, $src}", []>;
2629 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2630 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2631 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2632 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2633 } // Constraints = ""
2634 } // Uses = [EFLAGS]
2636 // Register-Register Subtraction
2637 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2638 "sub{b}\t{$src2, $dst|$dst, $src2}",
2639 [(set GR8:$dst, EFLAGS,
2640 (X86sub_flag GR8:$src1, GR8:$src2))]>;
2641 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2642 "sub{w}\t{$src2, $dst|$dst, $src2}",
2643 [(set GR16:$dst, EFLAGS,
2644 (X86sub_flag GR16:$src1, GR16:$src2))]>, OpSize;
2645 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2646 "sub{l}\t{$src2, $dst|$dst, $src2}",
2647 [(set GR32:$dst, EFLAGS,
2648 (X86sub_flag GR32:$src1, GR32:$src2))]>;
2650 let isCodeGenOnly = 1 in {
2651 def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2652 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2653 def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2654 (ins GR16:$src1, GR16:$src2),
2655 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2656 def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2657 (ins GR32:$src1, GR32:$src2),
2658 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2661 // Register-Memory Subtraction
2662 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2663 (ins GR8 :$src1, i8mem :$src2),
2664 "sub{b}\t{$src2, $dst|$dst, $src2}",
2665 [(set GR8:$dst, EFLAGS,
2666 (X86sub_flag GR8:$src1, (load addr:$src2)))]>;
2667 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2668 (ins GR16:$src1, i16mem:$src2),
2669 "sub{w}\t{$src2, $dst|$dst, $src2}",
2670 [(set GR16:$dst, EFLAGS,
2671 (X86sub_flag GR16:$src1, (load addr:$src2)))]>, OpSize;
2672 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2673 (ins GR32:$src1, i32mem:$src2),
2674 "sub{l}\t{$src2, $dst|$dst, $src2}",
2675 [(set GR32:$dst, EFLAGS,
2676 (X86sub_flag GR32:$src1, (load addr:$src2)))]>;
2678 // Register-Integer Subtraction
2679 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2680 (ins GR8:$src1, i8imm:$src2),
2681 "sub{b}\t{$src2, $dst|$dst, $src2}",
2682 [(set GR8:$dst, EFLAGS,
2683 (X86sub_flag GR8:$src1, imm:$src2))]>;
2684 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2685 (ins GR16:$src1, i16imm:$src2),
2686 "sub{w}\t{$src2, $dst|$dst, $src2}",
2687 [(set GR16:$dst, EFLAGS,
2688 (X86sub_flag GR16:$src1, imm:$src2))]>, OpSize;
2689 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2690 (ins GR32:$src1, i32imm:$src2),
2691 "sub{l}\t{$src2, $dst|$dst, $src2}",
2692 [(set GR32:$dst, EFLAGS,
2693 (X86sub_flag GR32:$src1, imm:$src2))]>;
2694 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2695 (ins GR16:$src1, i16i8imm:$src2),
2696 "sub{w}\t{$src2, $dst|$dst, $src2}",
2697 [(set GR16:$dst, EFLAGS,
2698 (X86sub_flag GR16:$src1, i16immSExt8:$src2))]>, OpSize;
2699 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2700 (ins GR32:$src1, i32i8imm:$src2),
2701 "sub{l}\t{$src2, $dst|$dst, $src2}",
2702 [(set GR32:$dst, EFLAGS,
2703 (X86sub_flag GR32:$src1, i32immSExt8:$src2))]>;
2705 let Constraints = "" in {
2706 // Memory-Register Subtraction
2707 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2708 "sub{b}\t{$src2, $dst|$dst, $src2}",
2709 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2710 (implicit EFLAGS)]>;
2711 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2712 "sub{w}\t{$src2, $dst|$dst, $src2}",
2713 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2714 (implicit EFLAGS)]>, OpSize;
2715 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2716 "sub{l}\t{$src2, $dst|$dst, $src2}",
2717 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2718 (implicit EFLAGS)]>;
2720 // Memory-Integer Subtraction
2721 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2722 "sub{b}\t{$src2, $dst|$dst, $src2}",
2723 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2724 (implicit EFLAGS)]>;
2725 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2726 "sub{w}\t{$src2, $dst|$dst, $src2}",
2727 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2728 (implicit EFLAGS)]>, OpSize;
2729 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2730 "sub{l}\t{$src2, $dst|$dst, $src2}",
2731 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2732 (implicit EFLAGS)]>;
2733 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2734 "sub{w}\t{$src2, $dst|$dst, $src2}",
2735 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2737 (implicit EFLAGS)]>, OpSize;
2738 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2739 "sub{l}\t{$src2, $dst|$dst, $src2}",
2740 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2742 (implicit EFLAGS)]>;
2744 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2745 "sub{b}\t{$src, %al|%al, $src}", []>;
2746 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2747 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2748 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2749 "sub{l}\t{$src, %eax|%eax, $src}", []>;
2750 } // Constraints = ""
2752 let Uses = [EFLAGS] in {
2753 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2754 (ins GR8:$src1, GR8:$src2),
2755 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2756 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2757 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2758 (ins GR16:$src1, GR16:$src2),
2759 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2760 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2761 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2762 (ins GR32:$src1, GR32:$src2),
2763 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2764 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2766 let Constraints = "" in {
2767 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2768 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2769 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2770 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2771 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2772 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2774 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2775 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2776 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2777 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2778 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2779 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2780 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2781 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2782 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2784 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2785 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2786 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2788 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2789 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2790 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2791 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2792 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2793 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2795 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2796 "sbb{b}\t{$src, %al|%al, $src}", []>;
2797 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2798 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2799 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2800 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
2801 } // Constraints = ""
2803 let isCodeGenOnly = 1 in {
2804 def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2805 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
2806 def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
2807 (ins GR16:$src1, GR16:$src2),
2808 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2809 def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
2810 (ins GR32:$src1, GR32:$src2),
2811 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
2814 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2815 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2816 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2817 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2818 (ins GR16:$src1, i16mem:$src2),
2819 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2820 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2822 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2823 (ins GR32:$src1, i32mem:$src2),
2824 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2825 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2826 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2827 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2828 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2829 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2830 (ins GR16:$src1, i16imm:$src2),
2831 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2832 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2833 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2834 (ins GR16:$src1, i16i8imm:$src2),
2835 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2836 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2838 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2839 (ins GR32:$src1, i32imm:$src2),
2840 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2841 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2842 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2843 (ins GR32:$src1, i32i8imm:$src2),
2844 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2845 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2846 } // Uses = [EFLAGS]
2847 } // Defs = [EFLAGS]
2849 let Defs = [EFLAGS] in {
2850 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2851 // Register-Register Signed Integer Multiply
2852 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2853 "imul{w}\t{$src2, $dst|$dst, $src2}",
2854 [(set GR16:$dst, EFLAGS,
2855 (X86smul_flag GR16:$src1, GR16:$src2))]>, TB, OpSize;
2856 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2857 "imul{l}\t{$src2, $dst|$dst, $src2}",
2858 [(set GR32:$dst, EFLAGS,
2859 (X86smul_flag GR32:$src1, GR32:$src2))]>, TB;
2862 // Register-Memory Signed Integer Multiply
2863 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2864 (ins GR16:$src1, i16mem:$src2),
2865 "imul{w}\t{$src2, $dst|$dst, $src2}",
2866 [(set GR16:$dst, EFLAGS,
2867 (X86smul_flag GR16:$src1, (load addr:$src2)))]>,
2869 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
2870 (ins GR32:$src1, i32mem:$src2),
2871 "imul{l}\t{$src2, $dst|$dst, $src2}",
2872 [(set GR32:$dst, EFLAGS,
2873 (X86smul_flag GR32:$src1, (load addr:$src2)))]>, TB;
2874 } // Defs = [EFLAGS]
2875 } // end Two Address instructions
2877 // Suprisingly enough, these are not two address instructions!
2878 let Defs = [EFLAGS] in {
2879 // Register-Integer Signed Integer Multiply
2880 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2881 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2882 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2883 [(set GR16:$dst, EFLAGS,
2884 (X86smul_flag GR16:$src1, imm:$src2))]>, OpSize;
2885 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2886 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2887 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2888 [(set GR32:$dst, EFLAGS,
2889 (X86smul_flag GR32:$src1, imm:$src2))]>;
2890 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2891 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2892 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2893 [(set GR16:$dst, EFLAGS,
2894 (X86smul_flag GR16:$src1, i16immSExt8:$src2))]>,
2896 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2897 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2898 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2899 [(set GR32:$dst, EFLAGS,
2900 (X86smul_flag GR32:$src1, i32immSExt8:$src2))]>;
2902 // Memory-Integer Signed Integer Multiply
2903 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2904 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2905 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2906 [(set GR16:$dst, EFLAGS,
2907 (X86smul_flag (load addr:$src1), imm:$src2))]>,
2909 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2910 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2911 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2912 [(set GR32:$dst, EFLAGS,
2913 (X86smul_flag (load addr:$src1), imm:$src2))]>;
2914 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2915 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2916 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2917 [(set GR16:$dst, EFLAGS,
2918 (X86smul_flag (load addr:$src1),
2919 i16immSExt8:$src2))]>, OpSize;
2920 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2921 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2922 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2923 [(set GR32:$dst, EFLAGS,
2924 (X86smul_flag (load addr:$src1),
2925 i32immSExt8:$src2))]>;
2926 } // Defs = [EFLAGS]
2928 //===----------------------------------------------------------------------===//
2929 // Test instructions are just like AND, except they don't generate a result.
2931 let Defs = [EFLAGS] in {
2932 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2933 def TEST8rr : I<0x84, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
2934 "test{b}\t{$src2, $src1|$src1, $src2}",
2935 [(set EFLAGS, (X86cmp (and_su GR8:$src1, GR8:$src2), 0))]>;
2936 def TEST16rr : I<0x85, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
2937 "test{w}\t{$src2, $src1|$src1, $src2}",
2938 [(set EFLAGS, (X86cmp (and_su GR16:$src1, GR16:$src2),
2941 def TEST32rr : I<0x85, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
2942 "test{l}\t{$src2, $src1|$src1, $src2}",
2943 [(set EFLAGS, (X86cmp (and_su GR32:$src1, GR32:$src2),
2947 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
2948 "test{b}\t{$src, %al|%al, $src}", []>;
2949 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
2950 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2951 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
2952 "test{l}\t{$src, %eax|%eax, $src}", []>;
2954 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2955 "test{b}\t{$src2, $src1|$src1, $src2}",
2956 [(set EFLAGS, (X86cmp (and GR8:$src1, (loadi8 addr:$src2)),
2958 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2959 "test{w}\t{$src2, $src1|$src1, $src2}",
2960 [(set EFLAGS, (X86cmp (and GR16:$src1,
2961 (loadi16 addr:$src2)), 0))]>, OpSize;
2962 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2963 "test{l}\t{$src2, $src1|$src1, $src2}",
2964 [(set EFLAGS, (X86cmp (and GR32:$src1,
2965 (loadi32 addr:$src2)), 0))]>;
2967 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2968 (outs), (ins GR8:$src1, i8imm:$src2),
2969 "test{b}\t{$src2, $src1|$src1, $src2}",
2970 [(set EFLAGS, (X86cmp (and_su GR8:$src1, imm:$src2), 0))]>;
2971 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2972 (outs), (ins GR16:$src1, i16imm:$src2),
2973 "test{w}\t{$src2, $src1|$src1, $src2}",
2974 [(set EFLAGS, (X86cmp (and_su GR16:$src1, imm:$src2), 0))]>,
2976 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2977 (outs), (ins GR32:$src1, i32imm:$src2),
2978 "test{l}\t{$src2, $src1|$src1, $src2}",
2979 [(set EFLAGS, (X86cmp (and_su GR32:$src1, imm:$src2), 0))]>;
2981 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2982 (outs), (ins i8mem:$src1, i8imm:$src2),
2983 "test{b}\t{$src2, $src1|$src1, $src2}",
2984 [(set EFLAGS, (X86cmp (and (loadi8 addr:$src1), imm:$src2),
2986 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2987 (outs), (ins i16mem:$src1, i16imm:$src2),
2988 "test{w}\t{$src2, $src1|$src1, $src2}",
2989 [(set EFLAGS, (X86cmp (and (loadi16 addr:$src1), imm:$src2),
2991 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2992 (outs), (ins i32mem:$src1, i32imm:$src2),
2993 "test{l}\t{$src2, $src1|$src1, $src2}",
2994 [(set EFLAGS, (X86cmp (and (loadi32 addr:$src1), imm:$src2),
2996 } // Defs = [EFLAGS]
2999 // Condition code ops, incl. set if equal/not equal/...
3000 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
3001 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
3002 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
3003 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
3005 let Uses = [EFLAGS] in {
3006 // Use sbb to materialize carry bit.
3007 let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3008 // FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3009 // However, Pat<> can't replicate the destination reg into the inputs of the
3011 // FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3013 def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
3014 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3015 def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
3016 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
3018 def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
3019 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3022 def SETEr : I<0x94, MRM0r,
3023 (outs GR8 :$dst), (ins),
3025 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
3027 def SETEm : I<0x94, MRM0m,
3028 (outs), (ins i8mem:$dst),
3030 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
3033 def SETNEr : I<0x95, MRM0r,
3034 (outs GR8 :$dst), (ins),
3036 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
3038 def SETNEm : I<0x95, MRM0m,
3039 (outs), (ins i8mem:$dst),
3041 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
3044 def SETLr : I<0x9C, MRM0r,
3045 (outs GR8 :$dst), (ins),
3047 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
3048 TB; // GR8 = < signed
3049 def SETLm : I<0x9C, MRM0m,
3050 (outs), (ins i8mem:$dst),
3052 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
3053 TB; // [mem8] = < signed
3055 def SETGEr : I<0x9D, MRM0r,
3056 (outs GR8 :$dst), (ins),
3058 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
3059 TB; // GR8 = >= signed
3060 def SETGEm : I<0x9D, MRM0m,
3061 (outs), (ins i8mem:$dst),
3063 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
3064 TB; // [mem8] = >= signed
3066 def SETLEr : I<0x9E, MRM0r,
3067 (outs GR8 :$dst), (ins),
3069 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3070 TB; // GR8 = <= signed
3071 def SETLEm : I<0x9E, MRM0m,
3072 (outs), (ins i8mem:$dst),
3074 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3075 TB; // [mem8] = <= signed
3077 def SETGr : I<0x9F, MRM0r,
3078 (outs GR8 :$dst), (ins),
3080 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3081 TB; // GR8 = > signed
3082 def SETGm : I<0x9F, MRM0m,
3083 (outs), (ins i8mem:$dst),
3085 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3086 TB; // [mem8] = > signed
3088 def SETBr : I<0x92, MRM0r,
3089 (outs GR8 :$dst), (ins),
3091 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3092 TB; // GR8 = < unsign
3093 def SETBm : I<0x92, MRM0m,
3094 (outs), (ins i8mem:$dst),
3096 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3097 TB; // [mem8] = < unsign
3099 def SETAEr : I<0x93, MRM0r,
3100 (outs GR8 :$dst), (ins),
3102 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3103 TB; // GR8 = >= unsign
3104 def SETAEm : I<0x93, MRM0m,
3105 (outs), (ins i8mem:$dst),
3107 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3108 TB; // [mem8] = >= unsign
3110 def SETBEr : I<0x96, MRM0r,
3111 (outs GR8 :$dst), (ins),
3113 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3114 TB; // GR8 = <= unsign
3115 def SETBEm : I<0x96, MRM0m,
3116 (outs), (ins i8mem:$dst),
3118 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3119 TB; // [mem8] = <= unsign
3121 def SETAr : I<0x97, MRM0r,
3122 (outs GR8 :$dst), (ins),
3124 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3125 TB; // GR8 = > signed
3126 def SETAm : I<0x97, MRM0m,
3127 (outs), (ins i8mem:$dst),
3129 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3130 TB; // [mem8] = > signed
3132 def SETSr : I<0x98, MRM0r,
3133 (outs GR8 :$dst), (ins),
3135 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3136 TB; // GR8 = <sign bit>
3137 def SETSm : I<0x98, MRM0m,
3138 (outs), (ins i8mem:$dst),
3140 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3141 TB; // [mem8] = <sign bit>
3142 def SETNSr : I<0x99, MRM0r,
3143 (outs GR8 :$dst), (ins),
3145 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3146 TB; // GR8 = !<sign bit>
3147 def SETNSm : I<0x99, MRM0m,
3148 (outs), (ins i8mem:$dst),
3150 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3151 TB; // [mem8] = !<sign bit>
3153 def SETPr : I<0x9A, MRM0r,
3154 (outs GR8 :$dst), (ins),
3156 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3158 def SETPm : I<0x9A, MRM0m,
3159 (outs), (ins i8mem:$dst),
3161 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3162 TB; // [mem8] = parity
3163 def SETNPr : I<0x9B, MRM0r,
3164 (outs GR8 :$dst), (ins),
3166 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3167 TB; // GR8 = not parity
3168 def SETNPm : I<0x9B, MRM0m,
3169 (outs), (ins i8mem:$dst),
3171 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3172 TB; // [mem8] = not parity
3174 def SETOr : I<0x90, MRM0r,
3175 (outs GR8 :$dst), (ins),
3177 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3178 TB; // GR8 = overflow
3179 def SETOm : I<0x90, MRM0m,
3180 (outs), (ins i8mem:$dst),
3182 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3183 TB; // [mem8] = overflow
3184 def SETNOr : I<0x91, MRM0r,
3185 (outs GR8 :$dst), (ins),
3187 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3188 TB; // GR8 = not overflow
3189 def SETNOm : I<0x91, MRM0m,
3190 (outs), (ins i8mem:$dst),
3192 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3193 TB; // [mem8] = not overflow
3194 } // Uses = [EFLAGS]
3197 // Integer comparisons
3198 let Defs = [EFLAGS] in {
3199 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3200 "cmp{b}\t{$src, %al|%al, $src}", []>;
3201 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3202 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3203 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3204 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3206 def CMP8rr : I<0x38, MRMDestReg,
3207 (outs), (ins GR8 :$src1, GR8 :$src2),
3208 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3209 [(set EFLAGS, (X86cmp GR8:$src1, GR8:$src2))]>;
3210 def CMP16rr : I<0x39, MRMDestReg,
3211 (outs), (ins GR16:$src1, GR16:$src2),
3212 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3213 [(set EFLAGS, (X86cmp GR16:$src1, GR16:$src2))]>, OpSize;
3214 def CMP32rr : I<0x39, MRMDestReg,
3215 (outs), (ins GR32:$src1, GR32:$src2),
3216 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3217 [(set EFLAGS, (X86cmp GR32:$src1, GR32:$src2))]>;
3218 def CMP8mr : I<0x38, MRMDestMem,
3219 (outs), (ins i8mem :$src1, GR8 :$src2),
3220 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3221 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), GR8:$src2))]>;
3222 def CMP16mr : I<0x39, MRMDestMem,
3223 (outs), (ins i16mem:$src1, GR16:$src2),
3224 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3225 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), GR16:$src2))]>,
3227 def CMP32mr : I<0x39, MRMDestMem,
3228 (outs), (ins i32mem:$src1, GR32:$src2),
3229 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3230 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), GR32:$src2))]>;
3231 def CMP8rm : I<0x3A, MRMSrcMem,
3232 (outs), (ins GR8 :$src1, i8mem :$src2),
3233 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3234 [(set EFLAGS, (X86cmp GR8:$src1, (loadi8 addr:$src2)))]>;
3235 def CMP16rm : I<0x3B, MRMSrcMem,
3236 (outs), (ins GR16:$src1, i16mem:$src2),
3237 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3238 [(set EFLAGS, (X86cmp GR16:$src1, (loadi16 addr:$src2)))]>,
3240 def CMP32rm : I<0x3B, MRMSrcMem,
3241 (outs), (ins GR32:$src1, i32mem:$src2),
3242 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3243 [(set EFLAGS, (X86cmp GR32:$src1, (loadi32 addr:$src2)))]>;
3245 // These are alternate spellings for use by the disassembler, we mark them as
3246 // code gen only to ensure they aren't matched by the assembler.
3247 let isCodeGenOnly = 1 in {
3248 def CMP8rr_alt : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3249 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3250 def CMP16rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3251 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3252 def CMP32rr_alt : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3253 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3256 def CMP8ri : Ii8<0x80, MRM7r,
3257 (outs), (ins GR8:$src1, i8imm:$src2),
3258 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3259 [(set EFLAGS, (X86cmp GR8:$src1, imm:$src2))]>;
3260 def CMP16ri : Ii16<0x81, MRM7r,
3261 (outs), (ins GR16:$src1, i16imm:$src2),
3262 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3263 [(set EFLAGS, (X86cmp GR16:$src1, imm:$src2))]>, OpSize;
3264 def CMP32ri : Ii32<0x81, MRM7r,
3265 (outs), (ins GR32:$src1, i32imm:$src2),
3266 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3267 [(set EFLAGS, (X86cmp GR32:$src1, imm:$src2))]>;
3268 def CMP8mi : Ii8 <0x80, MRM7m,
3269 (outs), (ins i8mem :$src1, i8imm :$src2),
3270 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3271 [(set EFLAGS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>;
3272 def CMP16mi : Ii16<0x81, MRM7m,
3273 (outs), (ins i16mem:$src1, i16imm:$src2),
3274 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3275 [(set EFLAGS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
3277 def CMP32mi : Ii32<0x81, MRM7m,
3278 (outs), (ins i32mem:$src1, i32imm:$src2),
3279 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3280 [(set EFLAGS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>;
3281 def CMP16ri8 : Ii8<0x83, MRM7r,
3282 (outs), (ins GR16:$src1, i16i8imm:$src2),
3283 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3284 [(set EFLAGS, (X86cmp GR16:$src1, i16immSExt8:$src2))]>,
3286 def CMP16mi8 : Ii8<0x83, MRM7m,
3287 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3288 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3289 [(set EFLAGS, (X86cmp (loadi16 addr:$src1),
3290 i16immSExt8:$src2))]>, OpSize;
3291 def CMP32mi8 : Ii8<0x83, MRM7m,
3292 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3293 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3294 [(set EFLAGS, (X86cmp (loadi32 addr:$src1),
3295 i32immSExt8:$src2))]>;
3296 def CMP32ri8 : Ii8<0x83, MRM7r,
3297 (outs), (ins GR32:$src1, i32i8imm:$src2),
3298 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3299 [(set EFLAGS, (X86cmp GR32:$src1, i32immSExt8:$src2))]>;
3300 } // Defs = [EFLAGS]
3303 // TODO: BTC, BTR, and BTS
3304 let Defs = [EFLAGS] in {
3305 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3306 "bt{w}\t{$src2, $src1|$src1, $src2}",
3307 [(set EFLAGS, (X86bt GR16:$src1, GR16:$src2))]>, OpSize, TB;
3308 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3309 "bt{l}\t{$src2, $src1|$src1, $src2}",
3310 [(set EFLAGS, (X86bt GR32:$src1, GR32:$src2))]>, TB;
3312 // Unlike with the register+register form, the memory+register form of the
3313 // bt instruction does not ignore the high bits of the index. From ISel's
3314 // perspective, this is pretty bizarre. Make these instructions disassembly
3317 def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3318 "bt{w}\t{$src2, $src1|$src1, $src2}",
3319 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3320 // (implicit EFLAGS)]
3322 >, OpSize, TB, Requires<[FastBTMem]>;
3323 def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3324 "bt{l}\t{$src2, $src1|$src1, $src2}",
3325 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3326 // (implicit EFLAGS)]
3328 >, TB, Requires<[FastBTMem]>;
3330 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3331 "bt{w}\t{$src2, $src1|$src1, $src2}",
3332 [(set EFLAGS, (X86bt GR16:$src1, i16immSExt8:$src2))]>,
3334 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3335 "bt{l}\t{$src2, $src1|$src1, $src2}",
3336 [(set EFLAGS, (X86bt GR32:$src1, i32immSExt8:$src2))]>, TB;
3337 // Note that these instructions don't need FastBTMem because that
3338 // only applies when the other operand is in a register. When it's
3339 // an immediate, bt is still fast.
3340 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3341 "bt{w}\t{$src2, $src1|$src1, $src2}",
3342 [(set EFLAGS, (X86bt (loadi16 addr:$src1), i16immSExt8:$src2))
3344 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3345 "bt{l}\t{$src2, $src1|$src1, $src2}",
3346 [(set EFLAGS, (X86bt (loadi32 addr:$src1), i32immSExt8:$src2))
3349 def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3350 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3351 def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3352 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3353 def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3354 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3355 def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3356 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3357 def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3358 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3359 def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3360 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3361 def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3362 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3363 def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3364 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3366 def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3367 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3368 def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3369 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3370 def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3371 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3372 def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3373 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3374 def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3375 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3376 def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3377 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3378 def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3379 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3380 def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3381 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3383 def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3384 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3385 def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3386 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3387 def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3388 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3389 def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3390 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3391 def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3392 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3393 def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3394 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3395 def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3396 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3397 def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3398 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3399 } // Defs = [EFLAGS]
3401 // Sign/Zero extenders
3402 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3403 // of the register here. This has a smaller encoding and avoids a
3404 // partial-register update. Actual movsbw included for the disassembler.
3405 def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3406 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3407 def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3408 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3409 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3410 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
3411 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3412 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3413 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3414 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3415 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3416 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3417 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3418 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3419 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3420 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3421 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3422 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3423 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3424 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3426 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3427 // of the register here. This has a smaller encoding and avoids a
3428 // partial-register update. Actual movzbw included for the disassembler.
3429 def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3430 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3431 def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3432 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3433 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3434 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
3435 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3436 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3437 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3438 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3439 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3440 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3441 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3442 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3443 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3444 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3445 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3446 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3447 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3448 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3450 // These are the same as the regular MOVZX32rr8 and MOVZX32rm8
3451 // except that they use GR32_NOREX for the output operand register class
3452 // instead of GR32. This allows them to operate on h registers on x86-64.
3453 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3454 (outs GR32_NOREX:$dst), (ins GR8:$src),
3455 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3458 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3459 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3460 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3463 let neverHasSideEffects = 1 in {
3464 let Defs = [AX], Uses = [AL] in
3465 def CBW : I<0x98, RawFrm, (outs), (ins),
3466 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3467 let Defs = [EAX], Uses = [AX] in
3468 def CWDE : I<0x98, RawFrm, (outs), (ins),
3469 "{cwtl|cwde}", []>; // EAX = signext(AX)
3471 let Defs = [AX,DX], Uses = [AX] in
3472 def CWD : I<0x99, RawFrm, (outs), (ins),
3473 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3474 let Defs = [EAX,EDX], Uses = [EAX] in
3475 def CDQ : I<0x99, RawFrm, (outs), (ins),
3476 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3481 //===----------------------------------------------------------------------===//
3486 // Atomic swap. These are just normal xchg instructions. But since a memory
3487 // operand is referenced, the atomicity is ensured.
3488 let Constraints = "$val = $dst" in {
3489 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3490 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3491 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3492 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3493 (ins GR16:$val, i16mem:$ptr),
3494 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3495 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3497 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3498 (ins GR32:$val, i32mem:$ptr),
3499 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3500 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3501 def XCHG64rm : RI<0x87, MRMSrcMem, (outs GR64:$dst),
3502 (ins GR64:$val,i64mem:$ptr),
3503 "xchg{q}\t{$val, $ptr|$ptr, $val}",
3504 [(set GR64:$dst, (atomic_swap_64 addr:$ptr, GR64:$val))]>;
3506 def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3507 "xchg{b}\t{$val, $src|$src, $val}", []>;
3508 def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3509 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3510 def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3511 "xchg{l}\t{$val, $src|$src, $val}", []>;
3512 def XCHG64rr : RI<0x87, MRMSrcReg, (outs GR64:$dst), (ins GR64:$val,GR64:$src),
3513 "xchg{q}\t{$val, $src|$src, $val}", []>;
3516 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3517 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3518 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3519 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3520 def XCHG64ar : RI<0x90, AddRegFrm, (outs), (ins GR64:$src),
3521 "xchg{q}\t{$src, %rax|%rax, $src}", []>;
3525 def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3526 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3527 def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3528 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3529 def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3530 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3531 def XADD64rr : RI<0xC1, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
3532 "xadd{q}\t{$src, $dst|$dst, $src}", []>, TB;
3534 let mayLoad = 1, mayStore = 1 in {
3535 def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3536 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3537 def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3538 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3539 def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3540 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3541 def XADD64rm : RI<0xC1, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
3542 "xadd{q}\t{$src, $dst|$dst, $src}", []>, TB;
3546 def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3547 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3548 def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3549 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3550 def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3551 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3552 def CMPXCHG64rr : RI<0xB1, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
3553 "cmpxchg{q}\t{$src, $dst|$dst, $src}", []>, TB;
3555 let mayLoad = 1, mayStore = 1 in {
3556 def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3557 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3558 def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3559 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3560 def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3561 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3562 def CMPXCHG64rm : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src),
3563 "cmpxchg{q}\t{$src, $dst|$dst, $src}", []>, TB;
3566 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
3567 def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3568 "cmpxchg8b\t$dst", []>, TB;
3570 let Defs = [RAX, RDX, EFLAGS], Uses = [RAX, RBX, RCX, RDX] in
3571 def CMPXCHG16B : RI<0xC7, MRM1m, (outs), (ins i128mem:$dst),
3572 "cmpxchg16b\t$dst", []>, TB;
3576 // Lock instruction prefix
3577 def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
3579 // Repeat string operation instruction prefixes
3580 // These uses the DF flag in the EFLAGS register to inc or dec ECX
3581 let Defs = [ECX], Uses = [ECX,EFLAGS] in {
3582 // Repeat (used with INS, OUTS, MOVS, LODS and STOS)
3583 def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
3584 // Repeat while not equal (used with CMPS and SCAS)
3585 def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
3589 // String manipulation instructions
3591 def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
3592 def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
3593 def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
3594 def LODSQ : RI<0xAD, RawFrm, (outs), (ins), "lodsq", []>;
3596 def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
3597 def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
3598 def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
3601 // Flag instructions
3602 def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
3603 def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
3604 def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
3605 def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
3606 def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
3607 def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
3608 def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
3610 def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
3612 // Table lookup instructions
3613 def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
3617 //===----------------------------------------------------------------------===//
3619 //===----------------------------------------------------------------------===//
3621 // Floating Point Stack Support
3622 include "X86InstrFPStack.td"
3625 include "X86Instr64bit.td"
3627 include "X86InstrControl.td"
3629 // SIMD support (SSE, MMX and AVX)
3630 include "X86InstrFragmentsSIMD.td"
3632 // FMA - Fused Multiply-Add support (requires FMA)
3633 include "X86InstrFMA.td"
3635 // SSE, MMX and 3DNow! vector support.
3636 include "X86InstrSSE.td"
3637 include "X86InstrMMX.td"
3638 include "X86Instr3DNow.td"
3640 include "X86InstrVMX.td"
3642 // System instructions.
3643 include "X86InstrSystem.td"
3645 // Compiler Pseudo Instructions and Pat Patterns
3646 include "X86InstrCompiler.td"