1 //===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source 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 SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
40 def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
41 def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
44 def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
46 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
48 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
50 def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
52 def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
54 def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
56 def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
58 def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
60 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
61 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
63 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
65 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
66 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
68 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
70 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
71 [SDNPHasChain, SDNPOptInFlag]>;
73 def X86callseq_start :
74 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
75 [SDNPHasChain, SDNPOutFlag]>;
77 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
78 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
80 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
81 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
83 def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
84 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
86 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
87 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
88 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
91 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
92 [SDNPHasChain, SDNPOutFlag]>;
94 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
95 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
97 def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
98 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
99 def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
101 def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
104 def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
105 [SDNPHasChain, SDNPOptInFlag]>;
107 //===----------------------------------------------------------------------===//
108 // X86 Operand Definitions.
111 // *mem - Operand definitions for the funky X86 addressing mode operands.
113 class X86MemOperand<string printMethod> : Operand<iPTR> {
114 let PrintMethod = printMethod;
115 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
118 def i8mem : X86MemOperand<"printi8mem">;
119 def i16mem : X86MemOperand<"printi16mem">;
120 def i32mem : X86MemOperand<"printi32mem">;
121 def i64mem : X86MemOperand<"printi64mem">;
122 def i128mem : X86MemOperand<"printi128mem">;
123 def f32mem : X86MemOperand<"printf32mem">;
124 def f64mem : X86MemOperand<"printf64mem">;
125 def f80mem : X86MemOperand<"printf80mem">;
126 def f128mem : X86MemOperand<"printf128mem">;
128 def lea32mem : Operand<i32> {
129 let PrintMethod = "printi32mem";
130 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
133 def SSECC : Operand<i8> {
134 let PrintMethod = "printSSECC";
137 def piclabel: Operand<i32> {
138 let PrintMethod = "printPICLabel";
141 // A couple of more descriptive operand definitions.
142 // 16-bits but only 8 bits are significant.
143 def i16i8imm : Operand<i16>;
144 // 32-bits but only 8 bits are significant.
145 def i32i8imm : Operand<i32>;
147 // Branch targets have OtherVT type.
148 def brtarget : Operand<OtherVT>;
150 //===----------------------------------------------------------------------===//
151 // X86 Complex Pattern Definitions.
154 // Define X86 specific addressing mode.
155 def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
156 def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
157 [add, mul, shl, or, frameindex], []>;
159 //===----------------------------------------------------------------------===//
160 // X86 Instruction Predicate Definitions.
161 def HasMMX : Predicate<"Subtarget->hasMMX()">;
162 def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
163 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
164 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
165 def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
166 def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
167 def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
168 def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
169 def In64BitMode : Predicate<"Subtarget->is64Bit()">;
170 def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
171 def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
172 def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
173 def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
175 //===----------------------------------------------------------------------===//
176 // X86 Instruction Format Definitions.
179 include "X86InstrFormats.td"
181 //===----------------------------------------------------------------------===//
182 // Pattern fragments...
185 // X86 specific condition code. These correspond to CondCode in
186 // X86InstrInfo.h. They must be kept in synch.
187 def X86_COND_A : PatLeaf<(i8 0)>;
188 def X86_COND_AE : PatLeaf<(i8 1)>;
189 def X86_COND_B : PatLeaf<(i8 2)>;
190 def X86_COND_BE : PatLeaf<(i8 3)>;
191 def X86_COND_E : PatLeaf<(i8 4)>;
192 def X86_COND_G : PatLeaf<(i8 5)>;
193 def X86_COND_GE : PatLeaf<(i8 6)>;
194 def X86_COND_L : PatLeaf<(i8 7)>;
195 def X86_COND_LE : PatLeaf<(i8 8)>;
196 def X86_COND_NE : PatLeaf<(i8 9)>;
197 def X86_COND_NO : PatLeaf<(i8 10)>;
198 def X86_COND_NP : PatLeaf<(i8 11)>;
199 def X86_COND_NS : PatLeaf<(i8 12)>;
200 def X86_COND_O : PatLeaf<(i8 13)>;
201 def X86_COND_P : PatLeaf<(i8 14)>;
202 def X86_COND_S : PatLeaf<(i8 15)>;
204 def i16immSExt8 : PatLeaf<(i16 imm), [{
205 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
206 // sign extended field.
207 return (int16_t)N->getValue() == (int8_t)N->getValue();
210 def i32immSExt8 : PatLeaf<(i32 imm), [{
211 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
212 // sign extended field.
213 return (int32_t)N->getValue() == (int8_t)N->getValue();
216 // Helper fragments for loads.
217 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
218 def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
219 def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
220 def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
222 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
223 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
224 def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
226 def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
227 def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
228 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
229 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
230 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
232 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
233 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
234 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
235 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
236 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
237 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
239 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
240 def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
241 def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
242 def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
243 def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
244 def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
246 //===----------------------------------------------------------------------===//
247 // Instruction list...
250 // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
251 // a stack adjustment and the codegen must know that they may modify the stack
252 // pointer before prolog-epilog rewriting occurs.
253 // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become sub / add
254 // which can clobber EFLAGS.
255 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
256 def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt), "#ADJCALLSTACKDOWN",
257 [(X86callseq_start imm:$amt)]>;
258 def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
260 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
262 def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
263 "#IMPLICIT_USE", []>;
264 def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
265 "#IMPLICIT_DEF", []>;
266 def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
267 "#IMPLICIT_DEF $dst",
268 [(set GR8:$dst, (undef))]>;
269 def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
270 "#IMPLICIT_DEF $dst",
271 [(set GR16:$dst, (undef))]>;
272 def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
273 "#IMPLICIT_DEF $dst",
274 [(set GR32:$dst, (undef))]>;
277 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
280 //===----------------------------------------------------------------------===//
281 // Control Flow Instructions...
284 // Return instructions.
285 let isTerminator = 1, isReturn = 1, isBarrier = 1,
287 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
288 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
289 [(X86retflag imm:$amt)]>;
292 // All branches are RawFrm, Void, Branch, and Terminators
293 let isBranch = 1, isTerminator = 1 in
294 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
295 I<opcode, RawFrm, (outs), ins, asm, pattern>;
298 let isBranch = 1, isBarrier = 1 in
299 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
301 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
302 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
303 [(brind GR32:$dst)]>;
304 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
305 [(brind (loadi32 addr:$dst))]>;
308 // Conditional branches
309 let Uses = [EFLAGS] in {
310 def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
311 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
312 def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
313 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
314 def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
315 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
316 def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
317 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
318 def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
319 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
320 def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
321 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
323 def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
324 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
325 def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
326 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
327 def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
328 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
329 def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
330 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
332 def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
333 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
334 def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
335 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
336 def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
337 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
338 def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
339 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
340 def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
341 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
342 def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
343 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
346 //===----------------------------------------------------------------------===//
347 // Call Instructions...
350 // All calls clobber the non-callee saved registers...
351 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
352 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
353 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS] in {
354 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
355 "call\t${dst:call}", []>;
356 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
357 "call\t{*}$dst", [(X86call GR32:$dst)]>;
358 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
359 "call\t{*}$dst", []>;
364 def TAILCALL : I<0, Pseudo, (outs), (ins ),
368 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
369 def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset),
370 "#TC_RETURN $dst $offset",
373 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
374 def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset),
375 "#TC_RETURN $dst $offset",
378 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
379 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
381 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
382 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
384 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
385 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
386 "jmp\t{*}$dst # TAILCALL", []>;
388 //===----------------------------------------------------------------------===//
389 // Miscellaneous Instructions...
391 let Defs = [EBP, ESP], Uses = [EBP, ESP] in
392 def LEAVE : I<0xC9, RawFrm,
393 (outs), (ins), "leave", []>;
395 let Defs = [ESP], Uses = [ESP] in {
396 def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
398 def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
401 let Defs = [ESP, EFLAGS], Uses = [ESP] in
402 def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
403 let Defs = [ESP], Uses = [ESP, EFLAGS] in
404 def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
406 def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
409 let isTwoAddress = 1 in // GR32 = bswap GR32
410 def BSWAP32r : I<0xC8, AddRegFrm,
411 (outs GR32:$dst), (ins GR32:$src),
413 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
415 // FIXME: Model xchg* as two address instructions?
416 def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
417 (outs), (ins GR8:$src1, GR8:$src2),
418 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
419 def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
420 (outs), (ins GR16:$src1, GR16:$src2),
421 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
422 def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
423 (outs), (ins GR32:$src1, GR32:$src2),
424 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
426 def XCHG8mr : I<0x86, MRMDestMem,
427 (outs), (ins i8mem:$src1, GR8:$src2),
428 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
429 def XCHG16mr : I<0x87, MRMDestMem,
430 (outs), (ins i16mem:$src1, GR16:$src2),
431 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
432 def XCHG32mr : I<0x87, MRMDestMem,
433 (outs), (ins i32mem:$src1, GR32:$src2),
434 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
435 def XCHG8rm : I<0x86, MRMSrcMem,
436 (outs), (ins GR8:$src1, i8mem:$src2),
437 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
438 def XCHG16rm : I<0x87, MRMSrcMem,
439 (outs), (ins GR16:$src1, i16mem:$src2),
440 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
441 def XCHG32rm : I<0x87, MRMSrcMem,
442 (outs), (ins GR32:$src1, i32mem:$src2),
443 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
445 def LEA16r : I<0x8D, MRMSrcMem,
446 (outs GR16:$dst), (ins i32mem:$src),
447 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
448 def LEA32r : I<0x8D, MRMSrcMem,
449 (outs GR32:$dst), (ins lea32mem:$src),
450 "lea{l}\t{$src|$dst}, {$dst|$src}",
451 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
453 let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
454 def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
455 [(X86rep_movs i8)]>, REP;
456 def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
457 [(X86rep_movs i16)]>, REP, OpSize;
458 def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
459 [(X86rep_movs i32)]>, REP;
462 let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
463 def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
464 [(X86rep_stos i8)]>, REP;
465 let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
466 def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
467 [(X86rep_stos i16)]>, REP, OpSize;
468 let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
469 def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
470 [(X86rep_stos i32)]>, REP;
472 let Defs = [RAX, RDX] in
473 def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
476 //===----------------------------------------------------------------------===//
477 // Input/Output Instructions...
479 let Defs = [AL], Uses = [DX] in
480 def IN8rr : I<0xEC, RawFrm, (outs), (ins),
481 "in{b}\t{%dx, %al|%AL, %DX}", []>;
482 let Defs = [AX], Uses = [DX] in
483 def IN16rr : I<0xED, RawFrm, (outs), (ins),
484 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
485 let Defs = [EAX], Uses = [DX] in
486 def IN32rr : I<0xED, RawFrm, (outs), (ins),
487 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
490 def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
491 "in{b}\t{$port, %al|%AL, $port}", []>;
493 def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
494 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
496 def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
497 "in{l}\t{$port, %eax|%EAX, $port}", []>;
499 let Uses = [DX, AL] in
500 def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
501 "out{b}\t{%al, %dx|%DX, %AL}", []>;
502 let Uses = [DX, AX] in
503 def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
504 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
505 let Uses = [DX, EAX] in
506 def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
507 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
510 def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
511 "out{b}\t{%al, $port|$port, %AL}", []>;
513 def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
514 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
516 def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
517 "out{l}\t{%eax, $port|$port, %EAX}", []>;
519 //===----------------------------------------------------------------------===//
520 // Move Instructions...
522 def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
523 "mov{b}\t{$src, $dst|$dst, $src}", []>;
524 def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
525 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
526 def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
527 "mov{l}\t{$src, $dst|$dst, $src}", []>;
528 let isReMaterializable = 1 in {
529 def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
530 "mov{b}\t{$src, $dst|$dst, $src}",
531 [(set GR8:$dst, imm:$src)]>;
532 def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
533 "mov{w}\t{$src, $dst|$dst, $src}",
534 [(set GR16:$dst, imm:$src)]>, OpSize;
535 def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
536 "mov{l}\t{$src, $dst|$dst, $src}",
537 [(set GR32:$dst, imm:$src)]>;
539 def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
540 "mov{b}\t{$src, $dst|$dst, $src}",
541 [(store (i8 imm:$src), addr:$dst)]>;
542 def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
543 "mov{w}\t{$src, $dst|$dst, $src}",
544 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
545 def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
546 "mov{l}\t{$src, $dst|$dst, $src}",
547 [(store (i32 imm:$src), addr:$dst)]>;
550 def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
551 "mov{b}\t{$src, $dst|$dst, $src}",
552 [(set GR8:$dst, (load addr:$src))]>;
553 def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
554 "mov{w}\t{$src, $dst|$dst, $src}",
555 [(set GR16:$dst, (load addr:$src))]>, OpSize;
556 def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
557 "mov{l}\t{$src, $dst|$dst, $src}",
558 [(set GR32:$dst, (load addr:$src))]>;
561 def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
562 "mov{b}\t{$src, $dst|$dst, $src}",
563 [(store GR8:$src, addr:$dst)]>;
564 def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
565 "mov{w}\t{$src, $dst|$dst, $src}",
566 [(store GR16:$src, addr:$dst)]>, OpSize;
567 def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
568 "mov{l}\t{$src, $dst|$dst, $src}",
569 [(store GR32:$src, addr:$dst)]>;
571 //===----------------------------------------------------------------------===//
572 // Fixed-Register Multiplication and Division Instructions...
575 // Extra precision multiplication
576 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
577 def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
578 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
579 // This probably ought to be moved to a def : Pat<> if the
580 // syntax can be accepted.
581 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
582 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
583 def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
584 OpSize; // AX,DX = AX*GR16
585 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
586 def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
587 // EAX,EDX = EAX*GR32
588 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
589 def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
591 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
592 // This probably ought to be moved to a def : Pat<> if the
593 // syntax can be accepted.
594 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
595 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
596 def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
597 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
598 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
599 def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
600 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
602 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
603 def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
605 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
606 def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
607 OpSize; // AX,DX = AX*GR16
608 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
609 def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
610 // EAX,EDX = EAX*GR32
611 let Defs = [AL,AH,EFLAGS], Uses = [AL] in
612 def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
613 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
614 let Defs = [AX,DX,EFLAGS], Uses = [AX] in
615 def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
616 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
617 let Defs = [EAX,EDX], Uses = [EAX] in
618 def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
619 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
621 // unsigned division/remainder
622 let Defs = [AX,EFLAGS], Uses = [AL,AH] in
623 def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
625 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
626 def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
627 "div{w}\t$src", []>, OpSize;
628 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
629 def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
631 let Defs = [AX,EFLAGS], Uses = [AL,AH] in
632 def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
634 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
635 def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
636 "div{w}\t$src", []>, OpSize;
637 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
638 def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
641 // Signed division/remainder.
642 let Defs = [AX,EFLAGS], Uses = [AL,AH] in
643 def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
644 "idiv{b}\t$src", []>;
645 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
646 def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
647 "idiv{w}\t$src", []>, OpSize;
648 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
649 def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
650 "idiv{l}\t$src", []>;
651 let Defs = [AX,EFLAGS], Uses = [AL,AH] in
652 def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
653 "idiv{b}\t$src", []>;
654 let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
655 def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
656 "idiv{w}\t$src", []>, OpSize;
657 let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
658 def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
659 "idiv{l}\t$src", []>;
662 //===----------------------------------------------------------------------===//
663 // Two address Instructions...
665 let isTwoAddress = 1 in {
668 let Uses = [EFLAGS] in {
669 let isCommutable = 1 in {
670 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
671 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
672 "cmovb\t{$src2, $dst|$dst, $src2}",
673 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
674 X86_COND_B, EFLAGS))]>,
676 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
677 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
678 "cmovb\t{$src2, $dst|$dst, $src2}",
679 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
680 X86_COND_B, EFLAGS))]>,
683 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
684 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
685 "cmovae\t{$src2, $dst|$dst, $src2}",
686 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
687 X86_COND_AE, EFLAGS))]>,
689 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
690 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
691 "cmovae\t{$src2, $dst|$dst, $src2}",
692 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
693 X86_COND_AE, EFLAGS))]>,
695 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
696 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
697 "cmove\t{$src2, $dst|$dst, $src2}",
698 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
699 X86_COND_E, EFLAGS))]>,
701 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
702 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
703 "cmove\t{$src2, $dst|$dst, $src2}",
704 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
705 X86_COND_E, EFLAGS))]>,
707 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
708 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
709 "cmovne\t{$src2, $dst|$dst, $src2}",
710 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
711 X86_COND_NE, EFLAGS))]>,
713 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
714 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
715 "cmovne\t{$src2, $dst|$dst, $src2}",
716 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
717 X86_COND_NE, EFLAGS))]>,
719 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
720 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
721 "cmovbe\t{$src2, $dst|$dst, $src2}",
722 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
723 X86_COND_BE, EFLAGS))]>,
725 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
726 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
727 "cmovbe\t{$src2, $dst|$dst, $src2}",
728 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
729 X86_COND_BE, EFLAGS))]>,
731 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
732 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
733 "cmova\t{$src2, $dst|$dst, $src2}",
734 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
735 X86_COND_A, EFLAGS))]>,
737 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
738 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
739 "cmova\t{$src2, $dst|$dst, $src2}",
740 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
741 X86_COND_A, EFLAGS))]>,
743 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
744 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
745 "cmovl\t{$src2, $dst|$dst, $src2}",
746 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
747 X86_COND_L, EFLAGS))]>,
749 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
750 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
751 "cmovl\t{$src2, $dst|$dst, $src2}",
752 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
753 X86_COND_L, EFLAGS))]>,
755 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
756 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
757 "cmovge\t{$src2, $dst|$dst, $src2}",
758 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
759 X86_COND_GE, EFLAGS))]>,
761 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
762 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
763 "cmovge\t{$src2, $dst|$dst, $src2}",
764 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
765 X86_COND_GE, EFLAGS))]>,
767 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
768 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
769 "cmovle\t{$src2, $dst|$dst, $src2}",
770 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
771 X86_COND_LE, EFLAGS))]>,
773 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
774 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
775 "cmovle\t{$src2, $dst|$dst, $src2}",
776 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
777 X86_COND_LE, EFLAGS))]>,
779 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
780 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
781 "cmovg\t{$src2, $dst|$dst, $src2}",
782 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
783 X86_COND_G, EFLAGS))]>,
785 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
786 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
787 "cmovg\t{$src2, $dst|$dst, $src2}",
788 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
789 X86_COND_G, EFLAGS))]>,
791 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
792 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
793 "cmovs\t{$src2, $dst|$dst, $src2}",
794 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
795 X86_COND_S, EFLAGS))]>,
797 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
798 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
799 "cmovs\t{$src2, $dst|$dst, $src2}",
800 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
801 X86_COND_S, EFLAGS))]>,
803 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
804 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
805 "cmovns\t{$src2, $dst|$dst, $src2}",
806 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
807 X86_COND_NS, EFLAGS))]>,
809 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
810 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
811 "cmovns\t{$src2, $dst|$dst, $src2}",
812 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
813 X86_COND_NS, EFLAGS))]>,
815 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
816 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
817 "cmovp\t{$src2, $dst|$dst, $src2}",
818 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
819 X86_COND_P, EFLAGS))]>,
821 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
822 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
823 "cmovp\t{$src2, $dst|$dst, $src2}",
824 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
825 X86_COND_P, EFLAGS))]>,
827 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
828 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
829 "cmovnp\t{$src2, $dst|$dst, $src2}",
830 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
831 X86_COND_NP, EFLAGS))]>,
833 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
834 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
835 "cmovnp\t{$src2, $dst|$dst, $src2}",
836 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
837 X86_COND_NP, EFLAGS))]>,
839 } // isCommutable = 1
841 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
842 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
843 "cmovnp\t{$src2, $dst|$dst, $src2}",
844 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
845 X86_COND_NP, EFLAGS))]>,
848 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
849 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
850 "cmovb\t{$src2, $dst|$dst, $src2}",
851 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
852 X86_COND_B, EFLAGS))]>,
854 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
855 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
856 "cmovb\t{$src2, $dst|$dst, $src2}",
857 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
858 X86_COND_B, EFLAGS))]>,
860 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
861 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
862 "cmovae\t{$src2, $dst|$dst, $src2}",
863 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
864 X86_COND_AE, EFLAGS))]>,
866 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
867 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
868 "cmovae\t{$src2, $dst|$dst, $src2}",
869 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
870 X86_COND_AE, EFLAGS))]>,
872 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
873 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
874 "cmove\t{$src2, $dst|$dst, $src2}",
875 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
876 X86_COND_E, EFLAGS))]>,
878 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
879 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
880 "cmove\t{$src2, $dst|$dst, $src2}",
881 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
882 X86_COND_E, EFLAGS))]>,
884 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
885 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
886 "cmovne\t{$src2, $dst|$dst, $src2}",
887 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
888 X86_COND_NE, EFLAGS))]>,
890 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
891 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
892 "cmovne\t{$src2, $dst|$dst, $src2}",
893 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
894 X86_COND_NE, EFLAGS))]>,
896 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
897 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
898 "cmovbe\t{$src2, $dst|$dst, $src2}",
899 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
900 X86_COND_BE, EFLAGS))]>,
902 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
903 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
904 "cmovbe\t{$src2, $dst|$dst, $src2}",
905 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
906 X86_COND_BE, EFLAGS))]>,
908 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
909 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
910 "cmova\t{$src2, $dst|$dst, $src2}",
911 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
912 X86_COND_A, EFLAGS))]>,
914 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
915 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
916 "cmova\t{$src2, $dst|$dst, $src2}",
917 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
918 X86_COND_A, EFLAGS))]>,
920 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
921 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
922 "cmovl\t{$src2, $dst|$dst, $src2}",
923 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
924 X86_COND_L, EFLAGS))]>,
926 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
927 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
928 "cmovl\t{$src2, $dst|$dst, $src2}",
929 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
930 X86_COND_L, EFLAGS))]>,
932 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
933 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
934 "cmovge\t{$src2, $dst|$dst, $src2}",
935 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
936 X86_COND_GE, EFLAGS))]>,
938 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
939 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
940 "cmovge\t{$src2, $dst|$dst, $src2}",
941 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
942 X86_COND_GE, EFLAGS))]>,
944 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
945 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
946 "cmovle\t{$src2, $dst|$dst, $src2}",
947 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
948 X86_COND_LE, EFLAGS))]>,
950 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
951 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
952 "cmovle\t{$src2, $dst|$dst, $src2}",
953 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
954 X86_COND_LE, EFLAGS))]>,
956 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
957 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
958 "cmovg\t{$src2, $dst|$dst, $src2}",
959 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
960 X86_COND_G, EFLAGS))]>,
962 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
963 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
964 "cmovg\t{$src2, $dst|$dst, $src2}",
965 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
966 X86_COND_G, EFLAGS))]>,
968 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
969 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
970 "cmovs\t{$src2, $dst|$dst, $src2}",
971 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
972 X86_COND_S, EFLAGS))]>,
974 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
975 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
976 "cmovs\t{$src2, $dst|$dst, $src2}",
977 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
978 X86_COND_S, EFLAGS))]>,
980 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
981 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
982 "cmovns\t{$src2, $dst|$dst, $src2}",
983 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
984 X86_COND_NS, EFLAGS))]>,
986 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
987 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
988 "cmovns\t{$src2, $dst|$dst, $src2}",
989 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
990 X86_COND_NS, EFLAGS))]>,
992 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
993 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
994 "cmovp\t{$src2, $dst|$dst, $src2}",
995 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
996 X86_COND_P, EFLAGS))]>,
998 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
999 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1000 "cmovp\t{$src2, $dst|$dst, $src2}",
1001 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1002 X86_COND_P, EFLAGS))]>,
1004 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1005 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1006 "cmovnp\t{$src2, $dst|$dst, $src2}",
1007 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1008 X86_COND_NP, EFLAGS))]>,
1010 } // Uses = [EFLAGS]
1013 // unary instructions
1014 let CodeSize = 2 in {
1015 let Defs = [EFLAGS] in {
1016 def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
1017 [(set GR8:$dst, (ineg GR8:$src))]>;
1018 def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
1019 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1020 def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
1021 [(set GR32:$dst, (ineg GR32:$src))]>;
1022 let isTwoAddress = 0 in {
1023 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
1024 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1025 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
1026 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1027 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
1028 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1031 } // Defs = [EFLAGS]
1033 def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
1034 [(set GR8:$dst, (not GR8:$src))]>;
1035 def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
1036 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1037 def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
1038 [(set GR32:$dst, (not GR32:$src))]>;
1039 let isTwoAddress = 0 in {
1040 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
1041 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1042 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
1043 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1044 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
1045 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1049 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1050 let Defs = [EFLAGS] in {
1052 def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
1053 [(set GR8:$dst, (add GR8:$src, 1))]>;
1054 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1055 def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
1056 [(set GR16:$dst, (add GR16:$src, 1))]>,
1057 OpSize, Requires<[In32BitMode]>;
1058 def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
1059 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1061 let isTwoAddress = 0, CodeSize = 2 in {
1062 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
1063 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1064 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
1065 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
1066 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
1067 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1071 def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
1072 [(set GR8:$dst, (add GR8:$src, -1))]>;
1073 let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
1074 def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
1075 [(set GR16:$dst, (add GR16:$src, -1))]>,
1076 OpSize, Requires<[In32BitMode]>;
1077 def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
1078 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1081 let isTwoAddress = 0, CodeSize = 2 in {
1082 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
1083 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1084 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
1085 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
1086 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
1087 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1089 } // Defs = [EFLAGS]
1091 // Logical operators...
1092 let Defs = [EFLAGS] in {
1093 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1094 def AND8rr : I<0x20, MRMDestReg,
1095 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1096 "and{b}\t{$src2, $dst|$dst, $src2}",
1097 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1098 def AND16rr : I<0x21, MRMDestReg,
1099 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1100 "and{w}\t{$src2, $dst|$dst, $src2}",
1101 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1102 def AND32rr : I<0x21, MRMDestReg,
1103 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1104 "and{l}\t{$src2, $dst|$dst, $src2}",
1105 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1108 def AND8rm : I<0x22, MRMSrcMem,
1109 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1110 "and{b}\t{$src2, $dst|$dst, $src2}",
1111 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1112 def AND16rm : I<0x23, MRMSrcMem,
1113 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1114 "and{w}\t{$src2, $dst|$dst, $src2}",
1115 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1116 def AND32rm : I<0x23, MRMSrcMem,
1117 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1118 "and{l}\t{$src2, $dst|$dst, $src2}",
1119 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1121 def AND8ri : Ii8<0x80, MRM4r,
1122 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
1123 "and{b}\t{$src2, $dst|$dst, $src2}",
1124 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1125 def AND16ri : Ii16<0x81, MRM4r,
1126 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1127 "and{w}\t{$src2, $dst|$dst, $src2}",
1128 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1129 def AND32ri : Ii32<0x81, MRM4r,
1130 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1131 "and{l}\t{$src2, $dst|$dst, $src2}",
1132 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1133 def AND16ri8 : Ii8<0x83, MRM4r,
1134 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1135 "and{w}\t{$src2, $dst|$dst, $src2}",
1136 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1138 def AND32ri8 : Ii8<0x83, MRM4r,
1139 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1140 "and{l}\t{$src2, $dst|$dst, $src2}",
1141 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1143 let isTwoAddress = 0 in {
1144 def AND8mr : I<0x20, MRMDestMem,
1145 (outs), (ins i8mem :$dst, GR8 :$src),
1146 "and{b}\t{$src, $dst|$dst, $src}",
1147 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1148 def AND16mr : I<0x21, MRMDestMem,
1149 (outs), (ins i16mem:$dst, GR16:$src),
1150 "and{w}\t{$src, $dst|$dst, $src}",
1151 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1153 def AND32mr : I<0x21, MRMDestMem,
1154 (outs), (ins i32mem:$dst, GR32:$src),
1155 "and{l}\t{$src, $dst|$dst, $src}",
1156 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1157 def AND8mi : Ii8<0x80, MRM4m,
1158 (outs), (ins i8mem :$dst, i8imm :$src),
1159 "and{b}\t{$src, $dst|$dst, $src}",
1160 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1161 def AND16mi : Ii16<0x81, MRM4m,
1162 (outs), (ins i16mem:$dst, i16imm:$src),
1163 "and{w}\t{$src, $dst|$dst, $src}",
1164 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1166 def AND32mi : Ii32<0x81, MRM4m,
1167 (outs), (ins i32mem:$dst, i32imm:$src),
1168 "and{l}\t{$src, $dst|$dst, $src}",
1169 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1170 def AND16mi8 : Ii8<0x83, MRM4m,
1171 (outs), (ins i16mem:$dst, i16i8imm :$src),
1172 "and{w}\t{$src, $dst|$dst, $src}",
1173 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1175 def AND32mi8 : Ii8<0x83, MRM4m,
1176 (outs), (ins i32mem:$dst, i32i8imm :$src),
1177 "and{l}\t{$src, $dst|$dst, $src}",
1178 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1182 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1183 def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1184 "or{b}\t{$src2, $dst|$dst, $src2}",
1185 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1186 def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1187 "or{w}\t{$src2, $dst|$dst, $src2}",
1188 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1189 def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1190 "or{l}\t{$src2, $dst|$dst, $src2}",
1191 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1193 def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1194 "or{b}\t{$src2, $dst|$dst, $src2}",
1195 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1196 def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1197 "or{w}\t{$src2, $dst|$dst, $src2}",
1198 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1199 def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1200 "or{l}\t{$src2, $dst|$dst, $src2}",
1201 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1203 def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1204 "or{b}\t{$src2, $dst|$dst, $src2}",
1205 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1206 def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1207 "or{w}\t{$src2, $dst|$dst, $src2}",
1208 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1209 def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1210 "or{l}\t{$src2, $dst|$dst, $src2}",
1211 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1213 def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1214 "or{w}\t{$src2, $dst|$dst, $src2}",
1215 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1216 def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1217 "or{l}\t{$src2, $dst|$dst, $src2}",
1218 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1219 let isTwoAddress = 0 in {
1220 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
1221 "or{b}\t{$src, $dst|$dst, $src}",
1222 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1223 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
1224 "or{w}\t{$src, $dst|$dst, $src}",
1225 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1226 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
1227 "or{l}\t{$src, $dst|$dst, $src}",
1228 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
1229 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1230 "or{b}\t{$src, $dst|$dst, $src}",
1231 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1232 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
1233 "or{w}\t{$src, $dst|$dst, $src}",
1234 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1236 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
1237 "or{l}\t{$src, $dst|$dst, $src}",
1238 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1239 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
1240 "or{w}\t{$src, $dst|$dst, $src}",
1241 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1243 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
1244 "or{l}\t{$src, $dst|$dst, $src}",
1245 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1249 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1250 def XOR8rr : I<0x30, MRMDestReg,
1251 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1252 "xor{b}\t{$src2, $dst|$dst, $src2}",
1253 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1254 def XOR16rr : I<0x31, MRMDestReg,
1255 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1256 "xor{w}\t{$src2, $dst|$dst, $src2}",
1257 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1258 def XOR32rr : I<0x31, MRMDestReg,
1259 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1260 "xor{l}\t{$src2, $dst|$dst, $src2}",
1261 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1264 def XOR8rm : I<0x32, MRMSrcMem ,
1265 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
1266 "xor{b}\t{$src2, $dst|$dst, $src2}",
1267 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1268 def XOR16rm : I<0x33, MRMSrcMem ,
1269 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1270 "xor{w}\t{$src2, $dst|$dst, $src2}",
1271 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1272 def XOR32rm : I<0x33, MRMSrcMem ,
1273 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1274 "xor{l}\t{$src2, $dst|$dst, $src2}",
1275 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1277 def XOR8ri : Ii8<0x80, MRM6r,
1278 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1279 "xor{b}\t{$src2, $dst|$dst, $src2}",
1280 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1281 def XOR16ri : Ii16<0x81, MRM6r,
1282 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1283 "xor{w}\t{$src2, $dst|$dst, $src2}",
1284 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1285 def XOR32ri : Ii32<0x81, MRM6r,
1286 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1287 "xor{l}\t{$src2, $dst|$dst, $src2}",
1288 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1289 def XOR16ri8 : Ii8<0x83, MRM6r,
1290 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1291 "xor{w}\t{$src2, $dst|$dst, $src2}",
1292 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1294 def XOR32ri8 : Ii8<0x83, MRM6r,
1295 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1296 "xor{l}\t{$src2, $dst|$dst, $src2}",
1297 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1298 let isTwoAddress = 0 in {
1299 def XOR8mr : I<0x30, MRMDestMem,
1300 (outs), (ins i8mem :$dst, GR8 :$src),
1301 "xor{b}\t{$src, $dst|$dst, $src}",
1302 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1303 def XOR16mr : I<0x31, MRMDestMem,
1304 (outs), (ins i16mem:$dst, GR16:$src),
1305 "xor{w}\t{$src, $dst|$dst, $src}",
1306 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1308 def XOR32mr : I<0x31, MRMDestMem,
1309 (outs), (ins i32mem:$dst, GR32:$src),
1310 "xor{l}\t{$src, $dst|$dst, $src}",
1311 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1312 def XOR8mi : Ii8<0x80, MRM6m,
1313 (outs), (ins i8mem :$dst, i8imm :$src),
1314 "xor{b}\t{$src, $dst|$dst, $src}",
1315 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1316 def XOR16mi : Ii16<0x81, MRM6m,
1317 (outs), (ins i16mem:$dst, i16imm:$src),
1318 "xor{w}\t{$src, $dst|$dst, $src}",
1319 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1321 def XOR32mi : Ii32<0x81, MRM6m,
1322 (outs), (ins i32mem:$dst, i32imm:$src),
1323 "xor{l}\t{$src, $dst|$dst, $src}",
1324 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1325 def XOR16mi8 : Ii8<0x83, MRM6m,
1326 (outs), (ins i16mem:$dst, i16i8imm :$src),
1327 "xor{w}\t{$src, $dst|$dst, $src}",
1328 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1330 def XOR32mi8 : Ii8<0x83, MRM6m,
1331 (outs), (ins i32mem:$dst, i32i8imm :$src),
1332 "xor{l}\t{$src, $dst|$dst, $src}",
1333 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1335 } // Defs = [EFLAGS]
1337 // Shift instructions
1338 let Defs = [EFLAGS] in {
1339 let Uses = [CL] in {
1340 def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
1341 "shl{b}\t{%cl, $dst|$dst, %CL}",
1342 [(set GR8:$dst, (shl GR8:$src, CL))]>;
1343 def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
1344 "shl{w}\t{%cl, $dst|$dst, %CL}",
1345 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
1346 def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
1347 "shl{l}\t{%cl, $dst|$dst, %CL}",
1348 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1351 def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1352 "shl{b}\t{$src2, $dst|$dst, $src2}",
1353 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1354 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1355 def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1356 "shl{w}\t{$src2, $dst|$dst, $src2}",
1357 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1358 def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1359 "shl{l}\t{$src2, $dst|$dst, $src2}",
1360 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1363 // Shift left by one. Not used because (add x, x) is slightly cheaper.
1364 def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
1365 "shl{b}\t$dst", []>;
1366 def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
1367 "shl{w}\t$dst", []>, OpSize;
1368 def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
1369 "shl{l}\t$dst", []>;
1371 let isTwoAddress = 0 in {
1372 let Uses = [CL] in {
1373 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
1374 "shl{b}\t{%cl, $dst|$dst, %CL}",
1375 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
1376 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
1377 "shl{w}\t{%cl, $dst|$dst, %CL}",
1378 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1379 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
1380 "shl{l}\t{%cl, $dst|$dst, %CL}",
1381 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1383 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
1384 "shl{b}\t{$src, $dst|$dst, $src}",
1385 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1386 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
1387 "shl{w}\t{$src, $dst|$dst, $src}",
1388 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1390 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
1391 "shl{l}\t{$src, $dst|$dst, $src}",
1392 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1395 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
1397 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1398 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
1400 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1402 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
1404 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1407 let Uses = [CL] in {
1408 def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
1409 "shr{b}\t{%cl, $dst|$dst, %CL}",
1410 [(set GR8:$dst, (srl GR8:$src, CL))]>;
1411 def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
1412 "shr{w}\t{%cl, $dst|$dst, %CL}",
1413 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
1414 def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
1415 "shr{l}\t{%cl, $dst|$dst, %CL}",
1416 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1419 def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1420 "shr{b}\t{$src2, $dst|$dst, $src2}",
1421 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1422 def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1423 "shr{w}\t{$src2, $dst|$dst, $src2}",
1424 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1425 def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1426 "shr{l}\t{$src2, $dst|$dst, $src2}",
1427 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1430 def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
1432 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1433 def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
1435 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1436 def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
1438 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1440 let isTwoAddress = 0 in {
1441 let Uses = [CL] in {
1442 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
1443 "shr{b}\t{%cl, $dst|$dst, %CL}",
1444 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
1445 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
1446 "shr{w}\t{%cl, $dst|$dst, %CL}",
1447 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1449 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
1450 "shr{l}\t{%cl, $dst|$dst, %CL}",
1451 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1453 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
1454 "shr{b}\t{$src, $dst|$dst, $src}",
1455 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1456 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
1457 "shr{w}\t{$src, $dst|$dst, $src}",
1458 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1460 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
1461 "shr{l}\t{$src, $dst|$dst, $src}",
1462 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1465 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
1467 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1468 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
1470 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1471 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
1473 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1476 let Uses = [CL] in {
1477 def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
1478 "sar{b}\t{%cl, $dst|$dst, %CL}",
1479 [(set GR8:$dst, (sra GR8:$src, CL))]>;
1480 def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
1481 "sar{w}\t{%cl, $dst|$dst, %CL}",
1482 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
1483 def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
1484 "sar{l}\t{%cl, $dst|$dst, %CL}",
1485 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1488 def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1489 "sar{b}\t{$src2, $dst|$dst, $src2}",
1490 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1491 def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1492 "sar{w}\t{$src2, $dst|$dst, $src2}",
1493 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1495 def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1496 "sar{l}\t{$src2, $dst|$dst, $src2}",
1497 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1500 def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
1502 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1503 def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
1505 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1506 def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
1508 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1510 let isTwoAddress = 0 in {
1511 let Uses = [CL] in {
1512 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
1513 "sar{b}\t{%cl, $dst|$dst, %CL}",
1514 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
1515 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
1516 "sar{w}\t{%cl, $dst|$dst, %CL}",
1517 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1518 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
1519 "sar{l}\t{%cl, $dst|$dst, %CL}",
1520 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1522 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
1523 "sar{b}\t{$src, $dst|$dst, $src}",
1524 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1525 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
1526 "sar{w}\t{$src, $dst|$dst, $src}",
1527 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1529 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
1530 "sar{l}\t{$src, $dst|$dst, $src}",
1531 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1534 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
1536 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1537 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
1539 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1541 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
1543 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1546 // Rotate instructions
1547 // FIXME: provide shorter instructions when imm8 == 1
1548 let Uses = [CL] in {
1549 def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
1550 "rol{b}\t{%cl, $dst|$dst, %CL}",
1551 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
1552 def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
1553 "rol{w}\t{%cl, $dst|$dst, %CL}",
1554 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
1555 def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
1556 "rol{l}\t{%cl, $dst|$dst, %CL}",
1557 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1560 def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1561 "rol{b}\t{$src2, $dst|$dst, $src2}",
1562 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1563 def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1564 "rol{w}\t{$src2, $dst|$dst, $src2}",
1565 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1566 def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1567 "rol{l}\t{$src2, $dst|$dst, $src2}",
1568 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1571 def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
1573 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1574 def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
1576 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1577 def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
1579 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1581 let isTwoAddress = 0 in {
1582 let Uses = [CL] in {
1583 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
1584 "rol{b}\t{%cl, $dst|$dst, %CL}",
1585 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
1586 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
1587 "rol{w}\t{%cl, $dst|$dst, %CL}",
1588 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1589 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
1590 "rol{l}\t{%cl, $dst|$dst, %CL}",
1591 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1593 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
1594 "rol{b}\t{$src, $dst|$dst, $src}",
1595 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1596 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
1597 "rol{w}\t{$src, $dst|$dst, $src}",
1598 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1600 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
1601 "rol{l}\t{$src, $dst|$dst, $src}",
1602 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1605 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
1607 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1608 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
1610 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1612 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
1614 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1617 let Uses = [CL] in {
1618 def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
1619 "ror{b}\t{%cl, $dst|$dst, %CL}",
1620 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
1621 def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
1622 "ror{w}\t{%cl, $dst|$dst, %CL}",
1623 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
1624 def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
1625 "ror{l}\t{%cl, $dst|$dst, %CL}",
1626 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1629 def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
1630 "ror{b}\t{$src2, $dst|$dst, $src2}",
1631 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1632 def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
1633 "ror{w}\t{$src2, $dst|$dst, $src2}",
1634 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1635 def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
1636 "ror{l}\t{$src2, $dst|$dst, $src2}",
1637 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1640 def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
1642 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1643 def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
1645 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1646 def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
1648 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1650 let isTwoAddress = 0 in {
1651 let Uses = [CL] in {
1652 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
1653 "ror{b}\t{%cl, $dst|$dst, %CL}",
1654 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
1655 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
1656 "ror{w}\t{%cl, $dst|$dst, %CL}",
1657 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
1658 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
1659 "ror{l}\t{%cl, $dst|$dst, %CL}",
1660 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1662 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
1663 "ror{b}\t{$src, $dst|$dst, $src}",
1664 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1665 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
1666 "ror{w}\t{$src, $dst|$dst, $src}",
1667 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1669 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
1670 "ror{l}\t{$src, $dst|$dst, $src}",
1671 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1674 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
1676 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1677 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
1679 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1681 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
1683 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1688 // Double shift instructions (generalizations of rotate)
1689 let Uses = [CL] in {
1690 def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1691 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1692 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
1693 def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1694 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1695 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
1696 def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1697 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1698 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1700 def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1701 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1702 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1706 let isCommutable = 1 in { // These instructions commute to each other.
1707 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1708 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1709 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1710 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1713 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1714 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
1715 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1716 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1719 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1720 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1721 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1722 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1725 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1726 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
1727 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1728 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1733 let isTwoAddress = 0 in {
1734 let Uses = [CL] in {
1735 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1736 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1737 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1739 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1740 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1741 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1744 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1745 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1746 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1747 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1748 (i8 imm:$src3)), addr:$dst)]>,
1750 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1751 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
1752 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1753 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1754 (i8 imm:$src3)), addr:$dst)]>,
1757 let Uses = [CL] in {
1758 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1759 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1760 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1761 addr:$dst)]>, TB, OpSize;
1762 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1763 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
1764 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1765 addr:$dst)]>, TB, OpSize;
1767 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1768 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1769 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1770 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1771 (i8 imm:$src3)), addr:$dst)]>,
1773 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1774 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
1775 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
1776 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1777 (i8 imm:$src3)), addr:$dst)]>,
1780 } // Defs = [EFLAGS]
1784 let Defs = [EFLAGS] in {
1785 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1786 def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1787 (ins GR8 :$src1, GR8 :$src2),
1788 "add{b}\t{$src2, $dst|$dst, $src2}",
1789 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1790 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1791 def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1792 (ins GR16:$src1, GR16:$src2),
1793 "add{w}\t{$src2, $dst|$dst, $src2}",
1794 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1795 def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1796 (ins GR32:$src1, GR32:$src2),
1797 "add{l}\t{$src2, $dst|$dst, $src2}",
1798 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1799 } // end isConvertibleToThreeAddress
1800 } // end isCommutable
1801 def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1802 (ins GR8 :$src1, i8mem :$src2),
1803 "add{b}\t{$src2, $dst|$dst, $src2}",
1804 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1805 def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1806 (ins GR16:$src1, i16mem:$src2),
1807 "add{w}\t{$src2, $dst|$dst, $src2}",
1808 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1809 def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1810 (ins GR32:$src1, i32mem:$src2),
1811 "add{l}\t{$src2, $dst|$dst, $src2}",
1812 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1814 def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1815 "add{b}\t{$src2, $dst|$dst, $src2}",
1816 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1818 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1819 def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1820 (ins GR16:$src1, i16imm:$src2),
1821 "add{w}\t{$src2, $dst|$dst, $src2}",
1822 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1823 def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1824 (ins GR32:$src1, i32imm:$src2),
1825 "add{l}\t{$src2, $dst|$dst, $src2}",
1826 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
1827 def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1828 (ins GR16:$src1, i16i8imm:$src2),
1829 "add{w}\t{$src2, $dst|$dst, $src2}",
1830 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1831 def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1832 (ins GR32:$src1, i32i8imm:$src2),
1833 "add{l}\t{$src2, $dst|$dst, $src2}",
1834 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1837 let isTwoAddress = 0 in {
1838 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
1839 "add{b}\t{$src2, $dst|$dst, $src2}",
1840 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1841 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1842 "add{w}\t{$src2, $dst|$dst, $src2}",
1843 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1845 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1846 "add{l}\t{$src2, $dst|$dst, $src2}",
1847 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
1848 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
1849 "add{b}\t{$src2, $dst|$dst, $src2}",
1850 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1851 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
1852 "add{w}\t{$src2, $dst|$dst, $src2}",
1853 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1855 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
1856 "add{l}\t{$src2, $dst|$dst, $src2}",
1857 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1858 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
1859 "add{w}\t{$src2, $dst|$dst, $src2}",
1860 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1862 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1863 "add{l}\t{$src2, $dst|$dst, $src2}",
1864 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1867 let Uses = [EFLAGS] in {
1868 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1869 def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1870 "adc{l}\t{$src2, $dst|$dst, $src2}",
1871 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1873 def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1874 "adc{l}\t{$src2, $dst|$dst, $src2}",
1875 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1876 def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1877 "adc{l}\t{$src2, $dst|$dst, $src2}",
1878 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1879 def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1880 "adc{l}\t{$src2, $dst|$dst, $src2}",
1881 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1883 let isTwoAddress = 0 in {
1884 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1885 "adc{l}\t{$src2, $dst|$dst, $src2}",
1886 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
1887 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
1888 "adc{l}\t{$src2, $dst|$dst, $src2}",
1889 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1890 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1891 "adc{l}\t{$src2, $dst|$dst, $src2}",
1892 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1894 } // Uses = [EFLAGS]
1896 def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1897 "sub{b}\t{$src2, $dst|$dst, $src2}",
1898 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1899 def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1900 "sub{w}\t{$src2, $dst|$dst, $src2}",
1901 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1902 def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1903 "sub{l}\t{$src2, $dst|$dst, $src2}",
1904 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1905 def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
1906 "sub{b}\t{$src2, $dst|$dst, $src2}",
1907 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1908 def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1909 "sub{w}\t{$src2, $dst|$dst, $src2}",
1910 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1911 def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1912 "sub{l}\t{$src2, $dst|$dst, $src2}",
1913 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1915 def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1916 "sub{b}\t{$src2, $dst|$dst, $src2}",
1917 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1918 def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1919 "sub{w}\t{$src2, $dst|$dst, $src2}",
1920 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1921 def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1922 "sub{l}\t{$src2, $dst|$dst, $src2}",
1923 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1924 def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1925 "sub{w}\t{$src2, $dst|$dst, $src2}",
1926 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
1928 def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1929 "sub{l}\t{$src2, $dst|$dst, $src2}",
1930 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1931 let isTwoAddress = 0 in {
1932 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
1933 "sub{b}\t{$src2, $dst|$dst, $src2}",
1934 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
1935 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
1936 "sub{w}\t{$src2, $dst|$dst, $src2}",
1937 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
1939 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1940 "sub{l}\t{$src2, $dst|$dst, $src2}",
1941 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
1942 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
1943 "sub{b}\t{$src2, $dst|$dst, $src2}",
1944 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1945 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
1946 "sub{w}\t{$src2, $dst|$dst, $src2}",
1947 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1949 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
1950 "sub{l}\t{$src2, $dst|$dst, $src2}",
1951 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1952 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
1953 "sub{w}\t{$src2, $dst|$dst, $src2}",
1954 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1956 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1957 "sub{l}\t{$src2, $dst|$dst, $src2}",
1958 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1961 let Uses = [EFLAGS] in {
1962 def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1963 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1964 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
1966 let isTwoAddress = 0 in {
1967 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
1968 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1969 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
1970 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
1971 "sbb{b}\t{$src2, $dst|$dst, $src2}",
1972 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1973 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
1974 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1975 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1976 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
1977 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1978 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1980 def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1981 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1982 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
1983 def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1984 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1985 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
1986 def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1987 "sbb{l}\t{$src2, $dst|$dst, $src2}",
1988 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
1989 } // Uses = [EFLAGS]
1990 } // Defs = [EFLAGS]
1992 let Defs = [EFLAGS] in {
1993 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
1994 def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1995 "imul{w}\t{$src2, $dst|$dst, $src2}",
1996 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
1997 def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1998 "imul{l}\t{$src2, $dst|$dst, $src2}",
1999 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2001 def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
2002 "imul{w}\t{$src2, $dst|$dst, $src2}",
2003 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2005 def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
2006 "imul{l}\t{$src2, $dst|$dst, $src2}",
2007 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
2008 } // Defs = [EFLAGS]
2009 } // end Two Address instructions
2011 // Suprisingly enough, these are not two address instructions!
2012 let Defs = [EFLAGS] in {
2013 def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2014 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
2015 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2016 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2017 def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2018 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
2019 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2020 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2021 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2022 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
2023 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2024 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2026 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2027 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
2028 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2029 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2031 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2032 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
2033 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2034 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2036 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2037 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
2038 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2039 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2040 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2041 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
2042 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2043 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2045 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2046 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
2047 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
2048 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2049 } // Defs = [EFLAGS]
2051 //===----------------------------------------------------------------------===//
2052 // Test instructions are just like AND, except they don't generate a result.
2054 let Defs = [EFLAGS] in {
2055 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2056 def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
2057 "test{b}\t{$src2, $src1|$src1, $src2}",
2058 [(X86cmp (and GR8:$src1, GR8:$src2), 0),
2059 (implicit EFLAGS)]>;
2060 def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
2061 "test{w}\t{$src2, $src1|$src1, $src2}",
2062 [(X86cmp (and GR16:$src1, GR16:$src2), 0),
2063 (implicit EFLAGS)]>,
2065 def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
2066 "test{l}\t{$src2, $src1|$src1, $src2}",
2067 [(X86cmp (and GR32:$src1, GR32:$src2), 0),
2068 (implicit EFLAGS)]>;
2071 def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
2072 "test{b}\t{$src2, $src1|$src1, $src2}",
2073 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2074 (implicit EFLAGS)]>;
2075 def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
2076 "test{w}\t{$src2, $src1|$src1, $src2}",
2077 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2078 (implicit EFLAGS)]>, OpSize;
2079 def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
2080 "test{l}\t{$src2, $src1|$src1, $src2}",
2081 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2082 (implicit EFLAGS)]>;
2084 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2085 (outs), (ins GR8:$src1, i8imm:$src2),
2086 "test{b}\t{$src2, $src1|$src1, $src2}",
2087 [(X86cmp (and GR8:$src1, imm:$src2), 0),
2088 (implicit EFLAGS)]>;
2089 def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2090 (outs), (ins GR16:$src1, i16imm:$src2),
2091 "test{w}\t{$src2, $src1|$src1, $src2}",
2092 [(X86cmp (and GR16:$src1, imm:$src2), 0),
2093 (implicit EFLAGS)]>, OpSize;
2094 def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2095 (outs), (ins GR32:$src1, i32imm:$src2),
2096 "test{l}\t{$src2, $src1|$src1, $src2}",
2097 [(X86cmp (and GR32:$src1, imm:$src2), 0),
2098 (implicit EFLAGS)]>;
2100 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2101 (outs), (ins i8mem:$src1, i8imm:$src2),
2102 "test{b}\t{$src2, $src1|$src1, $src2}",
2103 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2104 (implicit EFLAGS)]>;
2105 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2106 (outs), (ins i16mem:$src1, i16imm:$src2),
2107 "test{w}\t{$src2, $src1|$src1, $src2}",
2108 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2109 (implicit EFLAGS)]>, OpSize;
2110 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2111 (outs), (ins i32mem:$src1, i32imm:$src2),
2112 "test{l}\t{$src2, $src1|$src1, $src2}",
2113 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
2114 (implicit EFLAGS)]>;
2115 } // Defs = [EFLAGS]
2118 // Condition code ops, incl. set if equal/not equal/...
2119 let Defs = [EFLAGS], Uses = [AH] in
2120 def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
2121 let Defs = [AH], Uses = [EFLAGS] in
2122 def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
2124 let Uses = [EFLAGS] in {
2125 def SETEr : I<0x94, MRM0r,
2126 (outs GR8 :$dst), (ins),
2128 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
2130 def SETEm : I<0x94, MRM0m,
2131 (outs), (ins i8mem:$dst),
2133 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
2135 def SETNEr : I<0x95, MRM0r,
2136 (outs GR8 :$dst), (ins),
2138 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
2140 def SETNEm : I<0x95, MRM0m,
2141 (outs), (ins i8mem:$dst),
2143 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
2145 def SETLr : I<0x9C, MRM0r,
2146 (outs GR8 :$dst), (ins),
2148 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
2149 TB; // GR8 = < signed
2150 def SETLm : I<0x9C, MRM0m,
2151 (outs), (ins i8mem:$dst),
2153 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
2154 TB; // [mem8] = < signed
2155 def SETGEr : I<0x9D, MRM0r,
2156 (outs GR8 :$dst), (ins),
2158 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
2159 TB; // GR8 = >= signed
2160 def SETGEm : I<0x9D, MRM0m,
2161 (outs), (ins i8mem:$dst),
2163 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
2164 TB; // [mem8] = >= signed
2165 def SETLEr : I<0x9E, MRM0r,
2166 (outs GR8 :$dst), (ins),
2168 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
2169 TB; // GR8 = <= signed
2170 def SETLEm : I<0x9E, MRM0m,
2171 (outs), (ins i8mem:$dst),
2173 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
2174 TB; // [mem8] = <= signed
2175 def SETGr : I<0x9F, MRM0r,
2176 (outs GR8 :$dst), (ins),
2178 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
2179 TB; // GR8 = > signed
2180 def SETGm : I<0x9F, MRM0m,
2181 (outs), (ins i8mem:$dst),
2183 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
2184 TB; // [mem8] = > signed
2186 def SETBr : I<0x92, MRM0r,
2187 (outs GR8 :$dst), (ins),
2189 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
2190 TB; // GR8 = < unsign
2191 def SETBm : I<0x92, MRM0m,
2192 (outs), (ins i8mem:$dst),
2194 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
2195 TB; // [mem8] = < unsign
2196 def SETAEr : I<0x93, MRM0r,
2197 (outs GR8 :$dst), (ins),
2199 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
2200 TB; // GR8 = >= unsign
2201 def SETAEm : I<0x93, MRM0m,
2202 (outs), (ins i8mem:$dst),
2204 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
2205 TB; // [mem8] = >= unsign
2206 def SETBEr : I<0x96, MRM0r,
2207 (outs GR8 :$dst), (ins),
2209 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
2210 TB; // GR8 = <= unsign
2211 def SETBEm : I<0x96, MRM0m,
2212 (outs), (ins i8mem:$dst),
2214 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
2215 TB; // [mem8] = <= unsign
2216 def SETAr : I<0x97, MRM0r,
2217 (outs GR8 :$dst), (ins),
2219 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
2220 TB; // GR8 = > signed
2221 def SETAm : I<0x97, MRM0m,
2222 (outs), (ins i8mem:$dst),
2224 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
2225 TB; // [mem8] = > signed
2227 def SETSr : I<0x98, MRM0r,
2228 (outs GR8 :$dst), (ins),
2230 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
2231 TB; // GR8 = <sign bit>
2232 def SETSm : I<0x98, MRM0m,
2233 (outs), (ins i8mem:$dst),
2235 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
2236 TB; // [mem8] = <sign bit>
2237 def SETNSr : I<0x99, MRM0r,
2238 (outs GR8 :$dst), (ins),
2240 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
2241 TB; // GR8 = !<sign bit>
2242 def SETNSm : I<0x99, MRM0m,
2243 (outs), (ins i8mem:$dst),
2245 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
2246 TB; // [mem8] = !<sign bit>
2247 def SETPr : I<0x9A, MRM0r,
2248 (outs GR8 :$dst), (ins),
2250 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
2252 def SETPm : I<0x9A, MRM0m,
2253 (outs), (ins i8mem:$dst),
2255 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
2256 TB; // [mem8] = parity
2257 def SETNPr : I<0x9B, MRM0r,
2258 (outs GR8 :$dst), (ins),
2260 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
2261 TB; // GR8 = not parity
2262 def SETNPm : I<0x9B, MRM0m,
2263 (outs), (ins i8mem:$dst),
2265 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
2266 TB; // [mem8] = not parity
2267 } // Uses = [EFLAGS]
2270 // Integer comparisons
2271 let Defs = [EFLAGS] in {
2272 def CMP8rr : I<0x38, MRMDestReg,
2273 (outs), (ins GR8 :$src1, GR8 :$src2),
2274 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2275 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
2276 def CMP16rr : I<0x39, MRMDestReg,
2277 (outs), (ins GR16:$src1, GR16:$src2),
2278 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2279 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
2280 def CMP32rr : I<0x39, MRMDestReg,
2281 (outs), (ins GR32:$src1, GR32:$src2),
2282 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2283 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
2284 def CMP8mr : I<0x38, MRMDestMem,
2285 (outs), (ins i8mem :$src1, GR8 :$src2),
2286 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2287 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2288 (implicit EFLAGS)]>;
2289 def CMP16mr : I<0x39, MRMDestMem,
2290 (outs), (ins i16mem:$src1, GR16:$src2),
2291 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2292 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2293 (implicit EFLAGS)]>, OpSize;
2294 def CMP32mr : I<0x39, MRMDestMem,
2295 (outs), (ins i32mem:$src1, GR32:$src2),
2296 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2297 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2298 (implicit EFLAGS)]>;
2299 def CMP8rm : I<0x3A, MRMSrcMem,
2300 (outs), (ins GR8 :$src1, i8mem :$src2),
2301 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2302 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2303 (implicit EFLAGS)]>;
2304 def CMP16rm : I<0x3B, MRMSrcMem,
2305 (outs), (ins GR16:$src1, i16mem:$src2),
2306 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2307 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2308 (implicit EFLAGS)]>, OpSize;
2309 def CMP32rm : I<0x3B, MRMSrcMem,
2310 (outs), (ins GR32:$src1, i32mem:$src2),
2311 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2312 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2313 (implicit EFLAGS)]>;
2314 def CMP8ri : Ii8<0x80, MRM7r,
2315 (outs), (ins GR8:$src1, i8imm:$src2),
2316 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2317 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
2318 def CMP16ri : Ii16<0x81, MRM7r,
2319 (outs), (ins GR16:$src1, i16imm:$src2),
2320 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2321 [(X86cmp GR16:$src1, imm:$src2),
2322 (implicit EFLAGS)]>, OpSize;
2323 def CMP32ri : Ii32<0x81, MRM7r,
2324 (outs), (ins GR32:$src1, i32imm:$src2),
2325 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2326 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
2327 def CMP8mi : Ii8 <0x80, MRM7m,
2328 (outs), (ins i8mem :$src1, i8imm :$src2),
2329 "cmp{b}\t{$src2, $src1|$src1, $src2}",
2330 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2331 (implicit EFLAGS)]>;
2332 def CMP16mi : Ii16<0x81, MRM7m,
2333 (outs), (ins i16mem:$src1, i16imm:$src2),
2334 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2335 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2336 (implicit EFLAGS)]>, OpSize;
2337 def CMP32mi : Ii32<0x81, MRM7m,
2338 (outs), (ins i32mem:$src1, i32imm:$src2),
2339 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2340 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2341 (implicit EFLAGS)]>;
2342 def CMP16ri8 : Ii8<0x83, MRM7r,
2343 (outs), (ins GR16:$src1, i16i8imm:$src2),
2344 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2345 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2346 (implicit EFLAGS)]>, OpSize;
2347 def CMP16mi8 : Ii8<0x83, MRM7m,
2348 (outs), (ins i16mem:$src1, i16i8imm:$src2),
2349 "cmp{w}\t{$src2, $src1|$src1, $src2}",
2350 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2351 (implicit EFLAGS)]>, OpSize;
2352 def CMP32mi8 : Ii8<0x83, MRM7m,
2353 (outs), (ins i32mem:$src1, i32i8imm:$src2),
2354 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2355 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2356 (implicit EFLAGS)]>;
2357 def CMP32ri8 : Ii8<0x83, MRM7r,
2358 (outs), (ins GR32:$src1, i32i8imm:$src2),
2359 "cmp{l}\t{$src2, $src1|$src1, $src2}",
2360 [(X86cmp GR32:$src1, i32immSExt8:$src2),
2361 (implicit EFLAGS)]>;
2362 } // Defs = [EFLAGS]
2364 // Sign/Zero extenders
2365 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2366 "movs{bw|x}\t{$src, $dst|$dst, $src}",
2367 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
2368 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2369 "movs{bw|x}\t{$src, $dst|$dst, $src}",
2370 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2371 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2372 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2373 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2374 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2375 "movs{bl|x}\t{$src, $dst|$dst, $src}",
2376 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2377 def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2378 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2379 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2380 def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2381 "movs{wl|x}\t{$src, $dst|$dst, $src}",
2382 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2384 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
2385 "movz{bw|x}\t{$src, $dst|$dst, $src}",
2386 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
2387 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
2388 "movz{bw|x}\t{$src, $dst|$dst, $src}",
2389 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2390 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
2391 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2392 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2393 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
2394 "movz{bl|x}\t{$src, $dst|$dst, $src}",
2395 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2396 def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
2397 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2398 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2399 def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
2400 "movz{wl|x}\t{$src, $dst|$dst, $src}",
2401 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2403 let Defs = [AX], Uses = [AL] in
2404 def CBW : I<0x98, RawFrm, (outs), (ins),
2405 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2406 let Defs = [EAX], Uses = [AX] in
2407 def CWDE : I<0x98, RawFrm, (outs), (ins),
2408 "{cwtl|cwde}", []>; // EAX = signext(AX)
2410 let Defs = [AX,DX], Uses = [AX] in
2411 def CWD : I<0x99, RawFrm, (outs), (ins),
2412 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2413 let Defs = [EAX,EDX], Uses = [EAX] in
2414 def CDQ : I<0x99, RawFrm, (outs), (ins),
2415 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2418 //===----------------------------------------------------------------------===//
2419 // Alias Instructions
2420 //===----------------------------------------------------------------------===//
2422 // Alias instructions that map movr0 to xor.
2423 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2424 let Defs = [EFLAGS], isReMaterializable = 1 in {
2425 def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
2426 "xor{b}\t$dst, $dst",
2427 [(set GR8:$dst, 0)]>;
2428 def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
2429 "xor{w}\t$dst, $dst",
2430 [(set GR16:$dst, 0)]>, OpSize;
2431 def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
2432 "xor{l}\t$dst, $dst",
2433 [(set GR32:$dst, 0)]>;
2436 // Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2437 // those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2438 def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
2439 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2440 def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
2441 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2443 def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
2444 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2445 def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
2446 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2448 def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
2449 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2450 def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
2451 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2453 def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
2454 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
2455 def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
2456 "mov{l}\t{$src, $dst|$dst, $src}", []>;
2458 //===----------------------------------------------------------------------===//
2459 // Thread Local Storage Instructions
2463 def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2464 "leal\t${sym:mem}(,%ebx,1), $dst",
2465 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
2467 let AddedComplexity = 10 in
2468 def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
2469 "movl\t%gs:($src), $dst",
2470 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2472 let AddedComplexity = 15 in
2473 def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2474 "movl\t%gs:${src:mem}, $dst",
2476 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2478 def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
2479 "movl\t%gs:0, $dst",
2480 [(set GR32:$dst, X86TLStp)]>;
2482 //===----------------------------------------------------------------------===//
2483 // DWARF Pseudo Instructions
2486 def DWARF_LOC : I<0, Pseudo, (outs),
2487 (ins i32imm:$line, i32imm:$col, i32imm:$file),
2488 ".loc\t${file:debug} ${line:debug} ${col:debug}",
2489 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2492 //===----------------------------------------------------------------------===//
2493 // EH Pseudo Instructions
2495 let isTerminator = 1, isReturn = 1, isBarrier = 1,
2497 def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
2498 "ret\t#eh_return, addr: $addr",
2499 [(X86ehret GR32:$addr)]>;
2503 //===----------------------------------------------------------------------===//
2504 // Non-Instruction Patterns
2505 //===----------------------------------------------------------------------===//
2507 // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2508 def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2509 def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2510 def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2511 def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2512 def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2514 def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2515 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2516 def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2517 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2518 def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2519 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2520 def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2521 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2523 def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2524 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2525 def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2526 (MOV32mi addr:$dst, texternalsym:$src)>;
2530 def : Pat<(X86tailcall GR32:$dst),
2533 def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2535 def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2538 def : Pat<(X86tcret GR32:$dst, imm:$off),
2539 (TCRETURNri GR32:$dst, imm:$off)>;
2541 def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2542 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2544 def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2545 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2547 def : Pat<(X86call (i32 tglobaladdr:$dst)),
2548 (CALLpcrel32 tglobaladdr:$dst)>;
2549 def : Pat<(X86call (i32 texternalsym:$dst)),
2550 (CALLpcrel32 texternalsym:$dst)>;
2552 // X86 specific add which produces a flag.
2553 def : Pat<(addc GR32:$src1, GR32:$src2),
2554 (ADD32rr GR32:$src1, GR32:$src2)>;
2555 def : Pat<(addc GR32:$src1, (load addr:$src2)),
2556 (ADD32rm GR32:$src1, addr:$src2)>;
2557 def : Pat<(addc GR32:$src1, imm:$src2),
2558 (ADD32ri GR32:$src1, imm:$src2)>;
2559 def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2560 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2562 def : Pat<(subc GR32:$src1, GR32:$src2),
2563 (SUB32rr GR32:$src1, GR32:$src2)>;
2564 def : Pat<(subc GR32:$src1, (load addr:$src2)),
2565 (SUB32rm GR32:$src1, addr:$src2)>;
2566 def : Pat<(subc GR32:$src1, imm:$src2),
2567 (SUB32ri GR32:$src1, imm:$src2)>;
2568 def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2569 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2571 def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2572 (MOV8mi addr:$dst, imm:$src)>;
2573 def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2574 (MOV8mr addr:$dst, GR8:$src)>;
2578 // TEST R,R is smaller than CMP R,0
2579 def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
2580 (TEST8rr GR8:$src1, GR8:$src1)>;
2581 def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
2582 (TEST16rr GR16:$src1, GR16:$src1)>;
2583 def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
2584 (TEST32rr GR32:$src1, GR32:$src1)>;
2586 // {s|z}extload bool -> {s|z}extload byte
2587 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2588 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2589 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2590 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2591 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2593 // extload bool -> extload byte
2594 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2595 def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2596 def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2597 def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2598 def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2599 def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2602 def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2603 def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2604 def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2605 def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2606 def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2607 def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2609 //===----------------------------------------------------------------------===//
2611 //===----------------------------------------------------------------------===//
2613 // (shl x, 1) ==> (add x, x)
2614 def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2615 def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2616 def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2618 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2619 def : Pat<(or (srl GR32:$src1, CL:$amt),
2620 (shl GR32:$src2, (sub 32, CL:$amt))),
2621 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2623 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2624 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2625 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2627 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2628 def : Pat<(or (shl GR32:$src1, CL:$amt),
2629 (srl GR32:$src2, (sub 32, CL:$amt))),
2630 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2632 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2633 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2634 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2636 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2637 def : Pat<(or (srl GR16:$src1, CL:$amt),
2638 (shl GR16:$src2, (sub 16, CL:$amt))),
2639 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2641 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2642 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2643 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2645 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2646 def : Pat<(or (shl GR16:$src1, CL:$amt),
2647 (srl GR16:$src2, (sub 16, CL:$amt))),
2648 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2650 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2651 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2652 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2655 //===----------------------------------------------------------------------===//
2656 // Floating Point Stack Support
2657 //===----------------------------------------------------------------------===//
2659 include "X86InstrFPStack.td"
2661 //===----------------------------------------------------------------------===//
2663 //===----------------------------------------------------------------------===//
2665 include "X86InstrX86-64.td"
2667 //===----------------------------------------------------------------------===//
2668 // MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2669 //===----------------------------------------------------------------------===//
2671 include "X86InstrMMX.td"
2673 //===----------------------------------------------------------------------===//
2674 // XMM Floating point support (requires SSE / SSE2)
2675 //===----------------------------------------------------------------------===//
2677 include "X86InstrSSE.td"