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>;
165 def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags>;
166 def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags>;
167 def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags>;
169 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
171 //===----------------------------------------------------------------------===//
172 // X86 Operand Definitions.
175 def i32imm_pcrel : Operand<i32> {
176 let PrintMethod = "print_pcrel_imm";
179 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
180 // the index operand of an address, to conform to x86 encoding restrictions.
181 def ptr_rc_nosp : PointerLikeRegClass<1>;
183 // *mem - Operand definitions for the funky X86 addressing mode operands.
185 def X86MemAsmOperand : AsmOperandClass {
189 class X86MemOperand<string printMethod> : Operand<iPTR> {
190 let PrintMethod = printMethod;
191 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
192 let ParserMatchClass = X86MemAsmOperand;
195 def opaque32mem : X86MemOperand<"printopaquemem">;
196 def opaque48mem : X86MemOperand<"printopaquemem">;
197 def opaque80mem : X86MemOperand<"printopaquemem">;
199 def i8mem : X86MemOperand<"printi8mem">;
200 def i16mem : X86MemOperand<"printi16mem">;
201 def i32mem : X86MemOperand<"printi32mem">;
202 def i64mem : X86MemOperand<"printi64mem">;
203 def i128mem : X86MemOperand<"printi128mem">;
204 //def i256mem : X86MemOperand<"printi256mem">;
205 def f32mem : X86MemOperand<"printf32mem">;
206 def f64mem : X86MemOperand<"printf64mem">;
207 def f80mem : X86MemOperand<"printf80mem">;
208 def f128mem : X86MemOperand<"printf128mem">;
209 //def f256mem : X86MemOperand<"printf256mem">;
211 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
212 // plain GR64, so that it doesn't potentially require a REX prefix.
213 def i8mem_NOREX : Operand<i64> {
214 let PrintMethod = "printi8mem";
215 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
216 let ParserMatchClass = X86MemAsmOperand;
219 def lea32mem : Operand<i32> {
220 let PrintMethod = "printlea32mem";
221 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
222 let ParserMatchClass = X86MemAsmOperand;
225 def SSECC : Operand<i8> {
226 let PrintMethod = "printSSECC";
229 def ImmSExt8AsmOperand : AsmOperandClass {
230 let Name = "ImmSExt8";
231 let SuperClass = ImmAsmOperand;
234 // A couple of more descriptive operand definitions.
235 // 16-bits but only 8 bits are significant.
236 def i16i8imm : Operand<i16> {
237 let ParserMatchClass = ImmSExt8AsmOperand;
239 // 32-bits but only 8 bits are significant.
240 def i32i8imm : Operand<i32> {
241 let ParserMatchClass = ImmSExt8AsmOperand;
244 // Branch targets have OtherVT type and print as pc-relative values.
245 def brtarget : Operand<OtherVT> {
246 let PrintMethod = "print_pcrel_imm";
249 def brtarget8 : Operand<OtherVT> {
250 let PrintMethod = "print_pcrel_imm";
253 //===----------------------------------------------------------------------===//
254 // X86 Complex Pattern Definitions.
257 // Define X86 specific addressing mode.
258 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
259 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
260 [add, sub, mul, X86mul_imm, shl, or, frameindex],
262 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
263 [tglobaltlsaddr], []>;
265 //===----------------------------------------------------------------------===//
266 // X86 Instruction Predicate Definitions.
267 def HasMMX : Predicate<"Subtarget->hasMMX()">;
268 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
269 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
270 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
271 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
272 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
273 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
274 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
275 def HasAVX : Predicate<"Subtarget->hasAVX()">;
276 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
277 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
278 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
279 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
280 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
281 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
282 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
283 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
284 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
285 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
286 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
287 "TM.getCodeModel() != CodeModel::Kernel">;
288 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
289 "TM.getCodeModel() == CodeModel::Kernel">;
290 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
291 def OptForSpeed : Predicate<"!OptForSize">;
292 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
293 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
295 //===----------------------------------------------------------------------===//
296 // X86 Instruction Format Definitions.
299 include "X86InstrFormats.td"
301 //===----------------------------------------------------------------------===//
302 // Pattern fragments...
305 // X86 specific condition code. These correspond to CondCode in
306 // X86InstrInfo.h. They must be kept in synch.
307 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
308 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
309 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
310 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
311 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
312 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
313 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
314 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
315 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
316 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
317 def X86_COND_NO : PatLeaf<(i8 10)>;
318 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
319 def X86_COND_NS : PatLeaf<(i8 12)>;
320 def X86_COND_O : PatLeaf<(i8 13)>;
321 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
322 def X86_COND_S : PatLeaf<(i8 15)>;
324 def i16immSExt8 : PatLeaf<(i16 imm), [{
325 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
326 // sign extended field.
327 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
330 def i32immSExt8 : PatLeaf<(i32 imm), [{
331 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
332 // sign extended field.
333 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
336 // Helper fragments for loads.
337 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
338 // known to be 32-bit aligned or better. Ditto for i8 to i16.
339 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
340 LoadSDNode *LD = cast<LoadSDNode>(N);
341 if (const Value *Src = LD->getSrcValue())
342 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
343 if (PT->getAddressSpace() > 255)
345 ISD::LoadExtType ExtType = LD->getExtensionType();
346 if (ExtType == ISD::NON_EXTLOAD)
348 if (ExtType == ISD::EXTLOAD)
349 return LD->getAlignment() >= 2 && !LD->isVolatile();
353 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
354 LoadSDNode *LD = cast<LoadSDNode>(N);
355 if (const Value *Src = LD->getSrcValue())
356 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
357 if (PT->getAddressSpace() > 255)
359 ISD::LoadExtType ExtType = LD->getExtensionType();
360 if (ExtType == ISD::EXTLOAD)
361 return LD->getAlignment() >= 2 && !LD->isVolatile();
365 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
366 LoadSDNode *LD = cast<LoadSDNode>(N);
367 if (const Value *Src = LD->getSrcValue())
368 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
369 if (PT->getAddressSpace() > 255)
371 ISD::LoadExtType ExtType = LD->getExtensionType();
372 if (ExtType == ISD::NON_EXTLOAD)
374 if (ExtType == ISD::EXTLOAD)
375 return LD->getAlignment() >= 4 && !LD->isVolatile();
379 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
380 LoadSDNode *LD = cast<LoadSDNode>(N);
381 if (const Value *Src = LD->getSrcValue())
382 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
383 if (PT->getAddressSpace() > 255)
385 if (LD->isVolatile())
387 ISD::LoadExtType ExtType = LD->getExtensionType();
388 if (ExtType == ISD::NON_EXTLOAD)
390 if (ExtType == ISD::EXTLOAD)
391 return LD->getAlignment() >= 4;
395 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
396 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
397 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
398 return PT->getAddressSpace() == 256;
402 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
403 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
404 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
405 return PT->getAddressSpace() == 257;
409 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
410 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
411 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
412 if (PT->getAddressSpace() > 255)
416 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
417 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
418 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
419 if (PT->getAddressSpace() > 255)
424 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
425 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
426 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
427 if (PT->getAddressSpace() > 255)
431 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
432 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
433 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
434 if (PT->getAddressSpace() > 255)
438 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
439 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
440 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
441 if (PT->getAddressSpace() > 255)
446 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
447 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
448 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
450 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
451 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
452 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
453 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
454 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
455 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
457 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
458 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
459 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
460 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
461 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
462 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
465 // An 'and' node with a single use.
466 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
467 return N->hasOneUse();
469 // An 'srl' node with a single use.
470 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
471 return N->hasOneUse();
473 // An 'trunc' node with a single use.
474 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
475 return N->hasOneUse();
478 // 'shld' and 'shrd' instruction patterns. Note that even though these have
479 // the srl and shl in their patterns, the C++ code must still check for them,
480 // because predicates are tested before children nodes are explored.
482 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
483 (or (srl node:$src1, node:$amt1),
484 (shl node:$src2, node:$amt2)), [{
485 assert(N->getOpcode() == ISD::OR);
486 return N->getOperand(0).getOpcode() == ISD::SRL &&
487 N->getOperand(1).getOpcode() == ISD::SHL &&
488 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
489 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
490 N->getOperand(0).getConstantOperandVal(1) ==
491 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
494 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
495 (or (shl node:$src1, node:$amt1),
496 (srl node:$src2, node:$amt2)), [{
497 assert(N->getOpcode() == ISD::OR);
498 return N->getOperand(0).getOpcode() == ISD::SHL &&
499 N->getOperand(1).getOpcode() == ISD::SRL &&
500 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
501 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
502 N->getOperand(0).getConstantOperandVal(1) ==
503 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
506 //===----------------------------------------------------------------------===//
507 // Instruction list...
510 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
511 // a stack adjustment and the codegen must know that they may modify the stack
512 // pointer before prolog-epilog rewriting occurs.
513 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
514 // sub / add which can clobber EFLAGS.
515 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
516 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
518 [(X86callseq_start timm:$amt)]>,
519 Requires<[In32BitMode]>;
520 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
522 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
523 Requires<[In32BitMode]>;
526 // x86-64 va_start lowering magic.
527 let usesCustomDAGSchedInserter = 1 in
528 def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
531 i64imm:$regsavefi, i64imm:$offset,
533 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
534 [(X86vastart_save_xmm_regs GR8:$al,
539 let neverHasSideEffects = 1 in {
540 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
541 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
542 "nopl\t$zero", []>, TB;
546 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int 3", []>;
547 def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
550 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
551 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
555 //===----------------------------------------------------------------------===//
556 // Control Flow Instructions...
559 // Return instructions.
560 let isTerminator = 1, isReturn = 1, isBarrier = 1,
561 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
562 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
565 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
567 [(X86retflag timm:$amt)]>;
568 def LRET : I <0xCB, RawFrm, (outs), (ins),
570 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
574 // All branches are RawFrm, Void, Branch, and Terminators
575 let isBranch = 1, isTerminator = 1 in
576 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
577 I<opcode, RawFrm, (outs), ins, asm, pattern>;
579 let isBranch = 1, isBarrier = 1 in {
580 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
581 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
585 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
586 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
587 [(brind GR32:$dst)]>;
588 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
589 [(brind (loadi32 addr:$dst))]>;
591 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
592 (ins i16imm:$seg, i16imm:$off),
593 "ljmp{w}\t$seg, $off", []>, OpSize;
594 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
595 (ins i16imm:$seg, i32imm:$off),
596 "ljmp{l}\t$seg, $off", []>;
598 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
599 "ljmp{w}\t{*}$dst", []>, OpSize;
600 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
601 "ljmp{l}\t{*}$dst", []>;
604 // Conditional branches
605 let Uses = [EFLAGS] in {
606 // Short conditional jumps
607 def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
608 def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
609 def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
610 def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
611 def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
612 def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
613 def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
614 def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
615 def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
616 def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
617 def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
618 def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
619 def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
620 def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
621 def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
622 def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
624 def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
626 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
627 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
628 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
629 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
630 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
631 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
632 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
633 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
634 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
635 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
636 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
637 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
639 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
640 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
641 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
642 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
643 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
644 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
645 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
646 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
648 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
649 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
650 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
651 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
652 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
653 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
654 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
655 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
656 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
657 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
658 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
659 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
664 def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
665 def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
666 def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
668 //===----------------------------------------------------------------------===//
669 // Call Instructions...
672 // All calls clobber the non-callee saved registers. ESP is marked as
673 // a use to prevent stack-pointer assignments that appear immediately
674 // before calls from potentially appearing dead. Uses for argument
675 // registers are added manually.
676 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
677 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
678 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
679 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
681 def CALLpcrel32 : Ii32<0xE8, RawFrm,
682 (outs), (ins i32imm_pcrel:$dst,variable_ops),
684 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
685 "call\t{*}$dst", [(X86call GR32:$dst)]>;
686 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
687 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
689 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
690 (ins i16imm:$seg, i16imm:$off),
691 "lcall{w}\t$seg, $off", []>, OpSize;
692 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
693 (ins i16imm:$seg, i32imm:$off),
694 "lcall{l}\t$seg, $off", []>;
696 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
697 "lcall{w}\t{*}$dst", []>, OpSize;
698 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
699 "lcall{l}\t{*}$dst", []>;
702 // Constructing a stack frame.
704 def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
705 "enter\t$len, $lvl", []>;
709 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
710 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
711 "#TC_RETURN $dst $offset",
714 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
715 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
716 "#TC_RETURN $dst $offset",
719 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
721 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
723 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
724 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
726 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
727 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
728 "jmp\t{*}$dst # TAILCALL", []>;
730 //===----------------------------------------------------------------------===//
731 // Miscellaneous Instructions...
733 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
734 def LEAVE : I<0xC9, RawFrm,
735 (outs), (ins), "leave", []>;
737 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
739 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
741 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
742 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
744 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
746 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
747 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
750 let mayStore = 1 in {
751 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
753 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
754 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
756 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
758 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
759 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
763 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
764 def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
765 "push{l}\t$imm", []>;
766 def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
767 "push{l}\t$imm", []>;
768 def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
769 "push{l}\t$imm", []>;
772 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
773 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
774 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
775 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
777 let isTwoAddress = 1 in // GR32 = bswap GR32
778 def BSWAP32r : I<0xC8, AddRegFrm,
779 (outs GR32:$dst), (ins GR32:$src),
781 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
784 // Bit scan instructions.
785 let Defs = [EFLAGS] in {
786 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
787 "bsf{w}\t{$src, $dst|$dst, $src}",
788 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
789 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
790 "bsf{w}\t{$src, $dst|$dst, $src}",
791 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
792 (implicit EFLAGS)]>, TB;
793 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
794 "bsf{l}\t{$src, $dst|$dst, $src}",
795 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
796 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
797 "bsf{l}\t{$src, $dst|$dst, $src}",
798 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
799 (implicit EFLAGS)]>, TB;
801 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
802 "bsr{w}\t{$src, $dst|$dst, $src}",
803 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
804 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
805 "bsr{w}\t{$src, $dst|$dst, $src}",
806 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
807 (implicit EFLAGS)]>, TB;
808 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
809 "bsr{l}\t{$src, $dst|$dst, $src}",
810 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
811 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
812 "bsr{l}\t{$src, $dst|$dst, $src}",
813 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
814 (implicit EFLAGS)]>, TB;
817 let neverHasSideEffects = 1 in
818 def LEA16r : I<0x8D, MRMSrcMem,
819 (outs GR16:$dst), (ins i32mem:$src),
820 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
821 let isReMaterializable = 1 in
822 def LEA32r : I<0x8D, MRMSrcMem,
823 (outs GR32:$dst), (ins lea32mem:$src),
824 "lea{l}\t{$src|$dst}, {$dst|$src}",
825 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
827 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
828 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
829 [(X86rep_movs i8)]>, REP;
830 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
831 [(X86rep_movs i16)]>, REP, OpSize;
832 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
833 [(X86rep_movs i32)]>, REP;
836 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
837 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
838 [(X86rep_stos i8)]>, REP;
839 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
840 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
841 [(X86rep_stos i16)]>, REP, OpSize;
842 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
843 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
844 [(X86rep_stos i32)]>, REP;
846 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
847 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
848 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
850 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
851 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
852 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
854 let Defs = [RAX, RDX] in
855 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
858 let isBarrier = 1, hasCtrlDep = 1 in {
859 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
862 def SYSCALL : I<0x05, RawFrm,
863 (outs), (ins), "syscall", []>, TB;
864 def SYSRET : I<0x07, RawFrm,
865 (outs), (ins), "sysret", []>, TB;
866 def SYSENTER : I<0x34, RawFrm,
867 (outs), (ins), "sysenter", []>, TB;
868 def SYSEXIT : I<0x35, RawFrm,
869 (outs), (ins), "sysexit", []>, TB;
871 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
874 //===----------------------------------------------------------------------===//
875 // Input/Output Instructions...
877 let Defs = [AL], Uses = [DX] in
878 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
879 "in{b}\t{%dx, %al|%AL, %DX}", []>;
880 let Defs = [AX], Uses = [DX] in
881 def IN16rr : I<0xED, RawFrm, (outs), (ins),
882 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
883 let Defs = [EAX], Uses = [DX] in
884 def IN32rr : I<0xED, RawFrm, (outs), (ins),
885 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
888 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
889 "in{b}\t{$port, %al|%AL, $port}", []>;
891 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
892 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
894 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
895 "in{l}\t{$port, %eax|%EAX, $port}", []>;
897 let Uses = [DX, AL] in
898 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
899 "out{b}\t{%al, %dx|%DX, %AL}", []>;
900 let Uses = [DX, AX] in
901 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
902 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
903 let Uses = [DX, EAX] in
904 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
905 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
908 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
909 "out{b}\t{%al, $port|$port, %AL}", []>;
911 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
912 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
914 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
915 "out{l}\t{%eax, $port|$port, %EAX}", []>;
917 //===----------------------------------------------------------------------===//
918 // Move Instructions...
920 let neverHasSideEffects = 1 in {
921 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
922 "mov{b}\t{$src, $dst|$dst, $src}", []>;
923 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
924 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
925 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
926 "mov{l}\t{$src, $dst|$dst, $src}", []>;
928 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
929 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
930 "mov{b}\t{$src, $dst|$dst, $src}",
931 [(set GR8:$dst, imm:$src)]>;
932 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
933 "mov{w}\t{$src, $dst|$dst, $src}",
934 [(set GR16:$dst, imm:$src)]>, OpSize;
935 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
936 "mov{l}\t{$src, $dst|$dst, $src}",
937 [(set GR32:$dst, imm:$src)]>;
939 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
940 "mov{b}\t{$src, $dst|$dst, $src}",
941 [(store (i8 imm:$src), addr:$dst)]>;
942 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
943 "mov{w}\t{$src, $dst|$dst, $src}",
944 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
945 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
946 "mov{l}\t{$src, $dst|$dst, $src}",
947 [(store (i32 imm:$src), addr:$dst)]>;
949 def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins i8imm:$src),
950 "mov{b}\t{$src, %al|%al, $src}", []>;
951 def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins i16imm:$src),
952 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
953 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins i32imm:$src),
954 "mov{l}\t{$src, %eax|%eax, $src}", []>;
956 def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs i8imm:$dst), (ins),
957 "mov{b}\t{%al, $dst|$dst, %al}", []>;
958 def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs i16imm:$dst), (ins),
959 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
960 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs i32imm:$dst), (ins),
961 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
963 // Moves to and from segment registers
964 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
965 "mov{w}\t{$src, $dst|$dst, $src}", []>;
966 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
967 "mov{w}\t{$src, $dst|$dst, $src}", []>;
968 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
969 "mov{w}\t{$src, $dst|$dst, $src}", []>;
970 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
971 "mov{w}\t{$src, $dst|$dst, $src}", []>;
973 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
974 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
975 "mov{b}\t{$src, $dst|$dst, $src}",
976 [(set GR8:$dst, (loadi8 addr:$src))]>;
977 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
978 "mov{w}\t{$src, $dst|$dst, $src}",
979 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
980 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
981 "mov{l}\t{$src, $dst|$dst, $src}",
982 [(set GR32:$dst, (loadi32 addr:$src))]>;
985 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
986 "mov{b}\t{$src, $dst|$dst, $src}",
987 [(store GR8:$src, addr:$dst)]>;
988 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
989 "mov{w}\t{$src, $dst|$dst, $src}",
990 [(store GR16:$src, addr:$dst)]>, OpSize;
991 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
992 "mov{l}\t{$src, $dst|$dst, $src}",
993 [(store GR32:$src, addr:$dst)]>;
995 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
996 // that they can be used for copying and storing h registers, which can't be
997 // encoded when a REX prefix is present.
998 let neverHasSideEffects = 1 in
999 def MOV8rr_NOREX : I<0x88, MRMDestReg,
1000 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
1001 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1003 def MOV8mr_NOREX : I<0x88, MRMDestMem,
1004 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1005 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1007 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
1008 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1009 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1010 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1012 //===----------------------------------------------------------------------===//
1013 // Fixed-Register Multiplication and Division Instructions...
1016 // Extra precision multiplication
1017 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1018 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
1019 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1020 // This probably ought to be moved to a def : Pat<> if the
1021 // syntax can be accepted.
1022 [(set AL, (mul AL, GR8:$src)),
1023 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1025 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1026 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1028 []>, OpSize; // AX,DX = AX*GR16
1030 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1031 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1033 []>; // EAX,EDX = EAX*GR32
1035 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1036 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1038 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1039 // This probably ought to be moved to a def : Pat<> if the
1040 // syntax can be accepted.
1041 [(set AL, (mul AL, (loadi8 addr:$src))),
1042 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1044 let mayLoad = 1, neverHasSideEffects = 1 in {
1045 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1046 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1048 []>, OpSize; // AX,DX = AX*[mem16]
1050 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1051 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1053 []>; // EAX,EDX = EAX*[mem32]
1056 let neverHasSideEffects = 1 in {
1057 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1058 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1060 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1061 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
1062 OpSize; // AX,DX = AX*GR16
1063 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1064 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1065 // EAX,EDX = EAX*GR32
1066 let mayLoad = 1 in {
1067 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1068 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1069 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
1070 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1071 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1072 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1073 let Defs = [EAX,EDX], Uses = [EAX] in
1074 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1075 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
1077 } // neverHasSideEffects
1079 // unsigned division/remainder
1080 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1081 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1082 "div{b}\t$src", []>;
1083 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1084 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1085 "div{w}\t$src", []>, OpSize;
1086 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1087 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1088 "div{l}\t$src", []>;
1089 let mayLoad = 1 in {
1090 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1091 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1092 "div{b}\t$src", []>;
1093 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1094 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1095 "div{w}\t$src", []>, OpSize;
1096 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1097 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
1098 "div{l}\t$src", []>;
1101 // Signed division/remainder.
1102 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1103 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1104 "idiv{b}\t$src", []>;
1105 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1106 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1107 "idiv{w}\t$src", []>, OpSize;
1108 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1109 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1110 "idiv{l}\t$src", []>;
1111 let mayLoad = 1, mayLoad = 1 in {
1112 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1113 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1114 "idiv{b}\t$src", []>;
1115 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1116 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1117 "idiv{w}\t$src", []>, OpSize;
1118 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1119 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
1120 "idiv{l}\t$src", []>;
1123 //===----------------------------------------------------------------------===//
1124 // Two address Instructions.
1126 let isTwoAddress = 1 in {
1128 // Conditional moves
1129 let Uses = [EFLAGS] in {
1131 // X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1132 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1133 // however that requires promoting the operands, and can induce additional
1134 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1135 // clobber EFLAGS, because if one of the operands is zero, the expansion
1136 // could involve an xor.
1137 let usesCustomDAGSchedInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
1138 def CMOV_GR8 : I<0, Pseudo,
1139 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1140 "#CMOV_GR8 PSEUDO!",
1141 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1142 imm:$cond, EFLAGS))]>;
1144 let isCommutable = 1 in {
1145 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1146 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1147 "cmovb\t{$src2, $dst|$dst, $src2}",
1148 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1149 X86_COND_B, EFLAGS))]>,
1151 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1152 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1153 "cmovb\t{$src2, $dst|$dst, $src2}",
1154 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1155 X86_COND_B, EFLAGS))]>,
1157 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1158 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1159 "cmovae\t{$src2, $dst|$dst, $src2}",
1160 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1161 X86_COND_AE, EFLAGS))]>,
1163 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1164 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1165 "cmovae\t{$src2, $dst|$dst, $src2}",
1166 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1167 X86_COND_AE, EFLAGS))]>,
1169 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1170 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1171 "cmove\t{$src2, $dst|$dst, $src2}",
1172 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1173 X86_COND_E, EFLAGS))]>,
1175 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1176 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1177 "cmove\t{$src2, $dst|$dst, $src2}",
1178 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1179 X86_COND_E, EFLAGS))]>,
1181 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1182 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1183 "cmovne\t{$src2, $dst|$dst, $src2}",
1184 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1185 X86_COND_NE, EFLAGS))]>,
1187 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1188 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1189 "cmovne\t{$src2, $dst|$dst, $src2}",
1190 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1191 X86_COND_NE, EFLAGS))]>,
1193 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1194 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1195 "cmovbe\t{$src2, $dst|$dst, $src2}",
1196 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1197 X86_COND_BE, EFLAGS))]>,
1199 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1200 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1201 "cmovbe\t{$src2, $dst|$dst, $src2}",
1202 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1203 X86_COND_BE, EFLAGS))]>,
1205 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1206 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1207 "cmova\t{$src2, $dst|$dst, $src2}",
1208 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1209 X86_COND_A, EFLAGS))]>,
1211 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1212 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1213 "cmova\t{$src2, $dst|$dst, $src2}",
1214 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1215 X86_COND_A, EFLAGS))]>,
1217 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1218 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1219 "cmovl\t{$src2, $dst|$dst, $src2}",
1220 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1221 X86_COND_L, EFLAGS))]>,
1223 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1224 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1225 "cmovl\t{$src2, $dst|$dst, $src2}",
1226 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1227 X86_COND_L, EFLAGS))]>,
1229 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1230 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1231 "cmovge\t{$src2, $dst|$dst, $src2}",
1232 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1233 X86_COND_GE, EFLAGS))]>,
1235 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1236 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1237 "cmovge\t{$src2, $dst|$dst, $src2}",
1238 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1239 X86_COND_GE, EFLAGS))]>,
1241 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1242 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1243 "cmovle\t{$src2, $dst|$dst, $src2}",
1244 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1245 X86_COND_LE, EFLAGS))]>,
1247 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1248 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1249 "cmovle\t{$src2, $dst|$dst, $src2}",
1250 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1251 X86_COND_LE, EFLAGS))]>,
1253 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1254 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1255 "cmovg\t{$src2, $dst|$dst, $src2}",
1256 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1257 X86_COND_G, EFLAGS))]>,
1259 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1260 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1261 "cmovg\t{$src2, $dst|$dst, $src2}",
1262 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1263 X86_COND_G, EFLAGS))]>,
1265 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1266 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1267 "cmovs\t{$src2, $dst|$dst, $src2}",
1268 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1269 X86_COND_S, EFLAGS))]>,
1271 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1272 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1273 "cmovs\t{$src2, $dst|$dst, $src2}",
1274 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1275 X86_COND_S, EFLAGS))]>,
1277 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1278 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1279 "cmovns\t{$src2, $dst|$dst, $src2}",
1280 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1281 X86_COND_NS, EFLAGS))]>,
1283 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1284 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1285 "cmovns\t{$src2, $dst|$dst, $src2}",
1286 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1287 X86_COND_NS, EFLAGS))]>,
1289 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1290 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1291 "cmovp\t{$src2, $dst|$dst, $src2}",
1292 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1293 X86_COND_P, EFLAGS))]>,
1295 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1296 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1297 "cmovp\t{$src2, $dst|$dst, $src2}",
1298 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1299 X86_COND_P, EFLAGS))]>,
1301 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1302 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1303 "cmovnp\t{$src2, $dst|$dst, $src2}",
1304 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1305 X86_COND_NP, EFLAGS))]>,
1307 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1308 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1309 "cmovnp\t{$src2, $dst|$dst, $src2}",
1310 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1311 X86_COND_NP, EFLAGS))]>,
1313 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1314 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1315 "cmovo\t{$src2, $dst|$dst, $src2}",
1316 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1317 X86_COND_O, EFLAGS))]>,
1319 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1320 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1321 "cmovo\t{$src2, $dst|$dst, $src2}",
1322 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1323 X86_COND_O, EFLAGS))]>,
1325 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1326 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1327 "cmovno\t{$src2, $dst|$dst, $src2}",
1328 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1329 X86_COND_NO, EFLAGS))]>,
1331 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1332 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1333 "cmovno\t{$src2, $dst|$dst, $src2}",
1334 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1335 X86_COND_NO, EFLAGS))]>,
1337 } // isCommutable = 1
1339 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1340 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1341 "cmovb\t{$src2, $dst|$dst, $src2}",
1342 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1343 X86_COND_B, EFLAGS))]>,
1345 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1346 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1347 "cmovb\t{$src2, $dst|$dst, $src2}",
1348 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1349 X86_COND_B, EFLAGS))]>,
1351 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1352 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1353 "cmovae\t{$src2, $dst|$dst, $src2}",
1354 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1355 X86_COND_AE, EFLAGS))]>,
1357 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1358 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1359 "cmovae\t{$src2, $dst|$dst, $src2}",
1360 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1361 X86_COND_AE, EFLAGS))]>,
1363 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1364 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1365 "cmove\t{$src2, $dst|$dst, $src2}",
1366 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1367 X86_COND_E, EFLAGS))]>,
1369 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1370 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1371 "cmove\t{$src2, $dst|$dst, $src2}",
1372 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1373 X86_COND_E, EFLAGS))]>,
1375 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1376 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1377 "cmovne\t{$src2, $dst|$dst, $src2}",
1378 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1379 X86_COND_NE, EFLAGS))]>,
1381 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1382 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1383 "cmovne\t{$src2, $dst|$dst, $src2}",
1384 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1385 X86_COND_NE, EFLAGS))]>,
1387 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1388 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1389 "cmovbe\t{$src2, $dst|$dst, $src2}",
1390 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1391 X86_COND_BE, EFLAGS))]>,
1393 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1394 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1395 "cmovbe\t{$src2, $dst|$dst, $src2}",
1396 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1397 X86_COND_BE, EFLAGS))]>,
1399 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1400 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1401 "cmova\t{$src2, $dst|$dst, $src2}",
1402 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1403 X86_COND_A, EFLAGS))]>,
1405 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1406 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1407 "cmova\t{$src2, $dst|$dst, $src2}",
1408 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1409 X86_COND_A, EFLAGS))]>,
1411 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1412 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1413 "cmovl\t{$src2, $dst|$dst, $src2}",
1414 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1415 X86_COND_L, EFLAGS))]>,
1417 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1418 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1419 "cmovl\t{$src2, $dst|$dst, $src2}",
1420 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1421 X86_COND_L, EFLAGS))]>,
1423 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1424 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1425 "cmovge\t{$src2, $dst|$dst, $src2}",
1426 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1427 X86_COND_GE, EFLAGS))]>,
1429 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1430 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1431 "cmovge\t{$src2, $dst|$dst, $src2}",
1432 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1433 X86_COND_GE, EFLAGS))]>,
1435 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1436 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1437 "cmovle\t{$src2, $dst|$dst, $src2}",
1438 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1439 X86_COND_LE, EFLAGS))]>,
1441 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1442 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1443 "cmovle\t{$src2, $dst|$dst, $src2}",
1444 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1445 X86_COND_LE, EFLAGS))]>,
1447 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1448 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1449 "cmovg\t{$src2, $dst|$dst, $src2}",
1450 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1451 X86_COND_G, EFLAGS))]>,
1453 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1454 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1455 "cmovg\t{$src2, $dst|$dst, $src2}",
1456 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1457 X86_COND_G, EFLAGS))]>,
1459 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1460 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1461 "cmovs\t{$src2, $dst|$dst, $src2}",
1462 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1463 X86_COND_S, EFLAGS))]>,
1465 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1466 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1467 "cmovs\t{$src2, $dst|$dst, $src2}",
1468 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1469 X86_COND_S, EFLAGS))]>,
1471 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1472 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1473 "cmovns\t{$src2, $dst|$dst, $src2}",
1474 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1475 X86_COND_NS, EFLAGS))]>,
1477 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1478 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1479 "cmovns\t{$src2, $dst|$dst, $src2}",
1480 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1481 X86_COND_NS, EFLAGS))]>,
1483 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1484 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1485 "cmovp\t{$src2, $dst|$dst, $src2}",
1486 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1487 X86_COND_P, EFLAGS))]>,
1489 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1490 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1491 "cmovp\t{$src2, $dst|$dst, $src2}",
1492 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1493 X86_COND_P, EFLAGS))]>,
1495 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1496 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1497 "cmovnp\t{$src2, $dst|$dst, $src2}",
1498 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1499 X86_COND_NP, EFLAGS))]>,
1501 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1502 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1503 "cmovnp\t{$src2, $dst|$dst, $src2}",
1504 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1505 X86_COND_NP, EFLAGS))]>,
1507 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1508 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1509 "cmovo\t{$src2, $dst|$dst, $src2}",
1510 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1511 X86_COND_O, EFLAGS))]>,
1513 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1514 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1515 "cmovo\t{$src2, $dst|$dst, $src2}",
1516 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1517 X86_COND_O, EFLAGS))]>,
1519 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1520 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1521 "cmovno\t{$src2, $dst|$dst, $src2}",
1522 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1523 X86_COND_NO, EFLAGS))]>,
1525 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1526 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1527 "cmovno\t{$src2, $dst|$dst, $src2}",
1528 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1529 X86_COND_NO, EFLAGS))]>,
1531 } // Uses = [EFLAGS]
1534 // unary instructions
1535 let CodeSize = 2 in {
1536 let Defs = [EFLAGS] in {
1537 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1538 [(set GR8:$dst, (ineg GR8:$src)),
1539 (implicit EFLAGS)]>;
1540 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1541 [(set GR16:$dst, (ineg GR16:$src)),
1542 (implicit EFLAGS)]>, OpSize;
1543 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1544 [(set GR32:$dst, (ineg GR32:$src)),
1545 (implicit EFLAGS)]>;
1546 let isTwoAddress = 0 in {
1547 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1548 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1549 (implicit EFLAGS)]>;
1550 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1551 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1552 (implicit EFLAGS)]>, OpSize;
1553 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1554 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1555 (implicit EFLAGS)]>;
1557 } // Defs = [EFLAGS]
1559 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1560 let AddedComplexity = 15 in {
1561 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1562 [(set GR8:$dst, (not GR8:$src))]>;
1563 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1564 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1565 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1566 [(set GR32:$dst, (not GR32:$src))]>;
1568 let isTwoAddress = 0 in {
1569 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1570 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1571 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1572 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1573 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1574 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1578 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1579 let Defs = [EFLAGS] in {
1581 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1582 [(set GR8:$dst, (add GR8:$src, 1)),
1583 (implicit EFLAGS)]>;
1584 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1585 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1586 [(set GR16:$dst, (add GR16:$src, 1)),
1587 (implicit EFLAGS)]>,
1588 OpSize, Requires<[In32BitMode]>;
1589 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1590 [(set GR32:$dst, (add GR32:$src, 1)),
1591 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1593 let isTwoAddress = 0, CodeSize = 2 in {
1594 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1595 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1596 (implicit EFLAGS)]>;
1597 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1598 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1599 (implicit EFLAGS)]>,
1600 OpSize, Requires<[In32BitMode]>;
1601 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1602 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1603 (implicit EFLAGS)]>,
1604 Requires<[In32BitMode]>;
1608 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1609 [(set GR8:$dst, (add GR8:$src, -1)),
1610 (implicit EFLAGS)]>;
1611 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1612 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1613 [(set GR16:$dst, (add GR16:$src, -1)),
1614 (implicit EFLAGS)]>,
1615 OpSize, Requires<[In32BitMode]>;
1616 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1617 [(set GR32:$dst, (add GR32:$src, -1)),
1618 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1621 let isTwoAddress = 0, CodeSize = 2 in {
1622 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1623 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1624 (implicit EFLAGS)]>;
1625 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1626 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1627 (implicit EFLAGS)]>,
1628 OpSize, Requires<[In32BitMode]>;
1629 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1630 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1631 (implicit EFLAGS)]>,
1632 Requires<[In32BitMode]>;
1634 } // Defs = [EFLAGS]
1636 // Logical operators...
1637 let Defs = [EFLAGS] in {
1638 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1639 def AND8rr : I<0x20, MRMDestReg,
1640 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1641 "and{b}\t{$src2, $dst|$dst, $src2}",
1642 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1643 (implicit EFLAGS)]>;
1644 def AND16rr : I<0x21, MRMDestReg,
1645 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1646 "and{w}\t{$src2, $dst|$dst, $src2}",
1647 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1648 (implicit EFLAGS)]>, OpSize;
1649 def AND32rr : I<0x21, MRMDestReg,
1650 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1651 "and{l}\t{$src2, $dst|$dst, $src2}",
1652 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1653 (implicit EFLAGS)]>;
1656 def AND8rm : I<0x22, MRMSrcMem,
1657 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1658 "and{b}\t{$src2, $dst|$dst, $src2}",
1659 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1660 (implicit EFLAGS)]>;
1661 def AND16rm : I<0x23, MRMSrcMem,
1662 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1663 "and{w}\t{$src2, $dst|$dst, $src2}",
1664 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1665 (implicit EFLAGS)]>, OpSize;
1666 def AND32rm : I<0x23, MRMSrcMem,
1667 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1668 "and{l}\t{$src2, $dst|$dst, $src2}",
1669 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1670 (implicit EFLAGS)]>;
1672 def AND8ri : Ii8<0x80, MRM4r,
1673 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1674 "and{b}\t{$src2, $dst|$dst, $src2}",
1675 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1676 (implicit EFLAGS)]>;
1677 def AND16ri : Ii16<0x81, MRM4r,
1678 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1679 "and{w}\t{$src2, $dst|$dst, $src2}",
1680 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1681 (implicit EFLAGS)]>, OpSize;
1682 def AND32ri : Ii32<0x81, MRM4r,
1683 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1684 "and{l}\t{$src2, $dst|$dst, $src2}",
1685 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1686 (implicit EFLAGS)]>;
1687 def AND16ri8 : Ii8<0x83, MRM4r,
1688 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1689 "and{w}\t{$src2, $dst|$dst, $src2}",
1690 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1691 (implicit EFLAGS)]>,
1693 def AND32ri8 : Ii8<0x83, MRM4r,
1694 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1695 "and{l}\t{$src2, $dst|$dst, $src2}",
1696 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1697 (implicit EFLAGS)]>;
1699 let isTwoAddress = 0 in {
1700 def AND8mr : I<0x20, MRMDestMem,
1701 (outs), (ins i8mem :$dst, GR8 :$src),
1702 "and{b}\t{$src, $dst|$dst, $src}",
1703 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1704 (implicit EFLAGS)]>;
1705 def AND16mr : I<0x21, MRMDestMem,
1706 (outs), (ins i16mem:$dst, GR16:$src),
1707 "and{w}\t{$src, $dst|$dst, $src}",
1708 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1709 (implicit EFLAGS)]>,
1711 def AND32mr : I<0x21, MRMDestMem,
1712 (outs), (ins i32mem:$dst, GR32:$src),
1713 "and{l}\t{$src, $dst|$dst, $src}",
1714 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1715 (implicit EFLAGS)]>;
1716 def AND8mi : Ii8<0x80, MRM4m,
1717 (outs), (ins i8mem :$dst, i8imm :$src),
1718 "and{b}\t{$src, $dst|$dst, $src}",
1719 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1720 (implicit EFLAGS)]>;
1721 def AND16mi : Ii16<0x81, MRM4m,
1722 (outs), (ins i16mem:$dst, i16imm:$src),
1723 "and{w}\t{$src, $dst|$dst, $src}",
1724 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1725 (implicit EFLAGS)]>,
1727 def AND32mi : Ii32<0x81, MRM4m,
1728 (outs), (ins i32mem:$dst, i32imm:$src),
1729 "and{l}\t{$src, $dst|$dst, $src}",
1730 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1731 (implicit EFLAGS)]>;
1732 def AND16mi8 : Ii8<0x83, MRM4m,
1733 (outs), (ins i16mem:$dst, i16i8imm :$src),
1734 "and{w}\t{$src, $dst|$dst, $src}",
1735 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1736 (implicit EFLAGS)]>,
1738 def AND32mi8 : Ii8<0x83, MRM4m,
1739 (outs), (ins i32mem:$dst, i32i8imm :$src),
1740 "and{l}\t{$src, $dst|$dst, $src}",
1741 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1742 (implicit EFLAGS)]>;
1744 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1745 "and{b}\t{$src, %al|%al, $src}", []>;
1746 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1747 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1748 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1749 "and{l}\t{$src, %eax|%eax, $src}", []>;
1754 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1755 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1756 "or{b}\t{$src2, $dst|$dst, $src2}",
1757 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1758 (implicit EFLAGS)]>;
1759 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1760 "or{w}\t{$src2, $dst|$dst, $src2}",
1761 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1762 (implicit EFLAGS)]>, OpSize;
1763 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1764 "or{l}\t{$src2, $dst|$dst, $src2}",
1765 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1766 (implicit EFLAGS)]>;
1768 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1769 "or{b}\t{$src2, $dst|$dst, $src2}",
1770 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1771 (implicit EFLAGS)]>;
1772 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1773 "or{w}\t{$src2, $dst|$dst, $src2}",
1774 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1775 (implicit EFLAGS)]>, OpSize;
1776 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1777 "or{l}\t{$src2, $dst|$dst, $src2}",
1778 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1779 (implicit EFLAGS)]>;
1781 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1782 "or{b}\t{$src2, $dst|$dst, $src2}",
1783 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1784 (implicit EFLAGS)]>;
1785 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1786 "or{w}\t{$src2, $dst|$dst, $src2}",
1787 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1788 (implicit EFLAGS)]>, OpSize;
1789 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1790 "or{l}\t{$src2, $dst|$dst, $src2}",
1791 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1792 (implicit EFLAGS)]>;
1794 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1795 "or{w}\t{$src2, $dst|$dst, $src2}",
1796 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1797 (implicit EFLAGS)]>, OpSize;
1798 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1799 "or{l}\t{$src2, $dst|$dst, $src2}",
1800 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1801 (implicit EFLAGS)]>;
1802 let isTwoAddress = 0 in {
1803 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1804 "or{b}\t{$src, $dst|$dst, $src}",
1805 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1806 (implicit EFLAGS)]>;
1807 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1808 "or{w}\t{$src, $dst|$dst, $src}",
1809 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1810 (implicit EFLAGS)]>, OpSize;
1811 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1812 "or{l}\t{$src, $dst|$dst, $src}",
1813 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1814 (implicit EFLAGS)]>;
1815 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1816 "or{b}\t{$src, $dst|$dst, $src}",
1817 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1818 (implicit EFLAGS)]>;
1819 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1820 "or{w}\t{$src, $dst|$dst, $src}",
1821 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1822 (implicit EFLAGS)]>,
1824 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1825 "or{l}\t{$src, $dst|$dst, $src}",
1826 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1827 (implicit EFLAGS)]>;
1828 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1829 "or{w}\t{$src, $dst|$dst, $src}",
1830 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1831 (implicit EFLAGS)]>,
1833 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1834 "or{l}\t{$src, $dst|$dst, $src}",
1835 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1836 (implicit EFLAGS)]>;
1838 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1839 "or{b}\t{$src, %al|%al, $src}", []>;
1840 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1841 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1842 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1843 "or{l}\t{$src, %eax|%eax, $src}", []>;
1844 } // isTwoAddress = 0
1847 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1848 def XOR8rr : I<0x30, MRMDestReg,
1849 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1850 "xor{b}\t{$src2, $dst|$dst, $src2}",
1851 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1852 (implicit EFLAGS)]>;
1853 def XOR16rr : I<0x31, MRMDestReg,
1854 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1855 "xor{w}\t{$src2, $dst|$dst, $src2}",
1856 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1857 (implicit EFLAGS)]>, OpSize;
1858 def XOR32rr : I<0x31, MRMDestReg,
1859 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1860 "xor{l}\t{$src2, $dst|$dst, $src2}",
1861 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1862 (implicit EFLAGS)]>;
1863 } // isCommutable = 1
1865 def XOR8rm : I<0x32, MRMSrcMem ,
1866 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1867 "xor{b}\t{$src2, $dst|$dst, $src2}",
1868 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1869 (implicit EFLAGS)]>;
1870 def XOR16rm : I<0x33, MRMSrcMem ,
1871 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1872 "xor{w}\t{$src2, $dst|$dst, $src2}",
1873 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1874 (implicit EFLAGS)]>,
1876 def XOR32rm : I<0x33, MRMSrcMem ,
1877 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1878 "xor{l}\t{$src2, $dst|$dst, $src2}",
1879 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1880 (implicit EFLAGS)]>;
1882 def XOR8ri : Ii8<0x80, MRM6r,
1883 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1884 "xor{b}\t{$src2, $dst|$dst, $src2}",
1885 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1886 (implicit EFLAGS)]>;
1887 def XOR16ri : Ii16<0x81, MRM6r,
1888 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1889 "xor{w}\t{$src2, $dst|$dst, $src2}",
1890 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1891 (implicit EFLAGS)]>, OpSize;
1892 def XOR32ri : Ii32<0x81, MRM6r,
1893 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1894 "xor{l}\t{$src2, $dst|$dst, $src2}",
1895 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1896 (implicit EFLAGS)]>;
1897 def XOR16ri8 : Ii8<0x83, MRM6r,
1898 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1899 "xor{w}\t{$src2, $dst|$dst, $src2}",
1900 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1901 (implicit EFLAGS)]>,
1903 def XOR32ri8 : Ii8<0x83, MRM6r,
1904 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1905 "xor{l}\t{$src2, $dst|$dst, $src2}",
1906 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1907 (implicit EFLAGS)]>;
1909 let isTwoAddress = 0 in {
1910 def XOR8mr : I<0x30, MRMDestMem,
1911 (outs), (ins i8mem :$dst, GR8 :$src),
1912 "xor{b}\t{$src, $dst|$dst, $src}",
1913 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1914 (implicit EFLAGS)]>;
1915 def XOR16mr : I<0x31, MRMDestMem,
1916 (outs), (ins i16mem:$dst, GR16:$src),
1917 "xor{w}\t{$src, $dst|$dst, $src}",
1918 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1919 (implicit EFLAGS)]>,
1921 def XOR32mr : I<0x31, MRMDestMem,
1922 (outs), (ins i32mem:$dst, GR32:$src),
1923 "xor{l}\t{$src, $dst|$dst, $src}",
1924 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1925 (implicit EFLAGS)]>;
1926 def XOR8mi : Ii8<0x80, MRM6m,
1927 (outs), (ins i8mem :$dst, i8imm :$src),
1928 "xor{b}\t{$src, $dst|$dst, $src}",
1929 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1930 (implicit EFLAGS)]>;
1931 def XOR16mi : Ii16<0x81, MRM6m,
1932 (outs), (ins i16mem:$dst, i16imm:$src),
1933 "xor{w}\t{$src, $dst|$dst, $src}",
1934 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1935 (implicit EFLAGS)]>,
1937 def XOR32mi : Ii32<0x81, MRM6m,
1938 (outs), (ins i32mem:$dst, i32imm:$src),
1939 "xor{l}\t{$src, $dst|$dst, $src}",
1940 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1941 (implicit EFLAGS)]>;
1942 def XOR16mi8 : Ii8<0x83, MRM6m,
1943 (outs), (ins i16mem:$dst, i16i8imm :$src),
1944 "xor{w}\t{$src, $dst|$dst, $src}",
1945 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1946 (implicit EFLAGS)]>,
1948 def XOR32mi8 : Ii8<0x83, MRM6m,
1949 (outs), (ins i32mem:$dst, i32i8imm :$src),
1950 "xor{l}\t{$src, $dst|$dst, $src}",
1951 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1952 (implicit EFLAGS)]>;
1954 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1955 "xor{b}\t{$src, %al|%al, $src}", []>;
1956 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
1957 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1958 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
1959 "xor{l}\t{$src, %eax|%eax, $src}", []>;
1960 } // isTwoAddress = 0
1961 } // Defs = [EFLAGS]
1963 // Shift instructions
1964 let Defs = [EFLAGS] in {
1965 let Uses = [CL] in {
1966 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1967 "shl{b}\t{%cl, $dst|$dst, CL}",
1968 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1969 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1970 "shl{w}\t{%cl, $dst|$dst, CL}",
1971 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1972 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1973 "shl{l}\t{%cl, $dst|$dst, CL}",
1974 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1977 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1978 "shl{b}\t{$src2, $dst|$dst, $src2}",
1979 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1980 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1981 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1982 "shl{w}\t{$src2, $dst|$dst, $src2}",
1983 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1984 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1985 "shl{l}\t{$src2, $dst|$dst, $src2}",
1986 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1988 // NOTE: We don't include patterns for shifts of a register by one, because
1989 // 'add reg,reg' is cheaper.
1991 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
1992 "shl{b}\t$dst", []>;
1993 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1994 "shl{w}\t$dst", []>, OpSize;
1995 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1996 "shl{l}\t$dst", []>;
1998 } // isConvertibleToThreeAddress = 1
2000 let isTwoAddress = 0 in {
2001 let Uses = [CL] in {
2002 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
2003 "shl{b}\t{%cl, $dst|$dst, CL}",
2004 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
2005 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
2006 "shl{w}\t{%cl, $dst|$dst, CL}",
2007 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2008 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
2009 "shl{l}\t{%cl, $dst|$dst, CL}",
2010 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2012 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
2013 "shl{b}\t{$src, $dst|$dst, $src}",
2014 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2015 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
2016 "shl{w}\t{$src, $dst|$dst, $src}",
2017 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2019 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
2020 "shl{l}\t{$src, $dst|$dst, $src}",
2021 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2024 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2026 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2027 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2029 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2031 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2033 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2036 let Uses = [CL] in {
2037 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
2038 "shr{b}\t{%cl, $dst|$dst, CL}",
2039 [(set GR8:$dst, (srl GR8:$src, CL))]>;
2040 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
2041 "shr{w}\t{%cl, $dst|$dst, CL}",
2042 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
2043 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
2044 "shr{l}\t{%cl, $dst|$dst, CL}",
2045 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2048 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2049 "shr{b}\t{$src2, $dst|$dst, $src2}",
2050 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2051 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2052 "shr{w}\t{$src2, $dst|$dst, $src2}",
2053 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2054 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2055 "shr{l}\t{$src2, $dst|$dst, $src2}",
2056 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2059 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2061 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2062 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2064 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2065 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2067 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2069 let isTwoAddress = 0 in {
2070 let Uses = [CL] in {
2071 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2072 "shr{b}\t{%cl, $dst|$dst, CL}",
2073 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2074 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2075 "shr{w}\t{%cl, $dst|$dst, CL}",
2076 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2078 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2079 "shr{l}\t{%cl, $dst|$dst, CL}",
2080 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2082 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2083 "shr{b}\t{$src, $dst|$dst, $src}",
2084 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2085 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2086 "shr{w}\t{$src, $dst|$dst, $src}",
2087 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2089 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2090 "shr{l}\t{$src, $dst|$dst, $src}",
2091 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2094 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2096 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2097 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2099 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2100 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2102 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2105 let Uses = [CL] in {
2106 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
2107 "sar{b}\t{%cl, $dst|$dst, CL}",
2108 [(set GR8:$dst, (sra GR8:$src, CL))]>;
2109 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
2110 "sar{w}\t{%cl, $dst|$dst, CL}",
2111 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
2112 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
2113 "sar{l}\t{%cl, $dst|$dst, CL}",
2114 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2117 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2118 "sar{b}\t{$src2, $dst|$dst, $src2}",
2119 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2120 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2121 "sar{w}\t{$src2, $dst|$dst, $src2}",
2122 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2124 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2125 "sar{l}\t{$src2, $dst|$dst, $src2}",
2126 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2129 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2131 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2132 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2134 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2135 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2137 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2139 let isTwoAddress = 0 in {
2140 let Uses = [CL] in {
2141 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2142 "sar{b}\t{%cl, $dst|$dst, CL}",
2143 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2144 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2145 "sar{w}\t{%cl, $dst|$dst, CL}",
2146 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2147 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2148 "sar{l}\t{%cl, $dst|$dst, CL}",
2149 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2151 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2152 "sar{b}\t{$src, $dst|$dst, $src}",
2153 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2154 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2155 "sar{w}\t{$src, $dst|$dst, $src}",
2156 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2158 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2159 "sar{l}\t{$src, $dst|$dst, $src}",
2160 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2163 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2165 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2166 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2168 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2170 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2172 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2175 // Rotate instructions
2177 def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2178 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2179 def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2180 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2181 let Uses = [CL] in {
2182 def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2183 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2184 def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2185 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2187 def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2188 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2189 def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2190 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2192 def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2193 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2194 def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2195 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2196 let Uses = [CL] in {
2197 def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2198 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2199 def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2200 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2202 def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2203 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2204 def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src, i8imm:$cnt),
2205 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2207 def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2208 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2209 def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2210 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2211 let Uses = [CL] in {
2212 def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2213 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2214 def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2215 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2217 def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2218 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2219 def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src, i8imm:$cnt),
2220 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2222 def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2223 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2224 def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2225 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2226 let Uses = [CL] in {
2227 def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2228 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2229 def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2230 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2232 def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2233 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2234 def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2235 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2237 def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2238 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2239 def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2240 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2241 let Uses = [CL] in {
2242 def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2243 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2244 def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2245 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2247 def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2248 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2249 def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src, i8imm:$cnt),
2250 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2252 def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2253 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2254 def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2255 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2256 let Uses = [CL] in {
2257 def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2258 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2259 def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2260 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2262 def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2263 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2264 def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src, i8imm:$cnt),
2265 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2267 // FIXME: provide shorter instructions when imm8 == 1
2268 let Uses = [CL] in {
2269 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
2270 "rol{b}\t{%cl, $dst|$dst, CL}",
2271 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
2272 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
2273 "rol{w}\t{%cl, $dst|$dst, CL}",
2274 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
2275 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
2276 "rol{l}\t{%cl, $dst|$dst, CL}",
2277 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2280 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2281 "rol{b}\t{$src2, $dst|$dst, $src2}",
2282 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2283 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2284 "rol{w}\t{$src2, $dst|$dst, $src2}",
2285 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2286 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2287 "rol{l}\t{$src2, $dst|$dst, $src2}",
2288 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2291 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2293 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2294 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2296 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2297 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2299 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2301 let isTwoAddress = 0 in {
2302 let Uses = [CL] in {
2303 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2304 "rol{b}\t{%cl, $dst|$dst, CL}",
2305 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2306 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2307 "rol{w}\t{%cl, $dst|$dst, CL}",
2308 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2309 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2310 "rol{l}\t{%cl, $dst|$dst, CL}",
2311 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2313 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2314 "rol{b}\t{$src, $dst|$dst, $src}",
2315 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2316 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2317 "rol{w}\t{$src, $dst|$dst, $src}",
2318 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2320 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2321 "rol{l}\t{$src, $dst|$dst, $src}",
2322 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2325 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2327 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2328 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2330 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2332 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2334 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2337 let Uses = [CL] in {
2338 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2339 "ror{b}\t{%cl, $dst|$dst, CL}",
2340 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2341 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2342 "ror{w}\t{%cl, $dst|$dst, CL}",
2343 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2344 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2345 "ror{l}\t{%cl, $dst|$dst, CL}",
2346 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2349 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2350 "ror{b}\t{$src2, $dst|$dst, $src2}",
2351 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2352 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2353 "ror{w}\t{$src2, $dst|$dst, $src2}",
2354 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2355 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2356 "ror{l}\t{$src2, $dst|$dst, $src2}",
2357 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2360 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2362 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2363 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2365 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2366 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2368 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2370 let isTwoAddress = 0 in {
2371 let Uses = [CL] in {
2372 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2373 "ror{b}\t{%cl, $dst|$dst, CL}",
2374 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2375 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2376 "ror{w}\t{%cl, $dst|$dst, CL}",
2377 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2378 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2379 "ror{l}\t{%cl, $dst|$dst, CL}",
2380 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2382 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2383 "ror{b}\t{$src, $dst|$dst, $src}",
2384 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2385 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2386 "ror{w}\t{$src, $dst|$dst, $src}",
2387 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2389 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2390 "ror{l}\t{$src, $dst|$dst, $src}",
2391 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2394 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2396 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2397 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2399 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2401 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2403 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2408 // Double shift instructions (generalizations of rotate)
2409 let Uses = [CL] in {
2410 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2411 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2412 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2413 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2414 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2415 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2416 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2417 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2418 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2420 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2421 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2422 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2426 let isCommutable = 1 in { // These instructions commute to each other.
2427 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2428 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2429 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2430 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2433 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2434 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2435 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2436 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2439 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2440 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2441 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2442 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2445 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2446 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2447 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2448 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2453 let isTwoAddress = 0 in {
2454 let Uses = [CL] in {
2455 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2456 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2457 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2459 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2460 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2461 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2464 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2465 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2466 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2467 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2468 (i8 imm:$src3)), addr:$dst)]>,
2470 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2471 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2472 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2473 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2474 (i8 imm:$src3)), addr:$dst)]>,
2477 let Uses = [CL] in {
2478 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2479 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2480 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2481 addr:$dst)]>, TB, OpSize;
2482 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2483 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2484 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2485 addr:$dst)]>, TB, OpSize;
2487 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2488 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2489 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2490 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2491 (i8 imm:$src3)), addr:$dst)]>,
2493 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2494 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2495 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2496 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2497 (i8 imm:$src3)), addr:$dst)]>,
2500 } // Defs = [EFLAGS]
2504 let Defs = [EFLAGS] in {
2505 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2506 // Register-Register Addition
2507 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2508 (ins GR8 :$src1, GR8 :$src2),
2509 "add{b}\t{$src2, $dst|$dst, $src2}",
2510 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2511 (implicit EFLAGS)]>;
2513 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2514 // Register-Register Addition
2515 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2516 (ins GR16:$src1, GR16:$src2),
2517 "add{w}\t{$src2, $dst|$dst, $src2}",
2518 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2519 (implicit EFLAGS)]>, OpSize;
2520 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2521 (ins GR32:$src1, GR32:$src2),
2522 "add{l}\t{$src2, $dst|$dst, $src2}",
2523 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2524 (implicit EFLAGS)]>;
2525 } // end isConvertibleToThreeAddress
2526 } // end isCommutable
2528 // Register-Memory Addition
2529 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2530 (ins GR8 :$src1, i8mem :$src2),
2531 "add{b}\t{$src2, $dst|$dst, $src2}",
2532 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2533 (implicit EFLAGS)]>;
2534 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2535 (ins GR16:$src1, i16mem:$src2),
2536 "add{w}\t{$src2, $dst|$dst, $src2}",
2537 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2538 (implicit EFLAGS)]>, OpSize;
2539 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2540 (ins GR32:$src1, i32mem:$src2),
2541 "add{l}\t{$src2, $dst|$dst, $src2}",
2542 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2543 (implicit EFLAGS)]>;
2545 // Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2546 // ADD16rr, and ADD32rr), but differently encoded.
2547 def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2548 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2549 def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2550 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2551 def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2552 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2554 // Register-Integer Addition
2555 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2556 "add{b}\t{$src2, $dst|$dst, $src2}",
2557 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2558 (implicit EFLAGS)]>;
2560 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2561 // Register-Integer Addition
2562 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2563 (ins GR16:$src1, i16imm:$src2),
2564 "add{w}\t{$src2, $dst|$dst, $src2}",
2565 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2566 (implicit EFLAGS)]>, OpSize;
2567 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2568 (ins GR32:$src1, i32imm:$src2),
2569 "add{l}\t{$src2, $dst|$dst, $src2}",
2570 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2571 (implicit EFLAGS)]>;
2572 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2573 (ins GR16:$src1, i16i8imm:$src2),
2574 "add{w}\t{$src2, $dst|$dst, $src2}",
2575 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2576 (implicit EFLAGS)]>, OpSize;
2577 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2578 (ins GR32:$src1, i32i8imm:$src2),
2579 "add{l}\t{$src2, $dst|$dst, $src2}",
2580 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2581 (implicit EFLAGS)]>;
2584 let isTwoAddress = 0 in {
2585 // Memory-Register Addition
2586 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2587 "add{b}\t{$src2, $dst|$dst, $src2}",
2588 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2589 (implicit EFLAGS)]>;
2590 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2591 "add{w}\t{$src2, $dst|$dst, $src2}",
2592 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2593 (implicit EFLAGS)]>, OpSize;
2594 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2595 "add{l}\t{$src2, $dst|$dst, $src2}",
2596 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2597 (implicit EFLAGS)]>;
2598 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2599 "add{b}\t{$src2, $dst|$dst, $src2}",
2600 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2601 (implicit EFLAGS)]>;
2602 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2603 "add{w}\t{$src2, $dst|$dst, $src2}",
2604 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2605 (implicit EFLAGS)]>, OpSize;
2606 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2607 "add{l}\t{$src2, $dst|$dst, $src2}",
2608 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2609 (implicit EFLAGS)]>;
2610 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2611 "add{w}\t{$src2, $dst|$dst, $src2}",
2612 [(store (add (load addr:$dst), i16immSExt8:$src2),
2614 (implicit EFLAGS)]>, OpSize;
2615 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2616 "add{l}\t{$src2, $dst|$dst, $src2}",
2617 [(store (add (load addr:$dst), i32immSExt8:$src2),
2619 (implicit EFLAGS)]>;
2622 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2623 "add{b}\t{$src, %al|%al, $src}", []>;
2624 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2625 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2626 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2627 "add{l}\t{$src, %eax|%eax, $src}", []>;
2630 let Uses = [EFLAGS] in {
2631 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2632 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2633 "adc{b}\t{$src2, $dst|$dst, $src2}",
2634 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2635 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2636 (ins GR16:$src1, GR16:$src2),
2637 "adc{w}\t{$src2, $dst|$dst, $src2}",
2638 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2639 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2640 (ins GR32:$src1, GR32:$src2),
2641 "adc{l}\t{$src2, $dst|$dst, $src2}",
2642 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2644 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2645 (ins GR8:$src1, i8mem:$src2),
2646 "adc{b}\t{$src2, $dst|$dst, $src2}",
2647 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2648 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2649 (ins GR16:$src1, i16mem:$src2),
2650 "adc{w}\t{$src2, $dst|$dst, $src2}",
2651 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2653 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2654 (ins GR32:$src1, i32mem:$src2),
2655 "adc{l}\t{$src2, $dst|$dst, $src2}",
2656 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2657 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2658 "adc{b}\t{$src2, $dst|$dst, $src2}",
2659 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2660 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2661 (ins GR16:$src1, i16imm:$src2),
2662 "adc{w}\t{$src2, $dst|$dst, $src2}",
2663 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2664 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2665 (ins GR16:$src1, i16i8imm:$src2),
2666 "adc{w}\t{$src2, $dst|$dst, $src2}",
2667 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2669 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2670 (ins GR32:$src1, i32imm:$src2),
2671 "adc{l}\t{$src2, $dst|$dst, $src2}",
2672 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2673 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2674 (ins GR32:$src1, i32i8imm:$src2),
2675 "adc{l}\t{$src2, $dst|$dst, $src2}",
2676 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2678 let isTwoAddress = 0 in {
2679 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2680 "adc{b}\t{$src2, $dst|$dst, $src2}",
2681 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2682 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2683 "adc{w}\t{$src2, $dst|$dst, $src2}",
2684 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2686 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2687 "adc{l}\t{$src2, $dst|$dst, $src2}",
2688 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2689 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2690 "adc{b}\t{$src2, $dst|$dst, $src2}",
2691 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2692 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2693 "adc{w}\t{$src2, $dst|$dst, $src2}",
2694 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2696 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2697 "adc{w}\t{$src2, $dst|$dst, $src2}",
2698 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2700 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2701 "adc{l}\t{$src2, $dst|$dst, $src2}",
2702 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2703 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2704 "adc{l}\t{$src2, $dst|$dst, $src2}",
2705 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2707 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2708 "adc{b}\t{$src, %al|%al, $src}", []>;
2709 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2710 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2711 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2712 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2714 } // Uses = [EFLAGS]
2716 // Register-Register Subtraction
2717 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2718 "sub{b}\t{$src2, $dst|$dst, $src2}",
2719 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2720 (implicit EFLAGS)]>;
2721 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2722 "sub{w}\t{$src2, $dst|$dst, $src2}",
2723 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2724 (implicit EFLAGS)]>, OpSize;
2725 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2726 "sub{l}\t{$src2, $dst|$dst, $src2}",
2727 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2728 (implicit EFLAGS)]>;
2730 // Register-Memory Subtraction
2731 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2732 (ins GR8 :$src1, i8mem :$src2),
2733 "sub{b}\t{$src2, $dst|$dst, $src2}",
2734 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2735 (implicit EFLAGS)]>;
2736 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2737 (ins GR16:$src1, i16mem:$src2),
2738 "sub{w}\t{$src2, $dst|$dst, $src2}",
2739 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2740 (implicit EFLAGS)]>, OpSize;
2741 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2742 (ins GR32:$src1, i32mem:$src2),
2743 "sub{l}\t{$src2, $dst|$dst, $src2}",
2744 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2745 (implicit EFLAGS)]>;
2747 // Register-Integer Subtraction
2748 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2749 (ins GR8:$src1, i8imm:$src2),
2750 "sub{b}\t{$src2, $dst|$dst, $src2}",
2751 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2752 (implicit EFLAGS)]>;
2753 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2754 (ins GR16:$src1, i16imm:$src2),
2755 "sub{w}\t{$src2, $dst|$dst, $src2}",
2756 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2757 (implicit EFLAGS)]>, OpSize;
2758 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2759 (ins GR32:$src1, i32imm:$src2),
2760 "sub{l}\t{$src2, $dst|$dst, $src2}",
2761 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2762 (implicit EFLAGS)]>;
2763 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2764 (ins GR16:$src1, i16i8imm:$src2),
2765 "sub{w}\t{$src2, $dst|$dst, $src2}",
2766 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2767 (implicit EFLAGS)]>, OpSize;
2768 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2769 (ins GR32:$src1, i32i8imm:$src2),
2770 "sub{l}\t{$src2, $dst|$dst, $src2}",
2771 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2772 (implicit EFLAGS)]>;
2774 let isTwoAddress = 0 in {
2775 // Memory-Register Subtraction
2776 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2777 "sub{b}\t{$src2, $dst|$dst, $src2}",
2778 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2779 (implicit EFLAGS)]>;
2780 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2781 "sub{w}\t{$src2, $dst|$dst, $src2}",
2782 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2783 (implicit EFLAGS)]>, OpSize;
2784 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2785 "sub{l}\t{$src2, $dst|$dst, $src2}",
2786 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2787 (implicit EFLAGS)]>;
2789 // Memory-Integer Subtraction
2790 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2791 "sub{b}\t{$src2, $dst|$dst, $src2}",
2792 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2793 (implicit EFLAGS)]>;
2794 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2795 "sub{w}\t{$src2, $dst|$dst, $src2}",
2796 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2797 (implicit EFLAGS)]>, OpSize;
2798 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2799 "sub{l}\t{$src2, $dst|$dst, $src2}",
2800 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2801 (implicit EFLAGS)]>;
2802 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2803 "sub{w}\t{$src2, $dst|$dst, $src2}",
2804 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2806 (implicit EFLAGS)]>, OpSize;
2807 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2808 "sub{l}\t{$src2, $dst|$dst, $src2}",
2809 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2811 (implicit EFLAGS)]>;
2813 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2814 "sub{b}\t{$src, %al|%al, $src}", []>;
2815 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2816 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2817 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2818 "sub{l}\t{$src, %eax|%eax, $src}", []>;
2821 let Uses = [EFLAGS] in {
2822 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2823 (ins GR8:$src1, GR8:$src2),
2824 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2825 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2826 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2827 (ins GR16:$src1, GR16:$src2),
2828 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2829 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2830 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2831 (ins GR32:$src1, GR32:$src2),
2832 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2833 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2835 let isTwoAddress = 0 in {
2836 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2837 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2838 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2839 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2840 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2841 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2843 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2844 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2845 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2846 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2847 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2848 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2849 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2850 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2851 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2853 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2854 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2855 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2857 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2858 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2859 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2860 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2861 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2862 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2864 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2865 "sbb{b}\t{$src, %al|%al, $src}", []>;
2866 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2867 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2868 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2869 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
2871 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2872 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2873 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2874 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2875 (ins GR16:$src1, i16mem:$src2),
2876 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2877 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2879 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2880 (ins GR32:$src1, i32mem:$src2),
2881 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2882 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2883 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2884 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2885 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2886 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2887 (ins GR16:$src1, i16imm:$src2),
2888 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2889 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2890 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2891 (ins GR16:$src1, i16i8imm:$src2),
2892 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2893 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2895 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2896 (ins GR32:$src1, i32imm:$src2),
2897 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2898 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2899 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2900 (ins GR32:$src1, i32i8imm:$src2),
2901 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2902 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2903 } // Uses = [EFLAGS]
2904 } // Defs = [EFLAGS]
2906 let Defs = [EFLAGS] in {
2907 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2908 // Register-Register Signed Integer Multiply
2909 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2910 "imul{w}\t{$src2, $dst|$dst, $src2}",
2911 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2912 (implicit EFLAGS)]>, TB, OpSize;
2913 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2914 "imul{l}\t{$src2, $dst|$dst, $src2}",
2915 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2916 (implicit EFLAGS)]>, TB;
2919 // Register-Memory Signed Integer Multiply
2920 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2921 (ins GR16:$src1, i16mem:$src2),
2922 "imul{w}\t{$src2, $dst|$dst, $src2}",
2923 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2924 (implicit EFLAGS)]>, TB, OpSize;
2925 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2926 "imul{l}\t{$src2, $dst|$dst, $src2}",
2927 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2928 (implicit EFLAGS)]>, TB;
2929 } // Defs = [EFLAGS]
2930 } // end Two Address instructions
2932 // Suprisingly enough, these are not two address instructions!
2933 let Defs = [EFLAGS] in {
2934 // Register-Integer Signed Integer Multiply
2935 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2936 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2937 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2938 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2939 (implicit EFLAGS)]>, OpSize;
2940 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2941 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2942 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2943 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2944 (implicit EFLAGS)]>;
2945 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2946 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2947 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2948 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2949 (implicit EFLAGS)]>, OpSize;
2950 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2951 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2952 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2953 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2954 (implicit EFLAGS)]>;
2956 // Memory-Integer Signed Integer Multiply
2957 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2958 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2959 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2960 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2961 (implicit EFLAGS)]>, OpSize;
2962 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2963 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2964 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2965 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2966 (implicit EFLAGS)]>;
2967 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2968 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2969 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2970 [(set GR16:$dst, (mul (load addr:$src1),
2971 i16immSExt8:$src2)),
2972 (implicit EFLAGS)]>, OpSize;
2973 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2974 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2975 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2976 [(set GR32:$dst, (mul (load addr:$src1),
2977 i32immSExt8:$src2)),
2978 (implicit EFLAGS)]>;
2979 } // Defs = [EFLAGS]
2981 //===----------------------------------------------------------------------===//
2982 // Test instructions are just like AND, except they don't generate a result.
2984 let Defs = [EFLAGS] in {
2985 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2986 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2987 "test{b}\t{$src2, $src1|$src1, $src2}",
2988 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2989 (implicit EFLAGS)]>;
2990 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2991 "test{w}\t{$src2, $src1|$src1, $src2}",
2992 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2993 (implicit EFLAGS)]>,
2995 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2996 "test{l}\t{$src2, $src1|$src1, $src2}",
2997 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2998 (implicit EFLAGS)]>;
3001 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3002 "test{b}\t{$src, %al|%al, $src}", []>;
3003 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3004 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3005 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3006 "test{l}\t{$src, %eax|%eax, $src}", []>;
3008 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
3009 "test{b}\t{$src2, $src1|$src1, $src2}",
3010 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3011 (implicit EFLAGS)]>;
3012 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
3013 "test{w}\t{$src2, $src1|$src1, $src2}",
3014 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3015 (implicit EFLAGS)]>, OpSize;
3016 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
3017 "test{l}\t{$src2, $src1|$src1, $src2}",
3018 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3019 (implicit EFLAGS)]>;
3021 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
3022 (outs), (ins GR8:$src1, i8imm:$src2),
3023 "test{b}\t{$src2, $src1|$src1, $src2}",
3024 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
3025 (implicit EFLAGS)]>;
3026 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
3027 (outs), (ins GR16:$src1, i16imm:$src2),
3028 "test{w}\t{$src2, $src1|$src1, $src2}",
3029 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
3030 (implicit EFLAGS)]>, OpSize;
3031 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
3032 (outs), (ins GR32:$src1, i32imm:$src2),
3033 "test{l}\t{$src2, $src1|$src1, $src2}",
3034 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
3035 (implicit EFLAGS)]>;
3037 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
3038 (outs), (ins i8mem:$src1, i8imm:$src2),
3039 "test{b}\t{$src2, $src1|$src1, $src2}",
3040 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3041 (implicit EFLAGS)]>;
3042 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
3043 (outs), (ins i16mem:$src1, i16imm:$src2),
3044 "test{w}\t{$src2, $src1|$src1, $src2}",
3045 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3046 (implicit EFLAGS)]>, OpSize;
3047 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
3048 (outs), (ins i32mem:$src1, i32imm:$src2),
3049 "test{l}\t{$src2, $src1|$src1, $src2}",
3050 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
3051 (implicit EFLAGS)]>;
3052 } // Defs = [EFLAGS]
3055 // Condition code ops, incl. set if equal/not equal/...
3056 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
3057 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
3058 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
3059 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
3061 let Uses = [EFLAGS] in {
3062 def SETEr : I<0x94, MRM0r,
3063 (outs GR8 :$dst), (ins),
3065 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
3067 def SETEm : I<0x94, MRM0m,
3068 (outs), (ins i8mem:$dst),
3070 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
3073 def SETNEr : I<0x95, MRM0r,
3074 (outs GR8 :$dst), (ins),
3076 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
3078 def SETNEm : I<0x95, MRM0m,
3079 (outs), (ins i8mem:$dst),
3081 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
3084 def SETLr : I<0x9C, MRM0r,
3085 (outs GR8 :$dst), (ins),
3087 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
3088 TB; // GR8 = < signed
3089 def SETLm : I<0x9C, MRM0m,
3090 (outs), (ins i8mem:$dst),
3092 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
3093 TB; // [mem8] = < signed
3095 def SETGEr : I<0x9D, MRM0r,
3096 (outs GR8 :$dst), (ins),
3098 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
3099 TB; // GR8 = >= signed
3100 def SETGEm : I<0x9D, MRM0m,
3101 (outs), (ins i8mem:$dst),
3103 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
3104 TB; // [mem8] = >= signed
3106 def SETLEr : I<0x9E, MRM0r,
3107 (outs GR8 :$dst), (ins),
3109 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3110 TB; // GR8 = <= signed
3111 def SETLEm : I<0x9E, MRM0m,
3112 (outs), (ins i8mem:$dst),
3114 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3115 TB; // [mem8] = <= signed
3117 def SETGr : I<0x9F, MRM0r,
3118 (outs GR8 :$dst), (ins),
3120 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3121 TB; // GR8 = > signed
3122 def SETGm : I<0x9F, MRM0m,
3123 (outs), (ins i8mem:$dst),
3125 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3126 TB; // [mem8] = > signed
3128 def SETBr : I<0x92, MRM0r,
3129 (outs GR8 :$dst), (ins),
3131 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3132 TB; // GR8 = < unsign
3133 def SETBm : I<0x92, MRM0m,
3134 (outs), (ins i8mem:$dst),
3136 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3137 TB; // [mem8] = < unsign
3139 def SETAEr : I<0x93, MRM0r,
3140 (outs GR8 :$dst), (ins),
3142 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3143 TB; // GR8 = >= unsign
3144 def SETAEm : I<0x93, MRM0m,
3145 (outs), (ins i8mem:$dst),
3147 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3148 TB; // [mem8] = >= unsign
3150 def SETBEr : I<0x96, MRM0r,
3151 (outs GR8 :$dst), (ins),
3153 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3154 TB; // GR8 = <= unsign
3155 def SETBEm : I<0x96, MRM0m,
3156 (outs), (ins i8mem:$dst),
3158 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3159 TB; // [mem8] = <= unsign
3161 def SETAr : I<0x97, MRM0r,
3162 (outs GR8 :$dst), (ins),
3164 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3165 TB; // GR8 = > signed
3166 def SETAm : I<0x97, MRM0m,
3167 (outs), (ins i8mem:$dst),
3169 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3170 TB; // [mem8] = > signed
3172 def SETSr : I<0x98, MRM0r,
3173 (outs GR8 :$dst), (ins),
3175 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3176 TB; // GR8 = <sign bit>
3177 def SETSm : I<0x98, MRM0m,
3178 (outs), (ins i8mem:$dst),
3180 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3181 TB; // [mem8] = <sign bit>
3182 def SETNSr : I<0x99, MRM0r,
3183 (outs GR8 :$dst), (ins),
3185 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3186 TB; // GR8 = !<sign bit>
3187 def SETNSm : I<0x99, MRM0m,
3188 (outs), (ins i8mem:$dst),
3190 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3191 TB; // [mem8] = !<sign bit>
3193 def SETPr : I<0x9A, MRM0r,
3194 (outs GR8 :$dst), (ins),
3196 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3198 def SETPm : I<0x9A, MRM0m,
3199 (outs), (ins i8mem:$dst),
3201 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3202 TB; // [mem8] = parity
3203 def SETNPr : I<0x9B, MRM0r,
3204 (outs GR8 :$dst), (ins),
3206 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3207 TB; // GR8 = not parity
3208 def SETNPm : I<0x9B, MRM0m,
3209 (outs), (ins i8mem:$dst),
3211 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3212 TB; // [mem8] = not parity
3214 def SETOr : I<0x90, MRM0r,
3215 (outs GR8 :$dst), (ins),
3217 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3218 TB; // GR8 = overflow
3219 def SETOm : I<0x90, MRM0m,
3220 (outs), (ins i8mem:$dst),
3222 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3223 TB; // [mem8] = overflow
3224 def SETNOr : I<0x91, MRM0r,
3225 (outs GR8 :$dst), (ins),
3227 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3228 TB; // GR8 = not overflow
3229 def SETNOm : I<0x91, MRM0m,
3230 (outs), (ins i8mem:$dst),
3232 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3233 TB; // [mem8] = not overflow
3234 } // Uses = [EFLAGS]
3237 // Integer comparisons
3238 let Defs = [EFLAGS] in {
3239 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3240 "cmp{b}\t{$src, %al|%al, $src}", []>;
3241 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3242 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3243 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3244 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3246 def CMP8rr : I<0x38, MRMDestReg,
3247 (outs), (ins GR8 :$src1, GR8 :$src2),
3248 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3249 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
3250 def CMP16rr : I<0x39, MRMDestReg,
3251 (outs), (ins GR16:$src1, GR16:$src2),
3252 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3253 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
3254 def CMP32rr : I<0x39, MRMDestReg,
3255 (outs), (ins GR32:$src1, GR32:$src2),
3256 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3257 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
3258 def CMP8mr : I<0x38, MRMDestMem,
3259 (outs), (ins i8mem :$src1, GR8 :$src2),
3260 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3261 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3262 (implicit EFLAGS)]>;
3263 def CMP16mr : I<0x39, MRMDestMem,
3264 (outs), (ins i16mem:$src1, GR16:$src2),
3265 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3266 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3267 (implicit EFLAGS)]>, OpSize;
3268 def CMP32mr : I<0x39, MRMDestMem,
3269 (outs), (ins i32mem:$src1, GR32:$src2),
3270 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3271 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3272 (implicit EFLAGS)]>;
3273 def CMP8rm : I<0x3A, MRMSrcMem,
3274 (outs), (ins GR8 :$src1, i8mem :$src2),
3275 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3276 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3277 (implicit EFLAGS)]>;
3278 def CMP16rm : I<0x3B, MRMSrcMem,
3279 (outs), (ins GR16:$src1, i16mem:$src2),
3280 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3281 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3282 (implicit EFLAGS)]>, OpSize;
3283 def CMP32rm : I<0x3B, MRMSrcMem,
3284 (outs), (ins GR32:$src1, i32mem:$src2),
3285 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3286 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3287 (implicit EFLAGS)]>;
3288 def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3289 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3290 def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3291 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3292 def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3293 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3294 def CMP8ri : Ii8<0x80, MRM7r,
3295 (outs), (ins GR8:$src1, i8imm:$src2),
3296 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3297 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
3298 def CMP16ri : Ii16<0x81, MRM7r,
3299 (outs), (ins GR16:$src1, i16imm:$src2),
3300 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3301 [(X86cmp GR16:$src1, imm:$src2),
3302 (implicit EFLAGS)]>, OpSize;
3303 def CMP32ri : Ii32<0x81, MRM7r,
3304 (outs), (ins GR32:$src1, i32imm:$src2),
3305 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3306 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
3307 def CMP8mi : Ii8 <0x80, MRM7m,
3308 (outs), (ins i8mem :$src1, i8imm :$src2),
3309 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3310 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3311 (implicit EFLAGS)]>;
3312 def CMP16mi : Ii16<0x81, MRM7m,
3313 (outs), (ins i16mem:$src1, i16imm:$src2),
3314 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3315 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3316 (implicit EFLAGS)]>, OpSize;
3317 def CMP32mi : Ii32<0x81, MRM7m,
3318 (outs), (ins i32mem:$src1, i32imm:$src2),
3319 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3320 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3321 (implicit EFLAGS)]>;
3322 def CMP16ri8 : Ii8<0x83, MRM7r,
3323 (outs), (ins GR16:$src1, i16i8imm:$src2),
3324 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3325 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3326 (implicit EFLAGS)]>, OpSize;
3327 def CMP16mi8 : Ii8<0x83, MRM7m,
3328 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3329 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3330 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3331 (implicit EFLAGS)]>, OpSize;
3332 def CMP32mi8 : Ii8<0x83, MRM7m,
3333 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3334 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3335 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3336 (implicit EFLAGS)]>;
3337 def CMP32ri8 : Ii8<0x83, MRM7r,
3338 (outs), (ins GR32:$src1, i32i8imm:$src2),
3339 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3340 [(X86cmp GR32:$src1, i32immSExt8:$src2),
3341 (implicit EFLAGS)]>;
3342 } // Defs = [EFLAGS]
3345 // TODO: BTC, BTR, and BTS
3346 let Defs = [EFLAGS] in {
3347 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3348 "bt{w}\t{$src2, $src1|$src1, $src2}",
3349 [(X86bt GR16:$src1, GR16:$src2),
3350 (implicit EFLAGS)]>, OpSize, TB;
3351 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3352 "bt{l}\t{$src2, $src1|$src1, $src2}",
3353 [(X86bt GR32:$src1, GR32:$src2),
3354 (implicit EFLAGS)]>, TB;
3356 // Unlike with the register+register form, the memory+register form of the
3357 // bt instruction does not ignore the high bits of the index. From ISel's
3358 // perspective, this is pretty bizarre. Disable these instructions for now.
3359 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3360 // "bt{w}\t{$src2, $src1|$src1, $src2}",
3361 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3362 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3363 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3364 // "bt{l}\t{$src2, $src1|$src1, $src2}",
3365 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3366 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
3368 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3369 "bt{w}\t{$src2, $src1|$src1, $src2}",
3370 [(X86bt GR16:$src1, i16immSExt8:$src2),
3371 (implicit EFLAGS)]>, OpSize, TB;
3372 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3373 "bt{l}\t{$src2, $src1|$src1, $src2}",
3374 [(X86bt GR32:$src1, i32immSExt8:$src2),
3375 (implicit EFLAGS)]>, TB;
3376 // Note that these instructions don't need FastBTMem because that
3377 // only applies when the other operand is in a register. When it's
3378 // an immediate, bt is still fast.
3379 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3380 "bt{w}\t{$src2, $src1|$src1, $src2}",
3381 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3382 (implicit EFLAGS)]>, OpSize, TB;
3383 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3384 "bt{l}\t{$src2, $src1|$src1, $src2}",
3385 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3386 (implicit EFLAGS)]>, TB;
3387 } // Defs = [EFLAGS]
3389 // Sign/Zero extenders
3390 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3391 // of the register here. This has a smaller encoding and avoids a
3392 // partial-register update.
3393 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3394 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3395 [(set GR16:$dst, (sext GR8:$src))]>, TB;
3396 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3397 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3398 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3399 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3400 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3401 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3402 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3403 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3404 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3405 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3406 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3407 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3408 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3409 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3410 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3412 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3413 // of the register here. This has a smaller encoding and avoids a
3414 // partial-register update.
3415 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3416 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3417 [(set GR16:$dst, (zext GR8:$src))]>, TB;
3418 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3419 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3420 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3421 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3422 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3423 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3424 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3425 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3426 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3427 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3428 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3429 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3430 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3431 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3432 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3434 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3435 // except that they use GR32_NOREX for the output operand register class
3436 // instead of GR32. This allows them to operate on h registers on x86-64.
3437 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3438 (outs GR32_NOREX:$dst), (ins GR8:$src),
3439 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3442 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3443 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3444 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3447 let neverHasSideEffects = 1 in {
3448 let Defs = [AX], Uses = [AL] in
3449 def CBW : I<0x98, RawFrm, (outs), (ins),
3450 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3451 let Defs = [EAX], Uses = [AX] in
3452 def CWDE : I<0x98, RawFrm, (outs), (ins),
3453 "{cwtl|cwde}", []>; // EAX = signext(AX)
3455 let Defs = [AX,DX], Uses = [AX] in
3456 def CWD : I<0x99, RawFrm, (outs), (ins),
3457 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3458 let Defs = [EAX,EDX], Uses = [EAX] in
3459 def CDQ : I<0x99, RawFrm, (outs), (ins),
3460 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3463 //===----------------------------------------------------------------------===//
3464 // Alias Instructions
3465 //===----------------------------------------------------------------------===//
3467 // Alias instructions that map movr0 to xor.
3468 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3469 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3470 isCodeGenOnly = 1 in {
3471 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
3472 "xor{b}\t$dst, $dst",
3473 [(set GR8:$dst, 0)]>;
3474 // Use xorl instead of xorw since we don't care about the high 16 bits,
3475 // it's smaller, and it avoids a partial-register update.
3476 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3477 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3478 [(set GR16:$dst, 0)]>;
3479 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3480 "xor{l}\t$dst, $dst",
3481 [(set GR32:$dst, 0)]>;
3484 //===----------------------------------------------------------------------===//
3485 // Thread Local Storage Instructions
3488 // All calls clobber the non-callee saved registers. ESP is marked as
3489 // a use to prevent stack-pointer assignments that appear immediately
3490 // before calls from potentially appearing dead.
3491 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3492 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3493 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3494 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3496 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3497 "leal\t$sym, %eax; "
3498 "call\t___tls_get_addr@PLT",
3499 [(X86tlsaddr tls32addr:$sym)]>,
3500 Requires<[In32BitMode]>;
3502 let AddedComplexity = 5, isCodeGenOnly = 1 in
3503 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3504 "movl\t%gs:$src, $dst",
3505 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3507 let AddedComplexity = 5, isCodeGenOnly = 1 in
3508 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3509 "movl\t%fs:$src, $dst",
3510 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3512 //===----------------------------------------------------------------------===//
3513 // DWARF Pseudo Instructions
3516 def DWARF_LOC : I<0, Pseudo, (outs),
3517 (ins i32imm:$line, i32imm:$col, i32imm:$file),
3518 ".loc\t$file $line $col",
3519 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3522 //===----------------------------------------------------------------------===//
3523 // EH Pseudo Instructions
3525 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3526 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3527 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3528 "ret\t#eh_return, addr: $addr",
3529 [(X86ehret GR32:$addr)]>;
3533 //===----------------------------------------------------------------------===//
3537 // Atomic swap. These are just normal xchg instructions. But since a memory
3538 // operand is referenced, the atomicity is ensured.
3539 let Constraints = "$val = $dst" in {
3540 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3541 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3542 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3543 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3544 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3545 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3547 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3548 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3549 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3552 // Atomic compare and swap.
3553 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3554 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3556 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3557 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3559 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3560 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3563 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3566 let Defs = [AX, EFLAGS], Uses = [AX] in {
3567 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3569 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3570 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3572 let Defs = [AL, EFLAGS], Uses = [AL] in {
3573 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3575 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3576 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3579 // Atomic exchange and add
3580 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3581 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3583 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3584 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3586 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3588 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3589 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3591 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3593 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3594 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3598 // Optimized codegen when the non-memory output is not used.
3599 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3600 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3602 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3603 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3605 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3606 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3608 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3609 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3611 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3612 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3614 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3615 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3617 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3618 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3620 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3621 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3623 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3625 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3627 "inc{b}\t$dst", []>, LOCK;
3628 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3630 "inc{w}\t$dst", []>, OpSize, LOCK;
3631 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3633 "inc{l}\t$dst", []>, LOCK;
3635 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3637 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3638 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3640 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3641 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3643 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3644 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3646 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3647 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3649 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3650 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3652 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3653 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3655 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3656 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3658 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3660 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3662 "dec{b}\t$dst", []>, LOCK;
3663 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3665 "dec{w}\t$dst", []>, OpSize, LOCK;
3666 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3668 "dec{l}\t$dst", []>, LOCK;
3670 // Atomic exchange, and, or, xor
3671 let Constraints = "$val = $dst", Defs = [EFLAGS],
3672 usesCustomDAGSchedInserter = 1 in {
3673 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3674 "#ATOMAND32 PSEUDO!",
3675 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3676 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3677 "#ATOMOR32 PSEUDO!",
3678 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3679 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3680 "#ATOMXOR32 PSEUDO!",
3681 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3682 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3683 "#ATOMNAND32 PSEUDO!",
3684 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3685 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3686 "#ATOMMIN32 PSEUDO!",
3687 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3688 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3689 "#ATOMMAX32 PSEUDO!",
3690 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3691 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3692 "#ATOMUMIN32 PSEUDO!",
3693 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3694 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3695 "#ATOMUMAX32 PSEUDO!",
3696 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3698 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3699 "#ATOMAND16 PSEUDO!",
3700 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3701 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3702 "#ATOMOR16 PSEUDO!",
3703 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3704 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3705 "#ATOMXOR16 PSEUDO!",
3706 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3707 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3708 "#ATOMNAND16 PSEUDO!",
3709 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3710 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3711 "#ATOMMIN16 PSEUDO!",
3712 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3713 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3714 "#ATOMMAX16 PSEUDO!",
3715 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3716 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3717 "#ATOMUMIN16 PSEUDO!",
3718 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3719 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3720 "#ATOMUMAX16 PSEUDO!",
3721 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3723 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3724 "#ATOMAND8 PSEUDO!",
3725 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3726 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3728 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3729 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3730 "#ATOMXOR8 PSEUDO!",
3731 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3732 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3733 "#ATOMNAND8 PSEUDO!",
3734 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3737 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3738 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3739 Uses = [EAX, EBX, ECX, EDX],
3740 mayLoad = 1, mayStore = 1,
3741 usesCustomDAGSchedInserter = 1 in {
3742 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3743 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3744 "#ATOMAND6432 PSEUDO!", []>;
3745 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3746 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3747 "#ATOMOR6432 PSEUDO!", []>;
3748 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3749 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3750 "#ATOMXOR6432 PSEUDO!", []>;
3751 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3752 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3753 "#ATOMNAND6432 PSEUDO!", []>;
3754 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3755 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3756 "#ATOMADD6432 PSEUDO!", []>;
3757 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3758 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3759 "#ATOMSUB6432 PSEUDO!", []>;
3760 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3761 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3762 "#ATOMSWAP6432 PSEUDO!", []>;
3765 // Segmentation support instructions.
3767 def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
3768 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3769 def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
3770 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3772 // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
3773 def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3774 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
3775 def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
3776 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
3778 // String manipulation instructions
3780 def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
3781 def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
3782 def LODSD : I<0xAD, RawFrm, (outs), (ins), "lodsd", []>;
3784 //===----------------------------------------------------------------------===//
3785 // Non-Instruction Patterns
3786 //===----------------------------------------------------------------------===//
3788 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3789 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3790 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3791 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3792 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3793 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3795 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3796 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3797 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3798 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3799 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3800 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3801 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3802 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3804 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3805 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3806 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3807 (MOV32mi addr:$dst, texternalsym:$src)>;
3811 def : Pat<(X86tcret GR32:$dst, imm:$off),
3812 (TCRETURNri GR32:$dst, imm:$off)>;
3814 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3815 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3817 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3818 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3820 // Normal calls, with various flavors of addresses.
3821 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3822 (CALLpcrel32 tglobaladdr:$dst)>;
3823 def : Pat<(X86call (i32 texternalsym:$dst)),
3824 (CALLpcrel32 texternalsym:$dst)>;
3825 def : Pat<(X86call (i32 imm:$dst)),
3826 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
3828 // X86 specific add which produces a flag.
3829 def : Pat<(addc GR32:$src1, GR32:$src2),
3830 (ADD32rr GR32:$src1, GR32:$src2)>;
3831 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3832 (ADD32rm GR32:$src1, addr:$src2)>;
3833 def : Pat<(addc GR32:$src1, imm:$src2),
3834 (ADD32ri GR32:$src1, imm:$src2)>;
3835 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3836 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3838 def : Pat<(subc GR32:$src1, GR32:$src2),
3839 (SUB32rr GR32:$src1, GR32:$src2)>;
3840 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3841 (SUB32rm GR32:$src1, addr:$src2)>;
3842 def : Pat<(subc GR32:$src1, imm:$src2),
3843 (SUB32ri GR32:$src1, imm:$src2)>;
3844 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3845 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3849 // TEST R,R is smaller than CMP R,0
3850 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3851 (TEST8rr GR8:$src1, GR8:$src1)>;
3852 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3853 (TEST16rr GR16:$src1, GR16:$src1)>;
3854 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3855 (TEST32rr GR32:$src1, GR32:$src1)>;
3857 // Conditional moves with folded loads with operands swapped and conditions
3859 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3860 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3861 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3862 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3863 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3864 (CMOVB16rm GR16:$src2, addr:$src1)>;
3865 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3866 (CMOVB32rm GR32:$src2, addr:$src1)>;
3867 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3868 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3869 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3870 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3871 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3872 (CMOVE16rm GR16:$src2, addr:$src1)>;
3873 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3874 (CMOVE32rm GR32:$src2, addr:$src1)>;
3875 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3876 (CMOVA16rm GR16:$src2, addr:$src1)>;
3877 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3878 (CMOVA32rm GR32:$src2, addr:$src1)>;
3879 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3880 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3881 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3882 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3883 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3884 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3885 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3886 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3887 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3888 (CMOVL16rm GR16:$src2, addr:$src1)>;
3889 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3890 (CMOVL32rm GR32:$src2, addr:$src1)>;
3891 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3892 (CMOVG16rm GR16:$src2, addr:$src1)>;
3893 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3894 (CMOVG32rm GR32:$src2, addr:$src1)>;
3895 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3896 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3897 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3898 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3899 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3900 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3901 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3902 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3903 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3904 (CMOVP16rm GR16:$src2, addr:$src1)>;
3905 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3906 (CMOVP32rm GR32:$src2, addr:$src1)>;
3907 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3908 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3909 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3910 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3911 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3912 (CMOVS16rm GR16:$src2, addr:$src1)>;
3913 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3914 (CMOVS32rm GR32:$src2, addr:$src1)>;
3915 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3916 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3917 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3918 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3919 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3920 (CMOVO16rm GR16:$src2, addr:$src1)>;
3921 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3922 (CMOVO32rm GR32:$src2, addr:$src1)>;
3924 // zextload bool -> zextload byte
3925 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3926 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3927 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3929 // extload bool -> extload byte
3930 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3931 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3932 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3933 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
3934 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3935 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3937 // anyext. Define these to do an explicit zero-extend to
3938 // avoid partial-register updates.
3939 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3940 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3941 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
3943 // (and (i32 load), 255) -> (zextload i8)
3944 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3945 (MOVZX32rm8 addr:$src)>;
3946 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3947 (MOVZX32rm16 addr:$src)>;
3949 //===----------------------------------------------------------------------===//
3951 //===----------------------------------------------------------------------===//
3953 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3954 // +128 doesn't, so in this special case use a sub instead of an add.
3955 def : Pat<(add GR16:$src1, 128),
3956 (SUB16ri8 GR16:$src1, -128)>;
3957 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3958 (SUB16mi8 addr:$dst, -128)>;
3959 def : Pat<(add GR32:$src1, 128),
3960 (SUB32ri8 GR32:$src1, -128)>;
3961 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3962 (SUB32mi8 addr:$dst, -128)>;
3964 // r & (2^16-1) ==> movz
3965 def : Pat<(and GR32:$src1, 0xffff),
3966 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
3967 // r & (2^8-1) ==> movz
3968 def : Pat<(and GR32:$src1, 0xff),
3969 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
3971 Requires<[In32BitMode]>;
3972 // r & (2^8-1) ==> movz
3973 def : Pat<(and GR16:$src1, 0xff),
3974 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
3976 Requires<[In32BitMode]>;
3978 // sext_inreg patterns
3979 def : Pat<(sext_inreg GR32:$src, i16),
3980 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3981 def : Pat<(sext_inreg GR32:$src, i8),
3982 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3984 Requires<[In32BitMode]>;
3985 def : Pat<(sext_inreg GR16:$src, i8),
3986 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3988 Requires<[In32BitMode]>;
3991 def : Pat<(i16 (trunc GR32:$src)),
3992 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
3993 def : Pat<(i8 (trunc GR32:$src)),
3994 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3996 Requires<[In32BitMode]>;
3997 def : Pat<(i8 (trunc GR16:$src)),
3998 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
4000 Requires<[In32BitMode]>;
4002 // h-register tricks
4003 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
4004 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
4005 x86_subreg_8bit_hi)>,
4006 Requires<[In32BitMode]>;
4007 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
4008 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
4009 x86_subreg_8bit_hi)>,
4010 Requires<[In32BitMode]>;
4011 def : Pat<(srl_su GR16:$src, (i8 8)),
4014 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
4015 x86_subreg_8bit_hi)),
4017 Requires<[In32BitMode]>;
4018 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
4019 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
4020 x86_subreg_8bit_hi))>,
4021 Requires<[In32BitMode]>;
4022 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
4023 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
4024 x86_subreg_8bit_hi))>,
4025 Requires<[In32BitMode]>;
4026 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
4027 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
4028 x86_subreg_8bit_hi))>,
4029 Requires<[In32BitMode]>;
4031 // (shl x, 1) ==> (add x, x)
4032 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4033 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4034 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4036 // (shl x (and y, 31)) ==> (shl x, y)
4037 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4038 (SHL8rCL GR8:$src1)>;
4039 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4040 (SHL16rCL GR16:$src1)>;
4041 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4042 (SHL32rCL GR32:$src1)>;
4043 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4044 (SHL8mCL addr:$dst)>;
4045 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4046 (SHL16mCL addr:$dst)>;
4047 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4048 (SHL32mCL addr:$dst)>;
4050 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4051 (SHR8rCL GR8:$src1)>;
4052 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4053 (SHR16rCL GR16:$src1)>;
4054 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4055 (SHR32rCL GR32:$src1)>;
4056 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4057 (SHR8mCL addr:$dst)>;
4058 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4059 (SHR16mCL addr:$dst)>;
4060 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4061 (SHR32mCL addr:$dst)>;
4063 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4064 (SAR8rCL GR8:$src1)>;
4065 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4066 (SAR16rCL GR16:$src1)>;
4067 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4068 (SAR32rCL GR32:$src1)>;
4069 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4070 (SAR8mCL addr:$dst)>;
4071 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4072 (SAR16mCL addr:$dst)>;
4073 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4074 (SAR32mCL addr:$dst)>;
4076 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4077 def : Pat<(or (srl GR32:$src1, CL:$amt),
4078 (shl GR32:$src2, (sub 32, CL:$amt))),
4079 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4081 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4082 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4083 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4085 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4086 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4087 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4089 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4090 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4092 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4094 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4095 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4097 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4098 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4099 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4101 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4102 def : Pat<(or (shl GR32:$src1, CL:$amt),
4103 (srl GR32:$src2, (sub 32, CL:$amt))),
4104 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4106 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4107 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4108 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4110 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4111 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4112 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4114 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4115 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4117 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4119 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4120 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4122 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4123 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4124 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4126 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4127 def : Pat<(or (srl GR16:$src1, CL:$amt),
4128 (shl GR16:$src2, (sub 16, CL:$amt))),
4129 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4131 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4132 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4133 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4135 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4136 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4137 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4139 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4140 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4142 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4144 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4145 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4147 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4148 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4149 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4151 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4152 def : Pat<(or (shl GR16:$src1, CL:$amt),
4153 (srl GR16:$src2, (sub 16, CL:$amt))),
4154 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4156 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4157 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4158 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4160 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4161 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4162 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4164 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4165 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4167 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4169 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4170 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4172 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4173 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4174 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4176 //===----------------------------------------------------------------------===//
4177 // EFLAGS-defining Patterns
4178 //===----------------------------------------------------------------------===//
4180 // Register-Register Addition with EFLAGS result
4181 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
4183 (ADD8rr GR8:$src1, GR8:$src2)>;
4184 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
4186 (ADD16rr GR16:$src1, GR16:$src2)>;
4187 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
4189 (ADD32rr GR32:$src1, GR32:$src2)>;
4191 // Register-Memory Addition with EFLAGS result
4192 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
4194 (ADD8rm GR8:$src1, addr:$src2)>;
4195 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
4197 (ADD16rm GR16:$src1, addr:$src2)>;
4198 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
4200 (ADD32rm GR32:$src1, addr:$src2)>;
4202 // Register-Integer Addition with EFLAGS result
4203 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
4205 (ADD8ri GR8:$src1, imm:$src2)>;
4206 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
4208 (ADD16ri GR16:$src1, imm:$src2)>;
4209 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
4211 (ADD32ri GR32:$src1, imm:$src2)>;
4212 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
4214 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4215 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
4217 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4219 // Memory-Register Addition with EFLAGS result
4220 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
4223 (ADD8mr addr:$dst, GR8:$src2)>;
4224 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
4227 (ADD16mr addr:$dst, GR16:$src2)>;
4228 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
4231 (ADD32mr addr:$dst, GR32:$src2)>;
4233 // Memory-Integer Addition with EFLAGS result
4234 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
4237 (ADD8mi addr:$dst, imm:$src2)>;
4238 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
4241 (ADD16mi addr:$dst, imm:$src2)>;
4242 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
4245 (ADD32mi addr:$dst, imm:$src2)>;
4246 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4249 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
4250 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4253 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4255 // Register-Register Subtraction with EFLAGS result
4256 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
4258 (SUB8rr GR8:$src1, GR8:$src2)>;
4259 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
4261 (SUB16rr GR16:$src1, GR16:$src2)>;
4262 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
4264 (SUB32rr GR32:$src1, GR32:$src2)>;
4266 // Register-Memory Subtraction with EFLAGS result
4267 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
4269 (SUB8rm GR8:$src1, addr:$src2)>;
4270 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
4272 (SUB16rm GR16:$src1, addr:$src2)>;
4273 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
4275 (SUB32rm GR32:$src1, addr:$src2)>;
4277 // Register-Integer Subtraction with EFLAGS result
4278 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
4280 (SUB8ri GR8:$src1, imm:$src2)>;
4281 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
4283 (SUB16ri GR16:$src1, imm:$src2)>;
4284 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
4286 (SUB32ri GR32:$src1, imm:$src2)>;
4287 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
4289 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4290 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
4292 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4294 // Memory-Register Subtraction with EFLAGS result
4295 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
4298 (SUB8mr addr:$dst, GR8:$src2)>;
4299 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
4302 (SUB16mr addr:$dst, GR16:$src2)>;
4303 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
4306 (SUB32mr addr:$dst, GR32:$src2)>;
4308 // Memory-Integer Subtraction with EFLAGS result
4309 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
4312 (SUB8mi addr:$dst, imm:$src2)>;
4313 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
4316 (SUB16mi addr:$dst, imm:$src2)>;
4317 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
4320 (SUB32mi addr:$dst, imm:$src2)>;
4321 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4324 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
4325 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4328 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4331 // Register-Register Signed Integer Multiply with EFLAGS result
4332 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
4334 (IMUL16rr GR16:$src1, GR16:$src2)>;
4335 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
4337 (IMUL32rr GR32:$src1, GR32:$src2)>;
4339 // Register-Memory Signed Integer Multiply with EFLAGS result
4340 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
4342 (IMUL16rm GR16:$src1, addr:$src2)>;
4343 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
4345 (IMUL32rm GR32:$src1, addr:$src2)>;
4347 // Register-Integer Signed Integer Multiply with EFLAGS result
4348 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
4350 (IMUL16rri GR16:$src1, imm:$src2)>;
4351 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
4353 (IMUL32rri GR32:$src1, imm:$src2)>;
4354 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
4356 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4357 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
4359 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4361 // Memory-Integer Signed Integer Multiply with EFLAGS result
4362 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
4364 (IMUL16rmi addr:$src1, imm:$src2)>;
4365 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
4367 (IMUL32rmi addr:$src1, imm:$src2)>;
4368 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
4370 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4371 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
4373 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4375 // Optimize multiply by 2 with EFLAGS result.
4376 let AddedComplexity = 2 in {
4377 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
4379 (ADD16rr GR16:$src1, GR16:$src1)>;
4381 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
4383 (ADD32rr GR32:$src1, GR32:$src1)>;
4386 // INC and DEC with EFLAGS result. Note that these do not set CF.
4387 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4389 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4392 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4394 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4398 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
4399 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4400 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4402 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
4403 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
4404 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4405 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4407 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
4409 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
4410 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4411 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4413 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
4414 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
4415 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4416 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4418 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
4420 // Register-Register Or with EFLAGS result
4421 def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4423 (OR8rr GR8:$src1, GR8:$src2)>;
4424 def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4426 (OR16rr GR16:$src1, GR16:$src2)>;
4427 def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4429 (OR32rr GR32:$src1, GR32:$src2)>;
4431 // Register-Memory Or with EFLAGS result
4432 def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4434 (OR8rm GR8:$src1, addr:$src2)>;
4435 def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4437 (OR16rm GR16:$src1, addr:$src2)>;
4438 def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4440 (OR32rm GR32:$src1, addr:$src2)>;
4442 // Register-Integer Or with EFLAGS result
4443 def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4445 (OR8ri GR8:$src1, imm:$src2)>;
4446 def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4448 (OR16ri GR16:$src1, imm:$src2)>;
4449 def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4451 (OR32ri GR32:$src1, imm:$src2)>;
4452 def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4454 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4455 def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4457 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4459 // Memory-Register Or with EFLAGS result
4460 def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4463 (OR8mr addr:$dst, GR8:$src2)>;
4464 def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4467 (OR16mr addr:$dst, GR16:$src2)>;
4468 def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4471 (OR32mr addr:$dst, GR32:$src2)>;
4473 // Memory-Integer Or with EFLAGS result
4474 def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4477 (OR8mi addr:$dst, imm:$src2)>;
4478 def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4481 (OR16mi addr:$dst, imm:$src2)>;
4482 def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
4485 (OR32mi addr:$dst, imm:$src2)>;
4486 def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4489 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
4490 def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4493 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
4495 // Register-Register XOr with EFLAGS result
4496 def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
4498 (XOR8rr GR8:$src1, GR8:$src2)>;
4499 def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
4501 (XOR16rr GR16:$src1, GR16:$src2)>;
4502 def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
4504 (XOR32rr GR32:$src1, GR32:$src2)>;
4506 // Register-Memory XOr with EFLAGS result
4507 def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
4509 (XOR8rm GR8:$src1, addr:$src2)>;
4510 def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
4512 (XOR16rm GR16:$src1, addr:$src2)>;
4513 def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
4515 (XOR32rm GR32:$src1, addr:$src2)>;
4517 // Register-Integer XOr with EFLAGS result
4518 def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
4520 (XOR8ri GR8:$src1, imm:$src2)>;
4521 def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
4523 (XOR16ri GR16:$src1, imm:$src2)>;
4524 def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
4526 (XOR32ri GR32:$src1, imm:$src2)>;
4527 def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
4529 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4530 def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
4532 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4534 // Memory-Register XOr with EFLAGS result
4535 def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
4538 (XOR8mr addr:$dst, GR8:$src2)>;
4539 def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
4542 (XOR16mr addr:$dst, GR16:$src2)>;
4543 def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
4546 (XOR32mr addr:$dst, GR32:$src2)>;
4548 // Memory-Integer XOr with EFLAGS result
4549 def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
4552 (XOR8mi addr:$dst, imm:$src2)>;
4553 def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
4556 (XOR16mi addr:$dst, imm:$src2)>;
4557 def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
4560 (XOR32mi addr:$dst, imm:$src2)>;
4561 def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4564 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
4565 def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4568 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
4570 // Register-Register And with EFLAGS result
4571 def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
4573 (AND8rr GR8:$src1, GR8:$src2)>;
4574 def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
4576 (AND16rr GR16:$src1, GR16:$src2)>;
4577 def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
4579 (AND32rr GR32:$src1, GR32:$src2)>;
4581 // Register-Memory And with EFLAGS result
4582 def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
4584 (AND8rm GR8:$src1, addr:$src2)>;
4585 def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
4587 (AND16rm GR16:$src1, addr:$src2)>;
4588 def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
4590 (AND32rm GR32:$src1, addr:$src2)>;
4592 // Register-Integer And with EFLAGS result
4593 def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
4595 (AND8ri GR8:$src1, imm:$src2)>;
4596 def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
4598 (AND16ri GR16:$src1, imm:$src2)>;
4599 def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
4601 (AND32ri GR32:$src1, imm:$src2)>;
4602 def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
4604 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
4605 def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
4607 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
4609 // Memory-Register And with EFLAGS result
4610 def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
4613 (AND8mr addr:$dst, GR8:$src2)>;
4614 def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
4617 (AND16mr addr:$dst, GR16:$src2)>;
4618 def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
4621 (AND32mr addr:$dst, GR32:$src2)>;
4623 // Memory-Integer And with EFLAGS result
4624 def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
4627 (AND8mi addr:$dst, imm:$src2)>;
4628 def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
4631 (AND16mi addr:$dst, imm:$src2)>;
4632 def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
4635 (AND32mi addr:$dst, imm:$src2)>;
4636 def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4639 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
4640 def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4643 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
4645 // -disable-16bit support.
4646 def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
4647 (MOV16mi addr:$dst, imm:$src)>;
4648 def : Pat<(truncstorei16 GR32:$src, addr:$dst),
4649 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4650 def : Pat<(i32 (sextloadi16 addr:$dst)),
4651 (MOVSX32rm16 addr:$dst)>;
4652 def : Pat<(i32 (zextloadi16 addr:$dst)),
4653 (MOVZX32rm16 addr:$dst)>;
4654 def : Pat<(i32 (extloadi16 addr:$dst)),
4655 (MOVZX32rm16 addr:$dst)>;
4657 //===----------------------------------------------------------------------===//
4658 // Floating Point Stack Support
4659 //===----------------------------------------------------------------------===//
4661 include "X86InstrFPStack.td"
4663 //===----------------------------------------------------------------------===//
4665 //===----------------------------------------------------------------------===//
4667 include "X86Instr64bit.td"
4669 //===----------------------------------------------------------------------===//
4670 // XMM Floating point support (requires SSE / SSE2)
4671 //===----------------------------------------------------------------------===//
4673 include "X86InstrSSE.td"
4675 //===----------------------------------------------------------------------===//
4676 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4677 //===----------------------------------------------------------------------===//
4679 include "X86InstrMMX.td"