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, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
30 def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
33 def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
36 def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
38 def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39 def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
42 def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
44 def SDTX86FpGet : SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>;
45 def SDTX86FpSet : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
47 def SDTX86Fld : SDTypeProfile<1, 2, [SDTCisVT<0, f64>,
48 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
49 def SDTX86Fst : SDTypeProfile<0, 3, [SDTCisFP<0>,
50 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
51 def SDTX86Fild : SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisPtrTy<1>,
52 SDTCisVT<2, OtherVT>]>;
53 def SDTX86FpToIMem: SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisPtrTy<1>]>;
55 def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
57 def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
59 def X86addflag : SDNode<"X86ISD::ADD_FLAG", SDTIntBinOp ,
60 [SDNPCommutative, SDNPAssociative, SDNPOutFlag]>;
61 def X86subflag : SDNode<"X86ISD::SUB_FLAG", SDTIntBinOp,
63 def X86adc : SDNode<"X86ISD::ADC" , SDTIntBinOp ,
64 [SDNPCommutative, SDNPAssociative, SDNPInFlag]>;
65 def X86sbb : SDNode<"X86ISD::SBB" , SDTIntBinOp,
68 def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
69 def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
71 def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
73 def X86test : SDNode<"X86ISD::TEST", SDTX86CmpTest,
76 def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
77 [SDNPInFlag, SDNPOutFlag]>;
78 def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
79 [SDNPHasChain, SDNPInFlag]>;
80 def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
81 [SDNPInFlag, SDNPOutFlag]>;
83 def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
84 [SDNPHasChain, SDNPOptInFlag]>;
86 def X86callseq_start :
87 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
90 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
91 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
93 def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
94 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
96 def X86fpget : SDNode<"X86ISD::FP_GET_RESULT", SDTX86FpGet,
97 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
98 def X86fpset : SDNode<"X86ISD::FP_SET_RESULT", SDTX86FpSet,
99 [SDNPHasChain, SDNPOutFlag]>;
101 def X86fld : SDNode<"X86ISD::FLD", SDTX86Fld,
103 def X86fst : SDNode<"X86ISD::FST", SDTX86Fst,
104 [SDNPHasChain, SDNPInFlag]>;
105 def X86fild : SDNode<"X86ISD::FILD", SDTX86Fild,
106 [SDNPHasChain, SDNPOutFlag]>;
107 def X86fp_to_i16mem : SDNode<"X86ISD::FP_TO_INT16_IN_MEM", SDTX86FpToIMem,
109 def X86fp_to_i32mem : SDNode<"X86ISD::FP_TO_INT32_IN_MEM", SDTX86FpToIMem,
111 def X86fp_to_i64mem : SDNode<"X86ISD::FP_TO_INT64_IN_MEM", SDTX86FpToIMem,
114 def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
115 [SDNPHasChain, SDNPInFlag]>;
116 def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
117 [SDNPHasChain, SDNPInFlag]>;
119 def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
120 [SDNPHasChain, SDNPOutFlag]>;
122 //===----------------------------------------------------------------------===//
123 // X86 Operand Definitions.
126 // *mem - Operand definitions for the funky X86 addressing mode operands.
128 class X86MemOperand<string printMethod> : Operand<i32> {
129 let PrintMethod = printMethod;
130 let NumMIOperands = 4;
131 let MIOperandInfo = (ops R32, i8imm, R32, i32imm);
134 def i8mem : X86MemOperand<"printi8mem">;
135 def i16mem : X86MemOperand<"printi16mem">;
136 def i32mem : X86MemOperand<"printi32mem">;
137 def i64mem : X86MemOperand<"printi64mem">;
138 def f32mem : X86MemOperand<"printf32mem">;
139 def f64mem : X86MemOperand<"printf64mem">;
140 def f80mem : X86MemOperand<"printf80mem">;
142 def SSECC : Operand<i8> {
143 let PrintMethod = "printSSECC";
146 // A couple of more descriptive operand definitions.
147 // 16-bits but only 8 bits are significant.
148 def i16i8imm : Operand<i16>;
149 // 32-bits but only 8 bits are significant.
150 def i32i8imm : Operand<i32>;
152 // PCRelative calls need special operand formatting.
153 let PrintMethod = "printCallOperand" in
154 def calltarget : Operand<i32>;
156 // Branch targets have OtherVT type.
157 def brtarget : Operand<OtherVT>;
159 //===----------------------------------------------------------------------===//
160 // X86 Complex Pattern Definitions.
163 // Define X86 specific addressing mode.
164 def addr : ComplexPattern<i32, 4, "SelectAddr", []>;
165 def leaaddr : ComplexPattern<i32, 4, "SelectLEAAddr",
166 [add, frameindex, constpool]>;
168 //===----------------------------------------------------------------------===//
169 // X86 Instruction Format Definitions.
172 // Format specifies the encoding used by the instruction. This is part of the
173 // ad-hoc solution used to emit machine instruction encodings by our machine
175 class Format<bits<5> val> {
179 def Pseudo : Format<0>; def RawFrm : Format<1>;
180 def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
181 def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
182 def MRMSrcMem : Format<6>;
183 def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
184 def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
185 def MRM6r : Format<22>; def MRM7r : Format<23>;
186 def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
187 def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
188 def MRM6m : Format<30>; def MRM7m : Format<31>;
190 //===----------------------------------------------------------------------===//
191 // X86 Instruction Predicate Definitions.
192 def HasSSE1 : Predicate<"Subtarget->hasSSE()">;
193 def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
194 def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
195 def FPStack : Predicate<"!Subtarget->hasSSE2()">;
197 //===----------------------------------------------------------------------===//
198 // X86 specific pattern fragments.
201 // ImmType - This specifies the immediate type used by an instruction. This is
202 // part of the ad-hoc solution used to emit machine instruction encodings by our
203 // machine code emitter.
204 class ImmType<bits<2> val> {
207 def NoImm : ImmType<0>;
208 def Imm8 : ImmType<1>;
209 def Imm16 : ImmType<2>;
210 def Imm32 : ImmType<3>;
212 // FPFormat - This specifies what form this FP instruction has. This is used by
213 // the Floating-Point stackifier pass.
214 class FPFormat<bits<3> val> {
217 def NotFP : FPFormat<0>;
218 def ZeroArgFP : FPFormat<1>;
219 def OneArgFP : FPFormat<2>;
220 def OneArgFPRW : FPFormat<3>;
221 def TwoArgFP : FPFormat<4>;
222 def CompareFP : FPFormat<5>;
223 def CondMovFP : FPFormat<6>;
224 def SpecialFP : FPFormat<7>;
227 class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
229 let Namespace = "X86";
231 bits<8> Opcode = opcod;
233 bits<5> FormBits = Form.Value;
235 bits<2> ImmTypeBits = ImmT.Value;
237 dag OperandList = ops;
238 string AsmString = AsmStr;
241 // Attributes specific to X86 instructions...
243 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
245 bits<4> Prefix = 0; // Which prefix byte does this inst have?
246 FPFormat FPForm; // What flavor of FP instruction is this?
247 bits<3> FPFormBits = 0;
250 class Imp<list<Register> uses, list<Register> defs> {
251 list<Register> Uses = uses;
252 list<Register> Defs = defs;
256 // Prefix byte classes which are used to indicate to the ad-hoc machine code
257 // emitter that various prefix bytes are required.
258 class OpSize { bit hasOpSizePrefix = 1; }
259 class TB { bits<4> Prefix = 1; }
260 class REP { bits<4> Prefix = 2; }
261 class D8 { bits<4> Prefix = 3; }
262 class D9 { bits<4> Prefix = 4; }
263 class DA { bits<4> Prefix = 5; }
264 class DB { bits<4> Prefix = 6; }
265 class DC { bits<4> Prefix = 7; }
266 class DD { bits<4> Prefix = 8; }
267 class DE { bits<4> Prefix = 9; }
268 class DF { bits<4> Prefix = 10; }
269 class XD { bits<4> Prefix = 11; }
270 class XS { bits<4> Prefix = 12; }
273 //===----------------------------------------------------------------------===//
274 // Pattern fragments...
277 // X86 specific condition code. These correspond to CondCode in
278 // X86ISelLowering.h. They must be kept in synch.
279 def X86_COND_A : PatLeaf<(i8 0)>;
280 def X86_COND_AE : PatLeaf<(i8 1)>;
281 def X86_COND_B : PatLeaf<(i8 2)>;
282 def X86_COND_BE : PatLeaf<(i8 3)>;
283 def X86_COND_E : PatLeaf<(i8 4)>;
284 def X86_COND_G : PatLeaf<(i8 5)>;
285 def X86_COND_GE : PatLeaf<(i8 6)>;
286 def X86_COND_L : PatLeaf<(i8 7)>;
287 def X86_COND_LE : PatLeaf<(i8 8)>;
288 def X86_COND_NE : PatLeaf<(i8 9)>;
289 def X86_COND_NO : PatLeaf<(i8 10)>;
290 def X86_COND_NP : PatLeaf<(i8 11)>;
291 def X86_COND_NS : PatLeaf<(i8 12)>;
292 def X86_COND_O : PatLeaf<(i8 13)>;
293 def X86_COND_P : PatLeaf<(i8 14)>;
294 def X86_COND_S : PatLeaf<(i8 15)>;
296 def i16immSExt8 : PatLeaf<(i16 imm), [{
297 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
298 // sign extended field.
299 return (int)N->getValue() == (signed char)N->getValue();
302 def i32immSExt8 : PatLeaf<(i32 imm), [{
303 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
304 // sign extended field.
305 return (int)N->getValue() == (signed char)N->getValue();
308 def i16immZExt8 : PatLeaf<(i16 imm), [{
309 // i16immZExt8 predicate - True if the 16-bit immediate fits in a 8-bit zero
311 return (unsigned)N->getValue() == (unsigned char)N->getValue();
314 def fp32imm0 : PatLeaf<(f32 fpimm), [{
315 return N->isExactlyValue(+0.0);
318 def fp64imm0 : PatLeaf<(f64 fpimm), [{
319 return N->isExactlyValue(+0.0);
322 def fp64immneg0 : PatLeaf<(f64 fpimm), [{
323 return N->isExactlyValue(-0.0);
326 def fp64imm1 : PatLeaf<(f64 fpimm), [{
327 return N->isExactlyValue(+1.0);
330 def fp64immneg1 : PatLeaf<(f64 fpimm), [{
331 return N->isExactlyValue(-1.0);
334 // Helper fragments for loads.
335 def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
336 def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
337 def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
338 def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
339 def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
341 def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i1))>;
342 def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i1))>;
343 def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i8))>;
344 def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i8))>;
345 def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i16))>;
347 def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextload node:$ptr, i1))>;
348 def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i1))>;
349 def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i1))>;
350 def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i8))>;
351 def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i8))>;
352 def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i16))>;
354 def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extload node:$ptr, i1))>;
355 def extloadf64f32 : PatFrag<(ops node:$ptr), (f64 (extload node:$ptr, f32))>;
357 //===----------------------------------------------------------------------===//
358 // Instruction templates...
360 class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
361 : X86Inst<o, f, NoImm, ops, asm> {
362 let Pattern = pattern;
364 class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
365 : X86Inst<o, f, Imm8 , ops, asm> {
366 let Pattern = pattern;
368 class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
369 : X86Inst<o, f, Imm16, ops, asm> {
370 let Pattern = pattern;
372 class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
373 : X86Inst<o, f, Imm32, ops, asm> {
374 let Pattern = pattern;
377 //===----------------------------------------------------------------------===//
378 // Instruction list...
381 def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
382 [(X86callseq_start imm:$amt)]>;
383 def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
385 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
386 def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
387 def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
388 def IMPLICIT_DEF_R8 : I<0, Pseudo, (ops R8:$dst),
389 "#IMPLICIT_DEF $dst",
390 [(set R8:$dst, (undef))]>;
391 def IMPLICIT_DEF_R16 : I<0, Pseudo, (ops R16:$dst),
392 "#IMPLICIT_DEF $dst",
393 [(set R16:$dst, (undef))]>;
394 def IMPLICIT_DEF_R32 : I<0, Pseudo, (ops R32:$dst),
395 "#IMPLICIT_DEF $dst",
396 [(set R32:$dst, (undef))]>;
397 def IMPLICIT_DEF_FR32 : I<0, Pseudo, (ops FR32:$dst),
398 "#IMPLICIT_DEF $dst",
399 [(set FR32:$dst, (undef))]>, Requires<[HasSSE2]>;
400 def IMPLICIT_DEF_FR64 : I<0, Pseudo, (ops FR64:$dst),
401 "#IMPLICIT_DEF $dst",
402 [(set FR64:$dst, (undef))]>, Requires<[HasSSE2]>;
405 // CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
406 // scheduler into a branch sequence.
407 let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
408 def CMOV_FR32 : I<0, Pseudo,
409 (ops FR32:$dst, FR32:$t, FR32:$f, i8imm:$cond),
410 "#CMOV_FR32 PSEUDO!",
411 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond))]>;
412 def CMOV_FR64 : I<0, Pseudo,
413 (ops FR64:$dst, FR64:$t, FR64:$f, i8imm:$cond),
414 "#CMOV_FR64 PSEUDO!",
415 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond))]>;
418 let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
419 def FP_TO_INT16_IN_MEM : I<0, Pseudo,
420 (ops i16mem:$dst, RFP:$src),
421 "#FP_TO_INT16_IN_MEM PSEUDO!",
422 [(X86fp_to_i16mem RFP:$src, addr:$dst)]>;
423 def FP_TO_INT32_IN_MEM : I<0, Pseudo,
424 (ops i32mem:$dst, RFP:$src),
425 "#FP_TO_INT32_IN_MEM PSEUDO!",
426 [(X86fp_to_i32mem RFP:$src, addr:$dst)]>;
427 def FP_TO_INT64_IN_MEM : I<0, Pseudo,
428 (ops i64mem:$dst, RFP:$src),
429 "#FP_TO_INT64_IN_MEM PSEUDO!",
430 [(X86fp_to_i64mem RFP:$src, addr:$dst)]>;
434 let isTerminator = 1 in
435 let Defs = [FP0, FP1, FP2, FP3, FP4, FP5, FP6] in
436 def FP_REG_KILL : I<0, Pseudo, (ops), "#FP_REG_KILL", []>;
440 def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
442 //===----------------------------------------------------------------------===//
443 // Control Flow Instructions...
446 // Return instructions.
447 let isTerminator = 1, isReturn = 1, isBarrier = 1,
448 hasCtrlDep = 1, noResults = 1 in {
449 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
450 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
451 [(X86retflag imm:$amt)]>;
454 // All branches are RawFrm, Void, Branch, and Terminators
455 let isBranch = 1, isTerminator = 1, noResults = 1 in
456 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
457 I<opcode, RawFrm, ops, asm, pattern>;
459 // Conditional branches
461 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
463 def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
464 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
465 def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
466 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
467 def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
468 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
469 def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
470 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
471 def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
472 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
473 def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
474 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
476 def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
477 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
478 def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
479 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
480 def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
481 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
482 def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
483 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
485 def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
486 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
487 def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
488 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
489 def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
490 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
491 def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
492 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
493 def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
494 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
495 def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
496 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
498 //===----------------------------------------------------------------------===//
499 // Call Instructions...
501 let isCall = 1, noResults = 1 in
502 // All calls clobber the non-callee saved registers...
503 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
504 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
505 def CALLpcrel32 : I<0xE8, RawFrm, (ops calltarget:$dst), "call $dst",
507 def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst",
508 [(X86call R32:$dst)]>;
509 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst), "call {*}$dst",
510 [(X86call (loadi32 addr:$dst))]>;
514 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
515 def TAILJMPd : IBr<0xE9, (ops calltarget:$dst), "jmp $dst # TAIL CALL", []>;
516 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
517 def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
518 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
519 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
520 "jmp {*}$dst # TAIL CALL", []>;
522 // ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
523 // way, except that it is marked as being a terminator. This causes the epilog
524 // inserter to insert reloads of callee saved registers BEFORE this. We need
525 // this until we have a more accurate way of tracking where the stack pointer is
526 // within a function.
527 let isTerminator = 1, isTwoAddress = 1 in
528 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
529 "add{l} {$src2, $dst|$dst, $src2}", []>;
531 //===----------------------------------------------------------------------===//
532 // Miscellaneous Instructions...
534 def LEAVE : I<0xC9, RawFrm,
535 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
536 def POP32r : I<0x58, AddRegFrm,
537 (ops R32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
539 let isTwoAddress = 1 in // R32 = bswap R32
540 def BSWAP32r : I<0xC8, AddRegFrm,
541 (ops R32:$dst, R32:$src),
543 [(set R32:$dst, (bswap R32:$src))]>, TB;
545 def XCHG8rr : I<0x86, MRMDestReg, // xchg R8, R8
546 (ops R8:$src1, R8:$src2),
547 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
548 def XCHG16rr : I<0x87, MRMDestReg, // xchg R16, R16
549 (ops R16:$src1, R16:$src2),
550 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
551 def XCHG32rr : I<0x87, MRMDestReg, // xchg R32, R32
552 (ops R32:$src1, R32:$src2),
553 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
555 def XCHG8mr : I<0x86, MRMDestMem,
556 (ops i8mem:$src1, R8:$src2),
557 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
558 def XCHG16mr : I<0x87, MRMDestMem,
559 (ops i16mem:$src1, R16:$src2),
560 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
561 def XCHG32mr : I<0x87, MRMDestMem,
562 (ops i32mem:$src1, R32:$src2),
563 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
564 def XCHG8rm : I<0x86, MRMSrcMem,
565 (ops R8:$src1, i8mem:$src2),
566 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
567 def XCHG16rm : I<0x87, MRMSrcMem,
568 (ops R16:$src1, i16mem:$src2),
569 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
570 def XCHG32rm : I<0x87, MRMSrcMem,
571 (ops R32:$src1, i32mem:$src2),
572 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
574 def LEA16r : I<0x8D, MRMSrcMem,
575 (ops R16:$dst, i32mem:$src),
576 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
577 def LEA32r : I<0x8D, MRMSrcMem,
578 (ops R32:$dst, i32mem:$src),
579 "lea{l} {$src|$dst}, {$dst|$src}",
580 [(set R32:$dst, leaaddr:$src)]>;
582 def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
584 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
585 def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
586 [(X86rep_movs i16)]>,
587 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
588 def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsd|rep movsd}",
589 [(X86rep_movs i32)]>,
590 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
592 def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
594 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
595 def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
596 [(X86rep_stos i16)]>,
597 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
598 def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
599 [(X86rep_stos i32)]>,
600 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
603 //===----------------------------------------------------------------------===//
604 // Input/Output Instructions...
606 def IN8rr : I<0xEC, RawFrm, (ops),
607 "in{b} {%dx, %al|%AL, %DX}",
608 [(set AL, (readport DX))]>, Imp<[DX], [AL]>;
609 def IN16rr : I<0xED, RawFrm, (ops),
610 "in{w} {%dx, %ax|%AX, %DX}",
611 [(set AX, (readport DX))]>, Imp<[DX], [AX]>, OpSize;
612 def IN32rr : I<0xED, RawFrm, (ops),
613 "in{l} {%dx, %eax|%EAX, %DX}",
614 [(set EAX, (readport DX))]>, Imp<[DX],[EAX]>;
616 def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
617 "in{b} {$port, %al|%AL, $port}",
618 [(set AL, (readport i16immZExt8:$port))]>,
620 def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
621 "in{w} {$port, %ax|%AX, $port}",
622 [(set AX, (readport i16immZExt8:$port))]>,
623 Imp<[], [AX]>, OpSize;
624 def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
625 "in{l} {$port, %eax|%EAX, $port}",
626 [(set EAX, (readport i16immZExt8:$port))]>,
629 def OUT8rr : I<0xEE, RawFrm, (ops),
630 "out{b} {%al, %dx|%DX, %AL}",
631 [(writeport AL, DX)]>, Imp<[DX, AL], []>;
632 def OUT16rr : I<0xEF, RawFrm, (ops),
633 "out{w} {%ax, %dx|%DX, %AX}",
634 [(writeport AX, DX)]>, Imp<[DX, AX], []>, OpSize;
635 def OUT32rr : I<0xEF, RawFrm, (ops),
636 "out{l} {%eax, %dx|%DX, %EAX}",
637 [(writeport EAX, DX)]>, Imp<[DX, EAX], []>;
639 def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
640 "out{b} {%al, $port|$port, %AL}",
641 [(writeport AL, i16immZExt8:$port)]>,
643 def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
644 "out{w} {%ax, $port|$port, %AX}",
645 [(writeport AX, i16immZExt8:$port)]>,
646 Imp<[AX], []>, OpSize;
647 def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
648 "out{l} {%eax, $port|$port, %EAX}",
649 [(writeport EAX, i16immZExt8:$port)]>,
652 //===----------------------------------------------------------------------===//
653 // Move Instructions...
655 def MOV8rr : I<0x88, MRMDestReg, (ops R8 :$dst, R8 :$src),
656 "mov{b} {$src, $dst|$dst, $src}", []>;
657 def MOV16rr : I<0x89, MRMDestReg, (ops R16:$dst, R16:$src),
658 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
659 def MOV32rr : I<0x89, MRMDestReg, (ops R32:$dst, R32:$src),
660 "mov{l} {$src, $dst|$dst, $src}", []>;
661 def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops R8 :$dst, i8imm :$src),
662 "mov{b} {$src, $dst|$dst, $src}",
663 [(set R8:$dst, imm:$src)]>;
664 def MOV16ri : Ii16<0xB8, AddRegFrm, (ops R16:$dst, i16imm:$src),
665 "mov{w} {$src, $dst|$dst, $src}",
666 [(set R16:$dst, imm:$src)]>, OpSize;
667 def MOV32ri : Ii32<0xB8, AddRegFrm, (ops R32:$dst, i32imm:$src),
668 "mov{l} {$src, $dst|$dst, $src}",
669 [(set R32:$dst, imm:$src)]>;
670 def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
671 "mov{b} {$src, $dst|$dst, $src}",
672 [(store (i8 imm:$src), addr:$dst)]>;
673 def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
674 "mov{w} {$src, $dst|$dst, $src}",
675 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
676 def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
677 "mov{l} {$src, $dst|$dst, $src}",
678 [(store (i32 imm:$src), addr:$dst)]>;
680 def MOV8rm : I<0x8A, MRMSrcMem, (ops R8 :$dst, i8mem :$src),
681 "mov{b} {$src, $dst|$dst, $src}",
682 [(set R8:$dst, (load addr:$src))]>;
683 def MOV16rm : I<0x8B, MRMSrcMem, (ops R16:$dst, i16mem:$src),
684 "mov{w} {$src, $dst|$dst, $src}",
685 [(set R16:$dst, (load addr:$src))]>, OpSize;
686 def MOV32rm : I<0x8B, MRMSrcMem, (ops R32:$dst, i32mem:$src),
687 "mov{l} {$src, $dst|$dst, $src}",
688 [(set R32:$dst, (load addr:$src))]>;
690 def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, R8 :$src),
691 "mov{b} {$src, $dst|$dst, $src}",
692 [(store R8:$src, addr:$dst)]>;
693 def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, R16:$src),
694 "mov{w} {$src, $dst|$dst, $src}",
695 [(store R16:$src, addr:$dst)]>, OpSize;
696 def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, R32:$src),
697 "mov{l} {$src, $dst|$dst, $src}",
698 [(store R32:$src, addr:$dst)]>;
700 //===----------------------------------------------------------------------===//
701 // Fixed-Register Multiplication and Division Instructions...
704 // Extra precision multiplication
705 def MUL8r : I<0xF6, MRM4r, (ops R8:$src), "mul{b} $src",
706 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
707 // This probably ought to be moved to a def : Pat<> if the
708 // syntax can be accepted.
709 [(set AL, (mul AL, R8:$src))]>,
710 Imp<[AL],[AX]>; // AL,AH = AL*R8
711 def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul{w} $src", []>,
712 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
713 def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul{l} $src", []>,
714 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
715 def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
717 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
718 // This probably ought to be moved to a def : Pat<> if the
719 // syntax can be accepted.
720 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
721 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
722 def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
723 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
724 OpSize; // AX,DX = AX*[mem16]
725 def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
726 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
728 def IMUL8r : I<0xF6, MRM5r, (ops R8:$src), "imul{b} $src", []>,
729 Imp<[AL],[AX]>; // AL,AH = AL*R8
730 def IMUL16r : I<0xF7, MRM5r, (ops R16:$src), "imul{w} $src", []>,
731 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
732 def IMUL32r : I<0xF7, MRM5r, (ops R32:$src), "imul{l} $src", []>,
733 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
734 def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
735 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
736 def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
737 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
738 OpSize; // AX,DX = AX*[mem16]
739 def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
741 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
743 // unsigned division/remainder
744 def DIV8r : I<0xF6, MRM6r, (ops R8:$src), // AX/r8 = AL,AH
745 "div{b} $src", []>, Imp<[AX],[AX]>;
746 def DIV16r : I<0xF7, MRM6r, (ops R16:$src), // DX:AX/r16 = AX,DX
747 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
748 def DIV32r : I<0xF7, MRM6r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
749 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
750 def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
751 "div{b} $src", []>, Imp<[AX],[AX]>;
752 def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
753 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
754 def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
755 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
757 // Signed division/remainder.
758 def IDIV8r : I<0xF6, MRM7r, (ops R8:$src), // AX/r8 = AL,AH
759 "idiv{b} $src", []>, Imp<[AX],[AX]>;
760 def IDIV16r: I<0xF7, MRM7r, (ops R16:$src), // DX:AX/r16 = AX,DX
761 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
762 def IDIV32r: I<0xF7, MRM7r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
763 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
764 def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
765 "idiv{b} $src", []>, Imp<[AX],[AX]>;
766 def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
767 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
768 def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
769 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
771 // Sign-extenders for division.
772 def CBW : I<0x98, RawFrm, (ops),
773 "{cbtw|cbw}", []>, Imp<[AL],[AH]>; // AX = signext(AL)
774 def CWD : I<0x99, RawFrm, (ops),
775 "{cwtd|cwd}", []>, Imp<[AX],[DX]>; // DX:AX = signext(AX)
776 def CDQ : I<0x99, RawFrm, (ops),
777 "{cltd|cdq}", []>, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
780 //===----------------------------------------------------------------------===//
781 // Two address Instructions...
783 let isTwoAddress = 1 in {
786 def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, R16 = R16
787 (ops R16:$dst, R16:$src1, R16:$src2),
788 "cmovb {$src2, $dst|$dst, $src2}",
789 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
792 def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, R16 = [mem16]
793 (ops R16:$dst, R16:$src1, i16mem:$src2),
794 "cmovb {$src2, $dst|$dst, $src2}",
795 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
798 def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, R32 = R32
799 (ops R32:$dst, R32:$src1, R32:$src2),
800 "cmovb {$src2, $dst|$dst, $src2}",
801 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
804 def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, R32 = [mem32]
805 (ops R32:$dst, R32:$src1, i32mem:$src2),
806 "cmovb {$src2, $dst|$dst, $src2}",
807 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
811 def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, R16 = R16
812 (ops R16:$dst, R16:$src1, R16:$src2),
813 "cmovae {$src2, $dst|$dst, $src2}",
814 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
817 def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, R16 = [mem16]
818 (ops R16:$dst, R16:$src1, i16mem:$src2),
819 "cmovae {$src2, $dst|$dst, $src2}",
820 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
823 def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, R32 = R32
824 (ops R32:$dst, R32:$src1, R32:$src2),
825 "cmovae {$src2, $dst|$dst, $src2}",
826 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
829 def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, R32 = [mem32]
830 (ops R32:$dst, R32:$src1, i32mem:$src2),
831 "cmovae {$src2, $dst|$dst, $src2}",
832 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
836 def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, R16 = R16
837 (ops R16:$dst, R16:$src1, R16:$src2),
838 "cmove {$src2, $dst|$dst, $src2}",
839 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
842 def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, R16 = [mem16]
843 (ops R16:$dst, R16:$src1, i16mem:$src2),
844 "cmove {$src2, $dst|$dst, $src2}",
845 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
848 def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, R32 = R32
849 (ops R32:$dst, R32:$src1, R32:$src2),
850 "cmove {$src2, $dst|$dst, $src2}",
851 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
854 def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, R32 = [mem32]
855 (ops R32:$dst, R32:$src1, i32mem:$src2),
856 "cmove {$src2, $dst|$dst, $src2}",
857 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
861 def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, R16 = R16
862 (ops R16:$dst, R16:$src1, R16:$src2),
863 "cmovne {$src2, $dst|$dst, $src2}",
864 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
867 def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, R16 = [mem16]
868 (ops R16:$dst, R16:$src1, i16mem:$src2),
869 "cmovne {$src2, $dst|$dst, $src2}",
870 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
873 def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, R32 = R32
874 (ops R32:$dst, R32:$src1, R32:$src2),
875 "cmovne {$src2, $dst|$dst, $src2}",
876 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
879 def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, R32 = [mem32]
880 (ops R32:$dst, R32:$src1, i32mem:$src2),
881 "cmovne {$src2, $dst|$dst, $src2}",
882 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
886 def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, R16 = R16
887 (ops R16:$dst, R16:$src1, R16:$src2),
888 "cmovbe {$src2, $dst|$dst, $src2}",
889 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
892 def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, R16 = [mem16]
893 (ops R16:$dst, R16:$src1, i16mem:$src2),
894 "cmovbe {$src2, $dst|$dst, $src2}",
895 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
898 def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, R32 = R32
899 (ops R32:$dst, R32:$src1, R32:$src2),
900 "cmovbe {$src2, $dst|$dst, $src2}",
901 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
904 def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, R32 = [mem32]
905 (ops R32:$dst, R32:$src1, i32mem:$src2),
906 "cmovbe {$src2, $dst|$dst, $src2}",
907 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
911 def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, R16 = R16
912 (ops R16:$dst, R16:$src1, R16:$src2),
913 "cmova {$src2, $dst|$dst, $src2}",
914 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
917 def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, R16 = [mem16]
918 (ops R16:$dst, R16:$src1, i16mem:$src2),
919 "cmova {$src2, $dst|$dst, $src2}",
920 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
923 def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, R32 = R32
924 (ops R32:$dst, R32:$src1, R32:$src2),
925 "cmova {$src2, $dst|$dst, $src2}",
926 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
929 def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, R32 = [mem32]
930 (ops R32:$dst, R32:$src1, i32mem:$src2),
931 "cmova {$src2, $dst|$dst, $src2}",
932 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
936 def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, R16 = R16
937 (ops R16:$dst, R16:$src1, R16:$src2),
938 "cmovl {$src2, $dst|$dst, $src2}",
939 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
942 def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, R16 = [mem16]
943 (ops R16:$dst, R16:$src1, i16mem:$src2),
944 "cmovl {$src2, $dst|$dst, $src2}",
945 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
948 def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, R32 = R32
949 (ops R32:$dst, R32:$src1, R32:$src2),
950 "cmovl {$src2, $dst|$dst, $src2}",
951 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
954 def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, R32 = [mem32]
955 (ops R32:$dst, R32:$src1, i32mem:$src2),
956 "cmovl {$src2, $dst|$dst, $src2}",
957 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
961 def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, R16 = R16
962 (ops R16:$dst, R16:$src1, R16:$src2),
963 "cmovge {$src2, $dst|$dst, $src2}",
964 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
967 def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, R16 = [mem16]
968 (ops R16:$dst, R16:$src1, i16mem:$src2),
969 "cmovge {$src2, $dst|$dst, $src2}",
970 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
973 def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, R32 = R32
974 (ops R32:$dst, R32:$src1, R32:$src2),
975 "cmovge {$src2, $dst|$dst, $src2}",
976 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
979 def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, R32 = [mem32]
980 (ops R32:$dst, R32:$src1, i32mem:$src2),
981 "cmovge {$src2, $dst|$dst, $src2}",
982 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
986 def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, R16 = R16
987 (ops R16:$dst, R16:$src1, R16:$src2),
988 "cmovle {$src2, $dst|$dst, $src2}",
989 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
992 def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, R16 = [mem16]
993 (ops R16:$dst, R16:$src1, i16mem:$src2),
994 "cmovle {$src2, $dst|$dst, $src2}",
995 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
998 def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, R32 = R32
999 (ops R32:$dst, R32:$src1, R32:$src2),
1000 "cmovle {$src2, $dst|$dst, $src2}",
1001 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1004 def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, R32 = [mem32]
1005 (ops R32:$dst, R32:$src1, i32mem:$src2),
1006 "cmovle {$src2, $dst|$dst, $src2}",
1007 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1011 def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, R16 = R16
1012 (ops R16:$dst, R16:$src1, R16:$src2),
1013 "cmovg {$src2, $dst|$dst, $src2}",
1014 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1017 def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, R16 = [mem16]
1018 (ops R16:$dst, R16:$src1, i16mem:$src2),
1019 "cmovg {$src2, $dst|$dst, $src2}",
1020 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1023 def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, R32 = R32
1024 (ops R32:$dst, R32:$src1, R32:$src2),
1025 "cmovg {$src2, $dst|$dst, $src2}",
1026 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1029 def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, R32 = [mem32]
1030 (ops R32:$dst, R32:$src1, i32mem:$src2),
1031 "cmovg {$src2, $dst|$dst, $src2}",
1032 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1036 def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, R16 = R16
1037 (ops R16:$dst, R16:$src1, R16:$src2),
1038 "cmovs {$src2, $dst|$dst, $src2}",
1039 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1042 def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, R16 = [mem16]
1043 (ops R16:$dst, R16:$src1, i16mem:$src2),
1044 "cmovs {$src2, $dst|$dst, $src2}",
1045 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1048 def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, R32 = R32
1049 (ops R32:$dst, R32:$src1, R32:$src2),
1050 "cmovs {$src2, $dst|$dst, $src2}",
1051 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1054 def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, R32 = [mem32]
1055 (ops R32:$dst, R32:$src1, i32mem:$src2),
1056 "cmovs {$src2, $dst|$dst, $src2}",
1057 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1061 def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, R16 = R16
1062 (ops R16:$dst, R16:$src1, R16:$src2),
1063 "cmovns {$src2, $dst|$dst, $src2}",
1064 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1067 def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, R16 = [mem16]
1068 (ops R16:$dst, R16:$src1, i16mem:$src2),
1069 "cmovns {$src2, $dst|$dst, $src2}",
1070 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1073 def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, R32 = R32
1074 (ops R32:$dst, R32:$src1, R32:$src2),
1075 "cmovns {$src2, $dst|$dst, $src2}",
1076 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1079 def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, R32 = [mem32]
1080 (ops R32:$dst, R32:$src1, i32mem:$src2),
1081 "cmovns {$src2, $dst|$dst, $src2}",
1082 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1086 def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, R16 = R16
1087 (ops R16:$dst, R16:$src1, R16:$src2),
1088 "cmovp {$src2, $dst|$dst, $src2}",
1089 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1092 def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, R16 = [mem16]
1093 (ops R16:$dst, R16:$src1, i16mem:$src2),
1094 "cmovp {$src2, $dst|$dst, $src2}",
1095 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1098 def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, R32 = R32
1099 (ops R32:$dst, R32:$src1, R32:$src2),
1100 "cmovp {$src2, $dst|$dst, $src2}",
1101 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1104 def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, R32 = [mem32]
1105 (ops R32:$dst, R32:$src1, i32mem:$src2),
1106 "cmovp {$src2, $dst|$dst, $src2}",
1107 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1111 def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, R16 = R16
1112 (ops R16:$dst, R16:$src1, R16:$src2),
1113 "cmovnp {$src2, $dst|$dst, $src2}",
1114 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1117 def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, R16 = [mem16]
1118 (ops R16:$dst, R16:$src1, i16mem:$src2),
1119 "cmovnp {$src2, $dst|$dst, $src2}",
1120 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1123 def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, R32 = R32
1124 (ops R32:$dst, R32:$src1, R32:$src2),
1125 "cmovnp {$src2, $dst|$dst, $src2}",
1126 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1129 def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, R32 = [mem32]
1130 (ops R32:$dst, R32:$src1, i32mem:$src2),
1131 "cmovnp {$src2, $dst|$dst, $src2}",
1132 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1137 // unary instructions
1138 def NEG8r : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg{b} $dst",
1139 [(set R8:$dst, (ineg R8:$src))]>;
1140 def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg{w} $dst",
1141 [(set R16:$dst, (ineg R16:$src))]>, OpSize;
1142 def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg{l} $dst",
1143 [(set R32:$dst, (ineg R32:$src))]>;
1144 let isTwoAddress = 0 in {
1145 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
1146 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
1147 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
1148 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1149 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
1150 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1154 def NOT8r : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not{b} $dst",
1155 [(set R8:$dst, (not R8:$src))]>;
1156 def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not{w} $dst",
1157 [(set R16:$dst, (not R16:$src))]>, OpSize;
1158 def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not{l} $dst",
1159 [(set R32:$dst, (not R32:$src))]>;
1160 let isTwoAddress = 0 in {
1161 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
1162 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
1163 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
1164 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
1165 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
1166 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1169 // TODO: inc/dec is slow for P4, but fast for Pentium-M.
1170 def INC8r : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc{b} $dst",
1171 [(set R8:$dst, (add R8:$src, 1))]>;
1172 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1173 def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc{w} $dst",
1174 [(set R16:$dst, (add R16:$src, 1))]>, OpSize;
1175 def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc{l} $dst",
1176 [(set R32:$dst, (add R32:$src, 1))]>;
1178 let isTwoAddress = 0 in {
1179 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
1180 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
1181 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
1182 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
1183 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
1184 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1187 def DEC8r : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec{b} $dst",
1188 [(set R8:$dst, (add R8:$src, -1))]>;
1189 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1190 def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec{w} $dst",
1191 [(set R16:$dst, (add R16:$src, -1))]>, OpSize;
1192 def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec{l} $dst",
1193 [(set R32:$dst, (add R32:$src, -1))]>;
1196 let isTwoAddress = 0 in {
1197 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
1198 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
1199 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
1200 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
1201 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
1202 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1205 // Logical operators...
1206 let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1207 def AND8rr : I<0x20, MRMDestReg,
1208 (ops R8 :$dst, R8 :$src1, R8 :$src2),
1209 "and{b} {$src2, $dst|$dst, $src2}",
1210 [(set R8:$dst, (and R8:$src1, R8:$src2))]>;
1211 def AND16rr : I<0x21, MRMDestReg,
1212 (ops R16:$dst, R16:$src1, R16:$src2),
1213 "and{w} {$src2, $dst|$dst, $src2}",
1214 [(set R16:$dst, (and R16:$src1, R16:$src2))]>, OpSize;
1215 def AND32rr : I<0x21, MRMDestReg,
1216 (ops R32:$dst, R32:$src1, R32:$src2),
1217 "and{l} {$src2, $dst|$dst, $src2}",
1218 [(set R32:$dst, (and R32:$src1, R32:$src2))]>;
1221 def AND8rm : I<0x22, MRMSrcMem,
1222 (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1223 "and{b} {$src2, $dst|$dst, $src2}",
1224 [(set R8:$dst, (and R8:$src1, (load addr:$src2)))]>;
1225 def AND16rm : I<0x23, MRMSrcMem,
1226 (ops R16:$dst, R16:$src1, i16mem:$src2),
1227 "and{w} {$src2, $dst|$dst, $src2}",
1228 [(set R16:$dst, (and R16:$src1, (load addr:$src2)))]>, OpSize;
1229 def AND32rm : I<0x23, MRMSrcMem,
1230 (ops R32:$dst, R32:$src1, i32mem:$src2),
1231 "and{l} {$src2, $dst|$dst, $src2}",
1232 [(set R32:$dst, (and R32:$src1, (load addr:$src2)))]>;
1234 def AND8ri : Ii8<0x80, MRM4r,
1235 (ops R8 :$dst, R8 :$src1, i8imm :$src2),
1236 "and{b} {$src2, $dst|$dst, $src2}",
1237 [(set R8:$dst, (and R8:$src1, imm:$src2))]>;
1238 def AND16ri : Ii16<0x81, MRM4r,
1239 (ops R16:$dst, R16:$src1, i16imm:$src2),
1240 "and{w} {$src2, $dst|$dst, $src2}",
1241 [(set R16:$dst, (and R16:$src1, imm:$src2))]>, OpSize;
1242 def AND32ri : Ii32<0x81, MRM4r,
1243 (ops R32:$dst, R32:$src1, i32imm:$src2),
1244 "and{l} {$src2, $dst|$dst, $src2}",
1245 [(set R32:$dst, (and R32:$src1, imm:$src2))]>;
1246 def AND16ri8 : Ii8<0x83, MRM4r,
1247 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1248 "and{w} {$src2, $dst|$dst, $src2}",
1249 [(set R16:$dst, (and R16:$src1, i16immSExt8:$src2))]>,
1251 def AND32ri8 : Ii8<0x83, MRM4r,
1252 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1253 "and{l} {$src2, $dst|$dst, $src2}",
1254 [(set R32:$dst, (and R32:$src1, i32immSExt8:$src2))]>;
1256 let isTwoAddress = 0 in {
1257 def AND8mr : I<0x20, MRMDestMem,
1258 (ops i8mem :$dst, R8 :$src),
1259 "and{b} {$src, $dst|$dst, $src}",
1260 [(store (and (load addr:$dst), R8:$src), addr:$dst)]>;
1261 def AND16mr : I<0x21, MRMDestMem,
1262 (ops i16mem:$dst, R16:$src),
1263 "and{w} {$src, $dst|$dst, $src}",
1264 [(store (and (load addr:$dst), R16:$src), addr:$dst)]>,
1266 def AND32mr : I<0x21, MRMDestMem,
1267 (ops i32mem:$dst, R32:$src),
1268 "and{l} {$src, $dst|$dst, $src}",
1269 [(store (and (load addr:$dst), R32:$src), addr:$dst)]>;
1270 def AND8mi : Ii8<0x80, MRM4m,
1271 (ops i8mem :$dst, i8imm :$src),
1272 "and{b} {$src, $dst|$dst, $src}",
1273 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1274 def AND16mi : Ii16<0x81, MRM4m,
1275 (ops i16mem:$dst, i16imm:$src),
1276 "and{w} {$src, $dst|$dst, $src}",
1277 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1279 def AND32mi : Ii32<0x81, MRM4m,
1280 (ops i32mem:$dst, i32imm:$src),
1281 "and{l} {$src, $dst|$dst, $src}",
1282 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1283 def AND16mi8 : Ii8<0x83, MRM4m,
1284 (ops i16mem:$dst, i16i8imm :$src),
1285 "and{w} {$src, $dst|$dst, $src}",
1286 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1288 def AND32mi8 : Ii8<0x83, MRM4m,
1289 (ops i32mem:$dst, i32i8imm :$src),
1290 "and{l} {$src, $dst|$dst, $src}",
1291 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1295 let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
1296 def OR8rr : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1297 "or{b} {$src2, $dst|$dst, $src2}",
1298 [(set R8:$dst, (or R8:$src1, R8:$src2))]>;
1299 def OR16rr : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1300 "or{w} {$src2, $dst|$dst, $src2}",
1301 [(set R16:$dst, (or R16:$src1, R16:$src2))]>, OpSize;
1302 def OR32rr : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1303 "or{l} {$src2, $dst|$dst, $src2}",
1304 [(set R32:$dst, (or R32:$src1, R32:$src2))]>;
1306 def OR8rm : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1307 "or{b} {$src2, $dst|$dst, $src2}",
1308 [(set R8:$dst, (or R8:$src1, (load addr:$src2)))]>;
1309 def OR16rm : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
1310 "or{w} {$src2, $dst|$dst, $src2}",
1311 [(set R16:$dst, (or R16:$src1, (load addr:$src2)))]>, OpSize;
1312 def OR32rm : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
1313 "or{l} {$src2, $dst|$dst, $src2}",
1314 [(set R32:$dst, (or R32:$src1, (load addr:$src2)))]>;
1316 def OR8ri : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1317 "or{b} {$src2, $dst|$dst, $src2}",
1318 [(set R8:$dst, (or R8:$src1, imm:$src2))]>;
1319 def OR16ri : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1320 "or{w} {$src2, $dst|$dst, $src2}",
1321 [(set R16:$dst, (or R16:$src1, imm:$src2))]>, OpSize;
1322 def OR32ri : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1323 "or{l} {$src2, $dst|$dst, $src2}",
1324 [(set R32:$dst, (or R32:$src1, imm:$src2))]>;
1326 def OR16ri8 : Ii8<0x83, MRM1r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1327 "or{w} {$src2, $dst|$dst, $src2}",
1328 [(set R16:$dst, (or R16:$src1, i16immSExt8:$src2))]>, OpSize;
1329 def OR32ri8 : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1330 "or{l} {$src2, $dst|$dst, $src2}",
1331 [(set R32:$dst, (or R32:$src1, i32immSExt8:$src2))]>;
1332 let isTwoAddress = 0 in {
1333 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
1334 "or{b} {$src, $dst|$dst, $src}",
1335 [(store (or (load addr:$dst), R8:$src), addr:$dst)]>;
1336 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
1337 "or{w} {$src, $dst|$dst, $src}",
1338 [(store (or (load addr:$dst), R16:$src), addr:$dst)]>, OpSize;
1339 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
1340 "or{l} {$src, $dst|$dst, $src}",
1341 [(store (or (load addr:$dst), R32:$src), addr:$dst)]>;
1342 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
1343 "or{b} {$src, $dst|$dst, $src}",
1344 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1345 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
1346 "or{w} {$src, $dst|$dst, $src}",
1347 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1349 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
1350 "or{l} {$src, $dst|$dst, $src}",
1351 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1352 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1353 "or{w} {$src, $dst|$dst, $src}",
1354 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1356 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1357 "or{l} {$src, $dst|$dst, $src}",
1358 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1362 let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1363 def XOR8rr : I<0x30, MRMDestReg,
1364 (ops R8 :$dst, R8 :$src1, R8 :$src2),
1365 "xor{b} {$src2, $dst|$dst, $src2}",
1366 [(set R8:$dst, (xor R8:$src1, R8:$src2))]>;
1367 def XOR16rr : I<0x31, MRMDestReg,
1368 (ops R16:$dst, R16:$src1, R16:$src2),
1369 "xor{w} {$src2, $dst|$dst, $src2}",
1370 [(set R16:$dst, (xor R16:$src1, R16:$src2))]>, OpSize;
1371 def XOR32rr : I<0x31, MRMDestReg,
1372 (ops R32:$dst, R32:$src1, R32:$src2),
1373 "xor{l} {$src2, $dst|$dst, $src2}",
1374 [(set R32:$dst, (xor R32:$src1, R32:$src2))]>;
1377 def XOR8rm : I<0x32, MRMSrcMem ,
1378 (ops R8 :$dst, R8:$src1, i8mem :$src2),
1379 "xor{b} {$src2, $dst|$dst, $src2}",
1380 [(set R8:$dst, (xor R8:$src1, (load addr:$src2)))]>;
1381 def XOR16rm : I<0x33, MRMSrcMem ,
1382 (ops R16:$dst, R16:$src1, i16mem:$src2),
1383 "xor{w} {$src2, $dst|$dst, $src2}",
1384 [(set R16:$dst, (xor R16:$src1, (load addr:$src2)))]>, OpSize;
1385 def XOR32rm : I<0x33, MRMSrcMem ,
1386 (ops R32:$dst, R32:$src1, i32mem:$src2),
1387 "xor{l} {$src2, $dst|$dst, $src2}",
1388 [(set R32:$dst, (xor R32:$src1, (load addr:$src2)))]>;
1390 def XOR8ri : Ii8<0x80, MRM6r,
1391 (ops R8:$dst, R8:$src1, i8imm:$src2),
1392 "xor{b} {$src2, $dst|$dst, $src2}",
1393 [(set R8:$dst, (xor R8:$src1, imm:$src2))]>;
1394 def XOR16ri : Ii16<0x81, MRM6r,
1395 (ops R16:$dst, R16:$src1, i16imm:$src2),
1396 "xor{w} {$src2, $dst|$dst, $src2}",
1397 [(set R16:$dst, (xor R16:$src1, imm:$src2))]>, OpSize;
1398 def XOR32ri : Ii32<0x81, MRM6r,
1399 (ops R32:$dst, R32:$src1, i32imm:$src2),
1400 "xor{l} {$src2, $dst|$dst, $src2}",
1401 [(set R32:$dst, (xor R32:$src1, imm:$src2))]>;
1402 def XOR16ri8 : Ii8<0x83, MRM6r,
1403 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1404 "xor{w} {$src2, $dst|$dst, $src2}",
1405 [(set R16:$dst, (xor R16:$src1, i16immSExt8:$src2))]>,
1407 def XOR32ri8 : Ii8<0x83, MRM6r,
1408 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1409 "xor{l} {$src2, $dst|$dst, $src2}",
1410 [(set R32:$dst, (xor R32:$src1, i32immSExt8:$src2))]>;
1411 let isTwoAddress = 0 in {
1412 def XOR8mr : I<0x30, MRMDestMem,
1413 (ops i8mem :$dst, R8 :$src),
1414 "xor{b} {$src, $dst|$dst, $src}",
1415 [(store (xor (load addr:$dst), R8:$src), addr:$dst)]>;
1416 def XOR16mr : I<0x31, MRMDestMem,
1417 (ops i16mem:$dst, R16:$src),
1418 "xor{w} {$src, $dst|$dst, $src}",
1419 [(store (xor (load addr:$dst), R16:$src), addr:$dst)]>,
1421 def XOR32mr : I<0x31, MRMDestMem,
1422 (ops i32mem:$dst, R32:$src),
1423 "xor{l} {$src, $dst|$dst, $src}",
1424 [(store (xor (load addr:$dst), R32:$src), addr:$dst)]>;
1425 def XOR8mi : Ii8<0x80, MRM6m,
1426 (ops i8mem :$dst, i8imm :$src),
1427 "xor{b} {$src, $dst|$dst, $src}",
1428 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1429 def XOR16mi : Ii16<0x81, MRM6m,
1430 (ops i16mem:$dst, i16imm:$src),
1431 "xor{w} {$src, $dst|$dst, $src}",
1432 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1434 def XOR32mi : Ii32<0x81, MRM6m,
1435 (ops i32mem:$dst, i32imm:$src),
1436 "xor{l} {$src, $dst|$dst, $src}",
1437 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1438 def XOR16mi8 : Ii8<0x83, MRM6m,
1439 (ops i16mem:$dst, i16i8imm :$src),
1440 "xor{w} {$src, $dst|$dst, $src}",
1441 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1443 def XOR32mi8 : Ii8<0x83, MRM6m,
1444 (ops i32mem:$dst, i32i8imm :$src),
1445 "xor{l} {$src, $dst|$dst, $src}",
1446 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1449 // Shift instructions
1450 def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
1451 "shl{b} {%cl, $dst|$dst, %CL}",
1452 [(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
1453 def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src),
1454 "shl{w} {%cl, $dst|$dst, %CL}",
1455 [(set R16:$dst, (shl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1456 def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src),
1457 "shl{l} {%cl, $dst|$dst, %CL}",
1458 [(set R32:$dst, (shl R32:$src, CL))]>, Imp<[CL],[]>;
1460 def SHL8ri : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1461 "shl{b} {$src2, $dst|$dst, $src2}",
1462 [(set R8:$dst, (shl R8:$src1, (i8 imm:$src2)))]>;
1463 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1464 def SHL16ri : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1465 "shl{w} {$src2, $dst|$dst, $src2}",
1466 [(set R16:$dst, (shl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1467 def SHL32ri : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1468 "shl{l} {$src2, $dst|$dst, $src2}",
1469 [(set R32:$dst, (shl R32:$src1, (i8 imm:$src2)))]>;
1472 let isTwoAddress = 0 in {
1473 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
1474 "shl{b} {%cl, $dst|$dst, %CL}",
1475 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1477 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
1478 "shl{w} {%cl, $dst|$dst, %CL}",
1479 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1480 Imp<[CL],[]>, OpSize;
1481 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
1482 "shl{l} {%cl, $dst|$dst, %CL}",
1483 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1485 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
1486 "shl{b} {$src, $dst|$dst, $src}",
1487 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1488 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
1489 "shl{w} {$src, $dst|$dst, $src}",
1490 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1492 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
1493 "shl{l} {$src, $dst|$dst, $src}",
1494 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1497 def SHR8rCL : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src),
1498 "shr{b} {%cl, $dst|$dst, %CL}",
1499 [(set R8:$dst, (srl R8:$src, CL))]>, Imp<[CL],[]>;
1500 def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src),
1501 "shr{w} {%cl, $dst|$dst, %CL}",
1502 [(set R16:$dst, (srl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1503 def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src),
1504 "shr{l} {%cl, $dst|$dst, %CL}",
1505 [(set R32:$dst, (srl R32:$src, CL))]>, Imp<[CL],[]>;
1507 def SHR8ri : Ii8<0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1508 "shr{b} {$src2, $dst|$dst, $src2}",
1509 [(set R8:$dst, (srl R8:$src1, (i8 imm:$src2)))]>;
1510 def SHR16ri : Ii8<0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1511 "shr{w} {$src2, $dst|$dst, $src2}",
1512 [(set R16:$dst, (srl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1513 def SHR32ri : Ii8<0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1514 "shr{l} {$src2, $dst|$dst, $src2}",
1515 [(set R32:$dst, (srl R32:$src1, (i8 imm:$src2)))]>;
1517 let isTwoAddress = 0 in {
1518 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
1519 "shr{b} {%cl, $dst|$dst, %CL}",
1520 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1522 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
1523 "shr{w} {%cl, $dst|$dst, %CL}",
1524 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1525 Imp<[CL],[]>, OpSize;
1526 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
1527 "shr{l} {%cl, $dst|$dst, %CL}",
1528 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1530 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
1531 "shr{b} {$src, $dst|$dst, $src}",
1532 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1533 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
1534 "shr{w} {$src, $dst|$dst, $src}",
1535 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1537 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
1538 "shr{l} {$src, $dst|$dst, $src}",
1539 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1542 def SAR8rCL : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src),
1543 "sar{b} {%cl, $dst|$dst, %CL}",
1544 [(set R8:$dst, (sra R8:$src, CL))]>, Imp<[CL],[]>;
1545 def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src),
1546 "sar{w} {%cl, $dst|$dst, %CL}",
1547 [(set R16:$dst, (sra R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1548 def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src),
1549 "sar{l} {%cl, $dst|$dst, %CL}",
1550 [(set R32:$dst, (sra R32:$src, CL))]>, Imp<[CL],[]>;
1552 def SAR8ri : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1553 "sar{b} {$src2, $dst|$dst, $src2}",
1554 [(set R8:$dst, (sra R8:$src1, (i8 imm:$src2)))]>;
1555 def SAR16ri : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1556 "sar{w} {$src2, $dst|$dst, $src2}",
1557 [(set R16:$dst, (sra R16:$src1, (i8 imm:$src2)))]>,
1559 def SAR32ri : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1560 "sar{l} {$src2, $dst|$dst, $src2}",
1561 [(set R32:$dst, (sra R32:$src1, (i8 imm:$src2)))]>;
1562 let isTwoAddress = 0 in {
1563 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
1564 "sar{b} {%cl, $dst|$dst, %CL}",
1565 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1567 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
1568 "sar{w} {%cl, $dst|$dst, %CL}",
1569 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1570 Imp<[CL],[]>, OpSize;
1571 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
1572 "sar{l} {%cl, $dst|$dst, %CL}",
1573 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1575 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
1576 "sar{b} {$src, $dst|$dst, $src}",
1577 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1578 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
1579 "sar{w} {$src, $dst|$dst, $src}",
1580 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1582 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
1583 "sar{l} {$src, $dst|$dst, $src}",
1584 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1587 // Rotate instructions
1588 // FIXME: provide shorter instructions when imm8 == 1
1589 def ROL8rCL : I<0xD2, MRM0r, (ops R8 :$dst, R8 :$src),
1590 "rol{b} {%cl, $dst|$dst, %CL}",
1591 [(set R8:$dst, (rotl R8:$src, CL))]>, Imp<[CL],[]>;
1592 def ROL16rCL : I<0xD3, MRM0r, (ops R16:$dst, R16:$src),
1593 "rol{w} {%cl, $dst|$dst, %CL}",
1594 [(set R16:$dst, (rotl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1595 def ROL32rCL : I<0xD3, MRM0r, (ops R32:$dst, R32:$src),
1596 "rol{l} {%cl, $dst|$dst, %CL}",
1597 [(set R32:$dst, (rotl R32:$src, CL))]>, Imp<[CL],[]>;
1599 def ROL8ri : Ii8<0xC0, MRM0r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1600 "rol{b} {$src2, $dst|$dst, $src2}",
1601 [(set R8:$dst, (rotl R8:$src1, (i8 imm:$src2)))]>;
1602 def ROL16ri : Ii8<0xC1, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1603 "rol{w} {$src2, $dst|$dst, $src2}",
1604 [(set R16:$dst, (rotl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1605 def ROL32ri : Ii8<0xC1, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1606 "rol{l} {$src2, $dst|$dst, $src2}",
1607 [(set R32:$dst, (rotl R32:$src1, (i8 imm:$src2)))]>;
1609 let isTwoAddress = 0 in {
1610 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
1611 "rol{b} {%cl, $dst|$dst, %CL}",
1612 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1614 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
1615 "rol{w} {%cl, $dst|$dst, %CL}",
1616 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1617 Imp<[CL],[]>, OpSize;
1618 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
1619 "rol{l} {%cl, $dst|$dst, %CL}",
1620 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1622 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
1623 "rol{b} {$src, $dst|$dst, $src}",
1624 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1625 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
1626 "rol{w} {$src, $dst|$dst, $src}",
1627 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1629 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
1630 "rol{l} {$src, $dst|$dst, $src}",
1631 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1634 def ROR8rCL : I<0xD2, MRM1r, (ops R8 :$dst, R8 :$src),
1635 "ror{b} {%cl, $dst|$dst, %CL}",
1636 [(set R8:$dst, (rotr R8:$src, CL))]>, Imp<[CL],[]>;
1637 def ROR16rCL : I<0xD3, MRM1r, (ops R16:$dst, R16:$src),
1638 "ror{w} {%cl, $dst|$dst, %CL}",
1639 [(set R16:$dst, (rotr R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1640 def ROR32rCL : I<0xD3, MRM1r, (ops R32:$dst, R32:$src),
1641 "ror{l} {%cl, $dst|$dst, %CL}",
1642 [(set R32:$dst, (rotr R32:$src, CL))]>, Imp<[CL],[]>;
1644 def ROR8ri : Ii8<0xC0, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
1645 "ror{b} {$src2, $dst|$dst, $src2}",
1646 [(set R8:$dst, (rotr R8:$src1, (i8 imm:$src2)))]>;
1647 def ROR16ri : Ii8<0xC1, MRM1r, (ops R16:$dst, R16:$src1, i8imm:$src2),
1648 "ror{w} {$src2, $dst|$dst, $src2}",
1649 [(set R16:$dst, (rotr R16:$src1, (i8 imm:$src2)))]>, OpSize;
1650 def ROR32ri : Ii8<0xC1, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
1651 "ror{l} {$src2, $dst|$dst, $src2}",
1652 [(set R32:$dst, (rotr R32:$src1, (i8 imm:$src2)))]>;
1653 let isTwoAddress = 0 in {
1654 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
1655 "ror{b} {%cl, $dst|$dst, %CL}",
1656 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1658 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
1659 "ror{w} {%cl, $dst|$dst, %CL}",
1660 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1661 Imp<[CL],[]>, OpSize;
1662 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
1663 "ror{l} {%cl, $dst|$dst, %CL}",
1664 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1666 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
1667 "ror{b} {$src, $dst|$dst, $src}",
1668 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1669 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
1670 "ror{w} {$src, $dst|$dst, $src}",
1671 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1673 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
1674 "ror{l} {$src, $dst|$dst, $src}",
1675 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1680 // Double shift instructions (generalizations of rotate)
1682 def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1683 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1684 [(set R32:$dst, (X86shld R32:$src1, R32:$src2, CL))]>,
1686 def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1687 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1688 [(set R32:$dst, (X86shrd R32:$src1, R32:$src2, CL))]>,
1690 def SHLD16rrCL : I<0xA5, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1691 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1692 [(set R16:$dst, (X86shld R16:$src1, R16:$src2, CL))]>,
1693 Imp<[CL],[]>, TB, OpSize;
1694 def SHRD16rrCL : I<0xAD, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1695 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1696 [(set R16:$dst, (X86shrd R16:$src1, R16:$src2, CL))]>,
1697 Imp<[CL],[]>, TB, OpSize;
1699 let isCommutable = 1 in { // These instructions commute to each other.
1700 def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1701 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
1702 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1703 [(set R32:$dst, (X86shld R32:$src1, R32:$src2,
1706 def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1707 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
1708 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1709 [(set R32:$dst, (X86shrd R32:$src1, R32:$src2,
1712 def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1713 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
1714 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1715 [(set R16:$dst, (X86shld R16:$src1, R16:$src2,
1718 def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1719 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
1720 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1721 [(set R16:$dst, (X86shrd R16:$src1, R16:$src2,
1726 let isTwoAddress = 0 in {
1727 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1728 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1729 [(store (X86shld (loadi32 addr:$dst), R32:$src2, CL),
1732 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1733 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1734 [(store (X86shrd (loadi32 addr:$dst), R32:$src2, CL),
1737 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1738 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
1739 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1740 [(store (X86shld (loadi32 addr:$dst), R32:$src2,
1741 (i8 imm:$src3)), addr:$dst)]>,
1743 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1744 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
1745 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1746 [(store (X86shrd (loadi32 addr:$dst), R32:$src2,
1747 (i8 imm:$src3)), addr:$dst)]>,
1750 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1751 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1752 [(store (X86shld (loadi16 addr:$dst), R16:$src2, CL),
1754 Imp<[CL],[]>, TB, OpSize;
1755 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1756 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1757 [(store (X86shrd (loadi16 addr:$dst), R16:$src2, CL),
1759 Imp<[CL],[]>, TB, OpSize;
1760 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1761 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
1762 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1763 [(store (X86shld (loadi16 addr:$dst), R16:$src2,
1764 (i8 imm:$src3)), addr:$dst)]>,
1766 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1767 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
1768 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1769 [(store (X86shrd (loadi16 addr:$dst), R16:$src2,
1770 (i8 imm:$src3)), addr:$dst)]>,
1776 let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
1777 def ADD8rr : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1778 "add{b} {$src2, $dst|$dst, $src2}",
1779 [(set R8:$dst, (add R8:$src1, R8:$src2))]>;
1780 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1781 def ADD16rr : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1782 "add{w} {$src2, $dst|$dst, $src2}",
1783 [(set R16:$dst, (add R16:$src1, R16:$src2))]>, OpSize;
1784 def ADD32rr : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1785 "add{l} {$src2, $dst|$dst, $src2}",
1786 [(set R32:$dst, (add R32:$src1, R32:$src2))]>;
1787 } // end isConvertibleToThreeAddress
1788 } // end isCommutable
1789 def ADD8rm : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1790 "add{b} {$src2, $dst|$dst, $src2}",
1791 [(set R8:$dst, (add R8:$src1, (load addr:$src2)))]>;
1792 def ADD16rm : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1793 "add{w} {$src2, $dst|$dst, $src2}",
1794 [(set R16:$dst, (add R16:$src1, (load addr:$src2)))]>, OpSize;
1795 def ADD32rm : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1796 "add{l} {$src2, $dst|$dst, $src2}",
1797 [(set R32:$dst, (add R32:$src1, (load addr:$src2)))]>;
1799 def ADD8ri : Ii8<0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1800 "add{b} {$src2, $dst|$dst, $src2}",
1801 [(set R8:$dst, (add R8:$src1, imm:$src2))]>;
1803 let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
1804 def ADD16ri : Ii16<0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1805 "add{w} {$src2, $dst|$dst, $src2}",
1806 [(set R16:$dst, (add R16:$src1, imm:$src2))]>, OpSize;
1807 def ADD32ri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1808 "add{l} {$src2, $dst|$dst, $src2}",
1809 [(set R32:$dst, (add R32:$src1, imm:$src2))]>;
1812 // FIXME: move ADD16ri8 above ADD16ri to optimize for space.
1813 def ADD16ri8 : Ii8<0x83, MRM0r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1814 "add{w} {$src2, $dst|$dst, $src2}",
1815 [(set R16:$dst, (add R16:$src1, i16immSExt8:$src2))]>,
1817 def ADD32ri8 : Ii8<0x83, MRM0r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1818 "add{l} {$src2, $dst|$dst, $src2}",
1819 [(set R32:$dst, (add R32:$src1, i32immSExt8:$src2))]>;
1821 let isTwoAddress = 0 in {
1822 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
1823 "add{b} {$src2, $dst|$dst, $src2}",
1824 [(store (add (load addr:$dst), R8:$src2), addr:$dst)]>;
1825 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1826 "add{w} {$src2, $dst|$dst, $src2}",
1827 [(store (add (load addr:$dst), R16:$src2), addr:$dst)]>,
1829 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1830 "add{l} {$src2, $dst|$dst, $src2}",
1831 [(store (add (load addr:$dst), R32:$src2), addr:$dst)]>;
1832 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
1833 "add{b} {$src2, $dst|$dst, $src2}",
1834 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1835 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
1836 "add{w} {$src2, $dst|$dst, $src2}",
1837 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1839 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
1840 "add{l} {$src2, $dst|$dst, $src2}",
1841 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1842 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1843 "add{w} {$src2, $dst|$dst, $src2}",
1844 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1846 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1847 "add{l} {$src2, $dst|$dst, $src2}",
1848 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1851 let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
1852 def ADC32rr : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1853 "adc{l} {$src2, $dst|$dst, $src2}",
1854 [(set R32:$dst, (X86adc R32:$src1, R32:$src2))]>;
1856 def ADC32rm : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
1857 "adc{l} {$src2, $dst|$dst, $src2}",
1858 [(set R32:$dst, (X86adc R32:$src1, (load addr:$src2)))]>;
1859 def ADC32ri : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1860 "adc{l} {$src2, $dst|$dst, $src2}",
1861 [(set R32:$dst, (X86adc R32:$src1, imm:$src2))]>;
1862 def ADC32ri8 : Ii8<0x83, MRM2r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1863 "adc{l} {$src2, $dst|$dst, $src2}",
1864 [(set R32:$dst, (X86adc R32:$src1, i32immSExt8:$src2))]>;
1866 let isTwoAddress = 0 in {
1867 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1868 "adc{l} {$src2, $dst|$dst, $src2}",
1869 [(store (X86adc (load addr:$dst), R32:$src2), addr:$dst)]>;
1870 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
1871 "adc{l} {$src2, $dst|$dst, $src2}",
1872 [(store (X86adc (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1873 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1874 "adc{l} {$src2, $dst|$dst, $src2}",
1875 [(store (X86adc (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1878 def SUB8rr : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
1879 "sub{b} {$src2, $dst|$dst, $src2}",
1880 [(set R8:$dst, (sub R8:$src1, R8:$src2))]>;
1881 def SUB16rr : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
1882 "sub{w} {$src2, $dst|$dst, $src2}",
1883 [(set R16:$dst, (sub R16:$src1, R16:$src2))]>, OpSize;
1884 def SUB32rr : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1885 "sub{l} {$src2, $dst|$dst, $src2}",
1886 [(set R32:$dst, (sub R32:$src1, R32:$src2))]>;
1887 def SUB8rm : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
1888 "sub{b} {$src2, $dst|$dst, $src2}",
1889 [(set R8:$dst, (sub R8:$src1, (load addr:$src2)))]>;
1890 def SUB16rm : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
1891 "sub{w} {$src2, $dst|$dst, $src2}",
1892 [(set R16:$dst, (sub R16:$src1, (load addr:$src2)))]>, OpSize;
1893 def SUB32rm : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1894 "sub{l} {$src2, $dst|$dst, $src2}",
1895 [(set R32:$dst, (sub R32:$src1, (load addr:$src2)))]>;
1897 def SUB8ri : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1898 "sub{b} {$src2, $dst|$dst, $src2}",
1899 [(set R8:$dst, (sub R8:$src1, imm:$src2))]>;
1900 def SUB16ri : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1901 "sub{w} {$src2, $dst|$dst, $src2}",
1902 [(set R16:$dst, (sub R16:$src1, imm:$src2))]>, OpSize;
1903 def SUB32ri : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1904 "sub{l} {$src2, $dst|$dst, $src2}",
1905 [(set R32:$dst, (sub R32:$src1, imm:$src2))]>;
1906 def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1907 "sub{w} {$src2, $dst|$dst, $src2}",
1908 [(set R16:$dst, (sub R16:$src1, i16immSExt8:$src2))]>,
1910 def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1911 "sub{l} {$src2, $dst|$dst, $src2}",
1912 [(set R32:$dst, (sub R32:$src1, i32immSExt8:$src2))]>;
1913 let isTwoAddress = 0 in {
1914 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
1915 "sub{b} {$src2, $dst|$dst, $src2}",
1916 [(store (sub (load addr:$dst), R8:$src2), addr:$dst)]>;
1917 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2),
1918 "sub{w} {$src2, $dst|$dst, $src2}",
1919 [(store (sub (load addr:$dst), R16:$src2), addr:$dst)]>,
1921 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1922 "sub{l} {$src2, $dst|$dst, $src2}",
1923 [(store (sub (load addr:$dst), R32:$src2), addr:$dst)]>;
1924 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
1925 "sub{b} {$src2, $dst|$dst, $src2}",
1926 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1927 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
1928 "sub{w} {$src2, $dst|$dst, $src2}",
1929 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1931 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
1932 "sub{l} {$src2, $dst|$dst, $src2}",
1933 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1934 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1935 "sub{w} {$src2, $dst|$dst, $src2}",
1936 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1938 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1939 "sub{l} {$src2, $dst|$dst, $src2}",
1940 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1943 def SBB32rr : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
1944 "sbb{l} {$src2, $dst|$dst, $src2}",
1945 [(set R32:$dst, (X86sbb R32:$src1, R32:$src2))]>;
1947 let isTwoAddress = 0 in {
1948 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2),
1949 "sbb{l} {$src2, $dst|$dst, $src2}",
1950 [(store (X86sbb (load addr:$dst), R32:$src2), addr:$dst)]>;
1951 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
1952 "sbb{b} {$src2, $dst|$dst, $src2}",
1953 [(store (X86sbb (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
1954 def SBB16mi : Ii32<0x81, MRM3m, (ops i16mem:$dst, i16imm:$src2),
1955 "sbb{w} {$src2, $dst|$dst, $src2}",
1956 [(store (X86sbb (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1958 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
1959 "sbb{l} {$src2, $dst|$dst, $src2}",
1960 [(store (X86sbb (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1961 def SBB16mi8 : Ii8<0x83, MRM3m, (ops i16mem:$dst, i16i8imm :$src2),
1962 "sbb{w} {$src2, $dst|$dst, $src2}",
1963 [(store (X86sbb (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1965 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
1966 "sbb{l} {$src2, $dst|$dst, $src2}",
1967 [(store (X86sbb (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1969 def SBB8ri : Ii8<0x80, MRM3r, (ops R8:$dst, R8:$src1, i8imm:$src2),
1970 "sbb{b} {$src2, $dst|$dst, $src2}",
1971 [(set R8:$dst, (X86sbb R8:$src1, imm:$src2))]>;
1972 def SBB16ri : Ii16<0x81, MRM3r, (ops R16:$dst, R16:$src1, i16imm:$src2),
1973 "sbb{w} {$src2, $dst|$dst, $src2}",
1974 [(set R16:$dst, (X86sbb R16:$src1, imm:$src2))]>, OpSize;
1976 def SBB32rm : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
1977 "sbb{l} {$src2, $dst|$dst, $src2}",
1978 [(set R32:$dst, (X86sbb R32:$src1, (load addr:$src2)))]>;
1979 def SBB32ri : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
1980 "sbb{l} {$src2, $dst|$dst, $src2}",
1981 [(set R32:$dst, (X86sbb R32:$src1, imm:$src2))]>;
1983 def SBB16ri8 : Ii8<0x83, MRM3r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1984 "sbb{w} {$src2, $dst|$dst, $src2}",
1985 [(set R16:$dst, (X86sbb R16:$src1, i16immSExt8:$src2))]>,
1987 def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1988 "sbb{l} {$src2, $dst|$dst, $src2}",
1989 [(set R32:$dst, (X86sbb R32:$src1, i32immSExt8:$src2))]>;
1991 let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
1992 def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
1993 "imul{w} {$src2, $dst|$dst, $src2}",
1994 [(set R16:$dst, (mul R16:$src1, R16:$src2))]>, TB, OpSize;
1995 def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
1996 "imul{l} {$src2, $dst|$dst, $src2}",
1997 [(set R32:$dst, (mul R32:$src1, R32:$src2))]>, TB;
1999 def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
2000 "imul{w} {$src2, $dst|$dst, $src2}",
2001 [(set R16:$dst, (mul R16:$src1, (load addr:$src2)))]>,
2003 def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
2004 "imul{l} {$src2, $dst|$dst, $src2}",
2005 [(set R32:$dst, (mul R32:$src1, (load addr:$src2)))]>, TB;
2007 } // end Two Address instructions
2009 // Suprisingly enough, these are not two address instructions!
2010 def IMUL16rri : Ii16<0x69, MRMSrcReg, // R16 = R16*I16
2011 (ops R16:$dst, R16:$src1, i16imm:$src2),
2012 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2013 [(set R16:$dst, (mul R16:$src1, imm:$src2))]>, OpSize;
2014 def IMUL32rri : Ii32<0x69, MRMSrcReg, // R32 = R32*I32
2015 (ops R32:$dst, R32:$src1, i32imm:$src2),
2016 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2017 [(set R32:$dst, (mul R32:$src1, imm:$src2))]>;
2018 def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // R16 = R16*I8
2019 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
2020 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2021 [(set R16:$dst, (mul R16:$src1, i16immSExt8:$src2))]>,
2023 def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // R32 = R32*I8
2024 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
2025 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2026 [(set R32:$dst, (mul R32:$src1, i32immSExt8:$src2))]>;
2028 def IMUL16rmi : Ii16<0x69, MRMSrcMem, // R16 = [mem16]*I16
2029 (ops R16:$dst, i16mem:$src1, i16imm:$src2),
2030 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2031 [(set R16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2033 def IMUL32rmi : Ii32<0x69, MRMSrcMem, // R32 = [mem32]*I32
2034 (ops R32:$dst, i32mem:$src1, i32imm:$src2),
2035 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2036 [(set R32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2037 def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // R16 = [mem16]*I8
2038 (ops R16:$dst, i16mem:$src1, i16i8imm :$src2),
2039 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2040 [(set R16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2042 def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // R32 = [mem32]*I8
2043 (ops R32:$dst, i32mem:$src1, i32i8imm: $src2),
2044 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2045 [(set R32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
2047 //===----------------------------------------------------------------------===//
2048 // Test instructions are just like AND, except they don't generate a result.
2050 let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
2051 def TEST8rr : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
2052 "test{b} {$src2, $src1|$src1, $src2}",
2053 [(X86test R8:$src1, R8:$src2)]>;
2054 def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
2055 "test{w} {$src2, $src1|$src1, $src2}",
2056 [(X86test R16:$src1, R16:$src2)]>, OpSize;
2057 def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
2058 "test{l} {$src2, $src1|$src1, $src2}",
2059 [(X86test R32:$src1, R32:$src2)]>;
2061 def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
2062 "test{b} {$src2, $src1|$src1, $src2}",
2063 [(X86test (loadi8 addr:$src1), R8:$src2)]>;
2064 def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
2065 "test{w} {$src2, $src1|$src1, $src2}",
2066 [(X86test (loadi16 addr:$src1), R16:$src2)]>,
2068 def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
2069 "test{l} {$src2, $src1|$src1, $src2}",
2070 [(X86test (loadi32 addr:$src1), R32:$src2)]>;
2071 def TEST8rm : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
2072 "test{b} {$src2, $src1|$src1, $src2}",
2073 [(X86test R8:$src1, (loadi8 addr:$src2))]>;
2074 def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
2075 "test{w} {$src2, $src1|$src1, $src2}",
2076 [(X86test R16:$src1, (loadi16 addr:$src2))]>,
2078 def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
2079 "test{l} {$src2, $src1|$src1, $src2}",
2080 [(X86test R32:$src1, (loadi32 addr:$src2))]>;
2082 def TEST8ri : Ii8 <0xF6, MRM0r, // flags = R8 & imm8
2083 (ops R8:$src1, i8imm:$src2),
2084 "test{b} {$src2, $src1|$src1, $src2}",
2085 [(X86test R8:$src1, imm:$src2)]>;
2086 def TEST16ri : Ii16<0xF7, MRM0r, // flags = R16 & imm16
2087 (ops R16:$src1, i16imm:$src2),
2088 "test{w} {$src2, $src1|$src1, $src2}",
2089 [(X86test R16:$src1, imm:$src2)]>, OpSize;
2090 def TEST32ri : Ii32<0xF7, MRM0r, // flags = R32 & imm32
2091 (ops R32:$src1, i32imm:$src2),
2092 "test{l} {$src2, $src1|$src1, $src2}",
2093 [(X86test R32:$src1, imm:$src2)]>;
2094 def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
2095 (ops i8mem:$src1, i8imm:$src2),
2096 "test{b} {$src2, $src1|$src1, $src2}",
2097 [(X86test (loadi8 addr:$src1), imm:$src2)]>;
2098 def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2099 (ops i16mem:$src1, i16imm:$src2),
2100 "test{w} {$src2, $src1|$src1, $src2}",
2101 [(X86test (loadi16 addr:$src1), imm:$src2)]>,
2103 def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2104 (ops i32mem:$src1, i32imm:$src2),
2105 "test{l} {$src2, $src1|$src1, $src2}",
2106 [(X86test (loadi32 addr:$src1), imm:$src2)]>;
2109 // Condition code ops, incl. set if equal/not equal/...
2110 def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2111 def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
2113 def SETEr : I<0x94, MRM0r,
2116 [(set R8:$dst, (X86setcc X86_COND_E))]>,
2118 def SETEm : I<0x94, MRM0m,
2121 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2123 def SETNEr : I<0x95, MRM0r,
2126 [(set R8:$dst, (X86setcc X86_COND_NE))]>,
2128 def SETNEm : I<0x95, MRM0m,
2131 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2133 def SETLr : I<0x9C, MRM0r,
2136 [(set R8:$dst, (X86setcc X86_COND_L))]>,
2137 TB; // R8 = < signed
2138 def SETLm : I<0x9C, MRM0m,
2141 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2142 TB; // [mem8] = < signed
2143 def SETGEr : I<0x9D, MRM0r,
2146 [(set R8:$dst, (X86setcc X86_COND_GE))]>,
2147 TB; // R8 = >= signed
2148 def SETGEm : I<0x9D, MRM0m,
2151 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2152 TB; // [mem8] = >= signed
2153 def SETLEr : I<0x9E, MRM0r,
2156 [(set R8:$dst, (X86setcc X86_COND_LE))]>,
2157 TB; // R8 = <= signed
2158 def SETLEm : I<0x9E, MRM0m,
2161 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2162 TB; // [mem8] = <= signed
2163 def SETGr : I<0x9F, MRM0r,
2166 [(set R8:$dst, (X86setcc X86_COND_G))]>,
2167 TB; // R8 = > signed
2168 def SETGm : I<0x9F, MRM0m,
2171 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2172 TB; // [mem8] = > signed
2174 def SETBr : I<0x92, MRM0r,
2177 [(set R8:$dst, (X86setcc X86_COND_B))]>,
2178 TB; // R8 = < unsign
2179 def SETBm : I<0x92, MRM0m,
2182 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2183 TB; // [mem8] = < unsign
2184 def SETAEr : I<0x93, MRM0r,
2187 [(set R8:$dst, (X86setcc X86_COND_AE))]>,
2188 TB; // R8 = >= unsign
2189 def SETAEm : I<0x93, MRM0m,
2192 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2193 TB; // [mem8] = >= unsign
2194 def SETBEr : I<0x96, MRM0r,
2197 [(set R8:$dst, (X86setcc X86_COND_BE))]>,
2198 TB; // R8 = <= unsign
2199 def SETBEm : I<0x96, MRM0m,
2202 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2203 TB; // [mem8] = <= unsign
2204 def SETAr : I<0x97, MRM0r,
2207 [(set R8:$dst, (X86setcc X86_COND_A))]>,
2208 TB; // R8 = > signed
2209 def SETAm : I<0x97, MRM0m,
2212 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2213 TB; // [mem8] = > signed
2215 def SETSr : I<0x98, MRM0r,
2218 [(set R8:$dst, (X86setcc X86_COND_S))]>,
2219 TB; // R8 = <sign bit>
2220 def SETSm : I<0x98, MRM0m,
2223 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2224 TB; // [mem8] = <sign bit>
2225 def SETNSr : I<0x99, MRM0r,
2228 [(set R8:$dst, (X86setcc X86_COND_NS))]>,
2229 TB; // R8 = !<sign bit>
2230 def SETNSm : I<0x99, MRM0m,
2233 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2234 TB; // [mem8] = !<sign bit>
2235 def SETPr : I<0x9A, MRM0r,
2238 [(set R8:$dst, (X86setcc X86_COND_P))]>,
2240 def SETPm : I<0x9A, MRM0m,
2243 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2244 TB; // [mem8] = parity
2245 def SETNPr : I<0x9B, MRM0r,
2248 [(set R8:$dst, (X86setcc X86_COND_NP))]>,
2249 TB; // R8 = not parity
2250 def SETNPm : I<0x9B, MRM0m,
2253 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2254 TB; // [mem8] = not parity
2256 // Integer comparisons
2257 def CMP8rr : I<0x38, MRMDestReg,
2258 (ops R8 :$src1, R8 :$src2),
2259 "cmp{b} {$src2, $src1|$src1, $src2}",
2260 [(X86cmp R8:$src1, R8:$src2)]>;
2261 def CMP16rr : I<0x39, MRMDestReg,
2262 (ops R16:$src1, R16:$src2),
2263 "cmp{w} {$src2, $src1|$src1, $src2}",
2264 [(X86cmp R16:$src1, R16:$src2)]>, OpSize;
2265 def CMP32rr : I<0x39, MRMDestReg,
2266 (ops R32:$src1, R32:$src2),
2267 "cmp{l} {$src2, $src1|$src1, $src2}",
2268 [(X86cmp R32:$src1, R32:$src2)]>;
2269 def CMP8mr : I<0x38, MRMDestMem,
2270 (ops i8mem :$src1, R8 :$src2),
2271 "cmp{b} {$src2, $src1|$src1, $src2}",
2272 [(X86cmp (loadi8 addr:$src1), R8:$src2)]>;
2273 def CMP16mr : I<0x39, MRMDestMem,
2274 (ops i16mem:$src1, R16:$src2),
2275 "cmp{w} {$src2, $src1|$src1, $src2}",
2276 [(X86cmp (loadi16 addr:$src1), R16:$src2)]>, OpSize;
2277 def CMP32mr : I<0x39, MRMDestMem,
2278 (ops i32mem:$src1, R32:$src2),
2279 "cmp{l} {$src2, $src1|$src1, $src2}",
2280 [(X86cmp (loadi32 addr:$src1), R32:$src2)]>;
2281 def CMP8rm : I<0x3A, MRMSrcMem,
2282 (ops R8 :$src1, i8mem :$src2),
2283 "cmp{b} {$src2, $src1|$src1, $src2}",
2284 [(X86cmp R8:$src1, (loadi8 addr:$src2))]>;
2285 def CMP16rm : I<0x3B, MRMSrcMem,
2286 (ops R16:$src1, i16mem:$src2),
2287 "cmp{w} {$src2, $src1|$src1, $src2}",
2288 [(X86cmp R16:$src1, (loadi16 addr:$src2))]>, OpSize;
2289 def CMP32rm : I<0x3B, MRMSrcMem,
2290 (ops R32:$src1, i32mem:$src2),
2291 "cmp{l} {$src2, $src1|$src1, $src2}",
2292 [(X86cmp R32:$src1, (loadi32 addr:$src2))]>;
2293 def CMP8ri : Ii8<0x80, MRM7r,
2294 (ops R8:$src1, i8imm:$src2),
2295 "cmp{b} {$src2, $src1|$src1, $src2}",
2296 [(X86cmp R8:$src1, imm:$src2)]>;
2297 def CMP16ri : Ii16<0x81, MRM7r,
2298 (ops R16:$src1, i16imm:$src2),
2299 "cmp{w} {$src2, $src1|$src1, $src2}",
2300 [(X86cmp R16:$src1, imm:$src2)]>, OpSize;
2301 def CMP32ri : Ii32<0x81, MRM7r,
2302 (ops R32:$src1, i32imm:$src2),
2303 "cmp{l} {$src2, $src1|$src1, $src2}",
2304 [(X86cmp R32:$src1, imm:$src2)]>;
2305 def CMP8mi : Ii8 <0x80, MRM7m,
2306 (ops i8mem :$src1, i8imm :$src2),
2307 "cmp{b} {$src2, $src1|$src1, $src2}",
2308 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2309 def CMP16mi : Ii16<0x81, MRM7m,
2310 (ops i16mem:$src1, i16imm:$src2),
2311 "cmp{w} {$src2, $src1|$src1, $src2}",
2312 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2313 def CMP32mi : Ii32<0x81, MRM7m,
2314 (ops i32mem:$src1, i32imm:$src2),
2315 "cmp{l} {$src2, $src1|$src1, $src2}",
2316 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2318 // Sign/Zero extenders
2319 def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src),
2320 "movs{bw|x} {$src, $dst|$dst, $src}",
2321 [(set R16:$dst, (sext R8:$src))]>, TB, OpSize;
2322 def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src),
2323 "movs{bw|x} {$src, $dst|$dst, $src}",
2324 [(set R16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2325 def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src),
2326 "movs{bl|x} {$src, $dst|$dst, $src}",
2327 [(set R32:$dst, (sext R8:$src))]>, TB;
2328 def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src),
2329 "movs{bl|x} {$src, $dst|$dst, $src}",
2330 [(set R32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2331 def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src),
2332 "movs{wl|x} {$src, $dst|$dst, $src}",
2333 [(set R32:$dst, (sext R16:$src))]>, TB;
2334 def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src),
2335 "movs{wl|x} {$src, $dst|$dst, $src}",
2336 [(set R32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2338 def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src),
2339 "movz{bw|x} {$src, $dst|$dst, $src}",
2340 [(set R16:$dst, (zext R8:$src))]>, TB, OpSize;
2341 def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src),
2342 "movz{bw|x} {$src, $dst|$dst, $src}",
2343 [(set R16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2344 def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src),
2345 "movz{bl|x} {$src, $dst|$dst, $src}",
2346 [(set R32:$dst, (zext R8:$src))]>, TB;
2347 def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src),
2348 "movz{bl|x} {$src, $dst|$dst, $src}",
2349 [(set R32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2350 def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src),
2351 "movz{wl|x} {$src, $dst|$dst, $src}",
2352 [(set R32:$dst, (zext R16:$src))]>, TB;
2353 def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src),
2354 "movz{wl|x} {$src, $dst|$dst, $src}",
2355 [(set R32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2357 //===----------------------------------------------------------------------===//
2358 // XMM Floating point support (requires SSE / SSE2)
2359 //===----------------------------------------------------------------------===//
2361 def MOVSSrr : I<0x10, MRMSrcReg, (ops FR32:$dst, FR32:$src),
2362 "movss {$src, $dst|$dst, $src}", []>,
2363 Requires<[HasSSE1]>, XS;
2364 def MOVSDrr : I<0x10, MRMSrcReg, (ops FR64:$dst, FR64:$src),
2365 "movsd {$src, $dst|$dst, $src}", []>,
2366 Requires<[HasSSE2]>, XD;
2368 def MOVSSrm : I<0x10, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
2369 "movss {$src, $dst|$dst, $src}",
2370 [(set FR32:$dst, (loadf32 addr:$src))]>,
2371 Requires<[HasSSE1]>, XS;
2372 def MOVSSmr : I<0x11, MRMDestMem, (ops f32mem:$dst, FR32:$src),
2373 "movss {$src, $dst|$dst, $src}",
2374 [(store FR32:$src, addr:$dst)]>,
2375 Requires<[HasSSE1]>, XS;
2376 def MOVSDrm : I<0x10, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
2377 "movsd {$src, $dst|$dst, $src}",
2378 [(set FR64:$dst, (loadf64 addr:$src))]>,
2379 Requires<[HasSSE2]>, XD;
2380 def MOVSDmr : I<0x11, MRMDestMem, (ops f64mem:$dst, FR64:$src),
2381 "movsd {$src, $dst|$dst, $src}",
2382 [(store FR64:$src, addr:$dst)]>,
2383 Requires<[HasSSE2]>, XD;
2385 def CVTTSD2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, FR64:$src),
2386 "cvttsd2si {$src, $dst|$dst, $src}",
2387 [(set R32:$dst, (fp_to_sint FR64:$src))]>,
2388 Requires<[HasSSE2]>, XD;
2389 def CVTTSD2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f64mem:$src),
2390 "cvttsd2si {$src, $dst|$dst, $src}",
2391 [(set R32:$dst, (fp_to_sint (loadf64 addr:$src)))]>,
2392 Requires<[HasSSE2]>, XD;
2393 def CVTTSS2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, FR32:$src),
2394 "cvttss2si {$src, $dst|$dst, $src}",
2395 [(set R32:$dst, (fp_to_sint FR32:$src))]>,
2396 Requires<[HasSSE1]>, XS;
2397 def CVTTSS2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f32mem:$src),
2398 "cvttss2si {$src, $dst|$dst, $src}",
2399 [(set R32:$dst, (fp_to_sint (loadf32 addr:$src)))]>,
2400 Requires<[HasSSE1]>, XS;
2401 def CVTSD2SSrr: I<0x5A, MRMSrcReg, (ops FR32:$dst, FR64:$src),
2402 "cvtsd2ss {$src, $dst|$dst, $src}",
2403 [(set FR32:$dst, (fround FR64:$src))]>,
2404 Requires<[HasSSE2]>, XS;
2405 def CVTSD2SSrm: I<0x5A, MRMSrcMem, (ops FR32:$dst, f64mem:$src),
2406 "cvtsd2ss {$src, $dst|$dst, $src}",
2407 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>,
2408 Requires<[HasSSE2]>, XS;
2409 def CVTSS2SDrr: I<0x5A, MRMSrcReg, (ops FR64:$dst, FR32:$src),
2410 "cvtss2sd {$src, $dst|$dst, $src}",
2411 [(set FR64:$dst, (fextend FR32:$src))]>,
2412 Requires<[HasSSE2]>, XD;
2413 def CVTSS2SDrm: I<0x5A, MRMSrcMem, (ops FR64:$dst, f32mem:$src),
2414 "cvtss2sd {$src, $dst|$dst, $src}",
2415 [(set FR64:$dst, (fextend (loadf32 addr:$src)))]>,
2416 Requires<[HasSSE2]>, XD;
2417 def CVTSI2SSrr: I<0x2A, MRMSrcReg, (ops FR32:$dst, R32:$src),
2418 "cvtsi2ss {$src, $dst|$dst, $src}",
2419 [(set FR32:$dst, (sint_to_fp R32:$src))]>,
2420 Requires<[HasSSE2]>, XS;
2421 def CVTSI2SSrm: I<0x2A, MRMSrcMem, (ops FR32:$dst, i32mem:$src),
2422 "cvtsi2ss {$src, $dst|$dst, $src}",
2423 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>,
2424 Requires<[HasSSE2]>, XS;
2425 def CVTSI2SDrr: I<0x2A, MRMSrcReg, (ops FR64:$dst, R32:$src),
2426 "cvtsi2sd {$src, $dst|$dst, $src}",
2427 [(set FR64:$dst, (sint_to_fp R32:$src))]>,
2428 Requires<[HasSSE2]>, XD;
2429 def CVTSI2SDrm: I<0x2A, MRMSrcMem, (ops FR64:$dst, i32mem:$src),
2430 "cvtsi2sd {$src, $dst|$dst, $src}",
2431 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>,
2432 Requires<[HasSSE2]>, XD;
2434 def SQRTSSrm : I<0x51, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
2435 "sqrtss {$src, $dst|$dst, $src}",
2436 [(set FR32:$dst, (fsqrt (loadf32 addr:$src)))]>,
2437 Requires<[HasSSE1]>, XS;
2438 def SQRTSSrr : I<0x51, MRMSrcReg, (ops FR32:$dst, FR32:$src),
2439 "sqrtss {$src, $dst|$dst, $src}",
2440 [(set FR32:$dst, (fsqrt FR32:$src))]>,
2441 Requires<[HasSSE1]>, XS;
2442 def SQRTSDrm : I<0x51, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
2443 "sqrtsd {$src, $dst|$dst, $src}",
2444 [(set FR64:$dst, (fsqrt (loadf64 addr:$src)))]>,
2445 Requires<[HasSSE2]>, XD;
2446 def SQRTSDrr : I<0x51, MRMSrcReg, (ops FR64:$dst, FR64:$src),
2447 "sqrtsd {$src, $dst|$dst, $src}",
2448 [(set FR64:$dst, (fsqrt FR64:$src))]>,
2449 Requires<[HasSSE2]>, XD;
2451 def UCOMISDrr: I<0x2E, MRMSrcReg, (ops FR64:$src1, FR64:$src2),
2452 "ucomisd {$src2, $src1|$src1, $src2}",
2453 [(X86cmp FR64:$src1, FR64:$src2)]>,
2454 Requires<[HasSSE2]>, TB, OpSize;
2455 def UCOMISDrm: I<0x2E, MRMSrcMem, (ops FR64:$src1, f64mem:$src2),
2456 "ucomisd {$src2, $src1|$src1, $src2}",
2457 [(X86cmp FR64:$src1, (loadf64 addr:$src2))]>,
2458 Requires<[HasSSE2]>, TB, OpSize;
2459 def UCOMISSrr: I<0x2E, MRMSrcReg, (ops FR32:$src1, FR32:$src2),
2460 "ucomiss {$src2, $src1|$src1, $src2}",
2461 [(X86cmp FR32:$src1, FR32:$src2)]>,
2462 Requires<[HasSSE1]>, TB;
2463 def UCOMISSrm: I<0x2E, MRMSrcMem, (ops FR32:$src1, f32mem:$src2),
2464 "ucomiss {$src2, $src1|$src1, $src2}",
2465 [(X86cmp FR32:$src1, (loadf32 addr:$src2))]>,
2466 Requires<[HasSSE1]>, TB;
2468 // Pseudo-instructions that map fld0 to xorps/xorpd for sse.
2469 // FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2470 def FLD0SS : I<0x57, MRMSrcReg, (ops FR32:$dst),
2471 "xorps $dst, $dst", [(set FR32:$dst, fp32imm0)]>,
2472 Requires<[HasSSE1]>, TB;
2473 def FLD0SD : I<0x57, MRMSrcReg, (ops FR64:$dst),
2474 "xorpd $dst, $dst", [(set FR64:$dst, fp64imm0)]>,
2475 Requires<[HasSSE2]>, TB, OpSize;
2477 let isTwoAddress = 1 in {
2478 // SSE Scalar Arithmetic
2479 let isCommutable = 1 in {
2480 def ADDSSrr : I<0x58, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2481 "addss {$src2, $dst|$dst, $src2}",
2482 [(set FR32:$dst, (fadd FR32:$src1, FR32:$src2))]>,
2483 Requires<[HasSSE1]>, XS;
2484 def ADDSDrr : I<0x58, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2485 "addsd {$src2, $dst|$dst, $src2}",
2486 [(set FR64:$dst, (fadd FR64:$src1, FR64:$src2))]>,
2487 Requires<[HasSSE2]>, XD;
2488 def MULSSrr : I<0x59, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2489 "mulss {$src2, $dst|$dst, $src2}",
2490 [(set FR32:$dst, (fmul FR32:$src1, FR32:$src2))]>,
2491 Requires<[HasSSE1]>, XS;
2492 def MULSDrr : I<0x59, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2493 "mulsd {$src2, $dst|$dst, $src2}",
2494 [(set FR64:$dst, (fmul FR64:$src1, FR64:$src2))]>,
2495 Requires<[HasSSE2]>, XD;
2498 def ADDSSrm : I<0x58, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2499 "addss {$src2, $dst|$dst, $src2}",
2500 [(set FR32:$dst, (fadd FR32:$src1, (loadf32 addr:$src2)))]>,
2501 Requires<[HasSSE1]>, XS;
2502 def ADDSDrm : I<0x58, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2503 "addsd {$src2, $dst|$dst, $src2}",
2504 [(set FR64:$dst, (fadd FR64:$src1, (loadf64 addr:$src2)))]>,
2505 Requires<[HasSSE2]>, XD;
2506 def MULSSrm : I<0x59, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2507 "mulss {$src2, $dst|$dst, $src2}",
2508 [(set FR32:$dst, (fmul FR32:$src1, (loadf32 addr:$src2)))]>,
2509 Requires<[HasSSE1]>, XS;
2510 def MULSDrm : I<0x59, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2511 "mulsd {$src2, $dst|$dst, $src2}",
2512 [(set FR64:$dst, (fmul FR64:$src1, (loadf64 addr:$src2)))]>,
2513 Requires<[HasSSE2]>, XD;
2515 def DIVSSrr : I<0x5E, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2516 "divss {$src2, $dst|$dst, $src2}",
2517 [(set FR32:$dst, (fdiv FR32:$src1, FR32:$src2))]>,
2518 Requires<[HasSSE1]>, XS;
2519 def DIVSSrm : I<0x5E, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2520 "divss {$src2, $dst|$dst, $src2}",
2521 [(set FR32:$dst, (fdiv FR32:$src1, (loadf32 addr:$src2)))]>,
2522 Requires<[HasSSE1]>, XS;
2523 def DIVSDrr : I<0x5E, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2524 "divsd {$src2, $dst|$dst, $src2}",
2525 [(set FR64:$dst, (fdiv FR64:$src1, FR64:$src2))]>,
2526 Requires<[HasSSE2]>, XD;
2527 def DIVSDrm : I<0x5E, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2528 "divsd {$src2, $dst|$dst, $src2}",
2529 [(set FR64:$dst, (fdiv FR64:$src1, (loadf64 addr:$src2)))]>,
2530 Requires<[HasSSE2]>, XD;
2532 def SUBSSrr : I<0x5C, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2533 "subss {$src2, $dst|$dst, $src2}",
2534 [(set FR32:$dst, (fsub FR32:$src1, FR32:$src2))]>,
2535 Requires<[HasSSE1]>, XS;
2536 def SUBSSrm : I<0x5C, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2537 "subss {$src2, $dst|$dst, $src2}",
2538 [(set FR32:$dst, (fsub FR32:$src1, (loadf32 addr:$src2)))]>,
2539 Requires<[HasSSE1]>, XS;
2540 def SUBSDrr : I<0x5C, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2541 "subsd {$src2, $dst|$dst, $src2}",
2542 [(set FR64:$dst, (fsub FR64:$src1, FR64:$src2))]>,
2543 Requires<[HasSSE2]>, XD;
2544 def SUBSDrm : I<0x5C, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2545 "subsd {$src2, $dst|$dst, $src2}",
2546 [(set FR64:$dst, (fsub FR64:$src1, (loadf64 addr:$src2)))]>,
2547 Requires<[HasSSE2]>, XD;
2550 let isCommutable = 1 in {
2551 def ANDPSrr : I<0x54, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2552 "andps {$src2, $dst|$dst, $src2}", []>,
2553 Requires<[HasSSE1]>, TB;
2554 def ANDPDrr : I<0x54, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2555 "andpd {$src2, $dst|$dst, $src2}", []>,
2556 Requires<[HasSSE2]>, TB, OpSize;
2557 def ORPSrr : I<0x56, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2558 "orps {$src2, $dst|$dst, $src2}", []>,
2559 Requires<[HasSSE1]>, TB;
2560 def ORPDrr : I<0x56, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2561 "orpd {$src2, $dst|$dst, $src2}", []>,
2562 Requires<[HasSSE2]>, TB, OpSize;
2563 def XORPSrr : I<0x57, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2564 "xorps {$src2, $dst|$dst, $src2}", []>,
2565 Requires<[HasSSE1]>, TB;
2566 def XORPDrr : I<0x57, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2567 "xorpd {$src2, $dst|$dst, $src2}", []>,
2568 Requires<[HasSSE2]>, TB, OpSize;
2570 def ANDNPSrr : I<0x55, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2571 "andnps {$src2, $dst|$dst, $src2}", []>,
2572 Requires<[HasSSE1]>, TB;
2573 def ANDNPDrr : I<0x55, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2574 "andnpd {$src2, $dst|$dst, $src2}", []>,
2575 Requires<[HasSSE2]>, TB, OpSize;
2577 def CMPSSrr : I<0xC2, MRMSrcReg,
2578 (ops FR32:$dst, FR32:$src1, FR32:$src, SSECC:$cc),
2579 "cmp${cc}ss {$src, $dst|$dst, $src}", []>,
2580 Requires<[HasSSE1]>, XS;
2581 def CMPSSrm : I<0xC2, MRMSrcMem,
2582 (ops FR32:$dst, FR32:$src1, f32mem:$src, SSECC:$cc),
2583 "cmp${cc}ss {$src, $dst|$dst, $src}", []>,
2584 Requires<[HasSSE1]>, XS;
2585 def CMPSDrr : I<0xC2, MRMSrcReg,
2586 (ops FR64:$dst, FR64:$src1, FR64:$src, SSECC:$cc),
2587 "cmp${cc}sd {$src, $dst|$dst, $src}", []>,
2588 Requires<[HasSSE1]>, XD;
2589 def CMPSDrm : I<0xC2, MRMSrcMem,
2590 (ops FR64:$dst, FR64:$src1, f64mem:$src, SSECC:$cc),
2591 "cmp${cc}sd {$src, $dst|$dst, $src}", []>,
2592 Requires<[HasSSE2]>, XD;
2595 //===----------------------------------------------------------------------===//
2596 // Floating Point Stack Support
2597 //===----------------------------------------------------------------------===//
2599 // Floating point support. All FP Stack operations are represented with two
2600 // instructions here. The first instruction, generated by the instruction
2601 // selector, uses "RFP" registers: a traditional register file to reference
2602 // floating point values. These instructions are all psuedo instructions and
2603 // use the "Fp" prefix. The second instruction is defined with FPI, which is
2604 // the actual instruction emitted by the assembler. The FP stackifier pass
2605 // converts one to the other after register allocation occurs.
2607 // Note that the FpI instruction should have instruction selection info (e.g.
2608 // a pattern) and the FPI instruction should have emission info (e.g. opcode
2609 // encoding and asm printing info).
2611 // FPI - Floating Point Instruction template.
2612 class FPI<bits<8> o, Format F, dag ops, string asm> : I<o, F, ops, asm, []> {}
2614 // FpI_ - Floating Point Psuedo Instruction template. Not Predicated.
2615 class FpI_<dag ops, FPFormat fp, list<dag> pattern>
2616 : X86Inst<0, Pseudo, NoImm, ops, ""> {
2617 let FPForm = fp; let FPFormBits = FPForm.Value;
2618 let Pattern = pattern;
2621 // Random Pseudo Instructions.
2622 def FpGETRESULT : FpI_<(ops RFP:$dst), SpecialFP,
2623 [(set RFP:$dst, X86fpget)]>; // FPR = ST(0)
2625 let noResults = 1 in
2626 def FpSETRESULT : FpI_<(ops RFP:$src), SpecialFP,
2627 [(X86fpset RFP:$src)]>, Imp<[], [ST0]>; // ST(0) = FPR
2629 // FpI - Floating Point Psuedo Instruction template. Predicated on FPStack.
2630 class FpI<dag ops, FPFormat fp, list<dag> pattern> :
2631 FpI_<ops, fp, pattern>, Requires<[FPStack]>;
2634 def FpMOV : FpI<(ops RFP:$dst, RFP:$src), SpecialFP, []>; // f1 = fmov f2
2637 // Add, Sub, Mul, Div.
2638 def FpADD : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2639 [(set RFP:$dst, (fadd RFP:$src1, RFP:$src2))]>;
2640 def FpSUB : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2641 [(set RFP:$dst, (fsub RFP:$src1, RFP:$src2))]>;
2642 def FpMUL : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2643 [(set RFP:$dst, (fmul RFP:$src1, RFP:$src2))]>;
2644 def FpDIV : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2645 [(set RFP:$dst, (fdiv RFP:$src1, RFP:$src2))]>;
2647 class FPST0rInst<bits<8> o, string asm>
2648 : FPI<o, AddRegFrm, (ops RST:$op), asm>, D8;
2649 class FPrST0Inst<bits<8> o, string asm>
2650 : FPI<o, AddRegFrm, (ops RST:$op), asm>, DC;
2651 class FPrST0PInst<bits<8> o, string asm>
2652 : FPI<o, AddRegFrm, (ops RST:$op), asm>, DE;
2654 // Binary Ops with a memory source.
2655 def FpADD32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2656 [(set RFP:$dst, (fadd RFP:$src1,
2657 (extloadf64f32 addr:$src2)))]>;
2658 // ST(0) = ST(0) + [mem32]
2659 def FpADD64m : FpI<(ops RFP:$dst, RFP:$src1, f64mem:$src2), OneArgFPRW,
2660 [(set RFP:$dst, (fadd RFP:$src1, (loadf64 addr:$src2)))]>;
2661 // ST(0) = ST(0) + [mem64]
2662 def FpMUL32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2663 [(set RFP:$dst, (fmul RFP:$src1,
2664 (extloadf64f32 addr:$src2)))]>;
2665 // ST(0) = ST(0) * [mem32]
2666 def FpMUL64m : FpI<(ops RFP:$dst, RFP:$src1, f64mem:$src2), OneArgFPRW,
2667 [(set RFP:$dst, (fmul RFP:$src1, (loadf64 addr:$src2)))]>;
2668 // ST(0) = ST(0) * [mem64]
2669 def FpSUB32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2670 [(set RFP:$dst, (fsub RFP:$src1,
2671 (extloadf64f32 addr:$src2)))]>;
2672 // ST(0) = ST(0) - [mem32]
2673 def FpSUB64m : FpI<(ops RFP:$dst, RFP:$src1, f64mem:$src2), OneArgFPRW,
2674 [(set RFP:$dst, (fsub RFP:$src1, (loadf64 addr:$src2)))]>;
2675 // ST(0) = ST(0) - [mem64]
2676 def FpSUBR32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2677 [(set RFP:$dst, (fsub (extloadf64f32 addr:$src2),
2679 // ST(0) = [mem32] - ST(0)
2680 def FpSUBR64m : FpI<(ops RFP:$dst, RFP:$src1, f64mem:$src2), OneArgFPRW,
2681 [(set RFP:$dst, (fsub (loadf64 addr:$src2), RFP:$src1))]>;
2682 // ST(0) = [mem64] - ST(0)
2683 def FpDIV32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2684 [(set RFP:$dst, (fdiv RFP:$src1,
2685 (extloadf64f32 addr:$src2)))]>;
2686 // ST(0) = ST(0) / [mem32]
2687 def FpDIV64m : FpI<(ops RFP:$dst, RFP:$src1, f64mem:$src2), OneArgFPRW,
2688 [(set RFP:$dst, (fdiv RFP:$src1, (loadf64 addr:$src2)))]>;
2689 // ST(0) = ST(0) / [mem64]
2690 def FpDIVR32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
2691 [(set RFP:$dst, (fdiv (extloadf64f32 addr:$src2),
2693 // ST(0) = [mem32] / ST(0)
2694 def FpDIVR64m : FpI<(ops RFP:$dst, RFP:$src1, f64mem:$src2), OneArgFPRW,
2695 [(set RFP:$dst, (fdiv (loadf64 addr:$src2), RFP:$src1))]>;
2696 // ST(0) = [mem64] / ST(0)
2699 def FADD32m : FPI<0xD8, MRM0m, (ops f32mem:$src), "fadd{s} $src">;
2700 def FADD64m : FPI<0xDC, MRM0m, (ops f64mem:$src), "fadd{l} $src">;
2701 def FMUL32m : FPI<0xD8, MRM1m, (ops f32mem:$src), "fmul{s} $src">;
2702 def FMUL64m : FPI<0xDC, MRM1m, (ops f64mem:$src), "fmul{l} $src">;
2703 def FSUB32m : FPI<0xD8, MRM4m, (ops f32mem:$src), "fsub{s} $src">;
2704 def FSUB64m : FPI<0xDC, MRM4m, (ops f64mem:$src), "fsub{l} $src">;
2705 def FSUBR32m : FPI<0xD8, MRM5m, (ops f32mem:$src), "fsubr{s} $src">;
2706 def FSUBR64m : FPI<0xDC, MRM5m, (ops f64mem:$src), "fsubr{l} $src">;
2707 def FDIV32m : FPI<0xD8, MRM6m, (ops f32mem:$src), "fdiv{s} $src">;
2708 def FDIV64m : FPI<0xDC, MRM6m, (ops f64mem:$src), "fdiv{l} $src">;
2709 def FDIVR32m : FPI<0xD8, MRM7m, (ops f32mem:$src), "fdivr{s} $src">;
2710 def FDIVR64m : FPI<0xDC, MRM7m, (ops f64mem:$src), "fdivr{l} $src">;
2712 def FpIADD16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2713 [(set RFP:$dst, (fadd RFP:$src1,
2714 (X86fild addr:$src2, i16)))]>;
2715 // ST(0) = ST(0) + [mem16int]
2716 def FpIADD32m : FpI<(ops RFP:$dst, RFP:$src1, i32mem:$src2), OneArgFPRW,
2717 [(set RFP:$dst, (fadd RFP:$src1,
2718 (X86fild addr:$src2, i32)))]>;
2719 // ST(0) = ST(0) + [mem32int]
2720 def FpIMUL16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2721 [(set RFP:$dst, (fmul RFP:$src1,
2722 (X86fild addr:$src2, i16)))]>;
2723 // ST(0) = ST(0) * [mem16int]
2724 def FpIMUL32m : FpI<(ops RFP:$dst, RFP:$src1, i32mem:$src2), OneArgFPRW,
2725 [(set RFP:$dst, (fmul RFP:$src1,
2726 (X86fild addr:$src2, i32)))]>;
2727 // ST(0) = ST(0) * [mem32int]
2728 def FpISUB16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2729 [(set RFP:$dst, (fsub RFP:$src1,
2730 (X86fild addr:$src2, i16)))]>;
2731 // ST(0) = ST(0) - [mem16int]
2732 def FpISUB32m : FpI<(ops RFP:$dst, RFP:$src1, i32mem:$src2), OneArgFPRW,
2733 [(set RFP:$dst, (fsub RFP:$src1,
2734 (X86fild addr:$src2, i32)))]>;
2735 // ST(0) = ST(0) - [mem32int]
2736 def FpISUBR16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2737 [(set RFP:$dst, (fsub (X86fild addr:$src2, i16),
2739 // ST(0) = [mem16int] - ST(0)
2740 def FpISUBR32m : FpI<(ops RFP:$dst, RFP:$src1, i32mem:$src2), OneArgFPRW,
2741 [(set RFP:$dst, (fsub (X86fild addr:$src2, i32),
2743 // ST(0) = [mem32int] - ST(0)
2744 def FpIDIV16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2745 [(set RFP:$dst, (fdiv RFP:$src1,
2746 (X86fild addr:$src2, i16)))]>;
2747 // ST(0) = ST(0) / [mem16int]
2748 def FpIDIV32m : FpI<(ops RFP:$dst, RFP:$src1, i32mem:$src2), OneArgFPRW,
2749 [(set RFP:$dst, (fdiv RFP:$src1,
2750 (X86fild addr:$src2, i32)))]>;
2751 // ST(0) = ST(0) / [mem32int]
2752 def FpIDIVR16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2753 [(set RFP:$dst, (fdiv (X86fild addr:$src2, i16),
2755 // ST(0) = [mem16int] / ST(0)
2756 def FpIDIVR32m : FpI<(ops RFP:$dst, RFP:$src1, i32mem:$src2), OneArgFPRW,
2757 [(set RFP:$dst, (fdiv (X86fild addr:$src2, i32),
2759 // ST(0) = [mem32int] / ST(0)
2761 def FIADD16m : FPI<0xDE, MRM0m, (ops i16mem:$src), "fiadd{s} $src">;
2762 def FIADD32m : FPI<0xDA, MRM0m, (ops i32mem:$src), "fiadd{l} $src">;
2763 def FIMUL16m : FPI<0xDE, MRM1m, (ops i16mem:$src), "fimul{s} $src">;
2764 def FIMUL32m : FPI<0xDA, MRM1m, (ops i32mem:$src), "fimul{l} $src">;
2765 def FISUB16m : FPI<0xDE, MRM4m, (ops i16mem:$src), "fisub{s} $src">;
2766 def FISUB32m : FPI<0xDA, MRM4m, (ops i32mem:$src), "fisub{l} $src">;
2767 def FISUBR16m : FPI<0xDE, MRM5m, (ops i16mem:$src), "fisubr{s} $src">;
2768 def FISUBR32m : FPI<0xDA, MRM5m, (ops i32mem:$src), "fisubr{l} $src">;
2769 def FIDIV16m : FPI<0xDE, MRM6m, (ops i16mem:$src), "fidiv{s} $src">;
2770 def FIDIV32m : FPI<0xDA, MRM6m, (ops i32mem:$src), "fidiv{l} $src">;
2771 def FIDIVR16m : FPI<0xDE, MRM7m, (ops i16mem:$src), "fidivr{s} $src">;
2772 def FIDIVR32m : FPI<0xDA, MRM7m, (ops i32mem:$src), "fidivr{l} $src">;
2774 // NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
2775 // of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
2776 // we have to put some 'r's in and take them out of weird places.
2777 def FADDST0r : FPST0rInst <0xC0, "fadd $op">;
2778 def FADDrST0 : FPrST0Inst <0xC0, "fadd {%st(0), $op|$op, %ST(0)}">;
2779 def FADDPrST0 : FPrST0PInst<0xC0, "faddp $op">;
2780 def FSUBRST0r : FPST0rInst <0xE8, "fsubr $op">;
2781 def FSUBrST0 : FPrST0Inst <0xE8, "fsub{r} {%st(0), $op|$op, %ST(0)}">;
2782 def FSUBPrST0 : FPrST0PInst<0xE8, "fsub{r}p $op">;
2783 def FSUBST0r : FPST0rInst <0xE0, "fsub $op">;
2784 def FSUBRrST0 : FPrST0Inst <0xE0, "fsub{|r} {%st(0), $op|$op, %ST(0)}">;
2785 def FSUBRPrST0 : FPrST0PInst<0xE0, "fsub{|r}p $op">;
2786 def FMULST0r : FPST0rInst <0xC8, "fmul $op">;
2787 def FMULrST0 : FPrST0Inst <0xC8, "fmul {%st(0), $op|$op, %ST(0)}">;
2788 def FMULPrST0 : FPrST0PInst<0xC8, "fmulp $op">;
2789 def FDIVRST0r : FPST0rInst <0xF8, "fdivr $op">;
2790 def FDIVrST0 : FPrST0Inst <0xF8, "fdiv{r} {%st(0), $op|$op, %ST(0)}">;
2791 def FDIVPrST0 : FPrST0PInst<0xF8, "fdiv{r}p $op">;
2792 def FDIVST0r : FPST0rInst <0xF0, "fdiv $op">;
2793 def FDIVRrST0 : FPrST0Inst <0xF0, "fdiv{|r} {%st(0), $op|$op, %ST(0)}">;
2794 def FDIVRPrST0 : FPrST0PInst<0xF0, "fdiv{|r}p $op">;
2797 // Unary operations.
2798 def FpCHS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2799 [(set RFP:$dst, (fneg RFP:$src))]>;
2800 def FpABS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2801 [(set RFP:$dst, (fabs RFP:$src))]>;
2802 def FpSQRT : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2803 [(set RFP:$dst, (fsqrt RFP:$src))]>;
2804 def FpSIN : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2805 [(set RFP:$dst, (fsin RFP:$src))]>;
2806 def FpCOS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2807 [(set RFP:$dst, (fcos RFP:$src))]>;
2808 def FpTST : FpI<(ops RFP:$src), OneArgFP,
2811 def FCHS : FPI<0xE0, RawFrm, (ops), "fchs">, D9;
2812 def FABS : FPI<0xE1, RawFrm, (ops), "fabs">, D9;
2813 def FSQRT : FPI<0xFA, RawFrm, (ops), "fsqrt">, D9;
2814 def FSIN : FPI<0xFE, RawFrm, (ops), "fsin">, D9;
2815 def FCOS : FPI<0xFF, RawFrm, (ops), "fcos">, D9;
2816 def FTST : FPI<0xE4, RawFrm, (ops), "ftst">, D9;
2819 // Floating point cmovs.
2820 let isTwoAddress = 1 in {
2821 def FpCMOVB : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2822 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2824 def FpCMOVBE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2825 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2827 def FpCMOVE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2828 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2830 def FpCMOVP : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2831 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2833 def FpCMOVNB : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2834 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2836 def FpCMOVNBE: FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2837 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2839 def FpCMOVNE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2840 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2842 def FpCMOVNP : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2843 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2847 def FCMOVB : FPI<0xC0, AddRegFrm, (ops RST:$op),
2848 "fcmovb {$op, %st(0)|%ST(0), $op}">, DA;
2849 def FCMOVBE : FPI<0xD0, AddRegFrm, (ops RST:$op),
2850 "fcmovbe {$op, %st(0)|%ST(0), $op}">, DA;
2851 def FCMOVE : FPI<0xC8, AddRegFrm, (ops RST:$op),
2852 "fcmove {$op, %st(0)|%ST(0), $op}">, DA;
2853 def FCMOVP : FPI<0xD8, AddRegFrm, (ops RST:$op),
2854 "fcmovu {$op, %st(0)|%ST(0), $op}">, DA;
2855 def FCMOVNB : FPI<0xC0, AddRegFrm, (ops RST:$op),
2856 "fcmovnb {$op, %st(0)|%ST(0), $op}">, DB;
2857 def FCMOVNBE : FPI<0xD0, AddRegFrm, (ops RST:$op),
2858 "fcmovnbe {$op, %st(0)|%ST(0), $op}">, DB;
2859 def FCMOVNE : FPI<0xC8, AddRegFrm, (ops RST:$op),
2860 "fcmovne {$op, %st(0)|%ST(0), $op}">, DB;
2861 def FCMOVNP : FPI<0xD8, AddRegFrm, (ops RST:$op),
2862 "fcmovnu {$op, %st(0)|%ST(0), $op}">, DB;
2864 // Floating point loads & stores.
2865 def FpLD32m : FpI<(ops RFP:$dst, f32mem:$src), ZeroArgFP,
2866 [(set RFP:$dst, (extloadf64f32 addr:$src))]>;
2867 def FpLD64m : FpI<(ops RFP:$dst, f64mem:$src), ZeroArgFP,
2868 [(set RFP:$dst, (loadf64 addr:$src))]>;
2869 def FpILD16m : FpI<(ops RFP:$dst, i16mem:$src), ZeroArgFP,
2870 [(set RFP:$dst, (X86fild addr:$src, i16))]>;
2871 def FpILD32m : FpI<(ops RFP:$dst, i32mem:$src), ZeroArgFP,
2872 [(set RFP:$dst, (X86fild addr:$src, i32))]>;
2873 def FpILD64m : FpI<(ops RFP:$dst, i64mem:$src), ZeroArgFP,
2874 [(set RFP:$dst, (X86fild addr:$src, i64))]>;
2876 def FpST32m : FpI<(ops f32mem:$op, RFP:$src), OneArgFP,
2877 [(truncstore RFP:$src, addr:$op, f32)]>;
2878 def FpST64m : FpI<(ops f64mem:$op, RFP:$src), OneArgFP,
2879 [(store RFP:$src, addr:$op)]>;
2881 def FpSTP32m : FpI<(ops f32mem:$op, RFP:$src), OneArgFP, []>;
2882 def FpSTP64m : FpI<(ops f64mem:$op, RFP:$src), OneArgFP, []>;
2883 def FpIST16m : FpI<(ops i16mem:$op, RFP:$src), OneArgFP, []>;
2884 def FpIST32m : FpI<(ops i32mem:$op, RFP:$src), OneArgFP, []>;
2885 def FpIST64m : FpI<(ops i64mem:$op, RFP:$src), OneArgFP, []>;
2887 def FLD32m : FPI<0xD9, MRM0m, (ops f32mem:$src), "fld{s} $src">;
2888 def FLD64m : FPI<0xDD, MRM0m, (ops f64mem:$src), "fld{l} $src">;
2889 def FILD16m : FPI<0xDF, MRM0m, (ops i16mem:$src), "fild{s} $src">;
2890 def FILD32m : FPI<0xDB, MRM0m, (ops i32mem:$src), "fild{l} $src">;
2891 def FILD64m : FPI<0xDF, MRM5m, (ops i64mem:$src), "fild{ll} $src">;
2892 def FST32m : FPI<0xD9, MRM2m, (ops f32mem:$dst), "fst{s} $dst">;
2893 def FST64m : FPI<0xDD, MRM2m, (ops f64mem:$dst), "fst{l} $dst">;
2894 def FSTP32m : FPI<0xD9, MRM3m, (ops f32mem:$dst), "fstp{s} $dst">;
2895 def FSTP64m : FPI<0xDD, MRM3m, (ops f64mem:$dst), "fstp{l} $dst">;
2896 def FIST16m : FPI<0xDF, MRM2m, (ops i16mem:$dst), "fist{s} $dst">;
2897 def FIST32m : FPI<0xDB, MRM2m, (ops i32mem:$dst), "fist{l} $dst">;
2898 def FISTP16m : FPI<0xDF, MRM3m, (ops i16mem:$dst), "fistp{s} $dst">;
2899 def FISTP32m : FPI<0xDB, MRM3m, (ops i32mem:$dst), "fistp{l} $dst">;
2900 def FISTP64m : FPI<0xDF, MRM7m, (ops i64mem:$dst), "fistp{ll} $dst">;
2902 // FP Stack manipulation instructions.
2903 def FLDrr : FPI<0xC0, AddRegFrm, (ops RST:$op), "fld $op">, D9;
2904 def FSTrr : FPI<0xD0, AddRegFrm, (ops RST:$op), "fst $op">, DD;
2905 def FSTPrr : FPI<0xD8, AddRegFrm, (ops RST:$op), "fstp $op">, DD;
2906 def FXCH : FPI<0xC8, AddRegFrm, (ops RST:$op), "fxch $op">, D9;
2908 // Floating point constant loads.
2909 def FpLD0 : FpI<(ops RFP:$dst), ZeroArgFP,
2910 [(set RFP:$dst, fp64imm0)]>;
2911 def FpLD1 : FpI<(ops RFP:$dst), ZeroArgFP,
2912 [(set RFP:$dst, fp64imm1)]>;
2914 def FLD0 : FPI<0xEE, RawFrm, (ops), "fldz">, D9;
2915 def FLD1 : FPI<0xE8, RawFrm, (ops), "fld1">, D9;
2918 // Floating point compares.
2919 def FpUCOMr : FpI<(ops RFP:$lhs, RFP:$rhs), CompareFP,
2920 []>; // FPSW = cmp ST(0) with ST(i)
2921 def FpUCOMIr : FpI<(ops RFP:$lhs, RFP:$rhs), CompareFP,
2922 [(X86cmp RFP:$lhs, RFP:$rhs)]>; // CC = cmp ST(0) with ST(i)
2924 def FUCOMr : FPI<0xE0, AddRegFrm, // FPSW = cmp ST(0) with ST(i)
2926 "fucom $reg">, DD, Imp<[ST0],[]>;
2927 def FUCOMPr : FPI<0xE8, AddRegFrm, // FPSW = cmp ST(0) with ST(i), pop
2929 "fucomp $reg">, DD, Imp<[ST0],[]>;
2930 def FUCOMPPr : FPI<0xE9, RawFrm, // cmp ST(0) with ST(1), pop, pop
2932 "fucompp">, DA, Imp<[ST0],[]>;
2934 def FUCOMIr : FPI<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i)
2936 "fucomi {$reg, %st(0)|%ST(0), $reg}">, DB, Imp<[ST0],[]>;
2937 def FUCOMIPr : FPI<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i), pop
2939 "fucomip {$reg, %st(0)|%ST(0), $reg}">, DF, Imp<[ST0],[]>;
2942 // Floating point flag ops.
2943 def FNSTSW8r : I<0xE0, RawFrm, // AX = fp flags
2944 (ops), "fnstsw", []>, DF, Imp<[],[AX]>;
2946 def FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world
2947 (ops i16mem:$dst), "fnstcw $dst", []>;
2948 def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
2949 (ops i16mem:$dst), "fldcw $dst", []>;
2952 //===----------------------------------------------------------------------===//
2953 // Miscellaneous Instructions
2954 //===----------------------------------------------------------------------===//
2956 def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
2957 TB, Imp<[],[EAX,EDX]>;
2960 //===----------------------------------------------------------------------===//
2961 // Non-Instruction Patterns
2962 //===----------------------------------------------------------------------===//
2964 // GlobalAddress and ExternalSymbol
2965 def : Pat<(i32 globaladdr:$dst), (MOV32ri tglobaladdr:$dst)>;
2966 def : Pat<(i32 externalsym:$dst), (MOV32ri texternalsym:$dst)>;
2969 def : Pat<(X86call tglobaladdr:$dst),
2970 (CALLpcrel32 tglobaladdr:$dst)>;
2971 def : Pat<(X86call texternalsym:$dst),
2972 (CALLpcrel32 texternalsym:$dst)>;
2974 // X86 specific add which produces a flag.
2975 def : Pat<(X86addflag R32:$src1, R32:$src2),
2976 (ADD32rr R32:$src1, R32:$src2)>;
2977 def : Pat<(X86addflag R32:$src1, (load addr:$src2)),
2978 (ADD32rm R32:$src1, addr:$src2)>;
2979 def : Pat<(X86addflag R32:$src1, imm:$src2),
2980 (ADD32ri R32:$src1, imm:$src2)>;
2981 def : Pat<(X86addflag R32:$src1, i32immSExt8:$src2),
2982 (ADD32ri8 R32:$src1, i32immSExt8:$src2)>;
2984 def : Pat<(X86subflag R32:$src1, R32:$src2),
2985 (SUB32rr R32:$src1, R32:$src2)>;
2986 def : Pat<(X86subflag R32:$src1, (load addr:$src2)),
2987 (SUB32rm R32:$src1, addr:$src2)>;
2988 def : Pat<(X86subflag R32:$src1, imm:$src2),
2989 (SUB32ri R32:$src1, imm:$src2)>;
2990 def : Pat<(X86subflag R32:$src1, i32immSExt8:$src2),
2991 (SUB32ri8 R32:$src1, i32immSExt8:$src2)>;
2993 def : Pat<(truncstore (i8 imm:$src), addr:$dst, i1),
2994 (MOV8mi addr:$dst, imm:$src)>;
2995 def : Pat<(truncstore R8:$src, addr:$dst, i1),
2996 (MOV8mr addr:$dst, R8:$src)>;
2998 // {s|z}extload bool -> {s|z}extload byte
2999 def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
3000 def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
3001 def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3002 def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3003 def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3005 // extload bool -> extload byte
3006 def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3009 def : Pat<(i16 (anyext R8 :$src)), (MOVZX16rr8 R8 :$src)>;
3010 def : Pat<(i32 (anyext R8 :$src)), (MOVZX32rr8 R8 :$src)>;
3011 def : Pat<(i32 (anyext R16:$src)), (MOVZX32rr16 R16:$src)>;
3013 // Required for RET of f32 / f64 values.
3014 def : Pat<(X86fld addr:$src, f32), (FpLD32m addr:$src)>;
3015 def : Pat<(X86fld addr:$src, f64), (FpLD64m addr:$src)>;
3017 // Required for CALL which return f32 / f64 values.
3018 def : Pat<(X86fst RFP:$src, addr:$op, f32), (FpST32m addr:$op, RFP:$src)>;
3019 def : Pat<(X86fst RFP:$src, addr:$op, f64), (FpST64m addr:$op, RFP:$src)>;
3021 // Floating point constant -0.0 and -1.0
3022 def : Pat<(f64 fp64immneg0), (FpCHS (FpLD0))>, Requires<[FPStack]>;
3023 def : Pat<(f64 fp64immneg1), (FpCHS (FpLD1))>, Requires<[FPStack]>;
3025 // Used to conv. i64 to f64 since there isn't a SSE version.
3026 def : Pat<(X86fild addr:$src, i64), (FpILD64m addr:$src)>, Requires<[HasSSE2]>;
3028 //===----------------------------------------------------------------------===//
3030 //===----------------------------------------------------------------------===//
3032 // (shl x, 1) ==> (add x, x)
3033 def : Pat<(shl R8 :$src1, (i8 1)), (ADD8rr R8 :$src1, R8 :$src1)>;
3034 def : Pat<(shl R16:$src1, (i8 1)), (ADD16rr R16:$src1, R16:$src1)>;
3035 def : Pat<(shl R32:$src1, (i8 1)), (ADD32rr R32:$src1, R32:$src1)>;
3037 // (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3038 def : Pat<(or (srl R32:$src1, CL:$amt),
3039 (shl R32:$src2, (sub 32, CL:$amt))),
3040 (SHRD32rrCL R32:$src1, R32:$src2)>;
3042 def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3043 (shl R32:$src2, (sub 32, CL:$amt))), addr:$dst),
3044 (SHRD32mrCL addr:$dst, R32:$src2)>;
3046 // (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3047 def : Pat<(or (shl R32:$src1, CL:$amt),
3048 (srl R32:$src2, (sub 32, CL:$amt))),
3049 (SHLD32rrCL R32:$src1, R32:$src2)>;
3051 def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3052 (srl R32:$src2, (sub 32, CL:$amt))), addr:$dst),
3053 (SHLD32mrCL addr:$dst, R32:$src2)>;
3055 // (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3056 def : Pat<(or (srl R16:$src1, CL:$amt),
3057 (shl R16:$src2, (sub 16, CL:$amt))),
3058 (SHRD16rrCL R16:$src1, R16:$src2)>;
3060 def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3061 (shl R16:$src2, (sub 16, CL:$amt))), addr:$dst),
3062 (SHRD16mrCL addr:$dst, R16:$src2)>;
3064 // (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3065 def : Pat<(or (shl R16:$src1, CL:$amt),
3066 (srl R16:$src2, (sub 16, CL:$amt))),
3067 (SHLD16rrCL R16:$src1, R16:$src2)>;
3069 def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3070 (srl R16:$src2, (sub 16, CL:$amt))), addr:$dst),
3071 (SHLD16mrCL addr:$dst, R16:$src2)>;