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 {
1037 let isCommutable = 1 in {
1038 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1039 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1040 "cmovb\t{$src2, $dst|$dst, $src2}",
1041 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1042 X86_COND_B, EFLAGS))]>,
1044 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1045 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1046 "cmovb\t{$src2, $dst|$dst, $src2}",
1047 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1048 X86_COND_B, EFLAGS))]>,
1050 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1051 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1052 "cmovae\t{$src2, $dst|$dst, $src2}",
1053 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1054 X86_COND_AE, EFLAGS))]>,
1056 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1057 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1058 "cmovae\t{$src2, $dst|$dst, $src2}",
1059 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1060 X86_COND_AE, EFLAGS))]>,
1062 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1063 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1064 "cmove\t{$src2, $dst|$dst, $src2}",
1065 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1066 X86_COND_E, EFLAGS))]>,
1068 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1069 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1070 "cmove\t{$src2, $dst|$dst, $src2}",
1071 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1072 X86_COND_E, EFLAGS))]>,
1074 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1075 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1076 "cmovne\t{$src2, $dst|$dst, $src2}",
1077 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1078 X86_COND_NE, EFLAGS))]>,
1080 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1081 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1082 "cmovne\t{$src2, $dst|$dst, $src2}",
1083 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1084 X86_COND_NE, EFLAGS))]>,
1086 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1087 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1088 "cmovbe\t{$src2, $dst|$dst, $src2}",
1089 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1090 X86_COND_BE, EFLAGS))]>,
1092 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1093 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1094 "cmovbe\t{$src2, $dst|$dst, $src2}",
1095 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1096 X86_COND_BE, EFLAGS))]>,
1098 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1099 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1100 "cmova\t{$src2, $dst|$dst, $src2}",
1101 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1102 X86_COND_A, EFLAGS))]>,
1104 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1105 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1106 "cmova\t{$src2, $dst|$dst, $src2}",
1107 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1108 X86_COND_A, EFLAGS))]>,
1110 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1111 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1112 "cmovl\t{$src2, $dst|$dst, $src2}",
1113 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1114 X86_COND_L, EFLAGS))]>,
1116 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1117 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1118 "cmovl\t{$src2, $dst|$dst, $src2}",
1119 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1120 X86_COND_L, EFLAGS))]>,
1122 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1123 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1124 "cmovge\t{$src2, $dst|$dst, $src2}",
1125 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1126 X86_COND_GE, EFLAGS))]>,
1128 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1129 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1130 "cmovge\t{$src2, $dst|$dst, $src2}",
1131 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1132 X86_COND_GE, EFLAGS))]>,
1134 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1135 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1136 "cmovle\t{$src2, $dst|$dst, $src2}",
1137 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1138 X86_COND_LE, EFLAGS))]>,
1140 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1141 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1142 "cmovle\t{$src2, $dst|$dst, $src2}",
1143 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1144 X86_COND_LE, EFLAGS))]>,
1146 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1147 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1148 "cmovg\t{$src2, $dst|$dst, $src2}",
1149 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1150 X86_COND_G, EFLAGS))]>,
1152 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1153 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1154 "cmovg\t{$src2, $dst|$dst, $src2}",
1155 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1156 X86_COND_G, EFLAGS))]>,
1158 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1159 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1160 "cmovs\t{$src2, $dst|$dst, $src2}",
1161 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1162 X86_COND_S, EFLAGS))]>,
1164 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1165 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1166 "cmovs\t{$src2, $dst|$dst, $src2}",
1167 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1168 X86_COND_S, EFLAGS))]>,
1170 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1171 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1172 "cmovns\t{$src2, $dst|$dst, $src2}",
1173 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1174 X86_COND_NS, EFLAGS))]>,
1176 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1177 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1178 "cmovns\t{$src2, $dst|$dst, $src2}",
1179 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1180 X86_COND_NS, EFLAGS))]>,
1182 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1183 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1184 "cmovp\t{$src2, $dst|$dst, $src2}",
1185 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1186 X86_COND_P, EFLAGS))]>,
1188 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1189 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1190 "cmovp\t{$src2, $dst|$dst, $src2}",
1191 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1192 X86_COND_P, EFLAGS))]>,
1194 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1195 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1196 "cmovnp\t{$src2, $dst|$dst, $src2}",
1197 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1198 X86_COND_NP, EFLAGS))]>,
1200 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1201 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1202 "cmovnp\t{$src2, $dst|$dst, $src2}",
1203 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1204 X86_COND_NP, EFLAGS))]>,
1206 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1207 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1208 "cmovo\t{$src2, $dst|$dst, $src2}",
1209 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1210 X86_COND_O, EFLAGS))]>,
1212 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1213 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1214 "cmovo\t{$src2, $dst|$dst, $src2}",
1215 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1216 X86_COND_O, EFLAGS))]>,
1218 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1219 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1220 "cmovno\t{$src2, $dst|$dst, $src2}",
1221 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1222 X86_COND_NO, EFLAGS))]>,
1224 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1225 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1226 "cmovno\t{$src2, $dst|$dst, $src2}",
1227 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1228 X86_COND_NO, EFLAGS))]>,
1230 } // isCommutable = 1
1232 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1233 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1234 "cmovb\t{$src2, $dst|$dst, $src2}",
1235 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1236 X86_COND_B, EFLAGS))]>,
1238 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1239 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1240 "cmovb\t{$src2, $dst|$dst, $src2}",
1241 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1242 X86_COND_B, EFLAGS))]>,
1244 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1245 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1246 "cmovae\t{$src2, $dst|$dst, $src2}",
1247 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1248 X86_COND_AE, EFLAGS))]>,
1250 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1251 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1252 "cmovae\t{$src2, $dst|$dst, $src2}",
1253 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1254 X86_COND_AE, EFLAGS))]>,
1256 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1257 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1258 "cmove\t{$src2, $dst|$dst, $src2}",
1259 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1260 X86_COND_E, EFLAGS))]>,
1262 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1263 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1264 "cmove\t{$src2, $dst|$dst, $src2}",
1265 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1266 X86_COND_E, EFLAGS))]>,
1268 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1269 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1270 "cmovne\t{$src2, $dst|$dst, $src2}",
1271 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1272 X86_COND_NE, EFLAGS))]>,
1274 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1275 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1276 "cmovne\t{$src2, $dst|$dst, $src2}",
1277 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1278 X86_COND_NE, EFLAGS))]>,
1280 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1281 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1282 "cmovbe\t{$src2, $dst|$dst, $src2}",
1283 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1284 X86_COND_BE, EFLAGS))]>,
1286 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1287 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1288 "cmovbe\t{$src2, $dst|$dst, $src2}",
1289 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1290 X86_COND_BE, EFLAGS))]>,
1292 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1293 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1294 "cmova\t{$src2, $dst|$dst, $src2}",
1295 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1296 X86_COND_A, EFLAGS))]>,
1298 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1299 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1300 "cmova\t{$src2, $dst|$dst, $src2}",
1301 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1302 X86_COND_A, EFLAGS))]>,
1304 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1305 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1306 "cmovl\t{$src2, $dst|$dst, $src2}",
1307 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1308 X86_COND_L, EFLAGS))]>,
1310 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1311 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1312 "cmovl\t{$src2, $dst|$dst, $src2}",
1313 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1314 X86_COND_L, EFLAGS))]>,
1316 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1317 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1318 "cmovge\t{$src2, $dst|$dst, $src2}",
1319 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1320 X86_COND_GE, EFLAGS))]>,
1322 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1323 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1324 "cmovge\t{$src2, $dst|$dst, $src2}",
1325 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1326 X86_COND_GE, EFLAGS))]>,
1328 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1329 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1330 "cmovle\t{$src2, $dst|$dst, $src2}",
1331 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1332 X86_COND_LE, EFLAGS))]>,
1334 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1335 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1336 "cmovle\t{$src2, $dst|$dst, $src2}",
1337 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1338 X86_COND_LE, EFLAGS))]>,
1340 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1341 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1342 "cmovg\t{$src2, $dst|$dst, $src2}",
1343 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1344 X86_COND_G, EFLAGS))]>,
1346 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1347 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1348 "cmovg\t{$src2, $dst|$dst, $src2}",
1349 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1350 X86_COND_G, EFLAGS))]>,
1352 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1353 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1354 "cmovs\t{$src2, $dst|$dst, $src2}",
1355 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1356 X86_COND_S, EFLAGS))]>,
1358 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1359 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1360 "cmovs\t{$src2, $dst|$dst, $src2}",
1361 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1362 X86_COND_S, EFLAGS))]>,
1364 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1365 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1366 "cmovns\t{$src2, $dst|$dst, $src2}",
1367 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1368 X86_COND_NS, EFLAGS))]>,
1370 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1371 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1372 "cmovns\t{$src2, $dst|$dst, $src2}",
1373 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1374 X86_COND_NS, EFLAGS))]>,
1376 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1377 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1378 "cmovp\t{$src2, $dst|$dst, $src2}",
1379 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1380 X86_COND_P, EFLAGS))]>,
1382 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1383 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1384 "cmovp\t{$src2, $dst|$dst, $src2}",
1385 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1386 X86_COND_P, EFLAGS))]>,
1388 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1389 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1390 "cmovnp\t{$src2, $dst|$dst, $src2}",
1391 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1392 X86_COND_NP, EFLAGS))]>,
1394 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1395 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1396 "cmovnp\t{$src2, $dst|$dst, $src2}",
1397 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1398 X86_COND_NP, EFLAGS))]>,
1400 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1401 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1402 "cmovo\t{$src2, $dst|$dst, $src2}",
1403 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1404 X86_COND_O, EFLAGS))]>,
1406 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1407 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1408 "cmovo\t{$src2, $dst|$dst, $src2}",
1409 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1410 X86_COND_O, EFLAGS))]>,
1412 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1413 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1414 "cmovno\t{$src2, $dst|$dst, $src2}",
1415 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1416 X86_COND_NO, EFLAGS))]>,
1418 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1419 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1420 "cmovno\t{$src2, $dst|$dst, $src2}",
1421 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1422 X86_COND_NO, EFLAGS))]>,
1424 } // Uses = [EFLAGS]
1427 // unary instructions
1428 let CodeSize = 2 in {
1429 let Defs = [EFLAGS] in {
1430 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1431 [(set GR8:$dst, (ineg GR8:$src)),
1432 (implicit EFLAGS)]>;
1433 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1434 [(set GR16:$dst, (ineg GR16:$src)),
1435 (implicit EFLAGS)]>, OpSize;
1436 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1437 [(set GR32:$dst, (ineg GR32:$src)),
1438 (implicit EFLAGS)]>;
1439 let isTwoAddress = 0 in {
1440 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1441 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1442 (implicit EFLAGS)]>;
1443 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1444 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1445 (implicit EFLAGS)]>, OpSize;
1446 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1447 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1448 (implicit EFLAGS)]>;
1450 } // Defs = [EFLAGS]
1452 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1453 let AddedComplexity = 15 in {
1454 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1455 [(set GR8:$dst, (not GR8:$src))]>;
1456 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1457 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1458 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1459 [(set GR32:$dst, (not GR32:$src))]>;
1461 let isTwoAddress = 0 in {
1462 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1463 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1464 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1465 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1466 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1467 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1471 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1472 let Defs = [EFLAGS] in {
1474 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1475 [(set GR8:$dst, (add GR8:$src, 1)),
1476 (implicit EFLAGS)]>;
1477 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1478 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1479 [(set GR16:$dst, (add GR16:$src, 1)),
1480 (implicit EFLAGS)]>,
1481 OpSize, Requires<[In32BitMode]>;
1482 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1483 [(set GR32:$dst, (add GR32:$src, 1)),
1484 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1486 let isTwoAddress = 0, CodeSize = 2 in {
1487 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1488 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1489 (implicit EFLAGS)]>;
1490 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1491 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1492 (implicit EFLAGS)]>,
1493 OpSize, Requires<[In32BitMode]>;
1494 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1495 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1496 (implicit EFLAGS)]>,
1497 Requires<[In32BitMode]>;
1501 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1502 [(set GR8:$dst, (add GR8:$src, -1)),
1503 (implicit EFLAGS)]>;
1504 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1505 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1506 [(set GR16:$dst, (add GR16:$src, -1)),
1507 (implicit EFLAGS)]>,
1508 OpSize, Requires<[In32BitMode]>;
1509 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1510 [(set GR32:$dst, (add GR32:$src, -1)),
1511 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1514 let isTwoAddress = 0, CodeSize = 2 in {
1515 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1516 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1517 (implicit EFLAGS)]>;
1518 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1519 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1520 (implicit EFLAGS)]>,
1521 OpSize, Requires<[In32BitMode]>;
1522 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1523 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1524 (implicit EFLAGS)]>,
1525 Requires<[In32BitMode]>;
1527 } // Defs = [EFLAGS]
1529 // Logical operators...
1530 let Defs = [EFLAGS] in {
1531 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1532 def AND8rr : I<0x20, MRMDestReg,
1533 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1534 "and{b}\t{$src2, $dst|$dst, $src2}",
1535 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1536 (implicit EFLAGS)]>;
1537 def AND16rr : I<0x21, MRMDestReg,
1538 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1539 "and{w}\t{$src2, $dst|$dst, $src2}",
1540 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1541 (implicit EFLAGS)]>, OpSize;
1542 def AND32rr : I<0x21, MRMDestReg,
1543 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1544 "and{l}\t{$src2, $dst|$dst, $src2}",
1545 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1546 (implicit EFLAGS)]>;
1549 def AND8rm : I<0x22, MRMSrcMem,
1550 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1551 "and{b}\t{$src2, $dst|$dst, $src2}",
1552 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1553 (implicit EFLAGS)]>;
1554 def AND16rm : I<0x23, MRMSrcMem,
1555 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1556 "and{w}\t{$src2, $dst|$dst, $src2}",
1557 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1558 (implicit EFLAGS)]>, OpSize;
1559 def AND32rm : I<0x23, MRMSrcMem,
1560 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1561 "and{l}\t{$src2, $dst|$dst, $src2}",
1562 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1563 (implicit EFLAGS)]>;
1565 def AND8ri : Ii8<0x80, MRM4r,
1566 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1567 "and{b}\t{$src2, $dst|$dst, $src2}",
1568 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1569 (implicit EFLAGS)]>;
1570 def AND16ri : Ii16<0x81, MRM4r,
1571 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1572 "and{w}\t{$src2, $dst|$dst, $src2}",
1573 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1574 (implicit EFLAGS)]>, OpSize;
1575 def AND32ri : Ii32<0x81, MRM4r,
1576 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1577 "and{l}\t{$src2, $dst|$dst, $src2}",
1578 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1579 (implicit EFLAGS)]>;
1580 def AND16ri8 : Ii8<0x83, MRM4r,
1581 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1582 "and{w}\t{$src2, $dst|$dst, $src2}",
1583 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1584 (implicit EFLAGS)]>,
1586 def AND32ri8 : Ii8<0x83, MRM4r,
1587 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1588 "and{l}\t{$src2, $dst|$dst, $src2}",
1589 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1590 (implicit EFLAGS)]>;
1592 let isTwoAddress = 0 in {
1593 def AND8mr : I<0x20, MRMDestMem,
1594 (outs), (ins i8mem :$dst, GR8 :$src),
1595 "and{b}\t{$src, $dst|$dst, $src}",
1596 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1597 (implicit EFLAGS)]>;
1598 def AND16mr : I<0x21, MRMDestMem,
1599 (outs), (ins i16mem:$dst, GR16:$src),
1600 "and{w}\t{$src, $dst|$dst, $src}",
1601 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1602 (implicit EFLAGS)]>,
1604 def AND32mr : I<0x21, MRMDestMem,
1605 (outs), (ins i32mem:$dst, GR32:$src),
1606 "and{l}\t{$src, $dst|$dst, $src}",
1607 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1608 (implicit EFLAGS)]>;
1609 def AND8mi : Ii8<0x80, MRM4m,
1610 (outs), (ins i8mem :$dst, i8imm :$src),
1611 "and{b}\t{$src, $dst|$dst, $src}",
1612 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1613 (implicit EFLAGS)]>;
1614 def AND16mi : Ii16<0x81, MRM4m,
1615 (outs), (ins i16mem:$dst, i16imm:$src),
1616 "and{w}\t{$src, $dst|$dst, $src}",
1617 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1618 (implicit EFLAGS)]>,
1620 def AND32mi : Ii32<0x81, MRM4m,
1621 (outs), (ins i32mem:$dst, i32imm:$src),
1622 "and{l}\t{$src, $dst|$dst, $src}",
1623 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1624 (implicit EFLAGS)]>;
1625 def AND16mi8 : Ii8<0x83, MRM4m,
1626 (outs), (ins i16mem:$dst, i16i8imm :$src),
1627 "and{w}\t{$src, $dst|$dst, $src}",
1628 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1629 (implicit EFLAGS)]>,
1631 def AND32mi8 : Ii8<0x83, MRM4m,
1632 (outs), (ins i32mem:$dst, i32i8imm :$src),
1633 "and{l}\t{$src, $dst|$dst, $src}",
1634 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1635 (implicit EFLAGS)]>;
1639 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1640 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1641 "or{b}\t{$src2, $dst|$dst, $src2}",
1642 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1643 (implicit EFLAGS)]>;
1644 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1645 "or{w}\t{$src2, $dst|$dst, $src2}",
1646 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1647 (implicit EFLAGS)]>, OpSize;
1648 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1649 "or{l}\t{$src2, $dst|$dst, $src2}",
1650 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1651 (implicit EFLAGS)]>;
1653 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1654 "or{b}\t{$src2, $dst|$dst, $src2}",
1655 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1656 (implicit EFLAGS)]>;
1657 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1658 "or{w}\t{$src2, $dst|$dst, $src2}",
1659 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1660 (implicit EFLAGS)]>, OpSize;
1661 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1662 "or{l}\t{$src2, $dst|$dst, $src2}",
1663 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1664 (implicit EFLAGS)]>;
1666 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1667 "or{b}\t{$src2, $dst|$dst, $src2}",
1668 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1669 (implicit EFLAGS)]>;
1670 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1671 "or{w}\t{$src2, $dst|$dst, $src2}",
1672 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1673 (implicit EFLAGS)]>, OpSize;
1674 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1675 "or{l}\t{$src2, $dst|$dst, $src2}",
1676 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1677 (implicit EFLAGS)]>;
1679 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1680 "or{w}\t{$src2, $dst|$dst, $src2}",
1681 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1682 (implicit EFLAGS)]>, OpSize;
1683 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1684 "or{l}\t{$src2, $dst|$dst, $src2}",
1685 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1686 (implicit EFLAGS)]>;
1687 let isTwoAddress = 0 in {
1688 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1689 "or{b}\t{$src, $dst|$dst, $src}",
1690 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1691 (implicit EFLAGS)]>;
1692 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1693 "or{w}\t{$src, $dst|$dst, $src}",
1694 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1695 (implicit EFLAGS)]>, OpSize;
1696 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1697 "or{l}\t{$src, $dst|$dst, $src}",
1698 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1699 (implicit EFLAGS)]>;
1700 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1701 "or{b}\t{$src, $dst|$dst, $src}",
1702 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1703 (implicit EFLAGS)]>;
1704 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1705 "or{w}\t{$src, $dst|$dst, $src}",
1706 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1707 (implicit EFLAGS)]>,
1709 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1710 "or{l}\t{$src, $dst|$dst, $src}",
1711 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1712 (implicit EFLAGS)]>;
1713 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1714 "or{w}\t{$src, $dst|$dst, $src}",
1715 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1716 (implicit EFLAGS)]>,
1718 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1719 "or{l}\t{$src, $dst|$dst, $src}",
1720 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1721 (implicit EFLAGS)]>;
1722 } // isTwoAddress = 0
1725 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1726 def XOR8rr : I<0x30, MRMDestReg,
1727 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1728 "xor{b}\t{$src2, $dst|$dst, $src2}",
1729 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1730 (implicit EFLAGS)]>;
1731 def XOR16rr : I<0x31, MRMDestReg,
1732 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1733 "xor{w}\t{$src2, $dst|$dst, $src2}",
1734 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1735 (implicit EFLAGS)]>, OpSize;
1736 def XOR32rr : I<0x31, MRMDestReg,
1737 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1738 "xor{l}\t{$src2, $dst|$dst, $src2}",
1739 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1740 (implicit EFLAGS)]>;
1741 } // isCommutable = 1
1743 def XOR8rm : I<0x32, MRMSrcMem ,
1744 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1745 "xor{b}\t{$src2, $dst|$dst, $src2}",
1746 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1747 (implicit EFLAGS)]>;
1748 def XOR16rm : I<0x33, MRMSrcMem ,
1749 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1750 "xor{w}\t{$src2, $dst|$dst, $src2}",
1751 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1752 (implicit EFLAGS)]>,
1754 def XOR32rm : I<0x33, MRMSrcMem ,
1755 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1756 "xor{l}\t{$src2, $dst|$dst, $src2}",
1757 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1758 (implicit EFLAGS)]>;
1760 def XOR8ri : Ii8<0x80, MRM6r,
1761 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1762 "xor{b}\t{$src2, $dst|$dst, $src2}",
1763 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1764 (implicit EFLAGS)]>;
1765 def XOR16ri : Ii16<0x81, MRM6r,
1766 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1767 "xor{w}\t{$src2, $dst|$dst, $src2}",
1768 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1769 (implicit EFLAGS)]>, OpSize;
1770 def XOR32ri : Ii32<0x81, MRM6r,
1771 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1772 "xor{l}\t{$src2, $dst|$dst, $src2}",
1773 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1774 (implicit EFLAGS)]>;
1775 def XOR16ri8 : Ii8<0x83, MRM6r,
1776 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1777 "xor{w}\t{$src2, $dst|$dst, $src2}",
1778 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1779 (implicit EFLAGS)]>,
1781 def XOR32ri8 : Ii8<0x83, MRM6r,
1782 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1783 "xor{l}\t{$src2, $dst|$dst, $src2}",
1784 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1785 (implicit EFLAGS)]>;
1787 let isTwoAddress = 0 in {
1788 def XOR8mr : I<0x30, MRMDestMem,
1789 (outs), (ins i8mem :$dst, GR8 :$src),
1790 "xor{b}\t{$src, $dst|$dst, $src}",
1791 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1792 (implicit EFLAGS)]>;
1793 def XOR16mr : I<0x31, MRMDestMem,
1794 (outs), (ins i16mem:$dst, GR16:$src),
1795 "xor{w}\t{$src, $dst|$dst, $src}",
1796 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1797 (implicit EFLAGS)]>,
1799 def XOR32mr : I<0x31, MRMDestMem,
1800 (outs), (ins i32mem:$dst, GR32:$src),
1801 "xor{l}\t{$src, $dst|$dst, $src}",
1802 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1803 (implicit EFLAGS)]>;
1804 def XOR8mi : Ii8<0x80, MRM6m,
1805 (outs), (ins i8mem :$dst, i8imm :$src),
1806 "xor{b}\t{$src, $dst|$dst, $src}",
1807 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1808 (implicit EFLAGS)]>;
1809 def XOR16mi : Ii16<0x81, MRM6m,
1810 (outs), (ins i16mem:$dst, i16imm:$src),
1811 "xor{w}\t{$src, $dst|$dst, $src}",
1812 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1813 (implicit EFLAGS)]>,
1815 def XOR32mi : Ii32<0x81, MRM6m,
1816 (outs), (ins i32mem:$dst, i32imm:$src),
1817 "xor{l}\t{$src, $dst|$dst, $src}",
1818 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1819 (implicit EFLAGS)]>;
1820 def XOR16mi8 : Ii8<0x83, MRM6m,
1821 (outs), (ins i16mem:$dst, i16i8imm :$src),
1822 "xor{w}\t{$src, $dst|$dst, $src}",
1823 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1824 (implicit EFLAGS)]>,
1826 def XOR32mi8 : Ii8<0x83, MRM6m,
1827 (outs), (ins i32mem:$dst, i32i8imm :$src),
1828 "xor{l}\t{$src, $dst|$dst, $src}",
1829 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1830 (implicit EFLAGS)]>;
1831 } // isTwoAddress = 0
1832 } // Defs = [EFLAGS]
1834 // Shift instructions
1835 let Defs = [EFLAGS] in {
1836 let Uses = [CL] in {
1837 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1838 "shl{b}\t{%cl, $dst|$dst, CL}",
1839 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1840 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1841 "shl{w}\t{%cl, $dst|$dst, CL}",
1842 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1843 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1844 "shl{l}\t{%cl, $dst|$dst, CL}",
1845 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1848 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1849 "shl{b}\t{$src2, $dst|$dst, $src2}",
1850 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1851 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1852 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1853 "shl{w}\t{$src2, $dst|$dst, $src2}",
1854 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1855 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1856 "shl{l}\t{$src2, $dst|$dst, $src2}",
1857 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1858 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1860 } // isConvertibleToThreeAddress = 1
1862 let isTwoAddress = 0 in {
1863 let Uses = [CL] in {
1864 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1865 "shl{b}\t{%cl, $dst|$dst, CL}",
1866 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1867 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1868 "shl{w}\t{%cl, $dst|$dst, CL}",
1869 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1870 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1871 "shl{l}\t{%cl, $dst|$dst, CL}",
1872 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1874 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1875 "shl{b}\t{$src, $dst|$dst, $src}",
1876 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1877 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1878 "shl{w}\t{$src, $dst|$dst, $src}",
1879 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1881 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1882 "shl{l}\t{$src, $dst|$dst, $src}",
1883 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1886 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1888 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1889 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1891 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1893 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1895 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1898 let Uses = [CL] in {
1899 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1900 "shr{b}\t{%cl, $dst|$dst, CL}",
1901 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1902 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1903 "shr{w}\t{%cl, $dst|$dst, CL}",
1904 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1905 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1906 "shr{l}\t{%cl, $dst|$dst, CL}",
1907 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1910 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1911 "shr{b}\t{$src2, $dst|$dst, $src2}",
1912 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1913 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1914 "shr{w}\t{$src2, $dst|$dst, $src2}",
1915 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1916 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1917 "shr{l}\t{$src2, $dst|$dst, $src2}",
1918 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1921 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1923 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1924 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1926 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1927 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1929 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1931 let isTwoAddress = 0 in {
1932 let Uses = [CL] in {
1933 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1934 "shr{b}\t{%cl, $dst|$dst, CL}",
1935 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1936 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1937 "shr{w}\t{%cl, $dst|$dst, CL}",
1938 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1940 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1941 "shr{l}\t{%cl, $dst|$dst, CL}",
1942 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1944 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1945 "shr{b}\t{$src, $dst|$dst, $src}",
1946 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1947 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1948 "shr{w}\t{$src, $dst|$dst, $src}",
1949 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1951 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1952 "shr{l}\t{$src, $dst|$dst, $src}",
1953 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1956 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1958 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1959 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1961 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1962 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1964 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1967 let Uses = [CL] in {
1968 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1969 "sar{b}\t{%cl, $dst|$dst, CL}",
1970 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1971 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1972 "sar{w}\t{%cl, $dst|$dst, CL}",
1973 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1974 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1975 "sar{l}\t{%cl, $dst|$dst, CL}",
1976 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1979 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1980 "sar{b}\t{$src2, $dst|$dst, $src2}",
1981 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1982 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1983 "sar{w}\t{$src2, $dst|$dst, $src2}",
1984 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1986 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1987 "sar{l}\t{$src2, $dst|$dst, $src2}",
1988 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1991 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1993 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1994 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1996 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1997 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1999 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2001 let isTwoAddress = 0 in {
2002 let Uses = [CL] in {
2003 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2004 "sar{b}\t{%cl, $dst|$dst, CL}",
2005 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2006 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2007 "sar{w}\t{%cl, $dst|$dst, CL}",
2008 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2009 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2010 "sar{l}\t{%cl, $dst|$dst, CL}",
2011 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2013 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2014 "sar{b}\t{$src, $dst|$dst, $src}",
2015 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2016 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2017 "sar{w}\t{$src, $dst|$dst, $src}",
2018 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2020 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2021 "sar{l}\t{$src, $dst|$dst, $src}",
2022 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2025 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2027 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2028 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2030 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2032 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2034 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2037 // Rotate instructions
2038 // FIXME: provide shorter instructions when imm8 == 1
2039 let Uses = [CL] in {
2040 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
2041 "rol{b}\t{%cl, $dst|$dst, CL}",
2042 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
2043 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
2044 "rol{w}\t{%cl, $dst|$dst, CL}",
2045 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
2046 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
2047 "rol{l}\t{%cl, $dst|$dst, CL}",
2048 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2051 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2052 "rol{b}\t{$src2, $dst|$dst, $src2}",
2053 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2054 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2055 "rol{w}\t{$src2, $dst|$dst, $src2}",
2056 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2057 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2058 "rol{l}\t{$src2, $dst|$dst, $src2}",
2059 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2062 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2064 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2065 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2067 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2068 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2070 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2072 let isTwoAddress = 0 in {
2073 let Uses = [CL] in {
2074 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2075 "rol{b}\t{%cl, $dst|$dst, CL}",
2076 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2077 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2078 "rol{w}\t{%cl, $dst|$dst, CL}",
2079 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2080 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2081 "rol{l}\t{%cl, $dst|$dst, CL}",
2082 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2084 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2085 "rol{b}\t{$src, $dst|$dst, $src}",
2086 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2087 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2088 "rol{w}\t{$src, $dst|$dst, $src}",
2089 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2091 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2092 "rol{l}\t{$src, $dst|$dst, $src}",
2093 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2096 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2098 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2099 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2101 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2103 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2105 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2108 let Uses = [CL] in {
2109 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2110 "ror{b}\t{%cl, $dst|$dst, CL}",
2111 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2112 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2113 "ror{w}\t{%cl, $dst|$dst, CL}",
2114 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2115 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2116 "ror{l}\t{%cl, $dst|$dst, CL}",
2117 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2120 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2121 "ror{b}\t{$src2, $dst|$dst, $src2}",
2122 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2123 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2124 "ror{w}\t{$src2, $dst|$dst, $src2}",
2125 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2126 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2127 "ror{l}\t{$src2, $dst|$dst, $src2}",
2128 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2131 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2133 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2134 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2136 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2137 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2139 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2141 let isTwoAddress = 0 in {
2142 let Uses = [CL] in {
2143 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2144 "ror{b}\t{%cl, $dst|$dst, CL}",
2145 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2146 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2147 "ror{w}\t{%cl, $dst|$dst, CL}",
2148 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2149 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2150 "ror{l}\t{%cl, $dst|$dst, CL}",
2151 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2153 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2154 "ror{b}\t{$src, $dst|$dst, $src}",
2155 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2156 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2157 "ror{w}\t{$src, $dst|$dst, $src}",
2158 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2160 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2161 "ror{l}\t{$src, $dst|$dst, $src}",
2162 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2165 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2167 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2168 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2170 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2172 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2174 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2179 // Double shift instructions (generalizations of rotate)
2180 let Uses = [CL] in {
2181 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2182 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2183 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2184 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2185 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2186 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2187 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2188 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2189 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2191 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2192 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2193 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2197 let isCommutable = 1 in { // These instructions commute to each other.
2198 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2199 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2200 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2201 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2204 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2205 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2206 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2207 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2210 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2211 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2212 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2213 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2216 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2217 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2218 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2219 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2224 let isTwoAddress = 0 in {
2225 let Uses = [CL] in {
2226 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2227 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2228 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2230 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2231 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2232 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2235 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2236 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2237 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2238 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2239 (i8 imm:$src3)), addr:$dst)]>,
2241 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2242 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2243 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2244 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2245 (i8 imm:$src3)), addr:$dst)]>,
2248 let Uses = [CL] in {
2249 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2250 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2251 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2252 addr:$dst)]>, TB, OpSize;
2253 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2254 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2255 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2256 addr:$dst)]>, TB, OpSize;
2258 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2259 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2260 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2261 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2262 (i8 imm:$src3)), addr:$dst)]>,
2264 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2265 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2266 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2267 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2268 (i8 imm:$src3)), addr:$dst)]>,
2271 } // Defs = [EFLAGS]
2275 let Defs = [EFLAGS] in {
2276 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2277 // Register-Register Addition
2278 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2279 (ins GR8 :$src1, GR8 :$src2),
2280 "add{b}\t{$src2, $dst|$dst, $src2}",
2281 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2282 (implicit EFLAGS)]>;
2284 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2285 // Register-Register Addition
2286 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2287 (ins GR16:$src1, GR16:$src2),
2288 "add{w}\t{$src2, $dst|$dst, $src2}",
2289 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2290 (implicit EFLAGS)]>, OpSize;
2291 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2292 (ins GR32:$src1, GR32:$src2),
2293 "add{l}\t{$src2, $dst|$dst, $src2}",
2294 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2295 (implicit EFLAGS)]>;
2296 } // end isConvertibleToThreeAddress
2297 } // end isCommutable
2299 // Register-Memory Addition
2300 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2301 (ins GR8 :$src1, i8mem :$src2),
2302 "add{b}\t{$src2, $dst|$dst, $src2}",
2303 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2304 (implicit EFLAGS)]>;
2305 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2306 (ins GR16:$src1, i16mem:$src2),
2307 "add{w}\t{$src2, $dst|$dst, $src2}",
2308 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2309 (implicit EFLAGS)]>, OpSize;
2310 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2311 (ins GR32:$src1, i32mem:$src2),
2312 "add{l}\t{$src2, $dst|$dst, $src2}",
2313 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2314 (implicit EFLAGS)]>;
2316 // Register-Integer Addition
2317 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2318 "add{b}\t{$src2, $dst|$dst, $src2}",
2319 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2320 (implicit EFLAGS)]>;
2322 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2323 // Register-Integer Addition
2324 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2325 (ins GR16:$src1, i16imm:$src2),
2326 "add{w}\t{$src2, $dst|$dst, $src2}",
2327 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2328 (implicit EFLAGS)]>, OpSize;
2329 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2330 (ins GR32:$src1, i32imm:$src2),
2331 "add{l}\t{$src2, $dst|$dst, $src2}",
2332 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2333 (implicit EFLAGS)]>;
2334 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2335 (ins GR16:$src1, i16i8imm:$src2),
2336 "add{w}\t{$src2, $dst|$dst, $src2}",
2337 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2338 (implicit EFLAGS)]>, OpSize;
2339 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2340 (ins GR32:$src1, i32i8imm:$src2),
2341 "add{l}\t{$src2, $dst|$dst, $src2}",
2342 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2343 (implicit EFLAGS)]>;
2346 let isTwoAddress = 0 in {
2347 // Memory-Register Addition
2348 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2349 "add{b}\t{$src2, $dst|$dst, $src2}",
2350 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2351 (implicit EFLAGS)]>;
2352 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2353 "add{w}\t{$src2, $dst|$dst, $src2}",
2354 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2355 (implicit EFLAGS)]>, OpSize;
2356 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2357 "add{l}\t{$src2, $dst|$dst, $src2}",
2358 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2359 (implicit EFLAGS)]>;
2360 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2361 "add{b}\t{$src2, $dst|$dst, $src2}",
2362 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2363 (implicit EFLAGS)]>;
2364 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2365 "add{w}\t{$src2, $dst|$dst, $src2}",
2366 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2367 (implicit EFLAGS)]>, OpSize;
2368 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2369 "add{l}\t{$src2, $dst|$dst, $src2}",
2370 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2371 (implicit EFLAGS)]>;
2372 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2373 "add{w}\t{$src2, $dst|$dst, $src2}",
2374 [(store (add (load addr:$dst), i16immSExt8:$src2),
2376 (implicit EFLAGS)]>, OpSize;
2377 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2378 "add{l}\t{$src2, $dst|$dst, $src2}",
2379 [(store (add (load addr:$dst), i32immSExt8:$src2),
2381 (implicit EFLAGS)]>;
2384 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2385 "add\t{$src, %al|%al, $src}", []>;
2386 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2387 "add\t{$src, %ax|%ax, $src}", []>, OpSize;
2388 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2389 "add\t{$src, %eax|%eax, $src}", []>;
2392 let Uses = [EFLAGS] in {
2393 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2394 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2395 "adc{b}\t{$src2, $dst|$dst, $src2}",
2396 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2397 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2398 (ins GR16:$src1, GR16:$src2),
2399 "adc{w}\t{$src2, $dst|$dst, $src2}",
2400 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2401 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2402 (ins GR32:$src1, GR32:$src2),
2403 "adc{l}\t{$src2, $dst|$dst, $src2}",
2404 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2406 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2407 (ins GR8:$src1, i8mem:$src2),
2408 "adc{b}\t{$src2, $dst|$dst, $src2}",
2409 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2410 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2411 (ins GR16:$src1, i16mem:$src2),
2412 "adc{w}\t{$src2, $dst|$dst, $src2}",
2413 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2415 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2416 (ins GR32:$src1, i32mem:$src2),
2417 "adc{l}\t{$src2, $dst|$dst, $src2}",
2418 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2419 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2420 "adc{b}\t{$src2, $dst|$dst, $src2}",
2421 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2422 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2423 (ins GR16:$src1, i16imm:$src2),
2424 "adc{w}\t{$src2, $dst|$dst, $src2}",
2425 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2426 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2427 (ins GR16:$src1, i16i8imm:$src2),
2428 "adc{w}\t{$src2, $dst|$dst, $src2}",
2429 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2431 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2432 (ins GR32:$src1, i32imm:$src2),
2433 "adc{l}\t{$src2, $dst|$dst, $src2}",
2434 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2435 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2436 (ins GR32:$src1, i32i8imm:$src2),
2437 "adc{l}\t{$src2, $dst|$dst, $src2}",
2438 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2440 let isTwoAddress = 0 in {
2441 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2442 "adc{b}\t{$src2, $dst|$dst, $src2}",
2443 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2444 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2445 "adc{w}\t{$src2, $dst|$dst, $src2}",
2446 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2448 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2449 "adc{l}\t{$src2, $dst|$dst, $src2}",
2450 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2451 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2452 "adc{b}\t{$src2, $dst|$dst, $src2}",
2453 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2454 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2455 "adc{w}\t{$src2, $dst|$dst, $src2}",
2456 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2458 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2459 "adc{w}\t{$src2, $dst|$dst, $src2}",
2460 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2462 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2463 "adc{l}\t{$src2, $dst|$dst, $src2}",
2464 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2465 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2466 "adc{l}\t{$src2, $dst|$dst, $src2}",
2467 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2469 } // Uses = [EFLAGS]
2471 // Register-Register Subtraction
2472 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2473 "sub{b}\t{$src2, $dst|$dst, $src2}",
2474 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2475 (implicit EFLAGS)]>;
2476 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2477 "sub{w}\t{$src2, $dst|$dst, $src2}",
2478 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2479 (implicit EFLAGS)]>, OpSize;
2480 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2481 "sub{l}\t{$src2, $dst|$dst, $src2}",
2482 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2483 (implicit EFLAGS)]>;
2485 // Register-Memory Subtraction
2486 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2487 (ins GR8 :$src1, i8mem :$src2),
2488 "sub{b}\t{$src2, $dst|$dst, $src2}",
2489 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2490 (implicit EFLAGS)]>;
2491 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2492 (ins GR16:$src1, i16mem:$src2),
2493 "sub{w}\t{$src2, $dst|$dst, $src2}",
2494 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2495 (implicit EFLAGS)]>, OpSize;
2496 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2497 (ins GR32:$src1, i32mem:$src2),
2498 "sub{l}\t{$src2, $dst|$dst, $src2}",
2499 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2500 (implicit EFLAGS)]>;
2502 // Register-Integer Subtraction
2503 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2504 (ins GR8:$src1, i8imm:$src2),
2505 "sub{b}\t{$src2, $dst|$dst, $src2}",
2506 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2507 (implicit EFLAGS)]>;
2508 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2509 (ins GR16:$src1, i16imm:$src2),
2510 "sub{w}\t{$src2, $dst|$dst, $src2}",
2511 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2512 (implicit EFLAGS)]>, OpSize;
2513 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2514 (ins GR32:$src1, i32imm:$src2),
2515 "sub{l}\t{$src2, $dst|$dst, $src2}",
2516 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2517 (implicit EFLAGS)]>;
2518 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2519 (ins GR16:$src1, i16i8imm:$src2),
2520 "sub{w}\t{$src2, $dst|$dst, $src2}",
2521 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2522 (implicit EFLAGS)]>, OpSize;
2523 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2524 (ins GR32:$src1, i32i8imm:$src2),
2525 "sub{l}\t{$src2, $dst|$dst, $src2}",
2526 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2527 (implicit EFLAGS)]>;
2529 let isTwoAddress = 0 in {
2530 // Memory-Register Subtraction
2531 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2532 "sub{b}\t{$src2, $dst|$dst, $src2}",
2533 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2534 (implicit EFLAGS)]>;
2535 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2536 "sub{w}\t{$src2, $dst|$dst, $src2}",
2537 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2538 (implicit EFLAGS)]>, OpSize;
2539 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2540 "sub{l}\t{$src2, $dst|$dst, $src2}",
2541 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2542 (implicit EFLAGS)]>;
2544 // Memory-Integer Subtraction
2545 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2546 "sub{b}\t{$src2, $dst|$dst, $src2}",
2547 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2548 (implicit EFLAGS)]>;
2549 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2550 "sub{w}\t{$src2, $dst|$dst, $src2}",
2551 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2552 (implicit EFLAGS)]>, OpSize;
2553 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2554 "sub{l}\t{$src2, $dst|$dst, $src2}",
2555 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2556 (implicit EFLAGS)]>;
2557 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2558 "sub{w}\t{$src2, $dst|$dst, $src2}",
2559 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2561 (implicit EFLAGS)]>, OpSize;
2562 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2563 "sub{l}\t{$src2, $dst|$dst, $src2}",
2564 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2566 (implicit EFLAGS)]>;
2569 let Uses = [EFLAGS] in {
2570 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2571 (ins GR8:$src1, GR8:$src2),
2572 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2573 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2574 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2575 (ins GR16:$src1, GR16:$src2),
2576 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2577 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2578 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2579 (ins GR32:$src1, GR32:$src2),
2580 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2581 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2583 let isTwoAddress = 0 in {
2584 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2585 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2586 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2587 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2588 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2589 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2591 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2592 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2593 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2594 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2595 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2596 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2597 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2598 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2599 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2601 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2602 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2603 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2605 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2606 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2607 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2608 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2609 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2610 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2612 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2613 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2614 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2615 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2616 (ins GR16:$src1, i16mem:$src2),
2617 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2618 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2620 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2621 (ins GR32:$src1, i32mem:$src2),
2622 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2623 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2624 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2625 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2626 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2627 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2628 (ins GR16:$src1, i16imm:$src2),
2629 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2630 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2631 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2632 (ins GR16:$src1, i16i8imm:$src2),
2633 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2634 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2636 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2637 (ins GR32:$src1, i32imm:$src2),
2638 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2639 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2640 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2641 (ins GR32:$src1, i32i8imm:$src2),
2642 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2643 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2644 } // Uses = [EFLAGS]
2645 } // Defs = [EFLAGS]
2647 let Defs = [EFLAGS] in {
2648 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2649 // Register-Register Signed Integer Multiply
2650 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2651 "imul{w}\t{$src2, $dst|$dst, $src2}",
2652 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2653 (implicit EFLAGS)]>, TB, OpSize;
2654 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2655 "imul{l}\t{$src2, $dst|$dst, $src2}",
2656 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2657 (implicit EFLAGS)]>, TB;
2660 // Register-Memory Signed Integer Multiply
2661 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2662 (ins GR16:$src1, i16mem:$src2),
2663 "imul{w}\t{$src2, $dst|$dst, $src2}",
2664 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2665 (implicit EFLAGS)]>, TB, OpSize;
2666 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2667 "imul{l}\t{$src2, $dst|$dst, $src2}",
2668 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2669 (implicit EFLAGS)]>, TB;
2670 } // Defs = [EFLAGS]
2671 } // end Two Address instructions
2673 // Suprisingly enough, these are not two address instructions!
2674 let Defs = [EFLAGS] in {
2675 // Register-Integer Signed Integer Multiply
2676 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2677 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2678 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2679 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2680 (implicit EFLAGS)]>, OpSize;
2681 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2682 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2683 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2684 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2685 (implicit EFLAGS)]>;
2686 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2687 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2688 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2689 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2690 (implicit EFLAGS)]>, OpSize;
2691 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2692 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2693 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2694 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2695 (implicit EFLAGS)]>;
2697 // Memory-Integer Signed Integer Multiply
2698 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2699 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2700 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2701 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2702 (implicit EFLAGS)]>, OpSize;
2703 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2704 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2705 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2706 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2707 (implicit EFLAGS)]>;
2708 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2709 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2710 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2711 [(set GR16:$dst, (mul (load addr:$src1),
2712 i16immSExt8:$src2)),
2713 (implicit EFLAGS)]>, OpSize;
2714 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2715 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2716 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2717 [(set GR32:$dst, (mul (load addr:$src1),
2718 i32immSExt8:$src2)),
2719 (implicit EFLAGS)]>;
2720 } // Defs = [EFLAGS]
2722 //===----------------------------------------------------------------------===//
2723 // Test instructions are just like AND, except they don't generate a result.
2725 let Defs = [EFLAGS] in {
2726 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2727 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2728 "test{b}\t{$src2, $src1|$src1, $src2}",
2729 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2730 (implicit EFLAGS)]>;
2731 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2732 "test{w}\t{$src2, $src1|$src1, $src2}",
2733 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2734 (implicit EFLAGS)]>,
2736 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2737 "test{l}\t{$src2, $src1|$src1, $src2}",
2738 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2739 (implicit EFLAGS)]>;
2742 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2743 "test{b}\t{$src2, $src1|$src1, $src2}",
2744 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2745 (implicit EFLAGS)]>;
2746 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2747 "test{w}\t{$src2, $src1|$src1, $src2}",
2748 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2749 (implicit EFLAGS)]>, OpSize;
2750 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2751 "test{l}\t{$src2, $src1|$src1, $src2}",
2752 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2753 (implicit EFLAGS)]>;
2755 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2756 (outs), (ins GR8:$src1, i8imm:$src2),
2757 "test{b}\t{$src2, $src1|$src1, $src2}",
2758 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2759 (implicit EFLAGS)]>;
2760 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2761 (outs), (ins GR16:$src1, i16imm:$src2),
2762 "test{w}\t{$src2, $src1|$src1, $src2}",
2763 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2764 (implicit EFLAGS)]>, OpSize;
2765 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2766 (outs), (ins GR32:$src1, i32imm:$src2),
2767 "test{l}\t{$src2, $src1|$src1, $src2}",
2768 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2769 (implicit EFLAGS)]>;
2771 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2772 (outs), (ins i8mem:$src1, i8imm:$src2),
2773 "test{b}\t{$src2, $src1|$src1, $src2}",
2774 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2775 (implicit EFLAGS)]>;
2776 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2777 (outs), (ins i16mem:$src1, i16imm:$src2),
2778 "test{w}\t{$src2, $src1|$src1, $src2}",
2779 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2780 (implicit EFLAGS)]>, OpSize;
2781 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2782 (outs), (ins i32mem:$src1, i32imm:$src2),
2783 "test{l}\t{$src2, $src1|$src1, $src2}",
2784 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2785 (implicit EFLAGS)]>;
2786 } // Defs = [EFLAGS]
2789 // Condition code ops, incl. set if equal/not equal/...
2790 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2791 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2792 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2793 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2795 let Uses = [EFLAGS] in {
2796 def SETEr : I<0x94, MRM0r,
2797 (outs GR8 :$dst), (ins),
2799 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2801 def SETEm : I<0x94, MRM0m,
2802 (outs), (ins i8mem:$dst),
2804 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2807 def SETNEr : I<0x95, MRM0r,
2808 (outs GR8 :$dst), (ins),
2810 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2812 def SETNEm : I<0x95, MRM0m,
2813 (outs), (ins i8mem:$dst),
2815 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2818 def SETLr : I<0x9C, MRM0r,
2819 (outs GR8 :$dst), (ins),
2821 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2822 TB; // GR8 = < signed
2823 def SETLm : I<0x9C, MRM0m,
2824 (outs), (ins i8mem:$dst),
2826 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2827 TB; // [mem8] = < signed
2829 def SETGEr : I<0x9D, MRM0r,
2830 (outs GR8 :$dst), (ins),
2832 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2833 TB; // GR8 = >= signed
2834 def SETGEm : I<0x9D, MRM0m,
2835 (outs), (ins i8mem:$dst),
2837 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2838 TB; // [mem8] = >= signed
2840 def SETLEr : I<0x9E, MRM0r,
2841 (outs GR8 :$dst), (ins),
2843 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2844 TB; // GR8 = <= signed
2845 def SETLEm : I<0x9E, MRM0m,
2846 (outs), (ins i8mem:$dst),
2848 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2849 TB; // [mem8] = <= signed
2851 def SETGr : I<0x9F, MRM0r,
2852 (outs GR8 :$dst), (ins),
2854 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2855 TB; // GR8 = > signed
2856 def SETGm : I<0x9F, MRM0m,
2857 (outs), (ins i8mem:$dst),
2859 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2860 TB; // [mem8] = > signed
2862 def SETBr : I<0x92, MRM0r,
2863 (outs GR8 :$dst), (ins),
2865 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2866 TB; // GR8 = < unsign
2867 def SETBm : I<0x92, MRM0m,
2868 (outs), (ins i8mem:$dst),
2870 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2871 TB; // [mem8] = < unsign
2873 def SETAEr : I<0x93, MRM0r,
2874 (outs GR8 :$dst), (ins),
2876 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2877 TB; // GR8 = >= unsign
2878 def SETAEm : I<0x93, MRM0m,
2879 (outs), (ins i8mem:$dst),
2881 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2882 TB; // [mem8] = >= unsign
2884 def SETBEr : I<0x96, MRM0r,
2885 (outs GR8 :$dst), (ins),
2887 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2888 TB; // GR8 = <= unsign
2889 def SETBEm : I<0x96, MRM0m,
2890 (outs), (ins i8mem:$dst),
2892 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2893 TB; // [mem8] = <= unsign
2895 def SETAr : I<0x97, MRM0r,
2896 (outs GR8 :$dst), (ins),
2898 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2899 TB; // GR8 = > signed
2900 def SETAm : I<0x97, MRM0m,
2901 (outs), (ins i8mem:$dst),
2903 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2904 TB; // [mem8] = > signed
2906 def SETSr : I<0x98, MRM0r,
2907 (outs GR8 :$dst), (ins),
2909 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2910 TB; // GR8 = <sign bit>
2911 def SETSm : I<0x98, MRM0m,
2912 (outs), (ins i8mem:$dst),
2914 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2915 TB; // [mem8] = <sign bit>
2916 def SETNSr : I<0x99, MRM0r,
2917 (outs GR8 :$dst), (ins),
2919 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2920 TB; // GR8 = !<sign bit>
2921 def SETNSm : I<0x99, MRM0m,
2922 (outs), (ins i8mem:$dst),
2924 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2925 TB; // [mem8] = !<sign bit>
2927 def SETPr : I<0x9A, MRM0r,
2928 (outs GR8 :$dst), (ins),
2930 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2932 def SETPm : I<0x9A, MRM0m,
2933 (outs), (ins i8mem:$dst),
2935 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2936 TB; // [mem8] = parity
2937 def SETNPr : I<0x9B, MRM0r,
2938 (outs GR8 :$dst), (ins),
2940 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2941 TB; // GR8 = not parity
2942 def SETNPm : I<0x9B, MRM0m,
2943 (outs), (ins i8mem:$dst),
2945 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2946 TB; // [mem8] = not parity
2948 def SETOr : I<0x90, MRM0r,
2949 (outs GR8 :$dst), (ins),
2951 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2952 TB; // GR8 = overflow
2953 def SETOm : I<0x90, MRM0m,
2954 (outs), (ins i8mem:$dst),
2956 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2957 TB; // [mem8] = overflow
2958 def SETNOr : I<0x91, MRM0r,
2959 (outs GR8 :$dst), (ins),
2961 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2962 TB; // GR8 = not overflow
2963 def SETNOm : I<0x91, MRM0m,
2964 (outs), (ins i8mem:$dst),
2966 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2967 TB; // [mem8] = not overflow
2968 } // Uses = [EFLAGS]
2971 // Integer comparisons
2972 let Defs = [EFLAGS] in {
2973 def CMP8rr : I<0x38, MRMDestReg,
2974 (outs), (ins GR8 :$src1, GR8 :$src2),
2975 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2976 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2977 def CMP16rr : I<0x39, MRMDestReg,
2978 (outs), (ins GR16:$src1, GR16:$src2),
2979 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2980 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2981 def CMP32rr : I<0x39, MRMDestReg,
2982 (outs), (ins GR32:$src1, GR32:$src2),
2983 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2984 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2985 def CMP8mr : I<0x38, MRMDestMem,
2986 (outs), (ins i8mem :$src1, GR8 :$src2),
2987 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2988 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2989 (implicit EFLAGS)]>;
2990 def CMP16mr : I<0x39, MRMDestMem,
2991 (outs), (ins i16mem:$src1, GR16:$src2),
2992 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2993 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2994 (implicit EFLAGS)]>, OpSize;
2995 def CMP32mr : I<0x39, MRMDestMem,
2996 (outs), (ins i32mem:$src1, GR32:$src2),
2997 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2998 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2999 (implicit EFLAGS)]>;
3000 def CMP8rm : I<0x3A, MRMSrcMem,
3001 (outs), (ins GR8 :$src1, i8mem :$src2),
3002 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3003 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3004 (implicit EFLAGS)]>;
3005 def CMP16rm : I<0x3B, MRMSrcMem,
3006 (outs), (ins GR16:$src1, i16mem:$src2),
3007 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3008 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3009 (implicit EFLAGS)]>, OpSize;
3010 def CMP32rm : I<0x3B, MRMSrcMem,
3011 (outs), (ins GR32:$src1, i32mem:$src2),
3012 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3013 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3014 (implicit EFLAGS)]>;
3015 def CMP8ri : Ii8<0x80, MRM7r,
3016 (outs), (ins GR8:$src1, i8imm:$src2),
3017 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3018 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
3019 def CMP16ri : Ii16<0x81, MRM7r,
3020 (outs), (ins GR16:$src1, i16imm:$src2),
3021 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3022 [(X86cmp GR16:$src1, imm:$src2),
3023 (implicit EFLAGS)]>, OpSize;
3024 def CMP32ri : Ii32<0x81, MRM7r,
3025 (outs), (ins GR32:$src1, i32imm:$src2),
3026 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3027 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
3028 def CMP8mi : Ii8 <0x80, MRM7m,
3029 (outs), (ins i8mem :$src1, i8imm :$src2),
3030 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3031 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3032 (implicit EFLAGS)]>;
3033 def CMP16mi : Ii16<0x81, MRM7m,
3034 (outs), (ins i16mem:$src1, i16imm:$src2),
3035 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3036 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3037 (implicit EFLAGS)]>, OpSize;
3038 def CMP32mi : Ii32<0x81, MRM7m,
3039 (outs), (ins i32mem:$src1, i32imm:$src2),
3040 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3041 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3042 (implicit EFLAGS)]>;
3043 def CMP16ri8 : Ii8<0x83, MRM7r,
3044 (outs), (ins GR16:$src1, i16i8imm:$src2),
3045 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3046 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3047 (implicit EFLAGS)]>, OpSize;
3048 def CMP16mi8 : Ii8<0x83, MRM7m,
3049 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3050 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3051 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3052 (implicit EFLAGS)]>, OpSize;
3053 def CMP32mi8 : Ii8<0x83, MRM7m,
3054 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3055 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3056 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3057 (implicit EFLAGS)]>;
3058 def CMP32ri8 : Ii8<0x83, MRM7r,
3059 (outs), (ins GR32:$src1, i32i8imm:$src2),
3060 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3061 [(X86cmp GR32:$src1, i32immSExt8:$src2),
3062 (implicit EFLAGS)]>;
3063 } // Defs = [EFLAGS]
3066 // TODO: BTC, BTR, and BTS
3067 let Defs = [EFLAGS] in {
3068 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3069 "bt{w}\t{$src2, $src1|$src1, $src2}",
3070 [(X86bt GR16:$src1, GR16:$src2),
3071 (implicit EFLAGS)]>, OpSize, TB;
3072 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3073 "bt{l}\t{$src2, $src1|$src1, $src2}",
3074 [(X86bt GR32:$src1, GR32:$src2),
3075 (implicit EFLAGS)]>, TB;
3077 // Unlike with the register+register form, the memory+register form of the
3078 // bt instruction does not ignore the high bits of the index. From ISel's
3079 // perspective, this is pretty bizarre. Disable these instructions for now.
3080 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3081 // "bt{w}\t{$src2, $src1|$src1, $src2}",
3082 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3083 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3084 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3085 // "bt{l}\t{$src2, $src1|$src1, $src2}",
3086 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3087 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
3089 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3090 "bt{w}\t{$src2, $src1|$src1, $src2}",
3091 [(X86bt GR16:$src1, i16immSExt8:$src2),
3092 (implicit EFLAGS)]>, OpSize, TB;
3093 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3094 "bt{l}\t{$src2, $src1|$src1, $src2}",
3095 [(X86bt GR32:$src1, i32immSExt8:$src2),
3096 (implicit EFLAGS)]>, TB;
3097 // Note that these instructions don't need FastBTMem because that
3098 // only applies when the other operand is in a register. When it's
3099 // an immediate, bt is still fast.
3100 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3101 "bt{w}\t{$src2, $src1|$src1, $src2}",
3102 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3103 (implicit EFLAGS)]>, OpSize, TB;
3104 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3105 "bt{l}\t{$src2, $src1|$src1, $src2}",
3106 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3107 (implicit EFLAGS)]>, TB;
3108 } // Defs = [EFLAGS]
3110 // Sign/Zero extenders
3111 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3112 // of the register here. This has a smaller encoding and avoids a
3113 // partial-register update.
3114 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3115 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3116 [(set GR16:$dst, (sext GR8:$src))]>, TB;
3117 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3118 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3119 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3120 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3121 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3122 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3123 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3124 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3125 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3126 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3127 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3128 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3129 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3130 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3131 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3133 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3134 // of the register here. This has a smaller encoding and avoids a
3135 // partial-register update.
3136 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3137 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3138 [(set GR16:$dst, (zext GR8:$src))]>, TB;
3139 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3140 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3141 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3142 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3143 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3144 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3145 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3146 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3147 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3148 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3149 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3150 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3151 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3152 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3153 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3155 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3156 // except that they use GR32_NOREX for the output operand register class
3157 // instead of GR32. This allows them to operate on h registers on x86-64.
3158 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3159 (outs GR32_NOREX:$dst), (ins GR8:$src),
3160 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3163 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3164 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3165 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3168 let neverHasSideEffects = 1 in {
3169 let Defs = [AX], Uses = [AL] in
3170 def CBW : I<0x98, RawFrm, (outs), (ins),
3171 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3172 let Defs = [EAX], Uses = [AX] in
3173 def CWDE : I<0x98, RawFrm, (outs), (ins),
3174 "{cwtl|cwde}", []>; // EAX = signext(AX)
3176 let Defs = [AX,DX], Uses = [AX] in
3177 def CWD : I<0x99, RawFrm, (outs), (ins),
3178 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3179 let Defs = [EAX,EDX], Uses = [EAX] in
3180 def CDQ : I<0x99, RawFrm, (outs), (ins),
3181 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3184 //===----------------------------------------------------------------------===//
3185 // Alias Instructions
3186 //===----------------------------------------------------------------------===//
3188 // Alias instructions that map movr0 to xor.
3189 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3190 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3191 isCodeGenOnly = 1 in {
3192 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
3193 "xor{b}\t$dst, $dst",
3194 [(set GR8:$dst, 0)]>;
3195 // Use xorl instead of xorw since we don't care about the high 16 bits,
3196 // it's smaller, and it avoids a partial-register update.
3197 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3198 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3199 [(set GR16:$dst, 0)]>;
3200 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3201 "xor{l}\t$dst, $dst",
3202 [(set GR32:$dst, 0)]>;
3205 //===----------------------------------------------------------------------===//
3206 // Thread Local Storage Instructions
3209 // All calls clobber the non-callee saved registers. ESP is marked as
3210 // a use to prevent stack-pointer assignments that appear immediately
3211 // before calls from potentially appearing dead.
3212 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3213 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3214 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3215 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3217 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3218 "leal\t$sym, %eax; "
3219 "call\t___tls_get_addr@PLT",
3220 [(X86tlsaddr tls32addr:$sym)]>,
3221 Requires<[In32BitMode]>;
3223 let AddedComplexity = 5, isCodeGenOnly = 1 in
3224 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3225 "movl\t%gs:$src, $dst",
3226 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3228 let AddedComplexity = 5, isCodeGenOnly = 1 in
3229 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3230 "movl\t%fs:$src, $dst",
3231 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3233 //===----------------------------------------------------------------------===//
3234 // DWARF Pseudo Instructions
3237 def DWARF_LOC : I<0, Pseudo, (outs),
3238 (ins i32imm:$line, i32imm:$col, i32imm:$file),
3239 ".loc\t$file $line $col",
3240 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3243 //===----------------------------------------------------------------------===//
3244 // EH Pseudo Instructions
3246 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3248 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3249 "ret\t#eh_return, addr: $addr",
3250 [(X86ehret GR32:$addr)]>;
3254 //===----------------------------------------------------------------------===//
3258 // Atomic swap. These are just normal xchg instructions. But since a memory
3259 // operand is referenced, the atomicity is ensured.
3260 let Constraints = "$val = $dst" in {
3261 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3262 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3263 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3264 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3265 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3266 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3268 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3269 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3270 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3273 // Atomic compare and swap.
3274 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3275 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3277 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3278 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3280 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3281 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3284 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3287 let Defs = [AX, EFLAGS], Uses = [AX] in {
3288 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3290 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3291 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3293 let Defs = [AL, EFLAGS], Uses = [AL] in {
3294 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3296 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3297 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3300 // Atomic exchange and add
3301 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3302 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3304 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3305 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3307 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3309 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3310 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3312 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3314 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3315 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3319 // Optimized codegen when the non-memory output is not used.
3320 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3321 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3323 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3324 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3326 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3327 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3329 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3330 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3332 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3333 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3335 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3336 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3338 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3339 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3341 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3342 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3344 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3346 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3348 "inc{b}\t$dst", []>, LOCK;
3349 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3351 "inc{w}\t$dst", []>, OpSize, LOCK;
3352 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3354 "inc{l}\t$dst", []>, LOCK;
3356 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3358 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3359 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3361 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3362 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3364 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3365 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3367 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3368 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3370 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3371 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3373 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3374 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3376 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3377 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3379 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3381 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3383 "dec{b}\t$dst", []>, LOCK;
3384 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3386 "dec{w}\t$dst", []>, OpSize, LOCK;
3387 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3389 "dec{l}\t$dst", []>, LOCK;
3391 // Atomic exchange, and, or, xor
3392 let Constraints = "$val = $dst", Defs = [EFLAGS],
3393 usesCustomDAGSchedInserter = 1 in {
3394 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3395 "#ATOMAND32 PSEUDO!",
3396 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3397 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3398 "#ATOMOR32 PSEUDO!",
3399 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3400 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3401 "#ATOMXOR32 PSEUDO!",
3402 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3403 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3404 "#ATOMNAND32 PSEUDO!",
3405 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3406 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3407 "#ATOMMIN32 PSEUDO!",
3408 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3409 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3410 "#ATOMMAX32 PSEUDO!",
3411 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3412 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3413 "#ATOMUMIN32 PSEUDO!",
3414 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3415 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3416 "#ATOMUMAX32 PSEUDO!",
3417 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3419 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3420 "#ATOMAND16 PSEUDO!",
3421 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3422 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3423 "#ATOMOR16 PSEUDO!",
3424 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3425 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3426 "#ATOMXOR16 PSEUDO!",
3427 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3428 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3429 "#ATOMNAND16 PSEUDO!",
3430 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3431 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3432 "#ATOMMIN16 PSEUDO!",
3433 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3434 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3435 "#ATOMMAX16 PSEUDO!",
3436 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3437 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3438 "#ATOMUMIN16 PSEUDO!",
3439 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3440 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3441 "#ATOMUMAX16 PSEUDO!",
3442 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3444 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3445 "#ATOMAND8 PSEUDO!",
3446 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3447 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3449 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3450 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3451 "#ATOMXOR8 PSEUDO!",
3452 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3453 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3454 "#ATOMNAND8 PSEUDO!",
3455 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3458 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3459 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3460 Uses = [EAX, EBX, ECX, EDX],
3461 mayLoad = 1, mayStore = 1,
3462 usesCustomDAGSchedInserter = 1 in {
3463 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3464 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3465 "#ATOMAND6432 PSEUDO!", []>;
3466 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3467 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3468 "#ATOMOR6432 PSEUDO!", []>;
3469 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3470 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3471 "#ATOMXOR6432 PSEUDO!", []>;
3472 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3473 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3474 "#ATOMNAND6432 PSEUDO!", []>;
3475 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3476 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3477 "#ATOMADD6432 PSEUDO!", []>;
3478 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3479 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3480 "#ATOMSUB6432 PSEUDO!", []>;
3481 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3482 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3483 "#ATOMSWAP6432 PSEUDO!", []>;
3486 //===----------------------------------------------------------------------===//
3487 // Non-Instruction Patterns
3488 //===----------------------------------------------------------------------===//
3490 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3491 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3492 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3493 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3494 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3495 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3497 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3498 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3499 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3500 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3501 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3502 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3503 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3504 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3506 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3507 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3508 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3509 (MOV32mi addr:$dst, texternalsym:$src)>;
3513 def : Pat<(X86tcret GR32:$dst, imm:$off),
3514 (TCRETURNri GR32:$dst, imm:$off)>;
3516 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3517 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3519 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3520 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3522 // Normal calls, with various flavors of addresses.
3523 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3524 (CALLpcrel32 tglobaladdr:$dst)>;
3525 def : Pat<(X86call (i32 texternalsym:$dst)),
3526 (CALLpcrel32 texternalsym:$dst)>;
3527 def : Pat<(X86call (i32 imm:$dst)),
3528 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
3530 // X86 specific add which produces a flag.
3531 def : Pat<(addc GR32:$src1, GR32:$src2),
3532 (ADD32rr GR32:$src1, GR32:$src2)>;
3533 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3534 (ADD32rm GR32:$src1, addr:$src2)>;
3535 def : Pat<(addc GR32:$src1, imm:$src2),
3536 (ADD32ri GR32:$src1, imm:$src2)>;
3537 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3538 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3540 def : Pat<(subc GR32:$src1, GR32:$src2),
3541 (SUB32rr GR32:$src1, GR32:$src2)>;
3542 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3543 (SUB32rm GR32:$src1, addr:$src2)>;
3544 def : Pat<(subc GR32:$src1, imm:$src2),
3545 (SUB32ri GR32:$src1, imm:$src2)>;
3546 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3547 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3551 // TEST R,R is smaller than CMP R,0
3552 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3553 (TEST8rr GR8:$src1, GR8:$src1)>;
3554 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3555 (TEST16rr GR16:$src1, GR16:$src1)>;
3556 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3557 (TEST32rr GR32:$src1, GR32:$src1)>;
3559 // Conditional moves with folded loads with operands swapped and conditions
3561 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3562 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3563 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3564 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3565 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3566 (CMOVB16rm GR16:$src2, addr:$src1)>;
3567 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3568 (CMOVB32rm GR32:$src2, addr:$src1)>;
3569 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3570 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3571 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3572 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3573 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3574 (CMOVE16rm GR16:$src2, addr:$src1)>;
3575 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3576 (CMOVE32rm GR32:$src2, addr:$src1)>;
3577 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3578 (CMOVA16rm GR16:$src2, addr:$src1)>;
3579 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3580 (CMOVA32rm GR32:$src2, addr:$src1)>;
3581 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3582 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3583 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3584 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3585 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3586 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3587 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3588 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3589 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3590 (CMOVL16rm GR16:$src2, addr:$src1)>;
3591 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3592 (CMOVL32rm GR32:$src2, addr:$src1)>;
3593 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3594 (CMOVG16rm GR16:$src2, addr:$src1)>;
3595 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3596 (CMOVG32rm GR32:$src2, addr:$src1)>;
3597 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3598 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3599 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3600 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3601 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3602 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3603 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3604 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3605 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3606 (CMOVP16rm GR16:$src2, addr:$src1)>;
3607 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3608 (CMOVP32rm GR32:$src2, addr:$src1)>;
3609 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3610 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3611 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3612 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3613 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3614 (CMOVS16rm GR16:$src2, addr:$src1)>;
3615 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3616 (CMOVS32rm GR32:$src2, addr:$src1)>;
3617 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3618 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3619 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3620 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3621 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3622 (CMOVO16rm GR16:$src2, addr:$src1)>;
3623 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3624 (CMOVO32rm GR32:$src2, addr:$src1)>;
3626 // zextload bool -> zextload byte
3627 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3628 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3629 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3631 // extload bool -> extload byte
3632 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3633 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3634 Requires<[In32BitMode]>;
3635 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3636 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3637 Requires<[In32BitMode]>;
3638 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3639 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3642 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3643 Requires<[In32BitMode]>;
3644 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3645 Requires<[In32BitMode]>;
3646 def : Pat<(i32 (anyext GR16:$src)),
3647 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
3649 // (and (i32 load), 255) -> (zextload i8)
3650 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3651 (MOVZX32rm8 addr:$src)>;
3652 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3653 (MOVZX32rm16 addr:$src)>;
3655 //===----------------------------------------------------------------------===//
3657 //===----------------------------------------------------------------------===//
3659 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3660 // +128 doesn't, so in this special case use a sub instead of an add.
3661 def : Pat<(add GR16:$src1, 128),
3662 (SUB16ri8 GR16:$src1, -128)>;
3663 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3664 (SUB16mi8 addr:$dst, -128)>;
3665 def : Pat<(add GR32:$src1, 128),
3666 (SUB32ri8 GR32:$src1, -128)>;
3667 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3668 (SUB32mi8 addr:$dst, -128)>;
3670 // r & (2^16-1) ==> movz
3671 def : Pat<(and GR32:$src1, 0xffff),
3672 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
3673 // r & (2^8-1) ==> movz
3674 def : Pat<(and GR32:$src1, 0xff),
3675 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
3677 Requires<[In32BitMode]>;
3678 // r & (2^8-1) ==> movz
3679 def : Pat<(and GR16:$src1, 0xff),
3680 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
3682 Requires<[In32BitMode]>;
3684 // sext_inreg patterns
3685 def : Pat<(sext_inreg GR32:$src, i16),
3686 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3687 def : Pat<(sext_inreg GR32:$src, i8),
3688 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3690 Requires<[In32BitMode]>;
3691 def : Pat<(sext_inreg GR16:$src, i8),
3692 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3694 Requires<[In32BitMode]>;
3697 def : Pat<(i16 (trunc GR32:$src)),
3698 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
3699 def : Pat<(i8 (trunc GR32:$src)),
3700 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3702 Requires<[In32BitMode]>;
3703 def : Pat<(i8 (trunc GR16:$src)),
3704 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3706 Requires<[In32BitMode]>;
3708 // h-register tricks
3709 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
3710 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3711 x86_subreg_8bit_hi)>,
3712 Requires<[In32BitMode]>;
3713 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
3714 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3715 x86_subreg_8bit_hi)>,
3716 Requires<[In32BitMode]>;
3717 def : Pat<(srl_su GR16:$src, (i8 8)),
3720 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3721 x86_subreg_8bit_hi)),
3723 Requires<[In32BitMode]>;
3724 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3725 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3726 x86_subreg_8bit_hi))>,
3727 Requires<[In32BitMode]>;
3728 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
3729 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3730 x86_subreg_8bit_hi))>,
3731 Requires<[In32BitMode]>;
3733 // (shl x, 1) ==> (add x, x)
3734 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3735 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3736 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3738 // (shl x (and y, 31)) ==> (shl x, y)
3739 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3740 (SHL8rCL GR8:$src1)>;
3741 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3742 (SHL16rCL GR16:$src1)>;
3743 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3744 (SHL32rCL GR32:$src1)>;
3745 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3746 (SHL8mCL addr:$dst)>;
3747 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3748 (SHL16mCL addr:$dst)>;
3749 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3750 (SHL32mCL addr:$dst)>;
3752 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3753 (SHR8rCL GR8:$src1)>;
3754 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3755 (SHR16rCL GR16:$src1)>;
3756 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3757 (SHR32rCL GR32:$src1)>;
3758 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3759 (SHR8mCL addr:$dst)>;
3760 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3761 (SHR16mCL addr:$dst)>;
3762 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3763 (SHR32mCL addr:$dst)>;
3765 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3766 (SAR8rCL GR8:$src1)>;
3767 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3768 (SAR16rCL GR16:$src1)>;
3769 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3770 (SAR32rCL GR32:$src1)>;
3771 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3772 (SAR8mCL addr:$dst)>;
3773 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3774 (SAR16mCL addr:$dst)>;
3775 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3776 (SAR32mCL addr:$dst)>;
3778 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3779 def : Pat<(or (srl GR32:$src1, CL:$amt),
3780 (shl GR32:$src2, (sub 32, CL:$amt))),
3781 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3783 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3784 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3785 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3787 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3788 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3789 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3791 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3792 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3794 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3796 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3797 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3799 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3800 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3801 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3803 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3804 def : Pat<(or (shl GR32:$src1, CL:$amt),
3805 (srl GR32:$src2, (sub 32, CL:$amt))),
3806 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3808 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3809 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3810 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3812 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3813 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3814 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3816 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3817 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3819 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3821 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3822 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3824 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3825 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3826 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3828 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3829 def : Pat<(or (srl GR16:$src1, CL:$amt),
3830 (shl GR16:$src2, (sub 16, CL:$amt))),
3831 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3833 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3834 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3835 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3837 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3838 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3839 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3841 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3842 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3844 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3846 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3847 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3849 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3850 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3851 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3853 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3854 def : Pat<(or (shl GR16:$src1, CL:$amt),
3855 (srl GR16:$src2, (sub 16, CL:$amt))),
3856 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3858 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3859 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3860 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3862 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3863 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3864 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3866 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3867 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3869 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3871 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3872 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3874 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3875 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3876 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3878 //===----------------------------------------------------------------------===//
3879 // EFLAGS-defining Patterns
3880 //===----------------------------------------------------------------------===//
3882 // Register-Register Addition with EFLAGS result
3883 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
3885 (ADD8rr GR8:$src1, GR8:$src2)>;
3886 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
3888 (ADD16rr GR16:$src1, GR16:$src2)>;
3889 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
3891 (ADD32rr GR32:$src1, GR32:$src2)>;
3893 // Register-Memory Addition with EFLAGS result
3894 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
3896 (ADD8rm GR8:$src1, addr:$src2)>;
3897 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
3899 (ADD16rm GR16:$src1, addr:$src2)>;
3900 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
3902 (ADD32rm GR32:$src1, addr:$src2)>;
3904 // Register-Integer Addition with EFLAGS result
3905 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
3907 (ADD8ri GR8:$src1, imm:$src2)>;
3908 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
3910 (ADD16ri GR16:$src1, imm:$src2)>;
3911 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
3913 (ADD32ri GR32:$src1, imm:$src2)>;
3914 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
3916 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3917 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
3919 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3921 // Memory-Register Addition with EFLAGS result
3922 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
3925 (ADD8mr addr:$dst, GR8:$src2)>;
3926 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
3929 (ADD16mr addr:$dst, GR16:$src2)>;
3930 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
3933 (ADD32mr addr:$dst, GR32:$src2)>;
3935 // Memory-Integer Addition with EFLAGS result
3936 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
3939 (ADD8mi addr:$dst, imm:$src2)>;
3940 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
3943 (ADD16mi addr:$dst, imm:$src2)>;
3944 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
3947 (ADD32mi addr:$dst, imm:$src2)>;
3948 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3951 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3952 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3955 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3957 // Register-Register Subtraction with EFLAGS result
3958 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
3960 (SUB8rr GR8:$src1, GR8:$src2)>;
3961 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
3963 (SUB16rr GR16:$src1, GR16:$src2)>;
3964 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
3966 (SUB32rr GR32:$src1, GR32:$src2)>;
3968 // Register-Memory Subtraction with EFLAGS result
3969 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
3971 (SUB8rm GR8:$src1, addr:$src2)>;
3972 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
3974 (SUB16rm GR16:$src1, addr:$src2)>;
3975 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
3977 (SUB32rm GR32:$src1, addr:$src2)>;
3979 // Register-Integer Subtraction with EFLAGS result
3980 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
3982 (SUB8ri GR8:$src1, imm:$src2)>;
3983 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
3985 (SUB16ri GR16:$src1, imm:$src2)>;
3986 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
3988 (SUB32ri GR32:$src1, imm:$src2)>;
3989 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
3991 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3992 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
3994 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3996 // Memory-Register Subtraction with EFLAGS result
3997 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
4000 (SUB8mr addr:$dst, GR8:$src2)>;
4001 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
4004 (SUB16mr addr:$dst, GR16:$src2)>;
4005 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
4008 (SUB32mr addr:$dst, GR32:$src2)>;
4010 // Memory-Integer Subtraction with EFLAGS result
4011 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
4014 (SUB8mi addr:$dst, imm:$src2)>;
4015 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
4018 (SUB16mi addr:$dst, imm:$src2)>;
4019 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
4022 (SUB32mi addr:$dst, imm:$src2)>;
4023 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4026 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
4027 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4030 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4033 // Register-Register Signed Integer Multiply with EFLAGS result
4034 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
4036 (IMUL16rr GR16:$src1, GR16:$src2)>;
4037 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
4039 (IMUL32rr GR32:$src1, GR32:$src2)>;
4041 // Register-Memory Signed Integer Multiply with EFLAGS result
4042 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
4044 (IMUL16rm GR16:$src1, addr:$src2)>;
4045 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
4047 (IMUL32rm GR32:$src1, addr:$src2)>;
4049 // Register-Integer Signed Integer Multiply with EFLAGS result
4050 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
4052 (IMUL16rri GR16:$src1, imm:$src2)>;
4053 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
4055 (IMUL32rri GR32:$src1, imm:$src2)>;
4056 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
4058 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4059 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
4061 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4063 // Memory-Integer Signed Integer Multiply with EFLAGS result
4064 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
4066 (IMUL16rmi addr:$src1, imm:$src2)>;
4067 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
4069 (IMUL32rmi addr:$src1, imm:$src2)>;
4070 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
4072 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4073 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
4075 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4077 // Optimize multiply by 2 with EFLAGS result.
4078 let AddedComplexity = 2 in {
4079 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
4081 (ADD16rr GR16:$src1, GR16:$src1)>;
4083 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
4085 (ADD32rr GR32:$src1, GR32:$src1)>;
4088 // INC and DEC with EFLAGS result. Note that these do not set CF.
4089 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4091 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4094 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4096 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4100 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
4101 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4102 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4104 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
4105 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
4106 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4107 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4109 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
4111 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
4112 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4113 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4115 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
4116 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
4117 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4118 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4120 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
4122 //===----------------------------------------------------------------------===//
4123 // Floating Point Stack Support
4124 //===----------------------------------------------------------------------===//
4126 include "X86InstrFPStack.td"
4128 //===----------------------------------------------------------------------===//
4130 //===----------------------------------------------------------------------===//
4132 include "X86Instr64bit.td"
4134 //===----------------------------------------------------------------------===//
4135 // XMM Floating point support (requires SSE / SSE2)
4136 //===----------------------------------------------------------------------===//
4138 include "X86InstrSSE.td"
4140 //===----------------------------------------------------------------------===//
4141 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4142 //===----------------------------------------------------------------------===//
4144 include "X86InstrMMX.td"