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 def SDTUnaryArithOvf : SDTypeProfile<1, 1,
32 def SDTBinaryArithOvf : SDTypeProfile<1, 2,
33 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
36 def SDTX86BrCond : SDTypeProfile<0, 3,
37 [SDTCisVT<0, OtherVT>,
38 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
40 def SDTX86SetCC : SDTypeProfile<1, 2,
42 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
44 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
46 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
48 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
49 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
50 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
52 def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
53 def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
56 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
58 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
60 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
62 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
64 def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
66 def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
68 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
70 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
72 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
73 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
74 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
75 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
77 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
79 def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
81 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
82 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
84 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
86 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
87 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
89 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
90 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
92 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
93 [SDNPHasChain, SDNPMayStore,
94 SDNPMayLoad, SDNPMemOperand]>;
95 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
96 [SDNPHasChain, SDNPMayStore,
97 SDNPMayLoad, SDNPMemOperand]>;
98 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
99 [SDNPHasChain, SDNPMayStore,
100 SDNPMayLoad, SDNPMemOperand]>;
101 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
102 [SDNPHasChain, SDNPMayStore,
103 SDNPMayLoad, SDNPMemOperand]>;
104 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
105 [SDNPHasChain, SDNPMayStore,
106 SDNPMayLoad, SDNPMemOperand]>;
107 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
108 [SDNPHasChain, SDNPMayStore,
109 SDNPMayLoad, SDNPMemOperand]>;
110 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
111 [SDNPHasChain, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
113 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
114 [SDNPHasChain, SDNPOptInFlag]>;
116 def X86callseq_start :
117 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
118 [SDNPHasChain, SDNPOutFlag]>;
120 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
121 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
123 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
124 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
126 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
127 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
129 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
130 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
131 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
135 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
136 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
138 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
139 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
141 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
142 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
143 def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
145 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
148 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
149 [SDNPHasChain, SDNPOptInFlag]>;
151 def X86add_ovf : SDNode<"X86ISD::ADD", SDTBinaryArithOvf>;
152 def X86sub_ovf : SDNode<"X86ISD::SUB", SDTBinaryArithOvf>;
153 def X86smul_ovf : SDNode<"X86ISD::SMUL", SDTBinaryArithOvf>;
154 def X86umul_ovf : SDNode<"X86ISD::UMUL", SDTUnaryArithOvf>;
156 //===----------------------------------------------------------------------===//
157 // X86 Operand Definitions.
160 // *mem - Operand definitions for the funky X86 addressing mode operands.
162 class X86MemOperand<string printMethod> : Operand<iPTR> {
163 let PrintMethod = printMethod;
164 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
167 def i8mem : X86MemOperand<"printi8mem">;
168 def i16mem : X86MemOperand<"printi16mem">;
169 def i32mem : X86MemOperand<"printi32mem">;
170 def i64mem : X86MemOperand<"printi64mem">;
171 def i128mem : X86MemOperand<"printi128mem">;
172 def f32mem : X86MemOperand<"printf32mem">;
173 def f64mem : X86MemOperand<"printf64mem">;
174 def f80mem : X86MemOperand<"printf80mem">;
175 def f128mem : X86MemOperand<"printf128mem">;
177 def lea32mem : Operand<i32> {
178 let PrintMethod = "printi32mem";
179 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
182 def SSECC : Operand<i8> {
183 let PrintMethod = "printSSECC";
186 def piclabel: Operand<i32> {
187 let PrintMethod = "printPICLabel";
190 // A couple of more descriptive operand definitions.
191 // 16-bits but only 8 bits are significant.
192 def i16i8imm : Operand<i16>;
193 // 32-bits but only 8 bits are significant.
194 def i32i8imm : Operand<i32>;
196 // Branch targets have OtherVT type.
197 def brtarget : Operand<OtherVT>;
199 //===----------------------------------------------------------------------===//
200 // X86 Complex Pattern Definitions.
203 // Define X86 specific addressing mode.
204 def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
205 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
206 [add, mul, shl, or, frameindex], []>;
208 //===----------------------------------------------------------------------===//
209 // X86 Instruction Predicate Definitions.
210 def HasMMX : Predicate<"Subtarget->hasMMX()">;
211 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
212 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
213 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
214 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
215 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
216 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
217 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
218 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
219 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
220 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
221 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
222 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
223 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
224 def OptForSpeed : Predicate<"!OptForSize">;
225 def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
227 //===----------------------------------------------------------------------===//
228 // X86 Instruction Format Definitions.
231 include "X86InstrFormats.td"
233 //===----------------------------------------------------------------------===//
234 // Pattern fragments...
237 // X86 specific condition code. These correspond to CondCode in
238 // X86InstrInfo.h. They must be kept in synch.
239 def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
240 def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
241 def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
242 def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
243 def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
244 def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
245 def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
246 def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
247 def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
248 def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
249 def X86_COND_NO : PatLeaf<(i8 10)>;
250 def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
251 def X86_COND_NS : PatLeaf<(i8 12)>;
252 def X86_COND_O : PatLeaf<(i8 13)>;
253 def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
254 def X86_COND_S : PatLeaf<(i8 15)>;
256 def i16immSExt8 : PatLeaf<(i16 imm), [{
257 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
258 // sign extended field.
259 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
262 def i32immSExt8 : PatLeaf<(i32 imm), [{
263 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
264 // sign extended field.
265 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
268 // Helper fragments for loads.
269 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
270 // known to be 32-bit aligned or better. Ditto for i8 to i16.
271 def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
272 LoadSDNode *LD = cast<LoadSDNode>(N);
273 ISD::LoadExtType ExtType = LD->getExtensionType();
274 if (ExtType == ISD::NON_EXTLOAD)
276 if (ExtType == ISD::EXTLOAD)
277 return LD->getAlignment() >= 2 && !LD->isVolatile();
281 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
282 LoadSDNode *LD = cast<LoadSDNode>(N);
283 ISD::LoadExtType ExtType = LD->getExtensionType();
284 if (ExtType == ISD::EXTLOAD)
285 return LD->getAlignment() >= 2 && !LD->isVolatile();
289 def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
290 LoadSDNode *LD = cast<LoadSDNode>(N);
291 ISD::LoadExtType ExtType = LD->getExtensionType();
292 if (ExtType == ISD::NON_EXTLOAD)
294 if (ExtType == ISD::EXTLOAD)
295 return LD->getAlignment() >= 4 && !LD->isVolatile();
299 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
300 LoadSDNode *LD = cast<LoadSDNode>(N);
301 if (LD->isVolatile())
303 ISD::LoadExtType ExtType = LD->getExtensionType();
304 if (ExtType == ISD::NON_EXTLOAD)
306 if (ExtType == ISD::EXTLOAD)
307 return LD->getAlignment() >= 4;
311 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
312 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
314 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
315 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
316 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
318 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
319 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
320 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
322 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
323 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
324 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
325 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
326 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
327 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
329 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
330 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
331 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
332 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
333 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
334 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
337 // An 'and' node with a single use.
338 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
339 return N->hasOneUse();
342 // 'shld' and 'shrd' instruction patterns. Note that even though these have
343 // the srl and shl in their patterns, the C++ code must still check for them,
344 // because predicates are tested before children nodes are explored.
346 def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
347 (or (srl node:$src1, node:$amt1),
348 (shl node:$src2, node:$amt2)), [{
349 assert(N->getOpcode() == ISD::OR);
350 return N->getOperand(0).getOpcode() == ISD::SRL &&
351 N->getOperand(1).getOpcode() == ISD::SHL &&
352 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
353 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
354 N->getOperand(0).getConstantOperandVal(1) ==
355 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
358 def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
359 (or (shl node:$src1, node:$amt1),
360 (srl node:$src2, node:$amt2)), [{
361 assert(N->getOpcode() == ISD::OR);
362 return N->getOperand(0).getOpcode() == ISD::SHL &&
363 N->getOperand(1).getOpcode() == ISD::SRL &&
364 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
365 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
366 N->getOperand(0).getConstantOperandVal(1) ==
367 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
370 //===----------------------------------------------------------------------===//
371 // Instruction list...
374 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
375 // a stack adjustment and the codegen must know that they may modify the stack
376 // pointer before prolog-epilog rewriting occurs.
377 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
378 // sub / add which can clobber EFLAGS.
379 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
380 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
382 [(X86callseq_start timm:$amt)]>,
383 Requires<[In32BitMode]>;
384 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
386 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
387 Requires<[In32BitMode]>;
391 let neverHasSideEffects = 1 in
392 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
395 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
396 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
397 "call\t$label\n\tpop{l}\t$reg", []>;
399 //===----------------------------------------------------------------------===//
400 // Control Flow Instructions...
403 // Return instructions.
404 let isTerminator = 1, isReturn = 1, isBarrier = 1,
405 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
406 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
409 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
411 [(X86retflag imm:$amt)]>;
414 // All branches are RawFrm, Void, Branch, and Terminators
415 let isBranch = 1, isTerminator = 1 in
416 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
417 I<opcode, RawFrm, (outs), ins, asm, pattern>;
419 let isBranch = 1, isBarrier = 1 in
420 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
423 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
424 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
425 [(brind GR32:$dst)]>;
426 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
427 [(brind (loadi32 addr:$dst))]>;
430 // Conditional branches
431 let Uses = [EFLAGS] in {
432 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
433 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
434 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
435 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
436 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
437 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
438 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
439 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
440 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
441 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
442 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
443 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
445 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
446 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
447 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
448 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
449 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
450 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
451 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
452 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
454 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
455 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
456 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
457 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
458 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
459 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
460 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
461 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
462 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
463 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
464 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
465 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
468 //===----------------------------------------------------------------------===//
469 // Call Instructions...
472 // All calls clobber the non-callee saved registers. ESP is marked as
473 // a use to prevent stack-pointer assignments that appear immediately
474 // before calls from potentially appearing dead. Uses for argument
475 // registers are added manually.
476 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
477 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
478 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
479 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
481 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
482 "call\t${dst:call}", []>;
483 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
484 "call\t{*}$dst", [(X86call GR32:$dst)]>;
485 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
486 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
491 def TAILCALL : I<0, Pseudo, (outs), (ins),
495 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
496 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
497 "#TC_RETURN $dst $offset",
500 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
501 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
502 "#TC_RETURN $dst $offset",
505 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
507 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
509 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
510 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
512 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
513 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
514 "jmp\t{*}$dst # TAILCALL", []>;
516 //===----------------------------------------------------------------------===//
517 // Miscellaneous Instructions...
519 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
520 def LEAVE : I<0xC9, RawFrm,
521 (outs), (ins), "leave", []>;
523 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
525 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
528 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
531 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
532 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
533 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
534 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
536 let isTwoAddress = 1 in // GR32 = bswap GR32
537 def BSWAP32r : I<0xC8, AddRegFrm,
538 (outs GR32:$dst), (ins GR32:$src),
540 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
543 // Bit scan instructions.
544 let Defs = [EFLAGS] in {
545 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
546 "bsf{w}\t{$src, $dst|$dst, $src}",
547 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
548 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
549 "bsf{w}\t{$src, $dst|$dst, $src}",
550 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
551 (implicit EFLAGS)]>, TB;
552 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
553 "bsf{l}\t{$src, $dst|$dst, $src}",
554 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
555 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
556 "bsf{l}\t{$src, $dst|$dst, $src}",
557 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
558 (implicit EFLAGS)]>, TB;
560 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
561 "bsr{w}\t{$src, $dst|$dst, $src}",
562 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
563 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
564 "bsr{w}\t{$src, $dst|$dst, $src}",
565 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
566 (implicit EFLAGS)]>, TB;
567 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
568 "bsr{l}\t{$src, $dst|$dst, $src}",
569 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
570 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
571 "bsr{l}\t{$src, $dst|$dst, $src}",
572 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
573 (implicit EFLAGS)]>, TB;
576 let neverHasSideEffects = 1 in
577 def LEA16r : I<0x8D, MRMSrcMem,
578 (outs GR16:$dst), (ins i32mem:$src),
579 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
580 let isReMaterializable = 1 in
581 def LEA32r : I<0x8D, MRMSrcMem,
582 (outs GR32:$dst), (ins lea32mem:$src),
583 "lea{l}\t{$src|$dst}, {$dst|$src}",
584 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
586 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
587 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
588 [(X86rep_movs i8)]>, REP;
589 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
590 [(X86rep_movs i16)]>, REP, OpSize;
591 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
592 [(X86rep_movs i32)]>, REP;
595 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
596 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
597 [(X86rep_stos i8)]>, REP;
598 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
599 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
600 [(X86rep_stos i16)]>, REP, OpSize;
601 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
602 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
603 [(X86rep_stos i32)]>, REP;
605 let Defs = [RAX, RDX] in
606 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
609 let isBarrier = 1, hasCtrlDep = 1 in {
610 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
613 //===----------------------------------------------------------------------===//
614 // Input/Output Instructions...
616 let Defs = [AL], Uses = [DX] in
617 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
618 "in{b}\t{%dx, %al|%AL, %DX}", []>;
619 let Defs = [AX], Uses = [DX] in
620 def IN16rr : I<0xED, RawFrm, (outs), (ins),
621 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
622 let Defs = [EAX], Uses = [DX] in
623 def IN32rr : I<0xED, RawFrm, (outs), (ins),
624 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
627 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
628 "in{b}\t{$port, %al|%AL, $port}", []>;
630 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
631 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
633 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
634 "in{l}\t{$port, %eax|%EAX, $port}", []>;
636 let Uses = [DX, AL] in
637 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
638 "out{b}\t{%al, %dx|%DX, %AL}", []>;
639 let Uses = [DX, AX] in
640 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
641 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
642 let Uses = [DX, EAX] in
643 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
644 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
647 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
648 "out{b}\t{%al, $port|$port, %AL}", []>;
650 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
651 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
653 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
654 "out{l}\t{%eax, $port|$port, %EAX}", []>;
656 //===----------------------------------------------------------------------===//
657 // Move Instructions...
659 let neverHasSideEffects = 1 in {
660 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
661 "mov{b}\t{$src, $dst|$dst, $src}", []>;
662 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
663 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
664 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
665 "mov{l}\t{$src, $dst|$dst, $src}", []>;
667 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
668 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
669 "mov{b}\t{$src, $dst|$dst, $src}",
670 [(set GR8:$dst, imm:$src)]>;
671 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
672 "mov{w}\t{$src, $dst|$dst, $src}",
673 [(set GR16:$dst, imm:$src)]>, OpSize;
674 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
675 "mov{l}\t{$src, $dst|$dst, $src}",
676 [(set GR32:$dst, imm:$src)]>;
678 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
679 "mov{b}\t{$src, $dst|$dst, $src}",
680 [(store (i8 imm:$src), addr:$dst)]>;
681 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
682 "mov{w}\t{$src, $dst|$dst, $src}",
683 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
684 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
685 "mov{l}\t{$src, $dst|$dst, $src}",
686 [(store (i32 imm:$src), addr:$dst)]>;
688 let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
689 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
690 "mov{b}\t{$src, $dst|$dst, $src}",
691 [(set GR8:$dst, (load addr:$src))]>;
692 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
693 "mov{w}\t{$src, $dst|$dst, $src}",
694 [(set GR16:$dst, (load addr:$src))]>, OpSize;
695 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
696 "mov{l}\t{$src, $dst|$dst, $src}",
697 [(set GR32:$dst, (load addr:$src))]>;
700 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
701 "mov{b}\t{$src, $dst|$dst, $src}",
702 [(store GR8:$src, addr:$dst)]>;
703 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
704 "mov{w}\t{$src, $dst|$dst, $src}",
705 [(store GR16:$src, addr:$dst)]>, OpSize;
706 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
707 "mov{l}\t{$src, $dst|$dst, $src}",
708 [(store GR32:$src, addr:$dst)]>;
710 //===----------------------------------------------------------------------===//
711 // Fixed-Register Multiplication and Division Instructions...
714 // Extra precision multiplication
715 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
716 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
717 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
718 // This probably ought to be moved to a def : Pat<> if the
719 // syntax can be accepted.
720 [(set AL, (mul AL, GR8:$src)),
721 (implicit EFLAGS)]>; // AL,AH = AL*GR8
723 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
724 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
726 []>, OpSize; // AX,DX = AX*GR16
728 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
729 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
731 []>; // EAX,EDX = EAX*GR32
733 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
734 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
736 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
737 // This probably ought to be moved to a def : Pat<> if the
738 // syntax can be accepted.
739 [(set AL, (mul AL, (loadi8 addr:$src))),
740 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
742 let mayLoad = 1, neverHasSideEffects = 1 in {
743 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
744 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
746 []>, OpSize; // AX,DX = AX*[mem16]
748 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
749 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
751 []>; // EAX,EDX = EAX*[mem32]
754 let neverHasSideEffects = 1 in {
755 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
756 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
758 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
759 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
760 OpSize; // AX,DX = AX*GR16
761 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
762 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
763 // EAX,EDX = EAX*GR32
765 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
766 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
767 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
768 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
769 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
770 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
771 let Defs = [EAX,EDX], Uses = [EAX] in
772 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
773 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
775 } // neverHasSideEffects
777 // unsigned division/remainder
778 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
779 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
781 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
782 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
783 "div{w}\t$src", []>, OpSize;
784 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
785 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
788 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
789 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
791 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
792 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
793 "div{w}\t$src", []>, OpSize;
794 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
795 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
799 // Signed division/remainder.
800 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
801 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
802 "idiv{b}\t$src", []>;
803 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
804 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
805 "idiv{w}\t$src", []>, OpSize;
806 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
807 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
808 "idiv{l}\t$src", []>;
809 let mayLoad = 1, mayLoad = 1 in {
810 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
811 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
812 "idiv{b}\t$src", []>;
813 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
814 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
815 "idiv{w}\t$src", []>, OpSize;
816 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
817 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
818 "idiv{l}\t$src", []>;
821 //===----------------------------------------------------------------------===//
822 // Two address Instructions.
824 let isTwoAddress = 1 in {
827 let Uses = [EFLAGS] in {
828 let isCommutable = 1 in {
829 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
830 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
831 "cmovb\t{$src2, $dst|$dst, $src2}",
832 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
833 X86_COND_B, EFLAGS))]>,
835 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
836 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
837 "cmovb\t{$src2, $dst|$dst, $src2}",
838 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
839 X86_COND_B, EFLAGS))]>,
841 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
842 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
843 "cmovae\t{$src2, $dst|$dst, $src2}",
844 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
845 X86_COND_AE, EFLAGS))]>,
847 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
848 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
849 "cmovae\t{$src2, $dst|$dst, $src2}",
850 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
851 X86_COND_AE, EFLAGS))]>,
853 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
854 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
855 "cmove\t{$src2, $dst|$dst, $src2}",
856 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
857 X86_COND_E, EFLAGS))]>,
859 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
860 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
861 "cmove\t{$src2, $dst|$dst, $src2}",
862 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
863 X86_COND_E, EFLAGS))]>,
865 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
866 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
867 "cmovne\t{$src2, $dst|$dst, $src2}",
868 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
869 X86_COND_NE, EFLAGS))]>,
871 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
872 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
873 "cmovne\t{$src2, $dst|$dst, $src2}",
874 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
875 X86_COND_NE, EFLAGS))]>,
877 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
878 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
879 "cmovbe\t{$src2, $dst|$dst, $src2}",
880 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
881 X86_COND_BE, EFLAGS))]>,
883 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
884 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
885 "cmovbe\t{$src2, $dst|$dst, $src2}",
886 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
887 X86_COND_BE, EFLAGS))]>,
889 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
890 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
891 "cmova\t{$src2, $dst|$dst, $src2}",
892 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
893 X86_COND_A, EFLAGS))]>,
895 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
896 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
897 "cmova\t{$src2, $dst|$dst, $src2}",
898 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
899 X86_COND_A, EFLAGS))]>,
901 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
902 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
903 "cmovl\t{$src2, $dst|$dst, $src2}",
904 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
905 X86_COND_L, EFLAGS))]>,
907 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
908 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
909 "cmovl\t{$src2, $dst|$dst, $src2}",
910 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
911 X86_COND_L, EFLAGS))]>,
913 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
914 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
915 "cmovge\t{$src2, $dst|$dst, $src2}",
916 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
917 X86_COND_GE, EFLAGS))]>,
919 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
920 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
921 "cmovge\t{$src2, $dst|$dst, $src2}",
922 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
923 X86_COND_GE, EFLAGS))]>,
925 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
926 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
927 "cmovle\t{$src2, $dst|$dst, $src2}",
928 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
929 X86_COND_LE, EFLAGS))]>,
931 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
932 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
933 "cmovle\t{$src2, $dst|$dst, $src2}",
934 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
935 X86_COND_LE, EFLAGS))]>,
937 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
938 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
939 "cmovg\t{$src2, $dst|$dst, $src2}",
940 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
941 X86_COND_G, EFLAGS))]>,
943 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
944 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
945 "cmovg\t{$src2, $dst|$dst, $src2}",
946 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
947 X86_COND_G, EFLAGS))]>,
949 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
950 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
951 "cmovs\t{$src2, $dst|$dst, $src2}",
952 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
953 X86_COND_S, EFLAGS))]>,
955 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
956 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
957 "cmovs\t{$src2, $dst|$dst, $src2}",
958 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
959 X86_COND_S, EFLAGS))]>,
961 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
962 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
963 "cmovns\t{$src2, $dst|$dst, $src2}",
964 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
965 X86_COND_NS, EFLAGS))]>,
967 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
968 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
969 "cmovns\t{$src2, $dst|$dst, $src2}",
970 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
971 X86_COND_NS, EFLAGS))]>,
973 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
974 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
975 "cmovp\t{$src2, $dst|$dst, $src2}",
976 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
977 X86_COND_P, EFLAGS))]>,
979 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
980 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
981 "cmovp\t{$src2, $dst|$dst, $src2}",
982 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
983 X86_COND_P, EFLAGS))]>,
985 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
986 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
987 "cmovnp\t{$src2, $dst|$dst, $src2}",
988 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
989 X86_COND_NP, EFLAGS))]>,
991 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
992 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
993 "cmovnp\t{$src2, $dst|$dst, $src2}",
994 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
995 X86_COND_NP, EFLAGS))]>,
997 def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
998 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
999 "cmovo\t{$src2, $dst|$dst, $src2}",
1000 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1001 X86_COND_O, EFLAGS))]>,
1003 def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1004 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1005 "cmovo\t{$src2, $dst|$dst, $src2}",
1006 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1007 X86_COND_O, EFLAGS))]>,
1009 def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1010 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1011 "cmovno\t{$src2, $dst|$dst, $src2}",
1012 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1013 X86_COND_NO, EFLAGS))]>,
1015 def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1016 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1017 "cmovno\t{$src2, $dst|$dst, $src2}",
1018 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1019 X86_COND_NO, EFLAGS))]>,
1021 } // isCommutable = 1
1023 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1024 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1025 "cmovb\t{$src2, $dst|$dst, $src2}",
1026 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1027 X86_COND_B, EFLAGS))]>,
1029 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1030 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1031 "cmovb\t{$src2, $dst|$dst, $src2}",
1032 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1033 X86_COND_B, EFLAGS))]>,
1035 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1036 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1037 "cmovae\t{$src2, $dst|$dst, $src2}",
1038 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1039 X86_COND_AE, EFLAGS))]>,
1041 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1042 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1043 "cmovae\t{$src2, $dst|$dst, $src2}",
1044 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1045 X86_COND_AE, EFLAGS))]>,
1047 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1048 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1049 "cmove\t{$src2, $dst|$dst, $src2}",
1050 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1051 X86_COND_E, EFLAGS))]>,
1053 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1054 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1055 "cmove\t{$src2, $dst|$dst, $src2}",
1056 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1057 X86_COND_E, EFLAGS))]>,
1059 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1060 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1061 "cmovne\t{$src2, $dst|$dst, $src2}",
1062 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1063 X86_COND_NE, EFLAGS))]>,
1065 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1066 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1067 "cmovne\t{$src2, $dst|$dst, $src2}",
1068 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1069 X86_COND_NE, EFLAGS))]>,
1071 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1072 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1073 "cmovbe\t{$src2, $dst|$dst, $src2}",
1074 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1075 X86_COND_BE, EFLAGS))]>,
1077 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1078 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1079 "cmovbe\t{$src2, $dst|$dst, $src2}",
1080 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1081 X86_COND_BE, EFLAGS))]>,
1083 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1084 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1085 "cmova\t{$src2, $dst|$dst, $src2}",
1086 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1087 X86_COND_A, EFLAGS))]>,
1089 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1090 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1091 "cmova\t{$src2, $dst|$dst, $src2}",
1092 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1093 X86_COND_A, EFLAGS))]>,
1095 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1096 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1097 "cmovl\t{$src2, $dst|$dst, $src2}",
1098 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1099 X86_COND_L, EFLAGS))]>,
1101 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1102 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1103 "cmovl\t{$src2, $dst|$dst, $src2}",
1104 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1105 X86_COND_L, EFLAGS))]>,
1107 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1108 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1109 "cmovge\t{$src2, $dst|$dst, $src2}",
1110 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1111 X86_COND_GE, EFLAGS))]>,
1113 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1114 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1115 "cmovge\t{$src2, $dst|$dst, $src2}",
1116 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1117 X86_COND_GE, EFLAGS))]>,
1119 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1120 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1121 "cmovle\t{$src2, $dst|$dst, $src2}",
1122 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1123 X86_COND_LE, EFLAGS))]>,
1125 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1126 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1127 "cmovle\t{$src2, $dst|$dst, $src2}",
1128 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1129 X86_COND_LE, EFLAGS))]>,
1131 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1132 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1133 "cmovg\t{$src2, $dst|$dst, $src2}",
1134 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1135 X86_COND_G, EFLAGS))]>,
1137 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1138 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1139 "cmovg\t{$src2, $dst|$dst, $src2}",
1140 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1141 X86_COND_G, EFLAGS))]>,
1143 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1144 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1145 "cmovs\t{$src2, $dst|$dst, $src2}",
1146 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1147 X86_COND_S, EFLAGS))]>,
1149 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1150 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1151 "cmovs\t{$src2, $dst|$dst, $src2}",
1152 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1153 X86_COND_S, EFLAGS))]>,
1155 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1156 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1157 "cmovns\t{$src2, $dst|$dst, $src2}",
1158 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1159 X86_COND_NS, EFLAGS))]>,
1161 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1162 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1163 "cmovns\t{$src2, $dst|$dst, $src2}",
1164 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1165 X86_COND_NS, EFLAGS))]>,
1167 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1168 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1169 "cmovp\t{$src2, $dst|$dst, $src2}",
1170 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1171 X86_COND_P, EFLAGS))]>,
1173 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1174 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1175 "cmovp\t{$src2, $dst|$dst, $src2}",
1176 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1177 X86_COND_P, EFLAGS))]>,
1179 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1180 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1181 "cmovnp\t{$src2, $dst|$dst, $src2}",
1182 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1183 X86_COND_NP, EFLAGS))]>,
1185 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1186 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1187 "cmovnp\t{$src2, $dst|$dst, $src2}",
1188 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1189 X86_COND_NP, EFLAGS))]>,
1191 def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1192 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1193 "cmovo\t{$src2, $dst|$dst, $src2}",
1194 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1195 X86_COND_O, EFLAGS))]>,
1197 def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1198 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1199 "cmovo\t{$src2, $dst|$dst, $src2}",
1200 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1201 X86_COND_O, EFLAGS))]>,
1203 def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1204 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1205 "cmovno\t{$src2, $dst|$dst, $src2}",
1206 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1207 X86_COND_NO, EFLAGS))]>,
1209 def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1210 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1211 "cmovno\t{$src2, $dst|$dst, $src2}",
1212 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1213 X86_COND_NO, EFLAGS))]>,
1215 } // Uses = [EFLAGS]
1218 // unary instructions
1219 let CodeSize = 2 in {
1220 let Defs = [EFLAGS] in {
1221 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1222 [(set GR8:$dst, (ineg GR8:$src))]>;
1223 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1224 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1225 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1226 [(set GR32:$dst, (ineg GR32:$src))]>;
1227 let isTwoAddress = 0 in {
1228 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1229 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1230 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1231 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1232 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1233 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1236 } // Defs = [EFLAGS]
1238 // Match xor -1 to not. Favors these over a move imm + xor to save code size.
1239 let AddedComplexity = 15 in {
1240 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1241 [(set GR8:$dst, (not GR8:$src))]>;
1242 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1243 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1244 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1245 [(set GR32:$dst, (not GR32:$src))]>;
1247 let isTwoAddress = 0 in {
1248 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1249 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1250 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1251 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1252 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1253 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1257 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1258 let Defs = [EFLAGS] in {
1260 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1261 [(set GR8:$dst, (add GR8:$src, 1))]>;
1262 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1263 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1264 [(set GR16:$dst, (add GR16:$src, 1))]>,
1265 OpSize, Requires<[In32BitMode]>;
1266 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1267 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1269 let isTwoAddress = 0, CodeSize = 2 in {
1270 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1271 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1272 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1273 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1274 OpSize, Requires<[In32BitMode]>;
1275 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1276 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1277 Requires<[In32BitMode]>;
1281 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1282 [(set GR8:$dst, (add GR8:$src, -1))]>;
1283 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1284 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1285 [(set GR16:$dst, (add GR16:$src, -1))]>,
1286 OpSize, Requires<[In32BitMode]>;
1287 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1288 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1291 let isTwoAddress = 0, CodeSize = 2 in {
1292 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1293 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1294 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1295 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1296 OpSize, Requires<[In32BitMode]>;
1297 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1298 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1299 Requires<[In32BitMode]>;
1301 } // Defs = [EFLAGS]
1303 // Logical operators...
1304 let Defs = [EFLAGS] in {
1305 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1306 def AND8rr : I<0x20, MRMDestReg,
1307 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1308 "and{b}\t{$src2, $dst|$dst, $src2}",
1309 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1310 def AND16rr : I<0x21, MRMDestReg,
1311 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1312 "and{w}\t{$src2, $dst|$dst, $src2}",
1313 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1314 def AND32rr : I<0x21, MRMDestReg,
1315 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1316 "and{l}\t{$src2, $dst|$dst, $src2}",
1317 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1320 def AND8rm : I<0x22, MRMSrcMem,
1321 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1322 "and{b}\t{$src2, $dst|$dst, $src2}",
1323 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1324 def AND16rm : I<0x23, MRMSrcMem,
1325 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1326 "and{w}\t{$src2, $dst|$dst, $src2}",
1327 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1328 def AND32rm : I<0x23, MRMSrcMem,
1329 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1330 "and{l}\t{$src2, $dst|$dst, $src2}",
1331 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1333 def AND8ri : Ii8<0x80, MRM4r,
1334 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1335 "and{b}\t{$src2, $dst|$dst, $src2}",
1336 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1337 def AND16ri : Ii16<0x81, MRM4r,
1338 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1339 "and{w}\t{$src2, $dst|$dst, $src2}",
1340 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1341 def AND32ri : Ii32<0x81, MRM4r,
1342 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1343 "and{l}\t{$src2, $dst|$dst, $src2}",
1344 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1345 def AND16ri8 : Ii8<0x83, MRM4r,
1346 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1347 "and{w}\t{$src2, $dst|$dst, $src2}",
1348 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1350 def AND32ri8 : Ii8<0x83, MRM4r,
1351 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1352 "and{l}\t{$src2, $dst|$dst, $src2}",
1353 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1355 let isTwoAddress = 0 in {
1356 def AND8mr : I<0x20, MRMDestMem,
1357 (outs), (ins i8mem :$dst, GR8 :$src),
1358 "and{b}\t{$src, $dst|$dst, $src}",
1359 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1360 def AND16mr : I<0x21, MRMDestMem,
1361 (outs), (ins i16mem:$dst, GR16:$src),
1362 "and{w}\t{$src, $dst|$dst, $src}",
1363 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1365 def AND32mr : I<0x21, MRMDestMem,
1366 (outs), (ins i32mem:$dst, GR32:$src),
1367 "and{l}\t{$src, $dst|$dst, $src}",
1368 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1369 def AND8mi : Ii8<0x80, MRM4m,
1370 (outs), (ins i8mem :$dst, i8imm :$src),
1371 "and{b}\t{$src, $dst|$dst, $src}",
1372 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1373 def AND16mi : Ii16<0x81, MRM4m,
1374 (outs), (ins i16mem:$dst, i16imm:$src),
1375 "and{w}\t{$src, $dst|$dst, $src}",
1376 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1378 def AND32mi : Ii32<0x81, MRM4m,
1379 (outs), (ins i32mem:$dst, i32imm:$src),
1380 "and{l}\t{$src, $dst|$dst, $src}",
1381 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1382 def AND16mi8 : Ii8<0x83, MRM4m,
1383 (outs), (ins i16mem:$dst, i16i8imm :$src),
1384 "and{w}\t{$src, $dst|$dst, $src}",
1385 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1387 def AND32mi8 : Ii8<0x83, MRM4m,
1388 (outs), (ins i32mem:$dst, i32i8imm :$src),
1389 "and{l}\t{$src, $dst|$dst, $src}",
1390 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1394 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1395 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1396 "or{b}\t{$src2, $dst|$dst, $src2}",
1397 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1398 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1399 "or{w}\t{$src2, $dst|$dst, $src2}",
1400 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1401 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1402 "or{l}\t{$src2, $dst|$dst, $src2}",
1403 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1405 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1406 "or{b}\t{$src2, $dst|$dst, $src2}",
1407 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1408 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1409 "or{w}\t{$src2, $dst|$dst, $src2}",
1410 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1411 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1412 "or{l}\t{$src2, $dst|$dst, $src2}",
1413 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1415 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1416 "or{b}\t{$src2, $dst|$dst, $src2}",
1417 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1418 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1419 "or{w}\t{$src2, $dst|$dst, $src2}",
1420 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1421 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1422 "or{l}\t{$src2, $dst|$dst, $src2}",
1423 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1425 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1426 "or{w}\t{$src2, $dst|$dst, $src2}",
1427 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1428 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1429 "or{l}\t{$src2, $dst|$dst, $src2}",
1430 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1431 let isTwoAddress = 0 in {
1432 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1433 "or{b}\t{$src, $dst|$dst, $src}",
1434 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1435 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1436 "or{w}\t{$src, $dst|$dst, $src}",
1437 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1438 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1439 "or{l}\t{$src, $dst|$dst, $src}",
1440 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
1441 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1442 "or{b}\t{$src, $dst|$dst, $src}",
1443 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1444 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1445 "or{w}\t{$src, $dst|$dst, $src}",
1446 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1448 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1449 "or{l}\t{$src, $dst|$dst, $src}",
1450 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1451 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1452 "or{w}\t{$src, $dst|$dst, $src}",
1453 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1455 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1456 "or{l}\t{$src, $dst|$dst, $src}",
1457 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1458 } // isTwoAddress = 0
1461 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1462 def XOR8rr : I<0x30, MRMDestReg,
1463 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1464 "xor{b}\t{$src2, $dst|$dst, $src2}",
1465 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1466 def XOR16rr : I<0x31, MRMDestReg,
1467 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1468 "xor{w}\t{$src2, $dst|$dst, $src2}",
1469 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1470 def XOR32rr : I<0x31, MRMDestReg,
1471 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1472 "xor{l}\t{$src2, $dst|$dst, $src2}",
1473 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1474 } // isCommutable = 1
1476 def XOR8rm : I<0x32, MRMSrcMem ,
1477 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1478 "xor{b}\t{$src2, $dst|$dst, $src2}",
1479 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1480 def XOR16rm : I<0x33, MRMSrcMem ,
1481 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1482 "xor{w}\t{$src2, $dst|$dst, $src2}",
1483 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1485 def XOR32rm : I<0x33, MRMSrcMem ,
1486 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1487 "xor{l}\t{$src2, $dst|$dst, $src2}",
1488 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1490 def XOR8ri : Ii8<0x80, MRM6r,
1491 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1492 "xor{b}\t{$src2, $dst|$dst, $src2}",
1493 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1494 def XOR16ri : Ii16<0x81, MRM6r,
1495 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1496 "xor{w}\t{$src2, $dst|$dst, $src2}",
1497 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1498 def XOR32ri : Ii32<0x81, MRM6r,
1499 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1500 "xor{l}\t{$src2, $dst|$dst, $src2}",
1501 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1502 def XOR16ri8 : Ii8<0x83, MRM6r,
1503 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1504 "xor{w}\t{$src2, $dst|$dst, $src2}",
1505 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1507 def XOR32ri8 : Ii8<0x83, MRM6r,
1508 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1509 "xor{l}\t{$src2, $dst|$dst, $src2}",
1510 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1512 let isTwoAddress = 0 in {
1513 def XOR8mr : I<0x30, MRMDestMem,
1514 (outs), (ins i8mem :$dst, GR8 :$src),
1515 "xor{b}\t{$src, $dst|$dst, $src}",
1516 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1517 def XOR16mr : I<0x31, MRMDestMem,
1518 (outs), (ins i16mem:$dst, GR16:$src),
1519 "xor{w}\t{$src, $dst|$dst, $src}",
1520 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1522 def XOR32mr : I<0x31, MRMDestMem,
1523 (outs), (ins i32mem:$dst, GR32:$src),
1524 "xor{l}\t{$src, $dst|$dst, $src}",
1525 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1526 def XOR8mi : Ii8<0x80, MRM6m,
1527 (outs), (ins i8mem :$dst, i8imm :$src),
1528 "xor{b}\t{$src, $dst|$dst, $src}",
1529 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1530 def XOR16mi : Ii16<0x81, MRM6m,
1531 (outs), (ins i16mem:$dst, i16imm:$src),
1532 "xor{w}\t{$src, $dst|$dst, $src}",
1533 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1535 def XOR32mi : Ii32<0x81, MRM6m,
1536 (outs), (ins i32mem:$dst, i32imm:$src),
1537 "xor{l}\t{$src, $dst|$dst, $src}",
1538 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1539 def XOR16mi8 : Ii8<0x83, MRM6m,
1540 (outs), (ins i16mem:$dst, i16i8imm :$src),
1541 "xor{w}\t{$src, $dst|$dst, $src}",
1542 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1544 def XOR32mi8 : Ii8<0x83, MRM6m,
1545 (outs), (ins i32mem:$dst, i32i8imm :$src),
1546 "xor{l}\t{$src, $dst|$dst, $src}",
1547 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1548 } // isTwoAddress = 0
1549 } // Defs = [EFLAGS]
1551 // Shift instructions
1552 let Defs = [EFLAGS] in {
1553 let Uses = [CL] in {
1554 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1555 "shl{b}\t{%cl, $dst|$dst, %CL}",
1556 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1557 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1558 "shl{w}\t{%cl, $dst|$dst, %CL}",
1559 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1560 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1561 "shl{l}\t{%cl, $dst|$dst, %CL}",
1562 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1565 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1566 "shl{b}\t{$src2, $dst|$dst, $src2}",
1567 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1568 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1569 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1570 "shl{w}\t{$src2, $dst|$dst, $src2}",
1571 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1572 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1573 "shl{l}\t{$src2, $dst|$dst, $src2}",
1574 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1575 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1577 } // isConvertibleToThreeAddress = 1
1579 let isTwoAddress = 0 in {
1580 let Uses = [CL] in {
1581 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1582 "shl{b}\t{%cl, $dst|$dst, %CL}",
1583 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1584 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1585 "shl{w}\t{%cl, $dst|$dst, %CL}",
1586 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1587 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1588 "shl{l}\t{%cl, $dst|$dst, %CL}",
1589 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1591 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1592 "shl{b}\t{$src, $dst|$dst, $src}",
1593 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1594 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1595 "shl{w}\t{$src, $dst|$dst, $src}",
1596 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1598 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1599 "shl{l}\t{$src, $dst|$dst, $src}",
1600 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1603 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1605 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1606 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1608 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1610 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1612 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1615 let Uses = [CL] in {
1616 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1617 "shr{b}\t{%cl, $dst|$dst, %CL}",
1618 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1619 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1620 "shr{w}\t{%cl, $dst|$dst, %CL}",
1621 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1622 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1623 "shr{l}\t{%cl, $dst|$dst, %CL}",
1624 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1627 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1628 "shr{b}\t{$src2, $dst|$dst, $src2}",
1629 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1630 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1631 "shr{w}\t{$src2, $dst|$dst, $src2}",
1632 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1633 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1634 "shr{l}\t{$src2, $dst|$dst, $src2}",
1635 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1638 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1640 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1641 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1643 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1644 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1646 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1648 let isTwoAddress = 0 in {
1649 let Uses = [CL] in {
1650 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1651 "shr{b}\t{%cl, $dst|$dst, %CL}",
1652 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1653 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1654 "shr{w}\t{%cl, $dst|$dst, %CL}",
1655 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1657 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1658 "shr{l}\t{%cl, $dst|$dst, %CL}",
1659 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1661 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1662 "shr{b}\t{$src, $dst|$dst, $src}",
1663 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1664 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1665 "shr{w}\t{$src, $dst|$dst, $src}",
1666 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1668 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1669 "shr{l}\t{$src, $dst|$dst, $src}",
1670 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1673 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1675 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1676 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1678 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1679 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1681 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1684 let Uses = [CL] in {
1685 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1686 "sar{b}\t{%cl, $dst|$dst, %CL}",
1687 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1688 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1689 "sar{w}\t{%cl, $dst|$dst, %CL}",
1690 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1691 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1692 "sar{l}\t{%cl, $dst|$dst, %CL}",
1693 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1696 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1697 "sar{b}\t{$src2, $dst|$dst, $src2}",
1698 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1699 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1700 "sar{w}\t{$src2, $dst|$dst, $src2}",
1701 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1703 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1704 "sar{l}\t{$src2, $dst|$dst, $src2}",
1705 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1708 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1710 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1711 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1713 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1714 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1716 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1718 let isTwoAddress = 0 in {
1719 let Uses = [CL] in {
1720 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1721 "sar{b}\t{%cl, $dst|$dst, %CL}",
1722 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1723 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1724 "sar{w}\t{%cl, $dst|$dst, %CL}",
1725 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1726 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1727 "sar{l}\t{%cl, $dst|$dst, %CL}",
1728 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1730 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1731 "sar{b}\t{$src, $dst|$dst, $src}",
1732 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1733 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1734 "sar{w}\t{$src, $dst|$dst, $src}",
1735 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1737 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1738 "sar{l}\t{$src, $dst|$dst, $src}",
1739 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1742 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1744 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1745 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1747 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1749 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1751 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1754 // Rotate instructions
1755 // FIXME: provide shorter instructions when imm8 == 1
1756 let Uses = [CL] in {
1757 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1758 "rol{b}\t{%cl, $dst|$dst, %CL}",
1759 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1760 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1761 "rol{w}\t{%cl, $dst|$dst, %CL}",
1762 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1763 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1764 "rol{l}\t{%cl, $dst|$dst, %CL}",
1765 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1768 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1769 "rol{b}\t{$src2, $dst|$dst, $src2}",
1770 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1771 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1772 "rol{w}\t{$src2, $dst|$dst, $src2}",
1773 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1774 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1775 "rol{l}\t{$src2, $dst|$dst, $src2}",
1776 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1779 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1781 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1782 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1784 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1785 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1787 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1789 let isTwoAddress = 0 in {
1790 let Uses = [CL] in {
1791 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1792 "rol{b}\t{%cl, $dst|$dst, %CL}",
1793 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
1794 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1795 "rol{w}\t{%cl, $dst|$dst, %CL}",
1796 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1797 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1798 "rol{l}\t{%cl, $dst|$dst, %CL}",
1799 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1801 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
1802 "rol{b}\t{$src, $dst|$dst, $src}",
1803 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1804 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
1805 "rol{w}\t{$src, $dst|$dst, $src}",
1806 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1808 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
1809 "rol{l}\t{$src, $dst|$dst, $src}",
1810 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1813 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
1815 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1816 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
1818 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1820 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
1822 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1825 let Uses = [CL] in {
1826 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
1827 "ror{b}\t{%cl, $dst|$dst, %CL}",
1828 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
1829 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
1830 "ror{w}\t{%cl, $dst|$dst, %CL}",
1831 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
1832 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
1833 "ror{l}\t{%cl, $dst|$dst, %CL}",
1834 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1837 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1838 "ror{b}\t{$src2, $dst|$dst, $src2}",
1839 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1840 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1841 "ror{w}\t{$src2, $dst|$dst, $src2}",
1842 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1843 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1844 "ror{l}\t{$src2, $dst|$dst, $src2}",
1845 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1848 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1850 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1851 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
1853 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1854 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
1856 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1858 let isTwoAddress = 0 in {
1859 let Uses = [CL] in {
1860 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
1861 "ror{b}\t{%cl, $dst|$dst, %CL}",
1862 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
1863 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
1864 "ror{w}\t{%cl, $dst|$dst, %CL}",
1865 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1866 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
1867 "ror{l}\t{%cl, $dst|$dst, %CL}",
1868 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1870 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1871 "ror{b}\t{$src, $dst|$dst, $src}",
1872 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1873 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
1874 "ror{w}\t{$src, $dst|$dst, $src}",
1875 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1877 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
1878 "ror{l}\t{$src, $dst|$dst, $src}",
1879 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1882 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
1884 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1885 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
1887 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1889 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
1891 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1896 // Double shift instructions (generalizations of rotate)
1897 let Uses = [CL] in {
1898 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1899 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1900 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
1901 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1902 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1903 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
1904 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1905 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1906 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1908 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1909 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1910 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1914 let isCommutable = 1 in { // These instructions commute to each other.
1915 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1916 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1917 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1918 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1921 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1922 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1923 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1924 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1927 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1928 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1929 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1930 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1933 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1934 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1935 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1936 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1941 let isTwoAddress = 0 in {
1942 let Uses = [CL] in {
1943 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1944 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1945 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1947 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1948 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1949 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1952 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1953 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1954 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1955 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1956 (i8 imm:$src3)), addr:$dst)]>,
1958 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1959 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1960 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1961 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1962 (i8 imm:$src3)), addr:$dst)]>,
1965 let Uses = [CL] in {
1966 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1967 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1968 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1969 addr:$dst)]>, TB, OpSize;
1970 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1971 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1972 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1973 addr:$dst)]>, TB, OpSize;
1975 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1976 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1977 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1978 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1979 (i8 imm:$src3)), addr:$dst)]>,
1981 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1982 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1983 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1984 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1985 (i8 imm:$src3)), addr:$dst)]>,
1988 } // Defs = [EFLAGS]
1992 let Defs = [EFLAGS] in {
1993 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1994 // Register-Register Addition
1995 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1996 (ins GR8 :$src1, GR8 :$src2),
1997 "add{b}\t{$src2, $dst|$dst, $src2}",
1998 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
1999 (implicit EFLAGS)]>;
2001 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2002 // Register-Register Addition
2003 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2004 (ins GR16:$src1, GR16:$src2),
2005 "add{w}\t{$src2, $dst|$dst, $src2}",
2006 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2007 (implicit EFLAGS)]>, OpSize;
2008 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2009 (ins GR32:$src1, GR32:$src2),
2010 "add{l}\t{$src2, $dst|$dst, $src2}",
2011 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2012 (implicit EFLAGS)]>;
2013 } // end isConvertibleToThreeAddress
2014 } // end isCommutable
2016 // Register-Memory Addition
2017 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2018 (ins GR8 :$src1, i8mem :$src2),
2019 "add{b}\t{$src2, $dst|$dst, $src2}",
2020 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2021 (implicit EFLAGS)]>;
2022 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2023 (ins GR16:$src1, i16mem:$src2),
2024 "add{w}\t{$src2, $dst|$dst, $src2}",
2025 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2026 (implicit EFLAGS)]>, OpSize;
2027 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2028 (ins GR32:$src1, i32mem:$src2),
2029 "add{l}\t{$src2, $dst|$dst, $src2}",
2030 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2031 (implicit EFLAGS)]>;
2033 // Register-Integer Addition
2034 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2035 "add{b}\t{$src2, $dst|$dst, $src2}",
2036 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2037 (implicit EFLAGS)]>;
2039 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
2040 // Register-Integer Addition
2041 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2042 (ins GR16:$src1, i16imm:$src2),
2043 "add{w}\t{$src2, $dst|$dst, $src2}",
2044 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2045 (implicit EFLAGS)]>, OpSize;
2046 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2047 (ins GR32:$src1, i32imm:$src2),
2048 "add{l}\t{$src2, $dst|$dst, $src2}",
2049 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2050 (implicit EFLAGS)]>;
2051 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2052 (ins GR16:$src1, i16i8imm:$src2),
2053 "add{w}\t{$src2, $dst|$dst, $src2}",
2054 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2055 (implicit EFLAGS)]>, OpSize;
2056 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2057 (ins GR32:$src1, i32i8imm:$src2),
2058 "add{l}\t{$src2, $dst|$dst, $src2}",
2059 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2060 (implicit EFLAGS)]>;
2063 let isTwoAddress = 0 in {
2064 // Memory-Register Addition
2065 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2066 "add{b}\t{$src2, $dst|$dst, $src2}",
2067 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2068 (implicit EFLAGS)]>;
2069 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2070 "add{w}\t{$src2, $dst|$dst, $src2}",
2071 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2072 (implicit EFLAGS)]>, OpSize;
2073 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2074 "add{l}\t{$src2, $dst|$dst, $src2}",
2075 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2076 (implicit EFLAGS)]>;
2077 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
2078 "add{b}\t{$src2, $dst|$dst, $src2}",
2079 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2080 (implicit EFLAGS)]>;
2081 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
2082 "add{w}\t{$src2, $dst|$dst, $src2}",
2083 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2084 (implicit EFLAGS)]>, OpSize;
2085 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
2086 "add{l}\t{$src2, $dst|$dst, $src2}",
2087 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2088 (implicit EFLAGS)]>;
2089 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2090 "add{w}\t{$src2, $dst|$dst, $src2}",
2091 [(store (add (load addr:$dst), i16immSExt8:$src2),
2093 (implicit EFLAGS)]>, OpSize;
2094 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2095 "add{l}\t{$src2, $dst|$dst, $src2}",
2096 [(store (add (load addr:$dst), i32immSExt8:$src2),
2098 (implicit EFLAGS)]>;
2101 let Uses = [EFLAGS] in {
2102 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
2103 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2104 "adc{l}\t{$src2, $dst|$dst, $src2}",
2105 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
2107 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2108 "adc{l}\t{$src2, $dst|$dst, $src2}",
2109 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2110 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2111 "adc{l}\t{$src2, $dst|$dst, $src2}",
2112 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
2113 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2114 "adc{l}\t{$src2, $dst|$dst, $src2}",
2115 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
2117 let isTwoAddress = 0 in {
2118 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2119 "adc{l}\t{$src2, $dst|$dst, $src2}",
2120 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2121 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2122 "adc{l}\t{$src2, $dst|$dst, $src2}",
2123 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2124 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2125 "adc{l}\t{$src2, $dst|$dst, $src2}",
2126 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2128 } // Uses = [EFLAGS]
2130 // Register-Register Subtraction
2131 def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2132 "sub{b}\t{$src2, $dst|$dst, $src2}",
2133 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2134 (implicit EFLAGS)]>;
2135 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2136 "sub{w}\t{$src2, $dst|$dst, $src2}",
2137 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2138 (implicit EFLAGS)]>, OpSize;
2139 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2140 "sub{l}\t{$src2, $dst|$dst, $src2}",
2141 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2142 (implicit EFLAGS)]>;
2144 // Register-Memory Subtraction
2145 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2146 (ins GR8 :$src1, i8mem :$src2),
2147 "sub{b}\t{$src2, $dst|$dst, $src2}",
2148 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2149 (implicit EFLAGS)]>;
2150 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2151 (ins GR16:$src1, i16mem:$src2),
2152 "sub{w}\t{$src2, $dst|$dst, $src2}",
2153 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2154 (implicit EFLAGS)]>, OpSize;
2155 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2156 (ins GR32:$src1, i32mem:$src2),
2157 "sub{l}\t{$src2, $dst|$dst, $src2}",
2158 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2159 (implicit EFLAGS)]>;
2161 // Register-Integer Subtraction
2162 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2163 (ins GR8:$src1, i8imm:$src2),
2164 "sub{b}\t{$src2, $dst|$dst, $src2}",
2165 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2166 (implicit EFLAGS)]>;
2167 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2168 (ins GR16:$src1, i16imm:$src2),
2169 "sub{w}\t{$src2, $dst|$dst, $src2}",
2170 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2171 (implicit EFLAGS)]>, OpSize;
2172 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2173 (ins GR32:$src1, i32imm:$src2),
2174 "sub{l}\t{$src2, $dst|$dst, $src2}",
2175 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2176 (implicit EFLAGS)]>;
2177 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2178 (ins GR16:$src1, i16i8imm:$src2),
2179 "sub{w}\t{$src2, $dst|$dst, $src2}",
2180 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2181 (implicit EFLAGS)]>, OpSize;
2182 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2183 (ins GR32:$src1, i32i8imm:$src2),
2184 "sub{l}\t{$src2, $dst|$dst, $src2}",
2185 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2186 (implicit EFLAGS)]>;
2188 let isTwoAddress = 0 in {
2189 // Memory-Register Subtraction
2190 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2191 "sub{b}\t{$src2, $dst|$dst, $src2}",
2192 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2193 (implicit EFLAGS)]>;
2194 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2195 "sub{w}\t{$src2, $dst|$dst, $src2}",
2196 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2197 (implicit EFLAGS)]>, OpSize;
2198 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2199 "sub{l}\t{$src2, $dst|$dst, $src2}",
2200 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2201 (implicit EFLAGS)]>;
2203 // Memory-Integer Subtraction
2204 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2205 "sub{b}\t{$src2, $dst|$dst, $src2}",
2206 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2207 (implicit EFLAGS)]>;
2208 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2209 "sub{w}\t{$src2, $dst|$dst, $src2}",
2210 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2211 (implicit EFLAGS)]>, OpSize;
2212 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2213 "sub{l}\t{$src2, $dst|$dst, $src2}",
2214 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2215 (implicit EFLAGS)]>;
2216 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2217 "sub{w}\t{$src2, $dst|$dst, $src2}",
2218 [(store (sub (load addr:$dst), i16immSExt8:$src2),
2220 (implicit EFLAGS)]>, OpSize;
2221 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2222 "sub{l}\t{$src2, $dst|$dst, $src2}",
2223 [(store (sub (load addr:$dst), i32immSExt8:$src2),
2225 (implicit EFLAGS)]>;
2228 let Uses = [EFLAGS] in {
2229 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2230 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2231 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2233 let isTwoAddress = 0 in {
2234 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2235 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2236 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2237 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2238 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2239 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2240 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2241 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2242 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2243 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2244 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2245 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2247 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2248 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2249 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2250 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2251 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2252 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2253 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2254 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2255 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2256 } // Uses = [EFLAGS]
2257 } // Defs = [EFLAGS]
2259 let Defs = [EFLAGS] in {
2260 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2261 // Register-Register Signed Integer Multiply
2262 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2263 "imul{w}\t{$src2, $dst|$dst, $src2}",
2264 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2265 (implicit EFLAGS)]>, TB, OpSize;
2266 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2267 "imul{l}\t{$src2, $dst|$dst, $src2}",
2268 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2269 (implicit EFLAGS)]>, TB;
2272 // Register-Memory Signed Integer Multiply
2273 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2274 (ins GR16:$src1, i16mem:$src2),
2275 "imul{w}\t{$src2, $dst|$dst, $src2}",
2276 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2277 (implicit EFLAGS)]>, TB, OpSize;
2278 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2279 "imul{l}\t{$src2, $dst|$dst, $src2}",
2280 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2281 (implicit EFLAGS)]>, TB;
2282 } // Defs = [EFLAGS]
2283 } // end Two Address instructions
2285 // Suprisingly enough, these are not two address instructions!
2286 let Defs = [EFLAGS] in {
2287 // Register-Integer Signed Integer Multiply
2288 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2289 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2290 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2291 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2292 (implicit EFLAGS)]>, OpSize;
2293 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2294 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2295 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2296 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2297 (implicit EFLAGS)]>;
2298 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2299 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2300 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2301 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2302 (implicit EFLAGS)]>, OpSize;
2303 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2304 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2305 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2306 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2307 (implicit EFLAGS)]>;
2309 // Memory-Integer Signed Integer Multiply
2310 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2311 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2312 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2313 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2314 (implicit EFLAGS)]>, OpSize;
2315 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2316 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2317 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2318 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2319 (implicit EFLAGS)]>;
2320 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2321 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2322 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2323 [(set GR16:$dst, (mul (load addr:$src1),
2324 i16immSExt8:$src2)),
2325 (implicit EFLAGS)]>, OpSize;
2326 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2327 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2328 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2329 [(set GR32:$dst, (mul (load addr:$src1),
2330 i32immSExt8:$src2)),
2331 (implicit EFLAGS)]>;
2332 } // Defs = [EFLAGS]
2334 //===----------------------------------------------------------------------===//
2335 // Test instructions are just like AND, except they don't generate a result.
2337 let Defs = [EFLAGS] in {
2338 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2339 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2340 "test{b}\t{$src2, $src1|$src1, $src2}",
2341 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2342 (implicit EFLAGS)]>;
2343 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2344 "test{w}\t{$src2, $src1|$src1, $src2}",
2345 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2346 (implicit EFLAGS)]>,
2348 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2349 "test{l}\t{$src2, $src1|$src1, $src2}",
2350 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2351 (implicit EFLAGS)]>;
2354 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2355 "test{b}\t{$src2, $src1|$src1, $src2}",
2356 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2357 (implicit EFLAGS)]>;
2358 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2359 "test{w}\t{$src2, $src1|$src1, $src2}",
2360 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2361 (implicit EFLAGS)]>, OpSize;
2362 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2363 "test{l}\t{$src2, $src1|$src1, $src2}",
2364 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2365 (implicit EFLAGS)]>;
2367 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2368 (outs), (ins GR8:$src1, i8imm:$src2),
2369 "test{b}\t{$src2, $src1|$src1, $src2}",
2370 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2371 (implicit EFLAGS)]>;
2372 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2373 (outs), (ins GR16:$src1, i16imm:$src2),
2374 "test{w}\t{$src2, $src1|$src1, $src2}",
2375 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2376 (implicit EFLAGS)]>, OpSize;
2377 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2378 (outs), (ins GR32:$src1, i32imm:$src2),
2379 "test{l}\t{$src2, $src1|$src1, $src2}",
2380 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2381 (implicit EFLAGS)]>;
2383 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2384 (outs), (ins i8mem:$src1, i8imm:$src2),
2385 "test{b}\t{$src2, $src1|$src1, $src2}",
2386 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2387 (implicit EFLAGS)]>;
2388 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2389 (outs), (ins i16mem:$src1, i16imm:$src2),
2390 "test{w}\t{$src2, $src1|$src1, $src2}",
2391 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2392 (implicit EFLAGS)]>, OpSize;
2393 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2394 (outs), (ins i32mem:$src1, i32imm:$src2),
2395 "test{l}\t{$src2, $src1|$src1, $src2}",
2396 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2397 (implicit EFLAGS)]>;
2398 } // Defs = [EFLAGS]
2401 // Condition code ops, incl. set if equal/not equal/...
2402 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2403 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2404 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2405 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2407 let Uses = [EFLAGS] in {
2408 def SETEr : I<0x94, MRM0r,
2409 (outs GR8 :$dst), (ins),
2411 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2413 def SETEm : I<0x94, MRM0m,
2414 (outs), (ins i8mem:$dst),
2416 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2419 def SETNEr : I<0x95, MRM0r,
2420 (outs GR8 :$dst), (ins),
2422 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2424 def SETNEm : I<0x95, MRM0m,
2425 (outs), (ins i8mem:$dst),
2427 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2430 def SETLr : I<0x9C, MRM0r,
2431 (outs GR8 :$dst), (ins),
2433 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2434 TB; // GR8 = < signed
2435 def SETLm : I<0x9C, MRM0m,
2436 (outs), (ins i8mem:$dst),
2438 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2439 TB; // [mem8] = < signed
2441 def SETGEr : I<0x9D, MRM0r,
2442 (outs GR8 :$dst), (ins),
2444 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2445 TB; // GR8 = >= signed
2446 def SETGEm : I<0x9D, MRM0m,
2447 (outs), (ins i8mem:$dst),
2449 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2450 TB; // [mem8] = >= signed
2452 def SETLEr : I<0x9E, MRM0r,
2453 (outs GR8 :$dst), (ins),
2455 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2456 TB; // GR8 = <= signed
2457 def SETLEm : I<0x9E, MRM0m,
2458 (outs), (ins i8mem:$dst),
2460 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2461 TB; // [mem8] = <= signed
2463 def SETGr : I<0x9F, MRM0r,
2464 (outs GR8 :$dst), (ins),
2466 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2467 TB; // GR8 = > signed
2468 def SETGm : I<0x9F, MRM0m,
2469 (outs), (ins i8mem:$dst),
2471 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2472 TB; // [mem8] = > signed
2474 def SETBr : I<0x92, MRM0r,
2475 (outs GR8 :$dst), (ins),
2477 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2478 TB; // GR8 = < unsign
2479 def SETBm : I<0x92, MRM0m,
2480 (outs), (ins i8mem:$dst),
2482 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2483 TB; // [mem8] = < unsign
2485 def SETAEr : I<0x93, MRM0r,
2486 (outs GR8 :$dst), (ins),
2488 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2489 TB; // GR8 = >= unsign
2490 def SETAEm : I<0x93, MRM0m,
2491 (outs), (ins i8mem:$dst),
2493 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2494 TB; // [mem8] = >= unsign
2496 def SETBEr : I<0x96, MRM0r,
2497 (outs GR8 :$dst), (ins),
2499 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2500 TB; // GR8 = <= unsign
2501 def SETBEm : I<0x96, MRM0m,
2502 (outs), (ins i8mem:$dst),
2504 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2505 TB; // [mem8] = <= unsign
2507 def SETAr : I<0x97, MRM0r,
2508 (outs GR8 :$dst), (ins),
2510 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2511 TB; // GR8 = > signed
2512 def SETAm : I<0x97, MRM0m,
2513 (outs), (ins i8mem:$dst),
2515 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2516 TB; // [mem8] = > signed
2518 def SETSr : I<0x98, MRM0r,
2519 (outs GR8 :$dst), (ins),
2521 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2522 TB; // GR8 = <sign bit>
2523 def SETSm : I<0x98, MRM0m,
2524 (outs), (ins i8mem:$dst),
2526 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2527 TB; // [mem8] = <sign bit>
2528 def SETNSr : I<0x99, MRM0r,
2529 (outs GR8 :$dst), (ins),
2531 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2532 TB; // GR8 = !<sign bit>
2533 def SETNSm : I<0x99, MRM0m,
2534 (outs), (ins i8mem:$dst),
2536 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2537 TB; // [mem8] = !<sign bit>
2539 def SETPr : I<0x9A, MRM0r,
2540 (outs GR8 :$dst), (ins),
2542 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2544 def SETPm : I<0x9A, MRM0m,
2545 (outs), (ins i8mem:$dst),
2547 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2548 TB; // [mem8] = parity
2549 def SETNPr : I<0x9B, MRM0r,
2550 (outs GR8 :$dst), (ins),
2552 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2553 TB; // GR8 = not parity
2554 def SETNPm : I<0x9B, MRM0m,
2555 (outs), (ins i8mem:$dst),
2557 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2558 TB; // [mem8] = not parity
2560 def SETOr : I<0x90, MRM0r,
2561 (outs GR8 :$dst), (ins),
2563 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2564 TB; // GR8 = overflow
2565 def SETOm : I<0x90, MRM0m,
2566 (outs), (ins i8mem:$dst),
2568 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2569 TB; // [mem8] = overflow
2570 def SETNOr : I<0x91, MRM0r,
2571 (outs GR8 :$dst), (ins),
2573 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2574 TB; // GR8 = not overflow
2575 def SETNOm : I<0x91, MRM0m,
2576 (outs), (ins i8mem:$dst),
2578 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2579 TB; // [mem8] = not overflow
2580 } // Uses = [EFLAGS]
2583 // Integer comparisons
2584 let Defs = [EFLAGS] in {
2585 def CMP8rr : I<0x38, MRMDestReg,
2586 (outs), (ins GR8 :$src1, GR8 :$src2),
2587 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2588 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2589 def CMP16rr : I<0x39, MRMDestReg,
2590 (outs), (ins GR16:$src1, GR16:$src2),
2591 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2592 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2593 def CMP32rr : I<0x39, MRMDestReg,
2594 (outs), (ins GR32:$src1, GR32:$src2),
2595 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2596 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2597 def CMP8mr : I<0x38, MRMDestMem,
2598 (outs), (ins i8mem :$src1, GR8 :$src2),
2599 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2600 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2601 (implicit EFLAGS)]>;
2602 def CMP16mr : I<0x39, MRMDestMem,
2603 (outs), (ins i16mem:$src1, GR16:$src2),
2604 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2605 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2606 (implicit EFLAGS)]>, OpSize;
2607 def CMP32mr : I<0x39, MRMDestMem,
2608 (outs), (ins i32mem:$src1, GR32:$src2),
2609 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2610 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2611 (implicit EFLAGS)]>;
2612 def CMP8rm : I<0x3A, MRMSrcMem,
2613 (outs), (ins GR8 :$src1, i8mem :$src2),
2614 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2615 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2616 (implicit EFLAGS)]>;
2617 def CMP16rm : I<0x3B, MRMSrcMem,
2618 (outs), (ins GR16:$src1, i16mem:$src2),
2619 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2620 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2621 (implicit EFLAGS)]>, OpSize;
2622 def CMP32rm : I<0x3B, MRMSrcMem,
2623 (outs), (ins GR32:$src1, i32mem:$src2),
2624 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2625 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2626 (implicit EFLAGS)]>;
2627 def CMP8ri : Ii8<0x80, MRM7r,
2628 (outs), (ins GR8:$src1, i8imm:$src2),
2629 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2630 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
2631 def CMP16ri : Ii16<0x81, MRM7r,
2632 (outs), (ins GR16:$src1, i16imm:$src2),
2633 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2634 [(X86cmp GR16:$src1, imm:$src2),
2635 (implicit EFLAGS)]>, OpSize;
2636 def CMP32ri : Ii32<0x81, MRM7r,
2637 (outs), (ins GR32:$src1, i32imm:$src2),
2638 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2639 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
2640 def CMP8mi : Ii8 <0x80, MRM7m,
2641 (outs), (ins i8mem :$src1, i8imm :$src2),
2642 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2643 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2644 (implicit EFLAGS)]>;
2645 def CMP16mi : Ii16<0x81, MRM7m,
2646 (outs), (ins i16mem:$src1, i16imm:$src2),
2647 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2648 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2649 (implicit EFLAGS)]>, OpSize;
2650 def CMP32mi : Ii32<0x81, MRM7m,
2651 (outs), (ins i32mem:$src1, i32imm:$src2),
2652 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2653 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2654 (implicit EFLAGS)]>;
2655 def CMP16ri8 : Ii8<0x83, MRM7r,
2656 (outs), (ins GR16:$src1, i16i8imm:$src2),
2657 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2658 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2659 (implicit EFLAGS)]>, OpSize;
2660 def CMP16mi8 : Ii8<0x83, MRM7m,
2661 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2662 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2663 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2664 (implicit EFLAGS)]>, OpSize;
2665 def CMP32mi8 : Ii8<0x83, MRM7m,
2666 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2667 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2668 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2669 (implicit EFLAGS)]>;
2670 def CMP32ri8 : Ii8<0x83, MRM7r,
2671 (outs), (ins GR32:$src1, i32i8imm:$src2),
2672 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2673 [(X86cmp GR32:$src1, i32immSExt8:$src2),
2674 (implicit EFLAGS)]>;
2675 } // Defs = [EFLAGS]
2678 // TODO: BTC, BTR, and BTS
2679 let Defs = [EFLAGS] in {
2680 def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2681 "bt{w}\t{$src2, $src1|$src1, $src2}",
2682 [(X86bt GR16:$src1, GR16:$src2),
2683 (implicit EFLAGS)]>, OpSize, TB;
2684 def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2685 "bt{l}\t{$src2, $src1|$src1, $src2}",
2686 [(X86bt GR32:$src1, GR32:$src2),
2687 (implicit EFLAGS)]>, TB;
2689 // Unlike with the register+register form, the memory+register form of the
2690 // bt instruction does not ignore the high bits of the index. From ISel's
2691 // perspective, this is pretty bizarre. Disable these instructions for now.
2692 //def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2693 // "bt{w}\t{$src2, $src1|$src1, $src2}",
2694 // [(X86bt (loadi16 addr:$src1), GR16:$src2),
2695 // (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2696 //def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2697 // "bt{l}\t{$src2, $src1|$src1, $src2}",
2698 // [(X86bt (loadi32 addr:$src1), GR32:$src2),
2699 // (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
2701 def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2702 "bt{w}\t{$src2, $src1|$src1, $src2}",
2703 [(X86bt GR16:$src1, i16immSExt8:$src2),
2704 (implicit EFLAGS)]>, OpSize, TB;
2705 def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2706 "bt{l}\t{$src2, $src1|$src1, $src2}",
2707 [(X86bt GR32:$src1, i32immSExt8:$src2),
2708 (implicit EFLAGS)]>, TB;
2709 // Note that these instructions don't need FastBTMem because that
2710 // only applies when the other operand is in a register. When it's
2711 // an immediate, bt is still fast.
2712 def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2713 "bt{w}\t{$src2, $src1|$src1, $src2}",
2714 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2715 (implicit EFLAGS)]>, OpSize, TB;
2716 def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2717 "bt{l}\t{$src2, $src1|$src1, $src2}",
2718 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2719 (implicit EFLAGS)]>, TB;
2720 } // Defs = [EFLAGS]
2722 // Sign/Zero extenders
2723 // Use movsbl intead of movsbw; we don't care about the high 16 bits
2724 // of the register here. This has a smaller encoding and avoids a
2725 // partial-register update.
2726 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2727 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2728 [(set GR16:$dst, (sext GR8:$src))]>, TB;
2729 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2730 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2731 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
2732 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2733 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2734 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2735 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2736 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2737 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2738 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2739 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2740 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2741 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2742 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2743 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2745 // Use movzbl intead of movzbw; we don't care about the high 16 bits
2746 // of the register here. This has a smaller encoding and avoids a
2747 // partial-register update.
2748 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2749 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2750 [(set GR16:$dst, (zext GR8:$src))]>, TB;
2751 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2752 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2753 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
2754 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2755 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2756 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2757 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2758 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2759 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2760 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2761 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2762 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2763 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2764 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2765 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2767 let neverHasSideEffects = 1 in {
2768 let Defs = [AX], Uses = [AL] in
2769 def CBW : I<0x98, RawFrm, (outs), (ins),
2770 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2771 let Defs = [EAX], Uses = [AX] in
2772 def CWDE : I<0x98, RawFrm, (outs), (ins),
2773 "{cwtl|cwde}", []>; // EAX = signext(AX)
2775 let Defs = [AX,DX], Uses = [AX] in
2776 def CWD : I<0x99, RawFrm, (outs), (ins),
2777 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2778 let Defs = [EAX,EDX], Uses = [EAX] in
2779 def CDQ : I<0x99, RawFrm, (outs), (ins),
2780 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2783 //===----------------------------------------------------------------------===//
2784 // Alias Instructions
2785 //===----------------------------------------------------------------------===//
2787 // Alias instructions that map movr0 to xor.
2788 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2789 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2790 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
2791 "xor{b}\t$dst, $dst",
2792 [(set GR8:$dst, 0)]>;
2793 // Use xorl instead of xorw since we don't care about the high 16 bits,
2794 // it's smaller, and it avoids a partial-register update.
2795 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
2796 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2797 [(set GR16:$dst, 0)]>;
2798 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
2799 "xor{l}\t$dst, $dst",
2800 [(set GR32:$dst, 0)]>;
2803 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2804 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2805 let neverHasSideEffects = 1 in {
2806 def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
2807 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2808 def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
2809 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2811 def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
2812 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2813 def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
2814 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2815 } // neverHasSideEffects
2817 let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
2818 def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
2819 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2820 def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
2821 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2823 let mayStore = 1, neverHasSideEffects = 1 in {
2824 def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
2825 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2826 def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
2827 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2830 //===----------------------------------------------------------------------===//
2831 // Thread Local Storage Instructions
2835 def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2836 "leal\t${sym:mem}(,%ebx,1), $dst",
2837 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
2839 let AddedComplexity = 10 in
2840 def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
2841 "movl\t%gs:($src), $dst",
2842 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2844 let AddedComplexity = 15 in
2845 def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2846 "movl\t%gs:${src:mem}, $dst",
2848 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
2851 def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
2852 "movl\t%gs:0, $dst",
2853 [(set GR32:$dst, X86TLStp)]>, SegGS;
2855 //===----------------------------------------------------------------------===//
2856 // DWARF Pseudo Instructions
2859 def DWARF_LOC : I<0, Pseudo, (outs),
2860 (ins i32imm:$line, i32imm:$col, i32imm:$file),
2861 ".loc\t${file:debug} ${line:debug} ${col:debug}",
2862 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2865 //===----------------------------------------------------------------------===//
2866 // EH Pseudo Instructions
2868 let isTerminator = 1, isReturn = 1, isBarrier = 1,
2870 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
2871 "ret\t#eh_return, addr: $addr",
2872 [(X86ehret GR32:$addr)]>;
2876 //===----------------------------------------------------------------------===//
2880 // Atomic swap. These are just normal xchg instructions. But since a memory
2881 // operand is referenced, the atomicity is ensured.
2882 let Constraints = "$val = $dst" in {
2883 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2884 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2885 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2886 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2887 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2888 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2890 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2891 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2892 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2895 // Atomic compare and swap.
2896 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
2897 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
2898 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
2899 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
2901 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
2902 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
2903 "lock\n\tcmpxchg8b\t$ptr",
2904 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2907 let Defs = [AX, EFLAGS], Uses = [AX] in {
2908 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
2909 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
2910 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
2912 let Defs = [AL, EFLAGS], Uses = [AL] in {
2913 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
2914 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
2915 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
2918 // Atomic exchange and add
2919 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2920 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2921 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
2922 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
2924 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2925 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
2926 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
2928 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2929 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
2930 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
2934 // Atomic exchange, and, or, xor
2935 let Constraints = "$val = $dst", Defs = [EFLAGS],
2936 usesCustomDAGSchedInserter = 1 in {
2937 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2938 "#ATOMAND32 PSEUDO!",
2939 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
2940 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2941 "#ATOMOR32 PSEUDO!",
2942 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
2943 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2944 "#ATOMXOR32 PSEUDO!",
2945 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
2946 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2947 "#ATOMNAND32 PSEUDO!",
2948 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
2949 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2950 "#ATOMMIN32 PSEUDO!",
2951 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
2952 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2953 "#ATOMMAX32 PSEUDO!",
2954 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
2955 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2956 "#ATOMUMIN32 PSEUDO!",
2957 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
2958 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2959 "#ATOMUMAX32 PSEUDO!",
2960 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
2962 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2963 "#ATOMAND16 PSEUDO!",
2964 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
2965 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2966 "#ATOMOR16 PSEUDO!",
2967 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
2968 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2969 "#ATOMXOR16 PSEUDO!",
2970 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
2971 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2972 "#ATOMNAND16 PSEUDO!",
2973 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
2974 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2975 "#ATOMMIN16 PSEUDO!",
2976 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
2977 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2978 "#ATOMMAX16 PSEUDO!",
2979 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
2980 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2981 "#ATOMUMIN16 PSEUDO!",
2982 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
2983 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2984 "#ATOMUMAX16 PSEUDO!",
2985 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
2987 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2988 "#ATOMAND8 PSEUDO!",
2989 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
2990 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2992 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
2993 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2994 "#ATOMXOR8 PSEUDO!",
2995 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
2996 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2997 "#ATOMNAND8 PSEUDO!",
2998 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
3001 let Constraints = "$val1 = $dst1, $val2 = $dst2",
3002 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3003 Uses = [EAX, EBX, ECX, EDX],
3004 mayLoad = 1, mayStore = 1,
3005 usesCustomDAGSchedInserter = 1 in {
3006 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3007 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3008 "#ATOMAND6432 PSEUDO!", []>;
3009 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3010 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3011 "#ATOMOR6432 PSEUDO!", []>;
3012 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3013 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3014 "#ATOMXOR6432 PSEUDO!", []>;
3015 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3016 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3017 "#ATOMNAND6432 PSEUDO!", []>;
3018 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3019 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3020 "#ATOMADD6432 PSEUDO!", []>;
3021 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3022 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3023 "#ATOMSUB6432 PSEUDO!", []>;
3024 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3025 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
3026 "#ATOMSWAP6432 PSEUDO!", []>;
3029 //===----------------------------------------------------------------------===//
3030 // Non-Instruction Patterns
3031 //===----------------------------------------------------------------------===//
3033 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
3034 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3035 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
3036 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
3037 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3038 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3040 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3041 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3042 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3043 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3044 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3045 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3046 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3047 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3049 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3050 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3051 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3052 (MOV32mi addr:$dst, texternalsym:$src)>;
3056 def : Pat<(X86tailcall GR32:$dst),
3059 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
3061 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
3064 def : Pat<(X86tcret GR32:$dst, imm:$off),
3065 (TCRETURNri GR32:$dst, imm:$off)>;
3067 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3068 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3070 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3071 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3073 def : Pat<(X86call (i32 tglobaladdr:$dst)),
3074 (CALLpcrel32 tglobaladdr:$dst)>;
3075 def : Pat<(X86call (i32 texternalsym:$dst)),
3076 (CALLpcrel32 texternalsym:$dst)>;
3078 // X86 specific add which produces a flag.
3079 def : Pat<(addc GR32:$src1, GR32:$src2),
3080 (ADD32rr GR32:$src1, GR32:$src2)>;
3081 def : Pat<(addc GR32:$src1, (load addr:$src2)),
3082 (ADD32rm GR32:$src1, addr:$src2)>;
3083 def : Pat<(addc GR32:$src1, imm:$src2),
3084 (ADD32ri GR32:$src1, imm:$src2)>;
3085 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3086 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3088 def : Pat<(subc GR32:$src1, GR32:$src2),
3089 (SUB32rr GR32:$src1, GR32:$src2)>;
3090 def : Pat<(subc GR32:$src1, (load addr:$src2)),
3091 (SUB32rm GR32:$src1, addr:$src2)>;
3092 def : Pat<(subc GR32:$src1, imm:$src2),
3093 (SUB32ri GR32:$src1, imm:$src2)>;
3094 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3095 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3099 // TEST R,R is smaller than CMP R,0
3100 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
3101 (TEST8rr GR8:$src1, GR8:$src1)>;
3102 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
3103 (TEST16rr GR16:$src1, GR16:$src1)>;
3104 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
3105 (TEST32rr GR32:$src1, GR32:$src1)>;
3107 // Conditional moves with folded loads with operands swapped and conditions
3109 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3110 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3111 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3112 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3113 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3114 (CMOVB16rm GR16:$src2, addr:$src1)>;
3115 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3116 (CMOVB32rm GR32:$src2, addr:$src1)>;
3117 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3118 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3119 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3120 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3121 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3122 (CMOVE16rm GR16:$src2, addr:$src1)>;
3123 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3124 (CMOVE32rm GR32:$src2, addr:$src1)>;
3125 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3126 (CMOVA16rm GR16:$src2, addr:$src1)>;
3127 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3128 (CMOVA32rm GR32:$src2, addr:$src1)>;
3129 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3130 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3131 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3132 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3133 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3134 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3135 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3136 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3137 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3138 (CMOVL16rm GR16:$src2, addr:$src1)>;
3139 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3140 (CMOVL32rm GR32:$src2, addr:$src1)>;
3141 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3142 (CMOVG16rm GR16:$src2, addr:$src1)>;
3143 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3144 (CMOVG32rm GR32:$src2, addr:$src1)>;
3145 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3146 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3147 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3148 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3149 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3150 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3151 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3152 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3153 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3154 (CMOVP16rm GR16:$src2, addr:$src1)>;
3155 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3156 (CMOVP32rm GR32:$src2, addr:$src1)>;
3157 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3158 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3159 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3160 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3161 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3162 (CMOVS16rm GR16:$src2, addr:$src1)>;
3163 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3164 (CMOVS32rm GR32:$src2, addr:$src1)>;
3165 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3166 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3167 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3168 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3169 def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3170 (CMOVO16rm GR16:$src2, addr:$src1)>;
3171 def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3172 (CMOVO32rm GR32:$src2, addr:$src1)>;
3174 // zextload bool -> zextload byte
3175 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3176 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3177 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3179 // extload bool -> extload byte
3180 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3181 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3182 Requires<[In32BitMode]>;
3183 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3184 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3185 Requires<[In32BitMode]>;
3186 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3187 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3190 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3191 Requires<[In32BitMode]>;
3192 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3193 Requires<[In32BitMode]>;
3194 def : Pat<(i32 (anyext GR16:$src)),
3195 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
3197 // (and (i32 load), 255) -> (zextload i8)
3198 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3199 (MOVZX32rm8 addr:$src)>;
3200 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3201 (MOVZX32rm16 addr:$src)>;
3203 //===----------------------------------------------------------------------===//
3205 //===----------------------------------------------------------------------===//
3207 // Odd encoding trick: -128 fits into an 8-bit immediate field while
3208 // +128 doesn't, so in this special case use a sub instead of an add.
3209 def : Pat<(add GR16:$src1, 128),
3210 (SUB16ri8 GR16:$src1, -128)>;
3211 def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3212 (SUB16mi8 addr:$dst, -128)>;
3213 def : Pat<(add GR32:$src1, 128),
3214 (SUB32ri8 GR32:$src1, -128)>;
3215 def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3216 (SUB32mi8 addr:$dst, -128)>;
3218 // r & (2^16-1) ==> movz
3219 def : Pat<(and GR32:$src1, 0xffff),
3220 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
3221 // r & (2^8-1) ==> movz
3222 def : Pat<(and GR32:$src1, 0xff),
3223 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3224 x86_subreg_8bit)))>,
3225 Requires<[In32BitMode]>;
3226 // r & (2^8-1) ==> movz
3227 def : Pat<(and GR16:$src1, 0xff),
3228 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3229 x86_subreg_8bit)))>,
3230 Requires<[In32BitMode]>;
3232 // sext_inreg patterns
3233 def : Pat<(sext_inreg GR32:$src, i16),
3234 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3235 def : Pat<(sext_inreg GR32:$src, i8),
3236 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3237 x86_subreg_8bit)))>,
3238 Requires<[In32BitMode]>;
3239 def : Pat<(sext_inreg GR16:$src, i8),
3240 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3241 x86_subreg_8bit)))>,
3242 Requires<[In32BitMode]>;
3245 def : Pat<(i16 (trunc GR32:$src)),
3246 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3247 def : Pat<(i8 (trunc GR32:$src)),
3248 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3249 Requires<[In32BitMode]>;
3250 def : Pat<(i8 (trunc GR16:$src)),
3251 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
3252 Requires<[In32BitMode]>;
3254 // (shl x, 1) ==> (add x, x)
3255 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3256 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3257 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3259 // (shl x (and y, 31)) ==> (shl x, y)
3260 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3261 (SHL8rCL GR8:$src1)>;
3262 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3263 (SHL16rCL GR16:$src1)>;
3264 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3265 (SHL32rCL GR32:$src1)>;
3266 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3267 (SHL8mCL addr:$dst)>;
3268 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3269 (SHL16mCL addr:$dst)>;
3270 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3271 (SHL32mCL addr:$dst)>;
3273 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3274 (SHR8rCL GR8:$src1)>;
3275 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3276 (SHR16rCL GR16:$src1)>;
3277 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3278 (SHR32rCL GR32:$src1)>;
3279 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3280 (SHR8mCL addr:$dst)>;
3281 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3282 (SHR16mCL addr:$dst)>;
3283 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3284 (SHR32mCL addr:$dst)>;
3286 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3287 (SAR8rCL GR8:$src1)>;
3288 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3289 (SAR16rCL GR16:$src1)>;
3290 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3291 (SAR32rCL GR32:$src1)>;
3292 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3293 (SAR8mCL addr:$dst)>;
3294 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3295 (SAR16mCL addr:$dst)>;
3296 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3297 (SAR32mCL addr:$dst)>;
3299 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3300 def : Pat<(or (srl GR32:$src1, CL:$amt),
3301 (shl GR32:$src2, (sub 32, CL:$amt))),
3302 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3304 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3305 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3306 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3308 def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3309 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3310 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3312 def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3313 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3315 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3317 def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3318 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3320 def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3321 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3322 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3324 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3325 def : Pat<(or (shl GR32:$src1, CL:$amt),
3326 (srl GR32:$src2, (sub 32, CL:$amt))),
3327 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3329 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3330 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3331 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3333 def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3334 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3335 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3337 def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3338 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3340 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3342 def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3343 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3345 def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3346 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3347 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3349 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3350 def : Pat<(or (srl GR16:$src1, CL:$amt),
3351 (shl GR16:$src2, (sub 16, CL:$amt))),
3352 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3354 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3355 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3356 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3358 def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3359 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3360 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3362 def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3363 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3365 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3367 def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3368 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3370 def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3371 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3372 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3374 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3375 def : Pat<(or (shl GR16:$src1, CL:$amt),
3376 (srl GR16:$src2, (sub 16, CL:$amt))),
3377 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3379 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3380 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3381 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3383 def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3384 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3385 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3387 def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3388 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3390 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3392 def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3393 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3395 def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3396 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3397 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3399 //===----------------------------------------------------------------------===//
3400 // Overflow Patterns
3401 //===----------------------------------------------------------------------===//
3403 // Register-Register Addition with Overflow
3404 def : Pat<(parallel (X86add_ovf GR8:$src1, GR8:$src2),
3406 (ADD8rr GR8:$src1, GR8:$src2)>;
3408 // Register-Register Addition with Overflow
3409 def : Pat<(parallel (X86add_ovf GR16:$src1, GR16:$src2),
3411 (ADD16rr GR16:$src1, GR16:$src2)>;
3412 def : Pat<(parallel (X86add_ovf GR32:$src1, GR32:$src2),
3414 (ADD32rr GR32:$src1, GR32:$src2)>;
3416 // Register-Memory Addition with Overflow
3417 def : Pat<(parallel (X86add_ovf GR8:$src1, (load addr:$src2)),
3419 (ADD8rm GR8:$src1, addr:$src2)>;
3420 def : Pat<(parallel (X86add_ovf GR16:$src1, (load addr:$src2)),
3422 (ADD16rm GR16:$src1, addr:$src2)>;
3423 def : Pat<(parallel (X86add_ovf GR32:$src1, (load addr:$src2)),
3425 (ADD32rm GR32:$src1, addr:$src2)>;
3427 // Register-Integer Addition with Overflow
3428 def : Pat<(parallel (X86add_ovf GR8:$src1, imm:$src2),
3430 (ADD8ri GR8:$src1, imm:$src2)>;
3432 // Register-Integer Addition with Overflow
3433 def : Pat<(parallel (X86add_ovf GR16:$src1, imm:$src2),
3435 (ADD16ri GR16:$src1, imm:$src2)>;
3436 def : Pat<(parallel (X86add_ovf GR32:$src1, imm:$src2),
3438 (ADD32ri GR32:$src1, imm:$src2)>;
3439 def : Pat<(parallel (X86add_ovf GR16:$src1, i16immSExt8:$src2),
3441 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3442 def : Pat<(parallel (X86add_ovf GR32:$src1, i32immSExt8:$src2),
3444 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3446 // Memory-Register Addition with Overflow
3447 def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR8:$src2),
3450 (ADD8mr addr:$dst, GR8:$src2)>;
3451 def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR16:$src2),
3454 (ADD16mr addr:$dst, GR16:$src2)>;
3455 def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR32:$src2),
3458 (ADD32mr addr:$dst, GR32:$src2)>;
3459 def : Pat<(parallel (store (X86add_ovf (loadi8 addr:$dst), imm:$src2),
3462 (ADD8mi addr:$dst, imm:$src2)>;
3463 def : Pat<(parallel (store (X86add_ovf (loadi16 addr:$dst), imm:$src2),
3466 (ADD16mi addr:$dst, imm:$src2)>;
3467 def : Pat<(parallel (store (X86add_ovf (loadi32 addr:$dst), imm:$src2),
3470 (ADD32mi addr:$dst, imm:$src2)>;
3471 def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i16immSExt8:$src2),
3474 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3475 def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i32immSExt8:$src2),
3478 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3480 // Register-Register Subtraction with Overflow
3481 def : Pat<(parallel (X86sub_ovf GR8:$src1, GR8:$src2),
3483 (SUB8rr GR8:$src1, GR8:$src2)>;
3484 def : Pat<(parallel (X86sub_ovf GR16:$src1, GR16:$src2),
3486 (SUB16rr GR16:$src1, GR16:$src2)>;
3487 def : Pat<(parallel (X86sub_ovf GR32:$src1, GR32:$src2),
3489 (SUB32rr GR32:$src1, GR32:$src2)>;
3491 // Register-Memory Subtraction with Overflow
3492 def : Pat<(parallel (X86sub_ovf GR8:$src1, (load addr:$src2)),
3494 (SUB8rm GR8:$src1, addr:$src2)>;
3495 def : Pat<(parallel (X86sub_ovf GR16:$src1, (load addr:$src2)),
3497 (SUB16rm GR16:$src1, addr:$src2)>;
3498 def : Pat<(parallel (X86sub_ovf GR32:$src1, (load addr:$src2)),
3500 (SUB32rm GR32:$src1, addr:$src2)>;
3502 // Register-Integer Subtraction with Overflow
3503 def : Pat<(parallel (X86sub_ovf GR8:$src1, imm:$src2),
3505 (SUB8ri GR8:$src1, imm:$src2)>;
3506 def : Pat<(parallel (X86sub_ovf GR16:$src1, imm:$src2),
3508 (SUB16ri GR16:$src1, imm:$src2)>;
3509 def : Pat<(parallel (X86sub_ovf GR32:$src1, imm:$src2),
3511 (SUB32ri GR32:$src1, imm:$src2)>;
3512 def : Pat<(parallel (X86sub_ovf GR16:$src1, i16immSExt8:$src2),
3514 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3515 def : Pat<(parallel (X86sub_ovf GR32:$src1, i32immSExt8:$src2),
3517 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3519 // Memory-Register Subtraction with Overflow
3520 def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR8:$src2),
3523 (SUB8mr addr:$dst, GR8:$src2)>;
3524 def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR16:$src2),
3527 (SUB16mr addr:$dst, GR16:$src2)>;
3528 def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR32:$src2),
3531 (SUB32mr addr:$dst, GR32:$src2)>;
3533 // Memory-Integer Subtraction with Overflow
3534 def : Pat<(parallel (store (X86sub_ovf (loadi8 addr:$dst), imm:$src2),
3537 (SUB8mi addr:$dst, imm:$src2)>;
3538 def : Pat<(parallel (store (X86sub_ovf (loadi16 addr:$dst), imm:$src2),
3541 (SUB16mi addr:$dst, imm:$src2)>;
3542 def : Pat<(parallel (store (X86sub_ovf (loadi32 addr:$dst), imm:$src2),
3545 (SUB32mi addr:$dst, imm:$src2)>;
3546 def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i16immSExt8:$src2),
3549 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3550 def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i32immSExt8:$src2),
3553 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3556 // Register-Register Signed Integer Multiply with Overflow
3557 def : Pat<(parallel (X86smul_ovf GR16:$src1, GR16:$src2),
3559 (IMUL16rr GR16:$src1, GR16:$src2)>;
3560 def : Pat<(parallel (X86smul_ovf GR32:$src1, GR32:$src2),
3562 (IMUL32rr GR32:$src1, GR32:$src2)>;
3564 // Register-Memory Signed Integer Multiply with Overflow
3565 def : Pat<(parallel (X86smul_ovf GR16:$src1, (load addr:$src2)),
3567 (IMUL16rm GR16:$src1, addr:$src2)>;
3568 def : Pat<(parallel (X86smul_ovf GR32:$src1, (load addr:$src2)),
3570 (IMUL32rm GR32:$src1, addr:$src2)>;
3572 // Register-Integer Signed Integer Multiply with Overflow
3573 def : Pat<(parallel (X86smul_ovf GR16:$src1, imm:$src2),
3575 (IMUL16rri GR16:$src1, imm:$src2)>;
3576 def : Pat<(parallel (X86smul_ovf GR32:$src1, imm:$src2),
3578 (IMUL32rri GR32:$src1, imm:$src2)>;
3579 def : Pat<(parallel (X86smul_ovf GR16:$src1, i16immSExt8:$src2),
3581 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
3582 def : Pat<(parallel (X86smul_ovf GR32:$src1, i32immSExt8:$src2),
3584 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3586 // Memory-Integer Signed Integer Multiply with Overflow
3587 def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
3589 (IMUL16rmi addr:$src1, imm:$src2)>;
3590 def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
3592 (IMUL32rmi addr:$src1, imm:$src2)>;
3593 def : Pat<(parallel (X86smul_ovf (load addr:$src1), i16immSExt8:$src2),
3595 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
3596 def : Pat<(parallel (X86smul_ovf (load addr:$src1), i32immSExt8:$src2),
3598 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3600 //===----------------------------------------------------------------------===//
3601 // Floating Point Stack Support
3602 //===----------------------------------------------------------------------===//
3604 include "X86InstrFPStack.td"
3606 //===----------------------------------------------------------------------===//
3608 //===----------------------------------------------------------------------===//
3610 include "X86Instr64bit.td"
3612 //===----------------------------------------------------------------------===//
3613 // XMM Floating point support (requires SSE / SSE2)
3614 //===----------------------------------------------------------------------===//
3616 include "X86InstrSSE.td"
3618 //===----------------------------------------------------------------------===//
3619 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3620 //===----------------------------------------------------------------------===//
3622 include "X86InstrMMX.td"