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,
38 def SDTX86BrCond : SDTypeProfile<0, 3,
39 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
42 def SDTX86SetCC : SDTypeProfile<1, 2,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
46 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
48 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
50 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
51 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
52 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
54 def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
55 def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
58 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
60 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
62 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
64 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
66 def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
68 def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
70 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
72 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
74 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
75 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
76 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
77 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
79 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
81 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
83 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
84 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
86 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
88 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
91 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
94 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
95 [SDNPHasChain, SDNPMayStore,
96 SDNPMayLoad, SDNPMemOperand]>;
97 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
112 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
115 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
116 [SDNPHasChain, SDNPOptInFlag]>;
118 def X86callseq_start :
119 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
120 [SDNPHasChain, SDNPOutFlag]>;
122 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
123 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
125 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
126 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
128 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
129 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
131 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
133 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
134 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
137 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
138 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
140 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
141 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
143 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
144 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
145 def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
146 SDT_X86SegmentBaseAddress, []>;
148 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
151 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
152 [SDNPHasChain, SDNPOptInFlag]>;
154 def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
155 def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
156 def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
157 def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
158 def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
159 def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
161 def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
163 //===----------------------------------------------------------------------===//
164 // X86 Operand Definitions.
167 // *mem - Operand definitions for the funky X86 addressing mode operands.
169 class X86MemOperand<string printMethod> : Operand<iPTR> {
170 let PrintMethod = printMethod;
171 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
174 def i8mem : X86MemOperand<"printi8mem">;
175 def i16mem : X86MemOperand<"printi16mem">;
176 def i32mem : X86MemOperand<"printi32mem">;
177 def i64mem : X86MemOperand<"printi64mem">;
178 def i128mem : X86MemOperand<"printi128mem">;
179 def f32mem : X86MemOperand<"printf32mem">;
180 def f64mem : X86MemOperand<"printf64mem">;
181 def f80mem : X86MemOperand<"printf80mem">;
182 def f128mem : X86MemOperand<"printf128mem">;
184 // A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
185 // plain GR64, so that it doesn't potentially require a REX prefix.
186 def i8mem_NOREX : Operand<i64> {
187 let PrintMethod = "printi8mem";
188 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX, i32imm, i8imm);
191 def lea32mem : Operand<i32> {
192 let PrintMethod = "printlea32mem";
193 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
196 def SSECC : Operand<i8> {
197 let PrintMethod = "printSSECC";
200 def piclabel: Operand<i32> {
201 let PrintMethod = "printPICLabel";
204 // A couple of more descriptive operand definitions.
205 // 16-bits but only 8 bits are significant.
206 def i16i8imm : Operand<i16>;
207 // 32-bits but only 8 bits are significant.
208 def i32i8imm : Operand<i32>;
210 // Branch targets have OtherVT type.
211 def brtarget : Operand<OtherVT>;
213 //===----------------------------------------------------------------------===//
214 // X86 Complex Pattern Definitions.
217 // Define X86 specific addressing mode.
218 def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
219 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
220 [add, mul, shl, or, frameindex], []>;
222 //===----------------------------------------------------------------------===//
223 // X86 Instruction Predicate Definitions.
224 def HasMMX : Predicate<"Subtarget->hasMMX()">;
225 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
226 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
227 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
228 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
229 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
230 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
231 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
232 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
233 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
234 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
235 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
236 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
237 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
238 def OptForSpeed : Predicate<"!OptForSize">;
239 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
241 //===----------------------------------------------------------------------===//
242 // X86 Instruction Format Definitions.
245 include "X86InstrFormats.td"
247 //===----------------------------------------------------------------------===//
248 // Pattern fragments...
251 // X86 specific condition code. These correspond to CondCode in
252 // X86InstrInfo.h. They must be kept in synch.
253 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
254 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
255 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
256 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
257 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
258 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
259 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
260 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
261 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
262 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
263 def X86_COND_NO : PatLeaf<(i8 10)>;
264 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
265 def X86_COND_NS : PatLeaf<(i8 12)>;
266 def X86_COND_O : PatLeaf<(i8 13)>;
267 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
268 def X86_COND_S : PatLeaf<(i8 15)>;
270 def i16immSExt8 : PatLeaf<(i16 imm), [{
271 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
272 // sign extended field.
273 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
276 def i32immSExt8 : PatLeaf<(i32 imm), [{
277 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
278 // sign extended field.
279 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
282 // Helper fragments for loads.
283 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
284 // known to be 32-bit aligned or better. Ditto for i8 to i16.
285 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
286 LoadSDNode *LD = cast<LoadSDNode>(N);
287 if (const Value *Src = LD->getSrcValue())
288 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
289 if (PT->getAddressSpace() > 255)
291 ISD::LoadExtType ExtType = LD->getExtensionType();
292 if (ExtType == ISD::NON_EXTLOAD)
294 if (ExtType == ISD::EXTLOAD)
295 return LD->getAlignment() >= 2 && !LD->isVolatile();
299 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
300 LoadSDNode *LD = cast<LoadSDNode>(N);
301 if (const Value *Src = LD->getSrcValue())
302 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
303 if (PT->getAddressSpace() > 255)
305 ISD::LoadExtType ExtType = LD->getExtensionType();
306 if (ExtType == ISD::EXTLOAD)
307 return LD->getAlignment() >= 2 && !LD->isVolatile();
311 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
312 LoadSDNode *LD = cast<LoadSDNode>(N);
313 if (const Value *Src = LD->getSrcValue())
314 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
315 if (PT->getAddressSpace() > 255)
317 ISD::LoadExtType ExtType = LD->getExtensionType();
318 if (ExtType == ISD::NON_EXTLOAD)
320 if (ExtType == ISD::EXTLOAD)
321 return LD->getAlignment() >= 4 && !LD->isVolatile();
325 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
326 LoadSDNode *LD = cast<LoadSDNode>(N);
327 if (const Value *Src = LD->getSrcValue())
328 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
329 if (PT->getAddressSpace() > 255)
331 if (LD->isVolatile())
333 ISD::LoadExtType ExtType = LD->getExtensionType();
334 if (ExtType == ISD::NON_EXTLOAD)
336 if (ExtType == ISD::EXTLOAD)
337 return LD->getAlignment() >= 4;
341 def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
342 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
343 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
344 return PT->getAddressSpace() == 256;
348 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
349 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
350 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
351 if (PT->getAddressSpace() > 255)
355 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
356 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
357 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
358 if (PT->getAddressSpace() > 255)
363 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
364 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
365 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
366 if (PT->getAddressSpace() > 255)
370 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
373 if (PT->getAddressSpace() > 255)
377 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
378 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
380 if (PT->getAddressSpace() > 255)
385 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
386 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
387 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
389 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
390 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
391 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
392 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
393 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
394 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
396 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
397 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
398 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
399 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
400 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
401 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
404 // An 'and' node with a single use.
405 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
406 return N->hasOneUse();
408 // An 'srl' node with a single use.
409 def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
410 return N->hasOneUse();
412 // An 'trunc' node with a single use.
413 def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
414 return N->hasOneUse();
417 // 'shld' and 'shrd' instruction patterns. Note that even though these have
418 // the srl and shl in their patterns, the C++ code must still check for them,
419 // because predicates are tested before children nodes are explored.
421 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
422 (or (srl node:$src1, node:$amt1),
423 (shl node:$src2, node:$amt2)), [{
424 assert(N->getOpcode() == ISD::OR);
425 return N->getOperand(0).getOpcode() == ISD::SRL &&
426 N->getOperand(1).getOpcode() == ISD::SHL &&
427 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
428 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
429 N->getOperand(0).getConstantOperandVal(1) ==
430 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
433 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
434 (or (shl node:$src1, node:$amt1),
435 (srl node:$src2, node:$amt2)), [{
436 assert(N->getOpcode() == ISD::OR);
437 return N->getOperand(0).getOpcode() == ISD::SHL &&
438 N->getOperand(1).getOpcode() == ISD::SRL &&
439 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
440 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
441 N->getOperand(0).getConstantOperandVal(1) ==
442 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
445 //===----------------------------------------------------------------------===//
446 // Instruction list...
449 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
450 // a stack adjustment and the codegen must know that they may modify the stack
451 // pointer before prolog-epilog rewriting occurs.
452 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
453 // sub / add which can clobber EFLAGS.
454 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
455 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
457 [(X86callseq_start timm:$amt)]>,
458 Requires<[In32BitMode]>;
459 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
461 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
462 Requires<[In32BitMode]>;
466 let neverHasSideEffects = 1 in
467 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
470 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
471 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
475 //===----------------------------------------------------------------------===//
476 // Control Flow Instructions...
479 // Return instructions.
480 let isTerminator = 1, isReturn = 1, isBarrier = 1,
481 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
482 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
485 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
487 [(X86retflag imm:$amt)]>;
490 // All branches are RawFrm, Void, Branch, and Terminators
491 let isBranch = 1, isTerminator = 1 in
492 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
493 I<opcode, RawFrm, (outs), ins, asm, pattern>;
495 let isBranch = 1, isBarrier = 1 in
496 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
499 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
500 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
501 [(brind GR32:$dst)]>;
502 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
503 [(brind (loadi32 addr:$dst))]>;
506 // Conditional branches
507 let Uses = [EFLAGS] in {
508 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
509 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
510 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
511 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
512 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
513 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
514 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
515 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
516 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
517 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
518 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
519 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
521 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
522 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
523 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
524 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
525 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
526 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
527 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
528 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
530 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
531 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
532 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
533 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
534 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
535 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
536 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
537 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
538 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
539 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
540 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
541 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
544 //===----------------------------------------------------------------------===//
545 // Call Instructions...
548 // All calls clobber the non-callee saved registers. ESP is marked as
549 // a use to prevent stack-pointer assignments that appear immediately
550 // before calls from potentially appearing dead. Uses for argument
551 // registers are added manually.
552 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
553 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
554 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
555 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
557 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
558 "call\t${dst:call}", [(X86call imm:$dst)]>,
559 Requires<[In32BitMode]>;
560 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
561 "call\t{*}$dst", [(X86call GR32:$dst)]>;
562 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
563 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
568 def TAILCALL : I<0, Pseudo, (outs), (ins),
572 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
573 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
574 "#TC_RETURN $dst $offset",
577 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
578 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
579 "#TC_RETURN $dst $offset",
582 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
584 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
586 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
587 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
589 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
590 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
591 "jmp\t{*}$dst # TAILCALL", []>;
593 //===----------------------------------------------------------------------===//
594 // Miscellaneous Instructions...
596 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
597 def LEAVE : I<0xC9, RawFrm,
598 (outs), (ins), "leave", []>;
600 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
602 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
605 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
608 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
609 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
610 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
611 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
613 let isTwoAddress = 1 in // GR32 = bswap GR32
614 def BSWAP32r : I<0xC8, AddRegFrm,
615 (outs GR32:$dst), (ins GR32:$src),
617 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
620 // Bit scan instructions.
621 let Defs = [EFLAGS] in {
622 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
623 "bsf{w}\t{$src, $dst|$dst, $src}",
624 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
625 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
626 "bsf{w}\t{$src, $dst|$dst, $src}",
627 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
628 (implicit EFLAGS)]>, TB;
629 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
630 "bsf{l}\t{$src, $dst|$dst, $src}",
631 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
632 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
633 "bsf{l}\t{$src, $dst|$dst, $src}",
634 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
635 (implicit EFLAGS)]>, TB;
637 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
638 "bsr{w}\t{$src, $dst|$dst, $src}",
639 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
640 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
641 "bsr{w}\t{$src, $dst|$dst, $src}",
642 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
643 (implicit EFLAGS)]>, TB;
644 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
645 "bsr{l}\t{$src, $dst|$dst, $src}",
646 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
647 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
648 "bsr{l}\t{$src, $dst|$dst, $src}",
649 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
650 (implicit EFLAGS)]>, TB;
653 let neverHasSideEffects = 1 in
654 def LEA16r : I<0x8D, MRMSrcMem,
655 (outs GR16:$dst), (ins i32mem:$src),
656 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
657 let isReMaterializable = 1 in
658 def LEA32r : I<0x8D, MRMSrcMem,
659 (outs GR32:$dst), (ins lea32mem:$src),
660 "lea{l}\t{$src|$dst}, {$dst|$src}",
661 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
663 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
664 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
665 [(X86rep_movs i8)]>, REP;
666 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
667 [(X86rep_movs i16)]>, REP, OpSize;
668 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
669 [(X86rep_movs i32)]>, REP;
672 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
673 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
674 [(X86rep_stos i8)]>, REP;
675 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
676 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
677 [(X86rep_stos i16)]>, REP, OpSize;
678 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
679 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
680 [(X86rep_stos i32)]>, REP;
682 let Defs = [RAX, RDX] in
683 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
686 let isBarrier = 1, hasCtrlDep = 1 in {
687 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
690 //===----------------------------------------------------------------------===//
691 // Input/Output Instructions...
693 let Defs = [AL], Uses = [DX] in
694 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
695 "in{b}\t{%dx, %al|%AL, %DX}", []>;
696 let Defs = [AX], Uses = [DX] in
697 def IN16rr : I<0xED, RawFrm, (outs), (ins),
698 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
699 let Defs = [EAX], Uses = [DX] in
700 def IN32rr : I<0xED, RawFrm, (outs), (ins),
701 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
704 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
705 "in{b}\t{$port, %al|%AL, $port}", []>;
707 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
708 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
710 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
711 "in{l}\t{$port, %eax|%EAX, $port}", []>;
713 let Uses = [DX, AL] in
714 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
715 "out{b}\t{%al, %dx|%DX, %AL}", []>;
716 let Uses = [DX, AX] in
717 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
718 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
719 let Uses = [DX, EAX] in
720 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
721 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
724 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
725 "out{b}\t{%al, $port|$port, %AL}", []>;
727 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
728 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
730 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
731 "out{l}\t{%eax, $port|$port, %EAX}", []>;
733 //===----------------------------------------------------------------------===//
734 // Move Instructions...
736 let neverHasSideEffects = 1 in {
737 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
738 "mov{b}\t{$src, $dst|$dst, $src}", []>;
739 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
740 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
741 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
742 "mov{l}\t{$src, $dst|$dst, $src}", []>;
744 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
745 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
746 "mov{b}\t{$src, $dst|$dst, $src}",
747 [(set GR8:$dst, imm:$src)]>;
748 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
749 "mov{w}\t{$src, $dst|$dst, $src}",
750 [(set GR16:$dst, imm:$src)]>, OpSize;
751 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
752 "mov{l}\t{$src, $dst|$dst, $src}",
753 [(set GR32:$dst, imm:$src)]>;
755 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
756 "mov{b}\t{$src, $dst|$dst, $src}",
757 [(store (i8 imm:$src), addr:$dst)]>;
758 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
759 "mov{w}\t{$src, $dst|$dst, $src}",
760 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
761 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
762 "mov{l}\t{$src, $dst|$dst, $src}",
763 [(store (i32 imm:$src), addr:$dst)]>;
765 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
766 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
767 "mov{b}\t{$src, $dst|$dst, $src}",
768 [(set GR8:$dst, (loadi8 addr:$src))]>;
769 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
770 "mov{w}\t{$src, $dst|$dst, $src}",
771 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
772 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
773 "mov{l}\t{$src, $dst|$dst, $src}",
774 [(set GR32:$dst, (loadi32 addr:$src))]>;
777 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
778 "mov{b}\t{$src, $dst|$dst, $src}",
779 [(store GR8:$src, addr:$dst)]>;
780 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
781 "mov{w}\t{$src, $dst|$dst, $src}",
782 [(store GR16:$src, addr:$dst)]>, OpSize;
783 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
784 "mov{l}\t{$src, $dst|$dst, $src}",
785 [(store GR32:$src, addr:$dst)]>;
787 // Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
788 // that they can be used for copying and storing h registers, which can't be
789 // encoded when a REX prefix is present.
790 let neverHasSideEffects = 1 in
791 def MOV8rr_NOREX : I<0x88, MRMDestReg,
792 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
793 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
795 def MOV8mr_NOREX : I<0x88, MRMDestMem,
796 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
797 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
799 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
800 def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
801 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
802 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
804 //===----------------------------------------------------------------------===//
805 // Fixed-Register Multiplication and Division Instructions...
808 // Extra precision multiplication
809 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
810 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
811 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
812 // This probably ought to be moved to a def : Pat<> if the
813 // syntax can be accepted.
814 [(set AL, (mul AL, GR8:$src)),
815 (implicit EFLAGS)]>; // AL,AH = AL*GR8
817 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
818 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
820 []>, OpSize; // AX,DX = AX*GR16
822 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
823 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
825 []>; // EAX,EDX = EAX*GR32
827 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
828 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
830 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
831 // This probably ought to be moved to a def : Pat<> if the
832 // syntax can be accepted.
833 [(set AL, (mul AL, (loadi8 addr:$src))),
834 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
836 let mayLoad = 1, neverHasSideEffects = 1 in {
837 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
838 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
840 []>, OpSize; // AX,DX = AX*[mem16]
842 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
843 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
845 []>; // EAX,EDX = EAX*[mem32]
848 let neverHasSideEffects = 1 in {
849 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
850 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
852 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
853 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
854 OpSize; // AX,DX = AX*GR16
855 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
856 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
857 // EAX,EDX = EAX*GR32
859 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
860 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
861 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
862 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
863 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
864 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
865 let Defs = [EAX,EDX], Uses = [EAX] in
866 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
867 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
869 } // neverHasSideEffects
871 // unsigned division/remainder
872 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
873 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
875 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
876 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
877 "div{w}\t$src", []>, OpSize;
878 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
879 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
882 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
883 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
885 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
886 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
887 "div{w}\t$src", []>, OpSize;
888 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
889 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
893 // Signed division/remainder.
894 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
895 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
896 "idiv{b}\t$src", []>;
897 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
898 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
899 "idiv{w}\t$src", []>, OpSize;
900 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
901 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
902 "idiv{l}\t$src", []>;
903 let mayLoad = 1, mayLoad = 1 in {
904 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
905 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
906 "idiv{b}\t$src", []>;
907 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
908 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
909 "idiv{w}\t$src", []>, OpSize;
910 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
911 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
912 "idiv{l}\t$src", []>;
915 //===----------------------------------------------------------------------===//
916 // Two address Instructions.
918 let isTwoAddress = 1 in {
921 let Uses = [EFLAGS] in {
922 let isCommutable = 1 in {
923 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
924 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
925 "cmovb\t{$src2, $dst|$dst, $src2}",
926 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
927 X86_COND_B, EFLAGS))]>,
929 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
930 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
931 "cmovb\t{$src2, $dst|$dst, $src2}",
932 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
933 X86_COND_B, EFLAGS))]>,
935 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
936 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
937 "cmovae\t{$src2, $dst|$dst, $src2}",
938 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
939 X86_COND_AE, EFLAGS))]>,
941 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
942 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
943 "cmovae\t{$src2, $dst|$dst, $src2}",
944 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
945 X86_COND_AE, EFLAGS))]>,
947 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
948 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
949 "cmove\t{$src2, $dst|$dst, $src2}",
950 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
951 X86_COND_E, EFLAGS))]>,
953 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
954 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
955 "cmove\t{$src2, $dst|$dst, $src2}",
956 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
957 X86_COND_E, EFLAGS))]>,
959 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
960 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
961 "cmovne\t{$src2, $dst|$dst, $src2}",
962 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
963 X86_COND_NE, EFLAGS))]>,
965 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
966 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
967 "cmovne\t{$src2, $dst|$dst, $src2}",
968 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
969 X86_COND_NE, EFLAGS))]>,
971 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
972 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
973 "cmovbe\t{$src2, $dst|$dst, $src2}",
974 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
975 X86_COND_BE, EFLAGS))]>,
977 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
978 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
979 "cmovbe\t{$src2, $dst|$dst, $src2}",
980 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
981 X86_COND_BE, EFLAGS))]>,
983 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
984 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
985 "cmova\t{$src2, $dst|$dst, $src2}",
986 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
987 X86_COND_A, EFLAGS))]>,
989 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
990 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
991 "cmova\t{$src2, $dst|$dst, $src2}",
992 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
993 X86_COND_A, EFLAGS))]>,
995 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
996 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
997 "cmovl\t{$src2, $dst|$dst, $src2}",
998 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
999 X86_COND_L, EFLAGS))]>,
1001 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
1002 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1003 "cmovl\t{$src2, $dst|$dst, $src2}",
1004 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1005 X86_COND_L, EFLAGS))]>,
1007 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
1008 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1009 "cmovge\t{$src2, $dst|$dst, $src2}",
1010 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1011 X86_COND_GE, EFLAGS))]>,
1013 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
1014 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1015 "cmovge\t{$src2, $dst|$dst, $src2}",
1016 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1017 X86_COND_GE, EFLAGS))]>,
1019 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
1020 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1021 "cmovle\t{$src2, $dst|$dst, $src2}",
1022 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1023 X86_COND_LE, EFLAGS))]>,
1025 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
1026 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1027 "cmovle\t{$src2, $dst|$dst, $src2}",
1028 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1029 X86_COND_LE, EFLAGS))]>,
1031 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
1032 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1033 "cmovg\t{$src2, $dst|$dst, $src2}",
1034 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1035 X86_COND_G, EFLAGS))]>,
1037 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
1038 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1039 "cmovg\t{$src2, $dst|$dst, $src2}",
1040 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1041 X86_COND_G, EFLAGS))]>,
1043 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
1044 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1045 "cmovs\t{$src2, $dst|$dst, $src2}",
1046 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1047 X86_COND_S, EFLAGS))]>,
1049 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
1050 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1051 "cmovs\t{$src2, $dst|$dst, $src2}",
1052 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1053 X86_COND_S, EFLAGS))]>,
1055 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
1056 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1057 "cmovns\t{$src2, $dst|$dst, $src2}",
1058 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1059 X86_COND_NS, EFLAGS))]>,
1061 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1062 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1063 "cmovns\t{$src2, $dst|$dst, $src2}",
1064 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1065 X86_COND_NS, EFLAGS))]>,
1067 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1068 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1069 "cmovp\t{$src2, $dst|$dst, $src2}",
1070 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1071 X86_COND_P, EFLAGS))]>,
1073 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1074 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1075 "cmovp\t{$src2, $dst|$dst, $src2}",
1076 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1077 X86_COND_P, EFLAGS))]>,
1079 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1080 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1081 "cmovnp\t{$src2, $dst|$dst, $src2}",
1082 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1083 X86_COND_NP, EFLAGS))]>,
1085 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1086 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1087 "cmovnp\t{$src2, $dst|$dst, $src2}",
1088 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1089 X86_COND_NP, EFLAGS))]>,
1091 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1092 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1093 "cmovo\t{$src2, $dst|$dst, $src2}",
1094 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1095 X86_COND_O, EFLAGS))]>,
1097 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1098 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1099 "cmovo\t{$src2, $dst|$dst, $src2}",
1100 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1101 X86_COND_O, EFLAGS))]>,
1103 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1104 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1105 "cmovno\t{$src2, $dst|$dst, $src2}",
1106 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1107 X86_COND_NO, EFLAGS))]>,
1109 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1110 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1111 "cmovno\t{$src2, $dst|$dst, $src2}",
1112 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1113 X86_COND_NO, EFLAGS))]>,
1115 } // isCommutable = 1
1117 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1118 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1119 "cmovb\t{$src2, $dst|$dst, $src2}",
1120 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1121 X86_COND_B, EFLAGS))]>,
1123 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1124 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1125 "cmovb\t{$src2, $dst|$dst, $src2}",
1126 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1127 X86_COND_B, EFLAGS))]>,
1129 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1130 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1131 "cmovae\t{$src2, $dst|$dst, $src2}",
1132 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1133 X86_COND_AE, EFLAGS))]>,
1135 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1136 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1137 "cmovae\t{$src2, $dst|$dst, $src2}",
1138 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1139 X86_COND_AE, EFLAGS))]>,
1141 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1142 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1143 "cmove\t{$src2, $dst|$dst, $src2}",
1144 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1145 X86_COND_E, EFLAGS))]>,
1147 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1148 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1149 "cmove\t{$src2, $dst|$dst, $src2}",
1150 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1151 X86_COND_E, EFLAGS))]>,
1153 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1154 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1155 "cmovne\t{$src2, $dst|$dst, $src2}",
1156 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1157 X86_COND_NE, EFLAGS))]>,
1159 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1160 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1161 "cmovne\t{$src2, $dst|$dst, $src2}",
1162 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1163 X86_COND_NE, EFLAGS))]>,
1165 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1166 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1167 "cmovbe\t{$src2, $dst|$dst, $src2}",
1168 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1169 X86_COND_BE, EFLAGS))]>,
1171 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1172 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1173 "cmovbe\t{$src2, $dst|$dst, $src2}",
1174 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1175 X86_COND_BE, EFLAGS))]>,
1177 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1178 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1179 "cmova\t{$src2, $dst|$dst, $src2}",
1180 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1181 X86_COND_A, EFLAGS))]>,
1183 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1184 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1185 "cmova\t{$src2, $dst|$dst, $src2}",
1186 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1187 X86_COND_A, EFLAGS))]>,
1189 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1190 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1191 "cmovl\t{$src2, $dst|$dst, $src2}",
1192 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1193 X86_COND_L, EFLAGS))]>,
1195 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1196 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1197 "cmovl\t{$src2, $dst|$dst, $src2}",
1198 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1199 X86_COND_L, EFLAGS))]>,
1201 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1202 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1203 "cmovge\t{$src2, $dst|$dst, $src2}",
1204 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1205 X86_COND_GE, EFLAGS))]>,
1207 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1208 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1209 "cmovge\t{$src2, $dst|$dst, $src2}",
1210 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1211 X86_COND_GE, EFLAGS))]>,
1213 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1214 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1215 "cmovle\t{$src2, $dst|$dst, $src2}",
1216 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1217 X86_COND_LE, EFLAGS))]>,
1219 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1220 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1221 "cmovle\t{$src2, $dst|$dst, $src2}",
1222 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1223 X86_COND_LE, EFLAGS))]>,
1225 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1226 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1227 "cmovg\t{$src2, $dst|$dst, $src2}",
1228 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1229 X86_COND_G, EFLAGS))]>,
1231 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1232 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1233 "cmovg\t{$src2, $dst|$dst, $src2}",
1234 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1235 X86_COND_G, EFLAGS))]>,
1237 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1238 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1239 "cmovs\t{$src2, $dst|$dst, $src2}",
1240 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1241 X86_COND_S, EFLAGS))]>,
1243 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1244 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1245 "cmovs\t{$src2, $dst|$dst, $src2}",
1246 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1247 X86_COND_S, EFLAGS))]>,
1249 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1250 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1251 "cmovns\t{$src2, $dst|$dst, $src2}",
1252 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1253 X86_COND_NS, EFLAGS))]>,
1255 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1256 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1257 "cmovns\t{$src2, $dst|$dst, $src2}",
1258 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1259 X86_COND_NS, EFLAGS))]>,
1261 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1262 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1263 "cmovp\t{$src2, $dst|$dst, $src2}",
1264 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1265 X86_COND_P, EFLAGS))]>,
1267 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1268 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1269 "cmovp\t{$src2, $dst|$dst, $src2}",
1270 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1271 X86_COND_P, EFLAGS))]>,
1273 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1274 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1275 "cmovnp\t{$src2, $dst|$dst, $src2}",
1276 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1277 X86_COND_NP, EFLAGS))]>,
1279 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1280 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1281 "cmovnp\t{$src2, $dst|$dst, $src2}",
1282 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1283 X86_COND_NP, EFLAGS))]>,
1285 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1286 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1287 "cmovo\t{$src2, $dst|$dst, $src2}",
1288 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1289 X86_COND_O, EFLAGS))]>,
1291 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1292 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1293 "cmovo\t{$src2, $dst|$dst, $src2}",
1294 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1295 X86_COND_O, EFLAGS))]>,
1297 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1298 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1299 "cmovno\t{$src2, $dst|$dst, $src2}",
1300 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1301 X86_COND_NO, EFLAGS))]>,
1303 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1304 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1305 "cmovno\t{$src2, $dst|$dst, $src2}",
1306 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1307 X86_COND_NO, EFLAGS))]>,
1309 } // Uses = [EFLAGS]
1312 // unary instructions
1313 let CodeSize = 2 in {
1314 let Defs = [EFLAGS] in {
1315 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1316 [(set GR8:$dst, (ineg GR8:$src)),
1317 (implicit EFLAGS)]>;
1318 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1319 [(set GR16:$dst, (ineg GR16:$src)),
1320 (implicit EFLAGS)]>, OpSize;
1321 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1322 [(set GR32:$dst, (ineg GR32:$src)),
1323 (implicit EFLAGS)]>;
1324 let isTwoAddress = 0 in {
1325 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1326 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1327 (implicit EFLAGS)]>;
1328 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1329 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1330 (implicit EFLAGS)]>, OpSize;
1331 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1332 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1333 (implicit EFLAGS)]>;
1335 } // Defs = [EFLAGS]
1337 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1338 let AddedComplexity = 15 in {
1339 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1340 [(set GR8:$dst, (not GR8:$src))]>;
1341 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1342 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1343 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1344 [(set GR32:$dst, (not GR32:$src))]>;
1346 let isTwoAddress = 0 in {
1347 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1348 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1349 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1350 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1351 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1352 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1356 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1357 let Defs = [EFLAGS] in {
1359 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1360 [(set GR8:$dst, (add GR8:$src, 1)),
1361 (implicit EFLAGS)]>;
1362 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1363 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1364 [(set GR16:$dst, (add GR16:$src, 1)),
1365 (implicit EFLAGS)]>,
1366 OpSize, Requires<[In32BitMode]>;
1367 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1368 [(set GR32:$dst, (add GR32:$src, 1)),
1369 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1371 let isTwoAddress = 0, CodeSize = 2 in {
1372 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1373 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1374 (implicit EFLAGS)]>;
1375 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1376 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1377 (implicit EFLAGS)]>,
1378 OpSize, Requires<[In32BitMode]>;
1379 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1380 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1381 (implicit EFLAGS)]>,
1382 Requires<[In32BitMode]>;
1386 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1387 [(set GR8:$dst, (add GR8:$src, -1)),
1388 (implicit EFLAGS)]>;
1389 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1390 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1391 [(set GR16:$dst, (add GR16:$src, -1)),
1392 (implicit EFLAGS)]>,
1393 OpSize, Requires<[In32BitMode]>;
1394 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1395 [(set GR32:$dst, (add GR32:$src, -1)),
1396 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
1399 let isTwoAddress = 0, CodeSize = 2 in {
1400 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1401 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1402 (implicit EFLAGS)]>;
1403 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1404 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1405 (implicit EFLAGS)]>,
1406 OpSize, Requires<[In32BitMode]>;
1407 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1408 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1409 (implicit EFLAGS)]>,
1410 Requires<[In32BitMode]>;
1412 } // Defs = [EFLAGS]
1414 // Logical operators...
1415 let Defs = [EFLAGS] in {
1416 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1417 def AND8rr : I<0x20, MRMDestReg,
1418 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1419 "and{b}\t{$src2, $dst|$dst, $src2}",
1420 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1421 (implicit EFLAGS)]>;
1422 def AND16rr : I<0x21, MRMDestReg,
1423 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1424 "and{w}\t{$src2, $dst|$dst, $src2}",
1425 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1426 (implicit EFLAGS)]>, OpSize;
1427 def AND32rr : I<0x21, MRMDestReg,
1428 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1429 "and{l}\t{$src2, $dst|$dst, $src2}",
1430 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1431 (implicit EFLAGS)]>;
1434 def AND8rm : I<0x22, MRMSrcMem,
1435 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1436 "and{b}\t{$src2, $dst|$dst, $src2}",
1437 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
1438 (implicit EFLAGS)]>;
1439 def AND16rm : I<0x23, MRMSrcMem,
1440 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1441 "and{w}\t{$src2, $dst|$dst, $src2}",
1442 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
1443 (implicit EFLAGS)]>, OpSize;
1444 def AND32rm : I<0x23, MRMSrcMem,
1445 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1446 "and{l}\t{$src2, $dst|$dst, $src2}",
1447 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
1448 (implicit EFLAGS)]>;
1450 def AND8ri : Ii8<0x80, MRM4r,
1451 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1452 "and{b}\t{$src2, $dst|$dst, $src2}",
1453 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1454 (implicit EFLAGS)]>;
1455 def AND16ri : Ii16<0x81, MRM4r,
1456 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1457 "and{w}\t{$src2, $dst|$dst, $src2}",
1458 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1459 (implicit EFLAGS)]>, OpSize;
1460 def AND32ri : Ii32<0x81, MRM4r,
1461 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1462 "and{l}\t{$src2, $dst|$dst, $src2}",
1463 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1464 (implicit EFLAGS)]>;
1465 def AND16ri8 : Ii8<0x83, MRM4r,
1466 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1467 "and{w}\t{$src2, $dst|$dst, $src2}",
1468 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1469 (implicit EFLAGS)]>,
1471 def AND32ri8 : Ii8<0x83, MRM4r,
1472 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1473 "and{l}\t{$src2, $dst|$dst, $src2}",
1474 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1475 (implicit EFLAGS)]>;
1477 let isTwoAddress = 0 in {
1478 def AND8mr : I<0x20, MRMDestMem,
1479 (outs), (ins i8mem :$dst, GR8 :$src),
1480 "and{b}\t{$src, $dst|$dst, $src}",
1481 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1482 (implicit EFLAGS)]>;
1483 def AND16mr : I<0x21, MRMDestMem,
1484 (outs), (ins i16mem:$dst, GR16:$src),
1485 "and{w}\t{$src, $dst|$dst, $src}",
1486 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1487 (implicit EFLAGS)]>,
1489 def AND32mr : I<0x21, MRMDestMem,
1490 (outs), (ins i32mem:$dst, GR32:$src),
1491 "and{l}\t{$src, $dst|$dst, $src}",
1492 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1493 (implicit EFLAGS)]>;
1494 def AND8mi : Ii8<0x80, MRM4m,
1495 (outs), (ins i8mem :$dst, i8imm :$src),
1496 "and{b}\t{$src, $dst|$dst, $src}",
1497 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1498 (implicit EFLAGS)]>;
1499 def AND16mi : Ii16<0x81, MRM4m,
1500 (outs), (ins i16mem:$dst, i16imm:$src),
1501 "and{w}\t{$src, $dst|$dst, $src}",
1502 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1503 (implicit EFLAGS)]>,
1505 def AND32mi : Ii32<0x81, MRM4m,
1506 (outs), (ins i32mem:$dst, i32imm:$src),
1507 "and{l}\t{$src, $dst|$dst, $src}",
1508 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1509 (implicit EFLAGS)]>;
1510 def AND16mi8 : Ii8<0x83, MRM4m,
1511 (outs), (ins i16mem:$dst, i16i8imm :$src),
1512 "and{w}\t{$src, $dst|$dst, $src}",
1513 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1514 (implicit EFLAGS)]>,
1516 def AND32mi8 : Ii8<0x83, MRM4m,
1517 (outs), (ins i32mem:$dst, i32i8imm :$src),
1518 "and{l}\t{$src, $dst|$dst, $src}",
1519 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1520 (implicit EFLAGS)]>;
1524 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1525 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1526 "or{b}\t{$src2, $dst|$dst, $src2}",
1527 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1528 (implicit EFLAGS)]>;
1529 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1530 "or{w}\t{$src2, $dst|$dst, $src2}",
1531 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1532 (implicit EFLAGS)]>, OpSize;
1533 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1534 "or{l}\t{$src2, $dst|$dst, $src2}",
1535 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1536 (implicit EFLAGS)]>;
1538 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1539 "or{b}\t{$src2, $dst|$dst, $src2}",
1540 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1541 (implicit EFLAGS)]>;
1542 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1543 "or{w}\t{$src2, $dst|$dst, $src2}",
1544 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1545 (implicit EFLAGS)]>, OpSize;
1546 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1547 "or{l}\t{$src2, $dst|$dst, $src2}",
1548 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1549 (implicit EFLAGS)]>;
1551 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1552 "or{b}\t{$src2, $dst|$dst, $src2}",
1553 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1554 (implicit EFLAGS)]>;
1555 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1556 "or{w}\t{$src2, $dst|$dst, $src2}",
1557 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1558 (implicit EFLAGS)]>, OpSize;
1559 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1560 "or{l}\t{$src2, $dst|$dst, $src2}",
1561 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1562 (implicit EFLAGS)]>;
1564 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1565 "or{w}\t{$src2, $dst|$dst, $src2}",
1566 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1567 (implicit EFLAGS)]>, OpSize;
1568 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1569 "or{l}\t{$src2, $dst|$dst, $src2}",
1570 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1571 (implicit EFLAGS)]>;
1572 let isTwoAddress = 0 in {
1573 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1574 "or{b}\t{$src, $dst|$dst, $src}",
1575 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1576 (implicit EFLAGS)]>;
1577 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1578 "or{w}\t{$src, $dst|$dst, $src}",
1579 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1580 (implicit EFLAGS)]>, OpSize;
1581 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1582 "or{l}\t{$src, $dst|$dst, $src}",
1583 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1584 (implicit EFLAGS)]>;
1585 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1586 "or{b}\t{$src, $dst|$dst, $src}",
1587 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1588 (implicit EFLAGS)]>;
1589 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1590 "or{w}\t{$src, $dst|$dst, $src}",
1591 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1592 (implicit EFLAGS)]>,
1594 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1595 "or{l}\t{$src, $dst|$dst, $src}",
1596 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1597 (implicit EFLAGS)]>;
1598 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1599 "or{w}\t{$src, $dst|$dst, $src}",
1600 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1601 (implicit EFLAGS)]>,
1603 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1604 "or{l}\t{$src, $dst|$dst, $src}",
1605 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1606 (implicit EFLAGS)]>;
1607 } // isTwoAddress = 0
1610 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1611 def XOR8rr : I<0x30, MRMDestReg,
1612 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1613 "xor{b}\t{$src2, $dst|$dst, $src2}",
1614 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1615 (implicit EFLAGS)]>;
1616 def XOR16rr : I<0x31, MRMDestReg,
1617 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1618 "xor{w}\t{$src2, $dst|$dst, $src2}",
1619 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1620 (implicit EFLAGS)]>, OpSize;
1621 def XOR32rr : I<0x31, MRMDestReg,
1622 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1623 "xor{l}\t{$src2, $dst|$dst, $src2}",
1624 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1625 (implicit EFLAGS)]>;
1626 } // isCommutable = 1
1628 def XOR8rm : I<0x32, MRMSrcMem ,
1629 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1630 "xor{b}\t{$src2, $dst|$dst, $src2}",
1631 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1632 (implicit EFLAGS)]>;
1633 def XOR16rm : I<0x33, MRMSrcMem ,
1634 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1635 "xor{w}\t{$src2, $dst|$dst, $src2}",
1636 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1637 (implicit EFLAGS)]>,
1639 def XOR32rm : I<0x33, MRMSrcMem ,
1640 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1641 "xor{l}\t{$src2, $dst|$dst, $src2}",
1642 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1643 (implicit EFLAGS)]>;
1645 def XOR8ri : Ii8<0x80, MRM6r,
1646 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1647 "xor{b}\t{$src2, $dst|$dst, $src2}",
1648 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1649 (implicit EFLAGS)]>;
1650 def XOR16ri : Ii16<0x81, MRM6r,
1651 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1652 "xor{w}\t{$src2, $dst|$dst, $src2}",
1653 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1654 (implicit EFLAGS)]>, OpSize;
1655 def XOR32ri : Ii32<0x81, MRM6r,
1656 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1657 "xor{l}\t{$src2, $dst|$dst, $src2}",
1658 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1659 (implicit EFLAGS)]>;
1660 def XOR16ri8 : Ii8<0x83, MRM6r,
1661 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1662 "xor{w}\t{$src2, $dst|$dst, $src2}",
1663 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1664 (implicit EFLAGS)]>,
1666 def XOR32ri8 : Ii8<0x83, MRM6r,
1667 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1668 "xor{l}\t{$src2, $dst|$dst, $src2}",
1669 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1670 (implicit EFLAGS)]>;
1672 let isTwoAddress = 0 in {
1673 def XOR8mr : I<0x30, MRMDestMem,
1674 (outs), (ins i8mem :$dst, GR8 :$src),
1675 "xor{b}\t{$src, $dst|$dst, $src}",
1676 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1677 (implicit EFLAGS)]>;
1678 def XOR16mr : I<0x31, MRMDestMem,
1679 (outs), (ins i16mem:$dst, GR16:$src),
1680 "xor{w}\t{$src, $dst|$dst, $src}",
1681 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1682 (implicit EFLAGS)]>,
1684 def XOR32mr : I<0x31, MRMDestMem,
1685 (outs), (ins i32mem:$dst, GR32:$src),
1686 "xor{l}\t{$src, $dst|$dst, $src}",
1687 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1688 (implicit EFLAGS)]>;
1689 def XOR8mi : Ii8<0x80, MRM6m,
1690 (outs), (ins i8mem :$dst, i8imm :$src),
1691 "xor{b}\t{$src, $dst|$dst, $src}",
1692 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1693 (implicit EFLAGS)]>;
1694 def XOR16mi : Ii16<0x81, MRM6m,
1695 (outs), (ins i16mem:$dst, i16imm:$src),
1696 "xor{w}\t{$src, $dst|$dst, $src}",
1697 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1698 (implicit EFLAGS)]>,
1700 def XOR32mi : Ii32<0x81, MRM6m,
1701 (outs), (ins i32mem:$dst, i32imm:$src),
1702 "xor{l}\t{$src, $dst|$dst, $src}",
1703 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1704 (implicit EFLAGS)]>;
1705 def XOR16mi8 : Ii8<0x83, MRM6m,
1706 (outs), (ins i16mem:$dst, i16i8imm :$src),
1707 "xor{w}\t{$src, $dst|$dst, $src}",
1708 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1709 (implicit EFLAGS)]>,
1711 def XOR32mi8 : Ii8<0x83, MRM6m,
1712 (outs), (ins i32mem:$dst, i32i8imm :$src),
1713 "xor{l}\t{$src, $dst|$dst, $src}",
1714 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1715 (implicit EFLAGS)]>;
1716 } // isTwoAddress = 0
1717 } // Defs = [EFLAGS]
1719 // Shift instructions
1720 let Defs = [EFLAGS] in {
1721 let Uses = [CL] in {
1722 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1723 "shl{b}\t{%cl, $dst|$dst, %CL}",
1724 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1725 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1726 "shl{w}\t{%cl, $dst|$dst, %CL}",
1727 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1728 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1729 "shl{l}\t{%cl, $dst|$dst, %CL}",
1730 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1733 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1734 "shl{b}\t{$src2, $dst|$dst, $src2}",
1735 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1736 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1737 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1738 "shl{w}\t{$src2, $dst|$dst, $src2}",
1739 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1740 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1741 "shl{l}\t{$src2, $dst|$dst, $src2}",
1742 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1743 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1745 } // isConvertibleToThreeAddress = 1
1747 let isTwoAddress = 0 in {
1748 let Uses = [CL] in {
1749 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1750 "shl{b}\t{%cl, $dst|$dst, %CL}",
1751 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1752 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1753 "shl{w}\t{%cl, $dst|$dst, %CL}",
1754 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1755 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1756 "shl{l}\t{%cl, $dst|$dst, %CL}",
1757 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1759 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1760 "shl{b}\t{$src, $dst|$dst, $src}",
1761 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1762 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1763 "shl{w}\t{$src, $dst|$dst, $src}",
1764 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1766 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1767 "shl{l}\t{$src, $dst|$dst, $src}",
1768 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1771 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1773 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1774 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1776 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1778 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1780 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1783 let Uses = [CL] in {
1784 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1785 "shr{b}\t{%cl, $dst|$dst, %CL}",
1786 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1787 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1788 "shr{w}\t{%cl, $dst|$dst, %CL}",
1789 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1790 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1791 "shr{l}\t{%cl, $dst|$dst, %CL}",
1792 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1795 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1796 "shr{b}\t{$src2, $dst|$dst, $src2}",
1797 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1798 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1799 "shr{w}\t{$src2, $dst|$dst, $src2}",
1800 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1801 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1802 "shr{l}\t{$src2, $dst|$dst, $src2}",
1803 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1806 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1808 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1809 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1811 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1812 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1814 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1816 let isTwoAddress = 0 in {
1817 let Uses = [CL] in {
1818 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1819 "shr{b}\t{%cl, $dst|$dst, %CL}",
1820 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1821 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1822 "shr{w}\t{%cl, $dst|$dst, %CL}",
1823 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1825 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1826 "shr{l}\t{%cl, $dst|$dst, %CL}",
1827 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1829 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1830 "shr{b}\t{$src, $dst|$dst, $src}",
1831 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1832 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1833 "shr{w}\t{$src, $dst|$dst, $src}",
1834 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1836 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1837 "shr{l}\t{$src, $dst|$dst, $src}",
1838 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1841 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1843 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1844 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1846 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1847 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1849 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1852 let Uses = [CL] in {
1853 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1854 "sar{b}\t{%cl, $dst|$dst, %CL}",
1855 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1856 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1857 "sar{w}\t{%cl, $dst|$dst, %CL}",
1858 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1859 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1860 "sar{l}\t{%cl, $dst|$dst, %CL}",
1861 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1864 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1865 "sar{b}\t{$src2, $dst|$dst, $src2}",
1866 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1867 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1868 "sar{w}\t{$src2, $dst|$dst, $src2}",
1869 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1871 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1872 "sar{l}\t{$src2, $dst|$dst, $src2}",
1873 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1876 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1878 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1879 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1881 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1882 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1884 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1886 let isTwoAddress = 0 in {
1887 let Uses = [CL] in {
1888 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1889 "sar{b}\t{%cl, $dst|$dst, %CL}",
1890 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1891 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1892 "sar{w}\t{%cl, $dst|$dst, %CL}",
1893 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1894 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1895 "sar{l}\t{%cl, $dst|$dst, %CL}",
1896 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1898 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1899 "sar{b}\t{$src, $dst|$dst, $src}",
1900 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1901 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1902 "sar{w}\t{$src, $dst|$dst, $src}",
1903 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1905 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1906 "sar{l}\t{$src, $dst|$dst, $src}",
1907 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1910 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1912 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1913 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1915 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1917 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1919 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1922 // Rotate instructions
1923 // FIXME: provide shorter instructions when imm8 == 1
1924 let Uses = [CL] in {
1925 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1926 "rol{b}\t{%cl, $dst|$dst, %CL}",
1927 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1928 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1929 "rol{w}\t{%cl, $dst|$dst, %CL}",
1930 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1931 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1932 "rol{l}\t{%cl, $dst|$dst, %CL}",
1933 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1936 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1937 "rol{b}\t{$src2, $dst|$dst, $src2}",
1938 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1939 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1940 "rol{w}\t{$src2, $dst|$dst, $src2}",
1941 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1942 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1943 "rol{l}\t{$src2, $dst|$dst, $src2}",
1944 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1947 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1949 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1950 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1952 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1953 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1955 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1957 let isTwoAddress = 0 in {
1958 let Uses = [CL] in {
1959 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1960 "rol{b}\t{%cl, $dst|$dst, %CL}",
1961 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
1962 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1963 "rol{w}\t{%cl, $dst|$dst, %CL}",
1964 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1965 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1966 "rol{l}\t{%cl, $dst|$dst, %CL}",
1967 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1969 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
1970 "rol{b}\t{$src, $dst|$dst, $src}",
1971 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1972 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
1973 "rol{w}\t{$src, $dst|$dst, $src}",
1974 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1976 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
1977 "rol{l}\t{$src, $dst|$dst, $src}",
1978 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1981 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
1983 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1984 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
1986 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1988 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
1990 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1993 let Uses = [CL] in {
1994 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
1995 "ror{b}\t{%cl, $dst|$dst, %CL}",
1996 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
1997 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
1998 "ror{w}\t{%cl, $dst|$dst, %CL}",
1999 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
2000 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
2001 "ror{l}\t{%cl, $dst|$dst, %CL}",
2002 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2005 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
2006 "ror{b}\t{$src2, $dst|$dst, $src2}",
2007 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
2008 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
2009 "ror{w}\t{$src2, $dst|$dst, $src2}",
2010 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
2011 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
2012 "ror{l}\t{$src2, $dst|$dst, $src2}",
2013 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2016 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
2018 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
2019 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
2021 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
2022 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
2024 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2026 let isTwoAddress = 0 in {
2027 let Uses = [CL] in {
2028 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
2029 "ror{b}\t{%cl, $dst|$dst, %CL}",
2030 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
2031 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
2032 "ror{w}\t{%cl, $dst|$dst, %CL}",
2033 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
2034 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
2035 "ror{l}\t{%cl, $dst|$dst, %CL}",
2036 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2038 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
2039 "ror{b}\t{$src, $dst|$dst, $src}",
2040 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2041 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
2042 "ror{w}\t{$src, $dst|$dst, $src}",
2043 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2045 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
2046 "ror{l}\t{$src, $dst|$dst, $src}",
2047 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2050 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
2052 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
2053 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
2055 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2057 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
2059 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2064 // Double shift instructions (generalizations of rotate)
2065 let Uses = [CL] in {
2066 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2067 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2068 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
2069 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2070 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2071 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
2072 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2073 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2074 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
2076 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2077 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2078 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
2082 let isCommutable = 1 in { // These instructions commute to each other.
2083 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
2084 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2085 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2086 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2089 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
2090 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
2091 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2092 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2095 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
2096 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2097 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2098 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2101 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
2102 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
2103 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2104 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2109 let isTwoAddress = 0 in {
2110 let Uses = [CL] in {
2111 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2112 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2113 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
2115 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2116 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2117 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
2120 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
2121 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2122 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2123 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2124 (i8 imm:$src3)), addr:$dst)]>,
2126 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
2127 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
2128 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2129 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2130 (i8 imm:$src3)), addr:$dst)]>,
2133 let Uses = [CL] in {
2134 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2135 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2136 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
2137 addr:$dst)]>, TB, OpSize;
2138 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2139 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
2140 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
2141 addr:$dst)]>, TB, OpSize;
2143 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
2144 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2145 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2146 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2147 (i8 imm:$src3)), addr:$dst)]>,
2149 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
2150 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
2151 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
2152 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2153 (i8 imm:$src3)), addr:$dst)]>,
2156 } // Defs = [EFLAGS]
2160 let Defs = [EFLAGS] in {
2161 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
2162 // Register-Register Addition
2163 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2164 (ins GR8 :$src1, GR8 :$src2),
2165 "add{b}\t{$src2, $dst|$dst, $src2}",
2166 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
2167 (implicit EFLAGS)]>;
2169 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2170 // Register-Register Addition
2171 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2172 (ins GR16:$src1, GR16:$src2),
2173 "add{w}\t{$src2, $dst|$dst, $src2}",
2174 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2175 (implicit EFLAGS)]>, OpSize;
2176 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2177 (ins GR32:$src1, GR32:$src2),
2178 "add{l}\t{$src2, $dst|$dst, $src2}",
2179 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2180 (implicit EFLAGS)]>;
2181 } // end isConvertibleToThreeAddress
2182 } // end isCommutable
2184 // Register-Memory Addition
2185 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2186 (ins GR8 :$src1, i8mem :$src2),
2187 "add{b}\t{$src2, $dst|$dst, $src2}",
2188 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2189 (implicit EFLAGS)]>;
2190 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2191 (ins GR16:$src1, i16mem:$src2),
2192 "add{w}\t{$src2, $dst|$dst, $src2}",
2193 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2194 (implicit EFLAGS)]>, OpSize;
2195 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2196 (ins GR32:$src1, i32mem:$src2),
2197 "add{l}\t{$src2, $dst|$dst, $src2}",
2198 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2199 (implicit EFLAGS)]>;
2201 // Register-Integer Addition
2202 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2203 "add{b}\t{$src2, $dst|$dst, $src2}",
2204 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2205 (implicit EFLAGS)]>;
2207 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2208 // Register-Integer Addition
2209 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2210 (ins GR16:$src1, i16imm:$src2),
2211 "add{w}\t{$src2, $dst|$dst, $src2}",
2212 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2213 (implicit EFLAGS)]>, OpSize;
2214 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2215 (ins GR32:$src1, i32imm:$src2),
2216 "add{l}\t{$src2, $dst|$dst, $src2}",
2217 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2218 (implicit EFLAGS)]>;
2219 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2220 (ins GR16:$src1, i16i8imm:$src2),
2221 "add{w}\t{$src2, $dst|$dst, $src2}",
2222 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2223 (implicit EFLAGS)]>, OpSize;
2224 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2225 (ins GR32:$src1, i32i8imm:$src2),
2226 "add{l}\t{$src2, $dst|$dst, $src2}",
2227 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2228 (implicit EFLAGS)]>;
2231 let isTwoAddress = 0 in {
2232 // Memory-Register Addition
2233 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2234 "add{b}\t{$src2, $dst|$dst, $src2}",
2235 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2236 (implicit EFLAGS)]>;
2237 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2238 "add{w}\t{$src2, $dst|$dst, $src2}",
2239 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2240 (implicit EFLAGS)]>, OpSize;
2241 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2242 "add{l}\t{$src2, $dst|$dst, $src2}",
2243 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2244 (implicit EFLAGS)]>;
2245 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2246 "add{b}\t{$src2, $dst|$dst, $src2}",
2247 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2248 (implicit EFLAGS)]>;
2249 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2250 "add{w}\t{$src2, $dst|$dst, $src2}",
2251 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2252 (implicit EFLAGS)]>, OpSize;
2253 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2254 "add{l}\t{$src2, $dst|$dst, $src2}",
2255 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2256 (implicit EFLAGS)]>;
2257 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2258 "add{w}\t{$src2, $dst|$dst, $src2}",
2259 [(store (add (load addr:$dst), i16immSExt8:$src2),
2261 (implicit EFLAGS)]>, OpSize;
2262 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2263 "add{l}\t{$src2, $dst|$dst, $src2}",
2264 [(store (add (load addr:$dst), i32immSExt8:$src2),
2266 (implicit EFLAGS)]>;
2269 let Uses = [EFLAGS] in {
2270 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2271 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2272 "adc{l}\t{$src2, $dst|$dst, $src2}",
2273 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2275 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2276 "adc{l}\t{$src2, $dst|$dst, $src2}",
2277 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2278 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2279 "adc{l}\t{$src2, $dst|$dst, $src2}",
2280 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2281 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2282 "adc{l}\t{$src2, $dst|$dst, $src2}",
2283 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2285 let isTwoAddress = 0 in {
2286 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2287 "adc{l}\t{$src2, $dst|$dst, $src2}",
2288 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2289 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2290 "adc{l}\t{$src2, $dst|$dst, $src2}",
2291 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2292 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2293 "adc{l}\t{$src2, $dst|$dst, $src2}",
2294 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2296 } // Uses = [EFLAGS]
2298 // Register-Register Subtraction
2299 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2300 "sub{b}\t{$src2, $dst|$dst, $src2}",
2301 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2302 (implicit EFLAGS)]>;
2303 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2304 "sub{w}\t{$src2, $dst|$dst, $src2}",
2305 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2306 (implicit EFLAGS)]>, OpSize;
2307 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2308 "sub{l}\t{$src2, $dst|$dst, $src2}",
2309 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2310 (implicit EFLAGS)]>;
2312 // Register-Memory Subtraction
2313 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2314 (ins GR8 :$src1, i8mem :$src2),
2315 "sub{b}\t{$src2, $dst|$dst, $src2}",
2316 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2317 (implicit EFLAGS)]>;
2318 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2319 (ins GR16:$src1, i16mem:$src2),
2320 "sub{w}\t{$src2, $dst|$dst, $src2}",
2321 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2322 (implicit EFLAGS)]>, OpSize;
2323 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2324 (ins GR32:$src1, i32mem:$src2),
2325 "sub{l}\t{$src2, $dst|$dst, $src2}",
2326 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2327 (implicit EFLAGS)]>;
2329 // Register-Integer Subtraction
2330 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2331 (ins GR8:$src1, i8imm:$src2),
2332 "sub{b}\t{$src2, $dst|$dst, $src2}",
2333 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2334 (implicit EFLAGS)]>;
2335 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2336 (ins GR16:$src1, i16imm:$src2),
2337 "sub{w}\t{$src2, $dst|$dst, $src2}",
2338 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2339 (implicit EFLAGS)]>, OpSize;
2340 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2341 (ins GR32:$src1, i32imm:$src2),
2342 "sub{l}\t{$src2, $dst|$dst, $src2}",
2343 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2344 (implicit EFLAGS)]>;
2345 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2346 (ins GR16:$src1, i16i8imm:$src2),
2347 "sub{w}\t{$src2, $dst|$dst, $src2}",
2348 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2349 (implicit EFLAGS)]>, OpSize;
2350 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2351 (ins GR32:$src1, i32i8imm:$src2),
2352 "sub{l}\t{$src2, $dst|$dst, $src2}",
2353 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2354 (implicit EFLAGS)]>;
2356 let isTwoAddress = 0 in {
2357 // Memory-Register Subtraction
2358 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2359 "sub{b}\t{$src2, $dst|$dst, $src2}",
2360 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2361 (implicit EFLAGS)]>;
2362 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2363 "sub{w}\t{$src2, $dst|$dst, $src2}",
2364 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2365 (implicit EFLAGS)]>, OpSize;
2366 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2367 "sub{l}\t{$src2, $dst|$dst, $src2}",
2368 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2369 (implicit EFLAGS)]>;
2371 // Memory-Integer Subtraction
2372 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2373 "sub{b}\t{$src2, $dst|$dst, $src2}",
2374 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2375 (implicit EFLAGS)]>;
2376 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2377 "sub{w}\t{$src2, $dst|$dst, $src2}",
2378 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2379 (implicit EFLAGS)]>, OpSize;
2380 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2381 "sub{l}\t{$src2, $dst|$dst, $src2}",
2382 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2383 (implicit EFLAGS)]>;
2384 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2385 "sub{w}\t{$src2, $dst|$dst, $src2}",
2386 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2388 (implicit EFLAGS)]>, OpSize;
2389 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2390 "sub{l}\t{$src2, $dst|$dst, $src2}",
2391 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2393 (implicit EFLAGS)]>;
2396 let Uses = [EFLAGS] in {
2397 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2398 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2399 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2401 let isTwoAddress = 0 in {
2402 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2403 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2404 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2405 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2406 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2407 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2408 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2409 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2410 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2411 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2412 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2413 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2415 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2416 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2417 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2418 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2419 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2420 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2421 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2422 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2423 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2424 } // Uses = [EFLAGS]
2425 } // Defs = [EFLAGS]
2427 let Defs = [EFLAGS] in {
2428 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2429 // Register-Register Signed Integer Multiply
2430 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2431 "imul{w}\t{$src2, $dst|$dst, $src2}",
2432 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2433 (implicit EFLAGS)]>, TB, OpSize;
2434 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2435 "imul{l}\t{$src2, $dst|$dst, $src2}",
2436 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2437 (implicit EFLAGS)]>, TB;
2440 // Register-Memory Signed Integer Multiply
2441 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2442 (ins GR16:$src1, i16mem:$src2),
2443 "imul{w}\t{$src2, $dst|$dst, $src2}",
2444 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2445 (implicit EFLAGS)]>, TB, OpSize;
2446 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2447 "imul{l}\t{$src2, $dst|$dst, $src2}",
2448 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2449 (implicit EFLAGS)]>, TB;
2450 } // Defs = [EFLAGS]
2451 } // end Two Address instructions
2453 // Suprisingly enough, these are not two address instructions!
2454 let Defs = [EFLAGS] in {
2455 // Register-Integer Signed Integer Multiply
2456 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2457 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2458 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2459 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2460 (implicit EFLAGS)]>, OpSize;
2461 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2462 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2463 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2464 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2465 (implicit EFLAGS)]>;
2466 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2467 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2468 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2469 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2470 (implicit EFLAGS)]>, OpSize;
2471 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2472 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2473 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2474 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2475 (implicit EFLAGS)]>;
2477 // Memory-Integer Signed Integer Multiply
2478 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2479 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2480 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2481 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2482 (implicit EFLAGS)]>, OpSize;
2483 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2484 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2485 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2486 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2487 (implicit EFLAGS)]>;
2488 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2489 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2490 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2491 [(set GR16:$dst, (mul (load addr:$src1),
2492 i16immSExt8:$src2)),
2493 (implicit EFLAGS)]>, OpSize;
2494 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2495 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2496 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2497 [(set GR32:$dst, (mul (load addr:$src1),
2498 i32immSExt8:$src2)),
2499 (implicit EFLAGS)]>;
2500 } // Defs = [EFLAGS]
2502 //===----------------------------------------------------------------------===//
2503 // Test instructions are just like AND, except they don't generate a result.
2505 let Defs = [EFLAGS] in {
2506 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2507 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2508 "test{b}\t{$src2, $src1|$src1, $src2}",
2509 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2510 (implicit EFLAGS)]>;
2511 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2512 "test{w}\t{$src2, $src1|$src1, $src2}",
2513 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2514 (implicit EFLAGS)]>,
2516 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2517 "test{l}\t{$src2, $src1|$src1, $src2}",
2518 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2519 (implicit EFLAGS)]>;
2522 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2523 "test{b}\t{$src2, $src1|$src1, $src2}",
2524 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2525 (implicit EFLAGS)]>;
2526 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2527 "test{w}\t{$src2, $src1|$src1, $src2}",
2528 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2529 (implicit EFLAGS)]>, OpSize;
2530 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2531 "test{l}\t{$src2, $src1|$src1, $src2}",
2532 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2533 (implicit EFLAGS)]>;
2535 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2536 (outs), (ins GR8:$src1, i8imm:$src2),
2537 "test{b}\t{$src2, $src1|$src1, $src2}",
2538 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2539 (implicit EFLAGS)]>;
2540 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2541 (outs), (ins GR16:$src1, i16imm:$src2),
2542 "test{w}\t{$src2, $src1|$src1, $src2}",
2543 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2544 (implicit EFLAGS)]>, OpSize;
2545 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2546 (outs), (ins GR32:$src1, i32imm:$src2),
2547 "test{l}\t{$src2, $src1|$src1, $src2}",
2548 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2549 (implicit EFLAGS)]>;
2551 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2552 (outs), (ins i8mem:$src1, i8imm:$src2),
2553 "test{b}\t{$src2, $src1|$src1, $src2}",
2554 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2555 (implicit EFLAGS)]>;
2556 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2557 (outs), (ins i16mem:$src1, i16imm:$src2),
2558 "test{w}\t{$src2, $src1|$src1, $src2}",
2559 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2560 (implicit EFLAGS)]>, OpSize;
2561 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2562 (outs), (ins i32mem:$src1, i32imm:$src2),
2563 "test{l}\t{$src2, $src1|$src1, $src2}",
2564 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2565 (implicit EFLAGS)]>;
2566 } // Defs = [EFLAGS]
2569 // Condition code ops, incl. set if equal/not equal/...
2570 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2571 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2572 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2573 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2575 let Uses = [EFLAGS] in {
2576 def SETEr : I<0x94, MRM0r,
2577 (outs GR8 :$dst), (ins),
2579 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2581 def SETEm : I<0x94, MRM0m,
2582 (outs), (ins i8mem:$dst),
2584 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2587 def SETNEr : I<0x95, MRM0r,
2588 (outs GR8 :$dst), (ins),
2590 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2592 def SETNEm : I<0x95, MRM0m,
2593 (outs), (ins i8mem:$dst),
2595 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2598 def SETLr : I<0x9C, MRM0r,
2599 (outs GR8 :$dst), (ins),
2601 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2602 TB; // GR8 = < signed
2603 def SETLm : I<0x9C, MRM0m,
2604 (outs), (ins i8mem:$dst),
2606 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2607 TB; // [mem8] = < signed
2609 def SETGEr : I<0x9D, MRM0r,
2610 (outs GR8 :$dst), (ins),
2612 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2613 TB; // GR8 = >= signed
2614 def SETGEm : I<0x9D, MRM0m,
2615 (outs), (ins i8mem:$dst),
2617 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2618 TB; // [mem8] = >= signed
2620 def SETLEr : I<0x9E, MRM0r,
2621 (outs GR8 :$dst), (ins),
2623 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2624 TB; // GR8 = <= signed
2625 def SETLEm : I<0x9E, MRM0m,
2626 (outs), (ins i8mem:$dst),
2628 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2629 TB; // [mem8] = <= signed
2631 def SETGr : I<0x9F, MRM0r,
2632 (outs GR8 :$dst), (ins),
2634 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2635 TB; // GR8 = > signed
2636 def SETGm : I<0x9F, MRM0m,
2637 (outs), (ins i8mem:$dst),
2639 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2640 TB; // [mem8] = > signed
2642 def SETBr : I<0x92, MRM0r,
2643 (outs GR8 :$dst), (ins),
2645 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2646 TB; // GR8 = < unsign
2647 def SETBm : I<0x92, MRM0m,
2648 (outs), (ins i8mem:$dst),
2650 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2651 TB; // [mem8] = < unsign
2653 def SETAEr : I<0x93, MRM0r,
2654 (outs GR8 :$dst), (ins),
2656 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2657 TB; // GR8 = >= unsign
2658 def SETAEm : I<0x93, MRM0m,
2659 (outs), (ins i8mem:$dst),
2661 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2662 TB; // [mem8] = >= unsign
2664 def SETBEr : I<0x96, MRM0r,
2665 (outs GR8 :$dst), (ins),
2667 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2668 TB; // GR8 = <= unsign
2669 def SETBEm : I<0x96, MRM0m,
2670 (outs), (ins i8mem:$dst),
2672 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2673 TB; // [mem8] = <= unsign
2675 def SETAr : I<0x97, MRM0r,
2676 (outs GR8 :$dst), (ins),
2678 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2679 TB; // GR8 = > signed
2680 def SETAm : I<0x97, MRM0m,
2681 (outs), (ins i8mem:$dst),
2683 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2684 TB; // [mem8] = > signed
2686 def SETSr : I<0x98, MRM0r,
2687 (outs GR8 :$dst), (ins),
2689 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2690 TB; // GR8 = <sign bit>
2691 def SETSm : I<0x98, MRM0m,
2692 (outs), (ins i8mem:$dst),
2694 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2695 TB; // [mem8] = <sign bit>
2696 def SETNSr : I<0x99, MRM0r,
2697 (outs GR8 :$dst), (ins),
2699 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2700 TB; // GR8 = !<sign bit>
2701 def SETNSm : I<0x99, MRM0m,
2702 (outs), (ins i8mem:$dst),
2704 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2705 TB; // [mem8] = !<sign bit>
2707 def SETPr : I<0x9A, MRM0r,
2708 (outs GR8 :$dst), (ins),
2710 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2712 def SETPm : I<0x9A, MRM0m,
2713 (outs), (ins i8mem:$dst),
2715 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2716 TB; // [mem8] = parity
2717 def SETNPr : I<0x9B, MRM0r,
2718 (outs GR8 :$dst), (ins),
2720 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2721 TB; // GR8 = not parity
2722 def SETNPm : I<0x9B, MRM0m,
2723 (outs), (ins i8mem:$dst),
2725 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2726 TB; // [mem8] = not parity
2728 def SETOr : I<0x90, MRM0r,
2729 (outs GR8 :$dst), (ins),
2731 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2732 TB; // GR8 = overflow
2733 def SETOm : I<0x90, MRM0m,
2734 (outs), (ins i8mem:$dst),
2736 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2737 TB; // [mem8] = overflow
2738 def SETNOr : I<0x91, MRM0r,
2739 (outs GR8 :$dst), (ins),
2741 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2742 TB; // GR8 = not overflow
2743 def SETNOm : I<0x91, MRM0m,
2744 (outs), (ins i8mem:$dst),
2746 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2747 TB; // [mem8] = not overflow
2748 } // Uses = [EFLAGS]
2751 // Integer comparisons
2752 let Defs = [EFLAGS] in {
2753 def CMP8rr : I<0x38, MRMDestReg,
2754 (outs), (ins GR8 :$src1, GR8 :$src2),
2755 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2756 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2757 def CMP16rr : I<0x39, MRMDestReg,
2758 (outs), (ins GR16:$src1, GR16:$src2),
2759 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2760 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2761 def CMP32rr : I<0x39, MRMDestReg,
2762 (outs), (ins GR32:$src1, GR32:$src2),
2763 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2764 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2765 def CMP8mr : I<0x38, MRMDestMem,
2766 (outs), (ins i8mem :$src1, GR8 :$src2),
2767 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2768 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2769 (implicit EFLAGS)]>;
2770 def CMP16mr : I<0x39, MRMDestMem,
2771 (outs), (ins i16mem:$src1, GR16:$src2),
2772 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2773 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2774 (implicit EFLAGS)]>, OpSize;
2775 def CMP32mr : I<0x39, MRMDestMem,
2776 (outs), (ins i32mem:$src1, GR32:$src2),
2777 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2778 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2779 (implicit EFLAGS)]>;
2780 def CMP8rm : I<0x3A, MRMSrcMem,
2781 (outs), (ins GR8 :$src1, i8mem :$src2),
2782 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2783 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2784 (implicit EFLAGS)]>;
2785 def CMP16rm : I<0x3B, MRMSrcMem,
2786 (outs), (ins GR16:$src1, i16mem:$src2),
2787 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2788 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2789 (implicit EFLAGS)]>, OpSize;
2790 def CMP32rm : I<0x3B, MRMSrcMem,
2791 (outs), (ins GR32:$src1, i32mem:$src2),
2792 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2793 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2794 (implicit EFLAGS)]>;
2795 def CMP8ri : Ii8<0x80, MRM7r,
2796 (outs), (ins GR8:$src1, i8imm:$src2),
2797 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2798 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
2799 def CMP16ri : Ii16<0x81, MRM7r,
2800 (outs), (ins GR16:$src1, i16imm:$src2),
2801 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2802 [(X86cmp GR16:$src1, imm:$src2),
2803 (implicit EFLAGS)]>, OpSize;
2804 def CMP32ri : Ii32<0x81, MRM7r,
2805 (outs), (ins GR32:$src1, i32imm:$src2),
2806 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2807 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
2808 def CMP8mi : Ii8 <0x80, MRM7m,
2809 (outs), (ins i8mem :$src1, i8imm :$src2),
2810 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2811 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2812 (implicit EFLAGS)]>;
2813 def CMP16mi : Ii16<0x81, MRM7m,
2814 (outs), (ins i16mem:$src1, i16imm:$src2),
2815 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2816 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2817 (implicit EFLAGS)]>, OpSize;
2818 def CMP32mi : Ii32<0x81, MRM7m,
2819 (outs), (ins i32mem:$src1, i32imm:$src2),
2820 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2821 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2822 (implicit EFLAGS)]>;
2823 def CMP16ri8 : Ii8<0x83, MRM7r,
2824 (outs), (ins GR16:$src1, i16i8imm:$src2),
2825 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2826 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2827 (implicit EFLAGS)]>, OpSize;
2828 def CMP16mi8 : Ii8<0x83, MRM7m,
2829 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2830 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2831 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2832 (implicit EFLAGS)]>, OpSize;
2833 def CMP32mi8 : Ii8<0x83, MRM7m,
2834 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2835 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2836 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2837 (implicit EFLAGS)]>;
2838 def CMP32ri8 : Ii8<0x83, MRM7r,
2839 (outs), (ins GR32:$src1, i32i8imm:$src2),
2840 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2841 [(X86cmp GR32:$src1, i32immSExt8:$src2),
2842 (implicit EFLAGS)]>;
2843 } // Defs = [EFLAGS]
2846 // TODO: BTC, BTR, and BTS
2847 let Defs = [EFLAGS] in {
2848 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2849 "bt{w}\t{$src2, $src1|$src1, $src2}",
2850 [(X86bt GR16:$src1, GR16:$src2),
2851 (implicit EFLAGS)]>, OpSize, TB;
2852 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2853 "bt{l}\t{$src2, $src1|$src1, $src2}",
2854 [(X86bt GR32:$src1, GR32:$src2),
2855 (implicit EFLAGS)]>, TB;
2857 // Unlike with the register+register form, the memory+register form of the
2858 // bt instruction does not ignore the high bits of the index. From ISel's
2859 // perspective, this is pretty bizarre. Disable these instructions for now.
2860 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2861 // "bt{w}\t{$src2, $src1|$src1, $src2}",
2862 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
2863 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2864 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2865 // "bt{l}\t{$src2, $src1|$src1, $src2}",
2866 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
2867 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
2869 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2870 "bt{w}\t{$src2, $src1|$src1, $src2}",
2871 [(X86bt GR16:$src1, i16immSExt8:$src2),
2872 (implicit EFLAGS)]>, OpSize, TB;
2873 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2874 "bt{l}\t{$src2, $src1|$src1, $src2}",
2875 [(X86bt GR32:$src1, i32immSExt8:$src2),
2876 (implicit EFLAGS)]>, TB;
2877 // Note that these instructions don't need FastBTMem because that
2878 // only applies when the other operand is in a register. When it's
2879 // an immediate, bt is still fast.
2880 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2881 "bt{w}\t{$src2, $src1|$src1, $src2}",
2882 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2883 (implicit EFLAGS)]>, OpSize, TB;
2884 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2885 "bt{l}\t{$src2, $src1|$src1, $src2}",
2886 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2887 (implicit EFLAGS)]>, TB;
2888 } // Defs = [EFLAGS]
2890 // Sign/Zero extenders
2891 // Use movsbl intead of movsbw; we don't care about the high 16 bits
2892 // of the register here. This has a smaller encoding and avoids a
2893 // partial-register update.
2894 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2895 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2896 [(set GR16:$dst, (sext GR8:$src))]>, TB;
2897 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2898 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2899 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
2900 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2901 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2902 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2903 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2904 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2905 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2906 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2907 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2908 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2909 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2910 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2911 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2913 // Use movzbl intead of movzbw; we don't care about the high 16 bits
2914 // of the register here. This has a smaller encoding and avoids a
2915 // partial-register update.
2916 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2917 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2918 [(set GR16:$dst, (zext GR8:$src))]>, TB;
2919 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2920 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2921 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
2922 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2923 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2924 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2925 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2926 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2927 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2928 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2929 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2930 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2931 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2932 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2933 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2935 // These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
2936 // except that they use GR32_NOREX for the output operand register class
2937 // instead of GR32. This allows them to operate on h registers on x86-64.
2938 def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
2939 (outs GR32_NOREX:$dst), (ins GR8:$src),
2940 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
2943 def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
2944 (outs GR32_NOREX:$dst), (ins i8mem:$src),
2945 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
2948 let neverHasSideEffects = 1 in {
2949 let Defs = [AX], Uses = [AL] in
2950 def CBW : I<0x98, RawFrm, (outs), (ins),
2951 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2952 let Defs = [EAX], Uses = [AX] in
2953 def CWDE : I<0x98, RawFrm, (outs), (ins),
2954 "{cwtl|cwde}", []>; // EAX = signext(AX)
2956 let Defs = [AX,DX], Uses = [AX] in
2957 def CWD : I<0x99, RawFrm, (outs), (ins),
2958 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2959 let Defs = [EAX,EDX], Uses = [EAX] in
2960 def CDQ : I<0x99, RawFrm, (outs), (ins),
2961 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2964 //===----------------------------------------------------------------------===//
2965 // Alias Instructions
2966 //===----------------------------------------------------------------------===//
2968 // Alias instructions that map movr0 to xor.
2969 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2970 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2971 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
2972 "xor{b}\t$dst, $dst",
2973 [(set GR8:$dst, 0)]>;
2974 // Use xorl instead of xorw since we don't care about the high 16 bits,
2975 // it's smaller, and it avoids a partial-register update.
2976 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
2977 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2978 [(set GR16:$dst, 0)]>;
2979 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
2980 "xor{l}\t$dst, $dst",
2981 [(set GR32:$dst, 0)]>;
2984 //===----------------------------------------------------------------------===//
2985 // Thread Local Storage Instructions
2988 // All calls clobber the non-callee saved registers. ESP is marked as
2989 // a use to prevent stack-pointer assignments that appear immediately
2990 // before calls from potentially appearing dead.
2991 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
2992 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
2993 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
2994 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
2995 Uses = [ESP, EBX] in
2996 def TLS_addr32 : I<0, Pseudo, (outs), (ins i32imm:$sym),
2997 "leal\t${sym:mem}(,%ebx,1), %eax; "
2998 "call\t___tls_get_addr@PLT",
2999 [(X86tlsaddr tglobaltlsaddr:$sym)]>,
3000 Requires<[In32BitMode]>;
3002 let AddedComplexity = 5 in
3003 def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3004 "movl\t%gs:$src, $dst",
3005 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3007 //===----------------------------------------------------------------------===//
3008 // DWARF Pseudo Instructions
3011 def DWARF_LOC : I<0, Pseudo, (outs),
3012 (ins i32imm:$line, i32imm:$col, i32imm:$file),
3013 ".loc\t${file:debug} ${line:debug} ${col:debug}",
3014 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3017 //===----------------------------------------------------------------------===//
3018 // EH Pseudo Instructions
3020 let isTerminator = 1, isReturn = 1, isBarrier = 1,
3022 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
3023 "ret\t#eh_return, addr: $addr",
3024 [(X86ehret GR32:$addr)]>;
3028 //===----------------------------------------------------------------------===//
3032 // Atomic swap. These are just normal xchg instructions. But since a memory
3033 // operand is referenced, the atomicity is ensured.
3034 let Constraints = "$val = $dst" in {
3035 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3036 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3037 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3038 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3039 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3040 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3042 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3043 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3044 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3047 // Atomic compare and swap.
3048 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
3049 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
3051 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
3052 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
3054 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
3055 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
3058 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3061 let Defs = [AX, EFLAGS], Uses = [AX] in {
3062 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
3064 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
3065 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
3067 let Defs = [AL, EFLAGS], Uses = [AL] in {
3068 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
3070 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
3071 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
3074 // Atomic exchange and add
3075 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3076 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3078 "xadd{l}\t{$val, $ptr|$ptr, $val}",
3079 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
3081 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3083 "xadd{w}\t{$val, $ptr|$ptr, $val}",
3084 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
3086 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3088 "xadd{b}\t{$val, $ptr|$ptr, $val}",
3089 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
3093 // Atomic exchange, and, or, xor
3094 let Constraints = "$val = $dst", Defs = [EFLAGS],
3095 usesCustomDAGSchedInserter = 1 in {
3096 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3097 "#ATOMAND32 PSEUDO!",
3098 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
3099 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3100 "#ATOMOR32 PSEUDO!",
3101 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
3102 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3103 "#ATOMXOR32 PSEUDO!",
3104 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
3105 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3106 "#ATOMNAND32 PSEUDO!",
3107 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
3108 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3109 "#ATOMMIN32 PSEUDO!",
3110 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
3111 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3112 "#ATOMMAX32 PSEUDO!",
3113 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
3114 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3115 "#ATOMUMIN32 PSEUDO!",
3116 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
3117 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
3118 "#ATOMUMAX32 PSEUDO!",
3119 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
3121 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3122 "#ATOMAND16 PSEUDO!",
3123 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
3124 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3125 "#ATOMOR16 PSEUDO!",
3126 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
3127 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3128 "#ATOMXOR16 PSEUDO!",
3129 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
3130 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3131 "#ATOMNAND16 PSEUDO!",
3132 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
3133 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3134 "#ATOMMIN16 PSEUDO!",
3135 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
3136 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3137 "#ATOMMAX16 PSEUDO!",
3138 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
3139 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3140 "#ATOMUMIN16 PSEUDO!",
3141 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
3142 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
3143 "#ATOMUMAX16 PSEUDO!",
3144 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
3146 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3147 "#ATOMAND8 PSEUDO!",
3148 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
3149 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3151 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
3152 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3153 "#ATOMXOR8 PSEUDO!",
3154 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
3155 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
3156 "#ATOMNAND8 PSEUDO!",
3157 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3160 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3161 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3162 Uses = [EAX, EBX, ECX, EDX],
3163 mayLoad = 1, mayStore = 1,
3164 usesCustomDAGSchedInserter = 1 in {
3165 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3166 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3167 "#ATOMAND6432 PSEUDO!", []>;
3168 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3169 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3170 "#ATOMOR6432 PSEUDO!", []>;
3171 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3172 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3173 "#ATOMXOR6432 PSEUDO!", []>;
3174 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3175 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3176 "#ATOMNAND6432 PSEUDO!", []>;
3177 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3178 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3179 "#ATOMADD6432 PSEUDO!", []>;
3180 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3181 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3182 "#ATOMSUB6432 PSEUDO!", []>;
3183 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3184 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3185 "#ATOMSWAP6432 PSEUDO!", []>;
3188 //===----------------------------------------------------------------------===//
3189 // Non-Instruction Patterns
3190 //===----------------------------------------------------------------------===//
3192 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3193 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3194 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3195 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3196 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3197 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3199 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3200 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3201 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3202 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3203 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3204 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3205 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3206 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3208 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3209 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3210 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3211 (MOV32mi addr:$dst, texternalsym:$src)>;
3215 def : Pat<(X86tailcall GR32:$dst),
3218 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
3220 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
3223 def : Pat<(X86tcret GR32:$dst, imm:$off),
3224 (TCRETURNri GR32:$dst, imm:$off)>;
3226 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3227 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3229 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3230 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3232 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3233 (CALLpcrel32 tglobaladdr:$dst)>;
3234 def : Pat<(X86call (i32 texternalsym:$dst)),
3235 (CALLpcrel32 texternalsym:$dst)>;
3237 // X86 specific add which produces a flag.
3238 def : Pat<(addc GR32:$src1, GR32:$src2),
3239 (ADD32rr GR32:$src1, GR32:$src2)>;
3240 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3241 (ADD32rm GR32:$src1, addr:$src2)>;
3242 def : Pat<(addc GR32:$src1, imm:$src2),
3243 (ADD32ri GR32:$src1, imm:$src2)>;
3244 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3245 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3247 def : Pat<(subc GR32:$src1, GR32:$src2),
3248 (SUB32rr GR32:$src1, GR32:$src2)>;
3249 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3250 (SUB32rm GR32:$src1, addr:$src2)>;
3251 def : Pat<(subc GR32:$src1, imm:$src2),
3252 (SUB32ri GR32:$src1, imm:$src2)>;
3253 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3254 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3258 // TEST R,R is smaller than CMP R,0
3259 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3260 (TEST8rr GR8:$src1, GR8:$src1)>;
3261 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3262 (TEST16rr GR16:$src1, GR16:$src1)>;
3263 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3264 (TEST32rr GR32:$src1, GR32:$src1)>;
3266 // Conditional moves with folded loads with operands swapped and conditions
3268 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3269 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3270 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3271 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3272 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3273 (CMOVB16rm GR16:$src2, addr:$src1)>;
3274 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3275 (CMOVB32rm GR32:$src2, addr:$src1)>;
3276 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3277 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3278 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3279 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3280 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3281 (CMOVE16rm GR16:$src2, addr:$src1)>;
3282 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3283 (CMOVE32rm GR32:$src2, addr:$src1)>;
3284 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3285 (CMOVA16rm GR16:$src2, addr:$src1)>;
3286 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3287 (CMOVA32rm GR32:$src2, addr:$src1)>;
3288 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3289 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3290 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3291 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3292 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3293 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3294 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3295 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3296 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3297 (CMOVL16rm GR16:$src2, addr:$src1)>;
3298 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3299 (CMOVL32rm GR32:$src2, addr:$src1)>;
3300 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3301 (CMOVG16rm GR16:$src2, addr:$src1)>;
3302 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3303 (CMOVG32rm GR32:$src2, addr:$src1)>;
3304 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3305 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3306 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3307 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3308 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3309 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3310 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3311 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3312 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3313 (CMOVP16rm GR16:$src2, addr:$src1)>;
3314 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3315 (CMOVP32rm GR32:$src2, addr:$src1)>;
3316 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3317 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3318 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3319 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3320 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3321 (CMOVS16rm GR16:$src2, addr:$src1)>;
3322 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3323 (CMOVS32rm GR32:$src2, addr:$src1)>;
3324 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3325 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3326 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3327 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3328 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3329 (CMOVO16rm GR16:$src2, addr:$src1)>;
3330 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3331 (CMOVO32rm GR32:$src2, addr:$src1)>;
3333 // zextload bool -> zextload byte
3334 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3335 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3336 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3338 // extload bool -> extload byte
3339 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3340 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3341 Requires<[In32BitMode]>;
3342 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3343 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3344 Requires<[In32BitMode]>;
3345 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3346 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3349 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3350 Requires<[In32BitMode]>;
3351 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3352 Requires<[In32BitMode]>;
3353 def : Pat<(i32 (anyext GR16:$src)),
3354 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
3356 // (and (i32 load), 255) -> (zextload i8)
3357 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3358 (MOVZX32rm8 addr:$src)>;
3359 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3360 (MOVZX32rm16 addr:$src)>;
3362 //===----------------------------------------------------------------------===//
3364 //===----------------------------------------------------------------------===//
3366 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3367 // +128 doesn't, so in this special case use a sub instead of an add.
3368 def : Pat<(add GR16:$src1, 128),
3369 (SUB16ri8 GR16:$src1, -128)>;
3370 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3371 (SUB16mi8 addr:$dst, -128)>;
3372 def : Pat<(add GR32:$src1, 128),
3373 (SUB32ri8 GR32:$src1, -128)>;
3374 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3375 (SUB32mi8 addr:$dst, -128)>;
3377 // r & (2^16-1) ==> movz
3378 def : Pat<(and GR32:$src1, 0xffff),
3379 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
3380 // r & (2^8-1) ==> movz
3381 def : Pat<(and GR32:$src1, 0xff),
3382 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
3384 Requires<[In32BitMode]>;
3385 // r & (2^8-1) ==> movz
3386 def : Pat<(and GR16:$src1, 0xff),
3387 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
3389 Requires<[In32BitMode]>;
3391 // sext_inreg patterns
3392 def : Pat<(sext_inreg GR32:$src, i16),
3393 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3394 def : Pat<(sext_inreg GR32:$src, i8),
3395 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3397 Requires<[In32BitMode]>;
3398 def : Pat<(sext_inreg GR16:$src, i8),
3399 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3401 Requires<[In32BitMode]>;
3404 def : Pat<(i16 (trunc GR32:$src)),
3405 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
3406 def : Pat<(i8 (trunc GR32:$src)),
3407 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3409 Requires<[In32BitMode]>;
3410 def : Pat<(i8 (trunc GR16:$src)),
3411 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3413 Requires<[In32BitMode]>;
3415 // h-register tricks
3416 def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
3417 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3418 x86_subreg_8bit_hi)>,
3419 Requires<[In32BitMode]>;
3420 def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
3421 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3422 x86_subreg_8bit_hi)>,
3423 Requires<[In32BitMode]>;
3424 def : Pat<(srl_su GR16:$src, (i8 8)),
3427 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3428 x86_subreg_8bit_hi)),
3430 Requires<[In32BitMode]>;
3431 def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
3432 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
3433 x86_subreg_8bit_hi))>,
3434 Requires<[In32BitMode]>;
3436 // (shl x, 1) ==> (add x, x)
3437 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3438 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3439 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3441 // (shl x (and y, 31)) ==> (shl x, y)
3442 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3443 (SHL8rCL GR8:$src1)>;
3444 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3445 (SHL16rCL GR16:$src1)>;
3446 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3447 (SHL32rCL GR32:$src1)>;
3448 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3449 (SHL8mCL addr:$dst)>;
3450 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3451 (SHL16mCL addr:$dst)>;
3452 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3453 (SHL32mCL addr:$dst)>;
3455 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3456 (SHR8rCL GR8:$src1)>;
3457 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3458 (SHR16rCL GR16:$src1)>;
3459 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3460 (SHR32rCL GR32:$src1)>;
3461 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3462 (SHR8mCL addr:$dst)>;
3463 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3464 (SHR16mCL addr:$dst)>;
3465 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3466 (SHR32mCL addr:$dst)>;
3468 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3469 (SAR8rCL GR8:$src1)>;
3470 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3471 (SAR16rCL GR16:$src1)>;
3472 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3473 (SAR32rCL GR32:$src1)>;
3474 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3475 (SAR8mCL addr:$dst)>;
3476 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3477 (SAR16mCL addr:$dst)>;
3478 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3479 (SAR32mCL addr:$dst)>;
3481 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3482 def : Pat<(or (srl GR32:$src1, CL:$amt),
3483 (shl GR32:$src2, (sub 32, CL:$amt))),
3484 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3486 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3487 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3488 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3490 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3491 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3492 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3494 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3495 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3497 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3499 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3500 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3502 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3503 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3504 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3506 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3507 def : Pat<(or (shl GR32:$src1, CL:$amt),
3508 (srl GR32:$src2, (sub 32, CL:$amt))),
3509 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3511 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3512 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3513 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3515 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3516 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3517 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3519 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3520 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3522 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3524 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3525 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3527 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3528 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3529 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3531 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3532 def : Pat<(or (srl GR16:$src1, CL:$amt),
3533 (shl GR16:$src2, (sub 16, CL:$amt))),
3534 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3536 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3537 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3538 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3540 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3541 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3542 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3544 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3545 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3547 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3549 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3550 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3552 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3553 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3554 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3556 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3557 def : Pat<(or (shl GR16:$src1, CL:$amt),
3558 (srl GR16:$src2, (sub 16, CL:$amt))),
3559 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3561 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3562 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3563 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3565 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3566 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3567 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3569 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3570 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3572 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3574 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3575 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3577 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3578 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3579 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3581 //===----------------------------------------------------------------------===//
3582 // EFLAGS-defining Patterns
3583 //===----------------------------------------------------------------------===//
3585 // Register-Register Addition with EFLAGS result
3586 def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
3588 (ADD8rr GR8:$src1, GR8:$src2)>;
3590 // Register-Register Addition with EFLAGS result
3591 def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
3593 (ADD16rr GR16:$src1, GR16:$src2)>;
3594 def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
3596 (ADD32rr GR32:$src1, GR32:$src2)>;
3598 // Register-Memory Addition with EFLAGS result
3599 def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
3601 (ADD8rm GR8:$src1, addr:$src2)>;
3602 def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
3604 (ADD16rm GR16:$src1, addr:$src2)>;
3605 def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
3607 (ADD32rm GR32:$src1, addr:$src2)>;
3609 // Register-Integer Addition with EFLAGS result
3610 def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
3612 (ADD8ri GR8:$src1, imm:$src2)>;
3614 // Register-Integer Addition with EFLAGS result
3615 def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
3617 (ADD16ri GR16:$src1, imm:$src2)>;
3618 def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
3620 (ADD32ri GR32:$src1, imm:$src2)>;
3621 def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
3623 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3624 def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
3626 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3628 // Memory-Register Addition with EFLAGS result
3629 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
3632 (ADD8mr addr:$dst, GR8:$src2)>;
3633 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
3636 (ADD16mr addr:$dst, GR16:$src2)>;
3637 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
3640 (ADD32mr addr:$dst, GR32:$src2)>;
3641 def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
3644 (ADD8mi addr:$dst, imm:$src2)>;
3645 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
3648 (ADD16mi addr:$dst, imm:$src2)>;
3649 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
3652 (ADD32mi addr:$dst, imm:$src2)>;
3653 def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3656 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3657 def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3660 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3662 // Register-Register Subtraction with EFLAGS result
3663 def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
3665 (SUB8rr GR8:$src1, GR8:$src2)>;
3666 def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
3668 (SUB16rr GR16:$src1, GR16:$src2)>;
3669 def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
3671 (SUB32rr GR32:$src1, GR32:$src2)>;
3673 // Register-Memory Subtraction with EFLAGS result
3674 def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
3676 (SUB8rm GR8:$src1, addr:$src2)>;
3677 def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
3679 (SUB16rm GR16:$src1, addr:$src2)>;
3680 def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
3682 (SUB32rm GR32:$src1, addr:$src2)>;
3684 // Register-Integer Subtraction with EFLAGS result
3685 def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
3687 (SUB8ri GR8:$src1, imm:$src2)>;
3688 def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
3690 (SUB16ri GR16:$src1, imm:$src2)>;
3691 def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
3693 (SUB32ri GR32:$src1, imm:$src2)>;
3694 def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
3696 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3697 def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
3699 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3701 // Memory-Register Subtraction with EFLAGS result
3702 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
3705 (SUB8mr addr:$dst, GR8:$src2)>;
3706 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
3709 (SUB16mr addr:$dst, GR16:$src2)>;
3710 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
3713 (SUB32mr addr:$dst, GR32:$src2)>;
3715 // Memory-Integer Subtraction with EFLAGS result
3716 def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
3719 (SUB8mi addr:$dst, imm:$src2)>;
3720 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
3723 (SUB16mi addr:$dst, imm:$src2)>;
3724 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
3727 (SUB32mi addr:$dst, imm:$src2)>;
3728 def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
3731 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3732 def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
3735 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3738 // Register-Register Signed Integer Multiply with EFLAGS result
3739 def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
3741 (IMUL16rr GR16:$src1, GR16:$src2)>;
3742 def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
3744 (IMUL32rr GR32:$src1, GR32:$src2)>;
3746 // Register-Memory Signed Integer Multiply with EFLAGS result
3747 def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
3749 (IMUL16rm GR16:$src1, addr:$src2)>;
3750 def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
3752 (IMUL32rm GR32:$src1, addr:$src2)>;
3754 // Register-Integer Signed Integer Multiply with EFLAGS result
3755 def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
3757 (IMUL16rri GR16:$src1, imm:$src2)>;
3758 def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
3760 (IMUL32rri GR32:$src1, imm:$src2)>;
3761 def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
3763 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
3764 def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
3766 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3768 // Memory-Integer Signed Integer Multiply with EFLAGS result
3769 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
3771 (IMUL16rmi addr:$src1, imm:$src2)>;
3772 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
3774 (IMUL32rmi addr:$src1, imm:$src2)>;
3775 def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
3777 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
3778 def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
3780 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3782 // Optimize multiply by 2 with EFLAGS result.
3783 let AddedComplexity = 2 in {
3784 def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
3786 (ADD16rr GR16:$src1, GR16:$src1)>;
3788 def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
3790 (ADD32rr GR32:$src1, GR32:$src1)>;
3793 // INC and DEC with EFLAGS result. Note that these do not set CF.
3794 def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3796 def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3799 def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3801 def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3805 def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
3806 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
3807 def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3809 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
3810 def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
3811 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
3812 def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3814 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
3816 def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
3817 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
3818 def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3820 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
3821 def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
3822 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
3823 def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3825 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
3828 //===----------------------------------------------------------------------===//
3829 // Floating Point Stack Support
3830 //===----------------------------------------------------------------------===//
3832 include "X86InstrFPStack.td"
3834 //===----------------------------------------------------------------------===//
3836 //===----------------------------------------------------------------------===//
3838 include "X86Instr64bit.td"
3840 //===----------------------------------------------------------------------===//
3841 // XMM Floating point support (requires SSE / SSE2)
3842 //===----------------------------------------------------------------------===//
3844 include "X86InstrSSE.td"
3846 //===----------------------------------------------------------------------===//
3847 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3848 //===----------------------------------------------------------------------===//
3850 include "X86InstrMMX.td"