3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86 instruction set, defining the instructions, and
11 // properties of the instructions which are needed for code generation, machine
12 // code emission, and analysis.
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
17 // X86 specific DAG Nodes.
20 def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
24 def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
26 def SDTX86Cmov : SDTypeProfile<1, 4,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
30 // Unary and binary operator instructions that set EFLAGS as a side-effect.
31 def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
33 def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
37 def SDTX86BrCond : SDTypeProfile<0, 3,
38 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
41 def SDTX86SetCC : SDTypeProfile<1, 2,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
44 def SDTX86SetCC_C : SDTypeProfile<1, 2,
46 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
48 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
50 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
52 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
53 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
54 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
56 def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
57 def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
60 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
62 def SDT_X86VASTART_SAVE_XMM_REGS : SDTypeProfile<0, -1, [SDTCisVT<0, i8>,
66 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
68 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
70 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
72 def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
74 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
76 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
78 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
80 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
81 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
82 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
83 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
85 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
87 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
89 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
90 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
92 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
93 def X86setcc_c : SDNode<"X86ISD::SETCC_CARRY", SDTX86SetCC_C>;
95 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
96 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
98 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
99 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
101 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
102 [SDNPHasChain, SDNPMayStore,
103 SDNPMayLoad, SDNPMemOperand]>;
104 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
105 [SDNPHasChain, SDNPMayStore,
106 SDNPMayLoad, SDNPMemOperand]>;
107 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
108 [SDNPHasChain, SDNPMayStore,
109 SDNPMayLoad, SDNPMemOperand]>;
110 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
111 [SDNPHasChain, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
113 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
114 [SDNPHasChain, SDNPMayStore,
115 SDNPMayLoad, SDNPMemOperand]>;
116 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
117 [SDNPHasChain, SDNPMayStore,
118 SDNPMayLoad, SDNPMemOperand]>;
119 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
120 [SDNPHasChain, SDNPMayStore,
121 SDNPMayLoad, SDNPMemOperand]>;
122 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
123 [SDNPHasChain, SDNPOptInFlag]>;
125 def X86vastart_save_xmm_regs :
126 SDNode<"X86ISD::VASTART_SAVE_XMM_REGS",
127 SDT_X86VASTART_SAVE_XMM_REGS,
130 def X86callseq_start :
131 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
132 [SDNPHasChain, SDNPOutFlag]>;
134 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
135 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
137 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
138 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
140 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
141 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
142 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
143 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
146 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
147 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
149 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
150 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
152 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
153 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
154 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
155 SDT_X86SegmentBaseAddress, []>;
157 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
160 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
161 [SDNPHasChain, SDNPOptInFlag]>;
163 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
164 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
165 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
166 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
167 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
168 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
169 def X86or_flag : SDNode<"X86ISD::OR", SDTBinaryArithWithFlags>;
170 def X86xor_flag : SDNode<"X86ISD::XOR", SDTBinaryArithWithFlags>;
171 def X86and_flag : SDNode<"X86ISD::AND", SDTBinaryArithWithFlags>;
173 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
175 //===----------------------------------------------------------------------===//
176 // X86 Operand Definitions.
179 def i32imm_pcrel : Operand<i32> {
180 let PrintMethod = "print_pcrel_imm";
183 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
184 // the index operand of an address, to conform to x86 encoding restrictions.
185 def ptr_rc_nosp : PointerLikeRegClass<1>;
187 // *mem - Operand definitions for the funky X86 addressing mode operands.
189 def X86MemAsmOperand : AsmOperandClass {
193 class X86MemOperand<string printMethod> : Operand<iPTR> {
194 let PrintMethod = printMethod;
195 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
196 let ParserMatchClass = X86MemAsmOperand;
199 def opaque32mem : X86MemOperand<"printopaquemem">;
200 def opaque48mem : X86MemOperand<"printopaquemem">;
201 def opaque80mem : X86MemOperand<"printopaquemem">;
202 def opaque512mem : X86MemOperand<"printopaquemem">;
204 def offset8 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
205 def offset16 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
206 def offset32 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
207 def offset64 : Operand<i64> { let PrintMethod = "print_pcrel_imm"; }
209 def i8mem : X86MemOperand<"printi8mem">;
210 def i16mem : X86MemOperand<"printi16mem">;
211 def i32mem : X86MemOperand<"printi32mem">;
212 def i64mem : X86MemOperand<"printi64mem">;
213 def i128mem : X86MemOperand<"printi128mem">;
214 //def i256mem : X86MemOperand<"printi256mem">;
215 def f32mem : X86MemOperand<"printf32mem">;
216 def f64mem : X86MemOperand<"printf64mem">;
217 def f80mem : X86MemOperand<"printf80mem">;
218 def f128mem : X86MemOperand<"printf128mem">;
219 //def f256mem : X86MemOperand<"printf256mem">;
221 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
222 // plain GR64, so that it doesn't potentially require a REX prefix.
223 def i8mem_NOREX : Operand<i64> {
224 let PrintMethod = "printi8mem";
225 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
226 let ParserMatchClass = X86MemAsmOperand;
229 def lea32mem : Operand<i32> {
230 let PrintMethod = "printlea32mem";
231 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
232 let ParserMatchClass = X86MemAsmOperand;
235 def SSECC : Operand<i8> {
236 let PrintMethod = "printSSECC";
239 def ImmSExt8AsmOperand : AsmOperandClass {
240 let Name = "ImmSExt8";
241 let SuperClass = ImmAsmOperand;
244 // A couple of more descriptive operand definitions.
245 // 16-bits but only 8 bits are significant.
246 def i16i8imm : Operand<i16> {
247 let ParserMatchClass = ImmSExt8AsmOperand;
249 // 32-bits but only 8 bits are significant.
250 def i32i8imm : Operand<i32> {
251 let ParserMatchClass = ImmSExt8AsmOperand;
254 // Branch targets have OtherVT type and print as pc-relative values.
255 def brtarget : Operand<OtherVT> {
256 let PrintMethod = "print_pcrel_imm";
259 def brtarget8 : Operand<OtherVT> {
260 let PrintMethod = "print_pcrel_imm";
263 //===----------------------------------------------------------------------===//
264 // X86 Complex Pattern Definitions.
267 // Define X86 specific addressing mode.
268 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
269 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
270 [add, sub, mul, X86mul_imm, shl, or, frameindex],
272 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
273 [tglobaltlsaddr], []>;
275 //===----------------------------------------------------------------------===//
276 // X86 Instruction Predicate Definitions.
277 def HasMMX : Predicate<"Subtarget->hasMMX()">;
278 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
279 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
280 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
281 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
282 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
283 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
284 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
285 def HasAVX : Predicate<"Subtarget->hasAVX()">;
286 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
287 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
288 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
289 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
290 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
291 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
292 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
293 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
294 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
295 def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
296 def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
297 "TM.getCodeModel() != CodeModel::Kernel">;
298 def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
299 "TM.getCodeModel() == CodeModel::Kernel">;
300 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
301 def OptForSpeed : Predicate<"!OptForSize">;
302 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
303 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
305 //===----------------------------------------------------------------------===//
306 // X86 Instruction Format Definitions.
309 include "X86InstrFormats.td"
311 //===----------------------------------------------------------------------===//
312 // Pattern fragments...
315 // X86 specific condition code. These correspond to CondCode in
316 // X86InstrInfo.h. They must be kept in synch.
317 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
318 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
319 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
320 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
321 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
322 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
323 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
324 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
325 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
326 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
327 def X86_COND_NO : PatLeaf<(i8 10)>;
328 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
329 def X86_COND_NS : PatLeaf<(i8 12)>;
330 def X86_COND_O : PatLeaf<(i8 13)>;
331 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
332 def X86_COND_S : PatLeaf<(i8 15)>;
334 def i16immSExt8 : PatLeaf<(i16 imm), [{
335 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
336 // sign extended field.
337 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
340 def i32immSExt8 : PatLeaf<(i32 imm), [{
341 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
342 // sign extended field.
343 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
346 // Helper fragments for loads.
347 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
348 // known to be 32-bit aligned or better. Ditto for i8 to i16.
349 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
350 LoadSDNode *LD = cast<LoadSDNode>(N);
351 if (const Value *Src = LD->getSrcValue())
352 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
353 if (PT->getAddressSpace() > 255)
355 ISD::LoadExtType ExtType = LD->getExtensionType();
356 if (ExtType == ISD::NON_EXTLOAD)
358 if (ExtType == ISD::EXTLOAD)
359 return LD->getAlignment() >= 2 && !LD->isVolatile();
363 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)),
365 LoadSDNode *LD = cast<LoadSDNode>(N);
366 if (const Value *Src = LD->getSrcValue())
367 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
368 if (PT->getAddressSpace() > 255)
370 ISD::LoadExtType ExtType = LD->getExtensionType();
371 if (ExtType == ISD::EXTLOAD)
372 return LD->getAlignment() >= 2 && !LD->isVolatile();
376 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
377 LoadSDNode *LD = cast<LoadSDNode>(N);
378 if (const Value *Src = LD->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
380 if (PT->getAddressSpace() > 255)
382 ISD::LoadExtType ExtType = LD->getExtensionType();
383 if (ExtType == ISD::NON_EXTLOAD)
385 if (ExtType == ISD::EXTLOAD)
386 return LD->getAlignment() >= 4 && !LD->isVolatile();
390 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
391 LoadSDNode *LD = cast<LoadSDNode>(N);
392 if (const Value *Src = LD->getSrcValue())
393 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
394 if (PT->getAddressSpace() > 255)
396 if (LD->isVolatile())
398 ISD::LoadExtType ExtType = LD->getExtensionType();
399 if (ExtType == ISD::NON_EXTLOAD)
401 if (ExtType == ISD::EXTLOAD)
402 return LD->getAlignment() >= 4;
406 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
407 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
408 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
409 return PT->getAddressSpace() == 256;
413 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
414 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
415 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
416 return PT->getAddressSpace() == 257;
420 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
421 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
422 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
423 if (PT->getAddressSpace() > 255)
427 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
428 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
429 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
430 if (PT->getAddressSpace() > 255)
435 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
436 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
437 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
438 if (PT->getAddressSpace() > 255)
442 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
443 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
444 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
445 if (PT->getAddressSpace() > 255)
449 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
450 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
451 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
452 if (PT->getAddressSpace() > 255)
457 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
458 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
459 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
461 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
462 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
463 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
464 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
465 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
466 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
468 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
469 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
470 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
471 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
472 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
473 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
476 // An 'and' node with a single use.
477 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
478 return N->hasOneUse();
480 // An 'srl' node with a single use.
481 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
482 return N->hasOneUse();
484 // An 'trunc' node with a single use.
485 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
486 return N->hasOneUse();
489 // 'shld' and 'shrd' instruction patterns. Note that even though these have
490 // the srl and shl in their patterns, the C++ code must still check for them,
491 // because predicates are tested before children nodes are explored.
493 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
494 (or (srl node:$src1, node:$amt1),
495 (shl node:$src2, node:$amt2)), [{
496 assert(N->getOpcode() == ISD::OR);
497 return N->getOperand(0).getOpcode() == ISD::SRL &&
498 N->getOperand(1).getOpcode() == ISD::SHL &&
499 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
500 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
501 N->getOperand(0).getConstantOperandVal(1) ==
502 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
505 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
506 (or (shl node:$src1, node:$amt1),
507 (srl node:$src2, node:$amt2)), [{
508 assert(N->getOpcode() == ISD::OR);
509 return N->getOperand(0).getOpcode() == ISD::SHL &&
510 N->getOperand(1).getOpcode() == ISD::SRL &&
511 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
512 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
513 N->getOperand(0).getConstantOperandVal(1) ==
514 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
517 //===----------------------------------------------------------------------===//
518 // Instruction list...
521 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
522 // a stack adjustment and the codegen must know that they may modify the stack
523 // pointer before prolog-epilog rewriting occurs.
524 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
525 // sub / add which can clobber EFLAGS.
526 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
527 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
529 [(X86callseq_start timm:$amt)]>,
530 Requires<[In32BitMode]>;
531 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
533 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
534 Requires<[In32BitMode]>;
537 // x86-64 va_start lowering magic.
538 let usesCustomInserter = 1 in
539 def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
542 i64imm:$regsavefi, i64imm:$offset,
544 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
545 [(X86vastart_save_xmm_regs GR8:$al,
550 let neverHasSideEffects = 1 in {
551 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
552 def NOOPW : I<0x1f, MRM0m, (outs), (ins i16mem:$zero),
553 "nop{w}\t$zero", []>, TB, OpSize;
554 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
555 "nop{l}\t$zero", []>, TB;
559 def INT3 : I<0xcc, RawFrm, (outs), (ins), "int\t3", []>;
560 def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
561 def IRET16 : I<0xcf, RawFrm, (outs), (ins), "iret{w}", []>, OpSize;
562 def IRET32 : I<0xcf, RawFrm, (outs), (ins), "iret{l}", []>;
564 // PIC base construction. This expands to code that looks like this:
567 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
568 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label),
571 //===----------------------------------------------------------------------===//
572 // Control Flow Instructions...
575 // Return instructions.
576 let isTerminator = 1, isReturn = 1, isBarrier = 1,
577 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
578 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
581 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
583 [(X86retflag timm:$amt)]>;
584 def LRET : I <0xCB, RawFrm, (outs), (ins),
586 def LRETI : Ii16<0xCA, RawFrm, (outs), (ins i16imm:$amt),
590 // All branches are RawFrm, Void, Branch, and Terminators
591 let isBranch = 1, isTerminator = 1 in
592 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
593 I<opcode, RawFrm, (outs), ins, asm, pattern>;
595 let isBranch = 1, isBarrier = 1 in {
596 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
597 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
601 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
602 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
603 [(brind GR32:$dst)]>;
604 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
605 [(brind (loadi32 addr:$dst))]>;
607 def FARJMP16i : Iseg16<0xEA, RawFrm, (outs),
608 (ins i16imm:$seg, i16imm:$off),
609 "ljmp{w}\t$seg, $off", []>, OpSize;
610 def FARJMP32i : Iseg32<0xEA, RawFrm, (outs),
611 (ins i16imm:$seg, i32imm:$off),
612 "ljmp{l}\t$seg, $off", []>;
614 def FARJMP16m : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
615 "ljmp{w}\t{*}$dst", []>, OpSize;
616 def FARJMP32m : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
617 "ljmp{l}\t{*}$dst", []>;
620 // Conditional branches
621 let Uses = [EFLAGS] in {
622 // Short conditional jumps
623 def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
624 def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
625 def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
626 def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
627 def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
628 def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
629 def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
630 def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
631 def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
632 def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
633 def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
634 def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
635 def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
636 def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
637 def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
638 def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
640 def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
642 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
643 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
644 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
645 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
646 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
647 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
648 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
649 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
650 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
651 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
652 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
653 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
655 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
656 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
657 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
658 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
659 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
660 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
661 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
662 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
664 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
665 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
666 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
667 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
668 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
669 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
670 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
671 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
672 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
673 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
674 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
675 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
680 def LOOP : I<0xE2, RawFrm, (ins brtarget8:$dst), (outs), "loop\t$dst", []>;
681 def LOOPE : I<0xE1, RawFrm, (ins brtarget8:$dst), (outs), "loope\t$dst", []>;
682 def LOOPNE : I<0xE0, RawFrm, (ins brtarget8:$dst), (outs), "loopne\t$dst", []>;
684 //===----------------------------------------------------------------------===//
685 // Call Instructions...
688 // All calls clobber the non-callee saved registers. ESP is marked as
689 // a use to prevent stack-pointer assignments that appear immediately
690 // before calls from potentially appearing dead. Uses for argument
691 // registers are added manually.
692 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
693 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
694 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
695 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
697 def CALLpcrel32 : Ii32<0xE8, RawFrm,
698 (outs), (ins i32imm_pcrel:$dst,variable_ops),
700 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
701 "call\t{*}$dst", [(X86call GR32:$dst)]>;
702 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
703 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
705 def FARCALL16i : Iseg16<0x9A, RawFrm, (outs),
706 (ins i16imm:$seg, i16imm:$off),
707 "lcall{w}\t$seg, $off", []>, OpSize;
708 def FARCALL32i : Iseg32<0x9A, RawFrm, (outs),
709 (ins i16imm:$seg, i32imm:$off),
710 "lcall{l}\t$seg, $off", []>;
712 def FARCALL16m : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
713 "lcall{w}\t{*}$dst", []>, OpSize;
714 def FARCALL32m : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
715 "lcall{l}\t{*}$dst", []>;
718 // Constructing a stack frame.
720 def ENTER : I<0xC8, RawFrm, (outs), (ins i16imm:$len, i8imm:$lvl),
721 "enter\t$len, $lvl", []>;
725 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
726 def TCRETURNdi : I<0, Pseudo, (outs),
727 (ins i32imm:$dst, i32imm:$offset, variable_ops),
728 "#TC_RETURN $dst $offset",
731 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
732 def TCRETURNri : I<0, Pseudo, (outs),
733 (ins GR32:$dst, i32imm:$offset, variable_ops),
734 "#TC_RETURN $dst $offset",
737 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
738 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
740 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
741 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst),
742 "jmp{l}\t{*}$dst # TAILCALL",
744 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
745 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
746 "jmp\t{*}$dst # TAILCALL", []>;
748 //===----------------------------------------------------------------------===//
749 // Miscellaneous Instructions...
751 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
752 def LEAVE : I<0xC9, RawFrm,
753 (outs), (ins), "leave", []>;
755 def POPCNT16rr : I<0xB8, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
756 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
757 def POPCNT16rm : I<0xB8, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
758 "popcnt{w}\t{$src, $dst|$dst, $src}", []>, OpSize, XS;
759 def POPCNT32rr : I<0xB8, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
760 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
761 def POPCNT32rm : I<0xB8, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
762 "popcnt{l}\t{$src, $dst|$dst, $src}", []>, XS;
764 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
766 def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
768 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
769 def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
771 def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
773 def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
774 def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
777 let mayStore = 1 in {
778 def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
780 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
781 def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
783 def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
785 def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
786 def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
790 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
791 def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
792 "push{l}\t$imm", []>;
793 def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
794 "push{l}\t$imm", []>;
795 def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
796 "push{l}\t$imm", []>;
799 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in {
800 def POPF : I<0x9D, RawFrm, (outs), (ins), "popf{w}", []>, OpSize;
801 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf{l}", []>;
803 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in {
804 def PUSHF : I<0x9C, RawFrm, (outs), (ins), "pushf{w}", []>, OpSize;
805 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf{l}", []>;
808 let isTwoAddress = 1 in // GR32 = bswap GR32
809 def BSWAP32r : I<0xC8, AddRegFrm,
810 (outs GR32:$dst), (ins GR32:$src),
812 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
815 // Bit scan instructions.
816 let Defs = [EFLAGS] in {
817 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
818 "bsf{w}\t{$src, $dst|$dst, $src}",
819 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
820 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
821 "bsf{w}\t{$src, $dst|$dst, $src}",
822 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
823 (implicit EFLAGS)]>, TB;
824 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
825 "bsf{l}\t{$src, $dst|$dst, $src}",
826 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
827 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
828 "bsf{l}\t{$src, $dst|$dst, $src}",
829 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
830 (implicit EFLAGS)]>, TB;
832 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
833 "bsr{w}\t{$src, $dst|$dst, $src}",
834 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
835 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
836 "bsr{w}\t{$src, $dst|$dst, $src}",
837 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
838 (implicit EFLAGS)]>, TB;
839 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
840 "bsr{l}\t{$src, $dst|$dst, $src}",
841 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
842 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
843 "bsr{l}\t{$src, $dst|$dst, $src}",
844 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
845 (implicit EFLAGS)]>, TB;
848 let neverHasSideEffects = 1 in
849 def LEA16r : I<0x8D, MRMSrcMem,
850 (outs GR16:$dst), (ins lea32mem:$src),
851 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
852 let isReMaterializable = 1 in
853 def LEA32r : I<0x8D, MRMSrcMem,
854 (outs GR32:$dst), (ins lea32mem:$src),
855 "lea{l}\t{$src|$dst}, {$dst|$src}",
856 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
858 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
859 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
860 [(X86rep_movs i8)]>, REP;
861 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
862 [(X86rep_movs i16)]>, REP, OpSize;
863 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
864 [(X86rep_movs i32)]>, REP;
867 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
868 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
869 [(X86rep_stos i8)]>, REP;
870 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
871 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
872 [(X86rep_stos i16)]>, REP, OpSize;
873 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
874 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
875 [(X86rep_stos i32)]>, REP;
877 def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
878 def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
879 def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
881 def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
882 def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
883 def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
885 let Defs = [RAX, RDX] in
886 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
889 let isBarrier = 1, hasCtrlDep = 1 in {
890 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
893 def SYSCALL : I<0x05, RawFrm,
894 (outs), (ins), "syscall", []>, TB;
895 def SYSRET : I<0x07, RawFrm,
896 (outs), (ins), "sysret", []>, TB;
897 def SYSENTER : I<0x34, RawFrm,
898 (outs), (ins), "sysenter", []>, TB;
899 def SYSEXIT : I<0x35, RawFrm,
900 (outs), (ins), "sysexit", []>, TB;
902 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
905 //===----------------------------------------------------------------------===//
906 // Input/Output Instructions...
908 let Defs = [AL], Uses = [DX] in
909 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
910 "in{b}\t{%dx, %al|%AL, %DX}", []>;
911 let Defs = [AX], Uses = [DX] in
912 def IN16rr : I<0xED, RawFrm, (outs), (ins),
913 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
914 let Defs = [EAX], Uses = [DX] in
915 def IN32rr : I<0xED, RawFrm, (outs), (ins),
916 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
919 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
920 "in{b}\t{$port, %al|%AL, $port}", []>;
922 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
923 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
925 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
926 "in{l}\t{$port, %eax|%EAX, $port}", []>;
928 let Uses = [DX, AL] in
929 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
930 "out{b}\t{%al, %dx|%DX, %AL}", []>;
931 let Uses = [DX, AX] in
932 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
933 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
934 let Uses = [DX, EAX] in
935 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
936 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
939 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
940 "out{b}\t{%al, $port|$port, %AL}", []>;
942 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
943 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
945 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
946 "out{l}\t{%eax, $port|$port, %EAX}", []>;
948 def IN8 : I<0x6C, RawFrm, (outs), (ins),
950 def IN16 : I<0x6D, RawFrm, (outs), (ins),
951 "ins{w}", []>, OpSize;
952 def IN32 : I<0x6D, RawFrm, (outs), (ins),
955 //===----------------------------------------------------------------------===//
956 // Move Instructions...
958 let neverHasSideEffects = 1 in {
959 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
960 "mov{b}\t{$src, $dst|$dst, $src}", []>;
961 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
962 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
963 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
964 "mov{l}\t{$src, $dst|$dst, $src}", []>;
966 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
967 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
968 "mov{b}\t{$src, $dst|$dst, $src}",
969 [(set GR8:$dst, imm:$src)]>;
970 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
971 "mov{w}\t{$src, $dst|$dst, $src}",
972 [(set GR16:$dst, imm:$src)]>, OpSize;
973 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
974 "mov{l}\t{$src, $dst|$dst, $src}",
975 [(set GR32:$dst, imm:$src)]>;
977 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
978 "mov{b}\t{$src, $dst|$dst, $src}",
979 [(store (i8 imm:$src), addr:$dst)]>;
980 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
981 "mov{w}\t{$src, $dst|$dst, $src}",
982 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
983 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
984 "mov{l}\t{$src, $dst|$dst, $src}",
985 [(store (i32 imm:$src), addr:$dst)]>;
987 def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins offset8:$src),
988 "mov{b}\t{$src, %al|%al, $src}", []>;
989 def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins offset16:$src),
990 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
991 def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins offset32:$src),
992 "mov{l}\t{$src, %eax|%eax, $src}", []>;
994 def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs offset8:$dst), (ins),
995 "mov{b}\t{%al, $dst|$dst, %al}", []>;
996 def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs offset16:$dst), (ins),
997 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
998 def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs offset32:$dst), (ins),
999 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
1001 // Moves to and from segment registers
1002 def MOV16rs : I<0x8C, MRMDestReg, (outs GR16:$dst), (ins SEGMENT_REG:$src),
1003 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1004 def MOV16ms : I<0x8C, MRMDestMem, (outs i16mem:$dst), (ins SEGMENT_REG:$src),
1005 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1006 def MOV16sr : I<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR16:$src),
1007 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1008 def MOV16sm : I<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i16mem:$src),
1009 "mov{w}\t{$src, $dst|$dst, $src}", []>;
1011 def MOV8rr_REV : I<0x8A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src),
1012 "mov{b}\t{$src, $dst|$dst, $src}", []>;
1013 def MOV16rr_REV : I<0x8B, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
1014 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
1015 def MOV32rr_REV : I<0x8B, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
1016 "mov{l}\t{$src, $dst|$dst, $src}", []>;
1018 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
1019 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
1020 "mov{b}\t{$src, $dst|$dst, $src}",
1021 [(set GR8:$dst, (loadi8 addr:$src))]>;
1022 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
1023 "mov{w}\t{$src, $dst|$dst, $src}",
1024 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
1025 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
1026 "mov{l}\t{$src, $dst|$dst, $src}",
1027 [(set GR32:$dst, (loadi32 addr:$src))]>;
1030 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
1031 "mov{b}\t{$src, $dst|$dst, $src}",
1032 [(store GR8:$src, addr:$dst)]>;
1033 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1034 "mov{w}\t{$src, $dst|$dst, $src}",
1035 [(store GR16:$src, addr:$dst)]>, OpSize;
1036 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1037 "mov{l}\t{$src, $dst|$dst, $src}",
1038 [(store GR32:$src, addr:$dst)]>;
1040 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
1041 // that they can be used for copying and storing h registers, which can't be
1042 // encoded when a REX prefix is present.
1043 let neverHasSideEffects = 1 in
1044 def MOV8rr_NOREX : I<0x88, MRMDestReg,
1045 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
1046 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1048 def MOV8mr_NOREX : I<0x88, MRMDestMem,
1049 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
1050 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1052 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
1053 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
1054 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
1055 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
1057 // Moves to and from debug registers
1058 def MOV32rd : I<0x21, MRMDestReg, (outs GR32:$dst), (ins DEBUG_REG:$src),
1059 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1060 def MOV32dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR32:$src),
1061 "mov{l}\t{$src, $dst|$dst, $src}", []>, TB;
1063 // Moves to and from control registers
1064 def MOV32rc : I<0x20, MRMDestReg, (outs GR32:$dst), (ins CONTROL_REG_32:$src),
1065 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1066 def MOV32cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_32:$dst), (ins GR32:$src),
1067 "mov{q}\t{$src, $dst|$dst, $src}", []>, TB;
1069 //===----------------------------------------------------------------------===//
1070 // Fixed-Register Multiplication and Division Instructions...
1073 // Extra precision multiplication
1074 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1075 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
1076 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1077 // This probably ought to be moved to a def : Pat<> if the
1078 // syntax can be accepted.
1079 [(set AL, (mul AL, GR8:$src)),
1080 (implicit EFLAGS)]>; // AL,AH = AL*GR8
1082 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
1083 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
1085 []>, OpSize; // AX,DX = AX*GR16
1087 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
1088 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
1090 []>; // EAX,EDX = EAX*GR32
1092 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1093 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
1095 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
1096 // This probably ought to be moved to a def : Pat<> if the
1097 // syntax can be accepted.
1098 [(set AL, (mul AL, (loadi8 addr:$src))),
1099 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1101 let mayLoad = 1, neverHasSideEffects = 1 in {
1102 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1103 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
1105 []>, OpSize; // AX,DX = AX*[mem16]
1107 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1108 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
1110 []>; // EAX,EDX = EAX*[mem32]
1113 let neverHasSideEffects = 1 in {
1114 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1115 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1117 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1118 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
1119 OpSize; // AX,DX = AX*GR16
1120 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
1121 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1122 // EAX,EDX = EAX*GR32
1123 let mayLoad = 1 in {
1124 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
1125 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
1126 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
1127 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
1128 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
1129 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1130 let Defs = [EAX,EDX], Uses = [EAX] in
1131 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
1132 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
1134 } // neverHasSideEffects
1136 // unsigned division/remainder
1137 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1138 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1139 "div{b}\t$src", []>;
1140 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1141 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1142 "div{w}\t$src", []>, OpSize;
1143 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1144 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1145 "div{l}\t$src", []>;
1146 let mayLoad = 1 in {
1147 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1148 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1149 "div{b}\t$src", []>;
1150 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1151 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1152 "div{w}\t$src", []>, OpSize;
1153 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1154 // EDX:EAX/[mem32] = EAX,EDX
1155 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src),
1156 "div{l}\t$src", []>;
1159 // Signed division/remainder.
1160 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1161 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
1162 "idiv{b}\t$src", []>;
1163 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1164 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
1165 "idiv{w}\t$src", []>, OpSize;
1166 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1167 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
1168 "idiv{l}\t$src", []>;
1169 let mayLoad = 1, mayLoad = 1 in {
1170 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
1171 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
1172 "idiv{b}\t$src", []>;
1173 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
1174 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
1175 "idiv{w}\t$src", []>, OpSize;
1176 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
1177 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src),
1178 // EDX:EAX/[mem32] = EAX,EDX
1179 "idiv{l}\t$src", []>;
1182 //===----------------------------------------------------------------------===//
1183 // Two address Instructions.
1185 let isTwoAddress = 1 in {
1187 // Conditional moves
1188 let Uses = [EFLAGS] in {
1190 // X86 doesn't have 8-bit conditional moves. Use a customInserter to
1191 // emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1192 // however that requires promoting the operands, and can induce additional
1193 // i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1194 // clobber EFLAGS, because if one of the operands is zero, the expansion
1195 // could involve an xor.
1196 let usesCustomInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
1197 def CMOV_GR8 : I<0, Pseudo,
1198 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1199 "#CMOV_GR8 PSEUDO!",
1200 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1201 imm:$cond, EFLAGS))]>;
1203 let isCommutable = 1 in {
1204 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
1205 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1206 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1207 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1208 X86_COND_B, EFLAGS))]>,
1210 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
1211 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1212 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1213 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1214 X86_COND_B, EFLAGS))]>,
1216 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1217 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1218 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1219 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1220 X86_COND_AE, EFLAGS))]>,
1222 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1223 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1224 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1225 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1226 X86_COND_AE, EFLAGS))]>,
1228 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1229 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1230 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1231 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1232 X86_COND_E, EFLAGS))]>,
1234 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1235 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1236 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1237 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1238 X86_COND_E, EFLAGS))]>,
1240 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1241 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1242 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1243 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1244 X86_COND_NE, EFLAGS))]>,
1246 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1247 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1248 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1249 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1250 X86_COND_NE, EFLAGS))]>,
1252 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1253 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1254 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1255 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1256 X86_COND_BE, EFLAGS))]>,
1258 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1259 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1260 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1261 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1262 X86_COND_BE, EFLAGS))]>,
1264 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1265 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1266 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1267 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1268 X86_COND_A, EFLAGS))]>,
1270 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1271 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1272 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1273 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1274 X86_COND_A, EFLAGS))]>,
1276 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1277 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1278 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1279 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1280 X86_COND_L, EFLAGS))]>,
1282 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1283 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1284 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1285 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1286 X86_COND_L, EFLAGS))]>,
1288 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1289 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1290 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1291 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1292 X86_COND_GE, EFLAGS))]>,
1294 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1295 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1296 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1297 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1298 X86_COND_GE, EFLAGS))]>,
1300 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1301 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1302 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1303 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1304 X86_COND_LE, EFLAGS))]>,
1306 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1307 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1308 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1309 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1310 X86_COND_LE, EFLAGS))]>,
1312 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1313 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1314 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1315 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1316 X86_COND_G, EFLAGS))]>,
1318 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1319 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1320 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1321 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1322 X86_COND_G, EFLAGS))]>,
1324 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1325 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1326 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1327 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1328 X86_COND_S, EFLAGS))]>,
1330 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1331 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1332 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1333 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1334 X86_COND_S, EFLAGS))]>,
1336 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1337 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1338 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1339 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1340 X86_COND_NS, EFLAGS))]>,
1342 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1343 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1344 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1345 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1346 X86_COND_NS, EFLAGS))]>,
1348 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1349 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1350 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1351 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1352 X86_COND_P, EFLAGS))]>,
1354 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1355 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1356 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1357 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1358 X86_COND_P, EFLAGS))]>,
1360 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1361 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1362 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1363 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1364 X86_COND_NP, EFLAGS))]>,
1366 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1367 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1368 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1369 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1370 X86_COND_NP, EFLAGS))]>,
1372 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1373 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1374 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1375 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1376 X86_COND_O, EFLAGS))]>,
1378 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1379 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1380 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1381 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1382 X86_COND_O, EFLAGS))]>,
1384 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1385 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1386 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1387 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1388 X86_COND_NO, EFLAGS))]>,
1390 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1391 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1392 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1393 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1394 X86_COND_NO, EFLAGS))]>,
1396 } // isCommutable = 1
1398 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1399 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1400 "cmovb{w}\t{$src2, $dst|$dst, $src2}",
1401 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1402 X86_COND_B, EFLAGS))]>,
1404 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1405 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1406 "cmovb{l}\t{$src2, $dst|$dst, $src2}",
1407 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1408 X86_COND_B, EFLAGS))]>,
1410 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1411 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1412 "cmovae{w}\t{$src2, $dst|$dst, $src2}",
1413 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1414 X86_COND_AE, EFLAGS))]>,
1416 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1417 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1418 "cmovae{l}\t{$src2, $dst|$dst, $src2}",
1419 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1420 X86_COND_AE, EFLAGS))]>,
1422 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1423 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1424 "cmove{w}\t{$src2, $dst|$dst, $src2}",
1425 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1426 X86_COND_E, EFLAGS))]>,
1428 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1429 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1430 "cmove{l}\t{$src2, $dst|$dst, $src2}",
1431 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1432 X86_COND_E, EFLAGS))]>,
1434 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1435 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1436 "cmovne{w}\t{$src2, $dst|$dst, $src2}",
1437 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1438 X86_COND_NE, EFLAGS))]>,
1440 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1441 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1442 "cmovne{l}\t{$src2, $dst|$dst, $src2}",
1443 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1444 X86_COND_NE, EFLAGS))]>,
1446 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1447 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1448 "cmovbe{w}\t{$src2, $dst|$dst, $src2}",
1449 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1450 X86_COND_BE, EFLAGS))]>,
1452 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1453 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1454 "cmovbe{l}\t{$src2, $dst|$dst, $src2}",
1455 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1456 X86_COND_BE, EFLAGS))]>,
1458 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1459 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1460 "cmova{w}\t{$src2, $dst|$dst, $src2}",
1461 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1462 X86_COND_A, EFLAGS))]>,
1464 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1465 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1466 "cmova{l}\t{$src2, $dst|$dst, $src2}",
1467 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1468 X86_COND_A, EFLAGS))]>,
1470 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1471 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1472 "cmovl{w}\t{$src2, $dst|$dst, $src2}",
1473 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1474 X86_COND_L, EFLAGS))]>,
1476 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1477 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1478 "cmovl{l}\t{$src2, $dst|$dst, $src2}",
1479 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1480 X86_COND_L, EFLAGS))]>,
1482 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1483 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1484 "cmovge{w}\t{$src2, $dst|$dst, $src2}",
1485 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1486 X86_COND_GE, EFLAGS))]>,
1488 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1489 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1490 "cmovge{l}\t{$src2, $dst|$dst, $src2}",
1491 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1492 X86_COND_GE, EFLAGS))]>,
1494 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1495 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1496 "cmovle{w}\t{$src2, $dst|$dst, $src2}",
1497 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1498 X86_COND_LE, EFLAGS))]>,
1500 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1501 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1502 "cmovle{l}\t{$src2, $dst|$dst, $src2}",
1503 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1504 X86_COND_LE, EFLAGS))]>,
1506 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1507 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1508 "cmovg{w}\t{$src2, $dst|$dst, $src2}",
1509 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1510 X86_COND_G, EFLAGS))]>,
1512 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1513 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1514 "cmovg{l}\t{$src2, $dst|$dst, $src2}",
1515 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1516 X86_COND_G, EFLAGS))]>,
1518 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1519 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1520 "cmovs{w}\t{$src2, $dst|$dst, $src2}",
1521 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1522 X86_COND_S, EFLAGS))]>,
1524 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1525 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1526 "cmovs{l}\t{$src2, $dst|$dst, $src2}",
1527 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1528 X86_COND_S, EFLAGS))]>,
1530 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1531 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1532 "cmovns{w}\t{$src2, $dst|$dst, $src2}",
1533 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1534 X86_COND_NS, EFLAGS))]>,
1536 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1537 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1538 "cmovns{l}\t{$src2, $dst|$dst, $src2}",
1539 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1540 X86_COND_NS, EFLAGS))]>,
1542 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1543 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1544 "cmovp{w}\t{$src2, $dst|$dst, $src2}",
1545 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1546 X86_COND_P, EFLAGS))]>,
1548 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1549 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1550 "cmovp{l}\t{$src2, $dst|$dst, $src2}",
1551 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1552 X86_COND_P, EFLAGS))]>,
1554 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1555 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1556 "cmovnp{w}\t{$src2, $dst|$dst, $src2}",
1557 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1558 X86_COND_NP, EFLAGS))]>,
1560 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1561 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1562 "cmovnp{l}\t{$src2, $dst|$dst, $src2}",
1563 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1564 X86_COND_NP, EFLAGS))]>,
1566 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1567 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1568 "cmovo{w}\t{$src2, $dst|$dst, $src2}",
1569 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1570 X86_COND_O, EFLAGS))]>,
1572 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1573 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1574 "cmovo{l}\t{$src2, $dst|$dst, $src2}",
1575 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1576 X86_COND_O, EFLAGS))]>,
1578 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1579 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1580 "cmovno{w}\t{$src2, $dst|$dst, $src2}",
1581 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1582 X86_COND_NO, EFLAGS))]>,
1584 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1585 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1586 "cmovno{l}\t{$src2, $dst|$dst, $src2}",
1587 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1588 X86_COND_NO, EFLAGS))]>,
1590 } // Uses = [EFLAGS]
1593 // unary instructions
1594 let CodeSize = 2 in {
1595 let Defs = [EFLAGS] in {
1596 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1597 [(set GR8:$dst, (ineg GR8:$src)),
1598 (implicit EFLAGS)]>;
1599 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1600 [(set GR16:$dst, (ineg GR16:$src)),
1601 (implicit EFLAGS)]>, OpSize;
1602 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1603 [(set GR32:$dst, (ineg GR32:$src)),
1604 (implicit EFLAGS)]>;
1605 let isTwoAddress = 0 in {
1606 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1607 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1608 (implicit EFLAGS)]>;
1609 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1610 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1611 (implicit EFLAGS)]>, OpSize;
1612 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1613 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1614 (implicit EFLAGS)]>;
1616 } // Defs = [EFLAGS]
1618 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1619 let AddedComplexity = 15 in {
1620 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1621 [(set GR8:$dst, (not GR8:$src))]>;
1622 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1623 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1624 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1625 [(set GR32:$dst, (not GR32:$src))]>;
1627 let isTwoAddress = 0 in {
1628 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1629 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1630 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1631 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1632 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1633 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1637 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1638 let Defs = [EFLAGS] in {
1640 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1641 [(set GR8:$dst, (add GR8:$src, 1)),
1642 (implicit EFLAGS)]>;
1643 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1644 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1646 [(set GR16:$dst, (add GR16:$src, 1)),
1647 (implicit EFLAGS)]>,
1648 OpSize, Requires<[In32BitMode]>;
1649 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1651 [(set GR32:$dst, (add GR32:$src, 1)),
1652 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1654 let isTwoAddress = 0, CodeSize = 2 in {
1655 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1656 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1657 (implicit EFLAGS)]>;
1658 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1659 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1660 (implicit EFLAGS)]>,
1661 OpSize, Requires<[In32BitMode]>;
1662 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1663 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1664 (implicit EFLAGS)]>,
1665 Requires<[In32BitMode]>;
1669 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1670 [(set GR8:$dst, (add GR8:$src, -1)),
1671 (implicit EFLAGS)]>;
1672 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1673 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
1675 [(set GR16:$dst, (add GR16:$src, -1)),
1676 (implicit EFLAGS)]>,
1677 OpSize, Requires<[In32BitMode]>;
1678 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
1680 [(set GR32:$dst, (add GR32:$src, -1)),
1681 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1684 let isTwoAddress = 0, CodeSize = 2 in {
1685 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1686 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1687 (implicit EFLAGS)]>;
1688 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1689 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1690 (implicit EFLAGS)]>,
1691 OpSize, Requires<[In32BitMode]>;
1692 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1693 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1694 (implicit EFLAGS)]>,
1695 Requires<[In32BitMode]>;
1697 } // Defs = [EFLAGS]
1699 // Logical operators...
1700 let Defs = [EFLAGS] in {
1701 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1702 def AND8rr : I<0x20, MRMDestReg,
1703 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1704 "and{b}\t{$src2, $dst|$dst, $src2}",
1705 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1706 (implicit EFLAGS)]>;
1707 def AND16rr : I<0x21, MRMDestReg,
1708 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1709 "and{w}\t{$src2, $dst|$dst, $src2}",
1710 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1711 (implicit EFLAGS)]>, OpSize;
1712 def AND32rr : I<0x21, MRMDestReg,
1713 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1714 "and{l}\t{$src2, $dst|$dst, $src2}",
1715 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1716 (implicit EFLAGS)]>;
1719 // AND instructions with the destination register in REG and the source register
1720 // in R/M. Included for the disassembler.
1721 def AND8rr_REV : I<0x22, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1722 "and{b}\t{$src2, $dst|$dst, $src2}", []>;
1723 def AND16rr_REV : I<0x23, MRMSrcReg, (outs GR16:$dst),
1724 (ins GR16:$src1, GR16:$src2),
1725 "and{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1726 def AND32rr_REV : I<0x23, MRMSrcReg, (outs GR32:$dst),
1727 (ins GR32:$src1, GR32:$src2),
1728 "and{l}\t{$src2, $dst|$dst, $src2}", []>;
1730 def AND8rm : I<0x22, MRMSrcMem,
1731 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1732 "and{b}\t{$src2, $dst|$dst, $src2}",
1733 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1734 (implicit EFLAGS)]>;
1735 def AND16rm : I<0x23, MRMSrcMem,
1736 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1737 "and{w}\t{$src2, $dst|$dst, $src2}",
1738 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1739 (implicit EFLAGS)]>, OpSize;
1740 def AND32rm : I<0x23, MRMSrcMem,
1741 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1742 "and{l}\t{$src2, $dst|$dst, $src2}",
1743 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1744 (implicit EFLAGS)]>;
1746 def AND8ri : Ii8<0x80, MRM4r,
1747 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1748 "and{b}\t{$src2, $dst|$dst, $src2}",
1749 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1750 (implicit EFLAGS)]>;
1751 def AND16ri : Ii16<0x81, MRM4r,
1752 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1753 "and{w}\t{$src2, $dst|$dst, $src2}",
1754 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1755 (implicit EFLAGS)]>, OpSize;
1756 def AND32ri : Ii32<0x81, MRM4r,
1757 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1758 "and{l}\t{$src2, $dst|$dst, $src2}",
1759 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1760 (implicit EFLAGS)]>;
1761 def AND16ri8 : Ii8<0x83, MRM4r,
1762 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1763 "and{w}\t{$src2, $dst|$dst, $src2}",
1764 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1765 (implicit EFLAGS)]>,
1767 def AND32ri8 : Ii8<0x83, MRM4r,
1768 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1769 "and{l}\t{$src2, $dst|$dst, $src2}",
1770 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1771 (implicit EFLAGS)]>;
1773 let isTwoAddress = 0 in {
1774 def AND8mr : I<0x20, MRMDestMem,
1775 (outs), (ins i8mem :$dst, GR8 :$src),
1776 "and{b}\t{$src, $dst|$dst, $src}",
1777 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1778 (implicit EFLAGS)]>;
1779 def AND16mr : I<0x21, MRMDestMem,
1780 (outs), (ins i16mem:$dst, GR16:$src),
1781 "and{w}\t{$src, $dst|$dst, $src}",
1782 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1783 (implicit EFLAGS)]>,
1785 def AND32mr : I<0x21, MRMDestMem,
1786 (outs), (ins i32mem:$dst, GR32:$src),
1787 "and{l}\t{$src, $dst|$dst, $src}",
1788 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1789 (implicit EFLAGS)]>;
1790 def AND8mi : Ii8<0x80, MRM4m,
1791 (outs), (ins i8mem :$dst, i8imm :$src),
1792 "and{b}\t{$src, $dst|$dst, $src}",
1793 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1794 (implicit EFLAGS)]>;
1795 def AND16mi : Ii16<0x81, MRM4m,
1796 (outs), (ins i16mem:$dst, i16imm:$src),
1797 "and{w}\t{$src, $dst|$dst, $src}",
1798 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1799 (implicit EFLAGS)]>,
1801 def AND32mi : Ii32<0x81, MRM4m,
1802 (outs), (ins i32mem:$dst, i32imm:$src),
1803 "and{l}\t{$src, $dst|$dst, $src}",
1804 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1805 (implicit EFLAGS)]>;
1806 def AND16mi8 : Ii8<0x83, MRM4m,
1807 (outs), (ins i16mem:$dst, i16i8imm :$src),
1808 "and{w}\t{$src, $dst|$dst, $src}",
1809 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1810 (implicit EFLAGS)]>,
1812 def AND32mi8 : Ii8<0x83, MRM4m,
1813 (outs), (ins i32mem:$dst, i32i8imm :$src),
1814 "and{l}\t{$src, $dst|$dst, $src}",
1815 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1816 (implicit EFLAGS)]>;
1818 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1819 "and{b}\t{$src, %al|%al, $src}", []>;
1820 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1821 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1822 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1823 "and{l}\t{$src, %eax|%eax, $src}", []>;
1828 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1829 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst),
1830 (ins GR8 :$src1, GR8 :$src2),
1831 "or{b}\t{$src2, $dst|$dst, $src2}",
1832 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1833 (implicit EFLAGS)]>;
1834 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst),
1835 (ins GR16:$src1, GR16:$src2),
1836 "or{w}\t{$src2, $dst|$dst, $src2}",
1837 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1838 (implicit EFLAGS)]>, OpSize;
1839 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst),
1840 (ins GR32:$src1, GR32:$src2),
1841 "or{l}\t{$src2, $dst|$dst, $src2}",
1842 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1843 (implicit EFLAGS)]>;
1846 // OR instructions with the destination register in REG and the source register
1847 // in R/M. Included for the disassembler.
1848 def OR8rr_REV : I<0x0A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1849 "or{b}\t{$src2, $dst|$dst, $src2}", []>;
1850 def OR16rr_REV : I<0x0B, MRMSrcReg, (outs GR16:$dst),
1851 (ins GR16:$src1, GR16:$src2),
1852 "or{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1853 def OR32rr_REV : I<0x0B, MRMSrcReg, (outs GR32:$dst),
1854 (ins GR32:$src1, GR32:$src2),
1855 "or{l}\t{$src2, $dst|$dst, $src2}", []>;
1857 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst),
1858 (ins GR8 :$src1, i8mem :$src2),
1859 "or{b}\t{$src2, $dst|$dst, $src2}",
1860 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1861 (implicit EFLAGS)]>;
1862 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst),
1863 (ins GR16:$src1, i16mem:$src2),
1864 "or{w}\t{$src2, $dst|$dst, $src2}",
1865 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1866 (implicit EFLAGS)]>, OpSize;
1867 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst),
1868 (ins GR32:$src1, i32mem:$src2),
1869 "or{l}\t{$src2, $dst|$dst, $src2}",
1870 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1871 (implicit EFLAGS)]>;
1873 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst),
1874 (ins GR8 :$src1, i8imm:$src2),
1875 "or{b}\t{$src2, $dst|$dst, $src2}",
1876 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1877 (implicit EFLAGS)]>;
1878 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst),
1879 (ins GR16:$src1, i16imm:$src2),
1880 "or{w}\t{$src2, $dst|$dst, $src2}",
1881 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1882 (implicit EFLAGS)]>, OpSize;
1883 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst),
1884 (ins GR32:$src1, i32imm:$src2),
1885 "or{l}\t{$src2, $dst|$dst, $src2}",
1886 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1887 (implicit EFLAGS)]>;
1889 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst),
1890 (ins GR16:$src1, i16i8imm:$src2),
1891 "or{w}\t{$src2, $dst|$dst, $src2}",
1892 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1893 (implicit EFLAGS)]>, OpSize;
1894 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst),
1895 (ins GR32:$src1, i32i8imm:$src2),
1896 "or{l}\t{$src2, $dst|$dst, $src2}",
1897 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1898 (implicit EFLAGS)]>;
1899 let isTwoAddress = 0 in {
1900 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1901 "or{b}\t{$src, $dst|$dst, $src}",
1902 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1903 (implicit EFLAGS)]>;
1904 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1905 "or{w}\t{$src, $dst|$dst, $src}",
1906 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1907 (implicit EFLAGS)]>, OpSize;
1908 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1909 "or{l}\t{$src, $dst|$dst, $src}",
1910 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1911 (implicit EFLAGS)]>;
1912 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1913 "or{b}\t{$src, $dst|$dst, $src}",
1914 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1915 (implicit EFLAGS)]>;
1916 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1917 "or{w}\t{$src, $dst|$dst, $src}",
1918 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1919 (implicit EFLAGS)]>,
1921 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1922 "or{l}\t{$src, $dst|$dst, $src}",
1923 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1924 (implicit EFLAGS)]>;
1925 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1926 "or{w}\t{$src, $dst|$dst, $src}",
1927 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1928 (implicit EFLAGS)]>,
1930 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1931 "or{l}\t{$src, $dst|$dst, $src}",
1932 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1933 (implicit EFLAGS)]>;
1935 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1936 "or{b}\t{$src, %al|%al, $src}", []>;
1937 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1938 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1939 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1940 "or{l}\t{$src, %eax|%eax, $src}", []>;
1941 } // isTwoAddress = 0
1944 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1945 def XOR8rr : I<0x30, MRMDestReg,
1946 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1947 "xor{b}\t{$src2, $dst|$dst, $src2}",
1948 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1949 (implicit EFLAGS)]>;
1950 def XOR16rr : I<0x31, MRMDestReg,
1951 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1952 "xor{w}\t{$src2, $dst|$dst, $src2}",
1953 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1954 (implicit EFLAGS)]>, OpSize;
1955 def XOR32rr : I<0x31, MRMDestReg,
1956 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1957 "xor{l}\t{$src2, $dst|$dst, $src2}",
1958 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1959 (implicit EFLAGS)]>;
1960 } // isCommutable = 1
1962 // XOR instructions with the destination register in REG and the source register
1963 // in R/M. Included for the disassembler.
1964 def XOR8rr_REV : I<0x32, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
1965 "xor{b}\t{$src2, $dst|$dst, $src2}", []>;
1966 def XOR16rr_REV : I<0x33, MRMSrcReg, (outs GR16:$dst),
1967 (ins GR16:$src1, GR16:$src2),
1968 "xor{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
1969 def XOR32rr_REV : I<0x33, MRMSrcReg, (outs GR32:$dst),
1970 (ins GR32:$src1, GR32:$src2),
1971 "xor{l}\t{$src2, $dst|$dst, $src2}", []>;
1973 def XOR8rm : I<0x32, MRMSrcMem ,
1974 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1975 "xor{b}\t{$src2, $dst|$dst, $src2}",
1976 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1977 (implicit EFLAGS)]>;
1978 def XOR16rm : I<0x33, MRMSrcMem ,
1979 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1980 "xor{w}\t{$src2, $dst|$dst, $src2}",
1981 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1982 (implicit EFLAGS)]>,
1984 def XOR32rm : I<0x33, MRMSrcMem ,
1985 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1986 "xor{l}\t{$src2, $dst|$dst, $src2}",
1987 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1988 (implicit EFLAGS)]>;
1990 def XOR8ri : Ii8<0x80, MRM6r,
1991 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1992 "xor{b}\t{$src2, $dst|$dst, $src2}",
1993 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1994 (implicit EFLAGS)]>;
1995 def XOR16ri : Ii16<0x81, MRM6r,
1996 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1997 "xor{w}\t{$src2, $dst|$dst, $src2}",
1998 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1999 (implicit EFLAGS)]>, OpSize;
2000 def XOR32ri : Ii32<0x81, MRM6r,
2001 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2002 "xor{l}\t{$src2, $dst|$dst, $src2}",
2003 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
2004 (implicit EFLAGS)]>;
2005 def XOR16ri8 : Ii8<0x83, MRM6r,
2006 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2007 "xor{w}\t{$src2, $dst|$dst, $src2}",
2008 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
2009 (implicit EFLAGS)]>,
2011 def XOR32ri8 : Ii8<0x83, MRM6r,
2012 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2013 "xor{l}\t{$src2, $dst|$dst, $src2}",
2014 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
2015 (implicit EFLAGS)]>;
2017 let isTwoAddress = 0 in {
2018 def XOR8mr : I<0x30, MRMDestMem,
2019 (outs), (ins i8mem :$dst, GR8 :$src),
2020 "xor{b}\t{$src, $dst|$dst, $src}",
2021 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
2022 (implicit EFLAGS)]>;
2023 def XOR16mr : I<0x31, MRMDestMem,
2024 (outs), (ins i16mem:$dst, GR16:$src),
2025 "xor{w}\t{$src, $dst|$dst, $src}",
2026 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
2027 (implicit EFLAGS)]>,
2029 def XOR32mr : I<0x31, MRMDestMem,
2030 (outs), (ins i32mem:$dst, GR32:$src),
2031 "xor{l}\t{$src, $dst|$dst, $src}",
2032 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
2033 (implicit EFLAGS)]>;
2034 def XOR8mi : Ii8<0x80, MRM6m,
2035 (outs), (ins i8mem :$dst, i8imm :$src),
2036 "xor{b}\t{$src, $dst|$dst, $src}",
2037 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
2038 (implicit EFLAGS)]>;
2039 def XOR16mi : Ii16<0x81, MRM6m,
2040 (outs), (ins i16mem:$dst, i16imm:$src),
2041 "xor{w}\t{$src, $dst|$dst, $src}",
2042 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
2043 (implicit EFLAGS)]>,
2045 def XOR32mi : Ii32<0x81, MRM6m,
2046 (outs), (ins i32mem:$dst, i32imm:$src),
2047 "xor{l}\t{$src, $dst|$dst, $src}",
2048 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
2049 (implicit EFLAGS)]>;
2050 def XOR16mi8 : Ii8<0x83, MRM6m,
2051 (outs), (ins i16mem:$dst, i16i8imm :$src),
2052 "xor{w}\t{$src, $dst|$dst, $src}",
2053 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
2054 (implicit EFLAGS)]>,
2056 def XOR32mi8 : Ii8<0x83, MRM6m,
2057 (outs), (ins i32mem:$dst, i32i8imm :$src),
2058 "xor{l}\t{$src, $dst|$dst, $src}",
2059 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
2060 (implicit EFLAGS)]>;
2062 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
2063 "xor{b}\t{$src, %al|%al, $src}", []>;
2064 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
2065 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2066 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
2067 "xor{l}\t{$src, %eax|%eax, $src}", []>;
2068 } // isTwoAddress = 0
2069 } // Defs = [EFLAGS]
2071 // Shift instructions
2072 let Defs = [EFLAGS] in {
2073 let Uses = [CL] in {
2074 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
2075 "shl{b}\t{%cl, $dst|$dst, CL}",
2076 [(set GR8:$dst, (shl GR8:$src, CL))]>;
2077 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
2078 "shl{w}\t{%cl, $dst|$dst, CL}",
2079 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
2080 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
2081 "shl{l}\t{%cl, $dst|$dst, CL}",
2082 [(set GR32:$dst, (shl GR32:$src, CL))]>;
2085 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2086 "shl{b}\t{$src2, $dst|$dst, $src2}",
2087 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
2088 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2089 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2090 "shl{w}\t{$src2, $dst|$dst, $src2}",
2091 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2092 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2093 "shl{l}\t{$src2, $dst|$dst, $src2}",
2094 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
2096 // NOTE: We don't include patterns for shifts of a register by one, because
2097 // 'add reg,reg' is cheaper.
2099 def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
2100 "shl{b}\t$dst", []>;
2101 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
2102 "shl{w}\t$dst", []>, OpSize;
2103 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
2104 "shl{l}\t$dst", []>;
2106 } // isConvertibleToThreeAddress = 1
2108 let isTwoAddress = 0 in {
2109 let Uses = [CL] in {
2110 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
2111 "shl{b}\t{%cl, $dst|$dst, CL}",
2112 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
2113 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
2114 "shl{w}\t{%cl, $dst|$dst, CL}",
2115 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2116 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
2117 "shl{l}\t{%cl, $dst|$dst, CL}",
2118 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
2120 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
2121 "shl{b}\t{$src, $dst|$dst, $src}",
2122 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2123 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
2124 "shl{w}\t{$src, $dst|$dst, $src}",
2125 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2127 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
2128 "shl{l}\t{$src, $dst|$dst, $src}",
2129 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2132 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
2134 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2135 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
2137 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2139 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
2141 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2144 let Uses = [CL] in {
2145 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
2146 "shr{b}\t{%cl, $dst|$dst, CL}",
2147 [(set GR8:$dst, (srl GR8:$src, CL))]>;
2148 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
2149 "shr{w}\t{%cl, $dst|$dst, CL}",
2150 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
2151 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
2152 "shr{l}\t{%cl, $dst|$dst, CL}",
2153 [(set GR32:$dst, (srl GR32:$src, CL))]>;
2156 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2157 "shr{b}\t{$src2, $dst|$dst, $src2}",
2158 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
2159 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2160 "shr{w}\t{$src2, $dst|$dst, $src2}",
2161 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2162 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2163 "shr{l}\t{$src2, $dst|$dst, $src2}",
2164 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2167 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
2169 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
2170 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
2172 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
2173 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
2175 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2177 let isTwoAddress = 0 in {
2178 let Uses = [CL] in {
2179 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
2180 "shr{b}\t{%cl, $dst|$dst, CL}",
2181 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
2182 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
2183 "shr{w}\t{%cl, $dst|$dst, CL}",
2184 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
2186 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
2187 "shr{l}\t{%cl, $dst|$dst, CL}",
2188 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2190 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
2191 "shr{b}\t{$src, $dst|$dst, $src}",
2192 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2193 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
2194 "shr{w}\t{$src, $dst|$dst, $src}",
2195 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2197 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
2198 "shr{l}\t{$src, $dst|$dst, $src}",
2199 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2202 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
2204 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2205 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
2207 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
2208 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
2210 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2213 let Uses = [CL] in {
2214 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
2215 "sar{b}\t{%cl, $dst|$dst, CL}",
2216 [(set GR8:$dst, (sra GR8:$src, CL))]>;
2217 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
2218 "sar{w}\t{%cl, $dst|$dst, CL}",
2219 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
2220 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
2221 "sar{l}\t{%cl, $dst|$dst, CL}",
2222 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2225 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2226 "sar{b}\t{$src2, $dst|$dst, $src2}",
2227 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
2228 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2229 "sar{w}\t{$src2, $dst|$dst, $src2}",
2230 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2232 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2233 "sar{l}\t{$src2, $dst|$dst, $src2}",
2234 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2237 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
2239 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
2240 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
2242 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
2243 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
2245 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2247 let isTwoAddress = 0 in {
2248 let Uses = [CL] in {
2249 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
2250 "sar{b}\t{%cl, $dst|$dst, CL}",
2251 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
2252 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
2253 "sar{w}\t{%cl, $dst|$dst, CL}",
2254 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2255 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
2256 "sar{l}\t{%cl, $dst|$dst, CL}",
2257 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2259 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
2260 "sar{b}\t{$src, $dst|$dst, $src}",
2261 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2262 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
2263 "sar{w}\t{$src, $dst|$dst, $src}",
2264 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2266 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
2267 "sar{l}\t{$src, $dst|$dst, $src}",
2268 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2271 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
2273 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2274 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
2276 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2278 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
2280 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2283 // Rotate instructions
2285 def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2286 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2287 def RCL8m1 : I<0xD0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2288 "rcl{b}\t{1, $dst|$dst, 1}", []>;
2289 let Uses = [CL] in {
2290 def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src),
2291 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2292 def RCL8mCL : I<0xD2, MRM2m, (outs i8mem:$dst), (ins i8mem:$src),
2293 "rcl{b}\t{%cl, $dst|$dst, CL}", []>;
2295 def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2296 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2297 def RCL8mi : Ii8<0xC0, MRM2m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2298 "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2300 def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2301 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2302 def RCL16m1 : I<0xD1, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2303 "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2304 let Uses = [CL] in {
2305 def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src),
2306 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2307 def RCL16mCL : I<0xD3, MRM2m, (outs i16mem:$dst), (ins i16mem:$src),
2308 "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2310 def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2311 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2312 def RCL16mi : Ii8<0xC1, MRM2m, (outs i16mem:$dst),
2313 (ins i16mem:$src, i8imm:$cnt),
2314 "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2316 def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2317 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2318 def RCL32m1 : I<0xD1, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2319 "rcl{l}\t{1, $dst|$dst, 1}", []>;
2320 let Uses = [CL] in {
2321 def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src),
2322 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2323 def RCL32mCL : I<0xD3, MRM2m, (outs i32mem:$dst), (ins i32mem:$src),
2324 "rcl{l}\t{%cl, $dst|$dst, CL}", []>;
2326 def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2327 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2328 def RCL32mi : Ii8<0xC1, MRM2m, (outs i32mem:$dst),
2329 (ins i32mem:$src, i8imm:$cnt),
2330 "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2332 def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2333 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2334 def RCR8m1 : I<0xD0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2335 "rcr{b}\t{1, $dst|$dst, 1}", []>;
2336 let Uses = [CL] in {
2337 def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src),
2338 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2339 def RCR8mCL : I<0xD2, MRM3m, (outs i8mem:$dst), (ins i8mem:$src),
2340 "rcr{b}\t{%cl, $dst|$dst, CL}", []>;
2342 def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src, i8imm:$cnt),
2343 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2344 def RCR8mi : Ii8<0xC0, MRM3m, (outs i8mem:$dst), (ins i8mem:$src, i8imm:$cnt),
2345 "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>;
2347 def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2348 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2349 def RCR16m1 : I<0xD1, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2350 "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize;
2351 let Uses = [CL] in {
2352 def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src),
2353 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2354 def RCR16mCL : I<0xD3, MRM3m, (outs i16mem:$dst), (ins i16mem:$src),
2355 "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize;
2357 def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src, i8imm:$cnt),
2358 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2359 def RCR16mi : Ii8<0xC1, MRM3m, (outs i16mem:$dst),
2360 (ins i16mem:$src, i8imm:$cnt),
2361 "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize;
2363 def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2364 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2365 def RCR32m1 : I<0xD1, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2366 "rcr{l}\t{1, $dst|$dst, 1}", []>;
2367 let Uses = [CL] in {
2368 def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src),
2369 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2370 def RCR32mCL : I<0xD3, MRM3m, (outs i32mem:$dst), (ins i32mem:$src),
2371 "rcr{l}\t{%cl, $dst|$dst, CL}", []>;
2373 def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src, i8imm:$cnt),
2374 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2375 def RCR32mi : Ii8<0xC1, MRM3m, (outs i32mem:$dst),
2376 (ins i32mem:$src, i8imm:$cnt),
2377 "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>;
2379 // FIXME: provide shorter instructions when imm8 == 1
2380 let Uses = [CL] in {
2381 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
2382 "rol{b}\t{%cl, $dst|$dst, CL}",
2383 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
2384 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
2385 "rol{w}\t{%cl, $dst|$dst, CL}",
2386 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
2387 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
2388 "rol{l}\t{%cl, $dst|$dst, CL}",
2389 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2392 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2393 "rol{b}\t{$src2, $dst|$dst, $src2}",
2394 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2395 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2396 "rol{w}\t{$src2, $dst|$dst, $src2}",
2397 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>,
2399 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2400 "rol{l}\t{$src2, $dst|$dst, $src2}",
2401 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2404 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2406 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2407 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2409 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2410 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2412 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2414 let isTwoAddress = 0 in {
2415 let Uses = [CL] in {
2416 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2417 "rol{b}\t{%cl, $dst|$dst, CL}",
2418 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2419 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2420 "rol{w}\t{%cl, $dst|$dst, CL}",
2421 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2422 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2423 "rol{l}\t{%cl, $dst|$dst, CL}",
2424 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2426 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2427 "rol{b}\t{$src, $dst|$dst, $src}",
2428 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2429 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2430 "rol{w}\t{$src, $dst|$dst, $src}",
2431 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2433 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2434 "rol{l}\t{$src, $dst|$dst, $src}",
2435 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2438 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2440 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2441 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2443 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2445 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2447 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2450 let Uses = [CL] in {
2451 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2452 "ror{b}\t{%cl, $dst|$dst, CL}",
2453 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2454 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2455 "ror{w}\t{%cl, $dst|$dst, CL}",
2456 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2457 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2458 "ror{l}\t{%cl, $dst|$dst, CL}",
2459 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2462 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2463 "ror{b}\t{$src2, $dst|$dst, $src2}",
2464 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2465 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2466 "ror{w}\t{$src2, $dst|$dst, $src2}",
2467 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>,
2469 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2470 "ror{l}\t{$src2, $dst|$dst, $src2}",
2471 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2474 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2476 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2477 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2479 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2480 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2482 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2484 let isTwoAddress = 0 in {
2485 let Uses = [CL] in {
2486 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2487 "ror{b}\t{%cl, $dst|$dst, CL}",
2488 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2489 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2490 "ror{w}\t{%cl, $dst|$dst, CL}",
2491 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2492 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2493 "ror{l}\t{%cl, $dst|$dst, CL}",
2494 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2496 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2497 "ror{b}\t{$src, $dst|$dst, $src}",
2498 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2499 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2500 "ror{w}\t{$src, $dst|$dst, $src}",
2501 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2503 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2504 "ror{l}\t{$src, $dst|$dst, $src}",
2505 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2508 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2510 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2511 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2513 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2515 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2517 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2522 // Double shift instructions (generalizations of rotate)
2523 let Uses = [CL] in {
2524 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst),
2525 (ins GR32:$src1, GR32:$src2),
2526 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2527 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2528 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst),
2529 (ins GR32:$src1, GR32:$src2),
2530 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2531 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2532 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst),
2533 (ins GR16:$src1, GR16:$src2),
2534 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2535 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2537 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst),
2538 (ins GR16:$src1, GR16:$src2),
2539 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2540 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2544 let isCommutable = 1 in { // These instructions commute to each other.
2545 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2547 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2548 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2549 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2552 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2554 (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2555 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2556 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2559 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2561 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2562 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2563 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2566 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2568 (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2569 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2570 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2575 let isTwoAddress = 0 in {
2576 let Uses = [CL] in {
2577 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2578 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2579 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2581 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2582 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2583 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2586 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2587 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2588 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2589 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2590 (i8 imm:$src3)), addr:$dst)]>,
2592 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2593 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2594 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2595 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2596 (i8 imm:$src3)), addr:$dst)]>,
2599 let Uses = [CL] in {
2600 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2601 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2602 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2603 addr:$dst)]>, TB, OpSize;
2604 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2605 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2606 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2607 addr:$dst)]>, TB, OpSize;
2609 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2610 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2611 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2612 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2613 (i8 imm:$src3)), addr:$dst)]>,
2615 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2616 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2617 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2618 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2619 (i8 imm:$src3)), addr:$dst)]>,
2622 } // Defs = [EFLAGS]
2626 let Defs = [EFLAGS] in {
2627 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2628 // Register-Register Addition
2629 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2630 (ins GR8 :$src1, GR8 :$src2),
2631 "add{b}\t{$src2, $dst|$dst, $src2}",
2632 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2633 (implicit EFLAGS)]>;
2635 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2636 // Register-Register Addition
2637 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2638 (ins GR16:$src1, GR16:$src2),
2639 "add{w}\t{$src2, $dst|$dst, $src2}",
2640 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2641 (implicit EFLAGS)]>, OpSize;
2642 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2643 (ins GR32:$src1, GR32:$src2),
2644 "add{l}\t{$src2, $dst|$dst, $src2}",
2645 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2646 (implicit EFLAGS)]>;
2647 } // end isConvertibleToThreeAddress
2648 } // end isCommutable
2650 // Register-Memory Addition
2651 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2652 (ins GR8 :$src1, i8mem :$src2),
2653 "add{b}\t{$src2, $dst|$dst, $src2}",
2654 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2655 (implicit EFLAGS)]>;
2656 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2657 (ins GR16:$src1, i16mem:$src2),
2658 "add{w}\t{$src2, $dst|$dst, $src2}",
2659 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2660 (implicit EFLAGS)]>, OpSize;
2661 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2662 (ins GR32:$src1, i32mem:$src2),
2663 "add{l}\t{$src2, $dst|$dst, $src2}",
2664 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2665 (implicit EFLAGS)]>;
2667 // Register-Register Addition - Equivalent to the normal rr forms (ADD8rr,
2668 // ADD16rr, and ADD32rr), but differently encoded.
2669 def ADD8mrmrr: I<0x02, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2670 "add{b}\t{$src2, $dst|$dst, $src2}", []>;
2671 def ADD16mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2672 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2673 def ADD32mrmrr: I<0x03, MRMSrcReg,(outs GR16:$dst),(ins GR16:$src1, GR16:$src2),
2674 "add{l}\t{$src2, $dst|$dst, $src2}", []>;
2676 // Register-Integer Addition
2677 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2678 "add{b}\t{$src2, $dst|$dst, $src2}",
2679 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2680 (implicit EFLAGS)]>;
2682 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2683 // Register-Integer Addition
2684 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2685 (ins GR16:$src1, i16imm:$src2),
2686 "add{w}\t{$src2, $dst|$dst, $src2}",
2687 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2688 (implicit EFLAGS)]>, OpSize;
2689 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2690 (ins GR32:$src1, i32imm:$src2),
2691 "add{l}\t{$src2, $dst|$dst, $src2}",
2692 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2693 (implicit EFLAGS)]>;
2694 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2695 (ins GR16:$src1, i16i8imm:$src2),
2696 "add{w}\t{$src2, $dst|$dst, $src2}",
2697 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2698 (implicit EFLAGS)]>, OpSize;
2699 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2700 (ins GR32:$src1, i32i8imm:$src2),
2701 "add{l}\t{$src2, $dst|$dst, $src2}",
2702 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2703 (implicit EFLAGS)]>;
2706 let isTwoAddress = 0 in {
2707 // Memory-Register Addition
2708 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2709 "add{b}\t{$src2, $dst|$dst, $src2}",
2710 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2711 (implicit EFLAGS)]>;
2712 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2713 "add{w}\t{$src2, $dst|$dst, $src2}",
2714 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2715 (implicit EFLAGS)]>, OpSize;
2716 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2717 "add{l}\t{$src2, $dst|$dst, $src2}",
2718 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2719 (implicit EFLAGS)]>;
2720 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2721 "add{b}\t{$src2, $dst|$dst, $src2}",
2722 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2723 (implicit EFLAGS)]>;
2724 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2725 "add{w}\t{$src2, $dst|$dst, $src2}",
2726 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2727 (implicit EFLAGS)]>, OpSize;
2728 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2729 "add{l}\t{$src2, $dst|$dst, $src2}",
2730 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2731 (implicit EFLAGS)]>;
2732 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2733 "add{w}\t{$src2, $dst|$dst, $src2}",
2734 [(store (add (load addr:$dst), i16immSExt8:$src2),
2736 (implicit EFLAGS)]>, OpSize;
2737 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2738 "add{l}\t{$src2, $dst|$dst, $src2}",
2739 [(store (add (load addr:$dst), i32immSExt8:$src2),
2741 (implicit EFLAGS)]>;
2744 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2745 "add{b}\t{$src, %al|%al, $src}", []>;
2746 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2747 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2748 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2749 "add{l}\t{$src, %eax|%eax, $src}", []>;
2752 let Uses = [EFLAGS] in {
2753 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2754 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2755 "adc{b}\t{$src2, $dst|$dst, $src2}",
2756 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2757 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2758 (ins GR16:$src1, GR16:$src2),
2759 "adc{w}\t{$src2, $dst|$dst, $src2}",
2760 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2761 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2762 (ins GR32:$src1, GR32:$src2),
2763 "adc{l}\t{$src2, $dst|$dst, $src2}",
2764 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2767 def ADC8rr_REV : I<0x12, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2768 "adc{b}\t{$src2, $dst|$dst, $src2}", []>;
2769 def ADC16rr_REV : I<0x13, MRMSrcReg, (outs GR16:$dst),
2770 (ins GR16:$src1, GR16:$src2),
2771 "adc{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2772 def ADC32rr_REV : I<0x13, MRMSrcReg, (outs GR32:$dst),
2773 (ins GR32:$src1, GR32:$src2),
2774 "adc{l}\t{$src2, $dst|$dst, $src2}", []>;
2776 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2777 (ins GR8:$src1, i8mem:$src2),
2778 "adc{b}\t{$src2, $dst|$dst, $src2}",
2779 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2780 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2781 (ins GR16:$src1, i16mem:$src2),
2782 "adc{w}\t{$src2, $dst|$dst, $src2}",
2783 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2785 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2786 (ins GR32:$src1, i32mem:$src2),
2787 "adc{l}\t{$src2, $dst|$dst, $src2}",
2788 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2789 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2790 "adc{b}\t{$src2, $dst|$dst, $src2}",
2791 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2792 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2793 (ins GR16:$src1, i16imm:$src2),
2794 "adc{w}\t{$src2, $dst|$dst, $src2}",
2795 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2796 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2797 (ins GR16:$src1, i16i8imm:$src2),
2798 "adc{w}\t{$src2, $dst|$dst, $src2}",
2799 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2801 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2802 (ins GR32:$src1, i32imm:$src2),
2803 "adc{l}\t{$src2, $dst|$dst, $src2}",
2804 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2805 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2806 (ins GR32:$src1, i32i8imm:$src2),
2807 "adc{l}\t{$src2, $dst|$dst, $src2}",
2808 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2810 let isTwoAddress = 0 in {
2811 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2812 "adc{b}\t{$src2, $dst|$dst, $src2}",
2813 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2814 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2815 "adc{w}\t{$src2, $dst|$dst, $src2}",
2816 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2818 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2819 "adc{l}\t{$src2, $dst|$dst, $src2}",
2820 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2821 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2822 "adc{b}\t{$src2, $dst|$dst, $src2}",
2823 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2824 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2825 "adc{w}\t{$src2, $dst|$dst, $src2}",
2826 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2828 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2829 "adc{w}\t{$src2, $dst|$dst, $src2}",
2830 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2832 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2833 "adc{l}\t{$src2, $dst|$dst, $src2}",
2834 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2835 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2836 "adc{l}\t{$src2, $dst|$dst, $src2}",
2837 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2839 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2840 "adc{b}\t{$src, %al|%al, $src}", []>;
2841 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2842 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2843 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2844 "adc{l}\t{$src, %eax|%eax, $src}", []>;
2846 } // Uses = [EFLAGS]
2848 // Register-Register Subtraction
2849 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2850 "sub{b}\t{$src2, $dst|$dst, $src2}",
2851 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2852 (implicit EFLAGS)]>;
2853 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2854 "sub{w}\t{$src2, $dst|$dst, $src2}",
2855 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2856 (implicit EFLAGS)]>, OpSize;
2857 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2858 "sub{l}\t{$src2, $dst|$dst, $src2}",
2859 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2860 (implicit EFLAGS)]>;
2862 def SUB8rr_REV : I<0x2A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2863 "sub{b}\t{$src2, $dst|$dst, $src2}", []>;
2864 def SUB16rr_REV : I<0x2B, MRMSrcReg, (outs GR16:$dst),
2865 (ins GR16:$src1, GR16:$src2),
2866 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
2867 def SUB32rr_REV : I<0x2B, MRMSrcReg, (outs GR32:$dst),
2868 (ins GR32:$src1, GR32:$src2),
2869 "sub{l}\t{$src2, $dst|$dst, $src2}", []>;
2871 // Register-Memory Subtraction
2872 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2873 (ins GR8 :$src1, i8mem :$src2),
2874 "sub{b}\t{$src2, $dst|$dst, $src2}",
2875 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2876 (implicit EFLAGS)]>;
2877 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2878 (ins GR16:$src1, i16mem:$src2),
2879 "sub{w}\t{$src2, $dst|$dst, $src2}",
2880 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2881 (implicit EFLAGS)]>, OpSize;
2882 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2883 (ins GR32:$src1, i32mem:$src2),
2884 "sub{l}\t{$src2, $dst|$dst, $src2}",
2885 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2886 (implicit EFLAGS)]>;
2888 // Register-Integer Subtraction
2889 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2890 (ins GR8:$src1, i8imm:$src2),
2891 "sub{b}\t{$src2, $dst|$dst, $src2}",
2892 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2893 (implicit EFLAGS)]>;
2894 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2895 (ins GR16:$src1, i16imm:$src2),
2896 "sub{w}\t{$src2, $dst|$dst, $src2}",
2897 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2898 (implicit EFLAGS)]>, OpSize;
2899 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2900 (ins GR32:$src1, i32imm:$src2),
2901 "sub{l}\t{$src2, $dst|$dst, $src2}",
2902 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2903 (implicit EFLAGS)]>;
2904 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2905 (ins GR16:$src1, i16i8imm:$src2),
2906 "sub{w}\t{$src2, $dst|$dst, $src2}",
2907 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2908 (implicit EFLAGS)]>, OpSize;
2909 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2910 (ins GR32:$src1, i32i8imm:$src2),
2911 "sub{l}\t{$src2, $dst|$dst, $src2}",
2912 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2913 (implicit EFLAGS)]>;
2915 let isTwoAddress = 0 in {
2916 // Memory-Register Subtraction
2917 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2918 "sub{b}\t{$src2, $dst|$dst, $src2}",
2919 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2920 (implicit EFLAGS)]>;
2921 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2922 "sub{w}\t{$src2, $dst|$dst, $src2}",
2923 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2924 (implicit EFLAGS)]>, OpSize;
2925 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2926 "sub{l}\t{$src2, $dst|$dst, $src2}",
2927 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2928 (implicit EFLAGS)]>;
2930 // Memory-Integer Subtraction
2931 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2932 "sub{b}\t{$src2, $dst|$dst, $src2}",
2933 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2934 (implicit EFLAGS)]>;
2935 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2936 "sub{w}\t{$src2, $dst|$dst, $src2}",
2937 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2938 (implicit EFLAGS)]>, OpSize;
2939 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2940 "sub{l}\t{$src2, $dst|$dst, $src2}",
2941 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2942 (implicit EFLAGS)]>;
2943 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2944 "sub{w}\t{$src2, $dst|$dst, $src2}",
2945 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2947 (implicit EFLAGS)]>, OpSize;
2948 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2949 "sub{l}\t{$src2, $dst|$dst, $src2}",
2950 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2952 (implicit EFLAGS)]>;
2954 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2955 "sub{b}\t{$src, %al|%al, $src}", []>;
2956 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2957 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2958 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2959 "sub{l}\t{$src, %eax|%eax, $src}", []>;
2962 let Uses = [EFLAGS] in {
2963 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2964 (ins GR8:$src1, GR8:$src2),
2965 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2966 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2967 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2968 (ins GR16:$src1, GR16:$src2),
2969 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2970 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2971 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2972 (ins GR32:$src1, GR32:$src2),
2973 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2974 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2976 let isTwoAddress = 0 in {
2977 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2978 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2979 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2980 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2981 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2982 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2984 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2985 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2986 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2987 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2988 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2989 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2990 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2991 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2992 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2994 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2995 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2996 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2998 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2999 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3000 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
3001 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3002 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3003 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
3005 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
3006 "sbb{b}\t{$src, %al|%al, $src}", []>;
3007 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
3008 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3009 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
3010 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
3013 def SBB8rr_REV : I<0x1A, MRMSrcReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
3014 "sbb{b}\t{$src2, $dst|$dst, $src2}", []>;
3015 def SBB16rr_REV : I<0x1B, MRMSrcReg, (outs GR16:$dst),
3016 (ins GR16:$src1, GR16:$src2),
3017 "sbb{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize;
3018 def SBB32rr_REV : I<0x1B, MRMSrcReg, (outs GR32:$dst),
3019 (ins GR32:$src1, GR32:$src2),
3020 "sbb{l}\t{$src2, $dst|$dst, $src2}", []>;
3022 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
3023 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3024 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
3025 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
3026 (ins GR16:$src1, i16mem:$src2),
3027 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3028 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
3030 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
3031 (ins GR32:$src1, i32mem:$src2),
3032 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3033 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
3034 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
3035 "sbb{b}\t{$src2, $dst|$dst, $src2}",
3036 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
3037 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
3038 (ins GR16:$src1, i16imm:$src2),
3039 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3040 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
3041 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
3042 (ins GR16:$src1, i16i8imm:$src2),
3043 "sbb{w}\t{$src2, $dst|$dst, $src2}",
3044 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
3046 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
3047 (ins GR32:$src1, i32imm:$src2),
3048 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3049 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
3050 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
3051 (ins GR32:$src1, i32i8imm:$src2),
3052 "sbb{l}\t{$src2, $dst|$dst, $src2}",
3053 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
3054 } // Uses = [EFLAGS]
3055 } // Defs = [EFLAGS]
3057 let Defs = [EFLAGS] in {
3058 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
3059 // Register-Register Signed Integer Multiply
3060 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
3061 "imul{w}\t{$src2, $dst|$dst, $src2}",
3062 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
3063 (implicit EFLAGS)]>, TB, OpSize;
3064 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
3065 "imul{l}\t{$src2, $dst|$dst, $src2}",
3066 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
3067 (implicit EFLAGS)]>, TB;
3070 // Register-Memory Signed Integer Multiply
3071 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
3072 (ins GR16:$src1, i16mem:$src2),
3073 "imul{w}\t{$src2, $dst|$dst, $src2}",
3074 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
3075 (implicit EFLAGS)]>, TB, OpSize;
3076 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst),
3077 (ins GR32:$src1, i32mem:$src2),
3078 "imul{l}\t{$src2, $dst|$dst, $src2}",
3079 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
3080 (implicit EFLAGS)]>, TB;
3081 } // Defs = [EFLAGS]
3082 } // end Two Address instructions
3084 // Suprisingly enough, these are not two address instructions!
3085 let Defs = [EFLAGS] in {
3086 // Register-Integer Signed Integer Multiply
3087 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
3088 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
3089 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3090 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
3091 (implicit EFLAGS)]>, OpSize;
3092 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
3093 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
3094 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3095 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
3096 (implicit EFLAGS)]>;
3097 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
3098 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
3099 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3100 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
3101 (implicit EFLAGS)]>, OpSize;
3102 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
3103 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
3104 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3105 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
3106 (implicit EFLAGS)]>;
3108 // Memory-Integer Signed Integer Multiply
3109 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
3110 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
3111 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3112 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
3113 (implicit EFLAGS)]>, OpSize;
3114 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
3115 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
3116 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3117 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
3118 (implicit EFLAGS)]>;
3119 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
3120 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
3121 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3122 [(set GR16:$dst, (mul (load addr:$src1),
3123 i16immSExt8:$src2)),
3124 (implicit EFLAGS)]>, OpSize;
3125 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
3126 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
3127 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
3128 [(set GR32:$dst, (mul (load addr:$src1),
3129 i32immSExt8:$src2)),
3130 (implicit EFLAGS)]>;
3131 } // Defs = [EFLAGS]
3133 //===----------------------------------------------------------------------===//
3134 // Test instructions are just like AND, except they don't generate a result.
3136 let Defs = [EFLAGS] in {
3137 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
3138 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
3139 "test{b}\t{$src2, $src1|$src1, $src2}",
3140 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
3141 (implicit EFLAGS)]>;
3142 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3143 "test{w}\t{$src2, $src1|$src1, $src2}",
3144 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
3145 (implicit EFLAGS)]>,
3147 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3148 "test{l}\t{$src2, $src1|$src1, $src2}",
3149 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
3150 (implicit EFLAGS)]>;
3153 def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
3154 "test{b}\t{$src, %al|%al, $src}", []>;
3155 def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
3156 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3157 def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
3158 "test{l}\t{$src, %eax|%eax, $src}", []>;
3160 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
3161 "test{b}\t{$src2, $src1|$src1, $src2}",
3162 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
3163 (implicit EFLAGS)]>;
3164 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
3165 "test{w}\t{$src2, $src1|$src1, $src2}",
3166 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
3167 (implicit EFLAGS)]>, OpSize;
3168 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
3169 "test{l}\t{$src2, $src1|$src1, $src2}",
3170 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
3171 (implicit EFLAGS)]>;
3173 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
3174 (outs), (ins GR8:$src1, i8imm:$src2),
3175 "test{b}\t{$src2, $src1|$src1, $src2}",
3176 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
3177 (implicit EFLAGS)]>;
3178 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
3179 (outs), (ins GR16:$src1, i16imm:$src2),
3180 "test{w}\t{$src2, $src1|$src1, $src2}",
3181 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
3182 (implicit EFLAGS)]>, OpSize;
3183 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
3184 (outs), (ins GR32:$src1, i32imm:$src2),
3185 "test{l}\t{$src2, $src1|$src1, $src2}",
3186 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
3187 (implicit EFLAGS)]>;
3189 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
3190 (outs), (ins i8mem:$src1, i8imm:$src2),
3191 "test{b}\t{$src2, $src1|$src1, $src2}",
3192 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
3193 (implicit EFLAGS)]>;
3194 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
3195 (outs), (ins i16mem:$src1, i16imm:$src2),
3196 "test{w}\t{$src2, $src1|$src1, $src2}",
3197 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
3198 (implicit EFLAGS)]>, OpSize;
3199 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
3200 (outs), (ins i32mem:$src1, i32imm:$src2),
3201 "test{l}\t{$src2, $src1|$src1, $src2}",
3202 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
3203 (implicit EFLAGS)]>;
3204 } // Defs = [EFLAGS]
3207 // Condition code ops, incl. set if equal/not equal/...
3208 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
3209 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
3210 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
3211 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
3213 let Uses = [EFLAGS] in {
3214 // Use sbb to materialize carry bit.
3216 let Defs = [EFLAGS], isCodeGenOnly = 1 in {
3217 def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins),
3218 "sbb{b}\t$dst, $dst",
3219 [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3220 def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins),
3221 "sbb{w}\t$dst, $dst",
3222 [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>,
3224 def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins),
3225 "sbb{l}\t$dst, $dst",
3226 [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>;
3229 def SETEr : I<0x94, MRM0r,
3230 (outs GR8 :$dst), (ins),
3232 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
3234 def SETEm : I<0x94, MRM0m,
3235 (outs), (ins i8mem:$dst),
3237 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
3240 def SETNEr : I<0x95, MRM0r,
3241 (outs GR8 :$dst), (ins),
3243 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
3245 def SETNEm : I<0x95, MRM0m,
3246 (outs), (ins i8mem:$dst),
3248 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
3251 def SETLr : I<0x9C, MRM0r,
3252 (outs GR8 :$dst), (ins),
3254 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
3255 TB; // GR8 = < signed
3256 def SETLm : I<0x9C, MRM0m,
3257 (outs), (ins i8mem:$dst),
3259 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
3260 TB; // [mem8] = < signed
3262 def SETGEr : I<0x9D, MRM0r,
3263 (outs GR8 :$dst), (ins),
3265 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
3266 TB; // GR8 = >= signed
3267 def SETGEm : I<0x9D, MRM0m,
3268 (outs), (ins i8mem:$dst),
3270 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
3271 TB; // [mem8] = >= signed
3273 def SETLEr : I<0x9E, MRM0r,
3274 (outs GR8 :$dst), (ins),
3276 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
3277 TB; // GR8 = <= signed
3278 def SETLEm : I<0x9E, MRM0m,
3279 (outs), (ins i8mem:$dst),
3281 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
3282 TB; // [mem8] = <= signed
3284 def SETGr : I<0x9F, MRM0r,
3285 (outs GR8 :$dst), (ins),
3287 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
3288 TB; // GR8 = > signed
3289 def SETGm : I<0x9F, MRM0m,
3290 (outs), (ins i8mem:$dst),
3292 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
3293 TB; // [mem8] = > signed
3295 def SETBr : I<0x92, MRM0r,
3296 (outs GR8 :$dst), (ins),
3298 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
3299 TB; // GR8 = < unsign
3300 def SETBm : I<0x92, MRM0m,
3301 (outs), (ins i8mem:$dst),
3303 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
3304 TB; // [mem8] = < unsign
3306 def SETAEr : I<0x93, MRM0r,
3307 (outs GR8 :$dst), (ins),
3309 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
3310 TB; // GR8 = >= unsign
3311 def SETAEm : I<0x93, MRM0m,
3312 (outs), (ins i8mem:$dst),
3314 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
3315 TB; // [mem8] = >= unsign
3317 def SETBEr : I<0x96, MRM0r,
3318 (outs GR8 :$dst), (ins),
3320 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
3321 TB; // GR8 = <= unsign
3322 def SETBEm : I<0x96, MRM0m,
3323 (outs), (ins i8mem:$dst),
3325 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
3326 TB; // [mem8] = <= unsign
3328 def SETAr : I<0x97, MRM0r,
3329 (outs GR8 :$dst), (ins),
3331 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
3332 TB; // GR8 = > signed
3333 def SETAm : I<0x97, MRM0m,
3334 (outs), (ins i8mem:$dst),
3336 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
3337 TB; // [mem8] = > signed
3339 def SETSr : I<0x98, MRM0r,
3340 (outs GR8 :$dst), (ins),
3342 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
3343 TB; // GR8 = <sign bit>
3344 def SETSm : I<0x98, MRM0m,
3345 (outs), (ins i8mem:$dst),
3347 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
3348 TB; // [mem8] = <sign bit>
3349 def SETNSr : I<0x99, MRM0r,
3350 (outs GR8 :$dst), (ins),
3352 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
3353 TB; // GR8 = !<sign bit>
3354 def SETNSm : I<0x99, MRM0m,
3355 (outs), (ins i8mem:$dst),
3357 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
3358 TB; // [mem8] = !<sign bit>
3360 def SETPr : I<0x9A, MRM0r,
3361 (outs GR8 :$dst), (ins),
3363 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
3365 def SETPm : I<0x9A, MRM0m,
3366 (outs), (ins i8mem:$dst),
3368 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
3369 TB; // [mem8] = parity
3370 def SETNPr : I<0x9B, MRM0r,
3371 (outs GR8 :$dst), (ins),
3373 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
3374 TB; // GR8 = not parity
3375 def SETNPm : I<0x9B, MRM0m,
3376 (outs), (ins i8mem:$dst),
3378 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
3379 TB; // [mem8] = not parity
3381 def SETOr : I<0x90, MRM0r,
3382 (outs GR8 :$dst), (ins),
3384 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3385 TB; // GR8 = overflow
3386 def SETOm : I<0x90, MRM0m,
3387 (outs), (ins i8mem:$dst),
3389 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3390 TB; // [mem8] = overflow
3391 def SETNOr : I<0x91, MRM0r,
3392 (outs GR8 :$dst), (ins),
3394 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3395 TB; // GR8 = not overflow
3396 def SETNOm : I<0x91, MRM0m,
3397 (outs), (ins i8mem:$dst),
3399 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3400 TB; // [mem8] = not overflow
3401 } // Uses = [EFLAGS]
3404 // Integer comparisons
3405 let Defs = [EFLAGS] in {
3406 def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3407 "cmp{b}\t{$src, %al|%al, $src}", []>;
3408 def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3409 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3410 def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3411 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3413 def CMP8rr : I<0x38, MRMDestReg,
3414 (outs), (ins GR8 :$src1, GR8 :$src2),
3415 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3416 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
3417 def CMP16rr : I<0x39, MRMDestReg,
3418 (outs), (ins GR16:$src1, GR16:$src2),
3419 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3420 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
3421 def CMP32rr : I<0x39, MRMDestReg,
3422 (outs), (ins GR32:$src1, GR32:$src2),
3423 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3424 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
3425 def CMP8mr : I<0x38, MRMDestMem,
3426 (outs), (ins i8mem :$src1, GR8 :$src2),
3427 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3428 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3429 (implicit EFLAGS)]>;
3430 def CMP16mr : I<0x39, MRMDestMem,
3431 (outs), (ins i16mem:$src1, GR16:$src2),
3432 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3433 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3434 (implicit EFLAGS)]>, OpSize;
3435 def CMP32mr : I<0x39, MRMDestMem,
3436 (outs), (ins i32mem:$src1, GR32:$src2),
3437 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3438 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3439 (implicit EFLAGS)]>;
3440 def CMP8rm : I<0x3A, MRMSrcMem,
3441 (outs), (ins GR8 :$src1, i8mem :$src2),
3442 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3443 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3444 (implicit EFLAGS)]>;
3445 def CMP16rm : I<0x3B, MRMSrcMem,
3446 (outs), (ins GR16:$src1, i16mem:$src2),
3447 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3448 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3449 (implicit EFLAGS)]>, OpSize;
3450 def CMP32rm : I<0x3B, MRMSrcMem,
3451 (outs), (ins GR32:$src1, i32mem:$src2),
3452 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3453 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3454 (implicit EFLAGS)]>;
3455 def CMP8mrmrr : I<0x3A, MRMSrcReg, (outs), (ins GR8:$src1, GR8:$src2),
3456 "cmp{b}\t{$src2, $src1|$src1, $src2}", []>;
3457 def CMP16mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
3458 "cmp{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize;
3459 def CMP32mrmrr : I<0x3B, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
3460 "cmp{l}\t{$src2, $src1|$src1, $src2}", []>;
3461 def CMP8ri : Ii8<0x80, MRM7r,
3462 (outs), (ins GR8:$src1, i8imm:$src2),
3463 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3464 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
3465 def CMP16ri : Ii16<0x81, MRM7r,
3466 (outs), (ins GR16:$src1, i16imm:$src2),
3467 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3468 [(X86cmp GR16:$src1, imm:$src2),
3469 (implicit EFLAGS)]>, OpSize;
3470 def CMP32ri : Ii32<0x81, MRM7r,
3471 (outs), (ins GR32:$src1, i32imm:$src2),
3472 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3473 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
3474 def CMP8mi : Ii8 <0x80, MRM7m,
3475 (outs), (ins i8mem :$src1, i8imm :$src2),
3476 "cmp{b}\t{$src2, $src1|$src1, $src2}",
3477 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3478 (implicit EFLAGS)]>;
3479 def CMP16mi : Ii16<0x81, MRM7m,
3480 (outs), (ins i16mem:$src1, i16imm:$src2),
3481 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3482 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3483 (implicit EFLAGS)]>, OpSize;
3484 def CMP32mi : Ii32<0x81, MRM7m,
3485 (outs), (ins i32mem:$src1, i32imm:$src2),
3486 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3487 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3488 (implicit EFLAGS)]>;
3489 def CMP16ri8 : Ii8<0x83, MRM7r,
3490 (outs), (ins GR16:$src1, i16i8imm:$src2),
3491 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3492 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3493 (implicit EFLAGS)]>, OpSize;
3494 def CMP16mi8 : Ii8<0x83, MRM7m,
3495 (outs), (ins i16mem:$src1, i16i8imm:$src2),
3496 "cmp{w}\t{$src2, $src1|$src1, $src2}",
3497 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3498 (implicit EFLAGS)]>, OpSize;
3499 def CMP32mi8 : Ii8<0x83, MRM7m,
3500 (outs), (ins i32mem:$src1, i32i8imm:$src2),
3501 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3502 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3503 (implicit EFLAGS)]>;
3504 def CMP32ri8 : Ii8<0x83, MRM7r,
3505 (outs), (ins GR32:$src1, i32i8imm:$src2),
3506 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3507 [(X86cmp GR32:$src1, i32immSExt8:$src2),
3508 (implicit EFLAGS)]>;
3509 } // Defs = [EFLAGS]
3512 // TODO: BTC, BTR, and BTS
3513 let Defs = [EFLAGS] in {
3514 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3515 "bt{w}\t{$src2, $src1|$src1, $src2}",
3516 [(X86bt GR16:$src1, GR16:$src2),
3517 (implicit EFLAGS)]>, OpSize, TB;
3518 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3519 "bt{l}\t{$src2, $src1|$src1, $src2}",
3520 [(X86bt GR32:$src1, GR32:$src2),
3521 (implicit EFLAGS)]>, TB;
3523 // Unlike with the register+register form, the memory+register form of the
3524 // bt instruction does not ignore the high bits of the index. From ISel's
3525 // perspective, this is pretty bizarre. Make these instructions disassembly
3528 def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3529 "bt{w}\t{$src2, $src1|$src1, $src2}",
3530 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3531 // (implicit EFLAGS)]
3533 >, OpSize, TB, Requires<[FastBTMem]>;
3534 def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3535 "bt{l}\t{$src2, $src1|$src1, $src2}",
3536 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3537 // (implicit EFLAGS)]
3539 >, TB, Requires<[FastBTMem]>;
3541 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3542 "bt{w}\t{$src2, $src1|$src1, $src2}",
3543 [(X86bt GR16:$src1, i16immSExt8:$src2),
3544 (implicit EFLAGS)]>, OpSize, TB;
3545 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3546 "bt{l}\t{$src2, $src1|$src1, $src2}",
3547 [(X86bt GR32:$src1, i32immSExt8:$src2),
3548 (implicit EFLAGS)]>, TB;
3549 // Note that these instructions don't need FastBTMem because that
3550 // only applies when the other operand is in a register. When it's
3551 // an immediate, bt is still fast.
3552 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3553 "bt{w}\t{$src2, $src1|$src1, $src2}",
3554 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3555 (implicit EFLAGS)]>, OpSize, TB;
3556 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3557 "bt{l}\t{$src2, $src1|$src1, $src2}",
3558 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3559 (implicit EFLAGS)]>, TB;
3561 def BTC16rr : I<0xBB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3562 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3563 def BTC32rr : I<0xBB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3564 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3565 def BTC16mr : I<0xBB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3566 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3567 def BTC32mr : I<0xBB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3568 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3569 def BTC16ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3570 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3571 def BTC32ri8 : Ii8<0xBA, MRM7r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3572 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3573 def BTC16mi8 : Ii8<0xBA, MRM7m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3574 "btc{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3575 def BTC32mi8 : Ii8<0xBA, MRM7m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3576 "btc{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3578 def BTR16rr : I<0xB3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3579 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3580 def BTR32rr : I<0xB3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3581 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3582 def BTR16mr : I<0xB3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3583 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3584 def BTR32mr : I<0xB3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3585 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3586 def BTR16ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3587 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3588 def BTR32ri8 : Ii8<0xBA, MRM6r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3589 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3590 def BTR16mi8 : Ii8<0xBA, MRM6m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3591 "btr{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3592 def BTR32mi8 : Ii8<0xBA, MRM6m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3593 "btr{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3595 def BTS16rr : I<0xAB, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3596 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3597 def BTS32rr : I<0xAB, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3598 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3599 def BTS16mr : I<0xAB, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3600 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3601 def BTS32mr : I<0xAB, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3602 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3603 def BTS16ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3604 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3605 def BTS32ri8 : Ii8<0xBA, MRM5r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3606 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3607 def BTS16mi8 : Ii8<0xBA, MRM5m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3608 "bts{w}\t{$src2, $src1|$src1, $src2}", []>, OpSize, TB;
3609 def BTS32mi8 : Ii8<0xBA, MRM5m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3610 "bts{l}\t{$src2, $src1|$src1, $src2}", []>, TB;
3611 } // Defs = [EFLAGS]
3613 // Sign/Zero extenders
3614 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3615 // of the register here. This has a smaller encoding and avoids a
3616 // partial-register update. Actual movsbw included for the disassembler.
3617 def MOVSX16rr8W : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3618 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3619 def MOVSX16rm8W : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3620 "movs{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3621 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3622 "", [(set GR16:$dst, (sext GR8:$src))]>, TB;
3623 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3624 "", [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3625 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3626 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3627 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3628 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3629 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3630 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3631 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3632 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3633 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3634 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3635 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3636 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3638 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3639 // of the register here. This has a smaller encoding and avoids a
3640 // partial-register update. Actual movzbw included for the disassembler.
3641 def MOVZX16rr8W : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8:$src),
3642 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3643 def MOVZX16rm8W : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem:$src),
3644 "movz{bw|x}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3645 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3646 "", [(set GR16:$dst, (zext GR8:$src))]>, TB;
3647 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3648 "", [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3649 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3650 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3651 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3652 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3653 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3654 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3655 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3656 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3657 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3658 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3659 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3660 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3662 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3663 // except that they use GR32_NOREX for the output operand register class
3664 // instead of GR32. This allows them to operate on h registers on x86-64.
3665 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3666 (outs GR32_NOREX:$dst), (ins GR8:$src),
3667 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3670 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3671 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3672 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3675 let neverHasSideEffects = 1 in {
3676 let Defs = [AX], Uses = [AL] in
3677 def CBW : I<0x98, RawFrm, (outs), (ins),
3678 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3679 let Defs = [EAX], Uses = [AX] in
3680 def CWDE : I<0x98, RawFrm, (outs), (ins),
3681 "{cwtl|cwde}", []>; // EAX = signext(AX)
3683 let Defs = [AX,DX], Uses = [AX] in
3684 def CWD : I<0x99, RawFrm, (outs), (ins),
3685 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3686 let Defs = [EAX,EDX], Uses = [EAX] in
3687 def CDQ : I<0x99, RawFrm, (outs), (ins),
3688 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3691 //===----------------------------------------------------------------------===//
3692 // Alias Instructions
3693 //===----------------------------------------------------------------------===//
3695 // Alias instructions that map movr0 to xor.
3696 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3697 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3698 isCodeGenOnly = 1 in {
3699 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
3700 "xor{b}\t$dst, $dst",
3701 [(set GR8:$dst, 0)]>;
3702 // Use xorl instead of xorw since we don't care about the high 16 bits,
3703 // it's smaller, and it avoids a partial-register update.
3704 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3705 "", [(set GR16:$dst, 0)]>;
3706 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3707 "xor{l}\t$dst, $dst",
3708 [(set GR32:$dst, 0)]>;
3711 //===----------------------------------------------------------------------===//
3712 // Thread Local Storage Instructions
3715 // All calls clobber the non-callee saved registers. ESP is marked as
3716 // a use to prevent stack-pointer assignments that appear immediately
3717 // before calls from potentially appearing dead.
3718 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3719 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3720 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3721 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3723 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3724 "leal\t$sym, %eax; "
3725 "call\t___tls_get_addr@PLT",
3726 [(X86tlsaddr tls32addr:$sym)]>,
3727 Requires<[In32BitMode]>;
3729 let AddedComplexity = 5, isCodeGenOnly = 1 in
3730 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3731 "movl\t%gs:$src, $dst",
3732 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3734 let AddedComplexity = 5, isCodeGenOnly = 1 in
3735 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3736 "movl\t%fs:$src, $dst",
3737 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3739 //===----------------------------------------------------------------------===//
3740 // EH Pseudo Instructions
3742 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3743 hasCtrlDep = 1, isCodeGenOnly = 1 in {
3744 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3745 "ret\t#eh_return, addr: $addr",
3746 [(X86ehret GR32:$addr)]>;
3750 //===----------------------------------------------------------------------===//
3754 // Atomic swap. These are just normal xchg instructions. But since a memory
3755 // operand is referenced, the atomicity is ensured.
3756 let Constraints = "$val = $dst" in {
3757 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst),
3758 (ins GR32:$val, i32mem:$ptr),
3759 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3760 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3761 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst),
3762 (ins GR16:$val, i16mem:$ptr),
3763 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3764 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3766 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3767 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3768 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3770 def XCHG32rr : I<0x87, MRMSrcReg, (outs GR32:$dst), (ins GR32:$val, GR32:$src),
3771 "xchg{l}\t{$val, $src|$src, $val}", []>;
3772 def XCHG16rr : I<0x87, MRMSrcReg, (outs GR16:$dst), (ins GR16:$val, GR16:$src),
3773 "xchg{w}\t{$val, $src|$src, $val}", []>, OpSize;
3774 def XCHG8rr : I<0x86, MRMSrcReg, (outs GR8:$dst), (ins GR8:$val, GR8:$src),
3775 "xchg{b}\t{$val, $src|$src, $val}", []>;
3778 def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src),
3779 "xchg{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3780 def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src),
3781 "xchg{l}\t{$src, %eax|%eax, $src}", []>;
3783 // Atomic compare and swap.
3784 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3785 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3787 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3788 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3790 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3791 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3794 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3797 let Defs = [AX, EFLAGS], Uses = [AX] in {
3798 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3800 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3801 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3803 let Defs = [AL, EFLAGS], Uses = [AL] in {
3804 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3806 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3807 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3810 // Atomic exchange and add
3811 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3812 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr),
3814 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3815 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3817 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr),
3819 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3820 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3822 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr),
3824 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3825 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3829 def XADD8rr : I<0xC0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3830 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3831 def XADD16rr : I<0xC1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3832 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3833 def XADD32rr : I<0xC1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3834 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3836 def XADD8rm : I<0xC0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3837 "xadd{b}\t{$src, $dst|$dst, $src}", []>, TB;
3838 def XADD16rm : I<0xC1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3839 "xadd{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3840 def XADD32rm : I<0xC1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3841 "xadd{l}\t{$src, $dst|$dst, $src}", []>, TB;
3843 def CMPXCHG8rr : I<0xB0, MRMDestReg, (outs GR8:$dst), (ins GR8:$src),
3844 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3845 def CMPXCHG16rr : I<0xB1, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
3846 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3847 def CMPXCHG32rr : I<0xB1, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
3848 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3850 def CMPXCHG8rm : I<0xB0, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
3851 "cmpxchg{b}\t{$src, $dst|$dst, $src}", []>, TB;
3852 def CMPXCHG16rm : I<0xB1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
3853 "cmpxchg{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
3854 def CMPXCHG32rm : I<0xB1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
3855 "cmpxchg{l}\t{$src, $dst|$dst, $src}", []>, TB;
3857 def CMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$dst),
3858 "cmpxchg8b\t$dst", []>, TB;
3860 // Optimized codegen when the non-memory output is not used.
3861 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3862 let Defs = [EFLAGS] in {
3863 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3865 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3866 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3868 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3869 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3871 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3872 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3874 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3875 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3877 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3878 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3880 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3881 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3883 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3884 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3886 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3888 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3890 "inc{b}\t$dst", []>, LOCK;
3891 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3893 "inc{w}\t$dst", []>, OpSize, LOCK;
3894 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3896 "inc{l}\t$dst", []>, LOCK;
3898 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3900 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3901 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3903 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3904 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3906 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3907 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3909 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3910 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3912 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3913 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3915 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3916 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3918 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3919 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3921 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3923 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3925 "dec{b}\t$dst", []>, LOCK;
3926 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3928 "dec{w}\t$dst", []>, OpSize, LOCK;
3929 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3931 "dec{l}\t$dst", []>, LOCK;
3934 // Atomic exchange, and, or, xor
3935 let Constraints = "$val = $dst", Defs = [EFLAGS],
3936 usesCustomInserter = 1 in {
3937 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3938 "#ATOMAND32 PSEUDO!",
3939 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3940 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3941 "#ATOMOR32 PSEUDO!",
3942 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3943 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3944 "#ATOMXOR32 PSEUDO!",
3945 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3946 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3947 "#ATOMNAND32 PSEUDO!",
3948 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3949 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3950 "#ATOMMIN32 PSEUDO!",
3951 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3952 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3953 "#ATOMMAX32 PSEUDO!",
3954 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3955 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3956 "#ATOMUMIN32 PSEUDO!",
3957 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3958 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3959 "#ATOMUMAX32 PSEUDO!",
3960 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3962 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3963 "#ATOMAND16 PSEUDO!",
3964 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3965 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3966 "#ATOMOR16 PSEUDO!",
3967 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3968 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3969 "#ATOMXOR16 PSEUDO!",
3970 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3971 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3972 "#ATOMNAND16 PSEUDO!",
3973 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3974 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3975 "#ATOMMIN16 PSEUDO!",
3976 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3977 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3978 "#ATOMMAX16 PSEUDO!",
3979 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3980 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3981 "#ATOMUMIN16 PSEUDO!",
3982 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3983 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3984 "#ATOMUMAX16 PSEUDO!",
3985 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3987 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3988 "#ATOMAND8 PSEUDO!",
3989 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3990 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3992 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3993 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3994 "#ATOMXOR8 PSEUDO!",
3995 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3996 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3997 "#ATOMNAND8 PSEUDO!",
3998 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
4001 let Constraints = "$val1 = $dst1, $val2 = $dst2",
4002 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
4003 Uses = [EAX, EBX, ECX, EDX],
4004 mayLoad = 1, mayStore = 1,
4005 usesCustomInserter = 1 in {
4006 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4007 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4008 "#ATOMAND6432 PSEUDO!", []>;
4009 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4010 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4011 "#ATOMOR6432 PSEUDO!", []>;
4012 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4013 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4014 "#ATOMXOR6432 PSEUDO!", []>;
4015 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4016 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4017 "#ATOMNAND6432 PSEUDO!", []>;
4018 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4019 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4020 "#ATOMADD6432 PSEUDO!", []>;
4021 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4022 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4023 "#ATOMSUB6432 PSEUDO!", []>;
4024 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
4025 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
4026 "#ATOMSWAP6432 PSEUDO!", []>;
4029 // Segmentation support instructions.
4031 def LAR16rm : I<0x02, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4032 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4033 def LAR16rr : I<0x02, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4034 "lar{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4036 // i16mem operand in LAR32rm and GR32 operand in LAR32rr is not a typo.
4037 def LAR32rm : I<0x02, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
4038 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4039 def LAR32rr : I<0x02, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4040 "lar{l}\t{$src, $dst|$dst, $src}", []>, TB;
4042 def LSL16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
4043 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4044 def LSL16rr : I<0x03, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
4045 "lsl{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4046 def LSL32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4047 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4048 def LSL32rr : I<0x03, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4049 "lsl{l}\t{$src, $dst|$dst, $src}", []>, TB;
4051 def INVLPG : I<0x01, RawFrm, (outs), (ins), "invlpg", []>, TB;
4053 def STRr : I<0x00, MRM1r, (outs GR16:$dst), (ins),
4054 "str{w}\t{$dst}", []>, TB;
4055 def STRm : I<0x00, MRM1m, (outs i16mem:$dst), (ins),
4056 "str{w}\t{$dst}", []>, TB;
4057 def LTRr : I<0x00, MRM3r, (outs), (ins GR16:$src),
4058 "ltr{w}\t{$src}", []>, TB;
4059 def LTRm : I<0x00, MRM3m, (outs), (ins i16mem:$src),
4060 "ltr{w}\t{$src}", []>, TB;
4062 def PUSHFS16 : I<0xa0, RawFrm, (outs), (ins),
4063 "push{w}\t%fs", []>, OpSize, TB;
4064 def PUSHFS32 : I<0xa0, RawFrm, (outs), (ins),
4065 "push{l}\t%fs", []>, TB;
4066 def PUSHGS16 : I<0xa8, RawFrm, (outs), (ins),
4067 "push{w}\t%gs", []>, OpSize, TB;
4068 def PUSHGS32 : I<0xa8, RawFrm, (outs), (ins),
4069 "push{l}\t%gs", []>, TB;
4071 def POPFS16 : I<0xa1, RawFrm, (outs), (ins),
4072 "pop{w}\t%fs", []>, OpSize, TB;
4073 def POPFS32 : I<0xa1, RawFrm, (outs), (ins),
4074 "pop{l}\t%fs", []>, TB;
4075 def POPGS16 : I<0xa9, RawFrm, (outs), (ins),
4076 "pop{w}\t%gs", []>, OpSize, TB;
4077 def POPGS32 : I<0xa9, RawFrm, (outs), (ins),
4078 "pop{l}\t%gs", []>, TB;
4080 def LDS16rm : I<0xc5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4081 "lds{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4082 def LDS32rm : I<0xc5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4083 "lds{l}\t{$src, $dst|$dst, $src}", []>;
4084 def LSS16rm : I<0xb2, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4085 "lss{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4086 def LSS32rm : I<0xb2, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4087 "lss{l}\t{$src, $dst|$dst, $src}", []>, TB;
4088 def LES16rm : I<0xc4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4089 "les{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
4090 def LES32rm : I<0xc4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4091 "les{l}\t{$src, $dst|$dst, $src}", []>;
4092 def LFS16rm : I<0xb4, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4093 "lfs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4094 def LFS32rm : I<0xb4, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4095 "lfs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4096 def LGS16rm : I<0xb5, MRMSrcMem, (outs GR16:$dst), (ins opaque32mem:$src),
4097 "lgs{w}\t{$src, $dst|$dst, $src}", []>, TB, OpSize;
4098 def LGS32rm : I<0xb5, MRMSrcMem, (outs GR32:$dst), (ins opaque48mem:$src),
4099 "lgs{l}\t{$src, $dst|$dst, $src}", []>, TB;
4101 def VERRr : I<0x00, MRM4r, (outs), (ins GR16:$seg),
4102 "verr\t$seg", []>, TB;
4103 def VERRm : I<0x00, MRM4m, (outs), (ins i16mem:$seg),
4104 "verr\t$seg", []>, TB;
4105 def VERWr : I<0x00, MRM5r, (outs), (ins GR16:$seg),
4106 "verw\t$seg", []>, TB;
4107 def VERWm : I<0x00, MRM5m, (outs), (ins i16mem:$seg),
4108 "verw\t$seg", []>, TB;
4110 // Descriptor-table support instructions
4112 def SGDTm : I<0x01, MRM0m, (outs opaque48mem:$dst), (ins),
4113 "sgdt\t$dst", []>, TB;
4114 def SIDTm : I<0x01, MRM1m, (outs opaque48mem:$dst), (ins),
4115 "sidt\t$dst", []>, TB;
4116 def SLDT16r : I<0x00, MRM0r, (outs GR16:$dst), (ins),
4117 "sldt{w}\t$dst", []>, TB;
4118 def SLDT16m : I<0x00, MRM0m, (outs i16mem:$dst), (ins),
4119 "sldt{w}\t$dst", []>, TB;
4120 def LGDTm : I<0x01, MRM2m, (outs), (ins opaque48mem:$src),
4121 "lgdt\t$src", []>, TB;
4122 def LIDTm : I<0x01, MRM3m, (outs), (ins opaque48mem:$src),
4123 "lidt\t$src", []>, TB;
4124 def LLDT16r : I<0x00, MRM2r, (outs), (ins GR16:$src),
4125 "lldt{w}\t$src", []>, TB;
4126 def LLDT16m : I<0x00, MRM2m, (outs), (ins i16mem:$src),
4127 "lldt{w}\t$src", []>, TB;
4129 // String manipulation instructions
4131 def LODSB : I<0xAC, RawFrm, (outs), (ins), "lodsb", []>;
4132 def LODSW : I<0xAD, RawFrm, (outs), (ins), "lodsw", []>, OpSize;
4133 def LODSD : I<0xAD, RawFrm, (outs), (ins), "lods{l|d}", []>;
4135 def OUTSB : I<0x6E, RawFrm, (outs), (ins), "outsb", []>;
4136 def OUTSW : I<0x6F, RawFrm, (outs), (ins), "outsw", []>, OpSize;
4137 def OUTSD : I<0x6F, RawFrm, (outs), (ins), "outs{l|d}", []>;
4139 // CPU flow control instructions
4141 def HLT : I<0xF4, RawFrm, (outs), (ins), "hlt", []>;
4142 def RSM : I<0xAA, RawFrm, (outs), (ins), "rsm", []>, TB;
4144 // FPU control instructions
4146 def FNINIT : I<0xE3, RawFrm, (outs), (ins), "fninit", []>, DB;
4148 // Flag instructions
4150 def CLC : I<0xF8, RawFrm, (outs), (ins), "clc", []>;
4151 def STC : I<0xF9, RawFrm, (outs), (ins), "stc", []>;
4152 def CLI : I<0xFA, RawFrm, (outs), (ins), "cli", []>;
4153 def STI : I<0xFB, RawFrm, (outs), (ins), "sti", []>;
4154 def CLD : I<0xFC, RawFrm, (outs), (ins), "cld", []>;
4155 def STD : I<0xFD, RawFrm, (outs), (ins), "std", []>;
4156 def CMC : I<0xF5, RawFrm, (outs), (ins), "cmc", []>;
4158 def CLTS : I<0x06, RawFrm, (outs), (ins), "clts", []>, TB;
4160 // Table lookup instructions
4162 def XLAT : I<0xD7, RawFrm, (outs), (ins), "xlatb", []>;
4164 // Specialized register support
4166 def WRMSR : I<0x30, RawFrm, (outs), (ins), "wrmsr", []>, TB;
4167 def RDMSR : I<0x32, RawFrm, (outs), (ins), "rdmsr", []>, TB;
4168 def RDPMC : I<0x33, RawFrm, (outs), (ins), "rdpmc", []>, TB;
4170 def SMSW16r : I<0x01, MRM4r, (outs GR16:$dst), (ins),
4171 "smsw{w}\t$dst", []>, OpSize, TB;
4172 def SMSW32r : I<0x01, MRM4r, (outs GR32:$dst), (ins),
4173 "smsw{l}\t$dst", []>, TB;
4174 // For memory operands, there is only a 16-bit form
4175 def SMSW16m : I<0x01, MRM4m, (outs i16mem:$dst), (ins),
4176 "smsw{w}\t$dst", []>, TB;
4178 def LMSW16r : I<0x01, MRM6r, (outs), (ins GR16:$src),
4179 "lmsw{w}\t$src", []>, TB;
4180 def LMSW16m : I<0x01, MRM6m, (outs), (ins i16mem:$src),
4181 "lmsw{w}\t$src", []>, TB;
4183 def CPUID : I<0xA2, RawFrm, (outs), (ins), "cpuid", []>, TB;
4185 // Cache instructions
4187 def INVD : I<0x08, RawFrm, (outs), (ins), "invd", []>, TB;
4188 def WBINVD : I<0x09, RawFrm, (outs), (ins), "wbinvd", []>, TB;
4193 def INVEPT : I<0x38, RawFrm, (outs), (ins), "invept", []>, OpSize, TB;
4195 def INVVPID : I<0x38, RawFrm, (outs), (ins), "invvpid", []>, OpSize, TB;
4197 def VMCALL : I<0x01, RawFrm, (outs), (ins), "vmcall", []>, TB;
4198 def VMCLEARm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4199 "vmclear\t$vmcs", []>, OpSize, TB;
4201 def VMLAUNCH : I<0x01, RawFrm, (outs), (ins), "vmlaunch", []>, TB;
4203 def VMRESUME : I<0x01, RawFrm, (outs), (ins), "vmresume", []>, TB;
4204 def VMPTRLDm : I<0xC7, MRM6m, (outs), (ins i64mem:$vmcs),
4205 "vmptrld\t$vmcs", []>, TB;
4206 def VMPTRSTm : I<0xC7, MRM7m, (outs i64mem:$vmcs), (ins),
4207 "vmptrst\t$vmcs", []>, TB;
4208 def VMREAD64rm : I<0x78, MRMDestMem, (outs i64mem:$dst), (ins GR64:$src),
4209 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4210 def VMREAD64rr : I<0x78, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
4211 "vmread{q}\t{$src, $dst|$dst, $src}", []>, TB;
4212 def VMREAD32rm : I<0x78, MRMDestMem, (outs i32mem:$dst), (ins GR32:$src),
4213 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4214 def VMREAD32rr : I<0x78, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
4215 "vmread{l}\t{$src, $dst|$dst, $src}", []>, TB;
4216 def VMWRITE64rm : I<0x79, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src),
4217 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4218 def VMWRITE64rr : I<0x79, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src),
4219 "vmwrite{q}\t{$src, $dst|$dst, $src}", []>, TB;
4220 def VMWRITE32rm : I<0x79, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
4221 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4222 def VMWRITE32rr : I<0x79, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
4223 "vmwrite{l}\t{$src, $dst|$dst, $src}", []>, TB;
4225 def VMXOFF : I<0x01, RawFrm, (outs), (ins), "vmxoff", []>, OpSize;
4226 def VMXON : I<0xC7, MRM6m, (outs), (ins i64mem:$vmxon),
4227 "vmxon\t{$vmxon}", []>, XD;
4229 //===----------------------------------------------------------------------===//
4230 // Non-Instruction Patterns
4231 //===----------------------------------------------------------------------===//
4233 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
4234 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
4235 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
4236 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
4237 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
4238 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
4239 def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>;
4241 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
4242 (ADD32ri GR32:$src1, tconstpool:$src2)>;
4243 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
4244 (ADD32ri GR32:$src1, tjumptable:$src2)>;
4245 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
4246 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
4247 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
4248 (ADD32ri GR32:$src1, texternalsym:$src2)>;
4249 def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)),
4250 (ADD32ri GR32:$src1, tblockaddress:$src2)>;
4252 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
4253 (MOV32mi addr:$dst, tglobaladdr:$src)>;
4254 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
4255 (MOV32mi addr:$dst, texternalsym:$src)>;
4256 def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst),
4257 (MOV32mi addr:$dst, tblockaddress:$src)>;
4261 def : Pat<(X86tcret GR32:$dst, imm:$off),
4262 (TCRETURNri GR32:$dst, imm:$off)>;
4264 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
4265 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4267 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
4268 (TCRETURNdi texternalsym:$dst, imm:$off)>;
4270 // Normal calls, with various flavors of addresses.
4271 def : Pat<(X86call (i32 tglobaladdr:$dst)),
4272 (CALLpcrel32 tglobaladdr:$dst)>;
4273 def : Pat<(X86call (i32 texternalsym:$dst)),
4274 (CALLpcrel32 texternalsym:$dst)>;
4275 def : Pat<(X86call (i32 imm:$dst)),
4276 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
4278 // X86 specific add which produces a flag.
4279 def : Pat<(addc GR32:$src1, GR32:$src2),
4280 (ADD32rr GR32:$src1, GR32:$src2)>;
4281 def : Pat<(addc GR32:$src1, (load addr:$src2)),
4282 (ADD32rm GR32:$src1, addr:$src2)>;
4283 def : Pat<(addc GR32:$src1, imm:$src2),
4284 (ADD32ri GR32:$src1, imm:$src2)>;
4285 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
4286 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4288 def : Pat<(subc GR32:$src1, GR32:$src2),
4289 (SUB32rr GR32:$src1, GR32:$src2)>;
4290 def : Pat<(subc GR32:$src1, (load addr:$src2)),
4291 (SUB32rm GR32:$src1, addr:$src2)>;
4292 def : Pat<(subc GR32:$src1, imm:$src2),
4293 (SUB32ri GR32:$src1, imm:$src2)>;
4294 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
4295 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4299 // TEST R,R is smaller than CMP R,0
4300 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
4301 (TEST8rr GR8:$src1, GR8:$src1)>;
4302 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
4303 (TEST16rr GR16:$src1, GR16:$src1)>;
4304 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
4305 (TEST32rr GR32:$src1, GR32:$src1)>;
4307 // Conditional moves with folded loads with operands swapped and conditions
4309 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
4310 (CMOVAE16rm GR16:$src2, addr:$src1)>;
4311 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
4312 (CMOVAE32rm GR32:$src2, addr:$src1)>;
4313 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
4314 (CMOVB16rm GR16:$src2, addr:$src1)>;
4315 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
4316 (CMOVB32rm GR32:$src2, addr:$src1)>;
4317 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
4318 (CMOVNE16rm GR16:$src2, addr:$src1)>;
4319 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
4320 (CMOVNE32rm GR32:$src2, addr:$src1)>;
4321 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
4322 (CMOVE16rm GR16:$src2, addr:$src1)>;
4323 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
4324 (CMOVE32rm GR32:$src2, addr:$src1)>;
4325 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
4326 (CMOVA16rm GR16:$src2, addr:$src1)>;
4327 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
4328 (CMOVA32rm GR32:$src2, addr:$src1)>;
4329 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
4330 (CMOVBE16rm GR16:$src2, addr:$src1)>;
4331 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
4332 (CMOVBE32rm GR32:$src2, addr:$src1)>;
4333 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
4334 (CMOVGE16rm GR16:$src2, addr:$src1)>;
4335 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
4336 (CMOVGE32rm GR32:$src2, addr:$src1)>;
4337 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
4338 (CMOVL16rm GR16:$src2, addr:$src1)>;
4339 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
4340 (CMOVL32rm GR32:$src2, addr:$src1)>;
4341 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
4342 (CMOVG16rm GR16:$src2, addr:$src1)>;
4343 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
4344 (CMOVG32rm GR32:$src2, addr:$src1)>;
4345 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
4346 (CMOVLE16rm GR16:$src2, addr:$src1)>;
4347 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
4348 (CMOVLE32rm GR32:$src2, addr:$src1)>;
4349 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
4350 (CMOVNP16rm GR16:$src2, addr:$src1)>;
4351 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
4352 (CMOVNP32rm GR32:$src2, addr:$src1)>;
4353 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
4354 (CMOVP16rm GR16:$src2, addr:$src1)>;
4355 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
4356 (CMOVP32rm GR32:$src2, addr:$src1)>;
4357 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
4358 (CMOVNS16rm GR16:$src2, addr:$src1)>;
4359 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
4360 (CMOVNS32rm GR32:$src2, addr:$src1)>;
4361 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
4362 (CMOVS16rm GR16:$src2, addr:$src1)>;
4363 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
4364 (CMOVS32rm GR32:$src2, addr:$src1)>;
4365 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
4366 (CMOVNO16rm GR16:$src2, addr:$src1)>;
4367 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
4368 (CMOVNO32rm GR32:$src2, addr:$src1)>;
4369 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
4370 (CMOVO16rm GR16:$src2, addr:$src1)>;
4371 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
4372 (CMOVO32rm GR32:$src2, addr:$src1)>;
4374 // zextload bool -> zextload byte
4375 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4376 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4377 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4379 // extload bool -> extload byte
4380 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
4381 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
4382 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
4383 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
4384 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
4385 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
4387 // anyext. Define these to do an explicit zero-extend to
4388 // avoid partial-register updates.
4389 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
4390 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
4391 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
4393 // (and (i32 load), 255) -> (zextload i8)
4394 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
4395 (MOVZX32rm8 addr:$src)>;
4396 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
4397 (MOVZX32rm16 addr:$src)>;
4399 //===----------------------------------------------------------------------===//
4401 //===----------------------------------------------------------------------===//
4403 // Odd encoding trick: -128 fits into an 8-bit immediate field while
4404 // +128 doesn't, so in this special case use a sub instead of an add.
4405 def : Pat<(add GR16:$src1, 128),
4406 (SUB16ri8 GR16:$src1, -128)>;
4407 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
4408 (SUB16mi8 addr:$dst, -128)>;
4409 def : Pat<(add GR32:$src1, 128),
4410 (SUB32ri8 GR32:$src1, -128)>;
4411 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
4412 (SUB32mi8 addr:$dst, -128)>;
4414 // r & (2^16-1) ==> movz
4415 def : Pat<(and GR32:$src1, 0xffff),
4416 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
4417 // r & (2^8-1) ==> movz
4418 def : Pat<(and GR32:$src1, 0xff),
4419 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1,
4422 Requires<[In32BitMode]>;
4423 // r & (2^8-1) ==> movz
4424 def : Pat<(and GR16:$src1, 0xff),
4425 (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1,
4428 Requires<[In32BitMode]>;
4430 // sext_inreg patterns
4431 def : Pat<(sext_inreg GR32:$src, i16),
4432 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4433 def : Pat<(sext_inreg GR32:$src, i8),
4434 (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4437 Requires<[In32BitMode]>;
4438 def : Pat<(sext_inreg GR16:$src, i8),
4439 (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4442 Requires<[In32BitMode]>;
4445 def : Pat<(i16 (trunc GR32:$src)),
4446 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
4447 def : Pat<(i8 (trunc GR32:$src)),
4448 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4450 Requires<[In32BitMode]>;
4451 def : Pat<(i8 (trunc GR16:$src)),
4452 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4454 Requires<[In32BitMode]>;
4456 // h-register tricks
4457 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
4458 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4459 x86_subreg_8bit_hi)>,
4460 Requires<[In32BitMode]>;
4461 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
4462 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)),
4463 x86_subreg_8bit_hi)>,
4464 Requires<[In32BitMode]>;
4465 def : Pat<(srl_su GR16:$src, (i8 8)),
4468 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)),
4469 x86_subreg_8bit_hi)),
4471 Requires<[In32BitMode]>;
4472 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
4473 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4475 x86_subreg_8bit_hi))>,
4476 Requires<[In32BitMode]>;
4477 def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
4478 (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src,
4480 x86_subreg_8bit_hi))>,
4481 Requires<[In32BitMode]>;
4482 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
4483 (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src,
4485 x86_subreg_8bit_hi))>,
4486 Requires<[In32BitMode]>;
4488 // (shl x, 1) ==> (add x, x)
4489 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
4490 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
4491 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
4493 // (shl x (and y, 31)) ==> (shl x, y)
4494 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
4495 (SHL8rCL GR8:$src1)>;
4496 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
4497 (SHL16rCL GR16:$src1)>;
4498 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
4499 (SHL32rCL GR32:$src1)>;
4500 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4501 (SHL8mCL addr:$dst)>;
4502 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4503 (SHL16mCL addr:$dst)>;
4504 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4505 (SHL32mCL addr:$dst)>;
4507 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
4508 (SHR8rCL GR8:$src1)>;
4509 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
4510 (SHR16rCL GR16:$src1)>;
4511 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
4512 (SHR32rCL GR32:$src1)>;
4513 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4514 (SHR8mCL addr:$dst)>;
4515 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4516 (SHR16mCL addr:$dst)>;
4517 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4518 (SHR32mCL addr:$dst)>;
4520 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
4521 (SAR8rCL GR8:$src1)>;
4522 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
4523 (SAR16rCL GR16:$src1)>;
4524 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
4525 (SAR32rCL GR32:$src1)>;
4526 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4527 (SAR8mCL addr:$dst)>;
4528 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4529 (SAR16mCL addr:$dst)>;
4530 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
4531 (SAR32mCL addr:$dst)>;
4533 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
4534 def : Pat<(or (srl GR32:$src1, CL:$amt),
4535 (shl GR32:$src2, (sub 32, CL:$amt))),
4536 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4538 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
4539 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4540 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4542 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
4543 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4544 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
4546 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4547 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4549 (SHRD32mrCL addr:$dst, GR32:$src2)>;
4551 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4552 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4554 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
4555 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4556 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4558 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
4559 def : Pat<(or (shl GR32:$src1, CL:$amt),
4560 (srl GR32:$src2, (sub 32, CL:$amt))),
4561 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4563 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
4564 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
4565 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4567 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
4568 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4569 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
4571 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
4572 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
4574 (SHLD32mrCL addr:$dst, GR32:$src2)>;
4576 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
4577 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
4579 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
4580 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
4581 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
4583 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
4584 def : Pat<(or (srl GR16:$src1, CL:$amt),
4585 (shl GR16:$src2, (sub 16, CL:$amt))),
4586 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4588 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
4589 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4590 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4592 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
4593 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4594 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
4596 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4597 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4599 (SHRD16mrCL addr:$dst, GR16:$src2)>;
4601 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4602 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4604 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
4605 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4606 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4608 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
4609 def : Pat<(or (shl GR16:$src1, CL:$amt),
4610 (srl GR16:$src2, (sub 16, CL:$amt))),
4611 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4613 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
4614 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
4615 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4617 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
4618 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4619 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
4621 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
4622 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
4624 (SHLD16mrCL addr:$dst, GR16:$src2)>;
4626 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
4627 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
4629 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
4630 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4631 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4633 // (anyext (setcc_carry)) -> (setcc_carry)
4634 def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4636 def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))),
4639 //===----------------------------------------------------------------------===//
4640 // EFLAGS-defining Patterns
4641 //===----------------------------------------------------------------------===//
4643 // Register-Register Addition with EFLAGS result
4644 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
4646 (ADD8rr GR8:$src1, GR8:$src2)>;
4647 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
4649 (ADD16rr GR16:$src1, GR16:$src2)>;
4650 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
4652 (ADD32rr GR32:$src1, GR32:$src2)>;
4654 // Register-Memory Addition with EFLAGS result
4655 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
4657 (ADD8rm GR8:$src1, addr:$src2)>;
4658 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
4660 (ADD16rm GR16:$src1, addr:$src2)>;
4661 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
4663 (ADD32rm GR32:$src1, addr:$src2)>;
4665 // Register-Integer Addition with EFLAGS result
4666 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
4668 (ADD8ri GR8:$src1, imm:$src2)>;
4669 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
4671 (ADD16ri GR16:$src1, imm:$src2)>;
4672 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
4674 (ADD32ri GR32:$src1, imm:$src2)>;
4675 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
4677 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
4678 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
4680 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4682 // Memory-Register Addition with EFLAGS result
4683 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
4686 (ADD8mr addr:$dst, GR8:$src2)>;
4687 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
4690 (ADD16mr addr:$dst, GR16:$src2)>;
4691 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
4694 (ADD32mr addr:$dst, GR32:$src2)>;
4696 // Memory-Integer Addition with EFLAGS result
4697 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
4700 (ADD8mi addr:$dst, imm:$src2)>;
4701 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
4704 (ADD16mi addr:$dst, imm:$src2)>;
4705 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
4708 (ADD32mi addr:$dst, imm:$src2)>;
4709 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4712 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
4713 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4716 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4718 // Register-Register Subtraction with EFLAGS result
4719 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
4721 (SUB8rr GR8:$src1, GR8:$src2)>;
4722 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
4724 (SUB16rr GR16:$src1, GR16:$src2)>;
4725 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
4727 (SUB32rr GR32:$src1, GR32:$src2)>;
4729 // Register-Memory Subtraction with EFLAGS result
4730 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
4732 (SUB8rm GR8:$src1, addr:$src2)>;
4733 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
4735 (SUB16rm GR16:$src1, addr:$src2)>;
4736 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
4738 (SUB32rm GR32:$src1, addr:$src2)>;
4740 // Register-Integer Subtraction with EFLAGS result
4741 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
4743 (SUB8ri GR8:$src1, imm:$src2)>;
4744 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
4746 (SUB16ri GR16:$src1, imm:$src2)>;
4747 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
4749 (SUB32ri GR32:$src1, imm:$src2)>;
4750 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
4752 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
4753 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
4755 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4757 // Memory-Register Subtraction with EFLAGS result
4758 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
4761 (SUB8mr addr:$dst, GR8:$src2)>;
4762 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
4765 (SUB16mr addr:$dst, GR16:$src2)>;
4766 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
4769 (SUB32mr addr:$dst, GR32:$src2)>;
4771 // Memory-Integer Subtraction with EFLAGS result
4772 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
4775 (SUB8mi addr:$dst, imm:$src2)>;
4776 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
4779 (SUB16mi addr:$dst, imm:$src2)>;
4780 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
4783 (SUB32mi addr:$dst, imm:$src2)>;
4784 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4787 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
4788 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4791 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4794 // Register-Register Signed Integer Multiply with EFLAGS result
4795 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
4797 (IMUL16rr GR16:$src1, GR16:$src2)>;
4798 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
4800 (IMUL32rr GR32:$src1, GR32:$src2)>;
4802 // Register-Memory Signed Integer Multiply with EFLAGS result
4803 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
4805 (IMUL16rm GR16:$src1, addr:$src2)>;
4806 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
4808 (IMUL32rm GR32:$src1, addr:$src2)>;
4810 // Register-Integer Signed Integer Multiply with EFLAGS result
4811 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
4813 (IMUL16rri GR16:$src1, imm:$src2)>;
4814 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
4816 (IMUL32rri GR32:$src1, imm:$src2)>;
4817 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
4819 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4820 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
4822 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4824 // Memory-Integer Signed Integer Multiply with EFLAGS result
4825 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
4827 (IMUL16rmi addr:$src1, imm:$src2)>;
4828 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
4830 (IMUL32rmi addr:$src1, imm:$src2)>;
4831 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
4833 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4834 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
4836 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4838 // Optimize multiply by 2 with EFLAGS result.
4839 let AddedComplexity = 2 in {
4840 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
4842 (ADD16rr GR16:$src1, GR16:$src1)>;
4844 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
4846 (ADD32rr GR32:$src1, GR32:$src1)>;
4849 // INC and DEC with EFLAGS result. Note that these do not set CF.
4850 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4852 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4855 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4857 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4861 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
4862 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4863 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4865 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
4866 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
4867 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4868 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4870 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
4872 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
4873 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4874 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4876 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
4877 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
4878 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4879 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4881 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
4883 // Register-Register Or with EFLAGS result
4884 def : Pat<(parallel (X86or_flag GR8:$src1, GR8:$src2),
4886 (OR8rr GR8:$src1, GR8:$src2)>;
4887 def : Pat<(parallel (X86or_flag GR16:$src1, GR16:$src2),
4889 (OR16rr GR16:$src1, GR16:$src2)>;
4890 def : Pat<(parallel (X86or_flag GR32:$src1, GR32:$src2),
4892 (OR32rr GR32:$src1, GR32:$src2)>;
4894 // Register-Memory Or with EFLAGS result
4895 def : Pat<(parallel (X86or_flag GR8:$src1, (loadi8 addr:$src2)),
4897 (OR8rm GR8:$src1, addr:$src2)>;
4898 def : Pat<(parallel (X86or_flag GR16:$src1, (loadi16 addr:$src2)),
4900 (OR16rm GR16:$src1, addr:$src2)>;
4901 def : Pat<(parallel (X86or_flag GR32:$src1, (loadi32 addr:$src2)),
4903 (OR32rm GR32:$src1, addr:$src2)>;
4905 // Register-Integer Or with EFLAGS result
4906 def : Pat<(parallel (X86or_flag GR8:$src1, imm:$src2),
4908 (OR8ri GR8:$src1, imm:$src2)>;
4909 def : Pat<(parallel (X86or_flag GR16:$src1, imm:$src2),
4911 (OR16ri GR16:$src1, imm:$src2)>;
4912 def : Pat<(parallel (X86or_flag GR32:$src1, imm:$src2),
4914 (OR32ri GR32:$src1, imm:$src2)>;
4915 def : Pat<(parallel (X86or_flag GR16:$src1, i16immSExt8:$src2),
4917 (OR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4918 def : Pat<(parallel (X86or_flag GR32:$src1, i32immSExt8:$src2),
4920 (OR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4922 // Memory-Register Or with EFLAGS result
4923 def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), GR8:$src2),
4926 (OR8mr addr:$dst, GR8:$src2)>;
4927 def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), GR16:$src2),
4930 (OR16mr addr:$dst, GR16:$src2)>;
4931 def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), GR32:$src2),
4934 (OR32mr addr:$dst, GR32:$src2)>;
4936 // Memory-Integer Or with EFLAGS result
4937 def : Pat<(parallel (store (X86or_flag (loadi8 addr:$dst), imm:$src2),
4940 (OR8mi addr:$dst, imm:$src2)>;
4941 def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), imm:$src2),
4944 (OR16mi addr:$dst, imm:$src2)>;
4945 def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), imm:$src2),
4948 (OR32mi addr:$dst, imm:$src2)>;
4949 def : Pat<(parallel (store (X86or_flag (loadi16 addr:$dst), i16immSExt8:$src2),
4952 (OR16mi8 addr:$dst, i16immSExt8:$src2)>;
4953 def : Pat<(parallel (store (X86or_flag (loadi32 addr:$dst), i32immSExt8:$src2),
4956 (OR32mi8 addr:$dst, i32immSExt8:$src2)>;
4958 // Register-Register XOr with EFLAGS result
4959 def : Pat<(parallel (X86xor_flag GR8:$src1, GR8:$src2),
4961 (XOR8rr GR8:$src1, GR8:$src2)>;
4962 def : Pat<(parallel (X86xor_flag GR16:$src1, GR16:$src2),
4964 (XOR16rr GR16:$src1, GR16:$src2)>;
4965 def : Pat<(parallel (X86xor_flag GR32:$src1, GR32:$src2),
4967 (XOR32rr GR32:$src1, GR32:$src2)>;
4969 // Register-Memory XOr with EFLAGS result
4970 def : Pat<(parallel (X86xor_flag GR8:$src1, (loadi8 addr:$src2)),
4972 (XOR8rm GR8:$src1, addr:$src2)>;
4973 def : Pat<(parallel (X86xor_flag GR16:$src1, (loadi16 addr:$src2)),
4975 (XOR16rm GR16:$src1, addr:$src2)>;
4976 def : Pat<(parallel (X86xor_flag GR32:$src1, (loadi32 addr:$src2)),
4978 (XOR32rm GR32:$src1, addr:$src2)>;
4980 // Register-Integer XOr with EFLAGS result
4981 def : Pat<(parallel (X86xor_flag GR8:$src1, imm:$src2),
4983 (XOR8ri GR8:$src1, imm:$src2)>;
4984 def : Pat<(parallel (X86xor_flag GR16:$src1, imm:$src2),
4986 (XOR16ri GR16:$src1, imm:$src2)>;
4987 def : Pat<(parallel (X86xor_flag GR32:$src1, imm:$src2),
4989 (XOR32ri GR32:$src1, imm:$src2)>;
4990 def : Pat<(parallel (X86xor_flag GR16:$src1, i16immSExt8:$src2),
4992 (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>;
4993 def : Pat<(parallel (X86xor_flag GR32:$src1, i32immSExt8:$src2),
4995 (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>;
4997 // Memory-Register XOr with EFLAGS result
4998 def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), GR8:$src2),
5001 (XOR8mr addr:$dst, GR8:$src2)>;
5002 def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), GR16:$src2),
5005 (XOR16mr addr:$dst, GR16:$src2)>;
5006 def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), GR32:$src2),
5009 (XOR32mr addr:$dst, GR32:$src2)>;
5011 // Memory-Integer XOr with EFLAGS result
5012 def : Pat<(parallel (store (X86xor_flag (loadi8 addr:$dst), imm:$src2),
5015 (XOR8mi addr:$dst, imm:$src2)>;
5016 def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), imm:$src2),
5019 (XOR16mi addr:$dst, imm:$src2)>;
5020 def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), imm:$src2),
5023 (XOR32mi addr:$dst, imm:$src2)>;
5024 def : Pat<(parallel (store (X86xor_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5027 (XOR16mi8 addr:$dst, i16immSExt8:$src2)>;
5028 def : Pat<(parallel (store (X86xor_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5031 (XOR32mi8 addr:$dst, i32immSExt8:$src2)>;
5033 // Register-Register And with EFLAGS result
5034 def : Pat<(parallel (X86and_flag GR8:$src1, GR8:$src2),
5036 (AND8rr GR8:$src1, GR8:$src2)>;
5037 def : Pat<(parallel (X86and_flag GR16:$src1, GR16:$src2),
5039 (AND16rr GR16:$src1, GR16:$src2)>;
5040 def : Pat<(parallel (X86and_flag GR32:$src1, GR32:$src2),
5042 (AND32rr GR32:$src1, GR32:$src2)>;
5044 // Register-Memory And with EFLAGS result
5045 def : Pat<(parallel (X86and_flag GR8:$src1, (loadi8 addr:$src2)),
5047 (AND8rm GR8:$src1, addr:$src2)>;
5048 def : Pat<(parallel (X86and_flag GR16:$src1, (loadi16 addr:$src2)),
5050 (AND16rm GR16:$src1, addr:$src2)>;
5051 def : Pat<(parallel (X86and_flag GR32:$src1, (loadi32 addr:$src2)),
5053 (AND32rm GR32:$src1, addr:$src2)>;
5055 // Register-Integer And with EFLAGS result
5056 def : Pat<(parallel (X86and_flag GR8:$src1, imm:$src2),
5058 (AND8ri GR8:$src1, imm:$src2)>;
5059 def : Pat<(parallel (X86and_flag GR16:$src1, imm:$src2),
5061 (AND16ri GR16:$src1, imm:$src2)>;
5062 def : Pat<(parallel (X86and_flag GR32:$src1, imm:$src2),
5064 (AND32ri GR32:$src1, imm:$src2)>;
5065 def : Pat<(parallel (X86and_flag GR16:$src1, i16immSExt8:$src2),
5067 (AND16ri8 GR16:$src1, i16immSExt8:$src2)>;
5068 def : Pat<(parallel (X86and_flag GR32:$src1, i32immSExt8:$src2),
5070 (AND32ri8 GR32:$src1, i32immSExt8:$src2)>;
5072 // Memory-Register And with EFLAGS result
5073 def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), GR8:$src2),
5076 (AND8mr addr:$dst, GR8:$src2)>;
5077 def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), GR16:$src2),
5080 (AND16mr addr:$dst, GR16:$src2)>;
5081 def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), GR32:$src2),
5084 (AND32mr addr:$dst, GR32:$src2)>;
5086 // Memory-Integer And with EFLAGS result
5087 def : Pat<(parallel (store (X86and_flag (loadi8 addr:$dst), imm:$src2),
5090 (AND8mi addr:$dst, imm:$src2)>;
5091 def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), imm:$src2),
5094 (AND16mi addr:$dst, imm:$src2)>;
5095 def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), imm:$src2),
5098 (AND32mi addr:$dst, imm:$src2)>;
5099 def : Pat<(parallel (store (X86and_flag (loadi16 addr:$dst), i16immSExt8:$src2),
5102 (AND16mi8 addr:$dst, i16immSExt8:$src2)>;
5103 def : Pat<(parallel (store (X86and_flag (loadi32 addr:$dst), i32immSExt8:$src2),
5106 (AND32mi8 addr:$dst, i32immSExt8:$src2)>;
5108 // -disable-16bit support.
5109 def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
5110 (MOV16mi addr:$dst, imm:$src)>;
5111 def : Pat<(truncstorei16 GR32:$src, addr:$dst),
5112 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
5113 def : Pat<(i32 (sextloadi16 addr:$dst)),
5114 (MOVSX32rm16 addr:$dst)>;
5115 def : Pat<(i32 (zextloadi16 addr:$dst)),
5116 (MOVZX32rm16 addr:$dst)>;
5117 def : Pat<(i32 (extloadi16 addr:$dst)),
5118 (MOVZX32rm16 addr:$dst)>;
5120 //===----------------------------------------------------------------------===//
5121 // Floating Point Stack Support
5122 //===----------------------------------------------------------------------===//
5124 include "X86InstrFPStack.td"
5126 //===----------------------------------------------------------------------===//
5128 //===----------------------------------------------------------------------===//
5130 include "X86Instr64bit.td"
5132 //===----------------------------------------------------------------------===//
5133 // XMM Floating point support (requires SSE / SSE2)
5134 //===----------------------------------------------------------------------===//
5136 include "X86InstrSSE.td"
5138 //===----------------------------------------------------------------------===//
5139 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
5140 //===----------------------------------------------------------------------===//
5142 include "X86InstrMMX.td"