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 SDTX86BrCond : SDTypeProfile<0, 3,
31 [SDTCisVT<0, OtherVT>,
32 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
34 def SDTX86SetCC : SDTypeProfile<1, 2,
36 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
38 def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
40 def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
42 def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
43 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
44 def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
46 def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
47 def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
50 def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
52 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
54 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
56 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
58 def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
60 def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
62 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
64 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
66 def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
67 def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
68 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
69 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
71 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
73 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
74 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
76 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
78 def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
79 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
81 def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
82 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
84 def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
85 [SDNPHasChain, SDNPMayStore,
86 SDNPMayLoad, SDNPMemOperand]>;
87 def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
88 [SDNPHasChain, SDNPMayStore,
89 SDNPMayLoad, SDNPMemOperand]>;
90 def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
91 [SDNPHasChain, SDNPMayStore,
92 SDNPMayLoad, SDNPMemOperand]>;
93 def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96 def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99 def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
102 def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
105 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
106 [SDNPHasChain, SDNPOptInFlag]>;
108 def X86callseq_start :
109 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
110 [SDNPHasChain, SDNPOutFlag]>;
112 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
113 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
115 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
116 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
118 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
119 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
121 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
122 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
123 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
124 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
127 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
128 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
130 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
131 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
133 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
134 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
135 def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
137 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
140 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
141 [SDNPHasChain, SDNPOptInFlag]>;
143 //===----------------------------------------------------------------------===//
144 // X86 Operand Definitions.
147 // *mem - Operand definitions for the funky X86 addressing mode operands.
149 class X86MemOperand<string printMethod> : Operand<iPTR> {
150 let PrintMethod = printMethod;
151 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
154 def i8mem : X86MemOperand<"printi8mem">;
155 def i16mem : X86MemOperand<"printi16mem">;
156 def i32mem : X86MemOperand<"printi32mem">;
157 def i64mem : X86MemOperand<"printi64mem">;
158 def i128mem : X86MemOperand<"printi128mem">;
159 def f32mem : X86MemOperand<"printf32mem">;
160 def f64mem : X86MemOperand<"printf64mem">;
161 def f80mem : X86MemOperand<"printf80mem">;
162 def f128mem : X86MemOperand<"printf128mem">;
164 def lea32mem : Operand<i32> {
165 let PrintMethod = "printi32mem";
166 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
169 def SSECC : Operand<i8> {
170 let PrintMethod = "printSSECC";
173 def piclabel: Operand<i32> {
174 let PrintMethod = "printPICLabel";
177 // A couple of more descriptive operand definitions.
178 // 16-bits but only 8 bits are significant.
179 def i16i8imm : Operand<i16>;
180 // 32-bits but only 8 bits are significant.
181 def i32i8imm : Operand<i32>;
183 // Branch targets have OtherVT type.
184 def brtarget : Operand<OtherVT>;
186 //===----------------------------------------------------------------------===//
187 // X86 Complex Pattern Definitions.
190 // Define X86 specific addressing mode.
191 def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
192 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
193 [add, mul, shl, or, frameindex], []>;
195 //===----------------------------------------------------------------------===//
196 // X86 Instruction Predicate Definitions.
197 def HasMMX : Predicate<"Subtarget->hasMMX()">;
198 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
199 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
200 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
201 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
202 def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
203 def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
204 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
205 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
206 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
207 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
208 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
209 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
210 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
211 def OptForSpeed : Predicate<"!OptForSize">;
213 //===----------------------------------------------------------------------===//
214 // X86 Instruction Format Definitions.
217 include "X86InstrFormats.td"
219 //===----------------------------------------------------------------------===//
220 // Pattern fragments...
223 // X86 specific condition code. These correspond to CondCode in
224 // X86InstrInfo.h. They must be kept in synch.
225 def X86_COND_A : PatLeaf<(i8 0)>;
226 def X86_COND_AE : PatLeaf<(i8 1)>;
227 def X86_COND_B : PatLeaf<(i8 2)>;
228 def X86_COND_BE : PatLeaf<(i8 3)>;
229 def X86_COND_E : PatLeaf<(i8 4)>;
230 def X86_COND_G : PatLeaf<(i8 5)>;
231 def X86_COND_GE : PatLeaf<(i8 6)>;
232 def X86_COND_L : PatLeaf<(i8 7)>;
233 def X86_COND_LE : PatLeaf<(i8 8)>;
234 def X86_COND_NE : PatLeaf<(i8 9)>;
235 def X86_COND_NO : PatLeaf<(i8 10)>;
236 def X86_COND_NP : PatLeaf<(i8 11)>;
237 def X86_COND_NS : PatLeaf<(i8 12)>;
238 def X86_COND_O : PatLeaf<(i8 13)>;
239 def X86_COND_P : PatLeaf<(i8 14)>;
240 def X86_COND_S : PatLeaf<(i8 15)>;
242 def i16immSExt8 : PatLeaf<(i16 imm), [{
243 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
244 // sign extended field.
245 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
248 def i32immSExt8 : PatLeaf<(i32 imm), [{
249 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
250 // sign extended field.
251 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
254 // Helper fragments for loads.
255 // It's always safe to treat a anyext i16 load as a i32 load if the i16 is
256 // known to be 32-bit aligned or better. Ditto for i8 to i16.
257 def loadi16 : PatFrag<(ops node:$ptr), (i16 (ld node:$ptr)), [{
258 LoadSDNode *LD = cast<LoadSDNode>(N);
259 if (LD->getAddressingMode() != ISD::UNINDEXED)
261 ISD::LoadExtType ExtType = LD->getExtensionType();
262 if (ExtType == ISD::NON_EXTLOAD)
264 if (ExtType == ISD::EXTLOAD)
265 return LD->getAlignment() >= 2 && !LD->isVolatile();
269 def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
270 LoadSDNode *LD = cast<LoadSDNode>(N);
271 if (LD->getAddressingMode() != ISD::UNINDEXED)
273 ISD::LoadExtType ExtType = LD->getExtensionType();
274 if (ExtType == ISD::EXTLOAD)
275 return LD->getAlignment() >= 2 && !LD->isVolatile();
279 def loadi32 : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
280 LoadSDNode *LD = cast<LoadSDNode>(N);
281 if (LD->getAddressingMode() != ISD::UNINDEXED)
283 ISD::LoadExtType ExtType = LD->getExtensionType();
284 if (ExtType == ISD::NON_EXTLOAD)
286 if (ExtType == ISD::EXTLOAD)
287 return LD->getAlignment() >= 4 && !LD->isVolatile();
291 def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
292 LoadSDNode *LD = cast<LoadSDNode>(N);
293 if (LD->isVolatile())
295 if (LD->getAddressingMode() != ISD::UNINDEXED)
297 ISD::LoadExtType ExtType = LD->getExtensionType();
298 if (ExtType == ISD::NON_EXTLOAD)
300 if (ExtType == ISD::EXTLOAD)
301 return LD->getAlignment() >= 4;
305 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
306 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
308 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
309 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
310 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
312 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
313 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
314 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
316 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
317 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
318 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
319 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
320 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
321 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
323 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
324 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
325 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
326 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
327 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
328 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
331 // An 'and' node with a single use.
332 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
333 return N->hasOneUse();
336 //===----------------------------------------------------------------------===//
337 // Instruction list...
340 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
341 // a stack adjustment and the codegen must know that they may modify the stack
342 // pointer before prolog-epilog rewriting occurs.
343 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
344 // sub / add which can clobber EFLAGS.
345 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
346 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
348 [(X86callseq_start timm:$amt)]>,
349 Requires<[In32BitMode]>;
350 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
352 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
353 Requires<[In32BitMode]>;
357 let neverHasSideEffects = 1 in
358 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
361 let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
362 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
363 "call\t$label\n\tpop{l}\t$reg", []>;
365 //===----------------------------------------------------------------------===//
366 // Control Flow Instructions...
369 // Return instructions.
370 let isTerminator = 1, isReturn = 1, isBarrier = 1,
371 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
372 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
375 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
377 [(X86retflag imm:$amt)]>;
380 // All branches are RawFrm, Void, Branch, and Terminators
381 let isBranch = 1, isTerminator = 1 in
382 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
383 I<opcode, RawFrm, (outs), ins, asm, pattern>;
385 let isBranch = 1, isBarrier = 1 in
386 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
389 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
390 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
391 [(brind GR32:$dst)]>;
392 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
393 [(brind (loadi32 addr:$dst))]>;
396 // Conditional branches
397 let Uses = [EFLAGS] in {
398 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
399 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
400 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
401 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
402 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
403 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
404 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
405 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
406 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
407 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
408 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
409 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
411 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
412 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
413 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
414 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
415 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
416 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
417 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
418 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
420 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
421 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
422 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
423 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
424 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
425 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
426 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
427 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
428 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
429 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
430 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
431 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
434 //===----------------------------------------------------------------------===//
435 // Call Instructions...
438 // All calls clobber the non-callee saved registers. ESP is marked as
439 // a use to prevent stack-pointer assignments that appear immediately
440 // before calls from potentially appearing dead. Uses for argument
441 // registers are added manually.
442 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
443 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
444 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS],
446 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
447 "call\t${dst:call}", []>;
448 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
449 "call\t{*}$dst", [(X86call GR32:$dst)]>;
450 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
451 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
456 def TAILCALL : I<0, Pseudo, (outs), (ins),
460 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
461 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
462 "#TC_RETURN $dst $offset",
465 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
466 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
467 "#TC_RETURN $dst $offset",
470 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
472 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
474 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
475 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
477 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
478 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
479 "jmp\t{*}$dst # TAILCALL", []>;
481 //===----------------------------------------------------------------------===//
482 // Miscellaneous Instructions...
484 let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
485 def LEAVE : I<0xC9, RawFrm,
486 (outs), (ins), "leave", []>;
488 let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
490 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
493 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
496 let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
497 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
498 let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
499 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
501 let isTwoAddress = 1 in // GR32 = bswap GR32
502 def BSWAP32r : I<0xC8, AddRegFrm,
503 (outs GR32:$dst), (ins GR32:$src),
505 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
508 // Bit scan instructions.
509 let Defs = [EFLAGS] in {
510 def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
511 "bsf{w}\t{$src, $dst|$dst, $src}",
512 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
513 def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
514 "bsf{w}\t{$src, $dst|$dst, $src}",
515 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
516 (implicit EFLAGS)]>, TB;
517 def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
518 "bsf{l}\t{$src, $dst|$dst, $src}",
519 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
520 def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
521 "bsf{l}\t{$src, $dst|$dst, $src}",
522 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
523 (implicit EFLAGS)]>, TB;
525 def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
526 "bsr{w}\t{$src, $dst|$dst, $src}",
527 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
528 def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
529 "bsr{w}\t{$src, $dst|$dst, $src}",
530 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
531 (implicit EFLAGS)]>, TB;
532 def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
533 "bsr{l}\t{$src, $dst|$dst, $src}",
534 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
535 def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
536 "bsr{l}\t{$src, $dst|$dst, $src}",
537 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
538 (implicit EFLAGS)]>, TB;
541 let neverHasSideEffects = 1 in
542 def LEA16r : I<0x8D, MRMSrcMem,
543 (outs GR16:$dst), (ins i32mem:$src),
544 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
545 let isReMaterializable = 1 in
546 def LEA32r : I<0x8D, MRMSrcMem,
547 (outs GR32:$dst), (ins lea32mem:$src),
548 "lea{l}\t{$src|$dst}, {$dst|$src}",
549 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
551 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
552 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
553 [(X86rep_movs i8)]>, REP;
554 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
555 [(X86rep_movs i16)]>, REP, OpSize;
556 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
557 [(X86rep_movs i32)]>, REP;
560 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
561 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
562 [(X86rep_stos i8)]>, REP;
563 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
564 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
565 [(X86rep_stos i16)]>, REP, OpSize;
566 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
567 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
568 [(X86rep_stos i32)]>, REP;
570 let Defs = [RAX, RDX] in
571 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
574 let isBarrier = 1, hasCtrlDep = 1 in {
575 def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
578 //===----------------------------------------------------------------------===//
579 // Input/Output Instructions...
581 let Defs = [AL], Uses = [DX] in
582 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
583 "in{b}\t{%dx, %al|%AL, %DX}", []>;
584 let Defs = [AX], Uses = [DX] in
585 def IN16rr : I<0xED, RawFrm, (outs), (ins),
586 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
587 let Defs = [EAX], Uses = [DX] in
588 def IN32rr : I<0xED, RawFrm, (outs), (ins),
589 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
592 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
593 "in{b}\t{$port, %al|%AL, $port}", []>;
595 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
596 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
598 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
599 "in{l}\t{$port, %eax|%EAX, $port}", []>;
601 let Uses = [DX, AL] in
602 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
603 "out{b}\t{%al, %dx|%DX, %AL}", []>;
604 let Uses = [DX, AX] in
605 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
606 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
607 let Uses = [DX, EAX] in
608 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
609 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
612 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
613 "out{b}\t{%al, $port|$port, %AL}", []>;
615 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
616 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
618 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
619 "out{l}\t{%eax, $port|$port, %EAX}", []>;
621 //===----------------------------------------------------------------------===//
622 // Move Instructions...
624 let neverHasSideEffects = 1 in {
625 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
626 "mov{b}\t{$src, $dst|$dst, $src}", []>;
627 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
628 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
629 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
630 "mov{l}\t{$src, $dst|$dst, $src}", []>;
632 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
633 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
634 "mov{b}\t{$src, $dst|$dst, $src}",
635 [(set GR8:$dst, imm:$src)]>;
636 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
637 "mov{w}\t{$src, $dst|$dst, $src}",
638 [(set GR16:$dst, imm:$src)]>, OpSize;
639 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
640 "mov{l}\t{$src, $dst|$dst, $src}",
641 [(set GR32:$dst, imm:$src)]>;
643 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
644 "mov{b}\t{$src, $dst|$dst, $src}",
645 [(store (i8 imm:$src), addr:$dst)]>;
646 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
647 "mov{w}\t{$src, $dst|$dst, $src}",
648 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
649 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
650 "mov{l}\t{$src, $dst|$dst, $src}",
651 [(store (i32 imm:$src), addr:$dst)]>;
653 let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
654 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
655 "mov{b}\t{$src, $dst|$dst, $src}",
656 [(set GR8:$dst, (load addr:$src))]>;
657 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
658 "mov{w}\t{$src, $dst|$dst, $src}",
659 [(set GR16:$dst, (load addr:$src))]>, OpSize;
660 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
661 "mov{l}\t{$src, $dst|$dst, $src}",
662 [(set GR32:$dst, (load addr:$src))]>;
665 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
666 "mov{b}\t{$src, $dst|$dst, $src}",
667 [(store GR8:$src, addr:$dst)]>;
668 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
669 "mov{w}\t{$src, $dst|$dst, $src}",
670 [(store GR16:$src, addr:$dst)]>, OpSize;
671 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
672 "mov{l}\t{$src, $dst|$dst, $src}",
673 [(store GR32:$src, addr:$dst)]>;
675 //===----------------------------------------------------------------------===//
676 // Fixed-Register Multiplication and Division Instructions...
679 // Extra precision multiplication
680 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
681 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
682 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
683 // This probably ought to be moved to a def : Pat<> if the
684 // syntax can be accepted.
685 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
686 let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
687 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
688 OpSize; // AX,DX = AX*GR16
689 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
690 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
691 // EAX,EDX = EAX*GR32
692 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
693 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
695 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
696 // This probably ought to be moved to a def : Pat<> if the
697 // syntax can be accepted.
698 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
699 let mayLoad = 1, neverHasSideEffects = 1 in {
700 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
701 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
702 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
703 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
704 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
705 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
708 let neverHasSideEffects = 1 in {
709 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
710 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
712 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
713 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
714 OpSize; // AX,DX = AX*GR16
715 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
716 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
717 // EAX,EDX = EAX*GR32
719 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
720 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
721 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
722 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
723 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
724 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
725 let Defs = [EAX,EDX], Uses = [EAX] in
726 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
727 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
730 // unsigned division/remainder
731 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
732 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
734 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
735 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
736 "div{w}\t$src", []>, OpSize;
737 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
738 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
741 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
742 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
744 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
745 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
746 "div{w}\t$src", []>, OpSize;
747 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
748 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
752 // Signed division/remainder.
753 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
754 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
755 "idiv{b}\t$src", []>;
756 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
757 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
758 "idiv{w}\t$src", []>, OpSize;
759 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
760 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
761 "idiv{l}\t$src", []>;
762 let mayLoad = 1, mayLoad = 1 in {
763 let Defs = [AL,AH,EFLAGS], Uses = [AX] in
764 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
765 "idiv{b}\t$src", []>;
766 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
767 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
768 "idiv{w}\t$src", []>, OpSize;
769 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
770 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
771 "idiv{l}\t$src", []>;
773 } // neverHasSideEffects
775 //===----------------------------------------------------------------------===//
776 // Two address Instructions.
778 let isTwoAddress = 1 in {
781 let Uses = [EFLAGS] in {
782 let isCommutable = 1 in {
783 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
784 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
785 "cmovb\t{$src2, $dst|$dst, $src2}",
786 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
787 X86_COND_B, EFLAGS))]>,
789 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
790 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
791 "cmovb\t{$src2, $dst|$dst, $src2}",
792 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
793 X86_COND_B, EFLAGS))]>,
796 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
797 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
798 "cmovae\t{$src2, $dst|$dst, $src2}",
799 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
800 X86_COND_AE, EFLAGS))]>,
802 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
803 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
804 "cmovae\t{$src2, $dst|$dst, $src2}",
805 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
806 X86_COND_AE, EFLAGS))]>,
808 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
809 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
810 "cmove\t{$src2, $dst|$dst, $src2}",
811 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
812 X86_COND_E, EFLAGS))]>,
814 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
815 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
816 "cmove\t{$src2, $dst|$dst, $src2}",
817 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
818 X86_COND_E, EFLAGS))]>,
820 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
821 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
822 "cmovne\t{$src2, $dst|$dst, $src2}",
823 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
824 X86_COND_NE, EFLAGS))]>,
826 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
827 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
828 "cmovne\t{$src2, $dst|$dst, $src2}",
829 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
830 X86_COND_NE, EFLAGS))]>,
832 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
833 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
834 "cmovbe\t{$src2, $dst|$dst, $src2}",
835 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
836 X86_COND_BE, EFLAGS))]>,
838 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
839 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
840 "cmovbe\t{$src2, $dst|$dst, $src2}",
841 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
842 X86_COND_BE, EFLAGS))]>,
844 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
845 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
846 "cmova\t{$src2, $dst|$dst, $src2}",
847 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
848 X86_COND_A, EFLAGS))]>,
850 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
851 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
852 "cmova\t{$src2, $dst|$dst, $src2}",
853 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
854 X86_COND_A, EFLAGS))]>,
856 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
857 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
858 "cmovl\t{$src2, $dst|$dst, $src2}",
859 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
860 X86_COND_L, EFLAGS))]>,
862 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
863 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
864 "cmovl\t{$src2, $dst|$dst, $src2}",
865 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
866 X86_COND_L, EFLAGS))]>,
868 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
869 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
870 "cmovge\t{$src2, $dst|$dst, $src2}",
871 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
872 X86_COND_GE, EFLAGS))]>,
874 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
875 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
876 "cmovge\t{$src2, $dst|$dst, $src2}",
877 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
878 X86_COND_GE, EFLAGS))]>,
880 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
881 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
882 "cmovle\t{$src2, $dst|$dst, $src2}",
883 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
884 X86_COND_LE, EFLAGS))]>,
886 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
887 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
888 "cmovle\t{$src2, $dst|$dst, $src2}",
889 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
890 X86_COND_LE, EFLAGS))]>,
892 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
893 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
894 "cmovg\t{$src2, $dst|$dst, $src2}",
895 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
896 X86_COND_G, EFLAGS))]>,
898 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
899 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
900 "cmovg\t{$src2, $dst|$dst, $src2}",
901 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
902 X86_COND_G, EFLAGS))]>,
904 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
905 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
906 "cmovs\t{$src2, $dst|$dst, $src2}",
907 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
908 X86_COND_S, EFLAGS))]>,
910 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
911 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
912 "cmovs\t{$src2, $dst|$dst, $src2}",
913 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
914 X86_COND_S, EFLAGS))]>,
916 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
917 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
918 "cmovns\t{$src2, $dst|$dst, $src2}",
919 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
920 X86_COND_NS, EFLAGS))]>,
922 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
923 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
924 "cmovns\t{$src2, $dst|$dst, $src2}",
925 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
926 X86_COND_NS, EFLAGS))]>,
928 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
929 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
930 "cmovp\t{$src2, $dst|$dst, $src2}",
931 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
932 X86_COND_P, EFLAGS))]>,
934 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
935 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
936 "cmovp\t{$src2, $dst|$dst, $src2}",
937 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
938 X86_COND_P, EFLAGS))]>,
940 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
941 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
942 "cmovnp\t{$src2, $dst|$dst, $src2}",
943 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
944 X86_COND_NP, EFLAGS))]>,
946 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
947 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
948 "cmovnp\t{$src2, $dst|$dst, $src2}",
949 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
950 X86_COND_NP, EFLAGS))]>,
952 } // isCommutable = 1
954 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
955 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
956 "cmovnp\t{$src2, $dst|$dst, $src2}",
957 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
958 X86_COND_NP, EFLAGS))]>,
961 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
962 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
963 "cmovb\t{$src2, $dst|$dst, $src2}",
964 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
965 X86_COND_B, EFLAGS))]>,
967 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
968 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
969 "cmovb\t{$src2, $dst|$dst, $src2}",
970 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
971 X86_COND_B, EFLAGS))]>,
973 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
974 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
975 "cmovae\t{$src2, $dst|$dst, $src2}",
976 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
977 X86_COND_AE, EFLAGS))]>,
979 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
980 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
981 "cmovae\t{$src2, $dst|$dst, $src2}",
982 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
983 X86_COND_AE, EFLAGS))]>,
985 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
986 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
987 "cmove\t{$src2, $dst|$dst, $src2}",
988 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
989 X86_COND_E, EFLAGS))]>,
991 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
992 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
993 "cmove\t{$src2, $dst|$dst, $src2}",
994 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
995 X86_COND_E, EFLAGS))]>,
997 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
998 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
999 "cmovne\t{$src2, $dst|$dst, $src2}",
1000 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1001 X86_COND_NE, EFLAGS))]>,
1003 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1004 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1005 "cmovne\t{$src2, $dst|$dst, $src2}",
1006 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1007 X86_COND_NE, EFLAGS))]>,
1009 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1010 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1011 "cmovbe\t{$src2, $dst|$dst, $src2}",
1012 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1013 X86_COND_BE, EFLAGS))]>,
1015 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1016 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1017 "cmovbe\t{$src2, $dst|$dst, $src2}",
1018 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1019 X86_COND_BE, EFLAGS))]>,
1021 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1022 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1023 "cmova\t{$src2, $dst|$dst, $src2}",
1024 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1025 X86_COND_A, EFLAGS))]>,
1027 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1028 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1029 "cmova\t{$src2, $dst|$dst, $src2}",
1030 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1031 X86_COND_A, EFLAGS))]>,
1033 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1034 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1035 "cmovl\t{$src2, $dst|$dst, $src2}",
1036 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1037 X86_COND_L, EFLAGS))]>,
1039 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1040 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1041 "cmovl\t{$src2, $dst|$dst, $src2}",
1042 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1043 X86_COND_L, EFLAGS))]>,
1045 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1046 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1047 "cmovge\t{$src2, $dst|$dst, $src2}",
1048 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1049 X86_COND_GE, EFLAGS))]>,
1051 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1052 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1053 "cmovge\t{$src2, $dst|$dst, $src2}",
1054 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1055 X86_COND_GE, EFLAGS))]>,
1057 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1058 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1059 "cmovle\t{$src2, $dst|$dst, $src2}",
1060 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1061 X86_COND_LE, EFLAGS))]>,
1063 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1064 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1065 "cmovle\t{$src2, $dst|$dst, $src2}",
1066 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1067 X86_COND_LE, EFLAGS))]>,
1069 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1070 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1071 "cmovg\t{$src2, $dst|$dst, $src2}",
1072 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1073 X86_COND_G, EFLAGS))]>,
1075 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1076 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1077 "cmovg\t{$src2, $dst|$dst, $src2}",
1078 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1079 X86_COND_G, EFLAGS))]>,
1081 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1082 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1083 "cmovs\t{$src2, $dst|$dst, $src2}",
1084 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1085 X86_COND_S, EFLAGS))]>,
1087 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1088 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1089 "cmovs\t{$src2, $dst|$dst, $src2}",
1090 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1091 X86_COND_S, EFLAGS))]>,
1093 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1094 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1095 "cmovns\t{$src2, $dst|$dst, $src2}",
1096 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1097 X86_COND_NS, EFLAGS))]>,
1099 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1100 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1101 "cmovns\t{$src2, $dst|$dst, $src2}",
1102 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1103 X86_COND_NS, EFLAGS))]>,
1105 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1106 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1107 "cmovp\t{$src2, $dst|$dst, $src2}",
1108 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1109 X86_COND_P, EFLAGS))]>,
1111 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1112 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1113 "cmovp\t{$src2, $dst|$dst, $src2}",
1114 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1115 X86_COND_P, EFLAGS))]>,
1117 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1118 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1119 "cmovnp\t{$src2, $dst|$dst, $src2}",
1120 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1121 X86_COND_NP, EFLAGS))]>,
1123 } // Uses = [EFLAGS]
1126 // unary instructions
1127 let CodeSize = 2 in {
1128 let Defs = [EFLAGS] in {
1129 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1130 [(set GR8:$dst, (ineg GR8:$src))]>;
1131 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1132 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1133 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1134 [(set GR32:$dst, (ineg GR32:$src))]>;
1135 let isTwoAddress = 0 in {
1136 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1137 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1138 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1139 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1140 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1141 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1144 } // Defs = [EFLAGS]
1146 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1147 [(set GR8:$dst, (not GR8:$src))]>;
1148 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1149 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1150 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1151 [(set GR32:$dst, (not GR32:$src))]>;
1152 let isTwoAddress = 0 in {
1153 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1154 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1155 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1156 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1157 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1158 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1162 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1163 let Defs = [EFLAGS] in {
1165 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1166 [(set GR8:$dst, (add GR8:$src, 1))]>;
1167 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1168 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1169 [(set GR16:$dst, (add GR16:$src, 1))]>,
1170 OpSize, Requires<[In32BitMode]>;
1171 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1172 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1174 let isTwoAddress = 0, CodeSize = 2 in {
1175 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1176 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1177 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1178 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1179 OpSize, Requires<[In32BitMode]>;
1180 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1181 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1182 Requires<[In32BitMode]>;
1186 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1187 [(set GR8:$dst, (add GR8:$src, -1))]>;
1188 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1189 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1190 [(set GR16:$dst, (add GR16:$src, -1))]>,
1191 OpSize, Requires<[In32BitMode]>;
1192 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1193 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1196 let isTwoAddress = 0, CodeSize = 2 in {
1197 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1198 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1199 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1200 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1201 OpSize, Requires<[In32BitMode]>;
1202 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1203 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1204 Requires<[In32BitMode]>;
1206 } // Defs = [EFLAGS]
1208 // Logical operators...
1209 let Defs = [EFLAGS] in {
1210 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1211 def AND8rr : I<0x20, MRMDestReg,
1212 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1213 "and{b}\t{$src2, $dst|$dst, $src2}",
1214 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1215 def AND16rr : I<0x21, MRMDestReg,
1216 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1217 "and{w}\t{$src2, $dst|$dst, $src2}",
1218 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1219 def AND32rr : I<0x21, MRMDestReg,
1220 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1221 "and{l}\t{$src2, $dst|$dst, $src2}",
1222 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1225 def AND8rm : I<0x22, MRMSrcMem,
1226 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1227 "and{b}\t{$src2, $dst|$dst, $src2}",
1228 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1229 def AND16rm : I<0x23, MRMSrcMem,
1230 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1231 "and{w}\t{$src2, $dst|$dst, $src2}",
1232 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1233 def AND32rm : I<0x23, MRMSrcMem,
1234 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1235 "and{l}\t{$src2, $dst|$dst, $src2}",
1236 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1238 def AND8ri : Ii8<0x80, MRM4r,
1239 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1240 "and{b}\t{$src2, $dst|$dst, $src2}",
1241 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1242 def AND16ri : Ii16<0x81, MRM4r,
1243 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1244 "and{w}\t{$src2, $dst|$dst, $src2}",
1245 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1246 def AND32ri : Ii32<0x81, MRM4r,
1247 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1248 "and{l}\t{$src2, $dst|$dst, $src2}",
1249 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1250 def AND16ri8 : Ii8<0x83, MRM4r,
1251 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1252 "and{w}\t{$src2, $dst|$dst, $src2}",
1253 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1255 def AND32ri8 : Ii8<0x83, MRM4r,
1256 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1257 "and{l}\t{$src2, $dst|$dst, $src2}",
1258 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1260 let isTwoAddress = 0 in {
1261 def AND8mr : I<0x20, MRMDestMem,
1262 (outs), (ins i8mem :$dst, GR8 :$src),
1263 "and{b}\t{$src, $dst|$dst, $src}",
1264 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1265 def AND16mr : I<0x21, MRMDestMem,
1266 (outs), (ins i16mem:$dst, GR16:$src),
1267 "and{w}\t{$src, $dst|$dst, $src}",
1268 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1270 def AND32mr : I<0x21, MRMDestMem,
1271 (outs), (ins i32mem:$dst, GR32:$src),
1272 "and{l}\t{$src, $dst|$dst, $src}",
1273 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1274 def AND8mi : Ii8<0x80, MRM4m,
1275 (outs), (ins i8mem :$dst, i8imm :$src),
1276 "and{b}\t{$src, $dst|$dst, $src}",
1277 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1278 def AND16mi : Ii16<0x81, MRM4m,
1279 (outs), (ins i16mem:$dst, i16imm:$src),
1280 "and{w}\t{$src, $dst|$dst, $src}",
1281 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1283 def AND32mi : Ii32<0x81, MRM4m,
1284 (outs), (ins i32mem:$dst, i32imm:$src),
1285 "and{l}\t{$src, $dst|$dst, $src}",
1286 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1287 def AND16mi8 : Ii8<0x83, MRM4m,
1288 (outs), (ins i16mem:$dst, i16i8imm :$src),
1289 "and{w}\t{$src, $dst|$dst, $src}",
1290 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1292 def AND32mi8 : Ii8<0x83, MRM4m,
1293 (outs), (ins i32mem:$dst, i32i8imm :$src),
1294 "and{l}\t{$src, $dst|$dst, $src}",
1295 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1299 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1300 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1301 "or{b}\t{$src2, $dst|$dst, $src2}",
1302 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1303 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1304 "or{w}\t{$src2, $dst|$dst, $src2}",
1305 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1306 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1307 "or{l}\t{$src2, $dst|$dst, $src2}",
1308 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1310 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1311 "or{b}\t{$src2, $dst|$dst, $src2}",
1312 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1313 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1314 "or{w}\t{$src2, $dst|$dst, $src2}",
1315 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1316 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1317 "or{l}\t{$src2, $dst|$dst, $src2}",
1318 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1320 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1321 "or{b}\t{$src2, $dst|$dst, $src2}",
1322 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1323 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1324 "or{w}\t{$src2, $dst|$dst, $src2}",
1325 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1326 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1327 "or{l}\t{$src2, $dst|$dst, $src2}",
1328 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1330 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1331 "or{w}\t{$src2, $dst|$dst, $src2}",
1332 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1333 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1334 "or{l}\t{$src2, $dst|$dst, $src2}",
1335 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1336 let isTwoAddress = 0 in {
1337 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1338 "or{b}\t{$src, $dst|$dst, $src}",
1339 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1340 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1341 "or{w}\t{$src, $dst|$dst, $src}",
1342 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1343 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1344 "or{l}\t{$src, $dst|$dst, $src}",
1345 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
1346 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1347 "or{b}\t{$src, $dst|$dst, $src}",
1348 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1349 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1350 "or{w}\t{$src, $dst|$dst, $src}",
1351 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1353 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1354 "or{l}\t{$src, $dst|$dst, $src}",
1355 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1356 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1357 "or{w}\t{$src, $dst|$dst, $src}",
1358 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1360 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1361 "or{l}\t{$src, $dst|$dst, $src}",
1362 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1363 } // isTwoAddress = 0
1366 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1367 def XOR8rr : I<0x30, MRMDestReg,
1368 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1369 "xor{b}\t{$src2, $dst|$dst, $src2}",
1370 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1371 def XOR16rr : I<0x31, MRMDestReg,
1372 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1373 "xor{w}\t{$src2, $dst|$dst, $src2}",
1374 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1375 def XOR32rr : I<0x31, MRMDestReg,
1376 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1377 "xor{l}\t{$src2, $dst|$dst, $src2}",
1378 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1379 } // isCommutable = 1
1381 def XOR8rm : I<0x32, MRMSrcMem ,
1382 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1383 "xor{b}\t{$src2, $dst|$dst, $src2}",
1384 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1385 def XOR16rm : I<0x33, MRMSrcMem ,
1386 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1387 "xor{w}\t{$src2, $dst|$dst, $src2}",
1388 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1390 def XOR32rm : I<0x33, MRMSrcMem ,
1391 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1392 "xor{l}\t{$src2, $dst|$dst, $src2}",
1393 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1395 def XOR8ri : Ii8<0x80, MRM6r,
1396 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1397 "xor{b}\t{$src2, $dst|$dst, $src2}",
1398 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1399 def XOR16ri : Ii16<0x81, MRM6r,
1400 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1401 "xor{w}\t{$src2, $dst|$dst, $src2}",
1402 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1403 def XOR32ri : Ii32<0x81, MRM6r,
1404 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1405 "xor{l}\t{$src2, $dst|$dst, $src2}",
1406 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1407 def XOR16ri8 : Ii8<0x83, MRM6r,
1408 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1409 "xor{w}\t{$src2, $dst|$dst, $src2}",
1410 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1412 def XOR32ri8 : Ii8<0x83, MRM6r,
1413 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1414 "xor{l}\t{$src2, $dst|$dst, $src2}",
1415 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1417 let isTwoAddress = 0 in {
1418 def XOR8mr : I<0x30, MRMDestMem,
1419 (outs), (ins i8mem :$dst, GR8 :$src),
1420 "xor{b}\t{$src, $dst|$dst, $src}",
1421 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1422 def XOR16mr : I<0x31, MRMDestMem,
1423 (outs), (ins i16mem:$dst, GR16:$src),
1424 "xor{w}\t{$src, $dst|$dst, $src}",
1425 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1427 def XOR32mr : I<0x31, MRMDestMem,
1428 (outs), (ins i32mem:$dst, GR32:$src),
1429 "xor{l}\t{$src, $dst|$dst, $src}",
1430 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1431 def XOR8mi : Ii8<0x80, MRM6m,
1432 (outs), (ins i8mem :$dst, i8imm :$src),
1433 "xor{b}\t{$src, $dst|$dst, $src}",
1434 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1435 def XOR16mi : Ii16<0x81, MRM6m,
1436 (outs), (ins i16mem:$dst, i16imm:$src),
1437 "xor{w}\t{$src, $dst|$dst, $src}",
1438 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1440 def XOR32mi : Ii32<0x81, MRM6m,
1441 (outs), (ins i32mem:$dst, i32imm:$src),
1442 "xor{l}\t{$src, $dst|$dst, $src}",
1443 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1444 def XOR16mi8 : Ii8<0x83, MRM6m,
1445 (outs), (ins i16mem:$dst, i16i8imm :$src),
1446 "xor{w}\t{$src, $dst|$dst, $src}",
1447 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1449 def XOR32mi8 : Ii8<0x83, MRM6m,
1450 (outs), (ins i32mem:$dst, i32i8imm :$src),
1451 "xor{l}\t{$src, $dst|$dst, $src}",
1452 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1453 } // isTwoAddress = 0
1454 } // Defs = [EFLAGS]
1456 // Shift instructions
1457 let Defs = [EFLAGS] in {
1458 let Uses = [CL] in {
1459 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1460 "shl{b}\t{%cl, $dst|$dst, %CL}",
1461 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1462 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1463 "shl{w}\t{%cl, $dst|$dst, %CL}",
1464 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1465 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1466 "shl{l}\t{%cl, $dst|$dst, %CL}",
1467 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1470 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1471 "shl{b}\t{$src2, $dst|$dst, $src2}",
1472 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1473 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1474 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1475 "shl{w}\t{$src2, $dst|$dst, $src2}",
1476 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1477 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1478 "shl{l}\t{$src2, $dst|$dst, $src2}",
1479 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1480 // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1482 } // isConvertibleToThreeAddress = 1
1484 let isTwoAddress = 0 in {
1485 let Uses = [CL] in {
1486 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1487 "shl{b}\t{%cl, $dst|$dst, %CL}",
1488 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1489 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1490 "shl{w}\t{%cl, $dst|$dst, %CL}",
1491 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1492 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1493 "shl{l}\t{%cl, $dst|$dst, %CL}",
1494 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1496 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1497 "shl{b}\t{$src, $dst|$dst, $src}",
1498 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1499 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1500 "shl{w}\t{$src, $dst|$dst, $src}",
1501 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1503 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1504 "shl{l}\t{$src, $dst|$dst, $src}",
1505 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1508 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1510 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1511 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1513 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1515 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1517 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1520 let Uses = [CL] in {
1521 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1522 "shr{b}\t{%cl, $dst|$dst, %CL}",
1523 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1524 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1525 "shr{w}\t{%cl, $dst|$dst, %CL}",
1526 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1527 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1528 "shr{l}\t{%cl, $dst|$dst, %CL}",
1529 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1532 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1533 "shr{b}\t{$src2, $dst|$dst, $src2}",
1534 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1535 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1536 "shr{w}\t{$src2, $dst|$dst, $src2}",
1537 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1538 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1539 "shr{l}\t{$src2, $dst|$dst, $src2}",
1540 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1543 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1545 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1546 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1548 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1549 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1551 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1553 let isTwoAddress = 0 in {
1554 let Uses = [CL] in {
1555 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1556 "shr{b}\t{%cl, $dst|$dst, %CL}",
1557 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1558 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1559 "shr{w}\t{%cl, $dst|$dst, %CL}",
1560 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1562 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1563 "shr{l}\t{%cl, $dst|$dst, %CL}",
1564 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1566 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1567 "shr{b}\t{$src, $dst|$dst, $src}",
1568 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1569 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1570 "shr{w}\t{$src, $dst|$dst, $src}",
1571 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1573 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1574 "shr{l}\t{$src, $dst|$dst, $src}",
1575 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1578 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1580 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1581 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1583 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1584 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1586 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1589 let Uses = [CL] in {
1590 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1591 "sar{b}\t{%cl, $dst|$dst, %CL}",
1592 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1593 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1594 "sar{w}\t{%cl, $dst|$dst, %CL}",
1595 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1596 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1597 "sar{l}\t{%cl, $dst|$dst, %CL}",
1598 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1601 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1602 "sar{b}\t{$src2, $dst|$dst, $src2}",
1603 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1604 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1605 "sar{w}\t{$src2, $dst|$dst, $src2}",
1606 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1608 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1609 "sar{l}\t{$src2, $dst|$dst, $src2}",
1610 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1613 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1615 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1616 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1618 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1619 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1621 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1623 let isTwoAddress = 0 in {
1624 let Uses = [CL] in {
1625 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1626 "sar{b}\t{%cl, $dst|$dst, %CL}",
1627 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1628 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1629 "sar{w}\t{%cl, $dst|$dst, %CL}",
1630 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1631 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1632 "sar{l}\t{%cl, $dst|$dst, %CL}",
1633 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1635 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1636 "sar{b}\t{$src, $dst|$dst, $src}",
1637 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1638 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1639 "sar{w}\t{$src, $dst|$dst, $src}",
1640 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1642 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1643 "sar{l}\t{$src, $dst|$dst, $src}",
1644 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1647 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1649 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1650 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1652 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1654 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1656 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1659 // Rotate instructions
1660 // FIXME: provide shorter instructions when imm8 == 1
1661 let Uses = [CL] in {
1662 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1663 "rol{b}\t{%cl, $dst|$dst, %CL}",
1664 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1665 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1666 "rol{w}\t{%cl, $dst|$dst, %CL}",
1667 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1668 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1669 "rol{l}\t{%cl, $dst|$dst, %CL}",
1670 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1673 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1674 "rol{b}\t{$src2, $dst|$dst, $src2}",
1675 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1676 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1677 "rol{w}\t{$src2, $dst|$dst, $src2}",
1678 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1679 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1680 "rol{l}\t{$src2, $dst|$dst, $src2}",
1681 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1684 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1686 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1687 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1689 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1690 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1692 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1694 let isTwoAddress = 0 in {
1695 let Uses = [CL] in {
1696 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1697 "rol{b}\t{%cl, $dst|$dst, %CL}",
1698 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
1699 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1700 "rol{w}\t{%cl, $dst|$dst, %CL}",
1701 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1702 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1703 "rol{l}\t{%cl, $dst|$dst, %CL}",
1704 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1706 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
1707 "rol{b}\t{$src, $dst|$dst, $src}",
1708 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1709 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
1710 "rol{w}\t{$src, $dst|$dst, $src}",
1711 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1713 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
1714 "rol{l}\t{$src, $dst|$dst, $src}",
1715 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1718 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
1720 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1721 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
1723 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1725 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
1727 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1730 let Uses = [CL] in {
1731 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
1732 "ror{b}\t{%cl, $dst|$dst, %CL}",
1733 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
1734 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
1735 "ror{w}\t{%cl, $dst|$dst, %CL}",
1736 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
1737 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
1738 "ror{l}\t{%cl, $dst|$dst, %CL}",
1739 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1742 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1743 "ror{b}\t{$src2, $dst|$dst, $src2}",
1744 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1745 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1746 "ror{w}\t{$src2, $dst|$dst, $src2}",
1747 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1748 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1749 "ror{l}\t{$src2, $dst|$dst, $src2}",
1750 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1753 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1755 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1756 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
1758 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1759 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
1761 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1763 let isTwoAddress = 0 in {
1764 let Uses = [CL] in {
1765 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
1766 "ror{b}\t{%cl, $dst|$dst, %CL}",
1767 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
1768 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
1769 "ror{w}\t{%cl, $dst|$dst, %CL}",
1770 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1771 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
1772 "ror{l}\t{%cl, $dst|$dst, %CL}",
1773 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1775 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1776 "ror{b}\t{$src, $dst|$dst, $src}",
1777 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1778 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
1779 "ror{w}\t{$src, $dst|$dst, $src}",
1780 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1782 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
1783 "ror{l}\t{$src, $dst|$dst, $src}",
1784 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1787 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
1789 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1790 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
1792 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1794 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
1796 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1801 // Double shift instructions (generalizations of rotate)
1802 let Uses = [CL] in {
1803 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1804 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1805 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
1806 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1807 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1808 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
1809 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1810 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1811 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1813 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1814 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1815 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1819 let isCommutable = 1 in { // These instructions commute to each other.
1820 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1821 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1822 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1823 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1826 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1827 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1828 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1829 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1832 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1833 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1834 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1835 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1838 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1839 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1840 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1841 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1846 let isTwoAddress = 0 in {
1847 let Uses = [CL] in {
1848 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1849 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1850 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1852 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1853 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1854 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1857 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1858 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1859 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1860 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1861 (i8 imm:$src3)), addr:$dst)]>,
1863 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1864 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1865 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1866 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1867 (i8 imm:$src3)), addr:$dst)]>,
1870 let Uses = [CL] in {
1871 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1872 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1873 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1874 addr:$dst)]>, TB, OpSize;
1875 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1876 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1877 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1878 addr:$dst)]>, TB, OpSize;
1880 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1881 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1882 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1883 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1884 (i8 imm:$src3)), addr:$dst)]>,
1886 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1887 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1888 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1889 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1890 (i8 imm:$src3)), addr:$dst)]>,
1893 } // Defs = [EFLAGS]
1897 let Defs = [EFLAGS] in {
1898 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1899 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1900 (ins GR8 :$src1, GR8 :$src2),
1901 "add{b}\t{$src2, $dst|$dst, $src2}",
1902 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1903 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1904 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1905 (ins GR16:$src1, GR16:$src2),
1906 "add{w}\t{$src2, $dst|$dst, $src2}",
1907 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1908 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1909 (ins GR32:$src1, GR32:$src2),
1910 "add{l}\t{$src2, $dst|$dst, $src2}",
1911 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1912 } // end isConvertibleToThreeAddress
1913 } // end isCommutable
1914 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1915 (ins GR8 :$src1, i8mem :$src2),
1916 "add{b}\t{$src2, $dst|$dst, $src2}",
1917 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1918 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1919 (ins GR16:$src1, i16mem:$src2),
1920 "add{w}\t{$src2, $dst|$dst, $src2}",
1921 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1922 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1923 (ins GR32:$src1, i32mem:$src2),
1924 "add{l}\t{$src2, $dst|$dst, $src2}",
1925 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1927 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1928 "add{b}\t{$src2, $dst|$dst, $src2}",
1929 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1931 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1932 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1933 (ins GR16:$src1, i16imm:$src2),
1934 "add{w}\t{$src2, $dst|$dst, $src2}",
1935 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1936 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1937 (ins GR32:$src1, i32imm:$src2),
1938 "add{l}\t{$src2, $dst|$dst, $src2}",
1939 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
1940 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1941 (ins GR16:$src1, i16i8imm:$src2),
1942 "add{w}\t{$src2, $dst|$dst, $src2}",
1943 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1944 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1945 (ins GR32:$src1, i32i8imm:$src2),
1946 "add{l}\t{$src2, $dst|$dst, $src2}",
1947 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1950 let isTwoAddress = 0 in {
1951 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
1952 "add{b}\t{$src2, $dst|$dst, $src2}",
1953 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1954 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1955 "add{w}\t{$src2, $dst|$dst, $src2}",
1956 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1958 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1959 "add{l}\t{$src2, $dst|$dst, $src2}",
1960 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
1961 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
1962 "add{b}\t{$src2, $dst|$dst, $src2}",
1963 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1964 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
1965 "add{w}\t{$src2, $dst|$dst, $src2}",
1966 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1968 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
1969 "add{l}\t{$src2, $dst|$dst, $src2}",
1970 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1971 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
1972 "add{w}\t{$src2, $dst|$dst, $src2}",
1973 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1975 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1976 "add{l}\t{$src2, $dst|$dst, $src2}",
1977 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1980 let Uses = [EFLAGS] in {
1981 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1982 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1983 "adc{l}\t{$src2, $dst|$dst, $src2}",
1984 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1986 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1987 "adc{l}\t{$src2, $dst|$dst, $src2}",
1988 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1989 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1990 "adc{l}\t{$src2, $dst|$dst, $src2}",
1991 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1992 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1993 "adc{l}\t{$src2, $dst|$dst, $src2}",
1994 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1996 let isTwoAddress = 0 in {
1997 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1998 "adc{l}\t{$src2, $dst|$dst, $src2}",
1999 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2000 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
2001 "adc{l}\t{$src2, $dst|$dst, $src2}",
2002 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2003 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2004 "adc{l}\t{$src2, $dst|$dst, $src2}",
2005 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2007 } // Uses = [EFLAGS]
2009 def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
2010 "sub{b}\t{$src2, $dst|$dst, $src2}",
2011 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
2012 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2013 "sub{w}\t{$src2, $dst|$dst, $src2}",
2014 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
2015 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2016 "sub{l}\t{$src2, $dst|$dst, $src2}",
2017 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
2018 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
2019 "sub{b}\t{$src2, $dst|$dst, $src2}",
2020 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
2021 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
2022 "sub{w}\t{$src2, $dst|$dst, $src2}",
2023 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
2024 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2025 "sub{l}\t{$src2, $dst|$dst, $src2}",
2026 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
2028 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2029 "sub{b}\t{$src2, $dst|$dst, $src2}",
2030 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
2031 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2032 "sub{w}\t{$src2, $dst|$dst, $src2}",
2033 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
2034 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2035 "sub{l}\t{$src2, $dst|$dst, $src2}",
2036 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
2037 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2038 "sub{w}\t{$src2, $dst|$dst, $src2}",
2039 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
2041 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2042 "sub{l}\t{$src2, $dst|$dst, $src2}",
2043 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
2044 let isTwoAddress = 0 in {
2045 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
2046 "sub{b}\t{$src2, $dst|$dst, $src2}",
2047 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
2048 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2049 "sub{w}\t{$src2, $dst|$dst, $src2}",
2050 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
2052 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2053 "sub{l}\t{$src2, $dst|$dst, $src2}",
2054 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
2055 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
2056 "sub{b}\t{$src2, $dst|$dst, $src2}",
2057 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2058 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
2059 "sub{w}\t{$src2, $dst|$dst, $src2}",
2060 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2062 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
2063 "sub{l}\t{$src2, $dst|$dst, $src2}",
2064 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2065 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2066 "sub{w}\t{$src2, $dst|$dst, $src2}",
2067 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2069 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2070 "sub{l}\t{$src2, $dst|$dst, $src2}",
2071 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2074 let Uses = [EFLAGS] in {
2075 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2076 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2077 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
2079 let isTwoAddress = 0 in {
2080 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
2081 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2082 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
2083 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
2084 "sbb{b}\t{$src2, $dst|$dst, $src2}",
2085 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2086 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
2087 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2088 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2089 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
2090 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2091 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2093 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2094 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2095 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2096 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2097 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2098 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2099 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2100 "sbb{l}\t{$src2, $dst|$dst, $src2}",
2101 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
2102 } // Uses = [EFLAGS]
2103 } // Defs = [EFLAGS]
2105 let Defs = [EFLAGS] in {
2106 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
2107 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
2108 "imul{w}\t{$src2, $dst|$dst, $src2}",
2109 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2110 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
2111 "imul{l}\t{$src2, $dst|$dst, $src2}",
2112 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2114 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
2115 "imul{w}\t{$src2, $dst|$dst, $src2}",
2116 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2118 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2119 "imul{l}\t{$src2, $dst|$dst, $src2}",
2120 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
2121 } // Defs = [EFLAGS]
2122 } // end Two Address instructions
2124 // Suprisingly enough, these are not two address instructions!
2125 let Defs = [EFLAGS] in {
2126 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2127 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2128 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2129 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2130 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2131 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2132 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2133 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2134 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2135 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2136 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2137 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2139 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2140 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2141 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2142 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2144 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2145 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2146 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2147 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2149 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2150 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2151 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2152 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2153 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2154 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2155 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2156 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2158 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2159 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2160 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2161 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2162 } // Defs = [EFLAGS]
2164 //===----------------------------------------------------------------------===//
2165 // Test instructions are just like AND, except they don't generate a result.
2167 let Defs = [EFLAGS] in {
2168 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2169 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2170 "test{b}\t{$src2, $src1|$src1, $src2}",
2171 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
2172 (implicit EFLAGS)]>;
2173 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2174 "test{w}\t{$src2, $src1|$src1, $src2}",
2175 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
2176 (implicit EFLAGS)]>,
2178 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2179 "test{l}\t{$src2, $src1|$src1, $src2}",
2180 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
2181 (implicit EFLAGS)]>;
2184 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2185 "test{b}\t{$src2, $src1|$src1, $src2}",
2186 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2187 (implicit EFLAGS)]>;
2188 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2189 "test{w}\t{$src2, $src1|$src1, $src2}",
2190 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2191 (implicit EFLAGS)]>, OpSize;
2192 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2193 "test{l}\t{$src2, $src1|$src1, $src2}",
2194 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2195 (implicit EFLAGS)]>;
2197 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2198 (outs), (ins GR8:$src1, i8imm:$src2),
2199 "test{b}\t{$src2, $src1|$src1, $src2}",
2200 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
2201 (implicit EFLAGS)]>;
2202 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2203 (outs), (ins GR16:$src1, i16imm:$src2),
2204 "test{w}\t{$src2, $src1|$src1, $src2}",
2205 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
2206 (implicit EFLAGS)]>, OpSize;
2207 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2208 (outs), (ins GR32:$src1, i32imm:$src2),
2209 "test{l}\t{$src2, $src1|$src1, $src2}",
2210 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
2211 (implicit EFLAGS)]>;
2213 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2214 (outs), (ins i8mem:$src1, i8imm:$src2),
2215 "test{b}\t{$src2, $src1|$src1, $src2}",
2216 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2217 (implicit EFLAGS)]>;
2218 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2219 (outs), (ins i16mem:$src1, i16imm:$src2),
2220 "test{w}\t{$src2, $src1|$src1, $src2}",
2221 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2222 (implicit EFLAGS)]>, OpSize;
2223 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2224 (outs), (ins i32mem:$src1, i32imm:$src2),
2225 "test{l}\t{$src2, $src1|$src1, $src2}",
2226 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2227 (implicit EFLAGS)]>;
2228 } // Defs = [EFLAGS]
2231 // Condition code ops, incl. set if equal/not equal/...
2232 let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
2233 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2234 let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
2235 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2237 let Uses = [EFLAGS] in {
2238 def SETEr : I<0x94, MRM0r,
2239 (outs GR8 :$dst), (ins),
2241 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2243 def SETEm : I<0x94, MRM0m,
2244 (outs), (ins i8mem:$dst),
2246 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2248 def SETNEr : I<0x95, MRM0r,
2249 (outs GR8 :$dst), (ins),
2251 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2253 def SETNEm : I<0x95, MRM0m,
2254 (outs), (ins i8mem:$dst),
2256 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2258 def SETLr : I<0x9C, MRM0r,
2259 (outs GR8 :$dst), (ins),
2261 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2262 TB; // GR8 = < signed
2263 def SETLm : I<0x9C, MRM0m,
2264 (outs), (ins i8mem:$dst),
2266 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2267 TB; // [mem8] = < signed
2268 def SETGEr : I<0x9D, MRM0r,
2269 (outs GR8 :$dst), (ins),
2271 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2272 TB; // GR8 = >= signed
2273 def SETGEm : I<0x9D, MRM0m,
2274 (outs), (ins i8mem:$dst),
2276 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2277 TB; // [mem8] = >= signed
2278 def SETLEr : I<0x9E, MRM0r,
2279 (outs GR8 :$dst), (ins),
2281 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2282 TB; // GR8 = <= signed
2283 def SETLEm : I<0x9E, MRM0m,
2284 (outs), (ins i8mem:$dst),
2286 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2287 TB; // [mem8] = <= signed
2288 def SETGr : I<0x9F, MRM0r,
2289 (outs GR8 :$dst), (ins),
2291 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2292 TB; // GR8 = > signed
2293 def SETGm : I<0x9F, MRM0m,
2294 (outs), (ins i8mem:$dst),
2296 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2297 TB; // [mem8] = > signed
2299 def SETBr : I<0x92, MRM0r,
2300 (outs GR8 :$dst), (ins),
2302 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2303 TB; // GR8 = < unsign
2304 def SETBm : I<0x92, MRM0m,
2305 (outs), (ins i8mem:$dst),
2307 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2308 TB; // [mem8] = < unsign
2309 def SETAEr : I<0x93, MRM0r,
2310 (outs GR8 :$dst), (ins),
2312 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2313 TB; // GR8 = >= unsign
2314 def SETAEm : I<0x93, MRM0m,
2315 (outs), (ins i8mem:$dst),
2317 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2318 TB; // [mem8] = >= unsign
2319 def SETBEr : I<0x96, MRM0r,
2320 (outs GR8 :$dst), (ins),
2322 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2323 TB; // GR8 = <= unsign
2324 def SETBEm : I<0x96, MRM0m,
2325 (outs), (ins i8mem:$dst),
2327 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2328 TB; // [mem8] = <= unsign
2329 def SETAr : I<0x97, MRM0r,
2330 (outs GR8 :$dst), (ins),
2332 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2333 TB; // GR8 = > signed
2334 def SETAm : I<0x97, MRM0m,
2335 (outs), (ins i8mem:$dst),
2337 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2338 TB; // [mem8] = > signed
2340 def SETSr : I<0x98, MRM0r,
2341 (outs GR8 :$dst), (ins),
2343 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2344 TB; // GR8 = <sign bit>
2345 def SETSm : I<0x98, MRM0m,
2346 (outs), (ins i8mem:$dst),
2348 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2349 TB; // [mem8] = <sign bit>
2350 def SETNSr : I<0x99, MRM0r,
2351 (outs GR8 :$dst), (ins),
2353 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2354 TB; // GR8 = !<sign bit>
2355 def SETNSm : I<0x99, MRM0m,
2356 (outs), (ins i8mem:$dst),
2358 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2359 TB; // [mem8] = !<sign bit>
2360 def SETPr : I<0x9A, MRM0r,
2361 (outs GR8 :$dst), (ins),
2363 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2365 def SETPm : I<0x9A, MRM0m,
2366 (outs), (ins i8mem:$dst),
2368 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2369 TB; // [mem8] = parity
2370 def SETNPr : I<0x9B, MRM0r,
2371 (outs GR8 :$dst), (ins),
2373 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2374 TB; // GR8 = not parity
2375 def SETNPm : I<0x9B, MRM0m,
2376 (outs), (ins i8mem:$dst),
2378 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2379 TB; // [mem8] = not parity
2380 } // Uses = [EFLAGS]
2383 // Integer comparisons
2384 let Defs = [EFLAGS] in {
2385 def CMP8rr : I<0x38, MRMDestReg,
2386 (outs), (ins GR8 :$src1, GR8 :$src2),
2387 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2388 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2389 def CMP16rr : I<0x39, MRMDestReg,
2390 (outs), (ins GR16:$src1, GR16:$src2),
2391 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2392 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2393 def CMP32rr : I<0x39, MRMDestReg,
2394 (outs), (ins GR32:$src1, GR32:$src2),
2395 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2396 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2397 def CMP8mr : I<0x38, MRMDestMem,
2398 (outs), (ins i8mem :$src1, GR8 :$src2),
2399 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2400 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2401 (implicit EFLAGS)]>;
2402 def CMP16mr : I<0x39, MRMDestMem,
2403 (outs), (ins i16mem:$src1, GR16:$src2),
2404 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2405 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2406 (implicit EFLAGS)]>, OpSize;
2407 def CMP32mr : I<0x39, MRMDestMem,
2408 (outs), (ins i32mem:$src1, GR32:$src2),
2409 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2410 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2411 (implicit EFLAGS)]>;
2412 def CMP8rm : I<0x3A, MRMSrcMem,
2413 (outs), (ins GR8 :$src1, i8mem :$src2),
2414 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2415 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2416 (implicit EFLAGS)]>;
2417 def CMP16rm : I<0x3B, MRMSrcMem,
2418 (outs), (ins GR16:$src1, i16mem:$src2),
2419 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2420 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2421 (implicit EFLAGS)]>, OpSize;
2422 def CMP32rm : I<0x3B, MRMSrcMem,
2423 (outs), (ins GR32:$src1, i32mem:$src2),
2424 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2425 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2426 (implicit EFLAGS)]>;
2427 def CMP8ri : Ii8<0x80, MRM7r,
2428 (outs), (ins GR8:$src1, i8imm:$src2),
2429 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2430 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
2431 def CMP16ri : Ii16<0x81, MRM7r,
2432 (outs), (ins GR16:$src1, i16imm:$src2),
2433 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2434 [(X86cmp GR16:$src1, imm:$src2),
2435 (implicit EFLAGS)]>, OpSize;
2436 def CMP32ri : Ii32<0x81, MRM7r,
2437 (outs), (ins GR32:$src1, i32imm:$src2),
2438 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2439 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
2440 def CMP8mi : Ii8 <0x80, MRM7m,
2441 (outs), (ins i8mem :$src1, i8imm :$src2),
2442 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2443 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2444 (implicit EFLAGS)]>;
2445 def CMP16mi : Ii16<0x81, MRM7m,
2446 (outs), (ins i16mem:$src1, i16imm:$src2),
2447 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2448 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2449 (implicit EFLAGS)]>, OpSize;
2450 def CMP32mi : Ii32<0x81, MRM7m,
2451 (outs), (ins i32mem:$src1, i32imm:$src2),
2452 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2453 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2454 (implicit EFLAGS)]>;
2455 def CMP16ri8 : Ii8<0x83, MRM7r,
2456 (outs), (ins GR16:$src1, i16i8imm:$src2),
2457 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2458 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2459 (implicit EFLAGS)]>, OpSize;
2460 def CMP16mi8 : Ii8<0x83, MRM7m,
2461 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2462 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2463 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2464 (implicit EFLAGS)]>, OpSize;
2465 def CMP32mi8 : Ii8<0x83, MRM7m,
2466 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2467 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2468 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2469 (implicit EFLAGS)]>;
2470 def CMP32ri8 : Ii8<0x83, MRM7r,
2471 (outs), (ins GR32:$src1, i32i8imm:$src2),
2472 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2473 [(X86cmp GR32:$src1, i32immSExt8:$src2),
2474 (implicit EFLAGS)]>;
2475 } // Defs = [EFLAGS]
2477 // Sign/Zero extenders
2478 // Use movsbl intead of movsbw; we don't care about the high 16 bits
2479 // of the register here. This has a smaller encoding and avoids a
2480 // partial-register update.
2481 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2482 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2483 [(set GR16:$dst, (sext GR8:$src))]>, TB;
2484 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2485 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2486 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
2487 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2488 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2489 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2490 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2491 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2492 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2493 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2494 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2495 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2496 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2497 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2498 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2500 // Use movzbl intead of movzbw; we don't care about the high 16 bits
2501 // of the register here. This has a smaller encoding and avoids a
2502 // partial-register update.
2503 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2504 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2505 [(set GR16:$dst, (zext GR8:$src))]>, TB;
2506 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2507 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2508 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
2509 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2510 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2511 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2512 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2513 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2514 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2515 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2516 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2517 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2518 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2519 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2520 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2522 let neverHasSideEffects = 1 in {
2523 let Defs = [AX], Uses = [AL] in
2524 def CBW : I<0x98, RawFrm, (outs), (ins),
2525 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2526 let Defs = [EAX], Uses = [AX] in
2527 def CWDE : I<0x98, RawFrm, (outs), (ins),
2528 "{cwtl|cwde}", []>; // EAX = signext(AX)
2530 let Defs = [AX,DX], Uses = [AX] in
2531 def CWD : I<0x99, RawFrm, (outs), (ins),
2532 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2533 let Defs = [EAX,EDX], Uses = [EAX] in
2534 def CDQ : I<0x99, RawFrm, (outs), (ins),
2535 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2538 //===----------------------------------------------------------------------===//
2539 // Alias Instructions
2540 //===----------------------------------------------------------------------===//
2542 // Alias instructions that map movr0 to xor.
2543 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2544 let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2545 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
2546 "xor{b}\t$dst, $dst",
2547 [(set GR8:$dst, 0)]>;
2548 // Use xorl instead of xorw since we don't care about the high 16 bits,
2549 // it's smaller, and it avoids a partial-register update.
2550 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
2551 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2552 [(set GR16:$dst, 0)]>;
2553 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
2554 "xor{l}\t$dst, $dst",
2555 [(set GR32:$dst, 0)]>;
2558 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2559 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2560 let neverHasSideEffects = 1 in {
2561 def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
2562 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2563 def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
2564 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2566 def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
2567 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2568 def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
2569 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2570 } // neverHasSideEffects
2572 let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
2573 def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
2574 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2575 def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
2576 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2578 let mayStore = 1, neverHasSideEffects = 1 in {
2579 def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
2580 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2581 def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
2582 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2585 //===----------------------------------------------------------------------===//
2586 // Thread Local Storage Instructions
2590 def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2591 "leal\t${sym:mem}(,%ebx,1), $dst",
2592 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
2594 let AddedComplexity = 10 in
2595 def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
2596 "movl\t%gs:($src), $dst",
2597 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2599 let AddedComplexity = 15 in
2600 def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2601 "movl\t%gs:${src:mem}, $dst",
2603 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2605 def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
2606 "movl\t%gs:0, $dst",
2607 [(set GR32:$dst, X86TLStp)]>;
2609 //===----------------------------------------------------------------------===//
2610 // DWARF Pseudo Instructions
2613 def DWARF_LOC : I<0, Pseudo, (outs),
2614 (ins i32imm:$line, i32imm:$col, i32imm:$file),
2615 ".loc\t${file:debug} ${line:debug} ${col:debug}",
2616 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2619 //===----------------------------------------------------------------------===//
2620 // EH Pseudo Instructions
2622 let isTerminator = 1, isReturn = 1, isBarrier = 1,
2624 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
2625 "ret\t#eh_return, addr: $addr",
2626 [(X86ehret GR32:$addr)]>;
2630 //===----------------------------------------------------------------------===//
2634 // Atomic swap. These are just normal xchg instructions. But since a memory
2635 // operand is referenced, the atomicity is ensured.
2636 let Constraints = "$val = $dst" in {
2637 def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2638 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2639 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2640 def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2641 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2642 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2644 def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2645 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2646 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2649 // Atomic compare and swap.
2650 let Defs = [EAX, EFLAGS], Uses = [EAX] in {
2651 def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
2652 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
2653 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
2655 let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
2656 def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
2657 "lock\n\tcmpxchg8b\t$ptr",
2658 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2661 let Defs = [AX, EFLAGS], Uses = [AX] in {
2662 def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
2663 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
2664 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
2666 let Defs = [AL, EFLAGS], Uses = [AL] in {
2667 def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
2668 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
2669 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
2672 // Atomic exchange and add
2673 let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2674 def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2675 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
2676 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
2678 def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2679 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
2680 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
2682 def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2683 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
2684 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
2688 // Atomic exchange, and, or, xor
2689 let Constraints = "$val = $dst", Defs = [EFLAGS],
2690 usesCustomDAGSchedInserter = 1 in {
2691 def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2692 "#ATOMAND32 PSUEDO!",
2693 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
2694 def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2695 "#ATOMOR32 PSUEDO!",
2696 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
2697 def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2698 "#ATOMXOR32 PSUEDO!",
2699 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
2700 def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2701 "#ATOMNAND32 PSUEDO!",
2702 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
2703 def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2704 "#ATOMMIN32 PSUEDO!",
2705 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
2706 def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2707 "#ATOMMAX32 PSUEDO!",
2708 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
2709 def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2710 "#ATOMUMIN32 PSUEDO!",
2711 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
2712 def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
2713 "#ATOMUMAX32 PSUEDO!",
2714 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
2716 def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2717 "#ATOMAND16 PSUEDO!",
2718 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
2719 def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2720 "#ATOMOR16 PSUEDO!",
2721 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
2722 def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2723 "#ATOMXOR16 PSUEDO!",
2724 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
2725 def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2726 "#ATOMNAND16 PSUEDO!",
2727 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
2728 def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2729 "#ATOMMIN16 PSUEDO!",
2730 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
2731 def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2732 "#ATOMMAX16 PSUEDO!",
2733 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
2734 def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2735 "#ATOMUMIN16 PSUEDO!",
2736 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
2737 def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2738 "#ATOMUMAX16 PSUEDO!",
2739 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
2741 def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2742 "#ATOMAND8 PSUEDO!",
2743 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
2744 def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2746 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
2747 def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2748 "#ATOMXOR8 PSUEDO!",
2749 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
2750 def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2751 "#ATOMNAND8 PSUEDO!",
2752 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
2755 let Constraints = "$val1 = $dst1, $val2 = $dst2",
2756 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
2757 Uses = [EAX, EBX, ECX, EDX],
2758 mayLoad = 1, mayStore = 1,
2759 usesCustomDAGSchedInserter = 1 in {
2760 def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2761 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2762 "#ATOMAND6432 PSUEDO!", []>;
2763 def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2764 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2765 "#ATOMOR6432 PSUEDO!", []>;
2766 def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2767 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2768 "#ATOMXOR6432 PSUEDO!", []>;
2769 def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2770 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2771 "#ATOMNAND6432 PSUEDO!", []>;
2772 def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2773 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2774 "#ATOMADD6432 PSUEDO!", []>;
2775 def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2776 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2777 "#ATOMSUB6432 PSUEDO!", []>;
2778 def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2779 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2780 "#ATOMSWAP6432 PSUEDO!", []>;
2783 //===----------------------------------------------------------------------===//
2784 // Non-Instruction Patterns
2785 //===----------------------------------------------------------------------===//
2787 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2788 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2789 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2790 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
2791 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2792 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2794 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2795 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2796 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2797 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2798 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2799 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2800 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2801 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2803 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2804 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2805 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2806 (MOV32mi addr:$dst, texternalsym:$src)>;
2810 def : Pat<(X86tailcall GR32:$dst),
2813 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2815 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2818 def : Pat<(X86tcret GR32:$dst, imm:$off),
2819 (TCRETURNri GR32:$dst, imm:$off)>;
2821 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2822 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2824 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2825 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2827 def : Pat<(X86call (i32 tglobaladdr:$dst)),
2828 (CALLpcrel32 tglobaladdr:$dst)>;
2829 def : Pat<(X86call (i32 texternalsym:$dst)),
2830 (CALLpcrel32 texternalsym:$dst)>;
2832 // X86 specific add which produces a flag.
2833 def : Pat<(addc GR32:$src1, GR32:$src2),
2834 (ADD32rr GR32:$src1, GR32:$src2)>;
2835 def : Pat<(addc GR32:$src1, (load addr:$src2)),
2836 (ADD32rm GR32:$src1, addr:$src2)>;
2837 def : Pat<(addc GR32:$src1, imm:$src2),
2838 (ADD32ri GR32:$src1, imm:$src2)>;
2839 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2840 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2842 def : Pat<(subc GR32:$src1, GR32:$src2),
2843 (SUB32rr GR32:$src1, GR32:$src2)>;
2844 def : Pat<(subc GR32:$src1, (load addr:$src2)),
2845 (SUB32rm GR32:$src1, addr:$src2)>;
2846 def : Pat<(subc GR32:$src1, imm:$src2),
2847 (SUB32ri GR32:$src1, imm:$src2)>;
2848 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2849 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2853 // TEST R,R is smaller than CMP R,0
2854 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
2855 (TEST8rr GR8:$src1, GR8:$src1)>;
2856 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
2857 (TEST16rr GR16:$src1, GR16:$src1)>;
2858 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
2859 (TEST32rr GR32:$src1, GR32:$src1)>;
2861 // zextload bool -> zextload byte
2862 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2863 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2864 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2866 // extload bool -> extload byte
2867 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2868 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
2869 Requires<[In32BitMode]>;
2870 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2871 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
2872 Requires<[In32BitMode]>;
2873 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2874 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2877 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
2878 Requires<[In32BitMode]>;
2879 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
2880 Requires<[In32BitMode]>;
2881 def : Pat<(i32 (anyext GR16:$src)),
2882 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
2884 // (and (i32 load), 255) -> (zextload i8)
2885 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
2886 (MOVZX32rm8 addr:$src)>;
2887 def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
2888 (MOVZX32rm16 addr:$src)>;
2890 //===----------------------------------------------------------------------===//
2892 //===----------------------------------------------------------------------===//
2894 // r & (2^16-1) ==> movz
2895 def : Pat<(and GR32:$src1, 0xffff),
2896 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
2897 // r & (2^8-1) ==> movz
2898 def : Pat<(and GR32:$src1, 0xff),
2899 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
2900 x86_subreg_8bit)))>,
2901 Requires<[In32BitMode]>;
2902 // r & (2^8-1) ==> movz
2903 def : Pat<(and GR16:$src1, 0xff),
2904 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
2905 x86_subreg_8bit)))>,
2906 Requires<[In32BitMode]>;
2908 // sext_inreg patterns
2909 def : Pat<(sext_inreg GR32:$src, i16),
2910 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
2911 def : Pat<(sext_inreg GR32:$src, i8),
2912 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
2913 x86_subreg_8bit)))>,
2914 Requires<[In32BitMode]>;
2915 def : Pat<(sext_inreg GR16:$src, i8),
2916 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
2917 x86_subreg_8bit)))>,
2918 Requires<[In32BitMode]>;
2921 def : Pat<(i16 (trunc GR32:$src)),
2922 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
2923 def : Pat<(i8 (trunc GR32:$src)),
2924 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
2925 Requires<[In32BitMode]>;
2926 def : Pat<(i8 (trunc GR16:$src)),
2927 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
2928 Requires<[In32BitMode]>;
2930 // (shl x, 1) ==> (add x, x)
2931 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2932 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2933 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2935 // (shl x (and y, 31)) ==> (shl x, y)
2936 def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
2937 (SHL8rCL GR8:$src1)>;
2938 def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
2939 (SHL16rCL GR16:$src1)>;
2940 def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
2941 (SHL32rCL GR32:$src1)>;
2942 def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2943 (SHL8mCL addr:$dst)>;
2944 def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2945 (SHL16mCL addr:$dst)>;
2946 def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2947 (SHL32mCL addr:$dst)>;
2949 def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
2950 (SHR8rCL GR8:$src1)>;
2951 def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
2952 (SHR16rCL GR16:$src1)>;
2953 def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
2954 (SHR32rCL GR32:$src1)>;
2955 def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2956 (SHR8mCL addr:$dst)>;
2957 def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2958 (SHR16mCL addr:$dst)>;
2959 def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2960 (SHR32mCL addr:$dst)>;
2962 def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
2963 (SAR8rCL GR8:$src1)>;
2964 def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
2965 (SAR16rCL GR16:$src1)>;
2966 def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
2967 (SAR32rCL GR32:$src1)>;
2968 def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2969 (SAR8mCL addr:$dst)>;
2970 def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2971 (SAR16mCL addr:$dst)>;
2972 def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2973 (SAR32mCL addr:$dst)>;
2975 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2976 def : Pat<(or (srl GR32:$src1, CL:$amt),
2977 (shl GR32:$src2, (sub 32, CL:$amt))),
2978 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2980 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2981 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2982 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2984 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2985 def : Pat<(or (shl GR32:$src1, CL:$amt),
2986 (srl GR32:$src2, (sub 32, CL:$amt))),
2987 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2989 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2990 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2991 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2993 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2994 def : Pat<(or (srl GR16:$src1, CL:$amt),
2995 (shl GR16:$src2, (sub 16, CL:$amt))),
2996 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2998 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2999 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3000 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3002 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3003 def : Pat<(or (shl GR16:$src1, CL:$amt),
3004 (srl GR16:$src2, (sub 16, CL:$amt))),
3005 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3007 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3008 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3009 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3011 //===----------------------------------------------------------------------===//
3012 // Floating Point Stack Support
3013 //===----------------------------------------------------------------------===//
3015 include "X86InstrFPStack.td"
3017 //===----------------------------------------------------------------------===//
3019 //===----------------------------------------------------------------------===//
3021 include "X86Instr64bit.td"
3023 //===----------------------------------------------------------------------===//
3024 // XMM Floating point support (requires SSE / SSE2)
3025 //===----------------------------------------------------------------------===//
3027 include "X86InstrSSE.td"
3029 //===----------------------------------------------------------------------===//
3030 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3031 //===----------------------------------------------------------------------===//
3033 include "X86InstrMMX.td"