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<0, 2, [SDTCisSameAs<0, 1>]>;
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<1, 1,
33 def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
37 def SDTX86BrCond : SDTypeProfile<0, 3,
38 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
41 def SDTX86SetCC : SDTypeProfile<1, 2,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
44 def SDTX86SetCC_C : SDTypeProfile<1, 2,
46 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
48 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
50 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
52 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
53 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
54 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
56 def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
57 def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
60 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
62 def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
66 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
68 def SDTX86Void : SDTypeProfile<0, 0, []>;
70 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
72 def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
74 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
76 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
78 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
80 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
81 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
82 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
83 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
85 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
87 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
89 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
90 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
92 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
93 def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
95 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
96 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
98 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
99 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
101 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
102 [SDNPHasChain, SDNPMayStore,
103 SDNPMayLoad, SDNPMemOperand]>;
104 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
105 [SDNPHasChain, SDNPMayStore,
106 SDNPMayLoad, SDNPMemOperand]>;
107 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
108 [SDNPHasChain, SDNPMayStore,
109 SDNPMayLoad, SDNPMemOperand]>;
110 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
111 [SDNPHasChain, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
113 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
114 [SDNPHasChain, SDNPMayStore,
115 SDNPMayLoad, SDNPMemOperand]>;
116 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
117 [SDNPHasChain, SDNPMayStore,
118 SDNPMayLoad, SDNPMemOperand]>;
119 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
120 [SDNPHasChain, SDNPMayStore,
121 SDNPMayLoad, SDNPMemOperand]>;
122 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
123 [SDNPHasChain, SDNPOptInFlag]>;
125 def X86vastart_save_xmm_regs :
126 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
127 SDT_X86VASTART_SAVE_XMM_REGS,
130 def X86callseq_start :
131 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
132 [SDNPHasChain, SDNPOutFlag]>;
134 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
135 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
137 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
138 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
140 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
141 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
142 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
143 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
146 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG", SDTX86Void,
147 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
149 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
150 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
152 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
153 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
154 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
155 SDT_X86SegmentBaseAddress, []>;
157 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
160 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
161 [SDNPHasChain, SDNPOptInFlag]>;
163 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags,
165 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
166 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags,
168 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags,
170 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
171 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
172 def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags,
174 def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags,
176 def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags,
179 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
181 def X86MingwAlloca : SDNode<"X86ISD::MINGW_ALLOCA", SDTX86Void,
182 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
184 //===----------------------------------------------------------------------===//
185 // X86 Operand Definitions.
188 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
189 // the index operand of an address, to conform to x86 encoding restrictions.
190 def ptr_rc_nosp : PointerLikeRegClass<1>;
192 // *mem - Operand definitions for the funky X86 addressing mode operands.
194 def X86MemAsmOperand : AsmOperandClass {
198 def X86AbsMemAsmOperand : AsmOperandClass {
200 let SuperClass = X86MemAsmOperand;
202 def X86NoSegMemAsmOperand : AsmOperandClass {
203 let Name = "NoSegMem";
204 let SuperClass = X86MemAsmOperand;
206 class X86MemOperand<string printMethod> : Operand<iPTR> {
207 let PrintMethod = printMethod;
208 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
209 let ParserMatchClass = X86MemAsmOperand;
212 def opaque32mem : X86MemOperand<"printopaquemem">;
213 def opaque48mem : X86MemOperand<"printopaquemem">;
214 def opaque80mem : X86MemOperand<"printopaquemem">;
215 def opaque512mem : X86MemOperand<"printopaquemem">;
217 def i8mem : X86MemOperand<"printi8mem">;
218 def i16mem : X86MemOperand<"printi16mem">;
219 def i32mem : X86MemOperand<"printi32mem">;
220 def i64mem : X86MemOperand<"printi64mem">;
221 def i128mem : X86MemOperand<"printi128mem">;
222 //def i256mem : X86MemOperand<"printi256mem">;
223 def f32mem : X86MemOperand<"printf32mem">;
224 def f64mem : X86MemOperand<"printf64mem">;
225 def f80mem : X86MemOperand<"printf80mem">;
226 def f128mem : X86MemOperand<"printf128mem">;
227 //def f256mem : X86MemOperand<"printf256mem">;
229 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
230 // plain GR64, so that it doesn't potentially require a REX prefix.
231 def i8mem_NOREX : Operand<i64> {
232 let PrintMethod = "printi8mem";
233 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
234 let ParserMatchClass = X86MemAsmOperand;
237 def lea32mem : Operand<i32> {
238 let PrintMethod = "printlea32mem";
239 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
240 let ParserMatchClass = X86NoSegMemAsmOperand;
243 let ParserMatchClass = X86AbsMemAsmOperand,
244 PrintMethod = "print_pcrel_imm" in {
245 def i32imm_pcrel : Operand<i32>;
247 def offset8 : Operand<i64>;
248 def offset16 : Operand<i64>;
249 def offset32 : Operand<i64>;
250 def offset64 : Operand<i64>;
252 // Branch targets have OtherVT type and print as pc-relative values.
253 def brtarget : Operand<OtherVT>;
254 def brtarget8 : Operand<OtherVT>;
258 def SSECC : Operand<i8> {
259 let PrintMethod = "printSSECC";
262 def ImmSExt8AsmOperand : AsmOperandClass {
263 let Name = "ImmSExt8";
264 let SuperClass = ImmAsmOperand;
267 // A couple of more descriptive operand definitions.
268 // 16-bits but only 8 bits are significant.
269 def i16i8imm : Operand<i16> {
270 let ParserMatchClass = ImmSExt8AsmOperand;
272 // 32-bits but only 8 bits are significant.
273 def i32i8imm : Operand<i32> {
274 let ParserMatchClass = ImmSExt8AsmOperand;
277 //===----------------------------------------------------------------------===//
278 // X86 Complex Pattern Definitions.
281 // Define X86 specific addressing mode.
282 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
283 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
284 [add, sub, mul, X86mul_imm, shl, or, frameindex],
286 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
287 [tglobaltlsaddr], []>;
289 //===----------------------------------------------------------------------===//
290 // X86 Instruction Predicate Definitions.
291 def HasMMX : Predicate<"Subtarget->hasMMX()">;
292 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
293 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
294 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
295 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
296 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
297 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
298 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
299 def HasAVX : Predicate<"Subtarget->hasAVX()">;
300 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
301 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
302 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
303 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
304 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
305 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
306 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
307 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
308 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
309 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
310 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
311 "TM.getCodeModel() != CodeModel::Kernel">;
312 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
313 "TM.getCodeModel() == CodeModel::Kernel">;
314 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
315 def OptForSize : Predicate<"OptForSize">;
316 def OptForSpeed : Predicate<"!OptForSize">;
317 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
318 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
320 //===----------------------------------------------------------------------===//
321 // X86 Instruction Format Definitions.
324 include "X86InstrFormats.td"
326 //===----------------------------------------------------------------------===//
327 // Pattern fragments...
330 // X86 specific condition code. These correspond to CondCode in
331 // X86InstrInfo.h. They must be kept in synch.
332 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
333 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
334 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
335 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
336 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
337 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
338 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
339 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
340 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
341 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
342 def X86_COND_NO : PatLeaf<(i8 10)>;
343 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
344 def X86_COND_NS : PatLeaf<(i8 12)>;
345 def X86_COND_O : PatLeaf<(i8 13)>;
346 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
347 def X86_COND_S : PatLeaf<(i8 15)>;
349 def immSext8 : PatLeaf<(imm), [{
350 return N->getSExtValue() == (int8_t)N->getSExtValue();
353 def i16immSExt8 : PatLeaf<(i16 immSext8)>;
354 def i32immSExt8 : PatLeaf<(i32 immSext8)>;
356 /// Load patterns: these constraint the match to the right address space.
357 def dsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
358 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
359 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
360 if (PT->getAddressSpace() > 255)
365 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
366 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
367 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
368 return PT->getAddressSpace() == 256;
372 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
373 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
374 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
375 return PT->getAddressSpace() == 257;
380 // Helper fragments for loads.
381 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
382 // known to be 32-bit aligned or better. Ditto for i8 to i16.
383 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
384 LoadSDNode *LD = cast<LoadSDNode>(N);
385 if (const Value *Src = LD->getSrcValue())
386 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
387 if (PT->getAddressSpace() > 255)
389 ISD::LoadExtType ExtType = LD->getExtensionType();
390 if (ExtType == ISD::NON_EXTLOAD)
392 if (ExtType == ISD::EXTLOAD)
393 return LD->getAlignment() >= 2 && !LD->isVolatile();
397 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),[{
398 LoadSDNode *LD = cast<LoadSDNode>(N);
399 if (const Value *Src = LD->getSrcValue())
400 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
401 if (PT->getAddressSpace() > 255)
403 ISD::LoadExtType ExtType = LD->getExtensionType();
404 if (ExtType == ISD::EXTLOAD)
405 return LD->getAlignment() >= 2 && !LD->isVolatile();
409 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
410 LoadSDNode *LD = cast<LoadSDNode>(N);
411 if (const Value *Src = LD->getSrcValue())
412 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
413 if (PT->getAddressSpace() > 255)
415 ISD::LoadExtType ExtType = LD->getExtensionType();
416 if (ExtType == ISD::NON_EXTLOAD)
418 if (ExtType == ISD::EXTLOAD)
419 return LD->getAlignment() >= 4 && !LD->isVolatile();
423 def loadi8 : PatFrag<(ops node:$ptr), (i8 (dsload node:$ptr))>;
424 def loadi64 : PatFrag<(ops node:$ptr), (i64 (dsload node:$ptr))>;
425 def loadf32 : PatFrag<(ops node:$ptr), (f32 (dsload node:$ptr))>;
426 def loadf64 : PatFrag<(ops node:$ptr), (f64 (dsload node:$ptr))>;
427 def loadf80 : PatFrag<(ops node:$ptr), (f80 (dsload node:$ptr))>;
429 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
430 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
431 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
433 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
434 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
435 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
436 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
437 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
438 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
440 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
441 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
442 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
443 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
444 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
445 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
448 // An 'and' node with a single use.
449 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
450 return N->hasOneUse();
452 // An 'srl' node with a single use.
453 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
454 return N->hasOneUse();
456 // An 'trunc' node with a single use.
457 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
458 return N->hasOneUse();
461 // Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero.
462 def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{
463 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1)))
464 return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue());
466 unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits();
467 APInt Mask = APInt::getAllOnesValue(BitWidth);
468 APInt KnownZero0, KnownOne0;
469 CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0);
470 APInt KnownZero1, KnownOne1;
471 CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0);
472 return (~KnownZero0 & ~KnownZero1) == 0;
476 // 'shld' and 'shrd' instruction patterns. Note that even though these have
477 // the srl and shl in their patterns, the C++ code must still check for them,
478 // because predicates are tested before children nodes are explored.
480 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
481 (or (srl node:$src1, node:$amt1),
482 (shl node:$src2, node:$amt2)), [{
483 assert(N->getOpcode() == ISD::OR);
484 return N->getOperand(0).getOpcode() == ISD::SRL &&
485 N->getOperand(1).getOpcode() == ISD::SHL &&
486 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
487 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
488 N->getOperand(0).getConstantOperandVal(1) ==
489 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
492 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
493 (or (shl node:$src1, node:$amt1),
494 (srl node:$src2, node:$amt2)), [{
495 assert(N->getOpcode() == ISD::OR);
496 return N->getOperand(0).getOpcode() == ISD::SHL &&
497 N->getOperand(1).getOpcode() == ISD::SRL &&
498 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
499 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
500 N->getOperand(0).getConstantOperandVal(1) ==
501 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
504 //===----------------------------------------------------------------------===//
505 // Instruction list...
508 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
509 // a stack adjustment and the codegen must know that they may modify the stack
510 // pointer before prolog-epilog rewriting occurs.
511 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
512 // sub / add which can clobber EFLAGS.
513 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
514 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
516 [(X86callseq_start timm:$amt)]>,
517 Requires<[In32BitMode]>;
518 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
520 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
521 Requires<[In32BitMode]>;
524 // x86-64 va_start lowering magic.
525 let usesCustomInserter = 1 in {
526 def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
529 i64imm:$regsavefi, i64imm:$offset,
531 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
532 [(X86vastart_save_xmm_regs GR8:$al,
536 def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins),
542 let neverHasSideEffects = 1 in {
543 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
544 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
545 "nop{w}\t$zero", []>, TB, OpSize;
546 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
547 "nop{l}\t$zero", []>, TB;
551 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
552 def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
553 def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
554 def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
556 // PIC base construction. This expands to code that looks like this:
559 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
560 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
563 //===----------------------------------------------------------------------===//
564 // Control Flow Instructions.
567 // Return instructions.
568 let isTerminator = 1, isReturn = 1, isBarrier = 1,
569 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
570 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
573 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
575 [(X86retflag timm:$amt)]>;
576 def LRET : I <0xCB, RawFrm, (outs), (ins),
578 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
582 // Unconditional branches.
583 let isBarrier = 1, isBranch = 1, isTerminator = 1 in {
584 def JMP_4 : Ii32PCRel<0xE9, RawFrm, (outs), (ins brtarget:$dst),
585 "jmp\t$dst", [(br bb:$dst)]>;
586 def JMP_1 : Ii8PCRel<0xEB, RawFrm, (outs), (ins brtarget8:$dst),
590 // Conditional Branches.
591 let isBranch = 1, isTerminator = 1, Uses = [EFLAGS] in {
592 multiclass ICBr<bits<8> opc1, bits<8> opc4, string asm, PatFrag Cond> {
593 def _1 : Ii8PCRel <opc1, RawFrm, (outs), (ins brtarget8:$dst), asm, []>;
594 def _4 : Ii32PCRel<opc4, RawFrm, (outs), (ins brtarget:$dst), asm,
595 [(X86brcond bb:$dst, Cond, EFLAGS)]>, TB;
599 defm JO : ICBr<0x70, 0x80, "jo\t$dst" , X86_COND_O>;
600 defm JNO : ICBr<0x71, 0x81, "jno\t$dst" , X86_COND_NO>;
601 defm JB : ICBr<0x72, 0x82, "jb\t$dst" , X86_COND_B>;
602 defm JAE : ICBr<0x73, 0x83, "jae\t$dst", X86_COND_AE>;
603 defm JE : ICBr<0x74, 0x84, "je\t$dst" , X86_COND_E>;
604 defm JNE : ICBr<0x75, 0x85, "jne\t$dst", X86_COND_NE>;
605 defm JBE : ICBr<0x76, 0x86, "jbe\t$dst", X86_COND_BE>;
606 defm JA : ICBr<0x77, 0x87, "ja\t$dst" , X86_COND_A>;
607 defm JS : ICBr<0x78, 0x88, "js\t$dst" , X86_COND_S>;
608 defm JNS : ICBr<0x79, 0x89, "jns\t$dst", X86_COND_NS>;
609 defm JP : ICBr<0x7A, 0x8A, "jp\t$dst" , X86_COND_P>;
610 defm JNP : ICBr<0x7B, 0x8B, "jnp\t$dst", X86_COND_NP>;
611 defm JL : ICBr<0x7C, 0x8C, "jl\t$dst" , X86_COND_L>;
612 defm JGE : ICBr<0x7D, 0x8D, "jge\t$dst", X86_COND_GE>;
613 defm JLE : ICBr<0x7E, 0x8E, "jle\t$dst", X86_COND_LE>;
614 defm JG : ICBr<0x7F, 0x8F, "jg\t$dst" , X86_COND_G>;
616 // FIXME: What about the CX/RCX versions of this instruction?
617 let Uses = [ECX], isBranch = 1, isTerminator = 1 in
618 def JCXZ8 : Ii8PCRel<0xE3, RawFrm, (outs), (ins brtarget8:$dst),
623 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
624 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
625 [(brind GR32:$dst)]>;
626 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
627 [(brind (loadi32 addr:$dst))]>;
629 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
630 (ins i16imm:$seg, i16imm:$off),
631 "ljmp{w}\t$seg, $off", []>, OpSize;
632 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
633 (ins i16imm:$seg, i32imm:$off),
634 "ljmp{l}\t$seg, $off", []>;
636 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
637 "ljmp{w}\t{*}$dst", []>, OpSize;
638 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
639 "ljmp{l}\t{*}$dst", []>;
645 def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
646 def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
647 def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
649 //===----------------------------------------------------------------------===//
650 // Call Instructions...
653 // All calls clobber the non-callee saved registers. ESP is marked as
654 // a use to prevent stack-pointer assignments that appear immediately
655 // before calls from potentially appearing dead. Uses for argument
656 // registers are added manually.
657 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
658 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
659 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
660 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
662 def CALLpcrel32 : Ii32PCRel<0xE8, RawFrm,
663 (outs), (ins i32imm_pcrel:$dst,variable_ops),
665 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
666 "call\t{*}$dst", [(X86call GR32:$dst)]>;
667 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
668 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
670 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
671 (ins i16imm:$seg, i16imm:$off),
672 "lcall{w}\t$seg, $off", []>, OpSize;
673 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
674 (ins i16imm:$seg, i32imm:$off),
675 "lcall{l}\t$seg, $off", []>;
677 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
678 "lcall{w}\t{*}$dst", []>, OpSize;
679 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
680 "lcall{l}\t{*}$dst", []>;
683 // Constructing a stack frame.
685 def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
686 "enter\t$len, $lvl", []>;
690 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
691 def TCRETURNdi : I<0, Pseudo, (outs),
692 (ins i32imm:$dst, i32imm:$offset, variable_ops),
693 "#TC_RETURN $dst $offset",
696 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
697 def TCRETURNri : I<0, Pseudo, (outs),
698 (ins GR32:$dst, i32imm:$offset, variable_ops),
699 "#TC_RETURN $dst $offset",
702 // FIXME: The should be pseudo instructions that are lowered when going to
704 let isCall = 1, isBranch = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
705 def TAILJMPd : Ii32<0xE9, RawFrm, (outs),(ins i32imm_pcrel:$dst,variable_ops),
706 "jmp\t$dst # TAILCALL",
708 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
709 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst, variable_ops),
710 "jmp{l}\t{*}$dst # TAILCALL",
712 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
713 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst, variable_ops),
714 "jmp\t{*}$dst # TAILCALL", []>;
716 //===----------------------------------------------------------------------===//
717 // Miscellaneous Instructions...
719 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
720 def LEAVE : I<0xC9, RawFrm,
721 (outs), (ins), "leave", []>;
723 def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
724 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
725 def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
726 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
727 def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
728 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
729 def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
730 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
732 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
734 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
736 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
737 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
739 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
741 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
742 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
745 let mayStore = 1 in {
746 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
748 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
749 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
751 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
753 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
754 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
758 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
759 def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
760 "push{l}\t$imm", []>;
761 def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
762 "push{l}\t$imm", []>;
763 def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
764 "push{l}\t$imm", []>;
767 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
768 def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
769 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
771 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
772 def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
773 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
776 let isTwoAddress = 1 in // GR32 = bswap GR32
777 def BSWAP32r : I<0xC8, AddRegFrm,
778 (outs GR32:$dst), (ins GR32:$src),
780 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
783 // Bit scan instructions.
784 let Defs = [EFLAGS] in {
785 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
786 "bsf{w}\t{$src, $dst|$dst, $src}",
787 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
788 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
789 "bsf{w}\t{$src, $dst|$dst, $src}",
790 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
791 (implicit EFLAGS)]>, TB;
792 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
793 "bsf{l}\t{$src, $dst|$dst, $src}",
794 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
795 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
796 "bsf{l}\t{$src, $dst|$dst, $src}",
797 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
798 (implicit EFLAGS)]>, TB;
800 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
801 "bsr{w}\t{$src, $dst|$dst, $src}",
802 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
803 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
804 "bsr{w}\t{$src, $dst|$dst, $src}",
805 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
806 (implicit EFLAGS)]>, TB;
807 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
808 "bsr{l}\t{$src, $dst|$dst, $src}",
809 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
810 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
811 "bsr{l}\t{$src, $dst|$dst, $src}",
812 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
813 (implicit EFLAGS)]>, TB;
816 let neverHasSideEffects = 1 in
817 def LEA16r : I<0x8D, MRMSrcMem,
818 (outs GR16:$dst), (ins lea32mem:$src),
819 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
820 let isReMaterializable = 1 in
821 def LEA32r : I<0x8D, MRMSrcMem,
822 (outs GR32:$dst), (ins lea32mem:$src),
823 "lea{l}\t{$src|$dst}, {$dst|$src}",
824 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
826 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in {
827 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
828 [(X86rep_movs i8)]>, REP;
829 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
830 [(X86rep_movs i16)]>, REP, OpSize;
831 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
832 [(X86rep_movs i32)]>, REP;
835 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
836 let Defs = [EDI,ESI], Uses = [EDI,ESI,EFLAGS] in {
837 def MOVSB : I<0xA4, RawFrm, (outs), (ins), "{movsb}", []>;
838 def MOVSW : I<0xA5, RawFrm, (outs), (ins), "{movsw}", []>, OpSize;
839 def MOVSD : I<0xA5, RawFrm, (outs), (ins), "{movsl|movsd}", []>;
842 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in
843 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
844 [(X86rep_stos i8)]>, REP;
845 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in
846 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
847 [(X86rep_stos i16)]>, REP, OpSize;
848 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in
849 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
850 [(X86rep_stos i32)]>, REP;
852 // These uses the DF flag in the EFLAGS register to inc or dec EDI and ESI
853 let Defs = [EDI], Uses = [AL,EDI,EFLAGS] in
854 def STOSB : I<0xAA, RawFrm, (outs), (ins), "{stosb}", []>;
855 let Defs = [EDI], Uses = [AX,EDI,EFLAGS] in
856 def STOSW : I<0xAB, RawFrm, (outs), (ins), "{stosw}", []>, OpSize;
857 let Defs = [EDI], Uses = [EAX,EDI,EFLAGS] in
858 def STOSD : I<0xAB, RawFrm, (outs), (ins), "{stosl|stosd}", []>;
860 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
861 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
862 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
864 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
865 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
866 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
868 let Defs = [RAX, RDX] in
869 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
872 let Defs = [RAX, RCX, RDX] in
873 def RDTSCP : I<0x01, MRM_F9, (outs), (ins), "rdtscp", []>, TB;
875 let isBarrier = 1, hasCtrlDep = 1 in {
876 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
879 def SYSCALL : I<0x05, RawFrm,
880 (outs), (ins), "syscall", []>, TB;
881 def SYSRET : I<0x07, RawFrm,
882 (outs), (ins), "sysret", []>, TB;
883 def SYSENTER : I<0x34, RawFrm,
884 (outs), (ins), "sysenter", []>, TB;
885 def SYSEXIT : I<0x35, RawFrm,
886 (outs), (ins), "sysexit", []>, TB;
888 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
891 //===----------------------------------------------------------------------===//
892 // Input/Output Instructions...
894 let Defs = [AL], Uses = [DX] in
895 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
896 "in{b}\t{%dx, %al|%AL, %DX}", []>;
897 let Defs = [AX], Uses = [DX] in
898 def IN16rr : I<0xED, RawFrm, (outs), (ins),
899 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
900 let Defs = [EAX], Uses = [DX] in
901 def IN32rr : I<0xED, RawFrm, (outs), (ins),
902 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
905 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
906 "in{b}\t{$port, %al|%AL, $port}", []>;
908 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
909 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
911 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
912 "in{l}\t{$port, %eax|%EAX, $port}", []>;
914 let Uses = [DX, AL] in
915 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
916 "out{b}\t{%al, %dx|%DX, %AL}", []>;
917 let Uses = [DX, AX] in
918 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
919 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
920 let Uses = [DX, EAX] in
921 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
922 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
925 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
926 "out{b}\t{%al, $port|$port, %AL}", []>;
928 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
929 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
931 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
932 "out{l}\t{%eax, $port|$port, %EAX}", []>;
934 def IN8 : I<0x6C, RawFrm, (outs), (ins),
936 def IN16 : I<0x6D, RawFrm, (outs), (ins),
937 "ins{w}", []>, OpSize;
938 def IN32 : I<0x6D, RawFrm, (outs), (ins),
941 //===----------------------------------------------------------------------===//
942 // Move Instructions...
944 let neverHasSideEffects = 1 in {
945 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
946 "mov{b}\t{$src, $dst|$dst, $src}", []>;
947 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
948 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
949 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
950 "mov{l}\t{$src, $dst|$dst, $src}", []>;
952 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
953 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
954 "mov{b}\t{$src, $dst|$dst, $src}",
955 [(set GR8:$dst, imm:$src)]>;
956 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
957 "mov{w}\t{$src, $dst|$dst, $src}",
958 [(set GR16:$dst, imm:$src)]>, OpSize;
959 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
960 "mov{l}\t{$src, $dst|$dst, $src}",
961 [(set GR32:$dst, imm:$src)]>;
964 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
965 "mov{b}\t{$src, $dst|$dst, $src}",
966 [(store (i8 imm:$src), addr:$dst)]>;
967 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
968 "mov{w}\t{$src, $dst|$dst, $src}",
969 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
970 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
971 "mov{l}\t{$src, $dst|$dst, $src}",
972 [(store (i32 imm:$src), addr:$dst)]>;
974 def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
975 "mov{b}\t{$src, %al|%al, $src}", []>;
976 def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
977 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
978 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
979 "mov{l}\t{$src, %eax|%eax, $src}", []>;
981 def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
982 "mov{b}\t{%al, $dst|$dst, %al}", []>;
983 def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
984 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
985 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
986 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
988 // Moves to and from segment registers
989 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
990 "mov{w}\t{$src, $dst|$dst, $src}", []>;
991 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
992 "mov{w}\t{$src, $dst|$dst, $src}", []>;
993 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
994 "mov{w}\t{$src, $dst|$dst, $src}", []>;
995 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
996 "mov{w}\t{$src, $dst|$dst, $src}", []>;
998 def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
999 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1000 def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1001 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1002 def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1003 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1005 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1006 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
1007 "mov{b}\t{$src, $dst|$dst, $src}",
1008 [(set GR8:$dst, (loadi8 addr:$src))]>;
1009 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
1010 "mov{w}\t{$src, $dst|$dst, $src}",
1011 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
1012 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
1013 "mov{l}\t{$src, $dst|$dst, $src}",
1014 [(set GR32:$dst, (loadi32 addr:$src))]>;
1017 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
1018 "mov{b}\t{$src, $dst|$dst, $src}",
1019 [(store GR8:$src, addr:$dst)]>;
1020 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1021 "mov{w}\t{$src, $dst|$dst, $src}",
1022 [(store GR16:$src, addr:$dst)]>, OpSize;
1023 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1024 "mov{l}\t{$src, $dst|$dst, $src}",
1025 [(store GR32:$src, addr:$dst)]>;
1027 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1028 // that they can be used for copying and storing h registers, which can't be
1029 // encoded when a REX prefix is present.
1030 let neverHasSideEffects = 1 in
1031 def MOV8rr_NOREX : I<0x88, MRMDestReg,
1032 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
1033 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1035 def MOV8mr_NOREX : I<0x88, MRMDestMem,
1036 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1037 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1039 canFoldAsLoad = 1, isReMaterializable = 1 in
1040 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1041 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1042 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1044 // Moves to and from debug registers
1045 def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1046 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1047 def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1048 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1050 // Moves to and from control registers
1051 def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1052 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1053 def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1054 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1056 //===----------------------------------------------------------------------===//
1057 // Fixed-Register Multiplication and Division Instructions...
1060 // Extra precision multiplication
1062 // AL is really implied by AX, by the registers in Defs must match the
1063 // SDNode results (i8, i32).
1064 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1065 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
1066 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1067 // This probably ought to be moved to a def : Pat<> if the
1068 // syntax can be accepted.
1069 [(set AL, (mul AL, GR8:$src)),
1070 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1072 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1073 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1075 []>, OpSize; // AX,DX = AX*GR16
1077 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1078 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1080 []>; // EAX,EDX = EAX*GR32
1082 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1083 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1085 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1086 // This probably ought to be moved to a def : Pat<> if the
1087 // syntax can be accepted.
1088 [(set AL, (mul AL, (loadi8 addr:$src))),
1089 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1091 let mayLoad = 1, neverHasSideEffects = 1 in {
1092 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1093 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1095 []>, OpSize; // AX,DX = AX*[mem16]
1097 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1098 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1100 []>; // EAX,EDX = EAX*[mem32]
1103 let neverHasSideEffects = 1 in {
1104 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1105 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1107 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1108 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
1109 OpSize; // AX,DX = AX*GR16
1110 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1111 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1112 // EAX,EDX = EAX*GR32
1113 let mayLoad = 1 in {
1114 let Defs = [AL,EFLAGS,AX], Uses = [AL] in
1115 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1116 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
1117 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1118 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1119 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1120 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1121 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1122 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
1124 } // neverHasSideEffects
1126 // unsigned division/remainder
1127 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1128 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1129 "div{b}\t$src", []>;
1130 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1131 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1132 "div{w}\t$src", []>, OpSize;
1133 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1134 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1135 "div{l}\t$src", []>;
1136 let mayLoad = 1 in {
1137 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1138 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1139 "div{b}\t$src", []>;
1140 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1141 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1142 "div{w}\t$src", []>, OpSize;
1143 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1144 // EDX:EAX/[mem32] = EAX,EDX
1145 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
1146 "div{l}\t$src", []>;
1149 // Signed division/remainder.
1150 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1151 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1152 "idiv{b}\t$src", []>;
1153 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1154 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1155 "idiv{w}\t$src", []>, OpSize;
1156 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1157 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1158 "idiv{l}\t$src", []>;
1159 let mayLoad = 1, mayLoad = 1 in {
1160 let Defs = [AL,EFLAGS,AX], Uses = [AX] in
1161 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1162 "idiv{b}\t$src", []>;
1163 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1164 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1165 "idiv{w}\t$src", []>, OpSize;
1166 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1167 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1168 // EDX:EAX/[mem32] = EAX,EDX
1169 "idiv{l}\t$src", []>;
1172 //===----------------------------------------------------------------------===//
1173 // Two address Instructions.
1175 let isTwoAddress = 1 in {
1177 // Conditional moves
1178 let Uses = [EFLAGS] in {
1180 // X86 doesn't have 8-bit conditional moves. Use a customInserter to
1181 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1182 // however that requires promoting the operands, and can induce additional
1183 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1184 // clobber EFLAGS, because if one of the operands is zero, the expansion
1185 // could involve an xor.
1186 let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
1187 def CMOV_GR8 : I<0, Pseudo,
1188 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1189 "#CMOV_GR8 PSEUDO!",
1190 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1191 imm:$cond, EFLAGS))]>;
1193 let isCommutable = 1 in {
1194 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1195 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1196 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1197 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1198 X86_COND_B, EFLAGS))]>,
1200 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1201 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1202 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1203 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1204 X86_COND_B, EFLAGS))]>,
1206 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1207 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1208 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1209 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1210 X86_COND_AE, EFLAGS))]>,
1212 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1213 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1214 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1215 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1216 X86_COND_AE, EFLAGS))]>,
1218 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1219 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1220 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1221 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1222 X86_COND_E, EFLAGS))]>,
1224 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1225 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1226 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1227 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1228 X86_COND_E, EFLAGS))]>,
1230 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1231 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1232 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1233 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1234 X86_COND_NE, EFLAGS))]>,
1236 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1237 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1238 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1239 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1240 X86_COND_NE, EFLAGS))]>,
1242 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1243 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1244 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1245 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1246 X86_COND_BE, EFLAGS))]>,
1248 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1249 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1250 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1251 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1252 X86_COND_BE, EFLAGS))]>,
1254 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1255 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1256 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1257 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1258 X86_COND_A, EFLAGS))]>,
1260 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1261 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1262 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1263 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1264 X86_COND_A, EFLAGS))]>,
1266 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1267 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1268 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1269 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1270 X86_COND_L, EFLAGS))]>,
1272 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1273 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1274 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1275 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1276 X86_COND_L, EFLAGS))]>,
1278 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1279 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1280 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1281 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1282 X86_COND_GE, EFLAGS))]>,
1284 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1285 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1286 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1287 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1288 X86_COND_GE, EFLAGS))]>,
1290 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1291 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1292 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1293 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1294 X86_COND_LE, EFLAGS))]>,
1296 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1297 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1298 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1299 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1300 X86_COND_LE, EFLAGS))]>,
1302 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1303 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1304 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1305 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1306 X86_COND_G, EFLAGS))]>,
1308 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1309 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1310 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1311 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1312 X86_COND_G, EFLAGS))]>,
1314 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1315 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1316 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1317 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1318 X86_COND_S, EFLAGS))]>,
1320 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1321 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1322 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1323 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1324 X86_COND_S, EFLAGS))]>,
1326 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1327 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1328 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1329 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1330 X86_COND_NS, EFLAGS))]>,
1332 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1333 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1334 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1335 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1336 X86_COND_NS, EFLAGS))]>,
1338 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1339 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1340 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1341 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1342 X86_COND_P, EFLAGS))]>,
1344 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1345 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1346 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1347 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1348 X86_COND_P, EFLAGS))]>,
1350 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1351 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1352 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1353 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1354 X86_COND_NP, EFLAGS))]>,
1356 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1357 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1358 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1359 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1360 X86_COND_NP, EFLAGS))]>,
1362 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1363 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1364 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1365 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1366 X86_COND_O, EFLAGS))]>,
1368 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1369 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1370 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1371 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1372 X86_COND_O, EFLAGS))]>,
1374 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1375 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1376 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1377 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1378 X86_COND_NO, EFLAGS))]>,
1380 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1381 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1382 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1383 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1384 X86_COND_NO, EFLAGS))]>,
1386 } // isCommutable = 1
1388 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1389 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1390 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1391 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1392 X86_COND_B, EFLAGS))]>,
1394 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1395 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1396 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1397 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1398 X86_COND_B, EFLAGS))]>,
1400 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1401 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1402 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1403 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1404 X86_COND_AE, EFLAGS))]>,
1406 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1407 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1408 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1409 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1410 X86_COND_AE, EFLAGS))]>,
1412 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1413 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1414 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1415 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1416 X86_COND_E, EFLAGS))]>,
1418 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1419 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1420 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1421 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1422 X86_COND_E, EFLAGS))]>,
1424 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1425 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1426 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1427 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1428 X86_COND_NE, EFLAGS))]>,
1430 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1431 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1432 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1433 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1434 X86_COND_NE, EFLAGS))]>,
1436 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1437 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1438 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1439 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1440 X86_COND_BE, EFLAGS))]>,
1442 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1443 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1444 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1445 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1446 X86_COND_BE, EFLAGS))]>,
1448 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1449 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1450 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1451 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1452 X86_COND_A, EFLAGS))]>,
1454 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1455 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1456 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1457 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1458 X86_COND_A, EFLAGS))]>,
1460 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1461 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1462 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1463 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1464 X86_COND_L, EFLAGS))]>,
1466 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1467 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1468 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1469 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1470 X86_COND_L, EFLAGS))]>,
1472 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1473 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1474 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1475 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1476 X86_COND_GE, EFLAGS))]>,
1478 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1479 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1480 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1481 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1482 X86_COND_GE, EFLAGS))]>,
1484 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1485 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1486 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1487 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1488 X86_COND_LE, EFLAGS))]>,
1490 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1491 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1492 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1493 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1494 X86_COND_LE, EFLAGS))]>,
1496 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1497 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1498 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1499 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1500 X86_COND_G, EFLAGS))]>,
1502 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1503 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1504 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1505 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1506 X86_COND_G, EFLAGS))]>,
1508 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1509 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1510 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1511 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1512 X86_COND_S, EFLAGS))]>,
1514 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1515 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1516 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1517 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1518 X86_COND_S, EFLAGS))]>,
1520 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1521 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1522 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1523 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1524 X86_COND_NS, EFLAGS))]>,
1526 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1527 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1528 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1529 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1530 X86_COND_NS, EFLAGS))]>,
1532 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1533 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1534 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1535 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1536 X86_COND_P, EFLAGS))]>,
1538 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1539 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1540 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1541 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1542 X86_COND_P, EFLAGS))]>,
1544 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1545 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1546 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1547 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1548 X86_COND_NP, EFLAGS))]>,
1550 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1551 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1552 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1553 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1554 X86_COND_NP, EFLAGS))]>,
1556 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1557 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1558 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1559 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1560 X86_COND_O, EFLAGS))]>,
1562 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1563 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1564 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1565 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1566 X86_COND_O, EFLAGS))]>,
1568 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1569 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1570 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1571 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1572 X86_COND_NO, EFLAGS))]>,
1574 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1575 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1576 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1577 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1578 X86_COND_NO, EFLAGS))]>,
1580 } // Uses = [EFLAGS]
1583 // unary instructions
1584 let CodeSize = 2 in {
1585 let Defs = [EFLAGS] in {
1586 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1587 [(set GR8:$dst, (ineg GR8:$src)),
1588 (implicit EFLAGS)]>;
1589 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1590 [(set GR16:$dst, (ineg GR16:$src)),
1591 (implicit EFLAGS)]>, OpSize;
1592 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1593 [(set GR32:$dst, (ineg GR32:$src)),
1594 (implicit EFLAGS)]>;
1595 let isTwoAddress = 0 in {
1596 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1597 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1598 (implicit EFLAGS)]>;
1599 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1600 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1601 (implicit EFLAGS)]>, OpSize;
1602 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1603 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1604 (implicit EFLAGS)]>;
1606 } // Defs = [EFLAGS]
1608 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1609 let AddedComplexity = 15 in {
1610 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1611 [(set GR8:$dst, (not GR8:$src))]>;
1612 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1613 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1614 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1615 [(set GR32:$dst, (not GR32:$src))]>;
1617 let isTwoAddress = 0 in {
1618 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1619 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1620 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1621 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1622 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1623 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1627 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1628 let Defs = [EFLAGS] in {
1630 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1631 [(set GR8:$dst, (add GR8:$src, 1)),
1632 (implicit EFLAGS)]>;
1633 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1634 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1636 [(set GR16:$dst, (add GR16:$src, 1)),
1637 (implicit EFLAGS)]>,
1638 OpSize, Requires<[In32BitMode]>;
1639 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1641 [(set GR32:$dst, (add GR32:$src, 1)),
1642 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1644 let isTwoAddress = 0, CodeSize = 2 in {
1645 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1646 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1647 (implicit EFLAGS)]>;
1648 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1649 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1650 (implicit EFLAGS)]>,
1651 OpSize, Requires<[In32BitMode]>;
1652 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1653 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1654 (implicit EFLAGS)]>,
1655 Requires<[In32BitMode]>;
1659 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1660 [(set GR8:$dst, (add GR8:$src, -1)),
1661 (implicit EFLAGS)]>;
1662 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1663 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1665 [(set GR16:$dst, (add GR16:$src, -1)),
1666 (implicit EFLAGS)]>,
1667 OpSize, Requires<[In32BitMode]>;
1668 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1670 [(set GR32:$dst, (add GR32:$src, -1)),
1671 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1674 let isTwoAddress = 0, CodeSize = 2 in {
1675 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1676 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1677 (implicit EFLAGS)]>;
1678 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1679 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1680 (implicit EFLAGS)]>,
1681 OpSize, Requires<[In32BitMode]>;
1682 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1683 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1684 (implicit EFLAGS)]>,
1685 Requires<[In32BitMode]>;
1687 } // Defs = [EFLAGS]
1689 // Logical operators...
1690 let Defs = [EFLAGS] in {
1691 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1692 def AND8rr : I<0x20, MRMDestReg,
1693 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1694 "and{b}\t{$src2, $dst|$dst, $src2}",
1695 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1696 (implicit EFLAGS)]>;
1697 def AND16rr : I<0x21, MRMDestReg,
1698 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1699 "and{w}\t{$src2, $dst|$dst, $src2}",
1700 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1701 (implicit EFLAGS)]>, OpSize;
1702 def AND32rr : I<0x21, MRMDestReg,
1703 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1704 "and{l}\t{$src2, $dst|$dst, $src2}",
1705 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1706 (implicit EFLAGS)]>;
1709 // AND instructions with the destination register in REG and the source register
1710 // in R/M. Included for the disassembler.
1711 def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1712 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1713 def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1714 (ins GR16:$src1, GR16:$src2),
1715 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1716 def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1717 (ins GR32:$src1, GR32:$src2),
1718 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1720 def AND8rm : I<0x22, MRMSrcMem,
1721 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1722 "and{b}\t{$src2, $dst|$dst, $src2}",
1723 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1724 (implicit EFLAGS)]>;
1725 def AND16rm : I<0x23, MRMSrcMem,
1726 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1727 "and{w}\t{$src2, $dst|$dst, $src2}",
1728 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1729 (implicit EFLAGS)]>, OpSize;
1730 def AND32rm : I<0x23, MRMSrcMem,
1731 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1732 "and{l}\t{$src2, $dst|$dst, $src2}",
1733 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1734 (implicit EFLAGS)]>;
1736 def AND8ri : Ii8<0x80, MRM4r,
1737 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1738 "and{b}\t{$src2, $dst|$dst, $src2}",
1739 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1740 (implicit EFLAGS)]>;
1741 def AND16ri : Ii16<0x81, MRM4r,
1742 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1743 "and{w}\t{$src2, $dst|$dst, $src2}",
1744 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1745 (implicit EFLAGS)]>, OpSize;
1746 def AND32ri : Ii32<0x81, MRM4r,
1747 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1748 "and{l}\t{$src2, $dst|$dst, $src2}",
1749 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1750 (implicit EFLAGS)]>;
1751 def AND16ri8 : Ii8<0x83, MRM4r,
1752 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1753 "and{w}\t{$src2, $dst|$dst, $src2}",
1754 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1755 (implicit EFLAGS)]>,
1757 def AND32ri8 : Ii8<0x83, MRM4r,
1758 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1759 "and{l}\t{$src2, $dst|$dst, $src2}",
1760 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1761 (implicit EFLAGS)]>;
1763 let isTwoAddress = 0 in {
1764 def AND8mr : I<0x20, MRMDestMem,
1765 (outs), (ins i8mem :$dst, GR8 :$src),
1766 "and{b}\t{$src, $dst|$dst, $src}",
1767 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1768 (implicit EFLAGS)]>;
1769 def AND16mr : I<0x21, MRMDestMem,
1770 (outs), (ins i16mem:$dst, GR16:$src),
1771 "and{w}\t{$src, $dst|$dst, $src}",
1772 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1773 (implicit EFLAGS)]>,
1775 def AND32mr : I<0x21, MRMDestMem,
1776 (outs), (ins i32mem:$dst, GR32:$src),
1777 "and{l}\t{$src, $dst|$dst, $src}",
1778 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1779 (implicit EFLAGS)]>;
1780 def AND8mi : Ii8<0x80, MRM4m,
1781 (outs), (ins i8mem :$dst, i8imm :$src),
1782 "and{b}\t{$src, $dst|$dst, $src}",
1783 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1784 (implicit EFLAGS)]>;
1785 def AND16mi : Ii16<0x81, MRM4m,
1786 (outs), (ins i16mem:$dst, i16imm:$src),
1787 "and{w}\t{$src, $dst|$dst, $src}",
1788 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1789 (implicit EFLAGS)]>,
1791 def AND32mi : Ii32<0x81, MRM4m,
1792 (outs), (ins i32mem:$dst, i32imm:$src),
1793 "and{l}\t{$src, $dst|$dst, $src}",
1794 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1795 (implicit EFLAGS)]>;
1796 def AND16mi8 : Ii8<0x83, MRM4m,
1797 (outs), (ins i16mem:$dst, i16i8imm :$src),
1798 "and{w}\t{$src, $dst|$dst, $src}",
1799 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1800 (implicit EFLAGS)]>,
1802 def AND32mi8 : Ii8<0x83, MRM4m,
1803 (outs), (ins i32mem:$dst, i32i8imm :$src),
1804 "and{l}\t{$src, $dst|$dst, $src}",
1805 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1806 (implicit EFLAGS)]>;
1808 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1809 "and{b}\t{$src, %al|%al, $src}", []>;
1810 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1811 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1812 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1813 "and{l}\t{$src, %eax|%eax, $src}", []>;
1818 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1819 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1820 (ins GR8 :$src1, GR8 :$src2),
1821 "or{b}\t{$src2, $dst|$dst, $src2}",
1822 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1823 (implicit EFLAGS)]>;
1824 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1825 (ins GR16:$src1, GR16:$src2),
1826 "or{w}\t{$src2, $dst|$dst, $src2}",
1827 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1828 (implicit EFLAGS)]>, OpSize;
1829 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1830 (ins GR32:$src1, GR32:$src2),
1831 "or{l}\t{$src2, $dst|$dst, $src2}",
1832 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1833 (implicit EFLAGS)]>;
1836 // OR instructions with the destination register in REG and the source register
1837 // in R/M. Included for the disassembler.
1838 def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1839 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1840 def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1841 (ins GR16:$src1, GR16:$src2),
1842 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1843 def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1844 (ins GR32:$src1, GR32:$src2),
1845 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1847 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1848 (ins GR8 :$src1, i8mem :$src2),
1849 "or{b}\t{$src2, $dst|$dst, $src2}",
1850 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1851 (implicit EFLAGS)]>;
1852 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1853 (ins GR16:$src1, i16mem:$src2),
1854 "or{w}\t{$src2, $dst|$dst, $src2}",
1855 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1856 (implicit EFLAGS)]>, OpSize;
1857 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1858 (ins GR32:$src1, i32mem:$src2),
1859 "or{l}\t{$src2, $dst|$dst, $src2}",
1860 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1861 (implicit EFLAGS)]>;
1863 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1864 (ins GR8 :$src1, i8imm:$src2),
1865 "or{b}\t{$src2, $dst|$dst, $src2}",
1866 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1867 (implicit EFLAGS)]>;
1868 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1869 (ins GR16:$src1, i16imm:$src2),
1870 "or{w}\t{$src2, $dst|$dst, $src2}",
1871 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1872 (implicit EFLAGS)]>, OpSize;
1873 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1874 (ins GR32:$src1, i32imm:$src2),
1875 "or{l}\t{$src2, $dst|$dst, $src2}",
1876 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1877 (implicit EFLAGS)]>;
1879 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1880 (ins GR16:$src1, i16i8imm:$src2),
1881 "or{w}\t{$src2, $dst|$dst, $src2}",
1882 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1883 (implicit EFLAGS)]>, OpSize;
1884 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1885 (ins GR32:$src1, i32i8imm:$src2),
1886 "or{l}\t{$src2, $dst|$dst, $src2}",
1887 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1888 (implicit EFLAGS)]>;
1889 let isTwoAddress = 0 in {
1890 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1891 "or{b}\t{$src, $dst|$dst, $src}",
1892 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1893 (implicit EFLAGS)]>;
1894 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1895 "or{w}\t{$src, $dst|$dst, $src}",
1896 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1897 (implicit EFLAGS)]>, OpSize;
1898 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1899 "or{l}\t{$src, $dst|$dst, $src}",
1900 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1901 (implicit EFLAGS)]>;
1902 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1903 "or{b}\t{$src, $dst|$dst, $src}",
1904 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1905 (implicit EFLAGS)]>;
1906 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1907 "or{w}\t{$src, $dst|$dst, $src}",
1908 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1909 (implicit EFLAGS)]>,
1911 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1912 "or{l}\t{$src, $dst|$dst, $src}",
1913 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1914 (implicit EFLAGS)]>;
1915 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1916 "or{w}\t{$src, $dst|$dst, $src}",
1917 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1918 (implicit EFLAGS)]>,
1920 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1921 "or{l}\t{$src, $dst|$dst, $src}",
1922 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1923 (implicit EFLAGS)]>;
1925 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1926 "or{b}\t{$src, %al|%al, $src}", []>;
1927 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1928 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1929 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1930 "or{l}\t{$src, %eax|%eax, $src}", []>;
1931 } // isTwoAddress = 0
1934 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1935 def XOR8rr : I<0x30, MRMDestReg,
1936 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1937 "xor{b}\t{$src2, $dst|$dst, $src2}",
1938 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1939 (implicit EFLAGS)]>;
1940 def XOR16rr : I<0x31, MRMDestReg,
1941 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1942 "xor{w}\t{$src2, $dst|$dst, $src2}",
1943 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1944 (implicit EFLAGS)]>, OpSize;
1945 def XOR32rr : I<0x31, MRMDestReg,
1946 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1947 "xor{l}\t{$src2, $dst|$dst, $src2}",
1948 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1949 (implicit EFLAGS)]>;
1950 } // isCommutable = 1
1952 // XOR instructions with the destination register in REG and the source register
1953 // in R/M. Included for the disassembler.
1954 def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1955 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1956 def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1957 (ins GR16:$src1, GR16:$src2),
1958 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1959 def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1960 (ins GR32:$src1, GR32:$src2),
1961 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1963 def XOR8rm : I<0x32, MRMSrcMem ,
1964 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1965 "xor{b}\t{$src2, $dst|$dst, $src2}",
1966 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1967 (implicit EFLAGS)]>;
1968 def XOR16rm : I<0x33, MRMSrcMem ,
1969 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1970 "xor{w}\t{$src2, $dst|$dst, $src2}",
1971 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1972 (implicit EFLAGS)]>,
1974 def XOR32rm : I<0x33, MRMSrcMem ,
1975 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1976 "xor{l}\t{$src2, $dst|$dst, $src2}",
1977 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1978 (implicit EFLAGS)]>;
1980 def XOR8ri : Ii8<0x80, MRM6r,
1981 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1982 "xor{b}\t{$src2, $dst|$dst, $src2}",
1983 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1984 (implicit EFLAGS)]>;
1985 def XOR16ri : Ii16<0x81, MRM6r,
1986 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1987 "xor{w}\t{$src2, $dst|$dst, $src2}",
1988 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1989 (implicit EFLAGS)]>, OpSize;
1990 def XOR32ri : Ii32<0x81, MRM6r,
1991 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1992 "xor{l}\t{$src2, $dst|$dst, $src2}",
1993 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1994 (implicit EFLAGS)]>;
1995 def XOR16ri8 : Ii8<0x83, MRM6r,
1996 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1997 "xor{w}\t{$src2, $dst|$dst, $src2}",
1998 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1999 (implicit EFLAGS)]>,
2001 def XOR32ri8 : Ii8<0x83, MRM6r,
2002 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2003 "xor{l}\t{$src2, $dst|$dst, $src2}",
2004 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2005 (implicit EFLAGS)]>;
2007 let isTwoAddress = 0 in {
2008 def XOR8mr : I<0x30, MRMDestMem,
2009 (outs), (ins i8mem :$dst, GR8 :$src),
2010 "xor{b}\t{$src, $dst|$dst, $src}",
2011 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2012 (implicit EFLAGS)]>;
2013 def XOR16mr : I<0x31, MRMDestMem,
2014 (outs), (ins i16mem:$dst, GR16:$src),
2015 "xor{w}\t{$src, $dst|$dst, $src}",
2016 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2017 (implicit EFLAGS)]>,
2019 def XOR32mr : I<0x31, MRMDestMem,
2020 (outs), (ins i32mem:$dst, GR32:$src),
2021 "xor{l}\t{$src, $dst|$dst, $src}",
2022 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2023 (implicit EFLAGS)]>;
2024 def XOR8mi : Ii8<0x80, MRM6m,
2025 (outs), (ins i8mem :$dst, i8imm :$src),
2026 "xor{b}\t{$src, $dst|$dst, $src}",
2027 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2028 (implicit EFLAGS)]>;
2029 def XOR16mi : Ii16<0x81, MRM6m,
2030 (outs), (ins i16mem:$dst, i16imm:$src),
2031 "xor{w}\t{$src, $dst|$dst, $src}",
2032 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2033 (implicit EFLAGS)]>,
2035 def XOR32mi : Ii32<0x81, MRM6m,
2036 (outs), (ins i32mem:$dst, i32imm:$src),
2037 "xor{l}\t{$src, $dst|$dst, $src}",
2038 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2039 (implicit EFLAGS)]>;
2040 def XOR16mi8 : Ii8<0x83, MRM6m,
2041 (outs), (ins i16mem:$dst, i16i8imm :$src),
2042 "xor{w}\t{$src, $dst|$dst, $src}",
2043 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2044 (implicit EFLAGS)]>,
2046 def XOR32mi8 : Ii8<0x83, MRM6m,
2047 (outs), (ins i32mem:$dst, i32i8imm :$src),
2048 "xor{l}\t{$src, $dst|$dst, $src}",
2049 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2050 (implicit EFLAGS)]>;
2052 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2053 "xor{b}\t{$src, %al|%al, $src}", []>;
2054 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2055 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2056 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2057 "xor{l}\t{$src, %eax|%eax, $src}", []>;
2058 } // isTwoAddress = 0
2059 } // Defs = [EFLAGS]
2061 // Shift instructions
2062 let Defs = [EFLAGS] in {
2063 let Uses = [CL] in {
2064 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
2065 "shl{b}\t{%cl, $dst|$dst, CL}",
2066 [(set GR8:$dst, (shl GR8:$src, CL))]>;
2067 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
2068 "shl{w}\t{%cl, $dst|$dst, CL}",
2069 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
2070 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
2071 "shl{l}\t{%cl, $dst|$dst, CL}",
2072 [(set GR32:$dst, (shl GR32:$src, CL))]>;
2075 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2076 "shl{b}\t{$src2, $dst|$dst, $src2}",
2077 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2078 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2079 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2080 "shl{w}\t{$src2, $dst|$dst, $src2}",
2081 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2082 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2083 "shl{l}\t{$src2, $dst|$dst, $src2}",
2084 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
2086 // NOTE: We don't include patterns for shifts of a register by one, because
2087 // 'add reg,reg' is cheaper.
2089 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2090 "shl{b}\t$dst", []>;
2091 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2092 "shl{w}\t$dst", []>, OpSize;
2093 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2094 "shl{l}\t$dst", []>;
2096 } // isConvertibleToThreeAddress = 1
2098 let isTwoAddress = 0 in {
2099 let Uses = [CL] in {
2100 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
2101 "shl{b}\t{%cl, $dst|$dst, CL}",
2102 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
2103 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
2104 "shl{w}\t{%cl, $dst|$dst, CL}",
2105 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2106 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
2107 "shl{l}\t{%cl, $dst|$dst, CL}",
2108 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2110 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
2111 "shl{b}\t{$src, $dst|$dst, $src}",
2112 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2113 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
2114 "shl{w}\t{$src, $dst|$dst, $src}",
2115 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2117 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
2118 "shl{l}\t{$src, $dst|$dst, $src}",
2119 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2122 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2124 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2125 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2127 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2129 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2131 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2134 let Uses = [CL] in {
2135 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
2136 "shr{b}\t{%cl, $dst|$dst, CL}",
2137 [(set GR8:$dst, (srl GR8:$src, CL))]>;
2138 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
2139 "shr{w}\t{%cl, $dst|$dst, CL}",
2140 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
2141 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
2142 "shr{l}\t{%cl, $dst|$dst, CL}",
2143 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2146 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2147 "shr{b}\t{$src2, $dst|$dst, $src2}",
2148 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2149 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2150 "shr{w}\t{$src2, $dst|$dst, $src2}",
2151 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2152 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2153 "shr{l}\t{$src2, $dst|$dst, $src2}",
2154 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2157 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2159 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2160 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2162 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2163 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2165 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2167 let isTwoAddress = 0 in {
2168 let Uses = [CL] in {
2169 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2170 "shr{b}\t{%cl, $dst|$dst, CL}",
2171 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2172 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2173 "shr{w}\t{%cl, $dst|$dst, CL}",
2174 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2176 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2177 "shr{l}\t{%cl, $dst|$dst, CL}",
2178 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2180 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2181 "shr{b}\t{$src, $dst|$dst, $src}",
2182 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2183 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2184 "shr{w}\t{$src, $dst|$dst, $src}",
2185 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2187 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2188 "shr{l}\t{$src, $dst|$dst, $src}",
2189 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2192 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2194 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2195 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2197 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2198 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2200 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2203 let Uses = [CL] in {
2204 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
2205 "sar{b}\t{%cl, $dst|$dst, CL}",
2206 [(set GR8:$dst, (sra GR8:$src, CL))]>;
2207 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
2208 "sar{w}\t{%cl, $dst|$dst, CL}",
2209 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
2210 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
2211 "sar{l}\t{%cl, $dst|$dst, CL}",
2212 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2215 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2216 "sar{b}\t{$src2, $dst|$dst, $src2}",
2217 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2218 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2219 "sar{w}\t{$src2, $dst|$dst, $src2}",
2220 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2222 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2223 "sar{l}\t{$src2, $dst|$dst, $src2}",
2224 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2227 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2229 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2230 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2232 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2233 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2235 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2237 let isTwoAddress = 0 in {
2238 let Uses = [CL] in {
2239 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2240 "sar{b}\t{%cl, $dst|$dst, CL}",
2241 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2242 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2243 "sar{w}\t{%cl, $dst|$dst, CL}",
2244 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2245 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2246 "sar{l}\t{%cl, $dst|$dst, CL}",
2247 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2249 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2250 "sar{b}\t{$src, $dst|$dst, $src}",
2251 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2252 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2253 "sar{w}\t{$src, $dst|$dst, $src}",
2254 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2256 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2257 "sar{l}\t{$src, $dst|$dst, $src}",
2258 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2261 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2263 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2264 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2266 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2268 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2270 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2273 // Rotate instructions
2275 def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2276 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2277 let Uses = [CL] in {
2278 def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2279 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2281 def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2282 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2284 def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2285 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2286 let Uses = [CL] in {
2287 def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2288 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2290 def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2291 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2293 def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2294 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2295 let Uses = [CL] in {
2296 def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2297 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2299 def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2300 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2302 def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2303 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2304 let Uses = [CL] in {
2305 def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2306 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2308 def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2309 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2311 def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2312 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2313 let Uses = [CL] in {
2314 def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2315 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2317 def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2318 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2320 def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2321 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2322 let Uses = [CL] in {
2323 def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2324 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2326 def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2327 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2329 let isTwoAddress = 0 in {
2330 def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst),
2331 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2332 def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2333 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2334 def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst),
2335 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2336 def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2337 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2338 def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst),
2339 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2340 def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2341 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2342 def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst),
2343 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2344 def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt),
2345 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2346 def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst),
2347 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2348 def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt),
2349 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2350 def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst),
2351 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2352 def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt),
2353 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2355 let Uses = [CL] in {
2356 def RCL8mCL : I<0xD2, MRM2m, (outs), (ins i8mem:$dst),
2357 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2358 def RCL16mCL : I<0xD3, MRM2m, (outs), (ins i16mem:$dst),
2359 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2360 def RCL32mCL : I<0xD3, MRM2m, (outs), (ins i32mem:$dst),
2361 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2362 def RCR8mCL : I<0xD2, MRM3m, (outs), (ins i8mem:$dst),
2363 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2364 def RCR16mCL : I<0xD3, MRM3m, (outs), (ins i16mem:$dst),
2365 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2366 def RCR32mCL : I<0xD3, MRM3m, (outs), (ins i32mem:$dst),
2367 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2371 // FIXME: provide shorter instructions when imm8 == 1
2372 let Uses = [CL] in {
2373 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
2374 "rol{b}\t{%cl, $dst|$dst, CL}",
2375 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
2376 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
2377 "rol{w}\t{%cl, $dst|$dst, CL}",
2378 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
2379 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
2380 "rol{l}\t{%cl, $dst|$dst, CL}",
2381 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2384 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2385 "rol{b}\t{$src2, $dst|$dst, $src2}",
2386 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2387 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2388 "rol{w}\t{$src2, $dst|$dst, $src2}",
2389 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2391 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2392 "rol{l}\t{$src2, $dst|$dst, $src2}",
2393 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2396 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2398 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2399 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2401 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2402 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2404 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2406 let isTwoAddress = 0 in {
2407 let Uses = [CL] in {
2408 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2409 "rol{b}\t{%cl, $dst|$dst, CL}",
2410 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2411 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2412 "rol{w}\t{%cl, $dst|$dst, CL}",
2413 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2414 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2415 "rol{l}\t{%cl, $dst|$dst, CL}",
2416 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2418 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2419 "rol{b}\t{$src, $dst|$dst, $src}",
2420 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2421 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2422 "rol{w}\t{$src, $dst|$dst, $src}",
2423 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2425 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2426 "rol{l}\t{$src, $dst|$dst, $src}",
2427 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2430 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2432 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2433 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2435 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2437 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2439 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2442 let Uses = [CL] in {
2443 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2444 "ror{b}\t{%cl, $dst|$dst, CL}",
2445 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2446 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2447 "ror{w}\t{%cl, $dst|$dst, CL}",
2448 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2449 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2450 "ror{l}\t{%cl, $dst|$dst, CL}",
2451 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2454 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2455 "ror{b}\t{$src2, $dst|$dst, $src2}",
2456 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2457 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2458 "ror{w}\t{$src2, $dst|$dst, $src2}",
2459 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2461 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2462 "ror{l}\t{$src2, $dst|$dst, $src2}",
2463 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2466 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2468 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2469 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2471 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2472 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2474 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2476 let isTwoAddress = 0 in {
2477 let Uses = [CL] in {
2478 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2479 "ror{b}\t{%cl, $dst|$dst, CL}",
2480 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2481 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2482 "ror{w}\t{%cl, $dst|$dst, CL}",
2483 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2484 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2485 "ror{l}\t{%cl, $dst|$dst, CL}",
2486 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2488 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2489 "ror{b}\t{$src, $dst|$dst, $src}",
2490 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2491 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2492 "ror{w}\t{$src, $dst|$dst, $src}",
2493 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2495 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2496 "ror{l}\t{$src, $dst|$dst, $src}",
2497 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2500 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2502 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2503 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2505 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2507 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2509 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2514 // Double shift instructions (generalizations of rotate)
2515 let Uses = [CL] in {
2516 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2517 (ins GR32:$src1, GR32:$src2),
2518 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2519 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2520 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2521 (ins GR32:$src1, GR32:$src2),
2522 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2523 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2524 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2525 (ins GR16:$src1, GR16:$src2),
2526 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2527 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2529 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2530 (ins GR16:$src1, GR16:$src2),
2531 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2532 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2536 let isCommutable = 1 in { // These instructions commute to each other.
2537 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2539 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2540 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2541 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2544 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2546 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2547 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2548 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2551 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2553 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2554 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2555 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2558 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2560 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2561 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2562 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2567 let isTwoAddress = 0 in {
2568 let Uses = [CL] in {
2569 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2570 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2571 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2573 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2574 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2575 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2578 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2579 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2580 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2581 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2582 (i8 imm:$src3)), addr:$dst)]>,
2584 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2585 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2586 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2587 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2588 (i8 imm:$src3)), addr:$dst)]>,
2591 let Uses = [CL] in {
2592 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2593 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2594 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2595 addr:$dst)]>, TB, OpSize;
2596 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2597 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2598 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2599 addr:$dst)]>, TB, OpSize;
2601 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2602 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2603 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2604 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2605 (i8 imm:$src3)), addr:$dst)]>,
2607 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2608 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2609 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2610 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2611 (i8 imm:$src3)), addr:$dst)]>,
2614 } // Defs = [EFLAGS]
2618 let Defs = [EFLAGS] in {
2619 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2620 // Register-Register Addition
2621 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2622 (ins GR8 :$src1, GR8 :$src2),
2623 "add{b}\t{$src2, $dst|$dst, $src2}",
2624 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2625 (implicit EFLAGS)]>;
2627 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2628 // Register-Register Addition
2629 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2630 (ins GR16:$src1, GR16:$src2),
2631 "add{w}\t{$src2, $dst|$dst, $src2}",
2632 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2633 (implicit EFLAGS)]>, OpSize;
2634 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2635 (ins GR32:$src1, GR32:$src2),
2636 "add{l}\t{$src2, $dst|$dst, $src2}",
2637 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2638 (implicit EFLAGS)]>;
2639 } // end isConvertibleToThreeAddress
2640 } // end isCommutable
2642 // Register-Memory Addition
2643 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2644 (ins GR8 :$src1, i8mem :$src2),
2645 "add{b}\t{$src2, $dst|$dst, $src2}",
2646 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2647 (implicit EFLAGS)]>;
2648 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2649 (ins GR16:$src1, i16mem:$src2),
2650 "add{w}\t{$src2, $dst|$dst, $src2}",
2651 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2652 (implicit EFLAGS)]>, OpSize;
2653 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2654 (ins GR32:$src1, i32mem:$src2),
2655 "add{l}\t{$src2, $dst|$dst, $src2}",
2656 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2657 (implicit EFLAGS)]>;
2659 // Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2660 // ADD16rr, and ADD32rr), but differently encoded.
2661 def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2662 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2663 def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2664 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2665 def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2666 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2668 // Register-Integer Addition
2669 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2670 "add{b}\t{$src2, $dst|$dst, $src2}",
2671 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2672 (implicit EFLAGS)]>;
2674 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2675 // Register-Integer Addition
2676 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2677 (ins GR16:$src1, i16imm:$src2),
2678 "add{w}\t{$src2, $dst|$dst, $src2}",
2679 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2680 (implicit EFLAGS)]>, OpSize;
2681 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2682 (ins GR32:$src1, i32imm:$src2),
2683 "add{l}\t{$src2, $dst|$dst, $src2}",
2684 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2685 (implicit EFLAGS)]>;
2686 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2687 (ins GR16:$src1, i16i8imm:$src2),
2688 "add{w}\t{$src2, $dst|$dst, $src2}",
2689 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2690 (implicit EFLAGS)]>, OpSize;
2691 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2692 (ins GR32:$src1, i32i8imm:$src2),
2693 "add{l}\t{$src2, $dst|$dst, $src2}",
2694 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2695 (implicit EFLAGS)]>;
2698 let isTwoAddress = 0 in {
2699 // Memory-Register Addition
2700 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2701 "add{b}\t{$src2, $dst|$dst, $src2}",
2702 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2703 (implicit EFLAGS)]>;
2704 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2705 "add{w}\t{$src2, $dst|$dst, $src2}",
2706 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2707 (implicit EFLAGS)]>, OpSize;
2708 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2709 "add{l}\t{$src2, $dst|$dst, $src2}",
2710 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2711 (implicit EFLAGS)]>;
2712 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2713 "add{b}\t{$src2, $dst|$dst, $src2}",
2714 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2715 (implicit EFLAGS)]>;
2716 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2717 "add{w}\t{$src2, $dst|$dst, $src2}",
2718 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2719 (implicit EFLAGS)]>, OpSize;
2720 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2721 "add{l}\t{$src2, $dst|$dst, $src2}",
2722 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2723 (implicit EFLAGS)]>;
2724 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2725 "add{w}\t{$src2, $dst|$dst, $src2}",
2726 [(store (add (load addr:$dst), i16immSExt8:$src2),
2728 (implicit EFLAGS)]>, OpSize;
2729 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2730 "add{l}\t{$src2, $dst|$dst, $src2}",
2731 [(store (add (load addr:$dst), i32immSExt8:$src2),
2733 (implicit EFLAGS)]>;
2736 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2737 "add{b}\t{$src, %al|%al, $src}", []>;
2738 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2739 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2740 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2741 "add{l}\t{$src, %eax|%eax, $src}", []>;
2744 let Uses = [EFLAGS] in {
2745 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2746 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2747 "adc{b}\t{$src2, $dst|$dst, $src2}",
2748 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2749 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2750 (ins GR16:$src1, GR16:$src2),
2751 "adc{w}\t{$src2, $dst|$dst, $src2}",
2752 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2753 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2754 (ins GR32:$src1, GR32:$src2),
2755 "adc{l}\t{$src2, $dst|$dst, $src2}",
2756 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2759 def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2760 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2761 def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2762 (ins GR16:$src1, GR16:$src2),
2763 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2764 def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2765 (ins GR32:$src1, GR32:$src2),
2766 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2768 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2769 (ins GR8:$src1, i8mem:$src2),
2770 "adc{b}\t{$src2, $dst|$dst, $src2}",
2771 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2772 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2773 (ins GR16:$src1, i16mem:$src2),
2774 "adc{w}\t{$src2, $dst|$dst, $src2}",
2775 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2777 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2778 (ins GR32:$src1, i32mem:$src2),
2779 "adc{l}\t{$src2, $dst|$dst, $src2}",
2780 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2781 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2782 "adc{b}\t{$src2, $dst|$dst, $src2}",
2783 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2784 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2785 (ins GR16:$src1, i16imm:$src2),
2786 "adc{w}\t{$src2, $dst|$dst, $src2}",
2787 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2788 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2789 (ins GR16:$src1, i16i8imm:$src2),
2790 "adc{w}\t{$src2, $dst|$dst, $src2}",
2791 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2793 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2794 (ins GR32:$src1, i32imm:$src2),
2795 "adc{l}\t{$src2, $dst|$dst, $src2}",
2796 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2797 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2798 (ins GR32:$src1, i32i8imm:$src2),
2799 "adc{l}\t{$src2, $dst|$dst, $src2}",
2800 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2802 let isTwoAddress = 0 in {
2803 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2804 "adc{b}\t{$src2, $dst|$dst, $src2}",
2805 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2806 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2807 "adc{w}\t{$src2, $dst|$dst, $src2}",
2808 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2810 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2811 "adc{l}\t{$src2, $dst|$dst, $src2}",
2812 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2813 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2814 "adc{b}\t{$src2, $dst|$dst, $src2}",
2815 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2816 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2817 "adc{w}\t{$src2, $dst|$dst, $src2}",
2818 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2820 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2821 "adc{w}\t{$src2, $dst|$dst, $src2}",
2822 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2824 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2825 "adc{l}\t{$src2, $dst|$dst, $src2}",
2826 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2827 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2828 "adc{l}\t{$src2, $dst|$dst, $src2}",
2829 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2831 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2832 "adc{b}\t{$src, %al|%al, $src}", []>;
2833 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2834 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2835 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2836 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2838 } // Uses = [EFLAGS]
2840 // Register-Register Subtraction
2841 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2842 "sub{b}\t{$src2, $dst|$dst, $src2}",
2843 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2844 (implicit EFLAGS)]>;
2845 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2846 "sub{w}\t{$src2, $dst|$dst, $src2}",
2847 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2848 (implicit EFLAGS)]>, OpSize;
2849 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2850 "sub{l}\t{$src2, $dst|$dst, $src2}",
2851 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2852 (implicit EFLAGS)]>;
2854 def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2855 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2856 def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2857 (ins GR16:$src1, GR16:$src2),
2858 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2859 def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2860 (ins GR32:$src1, GR32:$src2),
2861 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2863 // Register-Memory Subtraction
2864 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2865 (ins GR8 :$src1, i8mem :$src2),
2866 "sub{b}\t{$src2, $dst|$dst, $src2}",
2867 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2868 (implicit EFLAGS)]>;
2869 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2870 (ins GR16:$src1, i16mem:$src2),
2871 "sub{w}\t{$src2, $dst|$dst, $src2}",
2872 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2873 (implicit EFLAGS)]>, OpSize;
2874 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2875 (ins GR32:$src1, i32mem:$src2),
2876 "sub{l}\t{$src2, $dst|$dst, $src2}",
2877 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2878 (implicit EFLAGS)]>;
2880 // Register-Integer Subtraction
2881 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2882 (ins GR8:$src1, i8imm:$src2),
2883 "sub{b}\t{$src2, $dst|$dst, $src2}",
2884 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2885 (implicit EFLAGS)]>;
2886 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2887 (ins GR16:$src1, i16imm:$src2),
2888 "sub{w}\t{$src2, $dst|$dst, $src2}",
2889 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2890 (implicit EFLAGS)]>, OpSize;
2891 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2892 (ins GR32:$src1, i32imm:$src2),
2893 "sub{l}\t{$src2, $dst|$dst, $src2}",
2894 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2895 (implicit EFLAGS)]>;
2896 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2897 (ins GR16:$src1, i16i8imm:$src2),
2898 "sub{w}\t{$src2, $dst|$dst, $src2}",
2899 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2900 (implicit EFLAGS)]>, OpSize;
2901 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2902 (ins GR32:$src1, i32i8imm:$src2),
2903 "sub{l}\t{$src2, $dst|$dst, $src2}",
2904 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2905 (implicit EFLAGS)]>;
2907 let isTwoAddress = 0 in {
2908 // Memory-Register Subtraction
2909 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2910 "sub{b}\t{$src2, $dst|$dst, $src2}",
2911 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2912 (implicit EFLAGS)]>;
2913 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2914 "sub{w}\t{$src2, $dst|$dst, $src2}",
2915 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2916 (implicit EFLAGS)]>, OpSize;
2917 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2918 "sub{l}\t{$src2, $dst|$dst, $src2}",
2919 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2920 (implicit EFLAGS)]>;
2922 // Memory-Integer Subtraction
2923 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2924 "sub{b}\t{$src2, $dst|$dst, $src2}",
2925 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2926 (implicit EFLAGS)]>;
2927 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2928 "sub{w}\t{$src2, $dst|$dst, $src2}",
2929 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2930 (implicit EFLAGS)]>, OpSize;
2931 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2932 "sub{l}\t{$src2, $dst|$dst, $src2}",
2933 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2934 (implicit EFLAGS)]>;
2935 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2936 "sub{w}\t{$src2, $dst|$dst, $src2}",
2937 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2939 (implicit EFLAGS)]>, OpSize;
2940 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2941 "sub{l}\t{$src2, $dst|$dst, $src2}",
2942 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2944 (implicit EFLAGS)]>;
2946 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2947 "sub{b}\t{$src, %al|%al, $src}", []>;
2948 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2949 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2950 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2951 "sub{l}\t{$src, %eax|%eax, $src}", []>;
2954 let Uses = [EFLAGS] in {
2955 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2956 (ins GR8:$src1, GR8:$src2),
2957 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2958 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2959 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2960 (ins GR16:$src1, GR16:$src2),
2961 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2962 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2963 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2964 (ins GR32:$src1, GR32:$src2),
2965 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2966 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2968 let isTwoAddress = 0 in {
2969 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2970 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2971 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2972 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2973 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2974 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2976 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2977 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2978 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2979 def SBB8mi : Ii8<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2980 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2981 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2982 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2983 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2984 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2986 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2987 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2988 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2990 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2991 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2992 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2993 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2994 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2995 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2997 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2998 "sbb{b}\t{$src, %al|%al, $src}", []>;
2999 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3000 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3001 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3002 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
3005 def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3006 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3007 def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3008 (ins GR16:$src1, GR16:$src2),
3009 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3010 def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3011 (ins GR32:$src1, GR32:$src2),
3012 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3014 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3015 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3016 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
3017 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3018 (ins GR16:$src1, i16mem:$src2),
3019 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3020 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
3022 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3023 (ins GR32:$src1, i32mem:$src2),
3024 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3025 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
3026 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3027 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3028 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
3029 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3030 (ins GR16:$src1, i16imm:$src2),
3031 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3032 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
3033 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3034 (ins GR16:$src1, i16i8imm:$src2),
3035 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3036 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3038 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3039 (ins GR32:$src1, i32imm:$src2),
3040 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3041 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
3042 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3043 (ins GR32:$src1, i32i8imm:$src2),
3044 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3045 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
3046 } // Uses = [EFLAGS]
3047 } // Defs = [EFLAGS]
3049 let Defs = [EFLAGS] in {
3050 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
3051 // Register-Register Signed Integer Multiply
3052 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
3053 "imul{w}\t{$src2, $dst|$dst, $src2}",
3054 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3055 (implicit EFLAGS)]>, TB, OpSize;
3056 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
3057 "imul{l}\t{$src2, $dst|$dst, $src2}",
3058 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3059 (implicit EFLAGS)]>, TB;
3062 // Register-Memory Signed Integer Multiply
3063 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3064 (ins GR16:$src1, i16mem:$src2),
3065 "imul{w}\t{$src2, $dst|$dst, $src2}",
3066 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3067 (implicit EFLAGS)]>, TB, OpSize;
3068 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3069 (ins GR32:$src1, i32mem:$src2),
3070 "imul{l}\t{$src2, $dst|$dst, $src2}",
3071 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3072 (implicit EFLAGS)]>, TB;
3073 } // Defs = [EFLAGS]
3074 } // end Two Address instructions
3076 // Suprisingly enough, these are not two address instructions!
3077 let Defs = [EFLAGS] in {
3078 // Register-Integer Signed Integer Multiply
3079 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
3080 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
3081 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3082 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3083 (implicit EFLAGS)]>, OpSize;
3084 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
3085 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
3086 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3087 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3088 (implicit EFLAGS)]>;
3089 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
3090 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
3091 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3092 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3093 (implicit EFLAGS)]>, OpSize;
3094 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
3095 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
3096 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3097 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3098 (implicit EFLAGS)]>;
3100 // Memory-Integer Signed Integer Multiply
3101 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
3102 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
3103 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3104 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3105 (implicit EFLAGS)]>, OpSize;
3106 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
3107 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
3108 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3109 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3110 (implicit EFLAGS)]>;
3111 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
3112 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
3113 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3114 [(set GR16:$dst, (mul (load addr:$src1),
3115 i16immSExt8:$src2)),
3116 (implicit EFLAGS)]>, OpSize;
3117 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
3118 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
3119 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3120 [(set GR32:$dst, (mul (load addr:$src1),
3121 i32immSExt8:$src2)),
3122 (implicit EFLAGS)]>;
3123 } // Defs = [EFLAGS]
3125 //===----------------------------------------------------------------------===//
3126 // Test instructions are just like AND, except they don't generate a result.
3128 let Defs = [EFLAGS] in {
3129 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
3130 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
3131 "test{b}\t{$src2, $src1|$src1, $src2}",
3132 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
3133 (implicit EFLAGS)]>;
3134 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3135 "test{w}\t{$src2, $src1|$src1, $src2}",
3136 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
3137 (implicit EFLAGS)]>,
3139 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3140 "test{l}\t{$src2, $src1|$src1, $src2}",
3141 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
3142 (implicit EFLAGS)]>;
3145 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3146 "test{b}\t{$src, %al|%al, $src}", []>;
3147 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3148 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3149 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3150 "test{l}\t{$src, %eax|%eax, $src}", []>;
3152 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
3153 "test{b}\t{$src2, $src1|$src1, $src2}",
3154 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3155 (implicit EFLAGS)]>;
3156 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
3157 "test{w}\t{$src2, $src1|$src1, $src2}",
3158 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3159 (implicit EFLAGS)]>, OpSize;
3160 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
3161 "test{l}\t{$src2, $src1|$src1, $src2}",
3162 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3163 (implicit EFLAGS)]>;
3165 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
3166 (outs), (ins GR8:$src1, i8imm:$src2),
3167 "test{b}\t{$src2, $src1|$src1, $src2}",
3168 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
3169 (implicit EFLAGS)]>;
3170 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
3171 (outs), (ins GR16:$src1, i16imm:$src2),
3172 "test{w}\t{$src2, $src1|$src1, $src2}",
3173 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
3174 (implicit EFLAGS)]>, OpSize;
3175 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
3176 (outs), (ins GR32:$src1, i32imm:$src2),
3177 "test{l}\t{$src2, $src1|$src1, $src2}",
3178 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
3179 (implicit EFLAGS)]>;
3181 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
3182 (outs), (ins i8mem:$src1, i8imm:$src2),
3183 "test{b}\t{$src2, $src1|$src1, $src2}",
3184 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3185 (implicit EFLAGS)]>;
3186 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
3187 (outs), (ins i16mem:$src1, i16imm:$src2),
3188 "test{w}\t{$src2, $src1|$src1, $src2}",
3189 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3190 (implicit EFLAGS)]>, OpSize;
3191 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
3192 (outs), (ins i32mem:$src1, i32imm:$src2),
3193 "test{l}\t{$src2, $src1|$src1, $src2}",
3194 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
3195 (implicit EFLAGS)]>;
3196 } // Defs = [EFLAGS]
3199 // Condition code ops, incl. set if equal/not equal/...
3200 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
3201 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
3202 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
3203 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
3205 let Uses = [EFLAGS] in {
3206 // Use sbb to materialize carry bit.
3207 let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3208 // FIXME: These are pseudo ops that should be replaced with Pat<> patterns.
3209 // However, Pat<> can't replicate the destination reg into the inputs of the
3211 // FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces
3213 def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "",
3214 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3215 def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "",
3216 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
3218 def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "",
3219 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3222 def SETEr : I<0x94, MRM0r,
3223 (outs GR8 :$dst), (ins),
3225 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
3227 def SETEm : I<0x94, MRM0m,
3228 (outs), (ins i8mem:$dst),
3230 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
3233 def SETNEr : I<0x95, MRM0r,
3234 (outs GR8 :$dst), (ins),
3236 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
3238 def SETNEm : I<0x95, MRM0m,
3239 (outs), (ins i8mem:$dst),
3241 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
3244 def SETLr : I<0x9C, MRM0r,
3245 (outs GR8 :$dst), (ins),
3247 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
3248 TB; // GR8 = < signed
3249 def SETLm : I<0x9C, MRM0m,
3250 (outs), (ins i8mem:$dst),
3252 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
3253 TB; // [mem8] = < signed
3255 def SETGEr : I<0x9D, MRM0r,
3256 (outs GR8 :$dst), (ins),
3258 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
3259 TB; // GR8 = >= signed
3260 def SETGEm : I<0x9D, MRM0m,
3261 (outs), (ins i8mem:$dst),
3263 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
3264 TB; // [mem8] = >= signed
3266 def SETLEr : I<0x9E, MRM0r,
3267 (outs GR8 :$dst), (ins),
3269 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3270 TB; // GR8 = <= signed
3271 def SETLEm : I<0x9E, MRM0m,
3272 (outs), (ins i8mem:$dst),
3274 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3275 TB; // [mem8] = <= signed
3277 def SETGr : I<0x9F, MRM0r,
3278 (outs GR8 :$dst), (ins),
3280 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3281 TB; // GR8 = > signed
3282 def SETGm : I<0x9F, MRM0m,
3283 (outs), (ins i8mem:$dst),
3285 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3286 TB; // [mem8] = > signed
3288 def SETBr : I<0x92, MRM0r,
3289 (outs GR8 :$dst), (ins),
3291 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3292 TB; // GR8 = < unsign
3293 def SETBm : I<0x92, MRM0m,
3294 (outs), (ins i8mem:$dst),
3296 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3297 TB; // [mem8] = < unsign
3299 def SETAEr : I<0x93, MRM0r,
3300 (outs GR8 :$dst), (ins),
3302 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3303 TB; // GR8 = >= unsign
3304 def SETAEm : I<0x93, MRM0m,
3305 (outs), (ins i8mem:$dst),
3307 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3308 TB; // [mem8] = >= unsign
3310 def SETBEr : I<0x96, MRM0r,
3311 (outs GR8 :$dst), (ins),
3313 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3314 TB; // GR8 = <= unsign
3315 def SETBEm : I<0x96, MRM0m,
3316 (outs), (ins i8mem:$dst),
3318 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3319 TB; // [mem8] = <= unsign
3321 def SETAr : I<0x97, MRM0r,
3322 (outs GR8 :$dst), (ins),
3324 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3325 TB; // GR8 = > signed
3326 def SETAm : I<0x97, MRM0m,
3327 (outs), (ins i8mem:$dst),
3329 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3330 TB; // [mem8] = > signed
3332 def SETSr : I<0x98, MRM0r,
3333 (outs GR8 :$dst), (ins),
3335 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3336 TB; // GR8 = <sign bit>
3337 def SETSm : I<0x98, MRM0m,
3338 (outs), (ins i8mem:$dst),
3340 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3341 TB; // [mem8] = <sign bit>
3342 def SETNSr : I<0x99, MRM0r,
3343 (outs GR8 :$dst), (ins),
3345 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3346 TB; // GR8 = !<sign bit>
3347 def SETNSm : I<0x99, MRM0m,
3348 (outs), (ins i8mem:$dst),
3350 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3351 TB; // [mem8] = !<sign bit>
3353 def SETPr : I<0x9A, MRM0r,
3354 (outs GR8 :$dst), (ins),
3356 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3358 def SETPm : I<0x9A, MRM0m,
3359 (outs), (ins i8mem:$dst),
3361 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3362 TB; // [mem8] = parity
3363 def SETNPr : I<0x9B, MRM0r,
3364 (outs GR8 :$dst), (ins),
3366 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3367 TB; // GR8 = not parity
3368 def SETNPm : I<0x9B, MRM0m,
3369 (outs), (ins i8mem:$dst),
3371 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3372 TB; // [mem8] = not parity
3374 def SETOr : I<0x90, MRM0r,
3375 (outs GR8 :$dst), (ins),
3377 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3378 TB; // GR8 = overflow
3379 def SETOm : I<0x90, MRM0m,
3380 (outs), (ins i8mem:$dst),
3382 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3383 TB; // [mem8] = overflow
3384 def SETNOr : I<0x91, MRM0r,
3385 (outs GR8 :$dst), (ins),
3387 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3388 TB; // GR8 = not overflow
3389 def SETNOm : I<0x91, MRM0m,
3390 (outs), (ins i8mem:$dst),
3392 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3393 TB; // [mem8] = not overflow
3394 } // Uses = [EFLAGS]
3397 // Integer comparisons
3398 let Defs = [EFLAGS] in {
3399 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3400 "cmp{b}\t{$src, %al|%al, $src}", []>;
3401 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3402 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3403 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3404 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3406 def CMP8rr : I<0x38, MRMDestReg,
3407 (outs), (ins GR8 :$src1, GR8 :$src2),
3408 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3409 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
3410 def CMP16rr : I<0x39, MRMDestReg,
3411 (outs), (ins GR16:$src1, GR16:$src2),
3412 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3413 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
3414 def CMP32rr : I<0x39, MRMDestReg,
3415 (outs), (ins GR32:$src1, GR32:$src2),
3416 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3417 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
3418 def CMP8mr : I<0x38, MRMDestMem,
3419 (outs), (ins i8mem :$src1, GR8 :$src2),
3420 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3421 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3422 (implicit EFLAGS)]>;
3423 def CMP16mr : I<0x39, MRMDestMem,
3424 (outs), (ins i16mem:$src1, GR16:$src2),
3425 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3426 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3427 (implicit EFLAGS)]>, OpSize;
3428 def CMP32mr : I<0x39, MRMDestMem,
3429 (outs), (ins i32mem:$src1, GR32:$src2),
3430 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3431 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3432 (implicit EFLAGS)]>;
3433 def CMP8rm : I<0x3A, MRMSrcMem,
3434 (outs), (ins GR8 :$src1, i8mem :$src2),
3435 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3436 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3437 (implicit EFLAGS)]>;
3438 def CMP16rm : I<0x3B, MRMSrcMem,
3439 (outs), (ins GR16:$src1, i16mem:$src2),
3440 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3441 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3442 (implicit EFLAGS)]>, OpSize;
3443 def CMP32rm : I<0x3B, MRMSrcMem,
3444 (outs), (ins GR32:$src1, i32mem:$src2),
3445 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3446 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3447 (implicit EFLAGS)]>;
3448 def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3449 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3450 def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3451 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3452 def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3453 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3454 def CMP8ri : Ii8<0x80, MRM7r,
3455 (outs), (ins GR8:$src1, i8imm:$src2),
3456 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3457 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
3458 def CMP16ri : Ii16<0x81, MRM7r,
3459 (outs), (ins GR16:$src1, i16imm:$src2),
3460 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3461 [(X86cmp GR16:$src1, imm:$src2),
3462 (implicit EFLAGS)]>, OpSize;
3463 def CMP32ri : Ii32<0x81, MRM7r,
3464 (outs), (ins GR32:$src1, i32imm:$src2),
3465 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3466 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
3467 def CMP8mi : Ii8 <0x80, MRM7m,
3468 (outs), (ins i8mem :$src1, i8imm :$src2),
3469 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3470 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3471 (implicit EFLAGS)]>;
3472 def CMP16mi : Ii16<0x81, MRM7m,
3473 (outs), (ins i16mem:$src1, i16imm:$src2),
3474 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3475 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3476 (implicit EFLAGS)]>, OpSize;
3477 def CMP32mi : Ii32<0x81, MRM7m,
3478 (outs), (ins i32mem:$src1, i32imm:$src2),
3479 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3480 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3481 (implicit EFLAGS)]>;
3482 def CMP16ri8 : Ii8<0x83, MRM7r,
3483 (outs), (ins GR16:$src1, i16i8imm:$src2),
3484 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3485 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3486 (implicit EFLAGS)]>, OpSize;
3487 def CMP16mi8 : Ii8<0x83, MRM7m,
3488 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3489 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3490 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3491 (implicit EFLAGS)]>, OpSize;
3492 def CMP32mi8 : Ii8<0x83, MRM7m,
3493 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3494 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3495 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3496 (implicit EFLAGS)]>;
3497 def CMP32ri8 : Ii8<0x83, MRM7r,
3498 (outs), (ins GR32:$src1, i32i8imm:$src2),
3499 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3500 [(X86cmp GR32:$src1, i32immSExt8:$src2),
3501 (implicit EFLAGS)]>;
3502 } // Defs = [EFLAGS]
3505 // TODO: BTC, BTR, and BTS
3506 let Defs = [EFLAGS] in {
3507 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3508 "bt{w}\t{$src2, $src1|$src1, $src2}",
3509 [(X86bt GR16:$src1, GR16:$src2),
3510 (implicit EFLAGS)]>, OpSize, TB;
3511 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3512 "bt{l}\t{$src2, $src1|$src1, $src2}",
3513 [(X86bt GR32:$src1, GR32:$src2),
3514 (implicit EFLAGS)]>, TB;
3516 // Unlike with the register+register form, the memory+register form of the
3517 // bt instruction does not ignore the high bits of the index. From ISel's
3518 // perspective, this is pretty bizarre. Make these instructions disassembly
3521 def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3522 "bt{w}\t{$src2, $src1|$src1, $src2}",
3523 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3524 // (implicit EFLAGS)]
3526 >, OpSize, TB, Requires<[FastBTMem]>;
3527 def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3528 "bt{l}\t{$src2, $src1|$src1, $src2}",
3529 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3530 // (implicit EFLAGS)]
3532 >, TB, Requires<[FastBTMem]>;
3534 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3535 "bt{w}\t{$src2, $src1|$src1, $src2}",
3536 [(X86bt GR16:$src1, i16immSExt8:$src2),
3537 (implicit EFLAGS)]>, OpSize, TB;
3538 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3539 "bt{l}\t{$src2, $src1|$src1, $src2}",
3540 [(X86bt GR32:$src1, i32immSExt8:$src2),
3541 (implicit EFLAGS)]>, TB;
3542 // Note that these instructions don't need FastBTMem because that
3543 // only applies when the other operand is in a register. When it's
3544 // an immediate, bt is still fast.
3545 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3546 "bt{w}\t{$src2, $src1|$src1, $src2}",
3547 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3548 (implicit EFLAGS)]>, OpSize, TB;
3549 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3550 "bt{l}\t{$src2, $src1|$src1, $src2}",
3551 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3552 (implicit EFLAGS)]>, TB;
3554 def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3555 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3556 def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3557 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3558 def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3559 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3560 def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3561 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3562 def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3563 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3564 def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3565 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3566 def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3567 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3568 def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3569 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3571 def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3572 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3573 def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3574 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3575 def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3576 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3577 def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3578 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3579 def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3580 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3581 def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3582 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3583 def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3584 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3585 def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3586 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3588 def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3589 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3590 def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3591 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3592 def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3593 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3594 def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3595 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3596 def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3597 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3598 def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3599 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3600 def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3601 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3602 def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3603 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3604 } // Defs = [EFLAGS]
3606 // Sign/Zero extenders
3607 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3608 // of the register here. This has a smaller encoding and avoids a
3609 // partial-register update. Actual movsbw included for the disassembler.
3610 def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3611 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3612 def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3613 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3614 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3615 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
3616 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3617 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3618 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3619 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3620 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3621 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3622 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3623 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3624 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3625 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3626 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3627 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3628 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3629 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3631 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3632 // of the register here. This has a smaller encoding and avoids a
3633 // partial-register update. Actual movzbw included for the disassembler.
3634 def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3635 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3636 def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3637 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3638 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3639 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
3640 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3641 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3642 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3643 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3644 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3645 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3646 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3647 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3648 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3649 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3650 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3651 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3652 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3653 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3655 // These are the same as the regular MOVZX32rr8 and MOVZX32rm8
3656 // except that they use GR32_NOREX for the output operand register class
3657 // instead of GR32. This allows them to operate on h registers on x86-64.
3658 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3659 (outs GR32_NOREX:$dst), (ins GR8:$src),
3660 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3663 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3664 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3665 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3668 let neverHasSideEffects = 1 in {
3669 let Defs = [AX], Uses = [AL] in
3670 def CBW : I<0x98, RawFrm, (outs), (ins),
3671 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3672 let Defs = [EAX], Uses = [AX] in
3673 def CWDE : I<0x98, RawFrm, (outs), (ins),
3674 "{cwtl|cwde}", []>; // EAX = signext(AX)
3676 let Defs = [AX,DX], Uses = [AX] in
3677 def CWD : I<0x99, RawFrm, (outs), (ins),
3678 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3679 let Defs = [EAX,EDX], Uses = [EAX] in
3680 def CDQ : I<0x99, RawFrm, (outs), (ins),
3681 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3684 //===----------------------------------------------------------------------===//
3685 // Alias Instructions
3686 //===----------------------------------------------------------------------===//
3688 // Alias instructions that map movr0 to xor.
3689 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3690 // FIXME: Set encoding to pseudo.
3691 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3692 isCodeGenOnly = 1 in {
3693 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "",
3694 [(set GR8:$dst, 0)]>;
3696 // We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller
3697 // encoding and avoids a partial-register update sometimes, but doing so
3698 // at isel time interferes with rematerialization in the current register
3699 // allocator. For now, this is rewritten when the instruction is lowered
3701 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3703 [(set GR16:$dst, 0)]>, OpSize;
3705 // FIXME: Set encoding to pseudo.
3706 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "",
3707 [(set GR32:$dst, 0)]>;
3710 //===----------------------------------------------------------------------===//
3711 // Thread Local Storage Instructions
3714 // All calls clobber the non-callee saved registers. ESP is marked as
3715 // a use to prevent stack-pointer assignments that appear immediately
3716 // before calls from potentially appearing dead.
3717 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3718 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3719 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3720 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3722 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3723 "leal\t$sym, %eax; "
3724 "call\t___tls_get_addr@PLT",
3725 [(X86tlsaddr tls32addr:$sym)]>,
3726 Requires<[In32BitMode]>;
3728 let AddedComplexity = 5, isCodeGenOnly = 1 in
3729 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3730 "movl\t%gs:$src, $dst",
3731 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3733 let AddedComplexity = 5, isCodeGenOnly = 1 in
3734 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3735 "movl\t%fs:$src, $dst",
3736 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3738 //===----------------------------------------------------------------------===//
3739 // EH Pseudo Instructions
3741 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3742 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3743 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3744 "ret\t#eh_return, addr: $addr",
3745 [(X86ehret GR32:$addr)]>;
3749 //===----------------------------------------------------------------------===//
3753 // Atomic swap. These are just normal xchg instructions. But since a memory
3754 // operand is referenced, the atomicity is ensured.
3755 let Constraints = "$val = $dst" in {
3756 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3757 (ins GR32:$val, i32mem:$ptr),
3758 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3759 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3760 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3761 (ins GR16:$val, i16mem:$ptr),
3762 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3763 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3765 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3766 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3767 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3769 def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3770 "xchg{l}\t{$val, $src|$src, $val}", []>;
3771 def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3772 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3773 def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3774 "xchg{b}\t{$val, $src|$src, $val}", []>;
3777 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3778 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3779 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3780 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3782 // Atomic compare and swap.
3783 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3784 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3786 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3787 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3789 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3790 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr),
3793 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3796 let Defs = [AX, EFLAGS], Uses = [AX] in {
3797 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3799 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3800 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3802 let Defs = [AL, EFLAGS], Uses = [AL] in {
3803 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3805 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3806 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3809 // Atomic exchange and add
3810 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3811 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
3813 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3814 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3816 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
3818 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3819 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3821 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3823 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3824 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3828 def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3829 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3830 def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3831 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3832 def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3833 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3835 def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3836 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3837 def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3838 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3839 def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3840 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3842 def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3843 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3844 def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3845 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3846 def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3847 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3849 def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3850 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3851 def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3852 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3853 def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3854 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3856 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in
3857 def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3858 "cmpxchg8b\t$dst", []>, TB;
3860 // Optimized codegen when the non-memory output is not used.
3861 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3862 let Defs = [EFLAGS] in {
3863 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3865 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3866 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3868 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3869 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3871 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3872 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3874 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3875 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3877 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3878 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3880 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3881 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3883 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3884 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3886 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3888 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3890 "inc{b}\t$dst", []>, LOCK;
3891 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3893 "inc{w}\t$dst", []>, OpSize, LOCK;
3894 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3896 "inc{l}\t$dst", []>, LOCK;
3898 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3900 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3901 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3903 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3904 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3906 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3907 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3909 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3910 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3912 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3913 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3915 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3916 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3918 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3919 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3921 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3923 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3925 "dec{b}\t$dst", []>, LOCK;
3926 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3928 "dec{w}\t$dst", []>, OpSize, LOCK;
3929 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3931 "dec{l}\t$dst", []>, LOCK;
3934 // Atomic exchange, and, or, xor
3935 let Constraints = "$val = $dst", Defs = [EFLAGS],
3936 usesCustomInserter = 1 in {
3937 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3938 "#ATOMAND32 PSEUDO!",
3939 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3940 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3941 "#ATOMOR32 PSEUDO!",
3942 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3943 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3944 "#ATOMXOR32 PSEUDO!",
3945 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3946 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3947 "#ATOMNAND32 PSEUDO!",
3948 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3949 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3950 "#ATOMMIN32 PSEUDO!",
3951 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3952 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3953 "#ATOMMAX32 PSEUDO!",
3954 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3955 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3956 "#ATOMUMIN32 PSEUDO!",
3957 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3958 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3959 "#ATOMUMAX32 PSEUDO!",
3960 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3962 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3963 "#ATOMAND16 PSEUDO!",
3964 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3965 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3966 "#ATOMOR16 PSEUDO!",
3967 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3968 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3969 "#ATOMXOR16 PSEUDO!",
3970 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3971 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3972 "#ATOMNAND16 PSEUDO!",
3973 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3974 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3975 "#ATOMMIN16 PSEUDO!",
3976 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3977 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3978 "#ATOMMAX16 PSEUDO!",
3979 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3980 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3981 "#ATOMUMIN16 PSEUDO!",
3982 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3983 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3984 "#ATOMUMAX16 PSEUDO!",
3985 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3987 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3988 "#ATOMAND8 PSEUDO!",
3989 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3990 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3992 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3993 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3994 "#ATOMXOR8 PSEUDO!",
3995 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3996 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3997 "#ATOMNAND8 PSEUDO!",
3998 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
4001 let Constraints = "$val1 = $dst1, $val2 = $dst2",
4002 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4003 Uses = [EAX, EBX, ECX, EDX],
4004 mayLoad = 1, mayStore = 1,
4005 usesCustomInserter = 1 in {
4006 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4007 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4008 "#ATOMAND6432 PSEUDO!", []>;
4009 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4010 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4011 "#ATOMOR6432 PSEUDO!", []>;
4012 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4013 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4014 "#ATOMXOR6432 PSEUDO!", []>;
4015 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4016 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4017 "#ATOMNAND6432 PSEUDO!", []>;
4018 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4019 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4020 "#ATOMADD6432 PSEUDO!", []>;
4021 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4022 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4023 "#ATOMSUB6432 PSEUDO!", []>;
4024 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4025 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4026 "#ATOMSWAP6432 PSEUDO!", []>;
4029 // Segmentation support instructions.
4031 def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4032 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4033 def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4034 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4036 // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4037 def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4038 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4039 def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4040 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4042 def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4043 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4044 def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4045 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4046 def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4047 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4048 def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4049 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4051 def INVLPG : I<0x01, MRM7m, (outs), (ins i8mem:$addr), "invlpg\t$addr", []>, TB;
4053 def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4054 "str{w}\t{$dst}", []>, TB;
4055 def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4056 "str{w}\t{$dst}", []>, TB;
4057 def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4058 "ltr{w}\t{$src}", []>, TB;
4059 def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4060 "ltr{w}\t{$src}", []>, TB;
4062 def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4063 "push{w}\t%fs", []>, OpSize, TB;
4064 def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4065 "push{l}\t%fs", []>, TB;
4066 def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4067 "push{w}\t%gs", []>, OpSize, TB;
4068 def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4069 "push{l}\t%gs", []>, TB;
4071 def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4072 "pop{w}\t%fs", []>, OpSize, TB;
4073 def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4074 "pop{l}\t%fs", []>, TB;
4075 def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4076 "pop{w}\t%gs", []>, OpSize, TB;
4077 def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4078 "pop{l}\t%gs", []>, TB;
4080 def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4081 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4082 def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4083 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4084 def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4085 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4086 def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4087 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4088 def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4089 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4090 def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4091 "les{l}\t{$src, $dst|$dst, $src}", []>;
4092 def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4093 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4094 def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4095 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4096 def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4097 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4098 def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4099 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4101 def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4102 "verr\t$seg", []>, TB;
4103 def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4104 "verr\t$seg", []>, TB;
4105 def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4106 "verw\t$seg", []>, TB;
4107 def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4108 "verw\t$seg", []>, TB;
4110 // Descriptor-table support instructions
4112 def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4113 "sgdt\t$dst", []>, TB;
4114 def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4115 "sidt\t$dst", []>, TB;
4116 def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4117 "sldt{w}\t$dst", []>, TB;
4118 def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4119 "sldt{w}\t$dst", []>, TB;
4120 def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4121 "lgdt\t$src", []>, TB;
4122 def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4123 "lidt\t$src", []>, TB;
4124 def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4125 "lldt{w}\t$src", []>, TB;
4126 def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4127 "lldt{w}\t$src", []>, TB;
4129 // Lock instruction prefix
4130 def LOCK_PREFIX : I<0xF0, RawFrm, (outs), (ins), "lock", []>;
4132 // Repeat string operation instruction prefixes
4133 // These uses the DF flag in the EFLAGS register to inc or dec ECX
4134 let Defs = [ECX], Uses = [ECX,EFLAGS] in {
4135 // Repeat (used with INS, OUTS, MOVS, LODS and STOS)
4136 def REP_PREFIX : I<0xF3, RawFrm, (outs), (ins), "rep", []>;
4137 // Repeat while not equal (used with CMPS and SCAS)
4138 def REPNE_PREFIX : I<0xF2, RawFrm, (outs), (ins), "repne", []>;
4141 // Segment override instruction prefixes
4142 def CS_PREFIX : I<0x2E, RawFrm, (outs), (ins), "cs", []>;
4143 def SS_PREFIX : I<0x36, RawFrm, (outs), (ins), "ss", []>;
4144 def DS_PREFIX : I<0x3E, RawFrm, (outs), (ins), "ds", []>;
4145 def ES_PREFIX : I<0x26, RawFrm, (outs), (ins), "es", []>;
4146 def FS_PREFIX : I<0x64, RawFrm, (outs), (ins), "fs", []>;
4147 def GS_PREFIX : I<0x65, RawFrm, (outs), (ins), "gs", []>;
4149 // String manipulation instructions
4151 def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4152 def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
4153 def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4155 def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4156 def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4157 def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4159 // CPU flow control instructions
4161 def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4162 def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4164 // FPU control instructions
4166 def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4168 // Flag instructions
4170 def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4171 def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4172 def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4173 def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4174 def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4175 def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4176 def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4178 def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4180 // Table lookup instructions
4182 def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4184 // Specialized register support
4186 def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4187 def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4188 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4190 def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4191 "smsw{w}\t$dst", []>, OpSize, TB;
4192 def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4193 "smsw{l}\t$dst", []>, TB;
4194 // For memory operands, there is only a 16-bit form
4195 def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4196 "smsw{w}\t$dst", []>, TB;
4198 def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4199 "lmsw{w}\t$src", []>, TB;
4200 def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4201 "lmsw{w}\t$src", []>, TB;
4203 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4205 // Cache instructions
4207 def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4208 def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4213 def INVEPT : I<0x80, RawFrm, (outs), (ins), "invept", []>, OpSize, T8;
4215 def INVVPID : I<0x81, RawFrm, (outs), (ins), "invvpid", []>, OpSize, T8;
4217 def VMCALL : I<0x01, MRM_C1, (outs), (ins), "vmcall", []>, TB;
4218 def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4219 "vmclear\t$vmcs", []>, OpSize, TB;
4221 def VMLAUNCH : I<0x01, MRM_C2, (outs), (ins), "vmlaunch", []>, TB;
4223 def VMRESUME : I<0x01, MRM_C3, (outs), (ins), "vmresume", []>, TB;
4224 def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4225 "vmptrld\t$vmcs", []>, TB;
4226 def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4227 "vmptrst\t$vmcs", []>, TB;
4228 def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4229 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4230 def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4231 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4232 def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4233 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4234 def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4235 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4236 def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4237 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4238 def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4239 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4240 def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4241 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4242 def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4243 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4245 def VMXOFF : I<0x01, MRM_C4, (outs), (ins), "vmxoff", []>, TB;
4246 def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4247 "vmxon\t{$vmxon}", []>, XD;
4249 //===----------------------------------------------------------------------===//
4250 // Non-Instruction Patterns
4251 //===----------------------------------------------------------------------===//
4253 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
4254 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4255 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
4256 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
4257 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4258 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
4259 def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
4261 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4262 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4263 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4264 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4265 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4266 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4267 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4268 (ADD32ri GR32:$src1, texternalsym:$src2)>;
4269 def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4270 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
4272 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4273 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4274 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4275 (MOV32mi addr:$dst, texternalsym:$src)>;
4276 def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4277 (MOV32mi addr:$dst, tblockaddress:$src)>;
4281 def : Pat<(X86tcret GR32:$dst, imm:$off),
4282 (TCRETURNri GR32:$dst, imm:$off)>;
4284 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4285 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4287 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4288 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4290 // Normal calls, with various flavors of addresses.
4291 def : Pat<(X86call (i32 tglobaladdr:$dst)),
4292 (CALLpcrel32 tglobaladdr:$dst)>;
4293 def : Pat<(X86call (i32 texternalsym:$dst)),
4294 (CALLpcrel32 texternalsym:$dst)>;
4295 def : Pat<(X86call (i32 imm:$dst)),
4296 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
4298 // X86 specific add which produces a flag.
4299 def : Pat<(addc GR32:$src1, GR32:$src2),
4300 (ADD32rr GR32:$src1, GR32:$src2)>;
4301 def : Pat<(addc GR32:$src1, (load addr:$src2)),
4302 (ADD32rm GR32:$src1, addr:$src2)>;
4303 def : Pat<(addc GR32:$src1, imm:$src2),
4304 (ADD32ri GR32:$src1, imm:$src2)>;
4305 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4306 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4308 def : Pat<(subc GR32:$src1, GR32:$src2),
4309 (SUB32rr GR32:$src1, GR32:$src2)>;
4310 def : Pat<(subc GR32:$src1, (load addr:$src2)),
4311 (SUB32rm GR32:$src1, addr:$src2)>;
4312 def : Pat<(subc GR32:$src1, imm:$src2),
4313 (SUB32ri GR32:$src1, imm:$src2)>;
4314 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4315 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4319 // TEST R,R is smaller than CMP R,0
4320 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
4321 (TEST8rr GR8:$src1, GR8:$src1)>;
4322 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
4323 (TEST16rr GR16:$src1, GR16:$src1)>;
4324 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
4325 (TEST32rr GR32:$src1, GR32:$src1)>;
4327 // Conditional moves with folded loads with operands swapped and conditions
4329 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4330 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4331 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4332 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4333 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4334 (CMOVB16rm GR16:$src2, addr:$src1)>;
4335 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4336 (CMOVB32rm GR32:$src2, addr:$src1)>;
4337 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4338 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4339 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4340 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4341 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4342 (CMOVE16rm GR16:$src2, addr:$src1)>;
4343 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4344 (CMOVE32rm GR32:$src2, addr:$src1)>;
4345 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4346 (CMOVA16rm GR16:$src2, addr:$src1)>;
4347 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4348 (CMOVA32rm GR32:$src2, addr:$src1)>;
4349 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4350 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4351 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4352 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4353 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4354 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4355 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4356 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4357 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4358 (CMOVL16rm GR16:$src2, addr:$src1)>;
4359 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4360 (CMOVL32rm GR32:$src2, addr:$src1)>;
4361 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4362 (CMOVG16rm GR16:$src2, addr:$src1)>;
4363 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4364 (CMOVG32rm GR32:$src2, addr:$src1)>;
4365 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4366 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4367 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4368 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4369 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4370 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4371 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4372 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4373 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4374 (CMOVP16rm GR16:$src2, addr:$src1)>;
4375 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4376 (CMOVP32rm GR32:$src2, addr:$src1)>;
4377 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4378 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4379 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4380 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4381 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4382 (CMOVS16rm GR16:$src2, addr:$src1)>;
4383 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4384 (CMOVS32rm GR32:$src2, addr:$src1)>;
4385 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4386 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4387 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4388 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4389 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4390 (CMOVO16rm GR16:$src2, addr:$src1)>;
4391 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4392 (CMOVO32rm GR32:$src2, addr:$src1)>;
4394 // zextload bool -> zextload byte
4395 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4396 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4397 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4399 // extload bool -> extload byte
4400 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4401 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4402 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4403 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
4404 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4405 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4407 // anyext. Define these to do an explicit zero-extend to
4408 // avoid partial-register updates.
4409 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4410 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4411 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
4413 //===----------------------------------------------------------------------===//
4415 //===----------------------------------------------------------------------===//
4417 // Odd encoding trick: -128 fits into an 8-bit immediate field while
4418 // +128 doesn't, so in this special case use a sub instead of an add.
4419 def : Pat<(add GR16:$src1, 128),
4420 (SUB16ri8 GR16:$src1, -128)>;
4421 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4422 (SUB16mi8 addr:$dst, -128)>;
4423 def : Pat<(add GR32:$src1, 128),
4424 (SUB32ri8 GR32:$src1, -128)>;
4425 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4426 (SUB32mi8 addr:$dst, -128)>;
4428 // r & (2^16-1) ==> movz
4429 def : Pat<(and GR32:$src1, 0xffff),
4430 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
4431 // r & (2^8-1) ==> movz
4432 def : Pat<(and GR32:$src1, 0xff),
4433 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4436 Requires<[In32BitMode]>;
4437 // r & (2^8-1) ==> movz
4438 def : Pat<(and GR16:$src1, 0xff),
4439 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4442 Requires<[In32BitMode]>;
4444 // sext_inreg patterns
4445 def : Pat<(sext_inreg GR32:$src, i16),
4446 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4447 def : Pat<(sext_inreg GR32:$src, i8),
4448 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4451 Requires<[In32BitMode]>;
4452 def : Pat<(sext_inreg GR16:$src, i8),
4453 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4456 Requires<[In32BitMode]>;
4459 def : Pat<(i16 (trunc GR32:$src)),
4460 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
4461 def : Pat<(i8 (trunc GR32:$src)),
4462 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4464 Requires<[In32BitMode]>;
4465 def : Pat<(i8 (trunc GR16:$src)),
4466 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4468 Requires<[In32BitMode]>;
4470 // h-register tricks
4471 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
4472 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4473 x86_subreg_8bit_hi)>,
4474 Requires<[In32BitMode]>;
4475 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
4476 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4477 x86_subreg_8bit_hi)>,
4478 Requires<[In32BitMode]>;
4479 def : Pat<(srl GR16:$src, (i8 8)),
4482 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4483 x86_subreg_8bit_hi)),
4485 Requires<[In32BitMode]>;
4486 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
4487 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4489 x86_subreg_8bit_hi))>,
4490 Requires<[In32BitMode]>;
4491 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
4492 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4494 x86_subreg_8bit_hi))>,
4495 Requires<[In32BitMode]>;
4496 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
4497 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4499 x86_subreg_8bit_hi))>,
4500 Requires<[In32BitMode]>;
4502 // (shl x, 1) ==> (add x, x)
4503 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4504 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4505 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4507 // (shl x (and y, 31)) ==> (shl x, y)
4508 def : Pat<(shl GR8:$src1, (and CL, 31)),
4509 (SHL8rCL GR8:$src1)>;
4510 def : Pat<(shl GR16:$src1, (and CL, 31)),
4511 (SHL16rCL GR16:$src1)>;
4512 def : Pat<(shl GR32:$src1, (and CL, 31)),
4513 (SHL32rCL GR32:$src1)>;
4514 def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4515 (SHL8mCL addr:$dst)>;
4516 def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4517 (SHL16mCL addr:$dst)>;
4518 def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4519 (SHL32mCL addr:$dst)>;
4521 def : Pat<(srl GR8:$src1, (and CL, 31)),
4522 (SHR8rCL GR8:$src1)>;
4523 def : Pat<(srl GR16:$src1, (and CL, 31)),
4524 (SHR16rCL GR16:$src1)>;
4525 def : Pat<(srl GR32:$src1, (and CL, 31)),
4526 (SHR32rCL GR32:$src1)>;
4527 def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4528 (SHR8mCL addr:$dst)>;
4529 def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4530 (SHR16mCL addr:$dst)>;
4531 def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4532 (SHR32mCL addr:$dst)>;
4534 def : Pat<(sra GR8:$src1, (and CL, 31)),
4535 (SAR8rCL GR8:$src1)>;
4536 def : Pat<(sra GR16:$src1, (and CL, 31)),
4537 (SAR16rCL GR16:$src1)>;
4538 def : Pat<(sra GR32:$src1, (and CL, 31)),
4539 (SAR32rCL GR32:$src1)>;
4540 def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst),
4541 (SAR8mCL addr:$dst)>;
4542 def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst),
4543 (SAR16mCL addr:$dst)>;
4544 def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst),
4545 (SAR32mCL addr:$dst)>;
4547 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4548 def : Pat<(or (srl GR32:$src1, CL:$amt),
4549 (shl GR32:$src2, (sub 32, CL:$amt))),
4550 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4552 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4553 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4554 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4556 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4557 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4558 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4560 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4561 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4563 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4565 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm/*:$amt2*/)),
4566 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4568 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4569 GR32:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
4570 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4572 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4573 def : Pat<(or (shl GR32:$src1, CL:$amt),
4574 (srl GR32:$src2, (sub 32, CL:$amt))),
4575 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4577 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4578 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4579 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4581 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4582 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4583 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4585 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4586 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4588 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4590 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm/*:$amt2*/)),
4591 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4593 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4594 GR32:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
4595 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4597 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4598 def : Pat<(or (srl GR16:$src1, CL:$amt),
4599 (shl GR16:$src2, (sub 16, CL:$amt))),
4600 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4602 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4603 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4604 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4606 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4607 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4608 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4610 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4611 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4613 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4615 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm/*:$amt2*/)),
4616 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4618 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4619 GR16:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
4620 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4622 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4623 def : Pat<(or (shl GR16:$src1, CL:$amt),
4624 (srl GR16:$src2, (sub 16, CL:$amt))),
4625 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4627 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4628 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4629 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4631 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4632 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4633 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4635 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4636 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4638 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4640 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm/*:$amt2*/)),
4641 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4643 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4644 GR16:$src2, (i8 imm/*:$amt2*/)), addr:$dst),
4645 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4647 // (anyext (setcc_carry)) -> (setcc_carry)
4648 def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4650 def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4653 // (or x1, x2) -> (add x1, x2) if two operands are known not to share bits.
4654 let AddedComplexity = 5 in { // Try this before the selecting to OR
4655 def : Pat<(parallel (or_is_add GR16:$src1, imm:$src2),
4657 (ADD16ri GR16:$src1, imm:$src2)>;
4658 def : Pat<(parallel (or_is_add GR32:$src1, imm:$src2),
4660 (ADD32ri GR32:$src1, imm:$src2)>;
4661 def : Pat<(parallel (or_is_add GR16:$src1, i16immSExt8:$src2),
4663 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4664 def : Pat<(parallel (or_is_add GR32:$src1, i32immSExt8:$src2),
4666 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4667 def : Pat<(parallel (or_is_add GR16:$src1, GR16:$src2),
4669 (ADD16rr GR16:$src1, GR16:$src2)>;
4670 def : Pat<(parallel (or_is_add GR32:$src1, GR32:$src2),
4672 (ADD32rr GR32:$src1, GR32:$src2)>;
4673 } // AddedComplexity
4675 //===----------------------------------------------------------------------===//
4676 // EFLAGS-defining Patterns
4677 //===----------------------------------------------------------------------===//
4679 // Register-Register Addition with EFLAGS result
4680 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
4682 (ADD8rr GR8:$src1, GR8:$src2)>;
4683 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
4685 (ADD16rr GR16:$src1, GR16:$src2)>;
4686 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
4688 (ADD32rr GR32:$src1, GR32:$src2)>;
4690 // Register-Memory Addition with EFLAGS result
4691 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
4693 (ADD8rm GR8:$src1, addr:$src2)>;
4694 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
4696 (ADD16rm GR16:$src1, addr:$src2)>;
4697 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
4699 (ADD32rm GR32:$src1, addr:$src2)>;
4701 // Register-Integer Addition with EFLAGS result
4702 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
4704 (ADD8ri GR8:$src1, imm:$src2)>;
4705 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
4707 (ADD16ri GR16:$src1, imm:$src2)>;
4708 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
4710 (ADD32ri GR32:$src1, imm:$src2)>;
4711 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
4713 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4714 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
4716 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4718 // Memory-Register Addition with EFLAGS result
4719 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
4722 (ADD8mr addr:$dst, GR8:$src2)>;
4723 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
4726 (ADD16mr addr:$dst, GR16:$src2)>;
4727 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
4730 (ADD32mr addr:$dst, GR32:$src2)>;
4732 // Memory-Integer Addition with EFLAGS result
4733 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
4736 (ADD8mi addr:$dst, imm:$src2)>;
4737 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
4740 (ADD16mi addr:$dst, imm:$src2)>;
4741 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
4744 (ADD32mi addr:$dst, imm:$src2)>;
4745 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4748 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
4749 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4752 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4754 // Register-Register Subtraction with EFLAGS result
4755 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
4757 (SUB8rr GR8:$src1, GR8:$src2)>;
4758 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
4760 (SUB16rr GR16:$src1, GR16:$src2)>;
4761 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
4763 (SUB32rr GR32:$src1, GR32:$src2)>;
4765 // Register-Memory Subtraction with EFLAGS result
4766 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
4768 (SUB8rm GR8:$src1, addr:$src2)>;
4769 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
4771 (SUB16rm GR16:$src1, addr:$src2)>;
4772 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
4774 (SUB32rm GR32:$src1, addr:$src2)>;
4776 // Register-Integer Subtraction with EFLAGS result
4777 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
4779 (SUB8ri GR8:$src1, imm:$src2)>;
4780 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
4782 (SUB16ri GR16:$src1, imm:$src2)>;
4783 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
4785 (SUB32ri GR32:$src1, imm:$src2)>;
4786 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
4788 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4789 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
4791 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4793 // Memory-Register Subtraction with EFLAGS result
4794 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
4797 (SUB8mr addr:$dst, GR8:$src2)>;
4798 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
4801 (SUB16mr addr:$dst, GR16:$src2)>;
4802 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
4805 (SUB32mr addr:$dst, GR32:$src2)>;
4807 // Memory-Integer Subtraction with EFLAGS result
4808 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
4811 (SUB8mi addr:$dst, imm:$src2)>;
4812 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
4815 (SUB16mi addr:$dst, imm:$src2)>;
4816 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
4819 (SUB32mi addr:$dst, imm:$src2)>;
4820 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4823 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
4824 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4827 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4830 // Register-Register Signed Integer Multiply with EFLAGS result
4831 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
4833 (IMUL16rr GR16:$src1, GR16:$src2)>;
4834 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
4836 (IMUL32rr GR32:$src1, GR32:$src2)>;
4838 // Register-Memory Signed Integer Multiply with EFLAGS result
4839 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
4841 (IMUL16rm GR16:$src1, addr:$src2)>;
4842 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
4844 (IMUL32rm GR32:$src1, addr:$src2)>;
4846 // Register-Integer Signed Integer Multiply with EFLAGS result
4847 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
4849 (IMUL16rri GR16:$src1, imm:$src2)>;
4850 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
4852 (IMUL32rri GR32:$src1, imm:$src2)>;
4853 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
4855 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4856 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
4858 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4860 // Memory-Integer Signed Integer Multiply with EFLAGS result
4861 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
4863 (IMUL16rmi addr:$src1, imm:$src2)>;
4864 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
4866 (IMUL32rmi addr:$src1, imm:$src2)>;
4867 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
4869 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4870 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
4872 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4874 // Optimize multiply by 2 with EFLAGS result.
4875 let AddedComplexity = 2 in {
4876 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
4878 (ADD16rr GR16:$src1, GR16:$src1)>;
4880 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
4882 (ADD32rr GR32:$src1, GR32:$src1)>;
4885 // INC and DEC with EFLAGS result. Note that these do not set CF.
4886 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4888 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4891 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4893 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4897 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
4898 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4899 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4901 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
4902 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
4903 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4904 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4906 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
4908 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
4909 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4910 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4912 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
4913 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
4914 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4915 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4917 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
4919 // Register-Register Or with EFLAGS result
4920 def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4922 (OR8rr GR8:$src1, GR8:$src2)>;
4923 def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4925 (OR16rr GR16:$src1, GR16:$src2)>;
4926 def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4928 (OR32rr GR32:$src1, GR32:$src2)>;
4930 // Register-Memory Or with EFLAGS result
4931 def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4933 (OR8rm GR8:$src1, addr:$src2)>;
4934 def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4936 (OR16rm GR16:$src1, addr:$src2)>;
4937 def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4939 (OR32rm GR32:$src1, addr:$src2)>;
4941 // Register-Integer Or with EFLAGS result
4942 def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4944 (OR8ri GR8:$src1, imm:$src2)>;
4945 def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4947 (OR16ri GR16:$src1, imm:$src2)>;
4948 def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4950 (OR32ri GR32:$src1, imm:$src2)>;
4951 def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4953 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4954 def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4956 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4958 // Memory-Register Or with EFLAGS result
4959 def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4962 (OR8mr addr:$dst, GR8:$src2)>;
4963 def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4966 (OR16mr addr:$dst, GR16:$src2)>;
4967 def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4970 (OR32mr addr:$dst, GR32:$src2)>;
4972 // Memory-Integer Or with EFLAGS result
4973 def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4976 (OR8mi addr:$dst, imm:$src2)>;
4977 def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4980 (OR16mi addr:$dst, imm:$src2)>;
4981 def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
4984 (OR32mi addr:$dst, imm:$src2)>;
4985 def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4988 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
4989 def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4992 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
4994 // Register-Register XOr with EFLAGS result
4995 def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
4997 (XOR8rr GR8:$src1, GR8:$src2)>;
4998 def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
5000 (XOR16rr GR16:$src1, GR16:$src2)>;
5001 def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
5003 (XOR32rr GR32:$src1, GR32:$src2)>;
5005 // Register-Memory XOr with EFLAGS result
5006 def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
5008 (XOR8rm GR8:$src1, addr:$src2)>;
5009 def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
5011 (XOR16rm GR16:$src1, addr:$src2)>;
5012 def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
5014 (XOR32rm GR32:$src1, addr:$src2)>;
5016 // Register-Integer XOr with EFLAGS result
5017 def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
5019 (XOR8ri GR8:$src1, imm:$src2)>;
5020 def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
5022 (XOR16ri GR16:$src1, imm:$src2)>;
5023 def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
5025 (XOR32ri GR32:$src1, imm:$src2)>;
5026 def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
5028 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
5029 def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
5031 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
5033 // Memory-Register XOr with EFLAGS result
5034 def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
5037 (XOR8mr addr:$dst, GR8:$src2)>;
5038 def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5041 (XOR16mr addr:$dst, GR16:$src2)>;
5042 def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5045 (XOR32mr addr:$dst, GR32:$src2)>;
5047 // Memory-Integer XOr with EFLAGS result
5048 def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5051 (XOR8mi addr:$dst, imm:$src2)>;
5052 def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5055 (XOR16mi addr:$dst, imm:$src2)>;
5056 def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5059 (XOR32mi addr:$dst, imm:$src2)>;
5060 def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5063 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5064 def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5067 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5069 // Register-Register And with EFLAGS result
5070 def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5072 (AND8rr GR8:$src1, GR8:$src2)>;
5073 def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5075 (AND16rr GR16:$src1, GR16:$src2)>;
5076 def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5078 (AND32rr GR32:$src1, GR32:$src2)>;
5080 // Register-Memory And with EFLAGS result
5081 def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5083 (AND8rm GR8:$src1, addr:$src2)>;
5084 def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5086 (AND16rm GR16:$src1, addr:$src2)>;
5087 def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5089 (AND32rm GR32:$src1, addr:$src2)>;
5091 // Register-Integer And with EFLAGS result
5092 def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5094 (AND8ri GR8:$src1, imm:$src2)>;
5095 def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5097 (AND16ri GR16:$src1, imm:$src2)>;
5098 def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5100 (AND32ri GR32:$src1, imm:$src2)>;
5101 def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5103 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5104 def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5106 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5108 // Memory-Register And with EFLAGS result
5109 def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5112 (AND8mr addr:$dst, GR8:$src2)>;
5113 def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5116 (AND16mr addr:$dst, GR16:$src2)>;
5117 def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5120 (AND32mr addr:$dst, GR32:$src2)>;
5122 // Memory-Integer And with EFLAGS result
5123 def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5126 (AND8mi addr:$dst, imm:$src2)>;
5127 def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5130 (AND16mi addr:$dst, imm:$src2)>;
5131 def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5134 (AND32mi addr:$dst, imm:$src2)>;
5135 def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5138 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5139 def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5142 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5144 // -disable-16bit support.
5145 def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
5146 (MOV16mi addr:$dst, imm:$src)>;
5147 def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5148 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5149 def : Pat<(i32 (sextloadi16 addr:$dst)),
5150 (MOVSX32rm16 addr:$dst)>;
5151 def : Pat<(i32 (zextloadi16 addr:$dst)),
5152 (MOVZX32rm16 addr:$dst)>;
5153 def : Pat<(i32 (extloadi16 addr:$dst)),
5154 (MOVZX32rm16 addr:$dst)>;
5156 //===----------------------------------------------------------------------===//
5157 // Floating Point Stack Support
5158 //===----------------------------------------------------------------------===//
5160 include "X86InstrFPStack.td"
5162 //===----------------------------------------------------------------------===//
5164 //===----------------------------------------------------------------------===//
5166 include "X86Instr64bit.td"
5168 //===----------------------------------------------------------------------===//
5169 // SIMD support (SSE, MMX and AVX)
5170 //===----------------------------------------------------------------------===//
5172 include "X86InstrFragmentsSIMD.td"
5174 //===----------------------------------------------------------------------===//
5175 // XMM Floating point support (requires SSE / SSE2)
5176 //===----------------------------------------------------------------------===//
5178 include "X86InstrSSE.td"
5180 //===----------------------------------------------------------------------===//
5181 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5182 //===----------------------------------------------------------------------===//
5184 include "X86InstrMMX.td"