1 //===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the X86 instruction set, defining the instructions, and
11 // properties of the instructions which are needed for code generation, machine
12 // code emission, and analysis.
14 //===----------------------------------------------------------------------===//
16 //===----------------------------------------------------------------------===//
17 // X86 specific DAG Nodes.
20 def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
24 def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
26 def SDTX86Cmov : SDTypeProfile<1, 4,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
30 // Unary and binary operator instructions that set EFLAGS as a side-effect.
31 def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
33 def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
37 def SDTX86BrCond : SDTypeProfile<0, 3,
38 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
41 def SDTX86SetCC : SDTypeProfile<1, 2,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
45 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
47 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
49 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
51 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
53 def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
54 def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
57 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
59 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
61 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
63 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
65 def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
67 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
69 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
71 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
73 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
74 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
75 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
76 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
78 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
80 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
82 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
83 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
85 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
87 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
90 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
91 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
102 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
105 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
106 [SDNPHasChain, SDNPMayStore,
107 SDNPMayLoad, SDNPMemOperand]>;
108 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
109 [SDNPHasChain, SDNPMayStore,
110 SDNPMayLoad, SDNPMemOperand]>;
111 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
112 [SDNPHasChain, SDNPMayStore,
113 SDNPMayLoad, SDNPMemOperand]>;
114 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
115 [SDNPHasChain, SDNPOptInFlag]>;
117 def X86callseq_start :
118 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
119 [SDNPHasChain, SDNPOutFlag]>;
121 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
122 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
124 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
125 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
127 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
128 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
130 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
131 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
132 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
133 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
136 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
137 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
139 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
140 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
142 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
143 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
144 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
145 SDT_X86SegmentBaseAddress, []>;
147 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
150 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
151 [SDNPHasChain, SDNPOptInFlag]>;
153 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
154 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
155 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
156 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
157 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
158 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
160 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
162 //===----------------------------------------------------------------------===//
163 // X86 Operand Definitions.
166 def i32imm_pcrel : Operand<i32> {
167 let PrintMethod = "print_pcrel_imm";
170 // A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
171 // the index operand of an address, to conform to x86 encoding restrictions.
172 def ptr_rc_nosp : PointerLikeRegClass<1>;
174 // *mem - Operand definitions for the funky X86 addressing mode operands.
176 class X86MemOperand<string printMethod> : Operand<iPTR> {
177 let PrintMethod = printMethod;
178 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
181 def i8mem : X86MemOperand<"printi8mem">;
182 def i16mem : X86MemOperand<"printi16mem">;
183 def i32mem : X86MemOperand<"printi32mem">;
184 def i64mem : X86MemOperand<"printi64mem">;
185 def i128mem : X86MemOperand<"printi128mem">;
186 def i256mem : X86MemOperand<"printi256mem">;
187 def f32mem : X86MemOperand<"printf32mem">;
188 def f64mem : X86MemOperand<"printf64mem">;
189 def f80mem : X86MemOperand<"printf80mem">;
190 def f128mem : X86MemOperand<"printf128mem">;
191 def f256mem : X86MemOperand<"printf256mem">;
193 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
194 // plain GR64, so that it doesn't potentially require a REX prefix.
195 def i8mem_NOREX : Operand<i64> {
196 let PrintMethod = "printi8mem";
197 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
200 def lea32mem : Operand<i32> {
201 let PrintMethod = "printlea32mem";
202 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
205 def SSECC : Operand<i8> {
206 let PrintMethod = "printSSECC";
209 def piclabel: Operand<i32> {
210 let PrintMethod = "printPICLabel";
213 // A couple of more descriptive operand definitions.
214 // 16-bits but only 8 bits are significant.
215 def i16i8imm : Operand<i16>;
216 // 32-bits but only 8 bits are significant.
217 def i32i8imm : Operand<i32>;
219 // Branch targets have OtherVT type and print as pc-relative values.
220 def brtarget : Operand<OtherVT> {
221 let PrintMethod = "print_pcrel_imm";
224 def brtarget8 : Operand<OtherVT> {
225 let PrintMethod = "print_pcrel_imm";
228 //===----------------------------------------------------------------------===//
229 // X86 Complex Pattern Definitions.
232 // Define X86 specific addressing mode.
233 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
234 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
235 [add, sub, mul, X86mul_imm, shl, or, frameindex],
237 def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
238 [tglobaltlsaddr], []>;
240 //===----------------------------------------------------------------------===//
241 // X86 Instruction Predicate Definitions.
242 def HasMMX : Predicate<"Subtarget->hasMMX()">;
243 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
244 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
245 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
246 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
247 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
248 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
249 def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
250 def HasAVX : Predicate<"Subtarget->hasAVX()">;
251 def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
252 def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
253 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
254 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
255 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
256 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
257 def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
258 def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
259 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
260 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
261 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
262 def OptForSpeed : Predicate<"!OptForSize">;
263 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
264 def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
266 //===----------------------------------------------------------------------===//
267 // X86 Instruction Format Definitions.
270 include "X86InstrFormats.td"
272 //===----------------------------------------------------------------------===//
273 // Pattern fragments...
276 // X86 specific condition code. These correspond to CondCode in
277 // X86InstrInfo.h. They must be kept in synch.
278 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
279 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
280 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
281 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
282 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
283 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
284 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
285 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
286 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
287 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
288 def X86_COND_NO : PatLeaf<(i8 10)>;
289 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
290 def X86_COND_NS : PatLeaf<(i8 12)>;
291 def X86_COND_O : PatLeaf<(i8 13)>;
292 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
293 def X86_COND_S : PatLeaf<(i8 15)>;
295 def i16immSExt8 : PatLeaf<(i16 imm), [{
296 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
297 // sign extended field.
298 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
301 def i32immSExt8 : PatLeaf<(i32 imm), [{
302 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
303 // sign extended field.
304 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
307 // Helper fragments for loads.
308 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
309 // known to be 32-bit aligned or better. Ditto for i8 to i16.
310 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
311 LoadSDNode *LD = cast<LoadSDNode>(N);
312 if (const Value *Src = LD->getSrcValue())
313 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
314 if (PT->getAddressSpace() > 255)
316 ISD::LoadExtType ExtType = LD->getExtensionType();
317 if (ExtType == ISD::NON_EXTLOAD)
319 if (ExtType == ISD::EXTLOAD)
320 return LD->getAlignment() >= 2 && !LD->isVolatile();
324 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
325 LoadSDNode *LD = cast<LoadSDNode>(N);
326 if (const Value *Src = LD->getSrcValue())
327 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
328 if (PT->getAddressSpace() > 255)
330 ISD::LoadExtType ExtType = LD->getExtensionType();
331 if (ExtType == ISD::EXTLOAD)
332 return LD->getAlignment() >= 2 && !LD->isVolatile();
336 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
337 LoadSDNode *LD = cast<LoadSDNode>(N);
338 if (const Value *Src = LD->getSrcValue())
339 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
340 if (PT->getAddressSpace() > 255)
342 ISD::LoadExtType ExtType = LD->getExtensionType();
343 if (ExtType == ISD::NON_EXTLOAD)
345 if (ExtType == ISD::EXTLOAD)
346 return LD->getAlignment() >= 4 && !LD->isVolatile();
350 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
351 LoadSDNode *LD = cast<LoadSDNode>(N);
352 if (const Value *Src = LD->getSrcValue())
353 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
354 if (PT->getAddressSpace() > 255)
356 if (LD->isVolatile())
358 ISD::LoadExtType ExtType = LD->getExtensionType();
359 if (ExtType == ISD::NON_EXTLOAD)
361 if (ExtType == ISD::EXTLOAD)
362 return LD->getAlignment() >= 4;
366 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
367 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
368 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
369 return PT->getAddressSpace() == 256;
373 def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
374 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
375 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
376 return PT->getAddressSpace() == 257;
380 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
381 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
382 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
383 if (PT->getAddressSpace() > 255)
387 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
388 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
389 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
390 if (PT->getAddressSpace() > 255)
395 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
396 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
397 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
398 if (PT->getAddressSpace() > 255)
402 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
403 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
404 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
405 if (PT->getAddressSpace() > 255)
409 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
410 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
411 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
412 if (PT->getAddressSpace() > 255)
417 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
418 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
419 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
421 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
422 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
423 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
424 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
425 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
426 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
428 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
429 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
430 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
431 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
432 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
433 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
436 // An 'and' node with a single use.
437 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
438 return N->hasOneUse();
440 // An 'srl' node with a single use.
441 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
442 return N->hasOneUse();
444 // An 'trunc' node with a single use.
445 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
446 return N->hasOneUse();
449 // 'shld' and 'shrd' instruction patterns. Note that even though these have
450 // the srl and shl in their patterns, the C++ code must still check for them,
451 // because predicates are tested before children nodes are explored.
453 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
454 (or (srl node:$src1, node:$amt1),
455 (shl node:$src2, node:$amt2)), [{
456 assert(N->getOpcode() == ISD::OR);
457 return N->getOperand(0).getOpcode() == ISD::SRL &&
458 N->getOperand(1).getOpcode() == ISD::SHL &&
459 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
460 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
461 N->getOperand(0).getConstantOperandVal(1) ==
462 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
465 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
466 (or (shl node:$src1, node:$amt1),
467 (srl node:$src2, node:$amt2)), [{
468 assert(N->getOpcode() == ISD::OR);
469 return N->getOperand(0).getOpcode() == ISD::SHL &&
470 N->getOperand(1).getOpcode() == ISD::SRL &&
471 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
472 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
473 N->getOperand(0).getConstantOperandVal(1) ==
474 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
477 //===----------------------------------------------------------------------===//
478 // Instruction list...
481 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
482 // a stack adjustment and the codegen must know that they may modify the stack
483 // pointer before prolog-epilog rewriting occurs.
484 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
485 // sub / add which can clobber EFLAGS.
486 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
487 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
489 [(X86callseq_start timm:$amt)]>,
490 Requires<[In32BitMode]>;
491 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
493 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
494 Requires<[In32BitMode]>;
498 let neverHasSideEffects = 1 in {
499 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
500 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
501 "nopl\t$zero", []>, TB;
505 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
506 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
510 //===----------------------------------------------------------------------===//
511 // Control Flow Instructions...
514 // Return instructions.
515 let isTerminator = 1, isReturn = 1, isBarrier = 1,
516 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
517 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
520 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
522 [(X86retflag imm:$amt)]>;
525 // All branches are RawFrm, Void, Branch, and Terminators
526 let isBranch = 1, isTerminator = 1 in
527 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
528 I<opcode, RawFrm, (outs), ins, asm, pattern>;
530 let isBranch = 1, isBarrier = 1 in {
531 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
532 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
536 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
537 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
538 [(brind GR32:$dst)]>;
539 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
540 [(brind (loadi32 addr:$dst))]>;
543 // Conditional branches
544 let Uses = [EFLAGS] in {
545 // Short conditional jumps
546 def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
547 def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
548 def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
549 def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
550 def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
551 def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
552 def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
553 def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
554 def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
555 def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
556 def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
557 def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
558 def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
559 def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
560 def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
561 def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
563 def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
565 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
566 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
567 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
568 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
569 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
570 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
571 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
572 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
573 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
574 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
575 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
576 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
578 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
579 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
580 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
581 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
582 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
583 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
584 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
585 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
587 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
588 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
589 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
590 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
591 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
592 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
593 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
594 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
595 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
596 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
597 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
598 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
601 //===----------------------------------------------------------------------===//
602 // Call Instructions...
605 // All calls clobber the non-callee saved registers. ESP is marked as
606 // a use to prevent stack-pointer assignments that appear immediately
607 // before calls from potentially appearing dead. Uses for argument
608 // registers are added manually.
609 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
610 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
611 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
612 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
614 def CALLpcrel32 : Ii32<0xE8, RawFrm,
615 (outs), (ins i32imm_pcrel:$dst,variable_ops),
617 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
618 "call\t{*}$dst", [(X86call GR32:$dst)]>;
619 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
620 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
625 def TAILCALL : I<0, Pseudo, (outs), (ins),
629 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
630 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
631 "#TC_RETURN $dst $offset",
634 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
635 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
636 "#TC_RETURN $dst $offset",
639 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
641 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
643 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
644 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
646 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
647 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
648 "jmp\t{*}$dst # TAILCALL", []>;
650 //===----------------------------------------------------------------------===//
651 // Miscellaneous Instructions...
653 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
654 def LEAVE : I<0xC9, RawFrm,
655 (outs), (ins), "leave", []>;
657 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
659 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
662 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
665 let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
666 def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
667 "push{l}\t$imm", []>;
668 def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
669 "push{l}\t$imm", []>;
670 def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
671 "push{l}\t$imm", []>;
674 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
675 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
676 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
677 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
679 let isTwoAddress = 1 in // GR32 = bswap GR32
680 def BSWAP32r : I<0xC8, AddRegFrm,
681 (outs GR32:$dst), (ins GR32:$src),
683 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
686 // Bit scan instructions.
687 let Defs = [EFLAGS] in {
688 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
689 "bsf{w}\t{$src, $dst|$dst, $src}",
690 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
691 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
692 "bsf{w}\t{$src, $dst|$dst, $src}",
693 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
694 (implicit EFLAGS)]>, TB;
695 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
696 "bsf{l}\t{$src, $dst|$dst, $src}",
697 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
698 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
699 "bsf{l}\t{$src, $dst|$dst, $src}",
700 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
701 (implicit EFLAGS)]>, TB;
703 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
704 "bsr{w}\t{$src, $dst|$dst, $src}",
705 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
706 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
707 "bsr{w}\t{$src, $dst|$dst, $src}",
708 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
709 (implicit EFLAGS)]>, TB;
710 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
711 "bsr{l}\t{$src, $dst|$dst, $src}",
712 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
713 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
714 "bsr{l}\t{$src, $dst|$dst, $src}",
715 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
716 (implicit EFLAGS)]>, TB;
719 let neverHasSideEffects = 1 in
720 def LEA16r : I<0x8D, MRMSrcMem,
721 (outs GR16:$dst), (ins i32mem:$src),
722 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
723 let isReMaterializable = 1 in
724 def LEA32r : I<0x8D, MRMSrcMem,
725 (outs GR32:$dst), (ins lea32mem:$src),
726 "lea{l}\t{$src|$dst}, {$dst|$src}",
727 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
729 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
730 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
731 [(X86rep_movs i8)]>, REP;
732 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
733 [(X86rep_movs i16)]>, REP, OpSize;
734 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
735 [(X86rep_movs i32)]>, REP;
738 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
739 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
740 [(X86rep_stos i8)]>, REP;
741 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
742 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
743 [(X86rep_stos i16)]>, REP, OpSize;
744 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
745 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
746 [(X86rep_stos i32)]>, REP;
748 let Defs = [RAX, RDX] in
749 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
752 let isBarrier = 1, hasCtrlDep = 1 in {
753 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
756 //===----------------------------------------------------------------------===//
757 // Input/Output Instructions...
759 let Defs = [AL], Uses = [DX] in
760 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
761 "in{b}\t{%dx, %al|%AL, %DX}", []>;
762 let Defs = [AX], Uses = [DX] in
763 def IN16rr : I<0xED, RawFrm, (outs), (ins),
764 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
765 let Defs = [EAX], Uses = [DX] in
766 def IN32rr : I<0xED, RawFrm, (outs), (ins),
767 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
770 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
771 "in{b}\t{$port, %al|%AL, $port}", []>;
773 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
774 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
776 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
777 "in{l}\t{$port, %eax|%EAX, $port}", []>;
779 let Uses = [DX, AL] in
780 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
781 "out{b}\t{%al, %dx|%DX, %AL}", []>;
782 let Uses = [DX, AX] in
783 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
784 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
785 let Uses = [DX, EAX] in
786 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
787 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
790 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
791 "out{b}\t{%al, $port|$port, %AL}", []>;
793 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
794 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
796 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
797 "out{l}\t{%eax, $port|$port, %EAX}", []>;
799 //===----------------------------------------------------------------------===//
800 // Move Instructions...
802 let neverHasSideEffects = 1 in {
803 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
804 "mov{b}\t{$src, $dst|$dst, $src}", []>;
805 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
806 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
807 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
808 "mov{l}\t{$src, $dst|$dst, $src}", []>;
810 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
811 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
812 "mov{b}\t{$src, $dst|$dst, $src}",
813 [(set GR8:$dst, imm:$src)]>;
814 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
815 "mov{w}\t{$src, $dst|$dst, $src}",
816 [(set GR16:$dst, imm:$src)]>, OpSize;
817 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
818 "mov{l}\t{$src, $dst|$dst, $src}",
819 [(set GR32:$dst, imm:$src)]>;
821 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
822 "mov{b}\t{$src, $dst|$dst, $src}",
823 [(store (i8 imm:$src), addr:$dst)]>;
824 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
825 "mov{w}\t{$src, $dst|$dst, $src}",
826 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
827 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
828 "mov{l}\t{$src, $dst|$dst, $src}",
829 [(store (i32 imm:$src), addr:$dst)]>;
831 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
832 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
833 "mov{b}\t{$src, $dst|$dst, $src}",
834 [(set GR8:$dst, (loadi8 addr:$src))]>;
835 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
836 "mov{w}\t{$src, $dst|$dst, $src}",
837 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
838 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
839 "mov{l}\t{$src, $dst|$dst, $src}",
840 [(set GR32:$dst, (loadi32 addr:$src))]>;
843 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
844 "mov{b}\t{$src, $dst|$dst, $src}",
845 [(store GR8:$src, addr:$dst)]>;
846 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
847 "mov{w}\t{$src, $dst|$dst, $src}",
848 [(store GR16:$src, addr:$dst)]>, OpSize;
849 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
850 "mov{l}\t{$src, $dst|$dst, $src}",
851 [(store GR32:$src, addr:$dst)]>;
853 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
854 // that they can be used for copying and storing h registers, which can't be
855 // encoded when a REX prefix is present.
856 let neverHasSideEffects = 1 in
857 def MOV8rr_NOREX : I<0x88, MRMDestReg,
858 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
859 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
861 def MOV8mr_NOREX : I<0x88, MRMDestMem,
862 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
863 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
865 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
866 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
867 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
868 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
870 //===----------------------------------------------------------------------===//
871 // Fixed-Register Multiplication and Division Instructions...
874 // Extra precision multiplication
875 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
876 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
877 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
878 // This probably ought to be moved to a def : Pat<> if the
879 // syntax can be accepted.
880 [(set AL, (mul AL, GR8:$src)),
881 (implicit EFLAGS)]>; // AL,AH = AL*GR8
883 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
884 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
886 []>, OpSize; // AX,DX = AX*GR16
888 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
889 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
891 []>; // EAX,EDX = EAX*GR32
893 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
894 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
896 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
897 // This probably ought to be moved to a def : Pat<> if the
898 // syntax can be accepted.
899 [(set AL, (mul AL, (loadi8 addr:$src))),
900 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
902 let mayLoad = 1, neverHasSideEffects = 1 in {
903 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
904 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
906 []>, OpSize; // AX,DX = AX*[mem16]
908 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
909 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
911 []>; // EAX,EDX = EAX*[mem32]
914 let neverHasSideEffects = 1 in {
915 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
916 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
918 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
919 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
920 OpSize; // AX,DX = AX*GR16
921 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
922 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
923 // EAX,EDX = EAX*GR32
925 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
926 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
927 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
928 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
929 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
930 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
931 let Defs = [EAX,EDX], Uses = [EAX] in
932 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
933 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
935 } // neverHasSideEffects
937 // unsigned division/remainder
938 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
939 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
941 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
942 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
943 "div{w}\t$src", []>, OpSize;
944 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
945 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
948 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
949 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
951 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
952 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
953 "div{w}\t$src", []>, OpSize;
954 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
955 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
959 // Signed division/remainder.
960 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
961 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
962 "idiv{b}\t$src", []>;
963 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
964 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
965 "idiv{w}\t$src", []>, OpSize;
966 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
967 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
968 "idiv{l}\t$src", []>;
969 let mayLoad = 1, mayLoad = 1 in {
970 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
971 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
972 "idiv{b}\t$src", []>;
973 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
974 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
975 "idiv{w}\t$src", []>, OpSize;
976 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
977 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
978 "idiv{l}\t$src", []>;
981 //===----------------------------------------------------------------------===//
982 // Two address Instructions.
984 let isTwoAddress = 1 in {
987 let Uses = [EFLAGS] in {
988 let isCommutable = 1 in {
989 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
990 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
991 "cmovb\t{$src2, $dst|$dst, $src2}",
992 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
993 X86_COND_B, EFLAGS))]>,
995 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
996 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
997 "cmovb\t{$src2, $dst|$dst, $src2}",
998 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
999 X86_COND_B, EFLAGS))]>,
1001 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
1002 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1003 "cmovae\t{$src2, $dst|$dst, $src2}",
1004 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1005 X86_COND_AE, EFLAGS))]>,
1007 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
1008 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1009 "cmovae\t{$src2, $dst|$dst, $src2}",
1010 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1011 X86_COND_AE, EFLAGS))]>,
1013 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
1014 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1015 "cmove\t{$src2, $dst|$dst, $src2}",
1016 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1017 X86_COND_E, EFLAGS))]>,
1019 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
1020 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1021 "cmove\t{$src2, $dst|$dst, $src2}",
1022 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1023 X86_COND_E, EFLAGS))]>,
1025 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
1026 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1027 "cmovne\t{$src2, $dst|$dst, $src2}",
1028 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1029 X86_COND_NE, EFLAGS))]>,
1031 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
1032 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1033 "cmovne\t{$src2, $dst|$dst, $src2}",
1034 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1035 X86_COND_NE, EFLAGS))]>,
1037 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
1038 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1039 "cmovbe\t{$src2, $dst|$dst, $src2}",
1040 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1041 X86_COND_BE, EFLAGS))]>,
1043 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
1044 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1045 "cmovbe\t{$src2, $dst|$dst, $src2}",
1046 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1047 X86_COND_BE, EFLAGS))]>,
1049 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
1050 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1051 "cmova\t{$src2, $dst|$dst, $src2}",
1052 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1053 X86_COND_A, EFLAGS))]>,
1055 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
1056 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1057 "cmova\t{$src2, $dst|$dst, $src2}",
1058 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1059 X86_COND_A, EFLAGS))]>,
1061 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
1062 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1063 "cmovl\t{$src2, $dst|$dst, $src2}",
1064 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1065 X86_COND_L, EFLAGS))]>,
1067 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1068 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1069 "cmovl\t{$src2, $dst|$dst, $src2}",
1070 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1071 X86_COND_L, EFLAGS))]>,
1073 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1074 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1075 "cmovge\t{$src2, $dst|$dst, $src2}",
1076 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1077 X86_COND_GE, EFLAGS))]>,
1079 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1080 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1081 "cmovge\t{$src2, $dst|$dst, $src2}",
1082 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1083 X86_COND_GE, EFLAGS))]>,
1085 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1086 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1087 "cmovle\t{$src2, $dst|$dst, $src2}",
1088 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1089 X86_COND_LE, EFLAGS))]>,
1091 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1092 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1093 "cmovle\t{$src2, $dst|$dst, $src2}",
1094 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1095 X86_COND_LE, EFLAGS))]>,
1097 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1098 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1099 "cmovg\t{$src2, $dst|$dst, $src2}",
1100 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1101 X86_COND_G, EFLAGS))]>,
1103 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1104 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1105 "cmovg\t{$src2, $dst|$dst, $src2}",
1106 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1107 X86_COND_G, EFLAGS))]>,
1109 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1110 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1111 "cmovs\t{$src2, $dst|$dst, $src2}",
1112 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1113 X86_COND_S, EFLAGS))]>,
1115 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1116 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1117 "cmovs\t{$src2, $dst|$dst, $src2}",
1118 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1119 X86_COND_S, EFLAGS))]>,
1121 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1122 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1123 "cmovns\t{$src2, $dst|$dst, $src2}",
1124 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1125 X86_COND_NS, EFLAGS))]>,
1127 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1128 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1129 "cmovns\t{$src2, $dst|$dst, $src2}",
1130 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1131 X86_COND_NS, EFLAGS))]>,
1133 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1134 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1135 "cmovp\t{$src2, $dst|$dst, $src2}",
1136 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1137 X86_COND_P, EFLAGS))]>,
1139 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1140 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1141 "cmovp\t{$src2, $dst|$dst, $src2}",
1142 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1143 X86_COND_P, EFLAGS))]>,
1145 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1146 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1147 "cmovnp\t{$src2, $dst|$dst, $src2}",
1148 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1149 X86_COND_NP, EFLAGS))]>,
1151 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1152 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1153 "cmovnp\t{$src2, $dst|$dst, $src2}",
1154 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1155 X86_COND_NP, EFLAGS))]>,
1157 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1158 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1159 "cmovo\t{$src2, $dst|$dst, $src2}",
1160 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1161 X86_COND_O, EFLAGS))]>,
1163 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1164 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1165 "cmovo\t{$src2, $dst|$dst, $src2}",
1166 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1167 X86_COND_O, EFLAGS))]>,
1169 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1170 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1171 "cmovno\t{$src2, $dst|$dst, $src2}",
1172 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1173 X86_COND_NO, EFLAGS))]>,
1175 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1176 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1177 "cmovno\t{$src2, $dst|$dst, $src2}",
1178 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1179 X86_COND_NO, EFLAGS))]>,
1181 } // isCommutable = 1
1183 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1184 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1185 "cmovb\t{$src2, $dst|$dst, $src2}",
1186 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1187 X86_COND_B, EFLAGS))]>,
1189 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1190 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1191 "cmovb\t{$src2, $dst|$dst, $src2}",
1192 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1193 X86_COND_B, EFLAGS))]>,
1195 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1196 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1197 "cmovae\t{$src2, $dst|$dst, $src2}",
1198 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1199 X86_COND_AE, EFLAGS))]>,
1201 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1202 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1203 "cmovae\t{$src2, $dst|$dst, $src2}",
1204 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1205 X86_COND_AE, EFLAGS))]>,
1207 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1208 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1209 "cmove\t{$src2, $dst|$dst, $src2}",
1210 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1211 X86_COND_E, EFLAGS))]>,
1213 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1214 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1215 "cmove\t{$src2, $dst|$dst, $src2}",
1216 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1217 X86_COND_E, EFLAGS))]>,
1219 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1220 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1221 "cmovne\t{$src2, $dst|$dst, $src2}",
1222 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1223 X86_COND_NE, EFLAGS))]>,
1225 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1226 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1227 "cmovne\t{$src2, $dst|$dst, $src2}",
1228 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1229 X86_COND_NE, EFLAGS))]>,
1231 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1232 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1233 "cmovbe\t{$src2, $dst|$dst, $src2}",
1234 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1235 X86_COND_BE, EFLAGS))]>,
1237 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1238 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1239 "cmovbe\t{$src2, $dst|$dst, $src2}",
1240 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1241 X86_COND_BE, EFLAGS))]>,
1243 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1244 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1245 "cmova\t{$src2, $dst|$dst, $src2}",
1246 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1247 X86_COND_A, EFLAGS))]>,
1249 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1250 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1251 "cmova\t{$src2, $dst|$dst, $src2}",
1252 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1253 X86_COND_A, EFLAGS))]>,
1255 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1256 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1257 "cmovl\t{$src2, $dst|$dst, $src2}",
1258 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1259 X86_COND_L, EFLAGS))]>,
1261 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1262 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1263 "cmovl\t{$src2, $dst|$dst, $src2}",
1264 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1265 X86_COND_L, EFLAGS))]>,
1267 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1268 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1269 "cmovge\t{$src2, $dst|$dst, $src2}",
1270 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1271 X86_COND_GE, EFLAGS))]>,
1273 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1274 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1275 "cmovge\t{$src2, $dst|$dst, $src2}",
1276 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1277 X86_COND_GE, EFLAGS))]>,
1279 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1280 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1281 "cmovle\t{$src2, $dst|$dst, $src2}",
1282 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1283 X86_COND_LE, EFLAGS))]>,
1285 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1286 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1287 "cmovle\t{$src2, $dst|$dst, $src2}",
1288 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1289 X86_COND_LE, EFLAGS))]>,
1291 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1292 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1293 "cmovg\t{$src2, $dst|$dst, $src2}",
1294 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1295 X86_COND_G, EFLAGS))]>,
1297 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1298 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1299 "cmovg\t{$src2, $dst|$dst, $src2}",
1300 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1301 X86_COND_G, EFLAGS))]>,
1303 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1304 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1305 "cmovs\t{$src2, $dst|$dst, $src2}",
1306 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1307 X86_COND_S, EFLAGS))]>,
1309 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1310 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1311 "cmovs\t{$src2, $dst|$dst, $src2}",
1312 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1313 X86_COND_S, EFLAGS))]>,
1315 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1316 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1317 "cmovns\t{$src2, $dst|$dst, $src2}",
1318 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1319 X86_COND_NS, EFLAGS))]>,
1321 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1322 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1323 "cmovns\t{$src2, $dst|$dst, $src2}",
1324 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1325 X86_COND_NS, EFLAGS))]>,
1327 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1328 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1329 "cmovp\t{$src2, $dst|$dst, $src2}",
1330 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1331 X86_COND_P, EFLAGS))]>,
1333 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1334 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1335 "cmovp\t{$src2, $dst|$dst, $src2}",
1336 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1337 X86_COND_P, EFLAGS))]>,
1339 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1340 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1341 "cmovnp\t{$src2, $dst|$dst, $src2}",
1342 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1343 X86_COND_NP, EFLAGS))]>,
1345 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1346 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1347 "cmovnp\t{$src2, $dst|$dst, $src2}",
1348 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1349 X86_COND_NP, EFLAGS))]>,
1351 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1352 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1353 "cmovo\t{$src2, $dst|$dst, $src2}",
1354 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1355 X86_COND_O, EFLAGS))]>,
1357 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1358 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1359 "cmovo\t{$src2, $dst|$dst, $src2}",
1360 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1361 X86_COND_O, EFLAGS))]>,
1363 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1364 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1365 "cmovno\t{$src2, $dst|$dst, $src2}",
1366 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1367 X86_COND_NO, EFLAGS))]>,
1369 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1370 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1371 "cmovno\t{$src2, $dst|$dst, $src2}",
1372 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1373 X86_COND_NO, EFLAGS))]>,
1375 } // Uses = [EFLAGS]
1378 // unary instructions
1379 let CodeSize = 2 in {
1380 let Defs = [EFLAGS] in {
1381 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1382 [(set GR8:$dst, (ineg GR8:$src)),
1383 (implicit EFLAGS)]>;
1384 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1385 [(set GR16:$dst, (ineg GR16:$src)),
1386 (implicit EFLAGS)]>, OpSize;
1387 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1388 [(set GR32:$dst, (ineg GR32:$src)),
1389 (implicit EFLAGS)]>;
1390 let isTwoAddress = 0 in {
1391 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1392 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1393 (implicit EFLAGS)]>;
1394 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1395 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1396 (implicit EFLAGS)]>, OpSize;
1397 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1398 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1399 (implicit EFLAGS)]>;
1401 } // Defs = [EFLAGS]
1403 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1404 let AddedComplexity = 15 in {
1405 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1406 [(set GR8:$dst, (not GR8:$src))]>;
1407 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1408 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1409 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1410 [(set GR32:$dst, (not GR32:$src))]>;
1412 let isTwoAddress = 0 in {
1413 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1414 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1415 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1416 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1417 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1418 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1422 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1423 let Defs = [EFLAGS] in {
1425 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1426 [(set GR8:$dst, (add GR8:$src, 1)),
1427 (implicit EFLAGS)]>;
1428 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1429 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1430 [(set GR16:$dst, (add GR16:$src, 1)),
1431 (implicit EFLAGS)]>,
1432 OpSize, Requires<[In32BitMode]>;
1433 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1434 [(set GR32:$dst, (add GR32:$src, 1)),
1435 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1437 let isTwoAddress = 0, CodeSize = 2 in {
1438 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1439 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1440 (implicit EFLAGS)]>;
1441 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1442 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1443 (implicit EFLAGS)]>,
1444 OpSize, Requires<[In32BitMode]>;
1445 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1446 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1447 (implicit EFLAGS)]>,
1448 Requires<[In32BitMode]>;
1452 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1453 [(set GR8:$dst, (add GR8:$src, -1)),
1454 (implicit EFLAGS)]>;
1455 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1456 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1457 [(set GR16:$dst, (add GR16:$src, -1)),
1458 (implicit EFLAGS)]>,
1459 OpSize, Requires<[In32BitMode]>;
1460 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1461 [(set GR32:$dst, (add GR32:$src, -1)),
1462 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1465 let isTwoAddress = 0, CodeSize = 2 in {
1466 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1467 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1468 (implicit EFLAGS)]>;
1469 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1470 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1471 (implicit EFLAGS)]>,
1472 OpSize, Requires<[In32BitMode]>;
1473 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1474 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1475 (implicit EFLAGS)]>,
1476 Requires<[In32BitMode]>;
1478 } // Defs = [EFLAGS]
1480 // Logical operators...
1481 let Defs = [EFLAGS] in {
1482 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1483 def AND8rr : I<0x20, MRMDestReg,
1484 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1485 "and{b}\t{$src2, $dst|$dst, $src2}",
1486 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1487 (implicit EFLAGS)]>;
1488 def AND16rr : I<0x21, MRMDestReg,
1489 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1490 "and{w}\t{$src2, $dst|$dst, $src2}",
1491 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1492 (implicit EFLAGS)]>, OpSize;
1493 def AND32rr : I<0x21, MRMDestReg,
1494 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1495 "and{l}\t{$src2, $dst|$dst, $src2}",
1496 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1497 (implicit EFLAGS)]>;
1500 def AND8rm : I<0x22, MRMSrcMem,
1501 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1502 "and{b}\t{$src2, $dst|$dst, $src2}",
1503 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1504 (implicit EFLAGS)]>;
1505 def AND16rm : I<0x23, MRMSrcMem,
1506 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1507 "and{w}\t{$src2, $dst|$dst, $src2}",
1508 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1509 (implicit EFLAGS)]>, OpSize;
1510 def AND32rm : I<0x23, MRMSrcMem,
1511 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1512 "and{l}\t{$src2, $dst|$dst, $src2}",
1513 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1514 (implicit EFLAGS)]>;
1516 def AND8ri : Ii8<0x80, MRM4r,
1517 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1518 "and{b}\t{$src2, $dst|$dst, $src2}",
1519 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1520 (implicit EFLAGS)]>;
1521 def AND16ri : Ii16<0x81, MRM4r,
1522 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1523 "and{w}\t{$src2, $dst|$dst, $src2}",
1524 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1525 (implicit EFLAGS)]>, OpSize;
1526 def AND32ri : Ii32<0x81, MRM4r,
1527 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1528 "and{l}\t{$src2, $dst|$dst, $src2}",
1529 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1530 (implicit EFLAGS)]>;
1531 def AND16ri8 : Ii8<0x83, MRM4r,
1532 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1533 "and{w}\t{$src2, $dst|$dst, $src2}",
1534 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1535 (implicit EFLAGS)]>,
1537 def AND32ri8 : Ii8<0x83, MRM4r,
1538 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1539 "and{l}\t{$src2, $dst|$dst, $src2}",
1540 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1541 (implicit EFLAGS)]>;
1543 let isTwoAddress = 0 in {
1544 def AND8mr : I<0x20, MRMDestMem,
1545 (outs), (ins i8mem :$dst, GR8 :$src),
1546 "and{b}\t{$src, $dst|$dst, $src}",
1547 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1548 (implicit EFLAGS)]>;
1549 def AND16mr : I<0x21, MRMDestMem,
1550 (outs), (ins i16mem:$dst, GR16:$src),
1551 "and{w}\t{$src, $dst|$dst, $src}",
1552 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1553 (implicit EFLAGS)]>,
1555 def AND32mr : I<0x21, MRMDestMem,
1556 (outs), (ins i32mem:$dst, GR32:$src),
1557 "and{l}\t{$src, $dst|$dst, $src}",
1558 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1559 (implicit EFLAGS)]>;
1560 def AND8mi : Ii8<0x80, MRM4m,
1561 (outs), (ins i8mem :$dst, i8imm :$src),
1562 "and{b}\t{$src, $dst|$dst, $src}",
1563 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1564 (implicit EFLAGS)]>;
1565 def AND16mi : Ii16<0x81, MRM4m,
1566 (outs), (ins i16mem:$dst, i16imm:$src),
1567 "and{w}\t{$src, $dst|$dst, $src}",
1568 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1569 (implicit EFLAGS)]>,
1571 def AND32mi : Ii32<0x81, MRM4m,
1572 (outs), (ins i32mem:$dst, i32imm:$src),
1573 "and{l}\t{$src, $dst|$dst, $src}",
1574 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1575 (implicit EFLAGS)]>;
1576 def AND16mi8 : Ii8<0x83, MRM4m,
1577 (outs), (ins i16mem:$dst, i16i8imm :$src),
1578 "and{w}\t{$src, $dst|$dst, $src}",
1579 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1580 (implicit EFLAGS)]>,
1582 def AND32mi8 : Ii8<0x83, MRM4m,
1583 (outs), (ins i32mem:$dst, i32i8imm :$src),
1584 "and{l}\t{$src, $dst|$dst, $src}",
1585 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1586 (implicit EFLAGS)]>;
1590 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1591 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1592 "or{b}\t{$src2, $dst|$dst, $src2}",
1593 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1594 (implicit EFLAGS)]>;
1595 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1596 "or{w}\t{$src2, $dst|$dst, $src2}",
1597 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1598 (implicit EFLAGS)]>, OpSize;
1599 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1600 "or{l}\t{$src2, $dst|$dst, $src2}",
1601 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1602 (implicit EFLAGS)]>;
1604 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1605 "or{b}\t{$src2, $dst|$dst, $src2}",
1606 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1607 (implicit EFLAGS)]>;
1608 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1609 "or{w}\t{$src2, $dst|$dst, $src2}",
1610 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1611 (implicit EFLAGS)]>, OpSize;
1612 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1613 "or{l}\t{$src2, $dst|$dst, $src2}",
1614 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1615 (implicit EFLAGS)]>;
1617 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1618 "or{b}\t{$src2, $dst|$dst, $src2}",
1619 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1620 (implicit EFLAGS)]>;
1621 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1622 "or{w}\t{$src2, $dst|$dst, $src2}",
1623 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1624 (implicit EFLAGS)]>, OpSize;
1625 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1626 "or{l}\t{$src2, $dst|$dst, $src2}",
1627 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1628 (implicit EFLAGS)]>;
1630 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1631 "or{w}\t{$src2, $dst|$dst, $src2}",
1632 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1633 (implicit EFLAGS)]>, OpSize;
1634 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1635 "or{l}\t{$src2, $dst|$dst, $src2}",
1636 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1637 (implicit EFLAGS)]>;
1638 let isTwoAddress = 0 in {
1639 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1640 "or{b}\t{$src, $dst|$dst, $src}",
1641 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1642 (implicit EFLAGS)]>;
1643 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1644 "or{w}\t{$src, $dst|$dst, $src}",
1645 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1646 (implicit EFLAGS)]>, OpSize;
1647 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1648 "or{l}\t{$src, $dst|$dst, $src}",
1649 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1650 (implicit EFLAGS)]>;
1651 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1652 "or{b}\t{$src, $dst|$dst, $src}",
1653 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1654 (implicit EFLAGS)]>;
1655 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1656 "or{w}\t{$src, $dst|$dst, $src}",
1657 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1658 (implicit EFLAGS)]>,
1660 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1661 "or{l}\t{$src, $dst|$dst, $src}",
1662 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1663 (implicit EFLAGS)]>;
1664 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1665 "or{w}\t{$src, $dst|$dst, $src}",
1666 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1667 (implicit EFLAGS)]>,
1669 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1670 "or{l}\t{$src, $dst|$dst, $src}",
1671 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1672 (implicit EFLAGS)]>;
1673 } // isTwoAddress = 0
1676 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1677 def XOR8rr : I<0x30, MRMDestReg,
1678 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1679 "xor{b}\t{$src2, $dst|$dst, $src2}",
1680 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1681 (implicit EFLAGS)]>;
1682 def XOR16rr : I<0x31, MRMDestReg,
1683 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1684 "xor{w}\t{$src2, $dst|$dst, $src2}",
1685 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1686 (implicit EFLAGS)]>, OpSize;
1687 def XOR32rr : I<0x31, MRMDestReg,
1688 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1689 "xor{l}\t{$src2, $dst|$dst, $src2}",
1690 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1691 (implicit EFLAGS)]>;
1692 } // isCommutable = 1
1694 def XOR8rm : I<0x32, MRMSrcMem ,
1695 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1696 "xor{b}\t{$src2, $dst|$dst, $src2}",
1697 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1698 (implicit EFLAGS)]>;
1699 def XOR16rm : I<0x33, MRMSrcMem ,
1700 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1701 "xor{w}\t{$src2, $dst|$dst, $src2}",
1702 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1703 (implicit EFLAGS)]>,
1705 def XOR32rm : I<0x33, MRMSrcMem ,
1706 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1707 "xor{l}\t{$src2, $dst|$dst, $src2}",
1708 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1709 (implicit EFLAGS)]>;
1711 def XOR8ri : Ii8<0x80, MRM6r,
1712 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1713 "xor{b}\t{$src2, $dst|$dst, $src2}",
1714 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1715 (implicit EFLAGS)]>;
1716 def XOR16ri : Ii16<0x81, MRM6r,
1717 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1718 "xor{w}\t{$src2, $dst|$dst, $src2}",
1719 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1720 (implicit EFLAGS)]>, OpSize;
1721 def XOR32ri : Ii32<0x81, MRM6r,
1722 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1723 "xor{l}\t{$src2, $dst|$dst, $src2}",
1724 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1725 (implicit EFLAGS)]>;
1726 def XOR16ri8 : Ii8<0x83, MRM6r,
1727 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1728 "xor{w}\t{$src2, $dst|$dst, $src2}",
1729 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1730 (implicit EFLAGS)]>,
1732 def XOR32ri8 : Ii8<0x83, MRM6r,
1733 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1734 "xor{l}\t{$src2, $dst|$dst, $src2}",
1735 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1736 (implicit EFLAGS)]>;
1738 let isTwoAddress = 0 in {
1739 def XOR8mr : I<0x30, MRMDestMem,
1740 (outs), (ins i8mem :$dst, GR8 :$src),
1741 "xor{b}\t{$src, $dst|$dst, $src}",
1742 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1743 (implicit EFLAGS)]>;
1744 def XOR16mr : I<0x31, MRMDestMem,
1745 (outs), (ins i16mem:$dst, GR16:$src),
1746 "xor{w}\t{$src, $dst|$dst, $src}",
1747 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1748 (implicit EFLAGS)]>,
1750 def XOR32mr : I<0x31, MRMDestMem,
1751 (outs), (ins i32mem:$dst, GR32:$src),
1752 "xor{l}\t{$src, $dst|$dst, $src}",
1753 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1754 (implicit EFLAGS)]>;
1755 def XOR8mi : Ii8<0x80, MRM6m,
1756 (outs), (ins i8mem :$dst, i8imm :$src),
1757 "xor{b}\t{$src, $dst|$dst, $src}",
1758 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1759 (implicit EFLAGS)]>;
1760 def XOR16mi : Ii16<0x81, MRM6m,
1761 (outs), (ins i16mem:$dst, i16imm:$src),
1762 "xor{w}\t{$src, $dst|$dst, $src}",
1763 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1764 (implicit EFLAGS)]>,
1766 def XOR32mi : Ii32<0x81, MRM6m,
1767 (outs), (ins i32mem:$dst, i32imm:$src),
1768 "xor{l}\t{$src, $dst|$dst, $src}",
1769 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1770 (implicit EFLAGS)]>;
1771 def XOR16mi8 : Ii8<0x83, MRM6m,
1772 (outs), (ins i16mem:$dst, i16i8imm :$src),
1773 "xor{w}\t{$src, $dst|$dst, $src}",
1774 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1775 (implicit EFLAGS)]>,
1777 def XOR32mi8 : Ii8<0x83, MRM6m,
1778 (outs), (ins i32mem:$dst, i32i8imm :$src),
1779 "xor{l}\t{$src, $dst|$dst, $src}",
1780 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1781 (implicit EFLAGS)]>;
1782 } // isTwoAddress = 0
1783 } // Defs = [EFLAGS]
1785 // Shift instructions
1786 let Defs = [EFLAGS] in {
1787 let Uses = [CL] in {
1788 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1789 "shl{b}\t{%cl, $dst|$dst, CL}",
1790 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1791 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1792 "shl{w}\t{%cl, $dst|$dst, CL}",
1793 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1794 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1795 "shl{l}\t{%cl, $dst|$dst, CL}",
1796 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1799 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1800 "shl{b}\t{$src2, $dst|$dst, $src2}",
1801 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1802 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1803 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1804 "shl{w}\t{$src2, $dst|$dst, $src2}",
1805 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1806 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1807 "shl{l}\t{$src2, $dst|$dst, $src2}",
1808 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1809 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1811 } // isConvertibleToThreeAddress = 1
1813 let isTwoAddress = 0 in {
1814 let Uses = [CL] in {
1815 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1816 "shl{b}\t{%cl, $dst|$dst, CL}",
1817 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1818 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1819 "shl{w}\t{%cl, $dst|$dst, CL}",
1820 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1821 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1822 "shl{l}\t{%cl, $dst|$dst, CL}",
1823 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1825 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1826 "shl{b}\t{$src, $dst|$dst, $src}",
1827 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1828 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1829 "shl{w}\t{$src, $dst|$dst, $src}",
1830 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1832 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1833 "shl{l}\t{$src, $dst|$dst, $src}",
1834 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1837 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1839 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1840 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1842 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1844 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1846 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1849 let Uses = [CL] in {
1850 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1851 "shr{b}\t{%cl, $dst|$dst, CL}",
1852 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1853 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1854 "shr{w}\t{%cl, $dst|$dst, CL}",
1855 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1856 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1857 "shr{l}\t{%cl, $dst|$dst, CL}",
1858 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1861 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1862 "shr{b}\t{$src2, $dst|$dst, $src2}",
1863 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1864 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1865 "shr{w}\t{$src2, $dst|$dst, $src2}",
1866 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1867 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1868 "shr{l}\t{$src2, $dst|$dst, $src2}",
1869 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1872 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1874 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1875 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1877 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1878 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1880 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1882 let isTwoAddress = 0 in {
1883 let Uses = [CL] in {
1884 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1885 "shr{b}\t{%cl, $dst|$dst, CL}",
1886 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1887 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1888 "shr{w}\t{%cl, $dst|$dst, CL}",
1889 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1891 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1892 "shr{l}\t{%cl, $dst|$dst, CL}",
1893 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1895 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1896 "shr{b}\t{$src, $dst|$dst, $src}",
1897 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1898 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1899 "shr{w}\t{$src, $dst|$dst, $src}",
1900 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1902 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1903 "shr{l}\t{$src, $dst|$dst, $src}",
1904 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1907 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1909 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1910 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1912 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1913 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1915 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1918 let Uses = [CL] in {
1919 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1920 "sar{b}\t{%cl, $dst|$dst, CL}",
1921 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1922 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1923 "sar{w}\t{%cl, $dst|$dst, CL}",
1924 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1925 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1926 "sar{l}\t{%cl, $dst|$dst, CL}",
1927 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1930 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1931 "sar{b}\t{$src2, $dst|$dst, $src2}",
1932 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1933 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1934 "sar{w}\t{$src2, $dst|$dst, $src2}",
1935 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1937 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1938 "sar{l}\t{$src2, $dst|$dst, $src2}",
1939 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1942 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1944 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1945 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1947 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1948 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1950 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1952 let isTwoAddress = 0 in {
1953 let Uses = [CL] in {
1954 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1955 "sar{b}\t{%cl, $dst|$dst, CL}",
1956 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1957 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1958 "sar{w}\t{%cl, $dst|$dst, CL}",
1959 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1960 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1961 "sar{l}\t{%cl, $dst|$dst, CL}",
1962 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1964 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1965 "sar{b}\t{$src, $dst|$dst, $src}",
1966 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1967 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1968 "sar{w}\t{$src, $dst|$dst, $src}",
1969 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1971 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1972 "sar{l}\t{$src, $dst|$dst, $src}",
1973 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1976 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1978 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1979 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1981 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1983 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1985 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1988 // Rotate instructions
1989 // FIXME: provide shorter instructions when imm8 == 1
1990 let Uses = [CL] in {
1991 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1992 "rol{b}\t{%cl, $dst|$dst, CL}",
1993 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1994 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1995 "rol{w}\t{%cl, $dst|$dst, CL}",
1996 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1997 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1998 "rol{l}\t{%cl, $dst|$dst, CL}",
1999 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2002 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2003 "rol{b}\t{$src2, $dst|$dst, $src2}",
2004 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
2005 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2006 "rol{w}\t{$src2, $dst|$dst, $src2}",
2007 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2008 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2009 "rol{l}\t{$src2, $dst|$dst, $src2}",
2010 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2013 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
2015 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
2016 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
2018 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
2019 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
2021 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2023 let isTwoAddress = 0 in {
2024 let Uses = [CL] in {
2025 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
2026 "rol{b}\t{%cl, $dst|$dst, CL}",
2027 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
2028 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
2029 "rol{w}\t{%cl, $dst|$dst, CL}",
2030 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2031 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
2032 "rol{l}\t{%cl, $dst|$dst, CL}",
2033 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2035 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
2036 "rol{b}\t{$src, $dst|$dst, $src}",
2037 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2038 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
2039 "rol{w}\t{$src, $dst|$dst, $src}",
2040 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2042 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
2043 "rol{l}\t{$src, $dst|$dst, $src}",
2044 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2047 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
2049 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2050 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
2052 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2054 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
2056 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2059 let Uses = [CL] in {
2060 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
2061 "ror{b}\t{%cl, $dst|$dst, CL}",
2062 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
2063 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
2064 "ror{w}\t{%cl, $dst|$dst, CL}",
2065 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2066 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2067 "ror{l}\t{%cl, $dst|$dst, CL}",
2068 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2071 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2072 "ror{b}\t{$src2, $dst|$dst, $src2}",
2073 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2074 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2075 "ror{w}\t{$src2, $dst|$dst, $src2}",
2076 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2077 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2078 "ror{l}\t{$src2, $dst|$dst, $src2}",
2079 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2082 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2084 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2085 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2087 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2088 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2090 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2092 let isTwoAddress = 0 in {
2093 let Uses = [CL] in {
2094 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2095 "ror{b}\t{%cl, $dst|$dst, CL}",
2096 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2097 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2098 "ror{w}\t{%cl, $dst|$dst, CL}",
2099 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2100 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2101 "ror{l}\t{%cl, $dst|$dst, CL}",
2102 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2104 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2105 "ror{b}\t{$src, $dst|$dst, $src}",
2106 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2107 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2108 "ror{w}\t{$src, $dst|$dst, $src}",
2109 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2111 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2112 "ror{l}\t{$src, $dst|$dst, $src}",
2113 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2116 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2118 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2119 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2121 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2123 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2125 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2130 // Double shift instructions (generalizations of rotate)
2131 let Uses = [CL] in {
2132 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2133 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2134 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2135 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2136 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2137 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2138 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2139 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2140 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2142 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2143 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2144 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2148 let isCommutable = 1 in { // These instructions commute to each other.
2149 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2150 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2151 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2152 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2155 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2156 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2157 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2158 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2161 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2162 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2163 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2164 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2167 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2168 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2169 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2170 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2175 let isTwoAddress = 0 in {
2176 let Uses = [CL] in {
2177 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2178 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2179 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2181 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2182 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2183 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2186 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2187 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2188 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2189 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2190 (i8 imm:$src3)), addr:$dst)]>,
2192 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2193 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2194 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2195 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2196 (i8 imm:$src3)), addr:$dst)]>,
2199 let Uses = [CL] in {
2200 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2201 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2202 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2203 addr:$dst)]>, TB, OpSize;
2204 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2205 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
2206 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2207 addr:$dst)]>, TB, OpSize;
2209 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2210 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2211 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2212 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2213 (i8 imm:$src3)), addr:$dst)]>,
2215 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2216 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2217 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2218 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2219 (i8 imm:$src3)), addr:$dst)]>,
2222 } // Defs = [EFLAGS]
2226 let Defs = [EFLAGS] in {
2227 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2228 // Register-Register Addition
2229 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2230 (ins GR8 :$src1, GR8 :$src2),
2231 "add{b}\t{$src2, $dst|$dst, $src2}",
2232 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2233 (implicit EFLAGS)]>;
2235 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2236 // Register-Register Addition
2237 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2238 (ins GR16:$src1, GR16:$src2),
2239 "add{w}\t{$src2, $dst|$dst, $src2}",
2240 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2241 (implicit EFLAGS)]>, OpSize;
2242 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2243 (ins GR32:$src1, GR32:$src2),
2244 "add{l}\t{$src2, $dst|$dst, $src2}",
2245 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2246 (implicit EFLAGS)]>;
2247 } // end isConvertibleToThreeAddress
2248 } // end isCommutable
2250 // Register-Memory Addition
2251 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2252 (ins GR8 :$src1, i8mem :$src2),
2253 "add{b}\t{$src2, $dst|$dst, $src2}",
2254 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2255 (implicit EFLAGS)]>;
2256 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2257 (ins GR16:$src1, i16mem:$src2),
2258 "add{w}\t{$src2, $dst|$dst, $src2}",
2259 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2260 (implicit EFLAGS)]>, OpSize;
2261 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2262 (ins GR32:$src1, i32mem:$src2),
2263 "add{l}\t{$src2, $dst|$dst, $src2}",
2264 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2265 (implicit EFLAGS)]>;
2267 // Register-Integer Addition
2268 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2269 "add{b}\t{$src2, $dst|$dst, $src2}",
2270 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2271 (implicit EFLAGS)]>;
2273 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2274 // Register-Integer Addition
2275 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2276 (ins GR16:$src1, i16imm:$src2),
2277 "add{w}\t{$src2, $dst|$dst, $src2}",
2278 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2279 (implicit EFLAGS)]>, OpSize;
2280 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2281 (ins GR32:$src1, i32imm:$src2),
2282 "add{l}\t{$src2, $dst|$dst, $src2}",
2283 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2284 (implicit EFLAGS)]>;
2285 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2286 (ins GR16:$src1, i16i8imm:$src2),
2287 "add{w}\t{$src2, $dst|$dst, $src2}",
2288 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2289 (implicit EFLAGS)]>, OpSize;
2290 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2291 (ins GR32:$src1, i32i8imm:$src2),
2292 "add{l}\t{$src2, $dst|$dst, $src2}",
2293 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2294 (implicit EFLAGS)]>;
2297 let isTwoAddress = 0 in {
2298 // Memory-Register Addition
2299 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2300 "add{b}\t{$src2, $dst|$dst, $src2}",
2301 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2302 (implicit EFLAGS)]>;
2303 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2304 "add{w}\t{$src2, $dst|$dst, $src2}",
2305 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2306 (implicit EFLAGS)]>, OpSize;
2307 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2308 "add{l}\t{$src2, $dst|$dst, $src2}",
2309 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2310 (implicit EFLAGS)]>;
2311 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2312 "add{b}\t{$src2, $dst|$dst, $src2}",
2313 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2314 (implicit EFLAGS)]>;
2315 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2316 "add{w}\t{$src2, $dst|$dst, $src2}",
2317 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2318 (implicit EFLAGS)]>, OpSize;
2319 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2320 "add{l}\t{$src2, $dst|$dst, $src2}",
2321 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2322 (implicit EFLAGS)]>;
2323 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2324 "add{w}\t{$src2, $dst|$dst, $src2}",
2325 [(store (add (load addr:$dst), i16immSExt8:$src2),
2327 (implicit EFLAGS)]>, OpSize;
2328 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2329 "add{l}\t{$src2, $dst|$dst, $src2}",
2330 [(store (add (load addr:$dst), i32immSExt8:$src2),
2332 (implicit EFLAGS)]>;
2335 let Uses = [EFLAGS] in {
2336 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2337 def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2338 "adc{b}\t{$src2, $dst|$dst, $src2}",
2339 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
2340 def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2341 (ins GR16:$src1, GR16:$src2),
2342 "adc{w}\t{$src2, $dst|$dst, $src2}",
2343 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
2344 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2345 (ins GR32:$src1, GR32:$src2),
2346 "adc{l}\t{$src2, $dst|$dst, $src2}",
2347 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2349 def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2350 (ins GR8:$src1, i8mem:$src2),
2351 "adc{b}\t{$src2, $dst|$dst, $src2}",
2352 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
2353 def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2354 (ins GR16:$src1, i16mem:$src2),
2355 "adc{w}\t{$src2, $dst|$dst, $src2}",
2356 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
2358 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2359 (ins GR32:$src1, i32mem:$src2),
2360 "adc{l}\t{$src2, $dst|$dst, $src2}",
2361 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2362 def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2363 "adc{b}\t{$src2, $dst|$dst, $src2}",
2364 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
2365 def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2366 (ins GR16:$src1, i16imm:$src2),
2367 "adc{w}\t{$src2, $dst|$dst, $src2}",
2368 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
2369 def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2370 (ins GR16:$src1, i16i8imm:$src2),
2371 "adc{w}\t{$src2, $dst|$dst, $src2}",
2372 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2374 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2375 (ins GR32:$src1, i32imm:$src2),
2376 "adc{l}\t{$src2, $dst|$dst, $src2}",
2377 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2378 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2379 (ins GR32:$src1, i32i8imm:$src2),
2380 "adc{l}\t{$src2, $dst|$dst, $src2}",
2381 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2383 let isTwoAddress = 0 in {
2384 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2385 "adc{b}\t{$src2, $dst|$dst, $src2}",
2386 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2387 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2388 "adc{w}\t{$src2, $dst|$dst, $src2}",
2389 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2391 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2392 "adc{l}\t{$src2, $dst|$dst, $src2}",
2393 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2394 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
2395 "adc{b}\t{$src2, $dst|$dst, $src2}",
2396 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2397 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
2398 "adc{w}\t{$src2, $dst|$dst, $src2}",
2399 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2401 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2402 "adc{w}\t{$src2, $dst|$dst, $src2}",
2403 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2405 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2406 "adc{l}\t{$src2, $dst|$dst, $src2}",
2407 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2408 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2409 "adc{l}\t{$src2, $dst|$dst, $src2}",
2410 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2412 } // Uses = [EFLAGS]
2414 // Register-Register Subtraction
2415 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2416 "sub{b}\t{$src2, $dst|$dst, $src2}",
2417 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2418 (implicit EFLAGS)]>;
2419 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2420 "sub{w}\t{$src2, $dst|$dst, $src2}",
2421 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2422 (implicit EFLAGS)]>, OpSize;
2423 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2424 "sub{l}\t{$src2, $dst|$dst, $src2}",
2425 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2426 (implicit EFLAGS)]>;
2428 // Register-Memory Subtraction
2429 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2430 (ins GR8 :$src1, i8mem :$src2),
2431 "sub{b}\t{$src2, $dst|$dst, $src2}",
2432 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2433 (implicit EFLAGS)]>;
2434 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2435 (ins GR16:$src1, i16mem:$src2),
2436 "sub{w}\t{$src2, $dst|$dst, $src2}",
2437 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2438 (implicit EFLAGS)]>, OpSize;
2439 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2440 (ins GR32:$src1, i32mem:$src2),
2441 "sub{l}\t{$src2, $dst|$dst, $src2}",
2442 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2443 (implicit EFLAGS)]>;
2445 // Register-Integer Subtraction
2446 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2447 (ins GR8:$src1, i8imm:$src2),
2448 "sub{b}\t{$src2, $dst|$dst, $src2}",
2449 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2450 (implicit EFLAGS)]>;
2451 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2452 (ins GR16:$src1, i16imm:$src2),
2453 "sub{w}\t{$src2, $dst|$dst, $src2}",
2454 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2455 (implicit EFLAGS)]>, OpSize;
2456 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2457 (ins GR32:$src1, i32imm:$src2),
2458 "sub{l}\t{$src2, $dst|$dst, $src2}",
2459 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2460 (implicit EFLAGS)]>;
2461 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2462 (ins GR16:$src1, i16i8imm:$src2),
2463 "sub{w}\t{$src2, $dst|$dst, $src2}",
2464 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2465 (implicit EFLAGS)]>, OpSize;
2466 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2467 (ins GR32:$src1, i32i8imm:$src2),
2468 "sub{l}\t{$src2, $dst|$dst, $src2}",
2469 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2470 (implicit EFLAGS)]>;
2472 let isTwoAddress = 0 in {
2473 // Memory-Register Subtraction
2474 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2475 "sub{b}\t{$src2, $dst|$dst, $src2}",
2476 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2477 (implicit EFLAGS)]>;
2478 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2479 "sub{w}\t{$src2, $dst|$dst, $src2}",
2480 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2481 (implicit EFLAGS)]>, OpSize;
2482 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2483 "sub{l}\t{$src2, $dst|$dst, $src2}",
2484 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2485 (implicit EFLAGS)]>;
2487 // Memory-Integer Subtraction
2488 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2489 "sub{b}\t{$src2, $dst|$dst, $src2}",
2490 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2491 (implicit EFLAGS)]>;
2492 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2493 "sub{w}\t{$src2, $dst|$dst, $src2}",
2494 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2495 (implicit EFLAGS)]>, OpSize;
2496 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2497 "sub{l}\t{$src2, $dst|$dst, $src2}",
2498 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2499 (implicit EFLAGS)]>;
2500 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2501 "sub{w}\t{$src2, $dst|$dst, $src2}",
2502 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2504 (implicit EFLAGS)]>, OpSize;
2505 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2506 "sub{l}\t{$src2, $dst|$dst, $src2}",
2507 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2509 (implicit EFLAGS)]>;
2512 let Uses = [EFLAGS] in {
2513 def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2514 (ins GR8:$src1, GR8:$src2),
2515 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2516 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
2517 def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2518 (ins GR16:$src1, GR16:$src2),
2519 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2520 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
2521 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2522 (ins GR32:$src1, GR32:$src2),
2523 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2524 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2526 let isTwoAddress = 0 in {
2527 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2528 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2529 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
2530 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2531 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2532 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
2534 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2535 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2536 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2537 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2538 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2539 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2540 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2541 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2542 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2544 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2545 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2546 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2548 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2549 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2550 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2551 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2552 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2553 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2555 def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2556 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2557 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
2558 def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2559 (ins GR16:$src1, i16mem:$src2),
2560 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2561 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
2563 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2564 (ins GR32:$src1, i32mem:$src2),
2565 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2566 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2567 def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2568 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2569 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
2570 def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2571 (ins GR16:$src1, i16imm:$src2),
2572 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2573 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
2574 def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2575 (ins GR16:$src1, i16i8imm:$src2),
2576 "sbb{w}\t{$src2, $dst|$dst, $src2}",
2577 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2579 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2580 (ins GR32:$src1, i32imm:$src2),
2581 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2582 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2583 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2584 (ins GR32:$src1, i32i8imm:$src2),
2585 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2586 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2587 } // Uses = [EFLAGS]
2588 } // Defs = [EFLAGS]
2590 let Defs = [EFLAGS] in {
2591 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2592 // Register-Register Signed Integer Multiply
2593 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2594 "imul{w}\t{$src2, $dst|$dst, $src2}",
2595 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2596 (implicit EFLAGS)]>, TB, OpSize;
2597 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2598 "imul{l}\t{$src2, $dst|$dst, $src2}",
2599 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2600 (implicit EFLAGS)]>, TB;
2603 // Register-Memory Signed Integer Multiply
2604 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2605 (ins GR16:$src1, i16mem:$src2),
2606 "imul{w}\t{$src2, $dst|$dst, $src2}",
2607 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2608 (implicit EFLAGS)]>, TB, OpSize;
2609 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2610 "imul{l}\t{$src2, $dst|$dst, $src2}",
2611 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2612 (implicit EFLAGS)]>, TB;
2613 } // Defs = [EFLAGS]
2614 } // end Two Address instructions
2616 // Suprisingly enough, these are not two address instructions!
2617 let Defs = [EFLAGS] in {
2618 // Register-Integer Signed Integer Multiply
2619 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2620 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2621 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2622 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2623 (implicit EFLAGS)]>, OpSize;
2624 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2625 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2626 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2627 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2628 (implicit EFLAGS)]>;
2629 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2630 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2631 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2632 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2633 (implicit EFLAGS)]>, OpSize;
2634 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2635 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2636 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2637 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2638 (implicit EFLAGS)]>;
2640 // Memory-Integer Signed Integer Multiply
2641 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2642 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2643 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2644 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2645 (implicit EFLAGS)]>, OpSize;
2646 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2647 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2648 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2649 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2650 (implicit EFLAGS)]>;
2651 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2652 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2653 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2654 [(set GR16:$dst, (mul (load addr:$src1),
2655 i16immSExt8:$src2)),
2656 (implicit EFLAGS)]>, OpSize;
2657 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2658 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2659 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2660 [(set GR32:$dst, (mul (load addr:$src1),
2661 i32immSExt8:$src2)),
2662 (implicit EFLAGS)]>;
2663 } // Defs = [EFLAGS]
2665 //===----------------------------------------------------------------------===//
2666 // Test instructions are just like AND, except they don't generate a result.
2668 let Defs = [EFLAGS] in {
2669 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2670 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2671 "test{b}\t{$src2, $src1|$src1, $src2}",
2672 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2673 (implicit EFLAGS)]>;
2674 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2675 "test{w}\t{$src2, $src1|$src1, $src2}",
2676 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2677 (implicit EFLAGS)]>,
2679 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2680 "test{l}\t{$src2, $src1|$src1, $src2}",
2681 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2682 (implicit EFLAGS)]>;
2685 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2686 "test{b}\t{$src2, $src1|$src1, $src2}",
2687 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2688 (implicit EFLAGS)]>;
2689 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2690 "test{w}\t{$src2, $src1|$src1, $src2}",
2691 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2692 (implicit EFLAGS)]>, OpSize;
2693 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2694 "test{l}\t{$src2, $src1|$src1, $src2}",
2695 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2696 (implicit EFLAGS)]>;
2698 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2699 (outs), (ins GR8:$src1, i8imm:$src2),
2700 "test{b}\t{$src2, $src1|$src1, $src2}",
2701 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2702 (implicit EFLAGS)]>;
2703 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2704 (outs), (ins GR16:$src1, i16imm:$src2),
2705 "test{w}\t{$src2, $src1|$src1, $src2}",
2706 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2707 (implicit EFLAGS)]>, OpSize;
2708 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2709 (outs), (ins GR32:$src1, i32imm:$src2),
2710 "test{l}\t{$src2, $src1|$src1, $src2}",
2711 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2712 (implicit EFLAGS)]>;
2714 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2715 (outs), (ins i8mem:$src1, i8imm:$src2),
2716 "test{b}\t{$src2, $src1|$src1, $src2}",
2717 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2718 (implicit EFLAGS)]>;
2719 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2720 (outs), (ins i16mem:$src1, i16imm:$src2),
2721 "test{w}\t{$src2, $src1|$src1, $src2}",
2722 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2723 (implicit EFLAGS)]>, OpSize;
2724 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2725 (outs), (ins i32mem:$src1, i32imm:$src2),
2726 "test{l}\t{$src2, $src1|$src1, $src2}",
2727 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2728 (implicit EFLAGS)]>;
2729 } // Defs = [EFLAGS]
2732 // Condition code ops, incl. set if equal/not equal/...
2733 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2734 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2735 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2736 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2738 let Uses = [EFLAGS] in {
2739 def SETEr : I<0x94, MRM0r,
2740 (outs GR8 :$dst), (ins),
2742 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2744 def SETEm : I<0x94, MRM0m,
2745 (outs), (ins i8mem:$dst),
2747 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2750 def SETNEr : I<0x95, MRM0r,
2751 (outs GR8 :$dst), (ins),
2753 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2755 def SETNEm : I<0x95, MRM0m,
2756 (outs), (ins i8mem:$dst),
2758 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2761 def SETLr : I<0x9C, MRM0r,
2762 (outs GR8 :$dst), (ins),
2764 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2765 TB; // GR8 = < signed
2766 def SETLm : I<0x9C, MRM0m,
2767 (outs), (ins i8mem:$dst),
2769 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2770 TB; // [mem8] = < signed
2772 def SETGEr : I<0x9D, MRM0r,
2773 (outs GR8 :$dst), (ins),
2775 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2776 TB; // GR8 = >= signed
2777 def SETGEm : I<0x9D, MRM0m,
2778 (outs), (ins i8mem:$dst),
2780 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2781 TB; // [mem8] = >= signed
2783 def SETLEr : I<0x9E, MRM0r,
2784 (outs GR8 :$dst), (ins),
2786 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2787 TB; // GR8 = <= signed
2788 def SETLEm : I<0x9E, MRM0m,
2789 (outs), (ins i8mem:$dst),
2791 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2792 TB; // [mem8] = <= signed
2794 def SETGr : I<0x9F, MRM0r,
2795 (outs GR8 :$dst), (ins),
2797 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2798 TB; // GR8 = > signed
2799 def SETGm : I<0x9F, MRM0m,
2800 (outs), (ins i8mem:$dst),
2802 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2803 TB; // [mem8] = > signed
2805 def SETBr : I<0x92, MRM0r,
2806 (outs GR8 :$dst), (ins),
2808 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2809 TB; // GR8 = < unsign
2810 def SETBm : I<0x92, MRM0m,
2811 (outs), (ins i8mem:$dst),
2813 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2814 TB; // [mem8] = < unsign
2816 def SETAEr : I<0x93, MRM0r,
2817 (outs GR8 :$dst), (ins),
2819 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2820 TB; // GR8 = >= unsign
2821 def SETAEm : I<0x93, MRM0m,
2822 (outs), (ins i8mem:$dst),
2824 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2825 TB; // [mem8] = >= unsign
2827 def SETBEr : I<0x96, MRM0r,
2828 (outs GR8 :$dst), (ins),
2830 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2831 TB; // GR8 = <= unsign
2832 def SETBEm : I<0x96, MRM0m,
2833 (outs), (ins i8mem:$dst),
2835 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2836 TB; // [mem8] = <= unsign
2838 def SETAr : I<0x97, MRM0r,
2839 (outs GR8 :$dst), (ins),
2841 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2842 TB; // GR8 = > signed
2843 def SETAm : I<0x97, MRM0m,
2844 (outs), (ins i8mem:$dst),
2846 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2847 TB; // [mem8] = > signed
2849 def SETSr : I<0x98, MRM0r,
2850 (outs GR8 :$dst), (ins),
2852 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2853 TB; // GR8 = <sign bit>
2854 def SETSm : I<0x98, MRM0m,
2855 (outs), (ins i8mem:$dst),
2857 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2858 TB; // [mem8] = <sign bit>
2859 def SETNSr : I<0x99, MRM0r,
2860 (outs GR8 :$dst), (ins),
2862 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2863 TB; // GR8 = !<sign bit>
2864 def SETNSm : I<0x99, MRM0m,
2865 (outs), (ins i8mem:$dst),
2867 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2868 TB; // [mem8] = !<sign bit>
2870 def SETPr : I<0x9A, MRM0r,
2871 (outs GR8 :$dst), (ins),
2873 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2875 def SETPm : I<0x9A, MRM0m,
2876 (outs), (ins i8mem:$dst),
2878 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2879 TB; // [mem8] = parity
2880 def SETNPr : I<0x9B, MRM0r,
2881 (outs GR8 :$dst), (ins),
2883 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2884 TB; // GR8 = not parity
2885 def SETNPm : I<0x9B, MRM0m,
2886 (outs), (ins i8mem:$dst),
2888 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2889 TB; // [mem8] = not parity
2891 def SETOr : I<0x90, MRM0r,
2892 (outs GR8 :$dst), (ins),
2894 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2895 TB; // GR8 = overflow
2896 def SETOm : I<0x90, MRM0m,
2897 (outs), (ins i8mem:$dst),
2899 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2900 TB; // [mem8] = overflow
2901 def SETNOr : I<0x91, MRM0r,
2902 (outs GR8 :$dst), (ins),
2904 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2905 TB; // GR8 = not overflow
2906 def SETNOm : I<0x91, MRM0m,
2907 (outs), (ins i8mem:$dst),
2909 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2910 TB; // [mem8] = not overflow
2911 } // Uses = [EFLAGS]
2914 // Integer comparisons
2915 let Defs = [EFLAGS] in {
2916 def CMP8rr : I<0x38, MRMDestReg,
2917 (outs), (ins GR8 :$src1, GR8 :$src2),
2918 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2919 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2920 def CMP16rr : I<0x39, MRMDestReg,
2921 (outs), (ins GR16:$src1, GR16:$src2),
2922 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2923 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2924 def CMP32rr : I<0x39, MRMDestReg,
2925 (outs), (ins GR32:$src1, GR32:$src2),
2926 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2927 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2928 def CMP8mr : I<0x38, MRMDestMem,
2929 (outs), (ins i8mem :$src1, GR8 :$src2),
2930 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2931 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2932 (implicit EFLAGS)]>;
2933 def CMP16mr : I<0x39, MRMDestMem,
2934 (outs), (ins i16mem:$src1, GR16:$src2),
2935 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2936 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2937 (implicit EFLAGS)]>, OpSize;
2938 def CMP32mr : I<0x39, MRMDestMem,
2939 (outs), (ins i32mem:$src1, GR32:$src2),
2940 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2941 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2942 (implicit EFLAGS)]>;
2943 def CMP8rm : I<0x3A, MRMSrcMem,
2944 (outs), (ins GR8 :$src1, i8mem :$src2),
2945 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2946 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2947 (implicit EFLAGS)]>;
2948 def CMP16rm : I<0x3B, MRMSrcMem,
2949 (outs), (ins GR16:$src1, i16mem:$src2),
2950 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2951 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2952 (implicit EFLAGS)]>, OpSize;
2953 def CMP32rm : I<0x3B, MRMSrcMem,
2954 (outs), (ins GR32:$src1, i32mem:$src2),
2955 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2956 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2957 (implicit EFLAGS)]>;
2958 def CMP8ri : Ii8<0x80, MRM7r,
2959 (outs), (ins GR8:$src1, i8imm:$src2),
2960 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2961 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
2962 def CMP16ri : Ii16<0x81, MRM7r,
2963 (outs), (ins GR16:$src1, i16imm:$src2),
2964 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2965 [(X86cmp GR16:$src1, imm:$src2),
2966 (implicit EFLAGS)]>, OpSize;
2967 def CMP32ri : Ii32<0x81, MRM7r,
2968 (outs), (ins GR32:$src1, i32imm:$src2),
2969 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2970 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
2971 def CMP8mi : Ii8 <0x80, MRM7m,
2972 (outs), (ins i8mem :$src1, i8imm :$src2),
2973 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2974 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2975 (implicit EFLAGS)]>;
2976 def CMP16mi : Ii16<0x81, MRM7m,
2977 (outs), (ins i16mem:$src1, i16imm:$src2),
2978 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2979 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2980 (implicit EFLAGS)]>, OpSize;
2981 def CMP32mi : Ii32<0x81, MRM7m,
2982 (outs), (ins i32mem:$src1, i32imm:$src2),
2983 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2984 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2985 (implicit EFLAGS)]>;
2986 def CMP16ri8 : Ii8<0x83, MRM7r,
2987 (outs), (ins GR16:$src1, i16i8imm:$src2),
2988 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2989 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2990 (implicit EFLAGS)]>, OpSize;
2991 def CMP16mi8 : Ii8<0x83, MRM7m,
2992 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2993 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2994 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2995 (implicit EFLAGS)]>, OpSize;
2996 def CMP32mi8 : Ii8<0x83, MRM7m,
2997 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2998 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2999 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3000 (implicit EFLAGS)]>;
3001 def CMP32ri8 : Ii8<0x83, MRM7r,
3002 (outs), (ins GR32:$src1, i32i8imm:$src2),
3003 "cmp{l}\t{$src2, $src1|$src1, $src2}",
3004 [(X86cmp GR32:$src1, i32immSExt8:$src2),
3005 (implicit EFLAGS)]>;
3006 } // Defs = [EFLAGS]
3009 // TODO: BTC, BTR, and BTS
3010 let Defs = [EFLAGS] in {
3011 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
3012 "bt{w}\t{$src2, $src1|$src1, $src2}",
3013 [(X86bt GR16:$src1, GR16:$src2),
3014 (implicit EFLAGS)]>, OpSize, TB;
3015 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
3016 "bt{l}\t{$src2, $src1|$src1, $src2}",
3017 [(X86bt GR32:$src1, GR32:$src2),
3018 (implicit EFLAGS)]>, TB;
3020 // Unlike with the register+register form, the memory+register form of the
3021 // bt instruction does not ignore the high bits of the index. From ISel's
3022 // perspective, this is pretty bizarre. Disable these instructions for now.
3023 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3024 // "bt{w}\t{$src2, $src1|$src1, $src2}",
3025 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
3026 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3027 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3028 // "bt{l}\t{$src2, $src1|$src1, $src2}",
3029 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
3030 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
3032 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3033 "bt{w}\t{$src2, $src1|$src1, $src2}",
3034 [(X86bt GR16:$src1, i16immSExt8:$src2),
3035 (implicit EFLAGS)]>, OpSize, TB;
3036 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3037 "bt{l}\t{$src2, $src1|$src1, $src2}",
3038 [(X86bt GR32:$src1, i32immSExt8:$src2),
3039 (implicit EFLAGS)]>, TB;
3040 // Note that these instructions don't need FastBTMem because that
3041 // only applies when the other operand is in a register. When it's
3042 // an immediate, bt is still fast.
3043 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3044 "bt{w}\t{$src2, $src1|$src1, $src2}",
3045 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3046 (implicit EFLAGS)]>, OpSize, TB;
3047 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3048 "bt{l}\t{$src2, $src1|$src1, $src2}",
3049 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3050 (implicit EFLAGS)]>, TB;
3051 } // Defs = [EFLAGS]
3053 // Sign/Zero extenders
3054 // Use movsbl intead of movsbw; we don't care about the high 16 bits
3055 // of the register here. This has a smaller encoding and avoids a
3056 // partial-register update.
3057 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3058 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3059 [(set GR16:$dst, (sext GR8:$src))]>, TB;
3060 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3061 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3062 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
3063 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3064 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3065 [(set GR32:$dst, (sext GR8:$src))]>, TB;
3066 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3067 "movs{bl|x}\t{$src, $dst|$dst, $src}",
3068 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
3069 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3070 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3071 [(set GR32:$dst, (sext GR16:$src))]>, TB;
3072 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3073 "movs{wl|x}\t{$src, $dst|$dst, $src}",
3074 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3076 // Use movzbl intead of movzbw; we don't care about the high 16 bits
3077 // of the register here. This has a smaller encoding and avoids a
3078 // partial-register update.
3079 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
3080 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3081 [(set GR16:$dst, (zext GR8:$src))]>, TB;
3082 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
3083 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3084 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
3085 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
3086 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3087 [(set GR32:$dst, (zext GR8:$src))]>, TB;
3088 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
3089 "movz{bl|x}\t{$src, $dst|$dst, $src}",
3090 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
3091 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
3092 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3093 [(set GR32:$dst, (zext GR16:$src))]>, TB;
3094 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
3095 "movz{wl|x}\t{$src, $dst|$dst, $src}",
3096 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3098 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3099 // except that they use GR32_NOREX for the output operand register class
3100 // instead of GR32. This allows them to operate on h registers on x86-64.
3101 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3102 (outs GR32_NOREX:$dst), (ins GR8:$src),
3103 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3106 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3107 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3108 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3111 let neverHasSideEffects = 1 in {
3112 let Defs = [AX], Uses = [AL] in
3113 def CBW : I<0x98, RawFrm, (outs), (ins),
3114 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3115 let Defs = [EAX], Uses = [AX] in
3116 def CWDE : I<0x98, RawFrm, (outs), (ins),
3117 "{cwtl|cwde}", []>; // EAX = signext(AX)
3119 let Defs = [AX,DX], Uses = [AX] in
3120 def CWD : I<0x99, RawFrm, (outs), (ins),
3121 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3122 let Defs = [EAX,EDX], Uses = [EAX] in
3123 def CDQ : I<0x99, RawFrm, (outs), (ins),
3124 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3127 //===----------------------------------------------------------------------===//
3128 // Alias Instructions
3129 //===----------------------------------------------------------------------===//
3131 // Alias instructions that map movr0 to xor.
3132 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
3133 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
3134 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
3135 "xor{b}\t$dst, $dst",
3136 [(set GR8:$dst, 0)]>;
3137 // Use xorl instead of xorw since we don't care about the high 16 bits,
3138 // it's smaller, and it avoids a partial-register update.
3139 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
3140 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3141 [(set GR16:$dst, 0)]>;
3142 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
3143 "xor{l}\t$dst, $dst",
3144 [(set GR32:$dst, 0)]>;
3147 //===----------------------------------------------------------------------===//
3148 // Thread Local Storage Instructions
3151 // All calls clobber the non-callee saved registers. ESP is marked as
3152 // a use to prevent stack-pointer assignments that appear immediately
3153 // before calls from potentially appearing dead.
3154 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3155 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3156 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3157 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3159 def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3160 "leal\t$sym, %eax; "
3161 "call\t___tls_get_addr@PLT",
3162 [(X86tlsaddr tls32addr:$sym)]>,
3163 Requires<[In32BitMode]>;
3165 let AddedComplexity = 5 in
3166 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3167 "movl\t%gs:$src, $dst",
3168 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3170 let AddedComplexity = 5 in
3171 def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3172 "movl\t%fs:$src, $dst",
3173 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3175 //===----------------------------------------------------------------------===//
3176 // DWARF Pseudo Instructions
3179 def DWARF_LOC : I<0, Pseudo, (outs),
3180 (ins i32imm:$line, i32imm:$col, i32imm:$file),
3181 ".loc\t$file $line $col",
3182 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3185 //===----------------------------------------------------------------------===//
3186 // EH Pseudo Instructions
3188 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3190 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3191 "ret\t#eh_return, addr: $addr",
3192 [(X86ehret GR32:$addr)]>;
3196 //===----------------------------------------------------------------------===//
3200 // Atomic swap. These are just normal xchg instructions. But since a memory
3201 // operand is referenced, the atomicity is ensured.
3202 let Constraints = "$val = $dst" in {
3203 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3204 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3205 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3206 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3207 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3208 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3210 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3211 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3212 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3215 // Atomic compare and swap.
3216 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3217 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3219 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3220 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3222 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3223 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3226 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3229 let Defs = [AX, EFLAGS], Uses = [AX] in {
3230 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3232 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3233 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3235 let Defs = [AL, EFLAGS], Uses = [AL] in {
3236 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3238 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3239 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3242 // Atomic exchange and add
3243 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3244 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3246 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3247 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3249 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3251 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3252 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3254 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3256 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3257 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3261 // Optimized codegen when the non-memory output is not used.
3262 // FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3263 def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3265 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3266 def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3268 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3269 def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3271 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3272 def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3274 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3275 def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3277 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3278 def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3280 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3281 def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3283 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3284 def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3286 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3288 def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3290 "inc{b}\t$dst", []>, LOCK;
3291 def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3293 "inc{w}\t$dst", []>, OpSize, LOCK;
3294 def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3296 "inc{l}\t$dst", []>, LOCK;
3298 def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3300 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3301 def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3303 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3304 def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3306 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3307 def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3309 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3310 def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3312 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3313 def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3315 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3316 def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3318 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3319 def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3321 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3323 def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3325 "dec{b}\t$dst", []>, LOCK;
3326 def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3328 "dec{w}\t$dst", []>, OpSize, LOCK;
3329 def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3331 "dec{l}\t$dst", []>, LOCK;
3333 // Atomic exchange, and, or, xor
3334 let Constraints = "$val = $dst", Defs = [EFLAGS],
3335 usesCustomDAGSchedInserter = 1 in {
3336 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3337 "#ATOMAND32 PSEUDO!",
3338 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3339 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3340 "#ATOMOR32 PSEUDO!",
3341 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3342 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3343 "#ATOMXOR32 PSEUDO!",
3344 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3345 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3346 "#ATOMNAND32 PSEUDO!",
3347 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3348 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3349 "#ATOMMIN32 PSEUDO!",
3350 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3351 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3352 "#ATOMMAX32 PSEUDO!",
3353 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3354 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3355 "#ATOMUMIN32 PSEUDO!",
3356 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3357 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3358 "#ATOMUMAX32 PSEUDO!",
3359 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3361 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3362 "#ATOMAND16 PSEUDO!",
3363 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3364 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3365 "#ATOMOR16 PSEUDO!",
3366 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3367 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3368 "#ATOMXOR16 PSEUDO!",
3369 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3370 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3371 "#ATOMNAND16 PSEUDO!",
3372 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3373 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3374 "#ATOMMIN16 PSEUDO!",
3375 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3376 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3377 "#ATOMMAX16 PSEUDO!",
3378 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3379 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3380 "#ATOMUMIN16 PSEUDO!",
3381 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3382 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3383 "#ATOMUMAX16 PSEUDO!",
3384 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3386 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3387 "#ATOMAND8 PSEUDO!",
3388 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3389 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3391 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3392 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3393 "#ATOMXOR8 PSEUDO!",
3394 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3395 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3396 "#ATOMNAND8 PSEUDO!",
3397 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3400 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3401 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3402 Uses = [EAX, EBX, ECX, EDX],
3403 mayLoad = 1, mayStore = 1,
3404 usesCustomDAGSchedInserter = 1 in {
3405 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3406 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3407 "#ATOMAND6432 PSEUDO!", []>;
3408 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3409 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3410 "#ATOMOR6432 PSEUDO!", []>;
3411 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3412 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3413 "#ATOMXOR6432 PSEUDO!", []>;
3414 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3415 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3416 "#ATOMNAND6432 PSEUDO!", []>;
3417 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3418 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3419 "#ATOMADD6432 PSEUDO!", []>;
3420 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3421 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3422 "#ATOMSUB6432 PSEUDO!", []>;
3423 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3424 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3425 "#ATOMSWAP6432 PSEUDO!", []>;
3428 //===----------------------------------------------------------------------===//
3429 // Non-Instruction Patterns
3430 //===----------------------------------------------------------------------===//
3432 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3433 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3434 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3435 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3436 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3437 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3439 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3440 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3441 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3442 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3443 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3444 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3445 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3446 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3448 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3449 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3450 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3451 (MOV32mi addr:$dst, texternalsym:$src)>;
3455 def : Pat<(X86tailcall GR32:$dst),
3458 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
3460 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
3463 def : Pat<(X86tcret GR32:$dst, imm:$off),
3464 (TCRETURNri GR32:$dst, imm:$off)>;
3466 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3467 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3469 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3470 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3472 // Normal calls, with various flavors of addresses.
3473 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3474 (CALLpcrel32 tglobaladdr:$dst)>;
3475 def : Pat<(X86call (i32 texternalsym:$dst)),
3476 (CALLpcrel32 texternalsym:$dst)>;
3477 def : Pat<(X86call (i32 imm:$dst)),
3478 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
3480 // X86 specific add which produces a flag.
3481 def : Pat<(addc GR32:$src1, GR32:$src2),
3482 (ADD32rr GR32:$src1, GR32:$src2)>;
3483 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3484 (ADD32rm GR32:$src1, addr:$src2)>;
3485 def : Pat<(addc GR32:$src1, imm:$src2),
3486 (ADD32ri GR32:$src1, imm:$src2)>;
3487 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3488 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3490 def : Pat<(subc GR32:$src1, GR32:$src2),
3491 (SUB32rr GR32:$src1, GR32:$src2)>;
3492 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3493 (SUB32rm GR32:$src1, addr:$src2)>;
3494 def : Pat<(subc GR32:$src1, imm:$src2),
3495 (SUB32ri GR32:$src1, imm:$src2)>;
3496 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3497 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3501 // TEST R,R is smaller than CMP R,0
3502 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3503 (TEST8rr GR8:$src1, GR8:$src1)>;
3504 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3505 (TEST16rr GR16:$src1, GR16:$src1)>;
3506 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3507 (TEST32rr GR32:$src1, GR32:$src1)>;
3509 // Conditional moves with folded loads with operands swapped and conditions
3511 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3512 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3513 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3514 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3515 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3516 (CMOVB16rm GR16:$src2, addr:$src1)>;
3517 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3518 (CMOVB32rm GR32:$src2, addr:$src1)>;
3519 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3520 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3521 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3522 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3523 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3524 (CMOVE16rm GR16:$src2, addr:$src1)>;
3525 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3526 (CMOVE32rm GR32:$src2, addr:$src1)>;
3527 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3528 (CMOVA16rm GR16:$src2, addr:$src1)>;
3529 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3530 (CMOVA32rm GR32:$src2, addr:$src1)>;
3531 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3532 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3533 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3534 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3535 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3536 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3537 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3538 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3539 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3540 (CMOVL16rm GR16:$src2, addr:$src1)>;
3541 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3542 (CMOVL32rm GR32:$src2, addr:$src1)>;
3543 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3544 (CMOVG16rm GR16:$src2, addr:$src1)>;
3545 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3546 (CMOVG32rm GR32:$src2, addr:$src1)>;
3547 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3548 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3549 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3550 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3551 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3552 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3553 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3554 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3555 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3556 (CMOVP16rm GR16:$src2, addr:$src1)>;
3557 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3558 (CMOVP32rm GR32:$src2, addr:$src1)>;
3559 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3560 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3561 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3562 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3563 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3564 (CMOVS16rm GR16:$src2, addr:$src1)>;
3565 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3566 (CMOVS32rm GR32:$src2, addr:$src1)>;
3567 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3568 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3569 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3570 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3571 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3572 (CMOVO16rm GR16:$src2, addr:$src1)>;
3573 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3574 (CMOVO32rm GR32:$src2, addr:$src1)>;
3576 // zextload bool -> zextload byte
3577 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3578 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3579 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3581 // extload bool -> extload byte
3582 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3583 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3584 Requires<[In32BitMode]>;
3585 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3586 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3587 Requires<[In32BitMode]>;
3588 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3589 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3592 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3593 Requires<[In32BitMode]>;
3594 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3595 Requires<[In32BitMode]>;
3596 def : Pat<(i32 (anyext GR16:$src)),
3597 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
3599 // (and (i32 load), 255) -> (zextload i8)
3600 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3601 (MOVZX32rm8 addr:$src)>;
3602 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3603 (MOVZX32rm16 addr:$src)>;
3605 //===----------------------------------------------------------------------===//
3607 //===----------------------------------------------------------------------===//
3609 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3610 // +128 doesn't, so in this special case use a sub instead of an add.
3611 def : Pat<(add GR16:$src1, 128),
3612 (SUB16ri8 GR16:$src1, -128)>;
3613 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3614 (SUB16mi8 addr:$dst, -128)>;
3615 def : Pat<(add GR32:$src1, 128),
3616 (SUB32ri8 GR32:$src1, -128)>;
3617 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3618 (SUB32mi8 addr:$dst, -128)>;
3620 // r & (2^16-1) ==> movz
3621 def : Pat<(and GR32:$src1, 0xffff),
3622 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
3623 // r & (2^8-1) ==> movz
3624 def : Pat<(and GR32:$src1, 0xff),
3625 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
3627 Requires<[In32BitMode]>;
3628 // r & (2^8-1) ==> movz
3629 def : Pat<(and GR16:$src1, 0xff),
3630 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
3632 Requires<[In32BitMode]>;
3634 // sext_inreg patterns
3635 def : Pat<(sext_inreg GR32:$src, i16),
3636 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3637 def : Pat<(sext_inreg GR32:$src, i8),
3638 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3640 Requires<[In32BitMode]>;
3641 def : Pat<(sext_inreg GR16:$src, i8),
3642 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3644 Requires<[In32BitMode]>;
3647 def : Pat<(i16 (trunc GR32:$src)),
3648 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
3649 def : Pat<(i8 (trunc GR32:$src)),
3650 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3652 Requires<[In32BitMode]>;
3653 def : Pat<(i8 (trunc GR16:$src)),
3654 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3656 Requires<[In32BitMode]>;
3658 // h-register tricks
3659 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
3660 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3661 x86_subreg_8bit_hi)>,
3662 Requires<[In32BitMode]>;
3663 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
3664 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3665 x86_subreg_8bit_hi)>,
3666 Requires<[In32BitMode]>;
3667 def : Pat<(srl_su GR16:$src, (i8 8)),
3670 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3671 x86_subreg_8bit_hi)),
3673 Requires<[In32BitMode]>;
3674 def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3675 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3676 x86_subreg_8bit_hi))>,
3677 Requires<[In32BitMode]>;
3678 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
3679 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3680 x86_subreg_8bit_hi))>,
3681 Requires<[In32BitMode]>;
3683 // (shl x, 1) ==> (add x, x)
3684 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3685 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3686 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3688 // (shl x (and y, 31)) ==> (shl x, y)
3689 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3690 (SHL8rCL GR8:$src1)>;
3691 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3692 (SHL16rCL GR16:$src1)>;
3693 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3694 (SHL32rCL GR32:$src1)>;
3695 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3696 (SHL8mCL addr:$dst)>;
3697 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3698 (SHL16mCL addr:$dst)>;
3699 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3700 (SHL32mCL addr:$dst)>;
3702 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3703 (SHR8rCL GR8:$src1)>;
3704 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3705 (SHR16rCL GR16:$src1)>;
3706 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3707 (SHR32rCL GR32:$src1)>;
3708 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3709 (SHR8mCL addr:$dst)>;
3710 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3711 (SHR16mCL addr:$dst)>;
3712 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3713 (SHR32mCL addr:$dst)>;
3715 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3716 (SAR8rCL GR8:$src1)>;
3717 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3718 (SAR16rCL GR16:$src1)>;
3719 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3720 (SAR32rCL GR32:$src1)>;
3721 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3722 (SAR8mCL addr:$dst)>;
3723 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3724 (SAR16mCL addr:$dst)>;
3725 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3726 (SAR32mCL addr:$dst)>;
3728 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3729 def : Pat<(or (srl GR32:$src1, CL:$amt),
3730 (shl GR32:$src2, (sub 32, CL:$amt))),
3731 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3733 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3734 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3735 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3737 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3738 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3739 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3741 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3742 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3744 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3746 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3747 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3749 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3750 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3751 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3753 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3754 def : Pat<(or (shl GR32:$src1, CL:$amt),
3755 (srl GR32:$src2, (sub 32, CL:$amt))),
3756 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3758 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3759 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3760 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3762 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3763 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3764 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3766 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3767 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3769 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3771 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3772 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3774 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3775 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3776 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3778 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3779 def : Pat<(or (srl GR16:$src1, CL:$amt),
3780 (shl GR16:$src2, (sub 16, CL:$amt))),
3781 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3783 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3784 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3785 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3787 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3788 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3789 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3791 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3792 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3794 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3796 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3797 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3799 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3800 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3801 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3803 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3804 def : Pat<(or (shl GR16:$src1, CL:$amt),
3805 (srl GR16:$src2, (sub 16, CL:$amt))),
3806 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3808 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3809 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3810 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3812 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3813 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3814 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3816 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3817 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3819 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3821 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3822 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3824 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3825 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3826 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3828 //===----------------------------------------------------------------------===//
3829 // EFLAGS-defining Patterns
3830 //===----------------------------------------------------------------------===//
3832 // Register-Register Addition with EFLAGS result
3833 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
3835 (ADD8rr GR8:$src1, GR8:$src2)>;
3836 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
3838 (ADD16rr GR16:$src1, GR16:$src2)>;
3839 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
3841 (ADD32rr GR32:$src1, GR32:$src2)>;
3843 // Register-Memory Addition with EFLAGS result
3844 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
3846 (ADD8rm GR8:$src1, addr:$src2)>;
3847 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
3849 (ADD16rm GR16:$src1, addr:$src2)>;
3850 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
3852 (ADD32rm GR32:$src1, addr:$src2)>;
3854 // Register-Integer Addition with EFLAGS result
3855 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
3857 (ADD8ri GR8:$src1, imm:$src2)>;
3858 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
3860 (ADD16ri GR16:$src1, imm:$src2)>;
3861 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
3863 (ADD32ri GR32:$src1, imm:$src2)>;
3864 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
3866 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3867 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
3869 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3871 // Memory-Register Addition with EFLAGS result
3872 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
3875 (ADD8mr addr:$dst, GR8:$src2)>;
3876 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
3879 (ADD16mr addr:$dst, GR16:$src2)>;
3880 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
3883 (ADD32mr addr:$dst, GR32:$src2)>;
3885 // Memory-Integer Addition with EFLAGS result
3886 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
3889 (ADD8mi addr:$dst, imm:$src2)>;
3890 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
3893 (ADD16mi addr:$dst, imm:$src2)>;
3894 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
3897 (ADD32mi addr:$dst, imm:$src2)>;
3898 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3901 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3902 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3905 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3907 // Register-Register Subtraction with EFLAGS result
3908 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
3910 (SUB8rr GR8:$src1, GR8:$src2)>;
3911 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
3913 (SUB16rr GR16:$src1, GR16:$src2)>;
3914 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
3916 (SUB32rr GR32:$src1, GR32:$src2)>;
3918 // Register-Memory Subtraction with EFLAGS result
3919 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
3921 (SUB8rm GR8:$src1, addr:$src2)>;
3922 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
3924 (SUB16rm GR16:$src1, addr:$src2)>;
3925 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
3927 (SUB32rm GR32:$src1, addr:$src2)>;
3929 // Register-Integer Subtraction with EFLAGS result
3930 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
3932 (SUB8ri GR8:$src1, imm:$src2)>;
3933 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
3935 (SUB16ri GR16:$src1, imm:$src2)>;
3936 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
3938 (SUB32ri GR32:$src1, imm:$src2)>;
3939 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
3941 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3942 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
3944 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3946 // Memory-Register Subtraction with EFLAGS result
3947 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
3950 (SUB8mr addr:$dst, GR8:$src2)>;
3951 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
3954 (SUB16mr addr:$dst, GR16:$src2)>;
3955 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
3958 (SUB32mr addr:$dst, GR32:$src2)>;
3960 // Memory-Integer Subtraction with EFLAGS result
3961 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
3964 (SUB8mi addr:$dst, imm:$src2)>;
3965 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
3968 (SUB16mi addr:$dst, imm:$src2)>;
3969 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
3972 (SUB32mi addr:$dst, imm:$src2)>;
3973 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3976 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3977 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3980 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3983 // Register-Register Signed Integer Multiply with EFLAGS result
3984 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
3986 (IMUL16rr GR16:$src1, GR16:$src2)>;
3987 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
3989 (IMUL32rr GR32:$src1, GR32:$src2)>;
3991 // Register-Memory Signed Integer Multiply with EFLAGS result
3992 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
3994 (IMUL16rm GR16:$src1, addr:$src2)>;
3995 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
3997 (IMUL32rm GR32:$src1, addr:$src2)>;
3999 // Register-Integer Signed Integer Multiply with EFLAGS result
4000 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
4002 (IMUL16rri GR16:$src1, imm:$src2)>;
4003 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
4005 (IMUL32rri GR32:$src1, imm:$src2)>;
4006 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
4008 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
4009 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
4011 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4013 // Memory-Integer Signed Integer Multiply with EFLAGS result
4014 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
4016 (IMUL16rmi addr:$src1, imm:$src2)>;
4017 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
4019 (IMUL32rmi addr:$src1, imm:$src2)>;
4020 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
4022 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
4023 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
4025 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4027 // Optimize multiply by 2 with EFLAGS result.
4028 let AddedComplexity = 2 in {
4029 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
4031 (ADD16rr GR16:$src1, GR16:$src1)>;
4033 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
4035 (ADD32rr GR32:$src1, GR32:$src1)>;
4038 // INC and DEC with EFLAGS result. Note that these do not set CF.
4039 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4041 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4044 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4046 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4050 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
4051 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
4052 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4054 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
4055 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
4056 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
4057 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4059 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
4061 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
4062 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
4063 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4065 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
4066 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
4067 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
4068 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4070 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
4072 //===----------------------------------------------------------------------===//
4073 // Floating Point Stack Support
4074 //===----------------------------------------------------------------------===//
4076 include "X86InstrFPStack.td"
4078 //===----------------------------------------------------------------------===//
4080 //===----------------------------------------------------------------------===//
4082 include "X86Instr64bit.td"
4084 //===----------------------------------------------------------------------===//
4085 // XMM Floating point support (requires SSE / SSE2)
4086 //===----------------------------------------------------------------------===//
4088 include "X86InstrSSE.td"
4090 //===----------------------------------------------------------------------===//
4091 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4092 //===----------------------------------------------------------------------===//
4094 include "X86InstrMMX.td"