1 //===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86 instruction set, defining the instructions, and
11 // properties of the instructions which are needed for code generation, machine
12 // code emission, and analysis.
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
17 // X86 specific DAG Nodes.
20 def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
24 def SDTX86CmpTest : SDTypeProfile<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>]>;
45 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
47 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
49 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
51 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
53 def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
54 def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
57 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
59 def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
63 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
65 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
67 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
69 def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
71 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
73 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
75 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
77 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
78 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
79 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
80 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
82 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
84 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
86 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
87 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
89 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
91 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
94 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
95 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
97 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
112 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
115 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
116 [SDNPHasChain, SDNPMayStore,
117 SDNPMayLoad, SDNPMemOperand]>;
118 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
119 [SDNPHasChain, SDNPOptInFlag]>;
121 def X86vastart_save_xmm_regs :
122 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
123 SDT_X86VASTART_SAVE_XMM_REGS,
126 def X86callseq_start :
127 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
128 [SDNPHasChain, SDNPOutFlag]>;
130 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
131 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
133 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
134 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
136 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
137 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
138 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
139 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
142 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
143 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
145 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
146 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
148 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
149 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
150 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
151 SDT_X86SegmentBaseAddress, []>;
153 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
156 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
157 [SDNPHasChain, SDNPOptInFlag]>;
159 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
160 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
161 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
162 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
163 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
164 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
166 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
168 //===----------------------------------------------------------------------===//
169 // X86 Operand Definitions.
172 def i32imm_pcrel : Operand<i32> {
173 let PrintMethod = "print_pcrel_imm";
176 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
177 // the index operand of an address, to conform to x86 encoding restrictions.
178 def ptr_rc_nosp : PointerLikeRegClass<1>;
180 // *mem - Operand definitions for the funky X86 addressing mode operands.
182 def X86MemAsmOperand : AsmOperandClass {
186 class X86MemOperand<string printMethod> : Operand<iPTR> {
187 let PrintMethod = printMethod;
188 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
189 let ParserMatchClass = X86MemAsmOperand;
192 def i8mem : X86MemOperand<"printi8mem">;
193 def i16mem : X86MemOperand<"printi16mem">;
194 def i32mem : X86MemOperand<"printi32mem">;
195 def i64mem : X86MemOperand<"printi64mem">;
196 def i128mem : X86MemOperand<"printi128mem">;
197 def i256mem : X86MemOperand<"printi256mem">;
198 def f32mem : X86MemOperand<"printf32mem">;
199 def f64mem : X86MemOperand<"printf64mem">;
200 def f80mem : X86MemOperand<"printf80mem">;
201 def f128mem : X86MemOperand<"printf128mem">;
202 def f256mem : X86MemOperand<"printf256mem">;
204 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
205 // plain GR64, so that it doesn't potentially require a REX prefix.
206 def i8mem_NOREX : Operand<i64> {
207 let PrintMethod = "printi8mem";
208 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
209 let ParserMatchClass = X86MemAsmOperand;
212 def lea32mem : Operand<i32> {
213 let PrintMethod = "printlea32mem";
214 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
215 let ParserMatchClass = X86MemAsmOperand;
218 def SSECC : Operand<i8> {
219 let PrintMethod = "printSSECC";
222 def piclabel: Operand<i32> {
223 let PrintMethod = "printPICLabel";
226 def ImmSExt8AsmOperand : AsmOperandClass {
227 let Name = "ImmSExt8";
228 let SuperClass = ImmAsmOperand;
231 // A couple of more descriptive operand definitions.
232 // 16-bits but only 8 bits are significant.
233 def i16i8imm : Operand<i16> {
234 let ParserMatchClass = ImmSExt8AsmOperand;
236 // 32-bits but only 8 bits are significant.
237 def i32i8imm : Operand<i32> {
238 let ParserMatchClass = ImmSExt8AsmOperand;
241 // Branch targets have OtherVT type and print as pc-relative values.
242 def brtarget : Operand<OtherVT> {
243 let PrintMethod = "print_pcrel_imm";
246 def brtarget8 : Operand<OtherVT> {
247 let PrintMethod = "print_pcrel_imm";
250 //===----------------------------------------------------------------------===//
251 // X86 Complex Pattern Definitions.
254 // Define X86 specific addressing mode.
255 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
256 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
257 [add, sub, mul, X86mul_imm, shl, or, frameindex],
259 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
260 [tglobaltlsaddr], []>;
262 //===----------------------------------------------------------------------===//
263 // X86 Instruction Predicate Definitions.
264 def HasMMX : Predicate<"Subtarget->hasMMX()">;
265 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
266 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
267 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
268 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
269 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
270 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
271 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
272 def HasAVX : Predicate<"Subtarget->hasAVX()">;
273 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
274 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
275 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
276 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
277 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
278 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
279 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
280 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
281 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
282 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
283 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
284 "TM.getCodeModel() != CodeModel::Kernel">;
285 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
286 "TM.getCodeModel() == CodeModel::Kernel">;
287 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
288 def OptForSpeed : Predicate<"!OptForSize">;
289 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
290 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
292 //===----------------------------------------------------------------------===//
293 // X86 Instruction Format Definitions.
296 include "X86InstrFormats.td"
298 //===----------------------------------------------------------------------===//
299 // Pattern fragments...
302 // X86 specific condition code. These correspond to CondCode in
303 // X86InstrInfo.h. They must be kept in synch.
304 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
305 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
306 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
307 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
308 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
309 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
310 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
311 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
312 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
313 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
314 def X86_COND_NO : PatLeaf<(i8 10)>;
315 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
316 def X86_COND_NS : PatLeaf<(i8 12)>;
317 def X86_COND_O : PatLeaf<(i8 13)>;
318 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
319 def X86_COND_S : PatLeaf<(i8 15)>;
321 def i16immSExt8 : PatLeaf<(i16 imm), [{
322 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
323 // sign extended field.
324 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
327 def i32immSExt8 : PatLeaf<(i32 imm), [{
328 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
329 // sign extended field.
330 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
333 // Helper fragments for loads.
334 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
335 // known to be 32-bit aligned or better. Ditto for i8 to i16.
336 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
337 LoadSDNode *LD = cast<LoadSDNode>(N);
338 if (const Value *Src = LD->getSrcValue())
339 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
340 if (PT->getAddressSpace() > 255)
342 ISD::LoadExtType ExtType = LD->getExtensionType();
343 if (ExtType == ISD::NON_EXTLOAD)
345 if (ExtType == ISD::EXTLOAD)
346 return LD->getAlignment() >= 2 && !LD->isVolatile();
350 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
351 LoadSDNode *LD = cast<LoadSDNode>(N);
352 if (const Value *Src = LD->getSrcValue())
353 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
354 if (PT->getAddressSpace() > 255)
356 ISD::LoadExtType ExtType = LD->getExtensionType();
357 if (ExtType == ISD::EXTLOAD)
358 return LD->getAlignment() >= 2 && !LD->isVolatile();
362 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
363 LoadSDNode *LD = cast<LoadSDNode>(N);
364 if (const Value *Src = LD->getSrcValue())
365 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
366 if (PT->getAddressSpace() > 255)
368 ISD::LoadExtType ExtType = LD->getExtensionType();
369 if (ExtType == ISD::NON_EXTLOAD)
371 if (ExtType == ISD::EXTLOAD)
372 return LD->getAlignment() >= 4 && !LD->isVolatile();
376 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
377 LoadSDNode *LD = cast<LoadSDNode>(N);
378 if (const Value *Src = LD->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
380 if (PT->getAddressSpace() > 255)
382 if (LD->isVolatile())
384 ISD::LoadExtType ExtType = LD->getExtensionType();
385 if (ExtType == ISD::NON_EXTLOAD)
387 if (ExtType == ISD::EXTLOAD)
388 return LD->getAlignment() >= 4;
392 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
393 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
394 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
395 return PT->getAddressSpace() == 256;
399 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
400 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
401 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
402 return PT->getAddressSpace() == 257;
406 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
407 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
408 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
409 if (PT->getAddressSpace() > 255)
413 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
414 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
415 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
416 if (PT->getAddressSpace() > 255)
421 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
422 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
423 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
424 if (PT->getAddressSpace() > 255)
428 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
429 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
430 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
431 if (PT->getAddressSpace() > 255)
435 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
436 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
437 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
438 if (PT->getAddressSpace() > 255)
443 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
444 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
445 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
447 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
448 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
449 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
450 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
451 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
452 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
454 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
455 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
456 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
457 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
458 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
459 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
462 // An 'and' node with a single use.
463 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
464 return N->hasOneUse();
466 // An 'srl' node with a single use.
467 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
468 return N->hasOneUse();
470 // An 'trunc' node with a single use.
471 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
472 return N->hasOneUse();
475 // 'shld' and 'shrd' instruction patterns. Note that even though these have
476 // the srl and shl in their patterns, the C++ code must still check for them,
477 // because predicates are tested before children nodes are explored.
479 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
480 (or (srl node:$src1, node:$amt1),
481 (shl node:$src2, node:$amt2)), [{
482 assert(N->getOpcode() == ISD::OR);
483 return N->getOperand(0).getOpcode() == ISD::SRL &&
484 N->getOperand(1).getOpcode() == ISD::SHL &&
485 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
486 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
487 N->getOperand(0).getConstantOperandVal(1) ==
488 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
491 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
492 (or (shl node:$src1, node:$amt1),
493 (srl node:$src2, node:$amt2)), [{
494 assert(N->getOpcode() == ISD::OR);
495 return N->getOperand(0).getOpcode() == ISD::SHL &&
496 N->getOperand(1).getOpcode() == ISD::SRL &&
497 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
498 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
499 N->getOperand(0).getConstantOperandVal(1) ==
500 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
503 //===----------------------------------------------------------------------===//
504 // Instruction list...
507 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
508 // a stack adjustment and the codegen must know that they may modify the stack
509 // pointer before prolog-epilog rewriting occurs.
510 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
511 // sub / add which can clobber EFLAGS.
512 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
513 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
515 [(X86callseq_start timm:$amt)]>,
516 Requires<[In32BitMode]>;
517 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
519 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
520 Requires<[In32BitMode]>;
523 // x86-64 va_start lowering magic.
524 let usesCustomDAGSchedInserter = 1 in
525 def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
528 i64imm:$regsavefi, i64imm:$offset,
530 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
531 [(X86vastart_save_xmm_regs GR8:$al,
536 let neverHasSideEffects = 1 in {
537 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
538 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
539 "nopl\t$zero", []>, TB;
543 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int 3", []>;
544 def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
547 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
548 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
552 //===----------------------------------------------------------------------===//
553 // Control Flow Instructions...
556 // Return instructions.
557 let isTerminator = 1, isReturn = 1, isBarrier = 1,
558 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
559 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
562 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
564 [(X86retflag imm:$amt)]>;
567 // All branches are RawFrm, Void, Branch, and Terminators
568 let isBranch = 1, isTerminator = 1 in
569 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
570 I<opcode, RawFrm, (outs), ins, asm, pattern>;
572 let isBranch = 1, isBarrier = 1 in {
573 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
574 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
578 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
579 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
580 [(brind GR32:$dst)]>;
581 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
582 [(brind (loadi32 addr:$dst))]>;
585 // Conditional branches
586 let Uses = [EFLAGS] in {
587 // Short conditional jumps
588 def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
589 def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
590 def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
591 def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
592 def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
593 def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
594 def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
595 def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
596 def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
597 def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
598 def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
599 def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
600 def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
601 def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
602 def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
603 def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
605 def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
607 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
608 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
609 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
610 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
611 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
612 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
613 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
614 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
615 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
616 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
617 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
618 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
620 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
621 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
622 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
623 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
624 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
625 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
626 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
627 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
629 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
630 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
631 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
632 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
633 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
634 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
635 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
636 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
637 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
638 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
639 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
640 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
643 //===----------------------------------------------------------------------===//
644 // Call Instructions...
647 // All calls clobber the non-callee saved registers. ESP is marked as
648 // a use to prevent stack-pointer assignments that appear immediately
649 // before calls from potentially appearing dead. Uses for argument
650 // registers are added manually.
651 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
652 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
653 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
654 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
656 def CALLpcrel32 : Ii32<0xE8, RawFrm,
657 (outs), (ins i32imm_pcrel:$dst,variable_ops),
659 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
660 "call\t{*}$dst", [(X86call GR32:$dst)]>;
661 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
662 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
667 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
668 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
669 "#TC_RETURN $dst $offset",
672 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
673 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
674 "#TC_RETURN $dst $offset",
677 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
679 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
681 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
682 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
684 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
685 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
686 "jmp\t{*}$dst # TAILCALL", []>;
688 //===----------------------------------------------------------------------===//
689 // Miscellaneous Instructions...
691 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
692 def LEAVE : I<0xC9, RawFrm,
693 (outs), (ins), "leave", []>;
695 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
697 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
700 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
703 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
704 def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
705 "push{l}\t$imm", []>;
706 def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
707 "push{l}\t$imm", []>;
708 def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
709 "push{l}\t$imm", []>;
712 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
713 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
714 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
715 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
717 let isTwoAddress = 1 in // GR32 = bswap GR32
718 def BSWAP32r : I<0xC8, AddRegFrm,
719 (outs GR32:$dst), (ins GR32:$src),
721 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
724 // Bit scan instructions.
725 let Defs = [EFLAGS] in {
726 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
727 "bsf{w}\t{$src, $dst|$dst, $src}",
728 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
729 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
730 "bsf{w}\t{$src, $dst|$dst, $src}",
731 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
732 (implicit EFLAGS)]>, TB;
733 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
734 "bsf{l}\t{$src, $dst|$dst, $src}",
735 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
736 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
737 "bsf{l}\t{$src, $dst|$dst, $src}",
738 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
739 (implicit EFLAGS)]>, TB;
741 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
742 "bsr{w}\t{$src, $dst|$dst, $src}",
743 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
744 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
745 "bsr{w}\t{$src, $dst|$dst, $src}",
746 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
747 (implicit EFLAGS)]>, TB;
748 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
749 "bsr{l}\t{$src, $dst|$dst, $src}",
750 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
751 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
752 "bsr{l}\t{$src, $dst|$dst, $src}",
753 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
754 (implicit EFLAGS)]>, TB;
757 let neverHasSideEffects = 1 in
758 def LEA16r : I<0x8D, MRMSrcMem,
759 (outs GR16:$dst), (ins i32mem:$src),
760 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
761 let isReMaterializable = 1 in
762 def LEA32r : I<0x8D, MRMSrcMem,
763 (outs GR32:$dst), (ins lea32mem:$src),
764 "lea{l}\t{$src|$dst}, {$dst|$src}",
765 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
767 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
768 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
769 [(X86rep_movs i8)]>, REP;
770 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
771 [(X86rep_movs i16)]>, REP, OpSize;
772 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
773 [(X86rep_movs i32)]>, REP;
776 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
777 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
778 [(X86rep_stos i8)]>, REP;
779 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
780 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
781 [(X86rep_stos i16)]>, REP, OpSize;
782 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
783 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
784 [(X86rep_stos i32)]>, REP;
786 let Defs = [RAX, RDX] in
787 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
790 let isBarrier = 1, hasCtrlDep = 1 in {
791 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
794 def SYSCALL : I<0x05, RawFrm,
795 (outs), (ins), "syscall", []>, TB;
796 def SYSRET : I<0x07, RawFrm,
797 (outs), (ins), "sysret", []>, TB;
798 def SYSENTER : I<0x34, RawFrm,
799 (outs), (ins), "sysenter", []>, TB;
800 def SYSEXIT : I<0x35, RawFrm,
801 (outs), (ins), "sysexit", []>, TB;
805 //===----------------------------------------------------------------------===//
806 // Input/Output Instructions...
808 let Defs = [AL], Uses = [DX] in
809 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
810 "in{b}\t{%dx, %al|%AL, %DX}", []>;
811 let Defs = [AX], Uses = [DX] in
812 def IN16rr : I<0xED, RawFrm, (outs), (ins),
813 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
814 let Defs = [EAX], Uses = [DX] in
815 def IN32rr : I<0xED, RawFrm, (outs), (ins),
816 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
819 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
820 "in{b}\t{$port, %al|%AL, $port}", []>;
822 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
823 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
825 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
826 "in{l}\t{$port, %eax|%EAX, $port}", []>;
828 let Uses = [DX, AL] in
829 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
830 "out{b}\t{%al, %dx|%DX, %AL}", []>;
831 let Uses = [DX, AX] in
832 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
833 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
834 let Uses = [DX, EAX] in
835 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
836 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
839 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
840 "out{b}\t{%al, $port|$port, %AL}", []>;
842 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
843 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
845 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
846 "out{l}\t{%eax, $port|$port, %EAX}", []>;
848 //===----------------------------------------------------------------------===//
849 // Move Instructions...
851 let neverHasSideEffects = 1 in {
852 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
853 "mov{b}\t{$src, $dst|$dst, $src}", []>;
854 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
855 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
856 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
857 "mov{l}\t{$src, $dst|$dst, $src}", []>;
859 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
860 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
861 "mov{b}\t{$src, $dst|$dst, $src}",
862 [(set GR8:$dst, imm:$src)]>;
863 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
864 "mov{w}\t{$src, $dst|$dst, $src}",
865 [(set GR16:$dst, imm:$src)]>, OpSize;
866 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
867 "mov{l}\t{$src, $dst|$dst, $src}",
868 [(set GR32:$dst, imm:$src)]>;
870 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
871 "mov{b}\t{$src, $dst|$dst, $src}",
872 [(store (i8 imm:$src), addr:$dst)]>;
873 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
874 "mov{w}\t{$src, $dst|$dst, $src}",
875 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
876 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
877 "mov{l}\t{$src, $dst|$dst, $src}",
878 [(store (i32 imm:$src), addr:$dst)]>;
880 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
881 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
882 "mov{b}\t{$src, $dst|$dst, $src}",
883 [(set GR8:$dst, (loadi8 addr:$src))]>;
884 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
885 "mov{w}\t{$src, $dst|$dst, $src}",
886 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
887 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
888 "mov{l}\t{$src, $dst|$dst, $src}",
889 [(set GR32:$dst, (loadi32 addr:$src))]>;
892 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
893 "mov{b}\t{$src, $dst|$dst, $src}",
894 [(store GR8:$src, addr:$dst)]>;
895 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
896 "mov{w}\t{$src, $dst|$dst, $src}",
897 [(store GR16:$src, addr:$dst)]>, OpSize;
898 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
899 "mov{l}\t{$src, $dst|$dst, $src}",
900 [(store GR32:$src, addr:$dst)]>;
902 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
903 // that they can be used for copying and storing h registers, which can't be
904 // encoded when a REX prefix is present.
905 let neverHasSideEffects = 1 in
906 def MOV8rr_NOREX : I<0x88, MRMDestReg,
907 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
908 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
910 def MOV8mr_NOREX : I<0x88, MRMDestMem,
911 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
912 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
914 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
915 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
916 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
917 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
919 //===----------------------------------------------------------------------===//
920 // Fixed-Register Multiplication and Division Instructions...
923 // Extra precision multiplication
924 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
925 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
926 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
927 // This probably ought to be moved to a def : Pat<> if the
928 // syntax can be accepted.
929 [(set AL, (mul AL, GR8:$src)),
930 (implicit EFLAGS)]>; // AL,AH = AL*GR8
932 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
933 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
935 []>, OpSize; // AX,DX = AX*GR16
937 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
938 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
940 []>; // EAX,EDX = EAX*GR32
942 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
943 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
945 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
946 // This probably ought to be moved to a def : Pat<> if the
947 // syntax can be accepted.
948 [(set AL, (mul AL, (loadi8 addr:$src))),
949 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
951 let mayLoad = 1, neverHasSideEffects = 1 in {
952 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
953 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
955 []>, OpSize; // AX,DX = AX*[mem16]
957 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
958 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
960 []>; // EAX,EDX = EAX*[mem32]
963 let neverHasSideEffects = 1 in {
964 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
965 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
967 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
968 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
969 OpSize; // AX,DX = AX*GR16
970 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
971 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
972 // EAX,EDX = EAX*GR32
974 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
975 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
976 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
977 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
978 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
979 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
980 let Defs = [EAX,EDX], Uses = [EAX] in
981 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
982 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
984 } // neverHasSideEffects
986 // unsigned division/remainder
987 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
988 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
990 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
991 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
992 "div{w}\t$src", []>, OpSize;
993 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
994 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
997 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
998 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1000 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1001 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1002 "div{w}\t$src", []>, OpSize;
1003 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1004 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
1005 "div{l}\t$src", []>;
1008 // Signed division/remainder.
1009 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1010 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1011 "idiv{b}\t$src", []>;
1012 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1013 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1014 "idiv{w}\t$src", []>, OpSize;
1015 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1016 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1017 "idiv{l}\t$src", []>;
1018 let mayLoad = 1, mayLoad = 1 in {
1019 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1020 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1021 "idiv{b}\t$src", []>;
1022 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1023 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1024 "idiv{w}\t$src", []>, OpSize;
1025 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1026 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
1027 "idiv{l}\t$src", []>;
1030 //===----------------------------------------------------------------------===//
1031 // Two address Instructions.
1033 let isTwoAddress = 1 in {
1035 // Conditional moves
1036 let Uses = [EFLAGS] in {
1038 // X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1039 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1040 // however that requires promoting the operands, and can induce additional
1041 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1042 // clobber EFLAGS, because if one of the operands is zero, the expansion
1043 // could involve an xor.
1044 let usesCustomDAGSchedInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
1045 def CMOV_GR8 : I<0, Pseudo,
1046 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1047 "#CMOV_GR8 PSEUDO!",
1048 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1049 imm:$cond, EFLAGS))]>;
1051 let isCommutable = 1 in {
1052 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1053 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1054 "cmovb\t{$src2, $dst|$dst, $src2}",
1055 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1056 X86_COND_B, EFLAGS))]>,
1058 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1059 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1060 "cmovb\t{$src2, $dst|$dst, $src2}",
1061 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1062 X86_COND_B, EFLAGS))]>,
1064 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1065 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1066 "cmovae\t{$src2, $dst|$dst, $src2}",
1067 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1068 X86_COND_AE, EFLAGS))]>,
1070 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1071 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1072 "cmovae\t{$src2, $dst|$dst, $src2}",
1073 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1074 X86_COND_AE, EFLAGS))]>,
1076 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1077 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1078 "cmove\t{$src2, $dst|$dst, $src2}",
1079 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1080 X86_COND_E, EFLAGS))]>,
1082 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1083 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1084 "cmove\t{$src2, $dst|$dst, $src2}",
1085 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1086 X86_COND_E, EFLAGS))]>,
1088 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1089 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1090 "cmovne\t{$src2, $dst|$dst, $src2}",
1091 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1092 X86_COND_NE, EFLAGS))]>,
1094 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1095 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1096 "cmovne\t{$src2, $dst|$dst, $src2}",
1097 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1098 X86_COND_NE, EFLAGS))]>,
1100 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1101 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1102 "cmovbe\t{$src2, $dst|$dst, $src2}",
1103 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1104 X86_COND_BE, EFLAGS))]>,
1106 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1107 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1108 "cmovbe\t{$src2, $dst|$dst, $src2}",
1109 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1110 X86_COND_BE, EFLAGS))]>,
1112 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1113 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1114 "cmova\t{$src2, $dst|$dst, $src2}",
1115 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1116 X86_COND_A, EFLAGS))]>,
1118 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1119 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1120 "cmova\t{$src2, $dst|$dst, $src2}",
1121 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1122 X86_COND_A, EFLAGS))]>,
1124 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1125 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1126 "cmovl\t{$src2, $dst|$dst, $src2}",
1127 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1128 X86_COND_L, EFLAGS))]>,
1130 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1131 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1132 "cmovl\t{$src2, $dst|$dst, $src2}",
1133 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1134 X86_COND_L, EFLAGS))]>,
1136 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1137 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1138 "cmovge\t{$src2, $dst|$dst, $src2}",
1139 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1140 X86_COND_GE, EFLAGS))]>,
1142 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1143 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1144 "cmovge\t{$src2, $dst|$dst, $src2}",
1145 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1146 X86_COND_GE, EFLAGS))]>,
1148 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1149 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1150 "cmovle\t{$src2, $dst|$dst, $src2}",
1151 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1152 X86_COND_LE, EFLAGS))]>,
1154 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1155 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1156 "cmovle\t{$src2, $dst|$dst, $src2}",
1157 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1158 X86_COND_LE, EFLAGS))]>,
1160 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1161 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1162 "cmovg\t{$src2, $dst|$dst, $src2}",
1163 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1164 X86_COND_G, EFLAGS))]>,
1166 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1167 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1168 "cmovg\t{$src2, $dst|$dst, $src2}",
1169 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1170 X86_COND_G, EFLAGS))]>,
1172 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1173 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1174 "cmovs\t{$src2, $dst|$dst, $src2}",
1175 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1176 X86_COND_S, EFLAGS))]>,
1178 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1179 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1180 "cmovs\t{$src2, $dst|$dst, $src2}",
1181 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1182 X86_COND_S, EFLAGS))]>,
1184 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1185 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1186 "cmovns\t{$src2, $dst|$dst, $src2}",
1187 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1188 X86_COND_NS, EFLAGS))]>,
1190 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1191 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1192 "cmovns\t{$src2, $dst|$dst, $src2}",
1193 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1194 X86_COND_NS, EFLAGS))]>,
1196 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1197 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1198 "cmovp\t{$src2, $dst|$dst, $src2}",
1199 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1200 X86_COND_P, EFLAGS))]>,
1202 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1203 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1204 "cmovp\t{$src2, $dst|$dst, $src2}",
1205 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1206 X86_COND_P, EFLAGS))]>,
1208 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1209 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1210 "cmovnp\t{$src2, $dst|$dst, $src2}",
1211 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1212 X86_COND_NP, EFLAGS))]>,
1214 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1215 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1216 "cmovnp\t{$src2, $dst|$dst, $src2}",
1217 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1218 X86_COND_NP, EFLAGS))]>,
1220 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1221 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1222 "cmovo\t{$src2, $dst|$dst, $src2}",
1223 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1224 X86_COND_O, EFLAGS))]>,
1226 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1227 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1228 "cmovo\t{$src2, $dst|$dst, $src2}",
1229 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1230 X86_COND_O, EFLAGS))]>,
1232 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1233 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1234 "cmovno\t{$src2, $dst|$dst, $src2}",
1235 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1236 X86_COND_NO, EFLAGS))]>,
1238 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1239 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1240 "cmovno\t{$src2, $dst|$dst, $src2}",
1241 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1242 X86_COND_NO, EFLAGS))]>,
1244 } // isCommutable = 1
1246 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1247 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1248 "cmovb\t{$src2, $dst|$dst, $src2}",
1249 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1250 X86_COND_B, EFLAGS))]>,
1252 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1253 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1254 "cmovb\t{$src2, $dst|$dst, $src2}",
1255 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1256 X86_COND_B, EFLAGS))]>,
1258 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1259 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1260 "cmovae\t{$src2, $dst|$dst, $src2}",
1261 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1262 X86_COND_AE, EFLAGS))]>,
1264 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1265 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1266 "cmovae\t{$src2, $dst|$dst, $src2}",
1267 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1268 X86_COND_AE, EFLAGS))]>,
1270 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1271 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1272 "cmove\t{$src2, $dst|$dst, $src2}",
1273 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1274 X86_COND_E, EFLAGS))]>,
1276 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1277 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1278 "cmove\t{$src2, $dst|$dst, $src2}",
1279 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1280 X86_COND_E, EFLAGS))]>,
1282 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1283 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1284 "cmovne\t{$src2, $dst|$dst, $src2}",
1285 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1286 X86_COND_NE, EFLAGS))]>,
1288 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1289 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1290 "cmovne\t{$src2, $dst|$dst, $src2}",
1291 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1292 X86_COND_NE, EFLAGS))]>,
1294 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1295 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1296 "cmovbe\t{$src2, $dst|$dst, $src2}",
1297 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1298 X86_COND_BE, EFLAGS))]>,
1300 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1301 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1302 "cmovbe\t{$src2, $dst|$dst, $src2}",
1303 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1304 X86_COND_BE, EFLAGS))]>,
1306 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1307 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1308 "cmova\t{$src2, $dst|$dst, $src2}",
1309 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1310 X86_COND_A, EFLAGS))]>,
1312 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1313 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1314 "cmova\t{$src2, $dst|$dst, $src2}",
1315 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1316 X86_COND_A, EFLAGS))]>,
1318 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1319 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1320 "cmovl\t{$src2, $dst|$dst, $src2}",
1321 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1322 X86_COND_L, EFLAGS))]>,
1324 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1325 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1326 "cmovl\t{$src2, $dst|$dst, $src2}",
1327 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1328 X86_COND_L, EFLAGS))]>,
1330 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1331 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1332 "cmovge\t{$src2, $dst|$dst, $src2}",
1333 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1334 X86_COND_GE, EFLAGS))]>,
1336 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1337 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1338 "cmovge\t{$src2, $dst|$dst, $src2}",
1339 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1340 X86_COND_GE, EFLAGS))]>,
1342 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1343 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1344 "cmovle\t{$src2, $dst|$dst, $src2}",
1345 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1346 X86_COND_LE, EFLAGS))]>,
1348 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1349 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1350 "cmovle\t{$src2, $dst|$dst, $src2}",
1351 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1352 X86_COND_LE, EFLAGS))]>,
1354 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1355 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1356 "cmovg\t{$src2, $dst|$dst, $src2}",
1357 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1358 X86_COND_G, EFLAGS))]>,
1360 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1361 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1362 "cmovg\t{$src2, $dst|$dst, $src2}",
1363 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1364 X86_COND_G, EFLAGS))]>,
1366 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1367 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1368 "cmovs\t{$src2, $dst|$dst, $src2}",
1369 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1370 X86_COND_S, EFLAGS))]>,
1372 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1373 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1374 "cmovs\t{$src2, $dst|$dst, $src2}",
1375 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1376 X86_COND_S, EFLAGS))]>,
1378 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1379 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1380 "cmovns\t{$src2, $dst|$dst, $src2}",
1381 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1382 X86_COND_NS, EFLAGS))]>,
1384 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1385 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1386 "cmovns\t{$src2, $dst|$dst, $src2}",
1387 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1388 X86_COND_NS, EFLAGS))]>,
1390 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1391 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1392 "cmovp\t{$src2, $dst|$dst, $src2}",
1393 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1394 X86_COND_P, EFLAGS))]>,
1396 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1397 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1398 "cmovp\t{$src2, $dst|$dst, $src2}",
1399 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1400 X86_COND_P, EFLAGS))]>,
1402 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1403 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1404 "cmovnp\t{$src2, $dst|$dst, $src2}",
1405 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1406 X86_COND_NP, EFLAGS))]>,
1408 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1409 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1410 "cmovnp\t{$src2, $dst|$dst, $src2}",
1411 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1412 X86_COND_NP, EFLAGS))]>,
1414 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1415 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1416 "cmovo\t{$src2, $dst|$dst, $src2}",
1417 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1418 X86_COND_O, EFLAGS))]>,
1420 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1421 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1422 "cmovo\t{$src2, $dst|$dst, $src2}",
1423 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1424 X86_COND_O, EFLAGS))]>,
1426 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1427 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1428 "cmovno\t{$src2, $dst|$dst, $src2}",
1429 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1430 X86_COND_NO, EFLAGS))]>,
1432 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1433 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1434 "cmovno\t{$src2, $dst|$dst, $src2}",
1435 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1436 X86_COND_NO, EFLAGS))]>,
1438 } // Uses = [EFLAGS]
1441 // unary instructions
1442 let CodeSize = 2 in {
1443 let Defs = [EFLAGS] in {
1444 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1445 [(set GR8:$dst, (ineg GR8:$src)),
1446 (implicit EFLAGS)]>;
1447 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1448 [(set GR16:$dst, (ineg GR16:$src)),
1449 (implicit EFLAGS)]>, OpSize;
1450 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1451 [(set GR32:$dst, (ineg GR32:$src)),
1452 (implicit EFLAGS)]>;
1453 let isTwoAddress = 0 in {
1454 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1455 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1456 (implicit EFLAGS)]>;
1457 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1458 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1459 (implicit EFLAGS)]>, OpSize;
1460 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1461 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1462 (implicit EFLAGS)]>;
1464 } // Defs = [EFLAGS]
1466 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1467 let AddedComplexity = 15 in {
1468 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1469 [(set GR8:$dst, (not GR8:$src))]>;
1470 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1471 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1472 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1473 [(set GR32:$dst, (not GR32:$src))]>;
1475 let isTwoAddress = 0 in {
1476 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1477 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1478 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1479 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1480 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1481 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1485 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1486 let Defs = [EFLAGS] in {
1488 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1489 [(set GR8:$dst, (add GR8:$src, 1)),
1490 (implicit EFLAGS)]>;
1491 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1492 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1493 [(set GR16:$dst, (add GR16:$src, 1)),
1494 (implicit EFLAGS)]>,
1495 OpSize, Requires<[In32BitMode]>;
1496 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1497 [(set GR32:$dst, (add GR32:$src, 1)),
1498 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1500 let isTwoAddress = 0, CodeSize = 2 in {
1501 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1502 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1503 (implicit EFLAGS)]>;
1504 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1505 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1506 (implicit EFLAGS)]>,
1507 OpSize, Requires<[In32BitMode]>;
1508 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1509 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1510 (implicit EFLAGS)]>,
1511 Requires<[In32BitMode]>;
1515 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1516 [(set GR8:$dst, (add GR8:$src, -1)),
1517 (implicit EFLAGS)]>;
1518 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1519 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1520 [(set GR16:$dst, (add GR16:$src, -1)),
1521 (implicit EFLAGS)]>,
1522 OpSize, Requires<[In32BitMode]>;
1523 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1524 [(set GR32:$dst, (add GR32:$src, -1)),
1525 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1528 let isTwoAddress = 0, CodeSize = 2 in {
1529 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1530 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1531 (implicit EFLAGS)]>;
1532 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1533 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1534 (implicit EFLAGS)]>,
1535 OpSize, Requires<[In32BitMode]>;
1536 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1537 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1538 (implicit EFLAGS)]>,
1539 Requires<[In32BitMode]>;
1541 } // Defs = [EFLAGS]
1543 // Logical operators...
1544 let Defs = [EFLAGS] in {
1545 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1546 def AND8rr : I<0x20, MRMDestReg,
1547 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1548 "and{b}\t{$src2, $dst|$dst, $src2}",
1549 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1550 (implicit EFLAGS)]>;
1551 def AND16rr : I<0x21, MRMDestReg,
1552 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1553 "and{w}\t{$src2, $dst|$dst, $src2}",
1554 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1555 (implicit EFLAGS)]>, OpSize;
1556 def AND32rr : I<0x21, MRMDestReg,
1557 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1558 "and{l}\t{$src2, $dst|$dst, $src2}",
1559 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1560 (implicit EFLAGS)]>;
1563 def AND8rm : I<0x22, MRMSrcMem,
1564 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1565 "and{b}\t{$src2, $dst|$dst, $src2}",
1566 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1567 (implicit EFLAGS)]>;
1568 def AND16rm : I<0x23, MRMSrcMem,
1569 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1570 "and{w}\t{$src2, $dst|$dst, $src2}",
1571 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1572 (implicit EFLAGS)]>, OpSize;
1573 def AND32rm : I<0x23, MRMSrcMem,
1574 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1575 "and{l}\t{$src2, $dst|$dst, $src2}",
1576 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1577 (implicit EFLAGS)]>;
1579 def AND8ri : Ii8<0x80, MRM4r,
1580 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1581 "and{b}\t{$src2, $dst|$dst, $src2}",
1582 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1583 (implicit EFLAGS)]>;
1584 def AND16ri : Ii16<0x81, MRM4r,
1585 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1586 "and{w}\t{$src2, $dst|$dst, $src2}",
1587 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1588 (implicit EFLAGS)]>, OpSize;
1589 def AND32ri : Ii32<0x81, MRM4r,
1590 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1591 "and{l}\t{$src2, $dst|$dst, $src2}",
1592 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1593 (implicit EFLAGS)]>;
1594 def AND16ri8 : Ii8<0x83, MRM4r,
1595 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1596 "and{w}\t{$src2, $dst|$dst, $src2}",
1597 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1598 (implicit EFLAGS)]>,
1600 def AND32ri8 : Ii8<0x83, MRM4r,
1601 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1602 "and{l}\t{$src2, $dst|$dst, $src2}",
1603 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1604 (implicit EFLAGS)]>;
1606 let isTwoAddress = 0 in {
1607 def AND8mr : I<0x20, MRMDestMem,
1608 (outs), (ins i8mem :$dst, GR8 :$src),
1609 "and{b}\t{$src, $dst|$dst, $src}",
1610 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1611 (implicit EFLAGS)]>;
1612 def AND16mr : I<0x21, MRMDestMem,
1613 (outs), (ins i16mem:$dst, GR16:$src),
1614 "and{w}\t{$src, $dst|$dst, $src}",
1615 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1616 (implicit EFLAGS)]>,
1618 def AND32mr : I<0x21, MRMDestMem,
1619 (outs), (ins i32mem:$dst, GR32:$src),
1620 "and{l}\t{$src, $dst|$dst, $src}",
1621 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1622 (implicit EFLAGS)]>;
1623 def AND8mi : Ii8<0x80, MRM4m,
1624 (outs), (ins i8mem :$dst, i8imm :$src),
1625 "and{b}\t{$src, $dst|$dst, $src}",
1626 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1627 (implicit EFLAGS)]>;
1628 def AND16mi : Ii16<0x81, MRM4m,
1629 (outs), (ins i16mem:$dst, i16imm:$src),
1630 "and{w}\t{$src, $dst|$dst, $src}",
1631 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1632 (implicit EFLAGS)]>,
1634 def AND32mi : Ii32<0x81, MRM4m,
1635 (outs), (ins i32mem:$dst, i32imm:$src),
1636 "and{l}\t{$src, $dst|$dst, $src}",
1637 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1638 (implicit EFLAGS)]>;
1639 def AND16mi8 : Ii8<0x83, MRM4m,
1640 (outs), (ins i16mem:$dst, i16i8imm :$src),
1641 "and{w}\t{$src, $dst|$dst, $src}",
1642 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1643 (implicit EFLAGS)]>,
1645 def AND32mi8 : Ii8<0x83, MRM4m,
1646 (outs), (ins i32mem:$dst, i32i8imm :$src),
1647 "and{l}\t{$src, $dst|$dst, $src}",
1648 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1649 (implicit EFLAGS)]>;
1651 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1652 "and{b}\t{$src, %al|%al, $src}", []>;
1653 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1654 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1655 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1656 "and{l}\t{$src, %eax|%eax, $src}", []>;
1661 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1662 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1663 "or{b}\t{$src2, $dst|$dst, $src2}",
1664 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1665 (implicit EFLAGS)]>;
1666 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1667 "or{w}\t{$src2, $dst|$dst, $src2}",
1668 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1669 (implicit EFLAGS)]>, OpSize;
1670 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1671 "or{l}\t{$src2, $dst|$dst, $src2}",
1672 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1673 (implicit EFLAGS)]>;
1675 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1676 "or{b}\t{$src2, $dst|$dst, $src2}",
1677 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1678 (implicit EFLAGS)]>;
1679 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1680 "or{w}\t{$src2, $dst|$dst, $src2}",
1681 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1682 (implicit EFLAGS)]>, OpSize;
1683 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1684 "or{l}\t{$src2, $dst|$dst, $src2}",
1685 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1686 (implicit EFLAGS)]>;
1688 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1689 "or{b}\t{$src2, $dst|$dst, $src2}",
1690 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1691 (implicit EFLAGS)]>;
1692 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1693 "or{w}\t{$src2, $dst|$dst, $src2}",
1694 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1695 (implicit EFLAGS)]>, OpSize;
1696 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1697 "or{l}\t{$src2, $dst|$dst, $src2}",
1698 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1699 (implicit EFLAGS)]>;
1701 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1702 "or{w}\t{$src2, $dst|$dst, $src2}",
1703 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1704 (implicit EFLAGS)]>, OpSize;
1705 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1706 "or{l}\t{$src2, $dst|$dst, $src2}",
1707 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1708 (implicit EFLAGS)]>;
1709 let isTwoAddress = 0 in {
1710 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1711 "or{b}\t{$src, $dst|$dst, $src}",
1712 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1713 (implicit EFLAGS)]>;
1714 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1715 "or{w}\t{$src, $dst|$dst, $src}",
1716 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1717 (implicit EFLAGS)]>, OpSize;
1718 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1719 "or{l}\t{$src, $dst|$dst, $src}",
1720 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1721 (implicit EFLAGS)]>;
1722 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1723 "or{b}\t{$src, $dst|$dst, $src}",
1724 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1725 (implicit EFLAGS)]>;
1726 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1727 "or{w}\t{$src, $dst|$dst, $src}",
1728 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1729 (implicit EFLAGS)]>,
1731 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1732 "or{l}\t{$src, $dst|$dst, $src}",
1733 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1734 (implicit EFLAGS)]>;
1735 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1736 "or{w}\t{$src, $dst|$dst, $src}",
1737 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1738 (implicit EFLAGS)]>,
1740 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1741 "or{l}\t{$src, $dst|$dst, $src}",
1742 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1743 (implicit EFLAGS)]>;
1744 } // isTwoAddress = 0
1747 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1748 def XOR8rr : I<0x30, MRMDestReg,
1749 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1750 "xor{b}\t{$src2, $dst|$dst, $src2}",
1751 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1752 (implicit EFLAGS)]>;
1753 def XOR16rr : I<0x31, MRMDestReg,
1754 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1755 "xor{w}\t{$src2, $dst|$dst, $src2}",
1756 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1757 (implicit EFLAGS)]>, OpSize;
1758 def XOR32rr : I<0x31, MRMDestReg,
1759 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1760 "xor{l}\t{$src2, $dst|$dst, $src2}",
1761 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1762 (implicit EFLAGS)]>;
1763 } // isCommutable = 1
1765 def XOR8rm : I<0x32, MRMSrcMem ,
1766 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1767 "xor{b}\t{$src2, $dst|$dst, $src2}",
1768 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1769 (implicit EFLAGS)]>;
1770 def XOR16rm : I<0x33, MRMSrcMem ,
1771 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1772 "xor{w}\t{$src2, $dst|$dst, $src2}",
1773 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1774 (implicit EFLAGS)]>,
1776 def XOR32rm : I<0x33, MRMSrcMem ,
1777 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1778 "xor{l}\t{$src2, $dst|$dst, $src2}",
1779 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1780 (implicit EFLAGS)]>;
1782 def XOR8ri : Ii8<0x80, MRM6r,
1783 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1784 "xor{b}\t{$src2, $dst|$dst, $src2}",
1785 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1786 (implicit EFLAGS)]>;
1787 def XOR16ri : Ii16<0x81, MRM6r,
1788 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1789 "xor{w}\t{$src2, $dst|$dst, $src2}",
1790 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1791 (implicit EFLAGS)]>, OpSize;
1792 def XOR32ri : Ii32<0x81, MRM6r,
1793 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1794 "xor{l}\t{$src2, $dst|$dst, $src2}",
1795 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1796 (implicit EFLAGS)]>;
1797 def XOR16ri8 : Ii8<0x83, MRM6r,
1798 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1799 "xor{w}\t{$src2, $dst|$dst, $src2}",
1800 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1801 (implicit EFLAGS)]>,
1803 def XOR32ri8 : Ii8<0x83, MRM6r,
1804 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1805 "xor{l}\t{$src2, $dst|$dst, $src2}",
1806 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1807 (implicit EFLAGS)]>;
1809 let isTwoAddress = 0 in {
1810 def XOR8mr : I<0x30, MRMDestMem,
1811 (outs), (ins i8mem :$dst, GR8 :$src),
1812 "xor{b}\t{$src, $dst|$dst, $src}",
1813 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1814 (implicit EFLAGS)]>;
1815 def XOR16mr : I<0x31, MRMDestMem,
1816 (outs), (ins i16mem:$dst, GR16:$src),
1817 "xor{w}\t{$src, $dst|$dst, $src}",
1818 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1819 (implicit EFLAGS)]>,
1821 def XOR32mr : I<0x31, MRMDestMem,
1822 (outs), (ins i32mem:$dst, GR32:$src),
1823 "xor{l}\t{$src, $dst|$dst, $src}",
1824 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1825 (implicit EFLAGS)]>;
1826 def XOR8mi : Ii8<0x80, MRM6m,
1827 (outs), (ins i8mem :$dst, i8imm :$src),
1828 "xor{b}\t{$src, $dst|$dst, $src}",
1829 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1830 (implicit EFLAGS)]>;
1831 def XOR16mi : Ii16<0x81, MRM6m,
1832 (outs), (ins i16mem:$dst, i16imm:$src),
1833 "xor{w}\t{$src, $dst|$dst, $src}",
1834 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1835 (implicit EFLAGS)]>,
1837 def XOR32mi : Ii32<0x81, MRM6m,
1838 (outs), (ins i32mem:$dst, i32imm:$src),
1839 "xor{l}\t{$src, $dst|$dst, $src}",
1840 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1841 (implicit EFLAGS)]>;
1842 def XOR16mi8 : Ii8<0x83, MRM6m,
1843 (outs), (ins i16mem:$dst, i16i8imm :$src),
1844 "xor{w}\t{$src, $dst|$dst, $src}",
1845 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1846 (implicit EFLAGS)]>,
1848 def XOR32mi8 : Ii8<0x83, MRM6m,
1849 (outs), (ins i32mem:$dst, i32i8imm :$src),
1850 "xor{l}\t{$src, $dst|$dst, $src}",
1851 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1852 (implicit EFLAGS)]>;
1853 } // isTwoAddress = 0
1854 } // Defs = [EFLAGS]
1856 // Shift instructions
1857 let Defs = [EFLAGS] in {
1858 let Uses = [CL] in {
1859 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1860 "shl{b}\t{%cl, $dst|$dst, CL}",
1861 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1862 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1863 "shl{w}\t{%cl, $dst|$dst, CL}",
1864 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1865 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1866 "shl{l}\t{%cl, $dst|$dst, CL}",
1867 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1870 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1871 "shl{b}\t{$src2, $dst|$dst, $src2}",
1872 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1873 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1874 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1875 "shl{w}\t{$src2, $dst|$dst, $src2}",
1876 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1877 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1878 "shl{l}\t{$src2, $dst|$dst, $src2}",
1879 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1880 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1882 } // isConvertibleToThreeAddress = 1
1884 let isTwoAddress = 0 in {
1885 let Uses = [CL] in {
1886 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1887 "shl{b}\t{%cl, $dst|$dst, CL}",
1888 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1889 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1890 "shl{w}\t{%cl, $dst|$dst, CL}",
1891 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1892 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1893 "shl{l}\t{%cl, $dst|$dst, CL}",
1894 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1896 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1897 "shl{b}\t{$src, $dst|$dst, $src}",
1898 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1899 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1900 "shl{w}\t{$src, $dst|$dst, $src}",
1901 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1903 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1904 "shl{l}\t{$src, $dst|$dst, $src}",
1905 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1908 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1910 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1911 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1913 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1915 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1917 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1920 let Uses = [CL] in {
1921 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1922 "shr{b}\t{%cl, $dst|$dst, CL}",
1923 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1924 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1925 "shr{w}\t{%cl, $dst|$dst, CL}",
1926 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1927 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1928 "shr{l}\t{%cl, $dst|$dst, CL}",
1929 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1932 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1933 "shr{b}\t{$src2, $dst|$dst, $src2}",
1934 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1935 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1936 "shr{w}\t{$src2, $dst|$dst, $src2}",
1937 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1938 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1939 "shr{l}\t{$src2, $dst|$dst, $src2}",
1940 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1943 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1945 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1946 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1948 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1949 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1951 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1953 let isTwoAddress = 0 in {
1954 let Uses = [CL] in {
1955 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1956 "shr{b}\t{%cl, $dst|$dst, CL}",
1957 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1958 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1959 "shr{w}\t{%cl, $dst|$dst, CL}",
1960 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1962 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1963 "shr{l}\t{%cl, $dst|$dst, CL}",
1964 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1966 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1967 "shr{b}\t{$src, $dst|$dst, $src}",
1968 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1969 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1970 "shr{w}\t{$src, $dst|$dst, $src}",
1971 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1973 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1974 "shr{l}\t{$src, $dst|$dst, $src}",
1975 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1978 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1980 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1981 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1983 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1984 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1986 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1989 let Uses = [CL] in {
1990 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1991 "sar{b}\t{%cl, $dst|$dst, CL}",
1992 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1993 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1994 "sar{w}\t{%cl, $dst|$dst, CL}",
1995 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1996 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1997 "sar{l}\t{%cl, $dst|$dst, CL}",
1998 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2001 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2002 "sar{b}\t{$src2, $dst|$dst, $src2}",
2003 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2004 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2005 "sar{w}\t{$src2, $dst|$dst, $src2}",
2006 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2008 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2009 "sar{l}\t{$src2, $dst|$dst, $src2}",
2010 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2013 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2015 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2016 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2018 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2019 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2021 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2023 let isTwoAddress = 0 in {
2024 let Uses = [CL] in {
2025 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2026 "sar{b}\t{%cl, $dst|$dst, CL}",
2027 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2028 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2029 "sar{w}\t{%cl, $dst|$dst, CL}",
2030 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2031 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2032 "sar{l}\t{%cl, $dst|$dst, CL}",
2033 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2035 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2036 "sar{b}\t{$src, $dst|$dst, $src}",
2037 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2038 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2039 "sar{w}\t{$src, $dst|$dst, $src}",
2040 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2042 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2043 "sar{l}\t{$src, $dst|$dst, $src}",
2044 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2047 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2049 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2050 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2052 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2054 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2056 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2059 // Rotate instructions
2060 // FIXME: provide shorter instructions when imm8 == 1
2061 let Uses = [CL] in {
2062 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
2063 "rol{b}\t{%cl, $dst|$dst, CL}",
2064 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
2065 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
2066 "rol{w}\t{%cl, $dst|$dst, CL}",
2067 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
2068 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
2069 "rol{l}\t{%cl, $dst|$dst, CL}",
2070 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2073 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2074 "rol{b}\t{$src2, $dst|$dst, $src2}",
2075 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2076 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2077 "rol{w}\t{$src2, $dst|$dst, $src2}",
2078 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2079 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2080 "rol{l}\t{$src2, $dst|$dst, $src2}",
2081 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2084 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2086 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2087 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2089 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2090 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2092 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2094 let isTwoAddress = 0 in {
2095 let Uses = [CL] in {
2096 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2097 "rol{b}\t{%cl, $dst|$dst, CL}",
2098 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2099 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2100 "rol{w}\t{%cl, $dst|$dst, CL}",
2101 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2102 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2103 "rol{l}\t{%cl, $dst|$dst, CL}",
2104 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2106 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2107 "rol{b}\t{$src, $dst|$dst, $src}",
2108 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2109 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2110 "rol{w}\t{$src, $dst|$dst, $src}",
2111 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2113 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2114 "rol{l}\t{$src, $dst|$dst, $src}",
2115 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2118 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2120 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2121 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2123 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2125 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2127 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2130 let Uses = [CL] in {
2131 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2132 "ror{b}\t{%cl, $dst|$dst, CL}",
2133 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2134 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2135 "ror{w}\t{%cl, $dst|$dst, CL}",
2136 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2137 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2138 "ror{l}\t{%cl, $dst|$dst, CL}",
2139 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2142 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2143 "ror{b}\t{$src2, $dst|$dst, $src2}",
2144 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2145 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2146 "ror{w}\t{$src2, $dst|$dst, $src2}",
2147 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2148 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2149 "ror{l}\t{$src2, $dst|$dst, $src2}",
2150 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2153 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2155 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2156 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2158 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2159 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2161 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2163 let isTwoAddress = 0 in {
2164 let Uses = [CL] in {
2165 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2166 "ror{b}\t{%cl, $dst|$dst, CL}",
2167 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2168 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2169 "ror{w}\t{%cl, $dst|$dst, CL}",
2170 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2171 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2172 "ror{l}\t{%cl, $dst|$dst, CL}",
2173 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2175 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2176 "ror{b}\t{$src, $dst|$dst, $src}",
2177 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2178 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2179 "ror{w}\t{$src, $dst|$dst, $src}",
2180 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2182 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2183 "ror{l}\t{$src, $dst|$dst, $src}",
2184 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2187 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2189 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2190 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2192 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2194 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2196 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2201 // Double shift instructions (generalizations of rotate)
2202 let Uses = [CL] in {
2203 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2204 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2205 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2206 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2207 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2208 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2209 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2210 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2211 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2213 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2214 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2215 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2219 let isCommutable = 1 in { // These instructions commute to each other.
2220 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2221 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2222 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2223 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2226 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2227 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2228 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2229 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2232 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2233 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2234 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2235 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2238 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2239 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2240 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2241 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2246 let isTwoAddress = 0 in {
2247 let Uses = [CL] in {
2248 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2249 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2250 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2252 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2253 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2254 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2257 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2258 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2259 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2260 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2261 (i8 imm:$src3)), addr:$dst)]>,
2263 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2264 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2265 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2266 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2267 (i8 imm:$src3)), addr:$dst)]>,
2270 let Uses = [CL] in {
2271 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2272 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2273 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2274 addr:$dst)]>, TB, OpSize;
2275 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2276 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2277 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2278 addr:$dst)]>, TB, OpSize;
2280 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2281 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2282 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2283 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2284 (i8 imm:$src3)), addr:$dst)]>,
2286 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2287 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2288 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2289 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2290 (i8 imm:$src3)), addr:$dst)]>,
2293 } // Defs = [EFLAGS]
2297 let Defs = [EFLAGS] in {
2298 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2299 // Register-Register Addition
2300 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2301 (ins GR8 :$src1, GR8 :$src2),
2302 "add{b}\t{$src2, $dst|$dst, $src2}",
2303 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2304 (implicit EFLAGS)]>;
2306 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2307 // Register-Register Addition
2308 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2309 (ins GR16:$src1, GR16:$src2),
2310 "add{w}\t{$src2, $dst|$dst, $src2}",
2311 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2312 (implicit EFLAGS)]>, OpSize;
2313 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2314 (ins GR32:$src1, GR32:$src2),
2315 "add{l}\t{$src2, $dst|$dst, $src2}",
2316 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2317 (implicit EFLAGS)]>;
2318 } // end isConvertibleToThreeAddress
2319 } // end isCommutable
2321 // Register-Memory Addition
2322 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2323 (ins GR8 :$src1, i8mem :$src2),
2324 "add{b}\t{$src2, $dst|$dst, $src2}",
2325 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2326 (implicit EFLAGS)]>;
2327 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2328 (ins GR16:$src1, i16mem:$src2),
2329 "add{w}\t{$src2, $dst|$dst, $src2}",
2330 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2331 (implicit EFLAGS)]>, OpSize;
2332 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2333 (ins GR32:$src1, i32mem:$src2),
2334 "add{l}\t{$src2, $dst|$dst, $src2}",
2335 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2336 (implicit EFLAGS)]>;
2338 // Register-Integer Addition
2339 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2340 "add{b}\t{$src2, $dst|$dst, $src2}",
2341 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2342 (implicit EFLAGS)]>;
2344 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2345 // Register-Integer Addition
2346 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2347 (ins GR16:$src1, i16imm:$src2),
2348 "add{w}\t{$src2, $dst|$dst, $src2}",
2349 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2350 (implicit EFLAGS)]>, OpSize;
2351 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2352 (ins GR32:$src1, i32imm:$src2),
2353 "add{l}\t{$src2, $dst|$dst, $src2}",
2354 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2355 (implicit EFLAGS)]>;
2356 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2357 (ins GR16:$src1, i16i8imm:$src2),
2358 "add{w}\t{$src2, $dst|$dst, $src2}",
2359 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2360 (implicit EFLAGS)]>, OpSize;
2361 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2362 (ins GR32:$src1, i32i8imm:$src2),
2363 "add{l}\t{$src2, $dst|$dst, $src2}",
2364 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2365 (implicit EFLAGS)]>;
2368 let isTwoAddress = 0 in {
2369 // Memory-Register Addition
2370 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2371 "add{b}\t{$src2, $dst|$dst, $src2}",
2372 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2373 (implicit EFLAGS)]>;
2374 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2375 "add{w}\t{$src2, $dst|$dst, $src2}",
2376 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2377 (implicit EFLAGS)]>, OpSize;
2378 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2379 "add{l}\t{$src2, $dst|$dst, $src2}",
2380 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2381 (implicit EFLAGS)]>;
2382 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2383 "add{b}\t{$src2, $dst|$dst, $src2}",
2384 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2385 (implicit EFLAGS)]>;
2386 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2387 "add{w}\t{$src2, $dst|$dst, $src2}",
2388 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2389 (implicit EFLAGS)]>, OpSize;
2390 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2391 "add{l}\t{$src2, $dst|$dst, $src2}",
2392 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2393 (implicit EFLAGS)]>;
2394 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2395 "add{w}\t{$src2, $dst|$dst, $src2}",
2396 [(store (add (load addr:$dst), i16immSExt8:$src2),
2398 (implicit EFLAGS)]>, OpSize;
2399 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2400 "add{l}\t{$src2, $dst|$dst, $src2}",
2401 [(store (add (load addr:$dst), i32immSExt8:$src2),
2403 (implicit EFLAGS)]>;
2406 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2407 "add{b}\t{$src, %al|%al, $src}", []>;
2408 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2409 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2410 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2411 "add{l}\t{$src, %eax|%eax, $src}", []>;
2414 let Uses = [EFLAGS] in {
2415 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2416 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2417 "adc{b}\t{$src2, $dst|$dst, $src2}",
2418 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2419 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2420 (ins GR16:$src1, GR16:$src2),
2421 "adc{w}\t{$src2, $dst|$dst, $src2}",
2422 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2423 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2424 (ins GR32:$src1, GR32:$src2),
2425 "adc{l}\t{$src2, $dst|$dst, $src2}",
2426 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2428 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2429 (ins GR8:$src1, i8mem:$src2),
2430 "adc{b}\t{$src2, $dst|$dst, $src2}",
2431 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2432 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2433 (ins GR16:$src1, i16mem:$src2),
2434 "adc{w}\t{$src2, $dst|$dst, $src2}",
2435 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2437 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2438 (ins GR32:$src1, i32mem:$src2),
2439 "adc{l}\t{$src2, $dst|$dst, $src2}",
2440 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2441 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2442 "adc{b}\t{$src2, $dst|$dst, $src2}",
2443 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2444 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2445 (ins GR16:$src1, i16imm:$src2),
2446 "adc{w}\t{$src2, $dst|$dst, $src2}",
2447 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2448 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2449 (ins GR16:$src1, i16i8imm:$src2),
2450 "adc{w}\t{$src2, $dst|$dst, $src2}",
2451 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2453 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2454 (ins GR32:$src1, i32imm:$src2),
2455 "adc{l}\t{$src2, $dst|$dst, $src2}",
2456 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2457 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2458 (ins GR32:$src1, i32i8imm:$src2),
2459 "adc{l}\t{$src2, $dst|$dst, $src2}",
2460 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2462 let isTwoAddress = 0 in {
2463 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2464 "adc{b}\t{$src2, $dst|$dst, $src2}",
2465 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2466 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2467 "adc{w}\t{$src2, $dst|$dst, $src2}",
2468 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2470 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2471 "adc{l}\t{$src2, $dst|$dst, $src2}",
2472 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2473 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2474 "adc{b}\t{$src2, $dst|$dst, $src2}",
2475 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2476 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2477 "adc{w}\t{$src2, $dst|$dst, $src2}",
2478 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2480 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2481 "adc{w}\t{$src2, $dst|$dst, $src2}",
2482 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2484 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2485 "adc{l}\t{$src2, $dst|$dst, $src2}",
2486 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2487 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2488 "adc{l}\t{$src2, $dst|$dst, $src2}",
2489 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2491 } // Uses = [EFLAGS]
2493 // Register-Register Subtraction
2494 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2495 "sub{b}\t{$src2, $dst|$dst, $src2}",
2496 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2497 (implicit EFLAGS)]>;
2498 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2499 "sub{w}\t{$src2, $dst|$dst, $src2}",
2500 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2501 (implicit EFLAGS)]>, OpSize;
2502 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2503 "sub{l}\t{$src2, $dst|$dst, $src2}",
2504 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2505 (implicit EFLAGS)]>;
2507 // Register-Memory Subtraction
2508 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2509 (ins GR8 :$src1, i8mem :$src2),
2510 "sub{b}\t{$src2, $dst|$dst, $src2}",
2511 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2512 (implicit EFLAGS)]>;
2513 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2514 (ins GR16:$src1, i16mem:$src2),
2515 "sub{w}\t{$src2, $dst|$dst, $src2}",
2516 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2517 (implicit EFLAGS)]>, OpSize;
2518 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2519 (ins GR32:$src1, i32mem:$src2),
2520 "sub{l}\t{$src2, $dst|$dst, $src2}",
2521 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2522 (implicit EFLAGS)]>;
2524 // Register-Integer Subtraction
2525 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2526 (ins GR8:$src1, i8imm:$src2),
2527 "sub{b}\t{$src2, $dst|$dst, $src2}",
2528 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2529 (implicit EFLAGS)]>;
2530 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2531 (ins GR16:$src1, i16imm:$src2),
2532 "sub{w}\t{$src2, $dst|$dst, $src2}",
2533 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2534 (implicit EFLAGS)]>, OpSize;
2535 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2536 (ins GR32:$src1, i32imm:$src2),
2537 "sub{l}\t{$src2, $dst|$dst, $src2}",
2538 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2539 (implicit EFLAGS)]>;
2540 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2541 (ins GR16:$src1, i16i8imm:$src2),
2542 "sub{w}\t{$src2, $dst|$dst, $src2}",
2543 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2544 (implicit EFLAGS)]>, OpSize;
2545 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2546 (ins GR32:$src1, i32i8imm:$src2),
2547 "sub{l}\t{$src2, $dst|$dst, $src2}",
2548 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2549 (implicit EFLAGS)]>;
2551 let isTwoAddress = 0 in {
2552 // Memory-Register Subtraction
2553 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2554 "sub{b}\t{$src2, $dst|$dst, $src2}",
2555 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2556 (implicit EFLAGS)]>;
2557 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2558 "sub{w}\t{$src2, $dst|$dst, $src2}",
2559 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2560 (implicit EFLAGS)]>, OpSize;
2561 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2562 "sub{l}\t{$src2, $dst|$dst, $src2}",
2563 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2564 (implicit EFLAGS)]>;
2566 // Memory-Integer Subtraction
2567 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2568 "sub{b}\t{$src2, $dst|$dst, $src2}",
2569 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2570 (implicit EFLAGS)]>;
2571 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2572 "sub{w}\t{$src2, $dst|$dst, $src2}",
2573 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2574 (implicit EFLAGS)]>, OpSize;
2575 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2576 "sub{l}\t{$src2, $dst|$dst, $src2}",
2577 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2578 (implicit EFLAGS)]>;
2579 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2580 "sub{w}\t{$src2, $dst|$dst, $src2}",
2581 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2583 (implicit EFLAGS)]>, OpSize;
2584 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2585 "sub{l}\t{$src2, $dst|$dst, $src2}",
2586 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2588 (implicit EFLAGS)]>;
2591 let Uses = [EFLAGS] in {
2592 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2593 (ins GR8:$src1, GR8:$src2),
2594 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2595 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2596 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2597 (ins GR16:$src1, GR16:$src2),
2598 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2599 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2600 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2601 (ins GR32:$src1, GR32:$src2),
2602 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2603 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2605 let isTwoAddress = 0 in {
2606 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2607 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2608 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2609 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2610 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2611 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2613 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2614 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2615 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2616 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2617 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2618 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2619 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2620 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2621 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2623 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2624 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2625 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2627 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2628 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2629 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2630 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2631 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2632 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2634 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2635 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2636 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2637 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2638 (ins GR16:$src1, i16mem:$src2),
2639 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2640 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2642 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2643 (ins GR32:$src1, i32mem:$src2),
2644 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2645 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2646 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2647 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2648 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2649 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2650 (ins GR16:$src1, i16imm:$src2),
2651 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2652 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2653 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2654 (ins GR16:$src1, i16i8imm:$src2),
2655 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2656 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2658 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2659 (ins GR32:$src1, i32imm:$src2),
2660 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2661 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2662 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2663 (ins GR32:$src1, i32i8imm:$src2),
2664 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2665 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2666 } // Uses = [EFLAGS]
2667 } // Defs = [EFLAGS]
2669 let Defs = [EFLAGS] in {
2670 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2671 // Register-Register Signed Integer Multiply
2672 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2673 "imul{w}\t{$src2, $dst|$dst, $src2}",
2674 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2675 (implicit EFLAGS)]>, TB, OpSize;
2676 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2677 "imul{l}\t{$src2, $dst|$dst, $src2}",
2678 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2679 (implicit EFLAGS)]>, TB;
2682 // Register-Memory Signed Integer Multiply
2683 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2684 (ins GR16:$src1, i16mem:$src2),
2685 "imul{w}\t{$src2, $dst|$dst, $src2}",
2686 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2687 (implicit EFLAGS)]>, TB, OpSize;
2688 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2689 "imul{l}\t{$src2, $dst|$dst, $src2}",
2690 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2691 (implicit EFLAGS)]>, TB;
2692 } // Defs = [EFLAGS]
2693 } // end Two Address instructions
2695 // Suprisingly enough, these are not two address instructions!
2696 let Defs = [EFLAGS] in {
2697 // Register-Integer Signed Integer Multiply
2698 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2699 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2700 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2701 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2702 (implicit EFLAGS)]>, OpSize;
2703 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2704 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2705 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2706 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2707 (implicit EFLAGS)]>;
2708 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2709 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2710 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2711 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2712 (implicit EFLAGS)]>, OpSize;
2713 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2714 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2715 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2716 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2717 (implicit EFLAGS)]>;
2719 // Memory-Integer Signed Integer Multiply
2720 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2721 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2722 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2723 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2724 (implicit EFLAGS)]>, OpSize;
2725 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2726 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2727 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2728 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2729 (implicit EFLAGS)]>;
2730 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2731 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2732 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2733 [(set GR16:$dst, (mul (load addr:$src1),
2734 i16immSExt8:$src2)),
2735 (implicit EFLAGS)]>, OpSize;
2736 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2737 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2738 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2739 [(set GR32:$dst, (mul (load addr:$src1),
2740 i32immSExt8:$src2)),
2741 (implicit EFLAGS)]>;
2742 } // Defs = [EFLAGS]
2744 //===----------------------------------------------------------------------===//
2745 // Test instructions are just like AND, except they don't generate a result.
2747 let Defs = [EFLAGS] in {
2748 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2749 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2750 "test{b}\t{$src2, $src1|$src1, $src2}",
2751 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2752 (implicit EFLAGS)]>;
2753 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2754 "test{w}\t{$src2, $src1|$src1, $src2}",
2755 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2756 (implicit EFLAGS)]>,
2758 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2759 "test{l}\t{$src2, $src1|$src1, $src2}",
2760 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2761 (implicit EFLAGS)]>;
2764 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
2765 "test{b}\t{$src, %al|%al, $src}", []>;
2766 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
2767 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2768 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
2769 "test{l}\t{$src, %eax|%eax, $src}", []>;
2771 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2772 "test{b}\t{$src2, $src1|$src1, $src2}",
2773 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2774 (implicit EFLAGS)]>;
2775 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2776 "test{w}\t{$src2, $src1|$src1, $src2}",
2777 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2778 (implicit EFLAGS)]>, OpSize;
2779 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2780 "test{l}\t{$src2, $src1|$src1, $src2}",
2781 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2782 (implicit EFLAGS)]>;
2784 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2785 (outs), (ins GR8:$src1, i8imm:$src2),
2786 "test{b}\t{$src2, $src1|$src1, $src2}",
2787 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2788 (implicit EFLAGS)]>;
2789 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2790 (outs), (ins GR16:$src1, i16imm:$src2),
2791 "test{w}\t{$src2, $src1|$src1, $src2}",
2792 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2793 (implicit EFLAGS)]>, OpSize;
2794 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2795 (outs), (ins GR32:$src1, i32imm:$src2),
2796 "test{l}\t{$src2, $src1|$src1, $src2}",
2797 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2798 (implicit EFLAGS)]>;
2800 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2801 (outs), (ins i8mem:$src1, i8imm:$src2),
2802 "test{b}\t{$src2, $src1|$src1, $src2}",
2803 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2804 (implicit EFLAGS)]>;
2805 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2806 (outs), (ins i16mem:$src1, i16imm:$src2),
2807 "test{w}\t{$src2, $src1|$src1, $src2}",
2808 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2809 (implicit EFLAGS)]>, OpSize;
2810 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2811 (outs), (ins i32mem:$src1, i32imm:$src2),
2812 "test{l}\t{$src2, $src1|$src1, $src2}",
2813 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2814 (implicit EFLAGS)]>;
2815 } // Defs = [EFLAGS]
2818 // Condition code ops, incl. set if equal/not equal/...
2819 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2820 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2821 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2822 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2824 let Uses = [EFLAGS] in {
2825 def SETEr : I<0x94, MRM0r,
2826 (outs GR8 :$dst), (ins),
2828 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2830 def SETEm : I<0x94, MRM0m,
2831 (outs), (ins i8mem:$dst),
2833 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2836 def SETNEr : I<0x95, MRM0r,
2837 (outs GR8 :$dst), (ins),
2839 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2841 def SETNEm : I<0x95, MRM0m,
2842 (outs), (ins i8mem:$dst),
2844 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2847 def SETLr : I<0x9C, MRM0r,
2848 (outs GR8 :$dst), (ins),
2850 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2851 TB; // GR8 = < signed
2852 def SETLm : I<0x9C, MRM0m,
2853 (outs), (ins i8mem:$dst),
2855 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2856 TB; // [mem8] = < signed
2858 def SETGEr : I<0x9D, MRM0r,
2859 (outs GR8 :$dst), (ins),
2861 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2862 TB; // GR8 = >= signed
2863 def SETGEm : I<0x9D, MRM0m,
2864 (outs), (ins i8mem:$dst),
2866 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2867 TB; // [mem8] = >= signed
2869 def SETLEr : I<0x9E, MRM0r,
2870 (outs GR8 :$dst), (ins),
2872 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2873 TB; // GR8 = <= signed
2874 def SETLEm : I<0x9E, MRM0m,
2875 (outs), (ins i8mem:$dst),
2877 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2878 TB; // [mem8] = <= signed
2880 def SETGr : I<0x9F, MRM0r,
2881 (outs GR8 :$dst), (ins),
2883 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2884 TB; // GR8 = > signed
2885 def SETGm : I<0x9F, MRM0m,
2886 (outs), (ins i8mem:$dst),
2888 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2889 TB; // [mem8] = > signed
2891 def SETBr : I<0x92, MRM0r,
2892 (outs GR8 :$dst), (ins),
2894 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2895 TB; // GR8 = < unsign
2896 def SETBm : I<0x92, MRM0m,
2897 (outs), (ins i8mem:$dst),
2899 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2900 TB; // [mem8] = < unsign
2902 def SETAEr : I<0x93, MRM0r,
2903 (outs GR8 :$dst), (ins),
2905 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2906 TB; // GR8 = >= unsign
2907 def SETAEm : I<0x93, MRM0m,
2908 (outs), (ins i8mem:$dst),
2910 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2911 TB; // [mem8] = >= unsign
2913 def SETBEr : I<0x96, MRM0r,
2914 (outs GR8 :$dst), (ins),
2916 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2917 TB; // GR8 = <= unsign
2918 def SETBEm : I<0x96, MRM0m,
2919 (outs), (ins i8mem:$dst),
2921 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2922 TB; // [mem8] = <= unsign
2924 def SETAr : I<0x97, MRM0r,
2925 (outs GR8 :$dst), (ins),
2927 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2928 TB; // GR8 = > signed
2929 def SETAm : I<0x97, MRM0m,
2930 (outs), (ins i8mem:$dst),
2932 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2933 TB; // [mem8] = > signed
2935 def SETSr : I<0x98, MRM0r,
2936 (outs GR8 :$dst), (ins),
2938 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2939 TB; // GR8 = <sign bit>
2940 def SETSm : I<0x98, MRM0m,
2941 (outs), (ins i8mem:$dst),
2943 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2944 TB; // [mem8] = <sign bit>
2945 def SETNSr : I<0x99, MRM0r,
2946 (outs GR8 :$dst), (ins),
2948 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2949 TB; // GR8 = !<sign bit>
2950 def SETNSm : I<0x99, MRM0m,
2951 (outs), (ins i8mem:$dst),
2953 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2954 TB; // [mem8] = !<sign bit>
2956 def SETPr : I<0x9A, MRM0r,
2957 (outs GR8 :$dst), (ins),
2959 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2961 def SETPm : I<0x9A, MRM0m,
2962 (outs), (ins i8mem:$dst),
2964 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2965 TB; // [mem8] = parity
2966 def SETNPr : I<0x9B, MRM0r,
2967 (outs GR8 :$dst), (ins),
2969 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2970 TB; // GR8 = not parity
2971 def SETNPm : I<0x9B, MRM0m,
2972 (outs), (ins i8mem:$dst),
2974 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2975 TB; // [mem8] = not parity
2977 def SETOr : I<0x90, MRM0r,
2978 (outs GR8 :$dst), (ins),
2980 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2981 TB; // GR8 = overflow
2982 def SETOm : I<0x90, MRM0m,
2983 (outs), (ins i8mem:$dst),
2985 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2986 TB; // [mem8] = overflow
2987 def SETNOr : I<0x91, MRM0r,
2988 (outs GR8 :$dst), (ins),
2990 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2991 TB; // GR8 = not overflow
2992 def SETNOm : I<0x91, MRM0m,
2993 (outs), (ins i8mem:$dst),
2995 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2996 TB; // [mem8] = not overflow
2997 } // Uses = [EFLAGS]
3000 // Integer comparisons
3001 let Defs = [EFLAGS] in {
3002 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3003 "cmp{b}\t{$src, %al|%al, $src}", []>;
3004 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3005 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3006 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3007 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3009 def CMP8rr : I<0x38, MRMDestReg,
3010 (outs), (ins GR8 :$src1, GR8 :$src2),
3011 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3012 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
3013 def CMP16rr : I<0x39, MRMDestReg,
3014 (outs), (ins GR16:$src1, GR16:$src2),
3015 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3016 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
3017 def CMP32rr : I<0x39, MRMDestReg,
3018 (outs), (ins GR32:$src1, GR32:$src2),
3019 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3020 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
3021 def CMP8mr : I<0x38, MRMDestMem,
3022 (outs), (ins i8mem :$src1, GR8 :$src2),
3023 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3024 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3025 (implicit EFLAGS)]>;
3026 def CMP16mr : I<0x39, MRMDestMem,
3027 (outs), (ins i16mem:$src1, GR16:$src2),
3028 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3029 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3030 (implicit EFLAGS)]>, OpSize;
3031 def CMP32mr : I<0x39, MRMDestMem,
3032 (outs), (ins i32mem:$src1, GR32:$src2),
3033 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3034 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3035 (implicit EFLAGS)]>;
3036 def CMP8rm : I<0x3A, MRMSrcMem,
3037 (outs), (ins GR8 :$src1, i8mem :$src2),
3038 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3039 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3040 (implicit EFLAGS)]>;
3041 def CMP16rm : I<0x3B, MRMSrcMem,
3042 (outs), (ins GR16:$src1, i16mem:$src2),
3043 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3044 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3045 (implicit EFLAGS)]>, OpSize;
3046 def CMP32rm : I<0x3B, MRMSrcMem,
3047 (outs), (ins GR32:$src1, i32mem:$src2),
3048 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3049 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3050 (implicit EFLAGS)]>;
3051 def CMP8ri : Ii8<0x80, MRM7r,
3052 (outs), (ins GR8:$src1, i8imm:$src2),
3053 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3054 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
3055 def CMP16ri : Ii16<0x81, MRM7r,
3056 (outs), (ins GR16:$src1, i16imm:$src2),
3057 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3058 [(X86cmp GR16:$src1, imm:$src2),
3059 (implicit EFLAGS)]>, OpSize;
3060 def CMP32ri : Ii32<0x81, MRM7r,
3061 (outs), (ins GR32:$src1, i32imm:$src2),
3062 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3063 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
3064 def CMP8mi : Ii8 <0x80, MRM7m,
3065 (outs), (ins i8mem :$src1, i8imm :$src2),
3066 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3067 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3068 (implicit EFLAGS)]>;
3069 def CMP16mi : Ii16<0x81, MRM7m,
3070 (outs), (ins i16mem:$src1, i16imm:$src2),
3071 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3072 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3073 (implicit EFLAGS)]>, OpSize;
3074 def CMP32mi : Ii32<0x81, MRM7m,
3075 (outs), (ins i32mem:$src1, i32imm:$src2),
3076 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3077 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3078 (implicit EFLAGS)]>;
3079 def CMP16ri8 : Ii8<0x83, MRM7r,
3080 (outs), (ins GR16:$src1, i16i8imm:$src2),
3081 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3082 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3083 (implicit EFLAGS)]>, OpSize;
3084 def CMP16mi8 : Ii8<0x83, MRM7m,
3085 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3086 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3087 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3088 (implicit EFLAGS)]>, OpSize;
3089 def CMP32mi8 : Ii8<0x83, MRM7m,
3090 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3091 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3092 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3093 (implicit EFLAGS)]>;
3094 def CMP32ri8 : Ii8<0x83, MRM7r,
3095 (outs), (ins GR32:$src1, i32i8imm:$src2),
3096 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3097 [(X86cmp GR32:$src1, i32immSExt8:$src2),
3098 (implicit EFLAGS)]>;
3099 } // Defs = [EFLAGS]
3102 // TODO: BTC, BTR, and BTS
3103 let Defs = [EFLAGS] in {
3104 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3105 "bt{w}\t{$src2, $src1|$src1, $src2}",
3106 [(X86bt GR16:$src1, GR16:$src2),
3107 (implicit EFLAGS)]>, OpSize, TB;
3108 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3109 "bt{l}\t{$src2, $src1|$src1, $src2}",
3110 [(X86bt GR32:$src1, GR32:$src2),
3111 (implicit EFLAGS)]>, TB;
3113 // Unlike with the register+register form, the memory+register form of the
3114 // bt instruction does not ignore the high bits of the index. From ISel's
3115 // perspective, this is pretty bizarre. Disable these instructions for now.
3116 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3117 // "bt{w}\t{$src2, $src1|$src1, $src2}",
3118 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3119 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3120 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3121 // "bt{l}\t{$src2, $src1|$src1, $src2}",
3122 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3123 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
3125 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3126 "bt{w}\t{$src2, $src1|$src1, $src2}",
3127 [(X86bt GR16:$src1, i16immSExt8:$src2),
3128 (implicit EFLAGS)]>, OpSize, TB;
3129 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3130 "bt{l}\t{$src2, $src1|$src1, $src2}",
3131 [(X86bt GR32:$src1, i32immSExt8:$src2),
3132 (implicit EFLAGS)]>, TB;
3133 // Note that these instructions don't need FastBTMem because that
3134 // only applies when the other operand is in a register. When it's
3135 // an immediate, bt is still fast.
3136 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3137 "bt{w}\t{$src2, $src1|$src1, $src2}",
3138 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3139 (implicit EFLAGS)]>, OpSize, TB;
3140 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3141 "bt{l}\t{$src2, $src1|$src1, $src2}",
3142 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3143 (implicit EFLAGS)]>, TB;
3144 } // Defs = [EFLAGS]
3146 // Sign/Zero extenders
3147 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3148 // of the register here. This has a smaller encoding and avoids a
3149 // partial-register update.
3150 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3151 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3152 [(set GR16:$dst, (sext GR8:$src))]>, TB;
3153 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3154 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3155 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3156 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3157 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3158 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3159 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3160 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3161 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3162 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3163 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3164 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3165 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3166 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3167 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3169 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3170 // of the register here. This has a smaller encoding and avoids a
3171 // partial-register update.
3172 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3173 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3174 [(set GR16:$dst, (zext GR8:$src))]>, TB;
3175 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3176 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3177 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3178 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3179 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3180 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3181 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3182 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3183 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3184 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3185 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3186 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3187 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3188 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3189 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3191 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3192 // except that they use GR32_NOREX for the output operand register class
3193 // instead of GR32. This allows them to operate on h registers on x86-64.
3194 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3195 (outs GR32_NOREX:$dst), (ins GR8:$src),
3196 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3199 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3200 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3201 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3204 let neverHasSideEffects = 1 in {
3205 let Defs = [AX], Uses = [AL] in
3206 def CBW : I<0x98, RawFrm, (outs), (ins),
3207 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3208 let Defs = [EAX], Uses = [AX] in
3209 def CWDE : I<0x98, RawFrm, (outs), (ins),
3210 "{cwtl|cwde}", []>; // EAX = signext(AX)
3212 let Defs = [AX,DX], Uses = [AX] in
3213 def CWD : I<0x99, RawFrm, (outs), (ins),
3214 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3215 let Defs = [EAX,EDX], Uses = [EAX] in
3216 def CDQ : I<0x99, RawFrm, (outs), (ins),
3217 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3220 //===----------------------------------------------------------------------===//
3221 // Alias Instructions
3222 //===----------------------------------------------------------------------===//
3224 // Alias instructions that map movr0 to xor.
3225 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3226 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3227 isCodeGenOnly = 1 in {
3228 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
3229 "xor{b}\t$dst, $dst",
3230 [(set GR8:$dst, 0)]>;
3231 // Use xorl instead of xorw since we don't care about the high 16 bits,
3232 // it's smaller, and it avoids a partial-register update.
3233 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3234 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3235 [(set GR16:$dst, 0)]>;
3236 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3237 "xor{l}\t$dst, $dst",
3238 [(set GR32:$dst, 0)]>;
3241 //===----------------------------------------------------------------------===//
3242 // Thread Local Storage Instructions
3245 // All calls clobber the non-callee saved registers. ESP is marked as
3246 // a use to prevent stack-pointer assignments that appear immediately
3247 // before calls from potentially appearing dead.
3248 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3249 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3250 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3251 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3253 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3254 "leal\t$sym, %eax; "
3255 "call\t___tls_get_addr@PLT",
3256 [(X86tlsaddr tls32addr:$sym)]>,
3257 Requires<[In32BitMode]>;
3259 let AddedComplexity = 5, isCodeGenOnly = 1 in
3260 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3261 "movl\t%gs:$src, $dst",
3262 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3264 let AddedComplexity = 5, isCodeGenOnly = 1 in
3265 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3266 "movl\t%fs:$src, $dst",
3267 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3269 //===----------------------------------------------------------------------===//
3270 // DWARF Pseudo Instructions
3273 def DWARF_LOC : I<0, Pseudo, (outs),
3274 (ins i32imm:$line, i32imm:$col, i32imm:$file),
3275 ".loc\t$file $line $col",
3276 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3279 //===----------------------------------------------------------------------===//
3280 // EH Pseudo Instructions
3282 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3283 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3284 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3285 "ret\t#eh_return, addr: $addr",
3286 [(X86ehret GR32:$addr)]>;
3290 //===----------------------------------------------------------------------===//
3294 // Atomic swap. These are just normal xchg instructions. But since a memory
3295 // operand is referenced, the atomicity is ensured.
3296 let Constraints = "$val = $dst" in {
3297 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3298 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3299 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3300 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3301 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3302 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3304 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3305 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3306 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3309 // Atomic compare and swap.
3310 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3311 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3313 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3314 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3316 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3317 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3320 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3323 let Defs = [AX, EFLAGS], Uses = [AX] in {
3324 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3326 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3327 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3329 let Defs = [AL, EFLAGS], Uses = [AL] in {
3330 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3332 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3333 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3336 // Atomic exchange and add
3337 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3338 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3340 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3341 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3343 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3345 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3346 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3348 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3350 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3351 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3355 // Optimized codegen when the non-memory output is not used.
3356 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3357 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3359 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3360 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3362 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3363 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3365 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3366 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3368 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3369 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3371 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3372 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3374 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3375 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3377 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3378 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3380 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3382 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3384 "inc{b}\t$dst", []>, LOCK;
3385 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3387 "inc{w}\t$dst", []>, OpSize, LOCK;
3388 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3390 "inc{l}\t$dst", []>, LOCK;
3392 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3394 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3395 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3397 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3398 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3400 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3401 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3403 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3404 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3406 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3407 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3409 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3410 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3412 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3413 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3415 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3417 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3419 "dec{b}\t$dst", []>, LOCK;
3420 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3422 "dec{w}\t$dst", []>, OpSize, LOCK;
3423 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3425 "dec{l}\t$dst", []>, LOCK;
3427 // Atomic exchange, and, or, xor
3428 let Constraints = "$val = $dst", Defs = [EFLAGS],
3429 usesCustomDAGSchedInserter = 1 in {
3430 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3431 "#ATOMAND32 PSEUDO!",
3432 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3433 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3434 "#ATOMOR32 PSEUDO!",
3435 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3436 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3437 "#ATOMXOR32 PSEUDO!",
3438 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3439 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3440 "#ATOMNAND32 PSEUDO!",
3441 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3442 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3443 "#ATOMMIN32 PSEUDO!",
3444 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3445 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3446 "#ATOMMAX32 PSEUDO!",
3447 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3448 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3449 "#ATOMUMIN32 PSEUDO!",
3450 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3451 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3452 "#ATOMUMAX32 PSEUDO!",
3453 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3455 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3456 "#ATOMAND16 PSEUDO!",
3457 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3458 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3459 "#ATOMOR16 PSEUDO!",
3460 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3461 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3462 "#ATOMXOR16 PSEUDO!",
3463 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3464 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3465 "#ATOMNAND16 PSEUDO!",
3466 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3467 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3468 "#ATOMMIN16 PSEUDO!",
3469 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3470 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3471 "#ATOMMAX16 PSEUDO!",
3472 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3473 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3474 "#ATOMUMIN16 PSEUDO!",
3475 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3476 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3477 "#ATOMUMAX16 PSEUDO!",
3478 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3480 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3481 "#ATOMAND8 PSEUDO!",
3482 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3483 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3485 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3486 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3487 "#ATOMXOR8 PSEUDO!",
3488 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3489 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3490 "#ATOMNAND8 PSEUDO!",
3491 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3494 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3495 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3496 Uses = [EAX, EBX, ECX, EDX],
3497 mayLoad = 1, mayStore = 1,
3498 usesCustomDAGSchedInserter = 1 in {
3499 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3500 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3501 "#ATOMAND6432 PSEUDO!", []>;
3502 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3503 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3504 "#ATOMOR6432 PSEUDO!", []>;
3505 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3506 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3507 "#ATOMXOR6432 PSEUDO!", []>;
3508 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3509 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3510 "#ATOMNAND6432 PSEUDO!", []>;
3511 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3512 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3513 "#ATOMADD6432 PSEUDO!", []>;
3514 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3515 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3516 "#ATOMSUB6432 PSEUDO!", []>;
3517 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3518 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3519 "#ATOMSWAP6432 PSEUDO!", []>;
3522 //===----------------------------------------------------------------------===//
3523 // Non-Instruction Patterns
3524 //===----------------------------------------------------------------------===//
3526 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3527 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3528 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3529 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3530 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3531 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3533 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3534 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3535 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3536 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3537 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3538 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3539 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3540 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3542 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3543 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3544 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3545 (MOV32mi addr:$dst, texternalsym:$src)>;
3549 def : Pat<(X86tcret GR32:$dst, imm:$off),
3550 (TCRETURNri GR32:$dst, imm:$off)>;
3552 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3553 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3555 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3556 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3558 // Normal calls, with various flavors of addresses.
3559 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3560 (CALLpcrel32 tglobaladdr:$dst)>;
3561 def : Pat<(X86call (i32 texternalsym:$dst)),
3562 (CALLpcrel32 texternalsym:$dst)>;
3563 def : Pat<(X86call (i32 imm:$dst)),
3564 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
3566 // X86 specific add which produces a flag.
3567 def : Pat<(addc GR32:$src1, GR32:$src2),
3568 (ADD32rr GR32:$src1, GR32:$src2)>;
3569 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3570 (ADD32rm GR32:$src1, addr:$src2)>;
3571 def : Pat<(addc GR32:$src1, imm:$src2),
3572 (ADD32ri GR32:$src1, imm:$src2)>;
3573 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3574 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3576 def : Pat<(subc GR32:$src1, GR32:$src2),
3577 (SUB32rr GR32:$src1, GR32:$src2)>;
3578 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3579 (SUB32rm GR32:$src1, addr:$src2)>;
3580 def : Pat<(subc GR32:$src1, imm:$src2),
3581 (SUB32ri GR32:$src1, imm:$src2)>;
3582 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3583 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3587 // TEST R,R is smaller than CMP R,0
3588 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3589 (TEST8rr GR8:$src1, GR8:$src1)>;
3590 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3591 (TEST16rr GR16:$src1, GR16:$src1)>;
3592 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3593 (TEST32rr GR32:$src1, GR32:$src1)>;
3595 // Conditional moves with folded loads with operands swapped and conditions
3597 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3598 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3599 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3600 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3601 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3602 (CMOVB16rm GR16:$src2, addr:$src1)>;
3603 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3604 (CMOVB32rm GR32:$src2, addr:$src1)>;
3605 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3606 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3607 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3608 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3609 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3610 (CMOVE16rm GR16:$src2, addr:$src1)>;
3611 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3612 (CMOVE32rm GR32:$src2, addr:$src1)>;
3613 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3614 (CMOVA16rm GR16:$src2, addr:$src1)>;
3615 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3616 (CMOVA32rm GR32:$src2, addr:$src1)>;
3617 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3618 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3619 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3620 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3621 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3622 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3623 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3624 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3625 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3626 (CMOVL16rm GR16:$src2, addr:$src1)>;
3627 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3628 (CMOVL32rm GR32:$src2, addr:$src1)>;
3629 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3630 (CMOVG16rm GR16:$src2, addr:$src1)>;
3631 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3632 (CMOVG32rm GR32:$src2, addr:$src1)>;
3633 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3634 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3635 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3636 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3637 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3638 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3639 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3640 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3641 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3642 (CMOVP16rm GR16:$src2, addr:$src1)>;
3643 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3644 (CMOVP32rm GR32:$src2, addr:$src1)>;
3645 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3646 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3647 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3648 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3649 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3650 (CMOVS16rm GR16:$src2, addr:$src1)>;
3651 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3652 (CMOVS32rm GR32:$src2, addr:$src1)>;
3653 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3654 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3655 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3656 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3657 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3658 (CMOVO16rm GR16:$src2, addr:$src1)>;
3659 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3660 (CMOVO32rm GR32:$src2, addr:$src1)>;
3662 // zextload bool -> zextload byte
3663 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3664 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3665 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3667 // extload bool -> extload byte
3668 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3669 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3670 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3671 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
3672 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3673 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3675 // anyext. Define these to do an explicit zero-extend to
3676 // avoid partial-register updates.
3677 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3678 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3679 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
3681 // (and (i32 load), 255) -> (zextload i8)
3682 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3683 (MOVZX32rm8 addr:$src)>;
3684 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3685 (MOVZX32rm16 addr:$src)>;
3687 //===----------------------------------------------------------------------===//
3689 //===----------------------------------------------------------------------===//
3691 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3692 // +128 doesn't, so in this special case use a sub instead of an add.
3693 def : Pat<(add GR16:$src1, 128),
3694 (SUB16ri8 GR16:$src1, -128)>;
3695 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3696 (SUB16mi8 addr:$dst, -128)>;
3697 def : Pat<(add GR32:$src1, 128),
3698 (SUB32ri8 GR32:$src1, -128)>;
3699 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3700 (SUB32mi8 addr:$dst, -128)>;
3702 // r & (2^16-1) ==> movz
3703 def : Pat<(and GR32:$src1, 0xffff),
3704 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
3705 // r & (2^8-1) ==> movz
3706 def : Pat<(and GR32:$src1, 0xff),
3707 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
3709 Requires<[In32BitMode]>;
3710 // r & (2^8-1) ==> movz
3711 def : Pat<(and GR16:$src1, 0xff),
3712 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
3714 Requires<[In32BitMode]>;
3716 // sext_inreg patterns
3717 def : Pat<(sext_inreg GR32:$src, i16),
3718 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3719 def : Pat<(sext_inreg GR32:$src, i8),
3720 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3722 Requires<[In32BitMode]>;
3723 def : Pat<(sext_inreg GR16:$src, i8),
3724 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3726 Requires<[In32BitMode]>;
3729 def : Pat<(i16 (trunc GR32:$src)),
3730 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
3731 def : Pat<(i8 (trunc GR32:$src)),
3732 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3734 Requires<[In32BitMode]>;
3735 def : Pat<(i8 (trunc GR16:$src)),
3736 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3738 Requires<[In32BitMode]>;
3740 // h-register tricks
3741 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
3742 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3743 x86_subreg_8bit_hi)>,
3744 Requires<[In32BitMode]>;
3745 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
3746 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3747 x86_subreg_8bit_hi)>,
3748 Requires<[In32BitMode]>;
3749 def : Pat<(srl_su GR16:$src, (i8 8)),
3752 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3753 x86_subreg_8bit_hi)),
3755 Requires<[In32BitMode]>;
3756 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3757 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3758 x86_subreg_8bit_hi))>,
3759 Requires<[In32BitMode]>;
3760 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3761 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3762 x86_subreg_8bit_hi))>,
3763 Requires<[In32BitMode]>;
3764 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
3765 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3766 x86_subreg_8bit_hi))>,
3767 Requires<[In32BitMode]>;
3769 // (shl x, 1) ==> (add x, x)
3770 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3771 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3772 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3774 // (shl x (and y, 31)) ==> (shl x, y)
3775 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3776 (SHL8rCL GR8:$src1)>;
3777 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3778 (SHL16rCL GR16:$src1)>;
3779 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3780 (SHL32rCL GR32:$src1)>;
3781 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3782 (SHL8mCL addr:$dst)>;
3783 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3784 (SHL16mCL addr:$dst)>;
3785 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3786 (SHL32mCL addr:$dst)>;
3788 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3789 (SHR8rCL GR8:$src1)>;
3790 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3791 (SHR16rCL GR16:$src1)>;
3792 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3793 (SHR32rCL GR32:$src1)>;
3794 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3795 (SHR8mCL addr:$dst)>;
3796 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3797 (SHR16mCL addr:$dst)>;
3798 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3799 (SHR32mCL addr:$dst)>;
3801 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3802 (SAR8rCL GR8:$src1)>;
3803 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3804 (SAR16rCL GR16:$src1)>;
3805 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3806 (SAR32rCL GR32:$src1)>;
3807 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3808 (SAR8mCL addr:$dst)>;
3809 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3810 (SAR16mCL addr:$dst)>;
3811 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3812 (SAR32mCL addr:$dst)>;
3814 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3815 def : Pat<(or (srl GR32:$src1, CL:$amt),
3816 (shl GR32:$src2, (sub 32, CL:$amt))),
3817 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3819 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3820 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3821 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3823 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3824 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3825 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3827 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3828 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3830 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3832 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3833 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3835 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3836 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3837 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3839 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3840 def : Pat<(or (shl GR32:$src1, CL:$amt),
3841 (srl GR32:$src2, (sub 32, CL:$amt))),
3842 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3844 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3845 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3846 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3848 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3849 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3850 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3852 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3853 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3855 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3857 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3858 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3860 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3861 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3862 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3864 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3865 def : Pat<(or (srl GR16:$src1, CL:$amt),
3866 (shl GR16:$src2, (sub 16, CL:$amt))),
3867 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3869 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3870 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3871 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3873 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3874 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3875 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3877 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3878 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3880 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3882 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3883 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3885 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3886 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3887 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3889 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3890 def : Pat<(or (shl GR16:$src1, CL:$amt),
3891 (srl GR16:$src2, (sub 16, CL:$amt))),
3892 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3894 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3895 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3896 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3898 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3899 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3900 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3902 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3903 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3905 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3907 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3908 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3910 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3911 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3912 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3914 //===----------------------------------------------------------------------===//
3915 // EFLAGS-defining Patterns
3916 //===----------------------------------------------------------------------===//
3918 // Register-Register Addition with EFLAGS result
3919 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
3921 (ADD8rr GR8:$src1, GR8:$src2)>;
3922 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
3924 (ADD16rr GR16:$src1, GR16:$src2)>;
3925 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
3927 (ADD32rr GR32:$src1, GR32:$src2)>;
3929 // Register-Memory Addition with EFLAGS result
3930 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
3932 (ADD8rm GR8:$src1, addr:$src2)>;
3933 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
3935 (ADD16rm GR16:$src1, addr:$src2)>;
3936 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
3938 (ADD32rm GR32:$src1, addr:$src2)>;
3940 // Register-Integer Addition with EFLAGS result
3941 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
3943 (ADD8ri GR8:$src1, imm:$src2)>;
3944 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
3946 (ADD16ri GR16:$src1, imm:$src2)>;
3947 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
3949 (ADD32ri GR32:$src1, imm:$src2)>;
3950 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
3952 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3953 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
3955 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3957 // Memory-Register Addition with EFLAGS result
3958 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
3961 (ADD8mr addr:$dst, GR8:$src2)>;
3962 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
3965 (ADD16mr addr:$dst, GR16:$src2)>;
3966 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
3969 (ADD32mr addr:$dst, GR32:$src2)>;
3971 // Memory-Integer Addition with EFLAGS result
3972 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
3975 (ADD8mi addr:$dst, imm:$src2)>;
3976 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
3979 (ADD16mi addr:$dst, imm:$src2)>;
3980 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
3983 (ADD32mi addr:$dst, imm:$src2)>;
3984 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3987 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3988 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3991 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3993 // Register-Register Subtraction with EFLAGS result
3994 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
3996 (SUB8rr GR8:$src1, GR8:$src2)>;
3997 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
3999 (SUB16rr GR16:$src1, GR16:$src2)>;
4000 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
4002 (SUB32rr GR32:$src1, GR32:$src2)>;
4004 // Register-Memory Subtraction with EFLAGS result
4005 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
4007 (SUB8rm GR8:$src1, addr:$src2)>;
4008 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
4010 (SUB16rm GR16:$src1, addr:$src2)>;
4011 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
4013 (SUB32rm GR32:$src1, addr:$src2)>;
4015 // Register-Integer Subtraction with EFLAGS result
4016 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
4018 (SUB8ri GR8:$src1, imm:$src2)>;
4019 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
4021 (SUB16ri GR16:$src1, imm:$src2)>;
4022 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
4024 (SUB32ri GR32:$src1, imm:$src2)>;
4025 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
4027 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4028 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
4030 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4032 // Memory-Register Subtraction with EFLAGS result
4033 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
4036 (SUB8mr addr:$dst, GR8:$src2)>;
4037 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
4040 (SUB16mr addr:$dst, GR16:$src2)>;
4041 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
4044 (SUB32mr addr:$dst, GR32:$src2)>;
4046 // Memory-Integer Subtraction with EFLAGS result
4047 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
4050 (SUB8mi addr:$dst, imm:$src2)>;
4051 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
4054 (SUB16mi addr:$dst, imm:$src2)>;
4055 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
4058 (SUB32mi addr:$dst, imm:$src2)>;
4059 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4062 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
4063 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4066 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4069 // Register-Register Signed Integer Multiply with EFLAGS result
4070 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
4072 (IMUL16rr GR16:$src1, GR16:$src2)>;
4073 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
4075 (IMUL32rr GR32:$src1, GR32:$src2)>;
4077 // Register-Memory Signed Integer Multiply with EFLAGS result
4078 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
4080 (IMUL16rm GR16:$src1, addr:$src2)>;
4081 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
4083 (IMUL32rm GR32:$src1, addr:$src2)>;
4085 // Register-Integer Signed Integer Multiply with EFLAGS result
4086 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
4088 (IMUL16rri GR16:$src1, imm:$src2)>;
4089 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
4091 (IMUL32rri GR32:$src1, imm:$src2)>;
4092 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
4094 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4095 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
4097 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4099 // Memory-Integer Signed Integer Multiply with EFLAGS result
4100 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
4102 (IMUL16rmi addr:$src1, imm:$src2)>;
4103 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
4105 (IMUL32rmi addr:$src1, imm:$src2)>;
4106 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
4108 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4109 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
4111 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4113 // Optimize multiply by 2 with EFLAGS result.
4114 let AddedComplexity = 2 in {
4115 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
4117 (ADD16rr GR16:$src1, GR16:$src1)>;
4119 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
4121 (ADD32rr GR32:$src1, GR32:$src1)>;
4124 // INC and DEC with EFLAGS result. Note that these do not set CF.
4125 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4127 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4130 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4132 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4136 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
4137 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4138 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4140 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
4141 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
4142 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4143 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4145 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
4147 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
4148 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4149 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4151 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
4152 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
4153 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4154 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4156 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
4158 //===----------------------------------------------------------------------===//
4159 // Floating Point Stack Support
4160 //===----------------------------------------------------------------------===//
4162 include "X86InstrFPStack.td"
4164 //===----------------------------------------------------------------------===//
4166 //===----------------------------------------------------------------------===//
4168 include "X86Instr64bit.td"
4170 //===----------------------------------------------------------------------===//
4171 // XMM Floating point support (requires SSE / SSE2)
4172 //===----------------------------------------------------------------------===//
4174 include "X86InstrSSE.td"
4176 //===----------------------------------------------------------------------===//
4177 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4178 //===----------------------------------------------------------------------===//
4180 include "X86InstrMMX.td"