blob: 7431a3c17482581e9d7ade944812ea7a4cc52724 [file] [log] [blame]
Chris Lattner1cca5e32003-08-03 21:54:21 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
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.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00009//
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.
13//
14//===----------------------------------------------------------------------===//
15
Evan Chengaed7c722005-12-17 01:24:02 +000016//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
Evan Chenge3413162006-01-09 18:33:28 +000020def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
Evan Chengd9558e02006-01-06 00:43:03 +000024def SDTX86CmpTest : SDTypeProfile<1, 2, [SDTCisVT<0, FlagVT>, SDTCisSameAs<1, 2>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000025
26def SDTX86Cmov : SDTypeProfile<1, 4,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
Evan Chengd9558e02006-01-06 00:43:03 +000028 SDTCisVT<3, i8>, SDTCisVT<4, FlagVT>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000029
Evan Cheng898101c2005-12-19 23:12:38 +000030def SDTX86BrCond : SDTypeProfile<0, 3,
31 [SDTCisVT<0, OtherVT>,
Evan Chengd9558e02006-01-06 00:43:03 +000032 SDTCisVT<1, i8>, SDTCisVT<2, FlagVT>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000033
Evan Chengd5781fc2005-12-21 20:21:51 +000034def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Chengd9558e02006-01-06 00:43:03 +000035 [SDTCisVT<0, i8>, SDTCisVT<1, i8>,
Evan Chengd5781fc2005-12-21 20:21:51 +000036 SDTCisVT<2, FlagVT>]>;
37
Evan Chengd9558e02006-01-06 00:43:03 +000038def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000039
Evan Chenge3413162006-01-09 18:33:28 +000040def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
41def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
42 SDTCisVT<1, i32> ]>;
43
44def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
45
46def SDTX86FpGet : SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>;
47def SDTX86FpSet : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
48
Evan Cheng38bcbaf2005-12-23 07:31:11 +000049def SDTX86Fld : SDTypeProfile<1, 2, [SDTCisVT<0, f64>,
Evan Chengb077b842005-12-21 02:39:21 +000050 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000051def SDTX86Fst : SDTypeProfile<0, 3, [SDTCisFP<0>,
52 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
Evan Chengf7100622006-01-10 22:22:02 +000053def SDTX86Fild64m : SDTypeProfile<1, 1, [SDTCisVT<0, f64>, SDTCisPtrTy<1>]>;
Evan Chengb077b842005-12-21 02:39:21 +000054
Evan Cheng67f92a72006-01-11 22:15:48 +000055def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
56
Evan Chenge3413162006-01-09 18:33:28 +000057def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000058
Evan Chenge3413162006-01-09 18:33:28 +000059def X86addflag : SDNode<"X86ISD::ADD_FLAG", SDTIntBinOp ,
60 [SDNPCommutative, SDNPAssociative, SDNPOutFlag]>;
61def X86subflag : SDNode<"X86ISD::SUB_FLAG", SDTIntBinOp,
62 [SDNPOutFlag]>;
63def X86adc : SDNode<"X86ISD::ADC" , SDTIntBinOp ,
64 [SDNPCommutative, SDNPAssociative]>;
65def X86sbb : SDNode<"X86ISD::SBB" , SDTIntBinOp>;
66
67def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
68def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000069
Evan Chengd5781fc2005-12-21 20:21:51 +000070def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest, []>;
71def X86test : SDNode<"X86ISD::TEST", SDTX86CmpTest, []>;
Evan Chengb077b842005-12-21 02:39:21 +000072
Evan Chenge3413162006-01-09 18:33:28 +000073def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
74 [SDNPOutFlag]>;
75def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
76 [SDNPHasChain]>;
Evan Cheng5ee4ccc2006-01-12 08:27:59 +000077def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
78 [SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000079
Evan Chenge3413162006-01-09 18:33:28 +000080def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
81 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000082
Evan Chenge3413162006-01-09 18:33:28 +000083def X86callseq_start :
84 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
85 [SDNPHasChain]>;
86def X86callseq_end :
87 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
88 [SDNPHasChain]>;
Evan Chengb077b842005-12-21 02:39:21 +000089
Evan Chenge3413162006-01-09 18:33:28 +000090def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
91 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +000092
Evan Chenge3413162006-01-09 18:33:28 +000093def X86fpget : SDNode<"X86ISD::FP_GET_RESULT", SDTX86FpGet,
94 [SDNPHasChain, SDNPInFlag]>;
95def X86fpset : SDNode<"X86ISD::FP_SET_RESULT", SDTX86FpSet,
96 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000097
Evan Chenge3413162006-01-09 18:33:28 +000098def X86fld : SDNode<"X86ISD::FLD", SDTX86Fld,
99 [SDNPHasChain]>;
100def X86fst : SDNode<"X86ISD::FST", SDTX86Fst,
101 [SDNPHasChain]>;
Evan Chengf7100622006-01-10 22:22:02 +0000102def X86fild64m : SDNode<"X86ISD::FILD64m", SDTX86Fild64m,
103 [SDNPHasChain]>;
Evan Chenge3413162006-01-09 18:33:28 +0000104
Evan Cheng67f92a72006-01-11 22:15:48 +0000105def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
106 [SDNPHasChain, SDNPInFlag]>;
107def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
108 [SDNPHasChain, SDNPInFlag]>;
109
Evan Chenge3413162006-01-09 18:33:28 +0000110def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
111 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000112
Evan Chengaed7c722005-12-17 01:24:02 +0000113//===----------------------------------------------------------------------===//
114// X86 Operand Definitions.
115//
116
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000117// *mem - Operand definitions for the funky X86 addressing mode operands.
118//
Chris Lattner45432512005-12-17 19:47:05 +0000119class X86MemOperand<string printMethod> : Operand<i32> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000120 let PrintMethod = printMethod;
Chris Lattner6adaf792005-11-19 07:01:30 +0000121 let NumMIOperands = 4;
122 let MIOperandInfo = (ops R32, i8imm, R32, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000123}
Nate Begeman391c5d22005-11-30 18:54:35 +0000124
Chris Lattner45432512005-12-17 19:47:05 +0000125def i8mem : X86MemOperand<"printi8mem">;
126def i16mem : X86MemOperand<"printi16mem">;
127def i32mem : X86MemOperand<"printi32mem">;
128def i64mem : X86MemOperand<"printi64mem">;
129def f32mem : X86MemOperand<"printf32mem">;
130def f64mem : X86MemOperand<"printf64mem">;
131def f80mem : X86MemOperand<"printf80mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000132
Nate Begeman16b04f32005-07-15 00:38:55 +0000133def SSECC : Operand<i8> {
134 let PrintMethod = "printSSECC";
135}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000136
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000137// A couple of more descriptive operand definitions.
138// 16-bits but only 8 bits are significant.
139def i16i8imm : Operand<i16>;
140// 32-bits but only 8 bits are significant.
141def i32i8imm : Operand<i32>;
142
Chris Lattnere4ead0c2004-08-11 06:59:12 +0000143// PCRelative calls need special operand formatting.
144let PrintMethod = "printCallOperand" in
145 def calltarget : Operand<i32>;
146
Evan Chengd35b8c12005-12-04 08:19:43 +0000147// Branch targets have OtherVT type.
148def brtarget : Operand<OtherVT>;
149
Evan Chengaed7c722005-12-17 01:24:02 +0000150//===----------------------------------------------------------------------===//
151// X86 Complex Pattern Definitions.
152//
153
Evan Chengec693f72005-12-08 02:01:35 +0000154// Define X86 specific addressing mode.
Evan Cheng670fd8f2005-12-08 02:15:07 +0000155def addr : ComplexPattern<i32, 4, "SelectAddr", []>;
Evan Cheng502c5bb2005-12-15 08:31:04 +0000156def leaaddr : ComplexPattern<i32, 4, "SelectLEAAddr",
Evan Cheng002fe9b2006-01-12 07:56:47 +0000157 [add, frameindex, constpool]>;
Evan Chengec693f72005-12-08 02:01:35 +0000158
Evan Chengaed7c722005-12-17 01:24:02 +0000159//===----------------------------------------------------------------------===//
160// X86 Instruction Format Definitions.
161//
162
Chris Lattner1cca5e32003-08-03 21:54:21 +0000163// Format specifies the encoding used by the instruction. This is part of the
164// ad-hoc solution used to emit machine instruction encodings by our machine
165// code emitter.
166class Format<bits<5> val> {
167 bits<5> Value = val;
168}
169
170def Pseudo : Format<0>; def RawFrm : Format<1>;
171def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
172def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
173def MRMSrcMem : Format<6>;
Alkis Evlogimenos169584e2004-02-27 18:55:12 +0000174def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
175def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
176def MRM6r : Format<22>; def MRM7r : Format<23>;
177def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
178def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
179def MRM6m : Format<30>; def MRM7m : Format<31>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000180
Evan Chengaed7c722005-12-17 01:24:02 +0000181//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000182// X86 Instruction Predicate Definitions.
183def HasSSE1 : Predicate<"X86Vector >= SSE">;
184def HasSSE2 : Predicate<"X86Vector >= SSE2">;
185def HasSSE3 : Predicate<"X86Vector >= SSE3">;
Evan Cheng38bcbaf2005-12-23 07:31:11 +0000186def FPStack : Predicate<"X86Vector < SSE2">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000187
188//===----------------------------------------------------------------------===//
Evan Chengaed7c722005-12-17 01:24:02 +0000189// X86 specific pattern fragments.
190//
191
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000192// ImmType - This specifies the immediate type used by an instruction. This is
Chris Lattner1cca5e32003-08-03 21:54:21 +0000193// part of the ad-hoc solution used to emit machine instruction encodings by our
194// machine code emitter.
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000195class ImmType<bits<2> val> {
196 bits<2> Value = val;
197}
198def NoImm : ImmType<0>;
199def Imm8 : ImmType<1>;
200def Imm16 : ImmType<2>;
201def Imm32 : ImmType<3>;
202
Chris Lattner1cca5e32003-08-03 21:54:21 +0000203// FPFormat - This specifies what form this FP instruction has. This is used by
204// the Floating-Point stackifier pass.
205class FPFormat<bits<3> val> {
206 bits<3> Value = val;
207}
208def NotFP : FPFormat<0>;
209def ZeroArgFP : FPFormat<1>;
210def OneArgFP : FPFormat<2>;
211def OneArgFPRW : FPFormat<3>;
212def TwoArgFP : FPFormat<4>;
Chris Lattnerab8decc2004-06-11 04:41:24 +0000213def CompareFP : FPFormat<5>;
214def CondMovFP : FPFormat<6>;
215def SpecialFP : FPFormat<7>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000216
217
Chris Lattner3a173df2004-10-03 20:35:00 +0000218class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
219 : Instruction {
Chris Lattnerc8f45872003-08-04 04:59:56 +0000220 let Namespace = "X86";
Chris Lattner1cca5e32003-08-03 21:54:21 +0000221
Chris Lattner1cca5e32003-08-03 21:54:21 +0000222 bits<8> Opcode = opcod;
223 Format Form = f;
224 bits<5> FormBits = Form.Value;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000225 ImmType ImmT = i;
226 bits<2> ImmTypeBits = ImmT.Value;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000227
Chris Lattnerc96bb812004-08-11 07:12:04 +0000228 dag OperandList = ops;
229 string AsmString = AsmStr;
230
John Criswell4ffff9e2004-04-08 20:31:47 +0000231 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000232 // Attributes specific to X86 instructions...
John Criswell4ffff9e2004-04-08 20:31:47 +0000233 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000234 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
John Criswell4ffff9e2004-04-08 20:31:47 +0000235
Chris Lattner1cca5e32003-08-03 21:54:21 +0000236 bits<4> Prefix = 0; // Which prefix byte does this inst have?
237 FPFormat FPForm; // What flavor of FP instruction is this?
238 bits<3> FPFormBits = 0;
239}
240
241class Imp<list<Register> uses, list<Register> defs> {
242 list<Register> Uses = uses;
243 list<Register> Defs = defs;
244}
245
246
247// Prefix byte classes which are used to indicate to the ad-hoc machine code
248// emitter that various prefix bytes are required.
249class OpSize { bit hasOpSizePrefix = 1; }
250class TB { bits<4> Prefix = 1; }
Chris Lattner915e5e52004-02-12 17:53:22 +0000251class REP { bits<4> Prefix = 2; }
252class D8 { bits<4> Prefix = 3; }
253class D9 { bits<4> Prefix = 4; }
254class DA { bits<4> Prefix = 5; }
255class DB { bits<4> Prefix = 6; }
256class DC { bits<4> Prefix = 7; }
257class DD { bits<4> Prefix = 8; }
258class DE { bits<4> Prefix = 9; }
259class DF { bits<4> Prefix = 10; }
Nate Begemanf1702ac2005-06-27 21:20:31 +0000260class XD { bits<4> Prefix = 11; }
261class XS { bits<4> Prefix = 12; }
Chris Lattner1cca5e32003-08-03 21:54:21 +0000262
263
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000264//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000265// Pattern fragments...
266//
Evan Chengd9558e02006-01-06 00:43:03 +0000267
268// X86 specific condition code. These correspond to CondCode in
269// X86ISelLowering.h. They must be kept in synch.
270def X86_COND_A : PatLeaf<(i8 0)>;
271def X86_COND_AE : PatLeaf<(i8 1)>;
272def X86_COND_B : PatLeaf<(i8 2)>;
273def X86_COND_BE : PatLeaf<(i8 3)>;
274def X86_COND_E : PatLeaf<(i8 4)>;
275def X86_COND_G : PatLeaf<(i8 5)>;
276def X86_COND_GE : PatLeaf<(i8 6)>;
277def X86_COND_L : PatLeaf<(i8 7)>;
278def X86_COND_LE : PatLeaf<(i8 8)>;
279def X86_COND_NE : PatLeaf<(i8 9)>;
280def X86_COND_NO : PatLeaf<(i8 10)>;
281def X86_COND_NP : PatLeaf<(i8 11)>;
282def X86_COND_NS : PatLeaf<(i8 12)>;
283def X86_COND_O : PatLeaf<(i8 13)>;
284def X86_COND_P : PatLeaf<(i8 14)>;
285def X86_COND_S : PatLeaf<(i8 15)>;
286
Evan Cheng9b6b6422005-12-13 00:14:11 +0000287def i16immSExt8 : PatLeaf<(i16 imm), [{
288 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000289 // sign extended field.
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000290 return (int)N->getValue() == (signed char)N->getValue();
291}]>;
292
Evan Cheng9b6b6422005-12-13 00:14:11 +0000293def i32immSExt8 : PatLeaf<(i32 imm), [{
294 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000295 // sign extended field.
296 return (int)N->getValue() == (signed char)N->getValue();
297}]>;
298
Evan Cheng9b6b6422005-12-13 00:14:11 +0000299def i16immZExt8 : PatLeaf<(i16 imm), [{
300 // i16immZExt8 predicate - True if the 16-bit immediate fits in a 8-bit zero
Evan Chengb3558542005-12-13 00:01:09 +0000301 // extended field.
Chris Lattner3d36a9f2005-12-05 02:40:25 +0000302 return (unsigned)N->getValue() == (unsigned char)N->getValue();
303}]>;
304
Evan Cheng650d6882006-01-05 02:08:37 +0000305def fp32imm0 : PatLeaf<(f32 fpimm), [{
306 return N->isExactlyValue(+0.0);
307}]>;
308
309def fp64imm0 : PatLeaf<(f64 fpimm), [{
310 return N->isExactlyValue(+0.0);
311}]>;
312
313def fp64immneg0 : PatLeaf<(f64 fpimm), [{
314 return N->isExactlyValue(-0.0);
315}]>;
316
317def fp64imm1 : PatLeaf<(f64 fpimm), [{
318 return N->isExactlyValue(+1.0);
319}]>;
320
321def fp64immneg1 : PatLeaf<(f64 fpimm), [{
322 return N->isExactlyValue(-1.0);
323}]>;
324
Evan Cheng605c4152005-12-13 01:57:51 +0000325// Helper fragments for loads.
Evan Cheng7a7e8372005-12-14 02:22:27 +0000326def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
327def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
328def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000329def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
330def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000331
332def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i1))>;
333def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i1))>;
334def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i8))>;
335def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i8))>;
336def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i16))>;
337
338def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i1))>;
339def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i1))>;
340def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i8))>;
341def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i8))>;
342def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i16))>;
343
Evan Cheng38bcbaf2005-12-23 07:31:11 +0000344def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extload node:$ptr, i1))>;
345def extloadf64f32 : PatFrag<(ops node:$ptr), (f64 (extload node:$ptr, f32))>;
Evan Cheng605c4152005-12-13 01:57:51 +0000346
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000347//===----------------------------------------------------------------------===//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000348// Instruction templates...
349
Evan Chengf0701842005-11-29 19:38:52 +0000350class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
351 : X86Inst<o, f, NoImm, ops, asm> {
352 let Pattern = pattern;
353}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000354class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
355 : X86Inst<o, f, Imm8 , ops, asm> {
356 let Pattern = pattern;
357}
Chris Lattner78432fe2005-11-17 02:01:55 +0000358class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
359 : X86Inst<o, f, Imm16, ops, asm> {
360 let Pattern = pattern;
361}
Chris Lattner7a125372005-11-16 22:59:19 +0000362class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
363 : X86Inst<o, f, Imm32, ops, asm> {
364 let Pattern = pattern;
365}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000366
Chris Lattner1cca5e32003-08-03 21:54:21 +0000367//===----------------------------------------------------------------------===//
368// Instruction list...
369//
370
Evan Cheng4a460802006-01-11 00:33:36 +0000371// Pseudo-instructions:
Evan Chengf0701842005-11-29 19:38:52 +0000372def PHI : I<0, Pseudo, (ops variable_ops), "PHINODE", []>; // PHI node.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000373
Evan Chengd90eb7f2006-01-05 00:27:02 +0000374def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
Evan Chenge3413162006-01-09 18:33:28 +0000375 [(X86callseq_start imm:$amt)]>;
Chris Lattner43ef1312005-09-14 21:10:24 +0000376def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
Evan Chengd90eb7f2006-01-05 00:27:02 +0000377 "#ADJCALLSTACKUP",
Evan Chenge3413162006-01-09 18:33:28 +0000378 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
Evan Chengf0701842005-11-29 19:38:52 +0000379def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
380def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
Evan Cheng510e4782006-01-09 23:10:28 +0000381def IMPLICIT_DEF_R8 : I<0, Pseudo, (ops R8:$dst),
382 "#IMPLICIT_DEF $dst",
383 [(set R8:$dst, (undef))]>;
384def IMPLICIT_DEF_R16 : I<0, Pseudo, (ops R16:$dst),
385 "#IMPLICIT_DEF $dst",
386 [(set R16:$dst, (undef))]>;
387def IMPLICIT_DEF_R32 : I<0, Pseudo, (ops R32:$dst),
388 "#IMPLICIT_DEF $dst",
389 [(set R32:$dst, (undef))]>;
Evan Chengaaca22c2006-01-10 20:26:56 +0000390def IMPLICIT_DEF_FR32 : I<0, Pseudo, (ops FR32:$dst),
391 "#IMPLICIT_DEF $dst",
392 [(set FR32:$dst, (undef))]>, Requires<[HasSSE2]>;
393def IMPLICIT_DEF_FR64 : I<0, Pseudo, (ops FR64:$dst),
394 "#IMPLICIT_DEF $dst",
395 [(set FR64:$dst, (undef))]>, Requires<[HasSSE2]>;
396
Evan Cheng510e4782006-01-09 23:10:28 +0000397
Evan Cheng4a460802006-01-11 00:33:36 +0000398// CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the
399// scheduler into a branch sequence.
400let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
401 def CMOV_FR32 : I<0, Pseudo,
402 (ops FR32:$dst, FR32:$t, FR32:$f, i8imm:$cond),
403 "#CMOV PSEUDO!",
404 [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond,
405 STATUS))]>;
406 def CMOV_FR64 : I<0, Pseudo,
407 (ops FR64:$dst, FR64:$t, FR64:$f, i8imm:$cond),
408 "#CMOV PSEUDO!",
409 [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond,
410 STATUS))]>;
411}
412
Alkis Evlogimenose0bb3e72003-12-20 16:22:59 +0000413let isTerminator = 1 in
414 let Defs = [FP0, FP1, FP2, FP3, FP4, FP5, FP6] in
Evan Chengf0701842005-11-29 19:38:52 +0000415 def FP_REG_KILL : I<0, Pseudo, (ops), "#FP_REG_KILL", []>;
Chris Lattner62cce392004-07-31 02:10:53 +0000416
Evan Cheng4a460802006-01-11 00:33:36 +0000417
418// Nop
419def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
420
Chris Lattner1cca5e32003-08-03 21:54:21 +0000421//===----------------------------------------------------------------------===//
422// Control Flow Instructions...
423//
424
Chris Lattner1be48112005-05-13 17:56:48 +0000425// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000426let isTerminator = 1, isReturn = 1, isBarrier = 1,
427 hasCtrlDep = 1, noResults = 1 in {
Evan Chenge3413162006-01-09 18:33:28 +0000428 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
429 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
430 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000431}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000432
433// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng2b4ea792005-12-26 09:11:45 +0000434let isBranch = 1, isTerminator = 1, noResults = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000435 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
436 I<opcode, RawFrm, ops, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000437
Evan Cheng4a460802006-01-11 00:33:36 +0000438// Conditional branches
Chris Lattner62cce392004-07-31 02:10:53 +0000439let isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000440 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000441
442def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000443 [(X86brcond bb:$dst, X86_COND_E, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000444def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000445 [(X86brcond bb:$dst, X86_COND_NE, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000446def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000447 [(X86brcond bb:$dst, X86_COND_L, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000448def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000449 [(X86brcond bb:$dst, X86_COND_LE, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000450def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000451 [(X86brcond bb:$dst, X86_COND_G, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000452def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000453 [(X86brcond bb:$dst, X86_COND_GE, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000454
Evan Chengd35b8c12005-12-04 08:19:43 +0000455def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000456 [(X86brcond bb:$dst, X86_COND_B, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000457def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000458 [(X86brcond bb:$dst, X86_COND_BE, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000459def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000460 [(X86brcond bb:$dst, X86_COND_A, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000461def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000462 [(X86brcond bb:$dst, X86_COND_AE, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000463
Evan Chengd9558e02006-01-06 00:43:03 +0000464def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
465 [(X86brcond bb:$dst, X86_COND_S, STATUS)]>, Imp<[STATUS],[]>, TB;
466def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
467 [(X86brcond bb:$dst, X86_COND_NS, STATUS)]>, Imp<[STATUS],[]>, TB;
468def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
469 [(X86brcond bb:$dst, X86_COND_P, STATUS)]>, Imp<[STATUS],[]>, TB;
470def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
471 [(X86brcond bb:$dst, X86_COND_NP, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000472def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
473 [(X86brcond bb:$dst, X86_COND_O, STATUS)]>, Imp<[STATUS],[]>, TB;
474def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
475 [(X86brcond bb:$dst, X86_COND_NO, STATUS)]>, Imp<[STATUS],[]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000476
477//===----------------------------------------------------------------------===//
478// Call Instructions...
479//
Evan Chenge3413162006-01-09 18:33:28 +0000480let isCall = 1, noResults = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000481 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000482 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Nate Begeman16b04f32005-07-15 00:38:55 +0000483 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengd90eb7f2006-01-05 00:27:02 +0000484 def CALLpcrel32 : I<0xE8, RawFrm, (ops calltarget:$dst), "call $dst",
485 []>;
486 def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst",
Evan Chenge3413162006-01-09 18:33:28 +0000487 [(X86call R32:$dst)]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000488 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst), "call {*}$dst",
Evan Chenge3413162006-01-09 18:33:28 +0000489 [(X86call (loadi32 addr:$dst))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000490 }
491
Chris Lattner1e9448b2005-05-15 03:10:37 +0000492// Tail call stuff.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000493let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000494 def TAILJMPd : IBr<0xE9, (ops calltarget:$dst), "jmp $dst # TAIL CALL", []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000495let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000496 def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000497let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000498 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
499 "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000500
501// ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
502// way, except that it is marked as being a terminator. This causes the epilog
503// inserter to insert reloads of callee saved registers BEFORE this. We need
504// this until we have a more accurate way of tracking where the stack pointer is
505// within a function.
506let isTerminator = 1, isTwoAddress = 1 in
507 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000508 "add{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000509
Chris Lattner1cca5e32003-08-03 21:54:21 +0000510//===----------------------------------------------------------------------===//
511// Miscellaneous Instructions...
512//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000513def LEAVE : I<0xC9, RawFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000514 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000515def POP32r : I<0x58, AddRegFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000516 (ops R32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000517
Chris Lattner3a173df2004-10-03 20:35:00 +0000518let isTwoAddress = 1 in // R32 = bswap R32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000519 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000520 (ops R32:$dst, R32:$src), "bswap{l} $dst", []>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000521
Chris Lattner30bf2d82004-08-10 20:17:41 +0000522def XCHG8rr : I<0x86, MRMDestReg, // xchg R8, R8
Chris Lattner3a173df2004-10-03 20:35:00 +0000523 (ops R8:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000524 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000525def XCHG16rr : I<0x87, MRMDestReg, // xchg R16, R16
Chris Lattner3a173df2004-10-03 20:35:00 +0000526 (ops R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000527 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000528def XCHG32rr : I<0x87, MRMDestReg, // xchg R32, R32
Chris Lattner3a173df2004-10-03 20:35:00 +0000529 (ops R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000530 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattnerfc752712004-08-01 09:52:59 +0000531
Chris Lattner3a173df2004-10-03 20:35:00 +0000532def XCHG8mr : I<0x86, MRMDestMem,
533 (ops i8mem:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000534 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000535def XCHG16mr : I<0x87, MRMDestMem,
536 (ops i16mem:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000537 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000538def XCHG32mr : I<0x87, MRMDestMem,
539 (ops i32mem:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000540 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000541def XCHG8rm : I<0x86, MRMSrcMem,
542 (ops R8:$src1, i8mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000543 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000544def XCHG16rm : I<0x87, MRMSrcMem,
545 (ops R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000546 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000547def XCHG32rm : I<0x87, MRMSrcMem,
548 (ops R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000549 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000550
Chris Lattner3a173df2004-10-03 20:35:00 +0000551def LEA16r : I<0x8D, MRMSrcMem,
552 (ops R16:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000553 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000554def LEA32r : I<0x8D, MRMSrcMem,
555 (ops R32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000556 "lea{l} {$src|$dst}, {$dst|$src}",
557 [(set R32:$dst, leaaddr:$src)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000558
Evan Cheng67f92a72006-01-11 22:15:48 +0000559def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
560 [(X86rep_movs i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000561 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000562def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
563 [(X86rep_movs i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000564 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Cheng67f92a72006-01-11 22:15:48 +0000565def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsd|rep movsd}",
566 [(X86rep_movs i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000567 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Chris Lattner915e5e52004-02-12 17:53:22 +0000568
Evan Cheng67f92a72006-01-11 22:15:48 +0000569def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
570 [(X86rep_stos i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000571 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000572def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
573 [(X86rep_stos i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000574 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Cheng67f92a72006-01-11 22:15:48 +0000575def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
576 [(X86rep_stos i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000577 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
578
Chris Lattnerb89abef2004-02-14 04:45:37 +0000579
Chris Lattner1cca5e32003-08-03 21:54:21 +0000580//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000581// Input/Output Instructions...
582//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000583def IN8rr : I<0xEC, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000584 "in{b} {%dx, %al|%AL, %DX}",
585 [(set AL, (readport DX))]>, Imp<[DX], [AL]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000586def IN16rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000587 "in{w} {%dx, %ax|%AX, %DX}",
588 [(set AX, (readport DX))]>, Imp<[DX], [AX]>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000589def IN32rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000590 "in{l} {%dx, %eax|%EAX, %DX}",
591 [(set EAX, (readport DX))]>, Imp<[DX],[EAX]>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000592
Evan Chenga5386b02005-12-20 07:38:38 +0000593def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
594 "in{b} {$port, %al|%AL, $port}",
595 [(set AL, (readport i16immZExt8:$port))]>,
596 Imp<[], [AL]>;
597def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
598 "in{w} {$port, %ax|%AX, $port}",
599 [(set AX, (readport i16immZExt8:$port))]>,
600 Imp<[], [AX]>, OpSize;
601def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
602 "in{l} {$port, %eax|%EAX, $port}",
603 [(set EAX, (readport i16immZExt8:$port))]>,
604 Imp<[],[EAX]>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000605
Evan Cheng8d202232005-12-05 23:09:43 +0000606def OUT8rr : I<0xEE, RawFrm, (ops),
607 "out{b} {%al, %dx|%DX, %AL}",
608 [(writeport AL, DX)]>, Imp<[DX, AL], []>;
609def OUT16rr : I<0xEF, RawFrm, (ops),
610 "out{w} {%ax, %dx|%DX, %AX}",
611 [(writeport AX, DX)]>, Imp<[DX, AX], []>, OpSize;
612def OUT32rr : I<0xEF, RawFrm, (ops),
613 "out{l} {%eax, %dx|%DX, %EAX}",
614 [(writeport EAX, DX)]>, Imp<[DX, EAX], []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000615
Evan Cheng8d202232005-12-05 23:09:43 +0000616def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
617 "out{b} {%al, $port|$port, %AL}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000618 [(writeport AL, i16immZExt8:$port)]>,
Evan Chenga5386b02005-12-20 07:38:38 +0000619 Imp<[AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000620def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
621 "out{w} {%ax, $port|$port, %AX}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000622 [(writeport AX, i16immZExt8:$port)]>,
Evan Chenga5386b02005-12-20 07:38:38 +0000623 Imp<[AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000624def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
625 "out{l} {%eax, $port|$port, %EAX}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000626 [(writeport EAX, i16immZExt8:$port)]>,
Evan Chenga5386b02005-12-20 07:38:38 +0000627 Imp<[EAX], []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000628
629//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000630// Move Instructions...
631//
Chris Lattner3a173df2004-10-03 20:35:00 +0000632def MOV8rr : I<0x88, MRMDestReg, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000633 "mov{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000634def MOV16rr : I<0x89, MRMDestReg, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000635 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000636def MOV32rr : I<0x89, MRMDestReg, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000637 "mov{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000638def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops R8 :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000639 "mov{b} {$src, $dst|$dst, $src}",
640 [(set R8:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000641def MOV16ri : Ii16<0xB8, AddRegFrm, (ops R16:$dst, i16imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000642 "mov{w} {$src, $dst|$dst, $src}",
643 [(set R16:$dst, imm:$src)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000644def MOV32ri : Ii32<0xB8, AddRegFrm, (ops R32:$dst, i32imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000645 "mov{l} {$src, $dst|$dst, $src}",
646 [(set R32:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000647def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000648 "mov{b} {$src, $dst|$dst, $src}",
649 [(store (i8 imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000650def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000651 "mov{w} {$src, $dst|$dst, $src}",
652 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000653def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000654 "mov{l} {$src, $dst|$dst, $src}",
655 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000656
Chris Lattner3a173df2004-10-03 20:35:00 +0000657def MOV8rm : I<0x8A, MRMSrcMem, (ops R8 :$dst, i8mem :$src),
Evan Chengec693f72005-12-08 02:01:35 +0000658 "mov{b} {$src, $dst|$dst, $src}",
659 [(set R8:$dst, (load addr:$src))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000660def MOV16rm : I<0x8B, MRMSrcMem, (ops R16:$dst, i16mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000661 "mov{w} {$src, $dst|$dst, $src}",
662 [(set R16:$dst, (load addr:$src))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000663def MOV32rm : I<0x8B, MRMSrcMem, (ops R32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000664 "mov{l} {$src, $dst|$dst, $src}",
665 [(set R32:$dst, (load addr:$src))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000666
Chris Lattner3a173df2004-10-03 20:35:00 +0000667def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, R8 :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000668 "mov{b} {$src, $dst|$dst, $src}",
669 [(store R8:$src, addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000670def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, R16:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000671 "mov{w} {$src, $dst|$dst, $src}",
672 [(store R16:$src, addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000673def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, R32:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000674 "mov{l} {$src, $dst|$dst, $src}",
675 [(store R32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000676
Chris Lattner1cca5e32003-08-03 21:54:21 +0000677//===----------------------------------------------------------------------===//
678// Fixed-Register Multiplication and Division Instructions...
679//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000680
Chris Lattnerc8f45872003-08-04 04:59:56 +0000681// Extra precision multiplication
Evan Chengf0701842005-11-29 19:38:52 +0000682def MUL8r : I<0xF6, MRM4r, (ops R8:$src), "mul{b} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000683 Imp<[AL],[AX]>; // AL,AH = AL*R8
Evan Chengf0701842005-11-29 19:38:52 +0000684def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul{w} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000685 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
Evan Chengf0701842005-11-29 19:38:52 +0000686def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul{l} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000687 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
Chris Lattner57a02302004-08-11 04:31:00 +0000688def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000689 "mul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner57a02302004-08-11 04:31:00 +0000690def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000691 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
692 OpSize; // AX,DX = AX*[mem16]
Chris Lattner57a02302004-08-11 04:31:00 +0000693def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000694 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000695
Evan Chengf0701842005-11-29 19:38:52 +0000696def IMUL8r : I<0xF6, MRM5r, (ops R8:$src), "imul{b} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000697 Imp<[AL],[AX]>; // AL,AH = AL*R8
Evan Chengf0701842005-11-29 19:38:52 +0000698def IMUL16r : I<0xF7, MRM5r, (ops R16:$src), "imul{w} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000699 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
Evan Chengf0701842005-11-29 19:38:52 +0000700def IMUL32r : I<0xF7, MRM5r, (ops R32:$src), "imul{l} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000701 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
702def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000703 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000704def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000705 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
706 OpSize; // AX,DX = AX*[mem16]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000707def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000708 "imul{l} $src", []>,
709 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000710
Chris Lattnerc8f45872003-08-04 04:59:56 +0000711// unsigned division/remainder
Chris Lattner3a173df2004-10-03 20:35:00 +0000712def DIV8r : I<0xF6, MRM6r, (ops R8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000713 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000714def DIV16r : I<0xF7, MRM6r, (ops R16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000715 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000716def DIV32r : I<0xF7, MRM6r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000717 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000718def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000719 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000720def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000721 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000722def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000723 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000724
Chris Lattnerfc752712004-08-01 09:52:59 +0000725// Signed division/remainder.
Chris Lattner3a173df2004-10-03 20:35:00 +0000726def IDIV8r : I<0xF6, MRM7r, (ops R8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000727 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000728def IDIV16r: I<0xF7, MRM7r, (ops R16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000729 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000730def IDIV32r: I<0xF7, MRM7r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000731 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000732def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000733 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000734def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000735 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000736def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000737 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattnerc8f45872003-08-04 04:59:56 +0000738
Chris Lattnerfc752712004-08-01 09:52:59 +0000739// Sign-extenders for division.
Chris Lattner3a173df2004-10-03 20:35:00 +0000740def CBW : I<0x98, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000741 "{cbtw|cbw}", []>, Imp<[AL],[AH]>; // AX = signext(AL)
Chris Lattner3a173df2004-10-03 20:35:00 +0000742def CWD : I<0x99, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000743 "{cwtd|cwd}", []>, Imp<[AX],[DX]>; // DX:AX = signext(AX)
Chris Lattner3a173df2004-10-03 20:35:00 +0000744def CDQ : I<0x99, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000745 "{cltd|cdq}", []>, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
Chris Lattnerfc752712004-08-01 09:52:59 +0000746
Chris Lattner1cca5e32003-08-03 21:54:21 +0000747
Chris Lattner1cca5e32003-08-03 21:54:21 +0000748//===----------------------------------------------------------------------===//
749// Two address Instructions...
750//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000751let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000752
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000753// Conditional moves
Chris Lattner3a173df2004-10-03 20:35:00 +0000754def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, R16 = R16
755 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000756 "cmovb {$src2, $dst|$dst, $src2}",
757 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000758 X86_COND_B, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000759 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000760def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, R16 = [mem16]
761 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000762 "cmovb {$src2, $dst|$dst, $src2}",
763 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000764 X86_COND_B, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000765 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000766def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, R32 = R32
767 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000768 "cmovb {$src2, $dst|$dst, $src2}",
769 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000770 X86_COND_B, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000771 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000772def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, R32 = [mem32]
773 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000774 "cmovb {$src2, $dst|$dst, $src2}",
775 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000776 X86_COND_B, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000777 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000778
Chris Lattner3a173df2004-10-03 20:35:00 +0000779def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, R16 = R16
780 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000781 "cmovae {$src2, $dst|$dst, $src2}",
782 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000783 X86_COND_AE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000784 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000785def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, R16 = [mem16]
786 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000787 "cmovae {$src2, $dst|$dst, $src2}",
788 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000789 X86_COND_AE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000790 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000791def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, R32 = R32
792 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000793 "cmovae {$src2, $dst|$dst, $src2}",
794 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000795 X86_COND_AE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000796 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000797def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, R32 = [mem32]
798 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000799 "cmovae {$src2, $dst|$dst, $src2}",
800 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000801 X86_COND_AE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000802 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000803
Chris Lattner3a173df2004-10-03 20:35:00 +0000804def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, R16 = R16
805 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000806 "cmove {$src2, $dst|$dst, $src2}",
807 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000808 X86_COND_E, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000809 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000810def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, R16 = [mem16]
811 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000812 "cmove {$src2, $dst|$dst, $src2}",
813 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000814 X86_COND_E, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000815 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000816def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, R32 = R32
817 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000818 "cmove {$src2, $dst|$dst, $src2}",
819 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000820 X86_COND_E, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000821 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000822def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, R32 = [mem32]
823 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000824 "cmove {$src2, $dst|$dst, $src2}",
825 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000826 X86_COND_E, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000827 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000828
Chris Lattner3a173df2004-10-03 20:35:00 +0000829def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, R16 = R16
830 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000831 "cmovne {$src2, $dst|$dst, $src2}",
832 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000833 X86_COND_NE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000834 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000835def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, R16 = [mem16]
836 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000837 "cmovne {$src2, $dst|$dst, $src2}",
838 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000839 X86_COND_NE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000840 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000841def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, R32 = R32
842 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000843 "cmovne {$src2, $dst|$dst, $src2}",
844 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000845 X86_COND_NE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000846 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000847def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, R32 = [mem32]
848 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000849 "cmovne {$src2, $dst|$dst, $src2}",
850 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000851 X86_COND_NE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000852 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000853
Chris Lattner3a173df2004-10-03 20:35:00 +0000854def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, R16 = R16
855 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000856 "cmovbe {$src2, $dst|$dst, $src2}",
857 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000858 X86_COND_BE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000859 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000860def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, R16 = [mem16]
861 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000862 "cmovbe {$src2, $dst|$dst, $src2}",
863 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000864 X86_COND_BE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000865 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000866def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, R32 = R32
867 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000868 "cmovbe {$src2, $dst|$dst, $src2}",
869 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000870 X86_COND_BE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000871 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000872def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, R32 = [mem32]
873 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000874 "cmovbe {$src2, $dst|$dst, $src2}",
875 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000876 X86_COND_BE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000877 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000878
Chris Lattner3a173df2004-10-03 20:35:00 +0000879def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, R16 = R16
880 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000881 "cmova {$src2, $dst|$dst, $src2}",
882 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000883 X86_COND_A, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000884 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000885def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, R16 = [mem16]
886 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000887 "cmova {$src2, $dst|$dst, $src2}",
888 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000889 X86_COND_A, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000890 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000891def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, R32 = R32
892 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000893 "cmova {$src2, $dst|$dst, $src2}",
894 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000895 X86_COND_A, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000896 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000897def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, R32 = [mem32]
898 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000899 "cmova {$src2, $dst|$dst, $src2}",
900 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000901 X86_COND_A, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000902 Imp<[STATUS],[]>, TB;
903
904def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, R16 = R16
905 (ops R16:$dst, R16:$src1, R16:$src2),
906 "cmovl {$src2, $dst|$dst, $src2}",
907 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000908 X86_COND_L, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000909 Imp<[STATUS],[]>, TB, OpSize;
910def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, R16 = [mem16]
911 (ops R16:$dst, R16:$src1, i16mem:$src2),
912 "cmovl {$src2, $dst|$dst, $src2}",
913 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000914 X86_COND_L, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000915 Imp<[STATUS],[]>, TB, OpSize;
916def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, R32 = R32
917 (ops R32:$dst, R32:$src1, R32:$src2),
918 "cmovl {$src2, $dst|$dst, $src2}",
919 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000920 X86_COND_L, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000921 Imp<[STATUS],[]>, TB;
922def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, R32 = [mem32]
923 (ops R32:$dst, R32:$src1, i32mem:$src2),
924 "cmovl {$src2, $dst|$dst, $src2}",
925 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000926 X86_COND_L, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000927 Imp<[STATUS],[]>, TB;
928
929def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, R16 = R16
930 (ops R16:$dst, R16:$src1, R16:$src2),
931 "cmovge {$src2, $dst|$dst, $src2}",
932 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000933 X86_COND_GE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000934 Imp<[STATUS],[]>, TB, OpSize;
935def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, R16 = [mem16]
936 (ops R16:$dst, R16:$src1, i16mem:$src2),
937 "cmovge {$src2, $dst|$dst, $src2}",
938 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000939 X86_COND_GE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000940 Imp<[STATUS],[]>, TB, OpSize;
941def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, R32 = R32
942 (ops R32:$dst, R32:$src1, R32:$src2),
943 "cmovge {$src2, $dst|$dst, $src2}",
944 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000945 X86_COND_GE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000946 Imp<[STATUS],[]>, TB;
947def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, R32 = [mem32]
948 (ops R32:$dst, R32:$src1, i32mem:$src2),
949 "cmovge {$src2, $dst|$dst, $src2}",
950 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000951 X86_COND_GE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000952 Imp<[STATUS],[]>, TB;
953
954def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, R16 = R16
955 (ops R16:$dst, R16:$src1, R16:$src2),
956 "cmovle {$src2, $dst|$dst, $src2}",
957 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000958 X86_COND_LE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000959 Imp<[STATUS],[]>, TB, OpSize;
960def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, R16 = [mem16]
961 (ops R16:$dst, R16:$src1, i16mem:$src2),
962 "cmovle {$src2, $dst|$dst, $src2}",
963 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000964 X86_COND_LE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000965 Imp<[STATUS],[]>, TB, OpSize;
966def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, R32 = R32
967 (ops R32:$dst, R32:$src1, R32:$src2),
968 "cmovle {$src2, $dst|$dst, $src2}",
969 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000970 X86_COND_LE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000971 Imp<[STATUS],[]>, TB;
972def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, R32 = [mem32]
973 (ops R32:$dst, R32:$src1, i32mem:$src2),
974 "cmovle {$src2, $dst|$dst, $src2}",
975 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000976 X86_COND_LE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000977 Imp<[STATUS],[]>, TB;
978
979def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, R16 = R16
980 (ops R16:$dst, R16:$src1, R16:$src2),
981 "cmovg {$src2, $dst|$dst, $src2}",
982 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000983 X86_COND_G, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000984 Imp<[STATUS],[]>, TB, OpSize;
985def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, R16 = [mem16]
986 (ops R16:$dst, R16:$src1, i16mem:$src2),
987 "cmovg {$src2, $dst|$dst, $src2}",
988 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000989 X86_COND_G, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000990 Imp<[STATUS],[]>, TB, OpSize;
991def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, R32 = R32
992 (ops R32:$dst, R32:$src1, R32:$src2),
993 "cmovg {$src2, $dst|$dst, $src2}",
994 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000995 X86_COND_G, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000996 Imp<[STATUS],[]>, TB;
997def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, R32 = [mem32]
998 (ops R32:$dst, R32:$src1, i32mem:$src2),
999 "cmovg {$src2, $dst|$dst, $src2}",
1000 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001001 X86_COND_G, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +00001002 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001003
Chris Lattner3a173df2004-10-03 20:35:00 +00001004def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, R16 = R16
1005 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001006 "cmovs {$src2, $dst|$dst, $src2}",
1007 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1008 X86_COND_S, STATUS))]>,
1009 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001010def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, R16 = [mem16]
1011 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001012 "cmovs {$src2, $dst|$dst, $src2}",
1013 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1014 X86_COND_S, STATUS))]>,
1015 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001016def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, R32 = R32
1017 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001018 "cmovs {$src2, $dst|$dst, $src2}",
1019 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1020 X86_COND_S, STATUS))]>,
1021 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001022def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, R32 = [mem32]
1023 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001024 "cmovs {$src2, $dst|$dst, $src2}",
1025 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1026 X86_COND_S, STATUS))]>,
1027 Imp<[STATUS],[]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001028
Chris Lattner3a173df2004-10-03 20:35:00 +00001029def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, R16 = R16
1030 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001031 "cmovns {$src2, $dst|$dst, $src2}",
1032 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1033 X86_COND_NS, STATUS))]>,
1034 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001035def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, R16 = [mem16]
1036 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001037 "cmovns {$src2, $dst|$dst, $src2}",
1038 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1039 X86_COND_NS, STATUS))]>,
1040 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001041def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, R32 = R32
1042 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001043 "cmovns {$src2, $dst|$dst, $src2}",
1044 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1045 X86_COND_NS, STATUS))]>,
1046 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001047def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, R32 = [mem32]
1048 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001049 "cmovns {$src2, $dst|$dst, $src2}",
1050 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1051 X86_COND_NS, STATUS))]>,
1052 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001053
Chris Lattner57fbfb52005-01-10 22:09:33 +00001054def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, R16 = R16
1055 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001056 "cmovp {$src2, $dst|$dst, $src2}",
1057 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1058 X86_COND_P, STATUS))]>,
1059 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001060def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, R16 = [mem16]
1061 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001062 "cmovp {$src2, $dst|$dst, $src2}",
1063 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1064 X86_COND_P, STATUS))]>,
1065 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001066def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, R32 = R32
1067 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001068 "cmovp {$src2, $dst|$dst, $src2}",
1069 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1070 X86_COND_P, STATUS))]>,
1071 Imp<[STATUS],[]>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001072def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, R32 = [mem32]
1073 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001074 "cmovp {$src2, $dst|$dst, $src2}",
1075 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1076 X86_COND_P, STATUS))]>,
1077 Imp<[STATUS],[]>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001078
Chris Lattner57fbfb52005-01-10 22:09:33 +00001079def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, R16 = R16
1080 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001081 "cmovnp {$src2, $dst|$dst, $src2}",
1082 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1083 X86_COND_NP, STATUS))]>,
1084 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001085def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, R16 = [mem16]
1086 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001087 "cmovnp {$src2, $dst|$dst, $src2}",
1088 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1089 X86_COND_NP, STATUS))]>,
1090 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001091def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, R32 = R32
1092 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001093 "cmovnp {$src2, $dst|$dst, $src2}",
1094 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1095 X86_COND_NP, STATUS))]>,
1096 Imp<[STATUS],[]>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001097def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, R32 = [mem32]
1098 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001099 "cmovnp {$src2, $dst|$dst, $src2}",
1100 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1101 X86_COND_NP, STATUS))]>,
1102 Imp<[STATUS],[]>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001103
1104
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001105// unary instructions
Evan Chengf0701842005-11-29 19:38:52 +00001106def NEG8r : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg{b} $dst",
1107 [(set R8:$dst, (ineg R8:$src))]>;
1108def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg{w} $dst",
1109 [(set R16:$dst, (ineg R16:$src))]>, OpSize;
1110def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg{l} $dst",
1111 [(set R32:$dst, (ineg R32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001112let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001113 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001114 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001115 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001116 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001117 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001118 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1119
Chris Lattner57a02302004-08-11 04:31:00 +00001120}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001121
Evan Chengf0701842005-11-29 19:38:52 +00001122def NOT8r : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not{b} $dst",
1123 [(set R8:$dst, (not R8:$src))]>;
1124def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not{w} $dst",
1125 [(set R16:$dst, (not R16:$src))]>, OpSize;
1126def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not{l} $dst",
1127 [(set R32:$dst, (not R32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001128let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001129 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001130 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001131 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001132 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001133 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001134 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001135}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001136
Evan Chengb51a0592005-12-10 00:48:20 +00001137// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Chengf0701842005-11-29 19:38:52 +00001138def INC8r : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc{b} $dst",
1139 [(set R8:$dst, (add R8:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001140let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengf0701842005-11-29 19:38:52 +00001141def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc{w} $dst",
1142 [(set R16:$dst, (add R16:$src, 1))]>, OpSize;
1143def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc{l} $dst",
1144 [(set R32:$dst, (add R32:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001145}
Chris Lattner57a02302004-08-11 04:31:00 +00001146let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001147 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001148 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001149 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001150 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001151 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001152 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001153}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001154
Evan Chengb51a0592005-12-10 00:48:20 +00001155def DEC8r : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec{b} $dst",
1156 [(set R8:$dst, (add R8:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001157let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb51a0592005-12-10 00:48:20 +00001158def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec{w} $dst",
1159 [(set R16:$dst, (add R16:$src, -1))]>, OpSize;
1160def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec{l} $dst",
1161 [(set R32:$dst, (add R32:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001162}
Chris Lattner57a02302004-08-11 04:31:00 +00001163
1164let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001165 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001166 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001167 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001168 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001169 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001170 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001171}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001172
1173// Logical operators...
Chris Lattnercc65bee2005-01-02 02:35:46 +00001174let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001175def AND8rr : I<0x20, MRMDestReg,
1176 (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001177 "and{b} {$src2, $dst|$dst, $src2}",
1178 [(set R8:$dst, (and R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001179def AND16rr : I<0x21, MRMDestReg,
1180 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001181 "and{w} {$src2, $dst|$dst, $src2}",
1182 [(set R16:$dst, (and R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001183def AND32rr : I<0x21, MRMDestReg,
1184 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001185 "and{l} {$src2, $dst|$dst, $src2}",
1186 [(set R32:$dst, (and R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001187}
Chris Lattner57a02302004-08-11 04:31:00 +00001188
Chris Lattner3a173df2004-10-03 20:35:00 +00001189def AND8rm : I<0x22, MRMSrcMem,
1190 (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001191 "and{b} {$src2, $dst|$dst, $src2}",
1192 [(set R8:$dst, (and R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001193def AND16rm : I<0x23, MRMSrcMem,
1194 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001195 "and{w} {$src2, $dst|$dst, $src2}",
1196 [(set R16:$dst, (and R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001197def AND32rm : I<0x23, MRMSrcMem,
1198 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001199 "and{l} {$src2, $dst|$dst, $src2}",
1200 [(set R32:$dst, (and R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001201
Chris Lattner3a173df2004-10-03 20:35:00 +00001202def AND8ri : Ii8<0x80, MRM4r,
1203 (ops R8 :$dst, R8 :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001204 "and{b} {$src2, $dst|$dst, $src2}",
1205 [(set R8:$dst, (and R8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001206def AND16ri : Ii16<0x81, MRM4r,
1207 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001208 "and{w} {$src2, $dst|$dst, $src2}",
1209 [(set R16:$dst, (and R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001210def AND32ri : Ii32<0x81, MRM4r,
1211 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001212 "and{l} {$src2, $dst|$dst, $src2}",
1213 [(set R32:$dst, (and R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001214def AND16ri8 : Ii8<0x83, MRM4r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001215 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1216 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001217 [(set R16:$dst, (and R16:$src1, i16immSExt8:$src2))]>,
1218 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001219def AND32ri8 : Ii8<0x83, MRM4r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001220 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1221 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001222 [(set R32:$dst, (and R32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001223
1224let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001225 def AND8mr : I<0x20, MRMDestMem,
1226 (ops i8mem :$dst, R8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001227 "and{b} {$src, $dst|$dst, $src}",
1228 [(store (and (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001229 def AND16mr : I<0x21, MRMDestMem,
1230 (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001231 "and{w} {$src, $dst|$dst, $src}",
1232 [(store (and (load addr:$dst), R16:$src), addr:$dst)]>,
1233 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001234 def AND32mr : I<0x21, MRMDestMem,
1235 (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001236 "and{l} {$src, $dst|$dst, $src}",
1237 [(store (and (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001238 def AND8mi : Ii8<0x80, MRM4m,
1239 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001240 "and{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001241 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001242 def AND16mi : Ii16<0x81, MRM4m,
1243 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001244 "and{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001245 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001246 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001247 def AND32mi : Ii32<0x81, MRM4m,
1248 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001249 "and{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001250 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001251 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001252 (ops i16mem:$dst, i16i8imm :$src),
1253 "and{w} {$src, $dst|$dst, $src}",
1254 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1255 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001256 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001257 (ops i32mem:$dst, i32i8imm :$src),
1258 "and{l} {$src, $dst|$dst, $src}",
1259 [(store (add (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001260}
1261
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001262
Chris Lattnercc65bee2005-01-02 02:35:46 +00001263let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Chris Lattner36b68902004-08-10 21:21:30 +00001264def OR8rr : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001265 "or{b} {$src2, $dst|$dst, $src2}",
1266 [(set R8:$dst, (or R8:$src1, R8:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001267def OR16rr : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001268 "or{w} {$src2, $dst|$dst, $src2}",
1269 [(set R16:$dst, (or R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001270def OR32rr : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001271 "or{l} {$src2, $dst|$dst, $src2}",
1272 [(set R32:$dst, (or R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001273}
Chris Lattner57a02302004-08-11 04:31:00 +00001274def OR8rm : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001275 "or{b} {$src2, $dst|$dst, $src2}",
1276 [(set R8:$dst, (or R8:$src1, (load addr:$src2)))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001277def OR16rm : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001278 "or{w} {$src2, $dst|$dst, $src2}",
1279 [(set R16:$dst, (or R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001280def OR32rm : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001281 "or{l} {$src2, $dst|$dst, $src2}",
1282 [(set R32:$dst, (or R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001283
Chris Lattner36b68902004-08-10 21:21:30 +00001284def OR8ri : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001285 "or{b} {$src2, $dst|$dst, $src2}",
1286 [(set R8:$dst, (or R8:$src1, imm:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001287def OR16ri : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001288 "or{w} {$src2, $dst|$dst, $src2}",
1289 [(set R16:$dst, (or R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001290def OR32ri : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001291 "or{l} {$src2, $dst|$dst, $src2}",
1292 [(set R32:$dst, (or R32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001293
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001294def OR16ri8 : Ii8<0x83, MRM1r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1295 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001296 [(set R16:$dst, (or R16:$src1, i16immSExt8:$src2))]>, OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001297def OR32ri8 : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1298 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001299 [(set R32:$dst, (or R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001300let isTwoAddress = 0 in {
Chris Lattnerf29ed092004-08-11 05:07:25 +00001301 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001302 "or{b} {$src, $dst|$dst, $src}",
1303 [(store (or (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001304 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001305 "or{w} {$src, $dst|$dst, $src}",
1306 [(store (or (load addr:$dst), R16:$src), addr:$dst)]>, OpSize;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001307 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001308 "or{l} {$src, $dst|$dst, $src}",
1309 [(store (or (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001310 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001311 "or{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001312 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001313 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001314 "or{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001315 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001316 OpSize;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001317 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001318 "or{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001319 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng0ef3a772005-12-13 01:41:36 +00001320 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1321 "or{w} {$src, $dst|$dst, $src}",
1322 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1323 OpSize;
1324 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1325 "or{l} {$src, $dst|$dst, $src}",
1326 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001327}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001328
1329
Chris Lattnercc65bee2005-01-02 02:35:46 +00001330let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001331def XOR8rr : I<0x30, MRMDestReg,
1332 (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001333 "xor{b} {$src2, $dst|$dst, $src2}",
1334 [(set R8:$dst, (xor R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001335def XOR16rr : I<0x31, MRMDestReg,
1336 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001337 "xor{w} {$src2, $dst|$dst, $src2}",
1338 [(set R16:$dst, (xor R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001339def XOR32rr : I<0x31, MRMDestReg,
1340 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001341 "xor{l} {$src2, $dst|$dst, $src2}",
1342 [(set R32:$dst, (xor R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001343}
1344
Chris Lattner3a173df2004-10-03 20:35:00 +00001345def XOR8rm : I<0x32, MRMSrcMem ,
1346 (ops R8 :$dst, R8:$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001347 "xor{b} {$src2, $dst|$dst, $src2}",
1348 [(set R8:$dst, (xor R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001349def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001350 (ops R16:$dst, R16:$src1, i16mem:$src2),
1351 "xor{w} {$src2, $dst|$dst, $src2}",
1352 [(set R16:$dst, (xor R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001353def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001354 (ops R32:$dst, R32:$src1, i32mem:$src2),
1355 "xor{l} {$src2, $dst|$dst, $src2}",
1356 [(set R32:$dst, (xor R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001357
Chris Lattner3a173df2004-10-03 20:35:00 +00001358def XOR8ri : Ii8<0x80, MRM6r,
1359 (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001360 "xor{b} {$src2, $dst|$dst, $src2}",
1361 [(set R8:$dst, (xor R8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001362def XOR16ri : Ii16<0x81, MRM6r,
1363 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001364 "xor{w} {$src2, $dst|$dst, $src2}",
1365 [(set R16:$dst, (xor R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001366def XOR32ri : Ii32<0x81, MRM6r,
1367 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001368 "xor{l} {$src2, $dst|$dst, $src2}",
1369 [(set R32:$dst, (xor R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001370def XOR16ri8 : Ii8<0x83, MRM6r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001371 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1372 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001373 [(set R16:$dst, (xor R16:$src1, i16immSExt8:$src2))]>,
1374 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001375def XOR32ri8 : Ii8<0x83, MRM6r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001376 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1377 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001378 [(set R32:$dst, (xor R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001379let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001380 def XOR8mr : I<0x30, MRMDestMem,
1381 (ops i8mem :$dst, R8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001382 "xor{b} {$src, $dst|$dst, $src}",
1383 [(store (xor (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001384 def XOR16mr : I<0x31, MRMDestMem,
1385 (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001386 "xor{w} {$src, $dst|$dst, $src}",
1387 [(store (xor (load addr:$dst), R16:$src), addr:$dst)]>,
1388 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001389 def XOR32mr : I<0x31, MRMDestMem,
1390 (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001391 "xor{l} {$src, $dst|$dst, $src}",
1392 [(store (xor (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001393 def XOR8mi : Ii8<0x80, MRM6m,
1394 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001395 "xor{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001396 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001397 def XOR16mi : Ii16<0x81, MRM6m,
1398 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001399 "xor{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001400 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001401 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001402 def XOR32mi : Ii32<0x81, MRM6m,
1403 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001404 "xor{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001405 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001406 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001407 (ops i16mem:$dst, i16i8imm :$src),
1408 "xor{w} {$src, $dst|$dst, $src}",
1409 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1410 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001411 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001412 (ops i32mem:$dst, i32i8imm :$src),
1413 "xor{l} {$src, $dst|$dst, $src}",
1414 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001415}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001416
1417// Shift instructions
Chris Lattner3a173df2004-10-03 20:35:00 +00001418def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001419 "shl{b} {%cl, $dst|$dst, %CL}",
1420 [(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001421def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001422 "shl{w} {%cl, $dst|$dst, %CL}",
1423 [(set R16:$dst, (shl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001424def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001425 "shl{l} {%cl, $dst|$dst, %CL}",
1426 [(set R32:$dst, (shl R32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001427
Chris Lattner36b68902004-08-10 21:21:30 +00001428def SHL8ri : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001429 "shl{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001430 [(set R8:$dst, (shl R8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001431let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001432def SHL16ri : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001433 "shl{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001434 [(set R16:$dst, (shl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1435def SHL32ri : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001436 "shl{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001437 [(set R32:$dst, (shl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001438}
Chris Lattnerf29ed092004-08-11 05:07:25 +00001439
1440let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001441 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001442 "shl{b} {%cl, $dst|$dst, %CL}",
1443 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1444 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001445 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001446 "shl{w} {%cl, $dst|$dst, %CL}",
1447 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1448 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001449 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001450 "shl{l} {%cl, $dst|$dst, %CL}",
1451 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1452 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001453 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001454 "shl{b} {$src, $dst|$dst, $src}",
1455 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001456 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001457 "shl{w} {$src, $dst|$dst, $src}",
1458 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1459 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001460 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001461 "shl{l} {$src, $dst|$dst, $src}",
1462 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001463}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001464
Chris Lattner3a173df2004-10-03 20:35:00 +00001465def SHR8rCL : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001466 "shr{b} {%cl, $dst|$dst, %CL}",
1467 [(set R8:$dst, (srl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001468def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001469 "shr{w} {%cl, $dst|$dst, %CL}",
1470 [(set R16:$dst, (srl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001471def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001472 "shr{l} {%cl, $dst|$dst, %CL}",
1473 [(set R32:$dst, (srl R32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001474
Chris Lattner3a173df2004-10-03 20:35:00 +00001475def SHR8ri : Ii8<0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001476 "shr{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001477 [(set R8:$dst, (srl R8:$src1, (i8 imm:$src2)))]>;
1478def SHR16ri : Ii8<0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001479 "shr{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001480 [(set R16:$dst, (srl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1481def SHR32ri : Ii8<0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001482 "shr{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001483 [(set R32:$dst, (srl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001484
Chris Lattner57a02302004-08-11 04:31:00 +00001485let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001486 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001487 "shr{b} {%cl, $dst|$dst, %CL}",
1488 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1489 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001490 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001491 "shr{w} {%cl, $dst|$dst, %CL}",
1492 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1493 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001494 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001495 "shr{l} {%cl, $dst|$dst, %CL}",
1496 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1497 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001498 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001499 "shr{b} {$src, $dst|$dst, $src}",
1500 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001501 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001502 "shr{w} {$src, $dst|$dst, $src}",
1503 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1504 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001505 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001506 "shr{l} {$src, $dst|$dst, $src}",
1507 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001508}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001509
Chris Lattner3a173df2004-10-03 20:35:00 +00001510def SAR8rCL : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001511 "sar{b} {%cl, $dst|$dst, %CL}",
1512 [(set R8:$dst, (sra R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001513def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001514 "sar{w} {%cl, $dst|$dst, %CL}",
1515 [(set R16:$dst, (sra R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001516def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001517 "sar{l} {%cl, $dst|$dst, %CL}",
1518 [(set R32:$dst, (sra R32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001519
Chris Lattner36b68902004-08-10 21:21:30 +00001520def SAR8ri : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001521 "sar{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001522 [(set R8:$dst, (sra R8:$src1, (i8 imm:$src2)))]>;
1523def SAR16ri : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001524 "sar{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001525 [(set R16:$dst, (sra R16:$src1, (i8 imm:$src2)))]>,
1526 OpSize;
1527def SAR32ri : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001528 "sar{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001529 [(set R32:$dst, (sra R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001530let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001531 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001532 "sar{b} {%cl, $dst|$dst, %CL}",
1533 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1534 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001535 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001536 "sar{w} {%cl, $dst|$dst, %CL}",
1537 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1538 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001539 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001540 "sar{l} {%cl, $dst|$dst, %CL}",
1541 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1542 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001543 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001544 "sar{b} {$src, $dst|$dst, $src}",
1545 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001546 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001547 "sar{w} {$src, $dst|$dst, $src}",
1548 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1549 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001550 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001551 "sar{l} {$src, $dst|$dst, $src}",
1552 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001553}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001554
Chris Lattner40ff6332005-01-19 07:50:03 +00001555// Rotate instructions
1556// FIXME: provide shorter instructions when imm8 == 1
1557def ROL8rCL : I<0xD2, MRM0r, (ops R8 :$dst, R8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001558 "rol{b} {%cl, $dst|$dst, %CL}",
1559 [(set R8:$dst, (rotl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001560def ROL16rCL : I<0xD3, MRM0r, (ops R16:$dst, R16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001561 "rol{w} {%cl, $dst|$dst, %CL}",
1562 [(set R16:$dst, (rotl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001563def ROL32rCL : I<0xD3, MRM0r, (ops R32:$dst, R32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001564 "rol{l} {%cl, $dst|$dst, %CL}",
1565 [(set R32:$dst, (rotl R32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001566
1567def ROL8ri : Ii8<0xC0, MRM0r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001568 "rol{b} {$src2, $dst|$dst, $src2}",
1569 [(set R8:$dst, (rotl R8:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001570def ROL16ri : Ii8<0xC1, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001571 "rol{w} {$src2, $dst|$dst, $src2}",
1572 [(set R16:$dst, (rotl R16:$src1, (i8 imm:$src2)))]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001573def ROL32ri : Ii8<0xC1, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001574 "rol{l} {$src2, $dst|$dst, $src2}",
1575 [(set R32:$dst, (rotl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001576
1577let isTwoAddress = 0 in {
1578 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001579 "rol{b} {%cl, $dst|$dst, %CL}",
1580 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1581 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001582 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001583 "rol{w} {%cl, $dst|$dst, %CL}",
1584 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1585 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001586 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001587 "rol{l} {%cl, $dst|$dst, %CL}",
1588 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1589 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001590 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001591 "rol{b} {$src, $dst|$dst, $src}",
1592 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001593 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001594 "rol{w} {$src, $dst|$dst, $src}",
1595 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1596 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001597 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001598 "rol{l} {$src, $dst|$dst, $src}",
1599 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001600}
1601
1602def ROR8rCL : I<0xD2, MRM1r, (ops R8 :$dst, R8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001603 "ror{b} {%cl, $dst|$dst, %CL}",
1604 [(set R8:$dst, (rotr R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001605def ROR16rCL : I<0xD3, MRM1r, (ops R16:$dst, R16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001606 "ror{w} {%cl, $dst|$dst, %CL}",
1607 [(set R16:$dst, (rotr R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001608def ROR32rCL : I<0xD3, MRM1r, (ops R32:$dst, R32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001609 "ror{l} {%cl, $dst|$dst, %CL}",
1610 [(set R32:$dst, (rotr R32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001611
1612def ROR8ri : Ii8<0xC0, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001613 "ror{b} {$src2, $dst|$dst, $src2}",
1614 [(set R8:$dst, (rotr R8:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001615def ROR16ri : Ii8<0xC1, MRM1r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001616 "ror{w} {$src2, $dst|$dst, $src2}",
1617 [(set R16:$dst, (rotr R16:$src1, (i8 imm:$src2)))]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001618def ROR32ri : Ii8<0xC1, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001619 "ror{l} {$src2, $dst|$dst, $src2}",
1620 [(set R32:$dst, (rotr R32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001621let isTwoAddress = 0 in {
1622 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001623 "ror{b} {%cl, $dst|$dst, %CL}",
1624 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1625 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001626 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001627 "ror{w} {%cl, $dst|$dst, %CL}",
1628 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1629 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001630 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001631 "ror{l} {%cl, $dst|$dst, %CL}",
1632 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1633 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001634 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001635 "ror{b} {$src, $dst|$dst, $src}",
1636 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001637 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001638 "ror{w} {$src, $dst|$dst, $src}",
1639 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1640 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001641 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001642 "ror{l} {$src, $dst|$dst, $src}",
1643 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001644}
1645
1646
1647
1648// Double shift instructions (generalizations of rotate)
1649
Chris Lattner57a02302004-08-11 04:31:00 +00001650def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001651 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1652 [(set R32:$dst, (X86shld R32:$src1, R32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001653 Imp<[CL],[]>, TB;
Chris Lattner57a02302004-08-11 04:31:00 +00001654def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001655 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1656 [(set R32:$dst, (X86shrd R32:$src1, R32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001657 Imp<[CL],[]>, TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001658def SHLD16rrCL : I<0xA5, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001659 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1660 [(set R16:$dst, (X86shld R16:$src1, R16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001661 Imp<[CL],[]>, TB, OpSize;
1662def SHRD16rrCL : I<0xAD, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001663 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1664 [(set R16:$dst, (X86shrd R16:$src1, R16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001665 Imp<[CL],[]>, TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001666
1667let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001668def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1669 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001670 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1671 [(set R32:$dst, (X86shld R32:$src1, R32:$src2,
1672 (i8 imm:$src3)))]>,
1673 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001674def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1675 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001676 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1677 [(set R32:$dst, (X86shrd R32:$src1, R32:$src2,
1678 (i8 imm:$src3)))]>,
1679 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001680def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1681 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001682 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1683 [(set R16:$dst, (X86shld R16:$src1, R16:$src2,
1684 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001685 TB, OpSize;
1686def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1687 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001688 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1689 [(set R16:$dst, (X86shrd R16:$src1, R16:$src2,
1690 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001691 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001692}
Chris Lattner0e967d42004-08-01 08:13:11 +00001693
Chris Lattner57a02302004-08-11 04:31:00 +00001694let isTwoAddress = 0 in {
1695 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001696 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1697 [(store (X86shld (loadi32 addr:$dst), R32:$src2, CL),
1698 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001699 Imp<[CL],[]>, TB;
Chris Lattner57a02302004-08-11 04:31:00 +00001700 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001701 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1702 [(store (X86shrd (loadi32 addr:$dst), R32:$src2, CL),
1703 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001704 Imp<[CL],[]>, TB;
1705 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1706 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001707 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1708 [(store (X86shld (loadi32 addr:$dst), R32:$src2,
1709 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001710 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001711 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1712 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001713 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1714 [(store (X86shrd (loadi32 addr:$dst), R32:$src2,
1715 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001716 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001717
1718 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001719 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1720 [(store (X86shld (loadi16 addr:$dst), R16:$src2, CL),
1721 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001722 Imp<[CL],[]>, TB, OpSize;
1723 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001724 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1725 [(store (X86shrd (loadi16 addr:$dst), R16:$src2, CL),
1726 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001727 Imp<[CL],[]>, TB, OpSize;
1728 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1729 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001730 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1731 [(store (X86shld (loadi16 addr:$dst), R16:$src2,
1732 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001733 TB, OpSize;
1734 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1735 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001736 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1737 [(store (X86shrd (loadi16 addr:$dst), R16:$src2,
1738 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001739 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001740}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001741
1742
Chris Lattnercc65bee2005-01-02 02:35:46 +00001743// Arithmetic.
1744let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001745def ADD8rr : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001746 "add{b} {$src2, $dst|$dst, $src2}",
1747 [(set R8:$dst, (add R8:$src1, R8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001748let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3a173df2004-10-03 20:35:00 +00001749def ADD16rr : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001750 "add{w} {$src2, $dst|$dst, $src2}",
1751 [(set R16:$dst, (add R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001752def ADD32rr : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001753 "add{l} {$src2, $dst|$dst, $src2}",
1754 [(set R32:$dst, (add R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001755} // end isConvertibleToThreeAddress
1756} // end isCommutable
Chris Lattner3a173df2004-10-03 20:35:00 +00001757def ADD8rm : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001758 "add{b} {$src2, $dst|$dst, $src2}",
1759 [(set R8:$dst, (add R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001760def ADD16rm : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001761 "add{w} {$src2, $dst|$dst, $src2}",
1762 [(set R16:$dst, (add R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001763def ADD32rm : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001764 "add{l} {$src2, $dst|$dst, $src2}",
1765 [(set R32:$dst, (add R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001766
Chris Lattner3a173df2004-10-03 20:35:00 +00001767def ADD8ri : Ii8<0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001768 "add{b} {$src2, $dst|$dst, $src2}",
1769 [(set R8:$dst, (add R8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001770
1771let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3a173df2004-10-03 20:35:00 +00001772def ADD16ri : Ii16<0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001773 "add{w} {$src2, $dst|$dst, $src2}",
1774 [(set R16:$dst, (add R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001775def ADD32ri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001776 "add{l} {$src2, $dst|$dst, $src2}",
1777 [(set R32:$dst, (add R32:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001778}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001779
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001780// FIXME: move ADD16ri8 above ADD16ri to optimize for space.
1781def ADD16ri8 : Ii8<0x83, MRM0r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1782 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001783 [(set R16:$dst, (add R16:$src1, i16immSExt8:$src2))]>,
1784 OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001785def ADD32ri8 : Ii8<0x83, MRM0r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1786 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001787 [(set R32:$dst, (add R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001788
1789let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001790 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001791 "add{b} {$src2, $dst|$dst, $src2}",
1792 [(store (add (load addr:$dst), R8:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001793 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001794 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001795 [(store (add (load addr:$dst), R16:$src2), addr:$dst)]>,
1796 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001797 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001798 "add{l} {$src2, $dst|$dst, $src2}",
1799 [(store (add (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001800 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001801 "add{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001802 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001803 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001804 "add{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001805 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001806 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001807 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001808 "add{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001809 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengee93f9d2005-12-12 19:45:23 +00001810 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1811 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001812 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1813 OpSize;
Evan Chengee93f9d2005-12-12 19:45:23 +00001814 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1815 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001816 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001817}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001818
Chris Lattner10197ff2005-01-03 01:27:59 +00001819let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001820def ADC32rr : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001821 "adc{l} {$src2, $dst|$dst, $src2}",
1822 [(set R32:$dst, (X86adc R32:$src1, R32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001823}
Chris Lattner3a173df2004-10-03 20:35:00 +00001824def ADC32rm : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001825 "adc{l} {$src2, $dst|$dst, $src2}",
1826 [(set R32:$dst, (X86adc R32:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001827def ADC32ri : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001828 "adc{l} {$src2, $dst|$dst, $src2}",
1829 [(set R32:$dst, (X86adc R32:$src1, imm:$src2))]>;
1830def ADC32ri8 : Ii8<0x83, MRM2r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1831 "adc{l} {$src2, $dst|$dst, $src2}",
1832 [(set R32:$dst, (X86adc R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001833
1834let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001835 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001836 "adc{l} {$src2, $dst|$dst, $src2}",
1837 [(store (X86adc (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001838 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001839 "adc{l} {$src2, $dst|$dst, $src2}",
1840 [(store (X86adc (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1841 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1842 "adc{l} {$src2, $dst|$dst, $src2}",
1843 [(store (X86adc (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001844}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001845
Chris Lattner3a173df2004-10-03 20:35:00 +00001846def SUB8rr : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001847 "sub{b} {$src2, $dst|$dst, $src2}",
1848 [(set R8:$dst, (sub R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001849def SUB16rr : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001850 "sub{w} {$src2, $dst|$dst, $src2}",
1851 [(set R16:$dst, (sub R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001852def SUB32rr : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001853 "sub{l} {$src2, $dst|$dst, $src2}",
1854 [(set R32:$dst, (sub R32:$src1, R32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001855def SUB8rm : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001856 "sub{b} {$src2, $dst|$dst, $src2}",
1857 [(set R8:$dst, (sub R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001858def SUB16rm : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001859 "sub{w} {$src2, $dst|$dst, $src2}",
1860 [(set R16:$dst, (sub R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001861def SUB32rm : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001862 "sub{l} {$src2, $dst|$dst, $src2}",
1863 [(set R32:$dst, (sub R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001864
Chris Lattner36b68902004-08-10 21:21:30 +00001865def SUB8ri : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001866 "sub{b} {$src2, $dst|$dst, $src2}",
1867 [(set R8:$dst, (sub R8:$src1, imm:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001868def SUB16ri : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001869 "sub{w} {$src2, $dst|$dst, $src2}",
1870 [(set R16:$dst, (sub R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001871def SUB32ri : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001872 "sub{l} {$src2, $dst|$dst, $src2}",
1873 [(set R32:$dst, (sub R32:$src1, imm:$src2))]>;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001874def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1875 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001876 [(set R16:$dst, (sub R16:$src1, i16immSExt8:$src2))]>,
1877 OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001878def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1879 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001880 [(set R32:$dst, (sub R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001881let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001882 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001883 "sub{b} {$src2, $dst|$dst, $src2}",
1884 [(store (sub (load addr:$dst), R8:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001885 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001886 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001887 [(store (sub (load addr:$dst), R16:$src2), addr:$dst)]>,
1888 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001889 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001890 "sub{l} {$src2, $dst|$dst, $src2}",
1891 [(store (sub (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001892 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001893 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001894 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001895 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001896 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001897 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001898 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001899 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001900 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001901 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengd160d482005-12-12 21:54:05 +00001902 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1903 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001904 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1905 OpSize;
Evan Chengd160d482005-12-12 21:54:05 +00001906 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1907 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001908 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001909}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001910
Chris Lattner3a173df2004-10-03 20:35:00 +00001911def SBB32rr : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001912 "sbb{l} {$src2, $dst|$dst, $src2}",
1913 [(set R32:$dst, (X86sbb R32:$src1, R32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001914
Chris Lattner57a02302004-08-11 04:31:00 +00001915let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001916 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001917 "sbb{l} {$src2, $dst|$dst, $src2}",
1918 [(store (X86sbb (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001919 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001920 "sbb{b} {$src2, $dst|$dst, $src2}",
1921 [(store (X86sbb (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001922 def SBB16mi : Ii32<0x81, MRM3m, (ops i16mem:$dst, i16imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001923 "sbb{w} {$src2, $dst|$dst, $src2}",
1924 [(store (X86sbb (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1925 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001926 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001927 "sbb{l} {$src2, $dst|$dst, $src2}",
1928 [(store (X86sbb (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
1929 def SBB16mi8 : Ii8<0x83, MRM3m, (ops i16mem:$dst, i16i8imm :$src2),
1930 "sbb{w} {$src2, $dst|$dst, $src2}",
1931 [(store (X86sbb (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1932 OpSize;
1933 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
1934 "sbb{l} {$src2, $dst|$dst, $src2}",
1935 [(store (X86sbb (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001936}
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001937def SBB8ri : Ii8<0x80, MRM3r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001938 "sbb{b} {$src2, $dst|$dst, $src2}",
1939 [(set R8:$dst, (X86sbb R8:$src1, imm:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001940def SBB16ri : Ii16<0x81, MRM3r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001941 "sbb{w} {$src2, $dst|$dst, $src2}",
1942 [(set R16:$dst, (X86sbb R16:$src1, imm:$src2))]>, OpSize;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001943
Chris Lattner57a02302004-08-11 04:31:00 +00001944def SBB32rm : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001945 "sbb{l} {$src2, $dst|$dst, $src2}",
1946 [(set R32:$dst, (X86sbb R32:$src1, (load addr:$src2)))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001947def SBB32ri : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001948 "sbb{l} {$src2, $dst|$dst, $src2}",
1949 [(set R32:$dst, (X86sbb R32:$src1, imm:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001950
Evan Chenge3413162006-01-09 18:33:28 +00001951def SBB16ri8 : Ii8<0x83, MRM3r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1952 "sbb{w} {$src2, $dst|$dst, $src2}",
1953 [(set R16:$dst, (X86sbb R16:$src1, i16immSExt8:$src2))]>,
1954 OpSize;
1955def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1956 "sbb{l} {$src2, $dst|$dst, $src2}",
1957 [(set R32:$dst, (X86sbb R32:$src1, i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001958
Chris Lattner10197ff2005-01-03 01:27:59 +00001959let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001960def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001961 "imul{w} {$src2, $dst|$dst, $src2}",
1962 [(set R16:$dst, (mul R16:$src1, R16:$src2))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001963def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001964 "imul{l} {$src2, $dst|$dst, $src2}",
1965 [(set R32:$dst, (mul R32:$src1, R32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00001966}
Chris Lattner3a173df2004-10-03 20:35:00 +00001967def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001968 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001969 [(set R16:$dst, (mul R16:$src1, (load addr:$src2)))]>,
1970 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001971def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001972 "imul{l} {$src2, $dst|$dst, $src2}",
1973 [(set R32:$dst, (mul R32:$src1, (load addr:$src2)))]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001974
1975} // end Two Address instructions
1976
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001977// Suprisingly enough, these are not two address instructions!
Chris Lattner3a173df2004-10-03 20:35:00 +00001978def IMUL16rri : Ii16<0x69, MRMSrcReg, // R16 = R16*I16
1979 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001980 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Chengf281e022005-12-12 23:47:46 +00001981 [(set R16:$dst, (mul R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001982def IMUL32rri : Ii32<0x69, MRMSrcReg, // R32 = R32*I32
1983 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001984 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1985 [(set R32:$dst, (mul R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001986def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // R16 = R16*I8
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001987 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1988 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001989 [(set R16:$dst, (mul R16:$src1, i16immSExt8:$src2))]>,
1990 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001991def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // R32 = R32*I8
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001992 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1993 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001994 [(set R32:$dst, (mul R32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001995
Chris Lattner3a173df2004-10-03 20:35:00 +00001996def IMUL16rmi : Ii16<0x69, MRMSrcMem, // R16 = [mem16]*I16
Evan Chengf281e022005-12-12 23:47:46 +00001997 (ops R16:$dst, i16mem:$src1, i16imm:$src2),
1998 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1999 [(set R16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2000 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002001def IMUL32rmi : Ii32<0x69, MRMSrcMem, // R32 = [mem32]*I32
2002 (ops R32:$dst, i32mem:$src1, i32imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002003 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2004 [(set R32:$dst, (mul (load addr:$src1), imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002005def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // R16 = [mem16]*I8
Evan Chengf281e022005-12-12 23:47:46 +00002006 (ops R16:$dst, i16mem:$src1, i16i8imm :$src2),
2007 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00002008 [(set R16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2009 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002010def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // R32 = [mem32]*I8
Evan Chengf281e022005-12-12 23:47:46 +00002011 (ops R32:$dst, i32mem:$src1, i32i8imm: $src2),
2012 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00002013 [(set R32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002014
2015//===----------------------------------------------------------------------===//
2016// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002017//
Chris Lattnercc65bee2005-01-02 02:35:46 +00002018let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Chris Lattner36b68902004-08-10 21:21:30 +00002019def TEST8rr : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002020 "test{b} {$src2, $src1|$src1, $src2}",
2021 [(set STATUS, (X86test R8:$src1, R8:$src2))]>,
2022 Imp<[],[STATUS]>;
Chris Lattner36b68902004-08-10 21:21:30 +00002023def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002024 "test{w} {$src2, $src1|$src1, $src2}",
2025 [(set STATUS, (X86test R16:$src1, R16:$src2))]>,
2026 Imp<[],[STATUS]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00002027def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002028 "test{l} {$src2, $src1|$src1, $src2}",
2029 [(set STATUS, (X86test R32:$src1, R32:$src2))]>,
2030 Imp<[],[STATUS]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002031}
Chris Lattner57a02302004-08-11 04:31:00 +00002032def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002033 "test{b} {$src2, $src1|$src1, $src2}",
2034 [(set STATUS, (X86test (loadi8 addr:$src1), R8:$src2))]>,
2035 Imp<[],[STATUS]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002036def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002037 "test{w} {$src2, $src1|$src1, $src2}",
2038 [(set STATUS, (X86test (loadi16 addr:$src1), R16:$src2))]>,
2039 Imp<[],[STATUS]>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002040def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002041 "test{l} {$src2, $src1|$src1, $src2}",
2042 [(set STATUS, (X86test (loadi32 addr:$src1), R32:$src2))]>,
2043 Imp<[],[STATUS]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002044def TEST8rm : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002045 "test{b} {$src2, $src1|$src1, $src2}",
2046 [(set STATUS, (X86test R8:$src1, (loadi8 addr:$src2)))]>,
2047 Imp<[],[STATUS]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002048def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002049 "test{w} {$src2, $src1|$src1, $src2}",
2050 [(set STATUS, (X86test R16:$src1, (loadi16 addr:$src2)))]>,
2051 Imp<[],[STATUS]>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002052def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002053 "test{l} {$src2, $src1|$src1, $src2}",
2054 [(set STATUS, (X86test R32:$src1, (loadi32 addr:$src2)))]>,
2055 Imp<[],[STATUS]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002056
Chris Lattner707c6fe2004-10-04 01:38:10 +00002057def TEST8ri : Ii8 <0xF6, MRM0r, // flags = R8 & imm8
2058 (ops R8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002059 "test{b} {$src2, $src1|$src1, $src2}",
2060 [(set STATUS, (X86test R8:$src1, imm:$src2))]>,
2061 Imp<[],[STATUS]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002062def TEST16ri : Ii16<0xF7, MRM0r, // flags = R16 & imm16
2063 (ops R16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002064 "test{w} {$src2, $src1|$src1, $src2}",
2065 [(set STATUS, (X86test R16:$src1, imm:$src2))]>,
2066 Imp<[],[STATUS]>, OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002067def TEST32ri : Ii32<0xF7, MRM0r, // flags = R32 & imm32
2068 (ops R32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002069 "test{l} {$src2, $src1|$src1, $src2}",
2070 [(set STATUS, (X86test R32:$src1, imm:$src2))]>,
2071 Imp<[],[STATUS]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002072def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengaed7c722005-12-17 01:24:02 +00002073 (ops i8mem:$src1, i8imm:$src2),
2074 "test{b} {$src2, $src1|$src1, $src2}",
2075 [(set STATUS, (X86test (loadi8 addr:$src1), imm:$src2))]>,
2076 Imp<[],[STATUS]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002077def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2078 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002079 "test{w} {$src2, $src1|$src1, $src2}",
2080 [(set STATUS, (X86test (loadi16 addr:$src1), imm:$src2))]>,
2081 Imp<[],[STATUS]>, OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002082def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2083 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002084 "test{l} {$src2, $src1|$src1, $src2}",
2085 [(set STATUS, (X86test (loadi32 addr:$src1), imm:$src2))]>,
2086 Imp<[],[STATUS]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002087
2088
2089// Condition code ops, incl. set if equal/not equal/...
Evan Chengf0701842005-11-29 19:38:52 +00002090def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2091def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002092
Chris Lattner3a173df2004-10-03 20:35:00 +00002093def SETEr : I<0x94, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002094 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002095 "sete $dst",
2096 [(set R8:$dst, (X86setcc X86_COND_E, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002097 TB; // R8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002098def SETEm : I<0x94, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002099 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002100 "sete $dst",
2101 [(store (X86setcc X86_COND_E, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002102 TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002103def SETNEr : I<0x95, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002104 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002105 "setne $dst",
2106 [(set R8:$dst, (X86setcc X86_COND_NE, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002107 TB; // R8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002108def SETNEm : I<0x95, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002109 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002110 "setne $dst",
2111 [(store (X86setcc X86_COND_NE, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002112 TB; // [mem8] = !=
2113def SETLr : I<0x9C, MRM0r,
2114 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002115 "setl $dst",
2116 [(set R8:$dst, (X86setcc X86_COND_L, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002117 TB; // R8 = < signed
2118def SETLm : I<0x9C, MRM0m,
2119 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002120 "setl $dst",
2121 [(store (X86setcc X86_COND_L, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002122 TB; // [mem8] = < signed
2123def SETGEr : I<0x9D, MRM0r,
2124 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002125 "setge $dst",
2126 [(set R8:$dst, (X86setcc X86_COND_GE, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002127 TB; // R8 = >= signed
2128def SETGEm : I<0x9D, MRM0m,
2129 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002130 "setge $dst",
2131 [(store (X86setcc X86_COND_GE, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002132 TB; // [mem8] = >= signed
2133def SETLEr : I<0x9E, MRM0r,
2134 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002135 "setle $dst",
2136 [(set R8:$dst, (X86setcc X86_COND_LE, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002137 TB; // R8 = <= signed
2138def SETLEm : I<0x9E, MRM0m,
2139 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002140 "setle $dst",
2141 [(store (X86setcc X86_COND_LE, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002142 TB; // [mem8] = <= signed
2143def SETGr : I<0x9F, MRM0r,
2144 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002145 "setg $dst",
2146 [(set R8:$dst, (X86setcc X86_COND_G, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002147 TB; // R8 = > signed
2148def SETGm : I<0x9F, MRM0m,
2149 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002150 "setg $dst",
2151 [(store (X86setcc X86_COND_G, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002152 TB; // [mem8] = > signed
2153
2154def SETBr : I<0x92, MRM0r,
2155 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002156 "setb $dst",
2157 [(set R8:$dst, (X86setcc X86_COND_B, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002158 TB; // R8 = < unsign
2159def SETBm : I<0x92, MRM0m,
2160 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002161 "setb $dst",
2162 [(store (X86setcc X86_COND_B, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002163 TB; // [mem8] = < unsign
2164def SETAEr : I<0x93, MRM0r,
2165 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002166 "setae $dst",
2167 [(set R8:$dst, (X86setcc X86_COND_AE, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002168 TB; // R8 = >= unsign
2169def SETAEm : I<0x93, MRM0m,
2170 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002171 "setae $dst",
2172 [(store (X86setcc X86_COND_AE, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002173 TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002174def SETBEr : I<0x96, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002175 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002176 "setbe $dst",
2177 [(set R8:$dst, (X86setcc X86_COND_BE, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002178 TB; // R8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002179def SETBEm : I<0x96, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002180 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002181 "setbe $dst",
2182 [(store (X86setcc X86_COND_BE, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002183 TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002184def SETAr : I<0x97, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002185 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002186 "seta $dst",
2187 [(set R8:$dst, (X86setcc X86_COND_A, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002188 TB; // R8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002189def SETAm : I<0x97, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002190 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002191 "seta $dst",
2192 [(store (X86setcc X86_COND_A, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002193 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002194
Chris Lattner3a173df2004-10-03 20:35:00 +00002195def SETSr : I<0x98, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002196 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002197 "sets $dst",
2198 [(set R8:$dst, (X86setcc X86_COND_S, STATUS))]>,
2199 TB; // R8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002200def SETSm : I<0x98, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002201 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002202 "sets $dst",
2203 [(store (X86setcc X86_COND_S, STATUS), addr:$dst)]>,
2204 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002205def SETNSr : I<0x99, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002206 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002207 "setns $dst",
2208 [(set R8:$dst, (X86setcc X86_COND_NS, STATUS))]>,
2209 TB; // R8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002210def SETNSm : I<0x99, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002211 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002212 "setns $dst",
2213 [(store (X86setcc X86_COND_NS, STATUS), addr:$dst)]>,
2214 TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002215def SETPr : I<0x9A, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002216 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002217 "setp $dst",
2218 [(set R8:$dst, (X86setcc X86_COND_P, STATUS))]>,
2219 TB; // R8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002220def SETPm : I<0x9A, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002221 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002222 "setp $dst",
2223 [(store (X86setcc X86_COND_P, STATUS), addr:$dst)]>,
2224 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002225def SETNPr : I<0x9B, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002226 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002227 "setnp $dst",
2228 [(set R8:$dst, (X86setcc X86_COND_NP, STATUS))]>,
2229 TB; // R8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002230def SETNPm : I<0x9B, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002231 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002232 "setnp $dst",
2233 [(store (X86setcc X86_COND_NP, STATUS), addr:$dst)]>,
2234 TB; // [mem8] = not parity
Chris Lattner1cca5e32003-08-03 21:54:21 +00002235
2236// Integer comparisons
Chris Lattner3a173df2004-10-03 20:35:00 +00002237def CMP8rr : I<0x38, MRMDestReg,
2238 (ops R8 :$src1, R8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002239 "cmp{b} {$src2, $src1|$src1, $src2}",
2240 [(set STATUS, (X86cmp R8:$src1, R8:$src2))]>,
2241 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002242def CMP16rr : I<0x39, MRMDestReg,
2243 (ops R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002244 "cmp{w} {$src2, $src1|$src1, $src2}",
2245 [(set STATUS, (X86cmp R16:$src1, R16:$src2))]>,
2246 Imp<[],[STATUS]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002247def CMP32rr : I<0x39, MRMDestReg,
2248 (ops R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002249 "cmp{l} {$src2, $src1|$src1, $src2}",
2250 [(set STATUS, (X86cmp R32:$src1, R32:$src2))]>,
2251 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002252def CMP8mr : I<0x38, MRMDestMem,
2253 (ops i8mem :$src1, R8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002254 "cmp{b} {$src2, $src1|$src1, $src2}",
2255 [(set STATUS, (X86cmp (loadi8 addr:$src1), R8:$src2))]>,
2256 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002257def CMP16mr : I<0x39, MRMDestMem,
2258 (ops i16mem:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002259 "cmp{w} {$src2, $src1|$src1, $src2}",
2260 [(set STATUS, (X86cmp (loadi16 addr:$src1), R16:$src2))]>,
2261 Imp<[],[STATUS]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002262def CMP32mr : I<0x39, MRMDestMem,
2263 (ops i32mem:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002264 "cmp{l} {$src2, $src1|$src1, $src2}",
2265 [(set STATUS, (X86cmp (loadi32 addr:$src1), R32:$src2))]>,
2266 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002267def CMP8rm : I<0x3A, MRMSrcMem,
2268 (ops R8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002269 "cmp{b} {$src2, $src1|$src1, $src2}",
2270 [(set STATUS, (X86cmp R8:$src1, (loadi8 addr:$src2)))]>,
2271 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002272def CMP16rm : I<0x3B, MRMSrcMem,
2273 (ops R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002274 "cmp{w} {$src2, $src1|$src1, $src2}",
2275 [(set STATUS, (X86cmp R16:$src1, (loadi16 addr:$src2)))]>,
2276 Imp<[],[STATUS]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002277def CMP32rm : I<0x3B, MRMSrcMem,
2278 (ops R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002279 "cmp{l} {$src2, $src1|$src1, $src2}",
2280 [(set STATUS, (X86cmp R32:$src1, (loadi32 addr:$src2)))]>,
2281 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002282def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengaed7c722005-12-17 01:24:02 +00002283 (ops R8:$src1, i8imm:$src2),
2284 "cmp{b} {$src2, $src1|$src1, $src2}",
2285 [(set STATUS, (X86cmp R8:$src1, imm:$src2))]>,
2286 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002287def CMP16ri : Ii16<0x81, MRM7r,
2288 (ops R16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002289 "cmp{w} {$src2, $src1|$src1, $src2}",
2290 [(set STATUS, (X86cmp R16:$src1, imm:$src2))]>,
2291 Imp<[],[STATUS]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002292def CMP32ri : Ii32<0x81, MRM7r,
2293 (ops R32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002294 "cmp{l} {$src2, $src1|$src1, $src2}",
2295 [(set STATUS, (X86cmp R32:$src1, imm:$src2))]>,
2296 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002297def CMP8mi : Ii8 <0x80, MRM7m,
2298 (ops i8mem :$src1, i8imm :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002299 "cmp{b} {$src2, $src1|$src1, $src2}",
2300 [(set STATUS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>,
2301 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002302def CMP16mi : Ii16<0x81, MRM7m,
2303 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002304 "cmp{w} {$src2, $src1|$src1, $src2}",
2305 [(set STATUS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
2306 Imp<[],[STATUS]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002307def CMP32mi : Ii32<0x81, MRM7m,
2308 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002309 "cmp{l} {$src2, $src1|$src1, $src2}",
2310 [(set STATUS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>,
2311 Imp<[],[STATUS]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002312
2313// Sign/Zero extenders
Chris Lattner3a173df2004-10-03 20:35:00 +00002314def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002315 "movs{bw|x} {$src, $dst|$dst, $src}",
2316 [(set R16:$dst, (sext R8:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002317def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002318 "movs{bw|x} {$src, $dst|$dst, $src}",
2319 [(set R16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002320def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002321 "movs{bl|x} {$src, $dst|$dst, $src}",
2322 [(set R32:$dst, (sext R8:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002323def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002324 "movs{bl|x} {$src, $dst|$dst, $src}",
2325 [(set R32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002326def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002327 "movs{wl|x} {$src, $dst|$dst, $src}",
2328 [(set R32:$dst, (sext R16:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002329def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002330 "movs{wl|x} {$src, $dst|$dst, $src}",
2331 [(set R32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002332
Chris Lattner3a173df2004-10-03 20:35:00 +00002333def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002334 "movz{bw|x} {$src, $dst|$dst, $src}",
2335 [(set R16:$dst, (zext R8:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002336def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002337 "movz{bw|x} {$src, $dst|$dst, $src}",
2338 [(set R16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002339def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002340 "movz{bl|x} {$src, $dst|$dst, $src}",
2341 [(set R32:$dst, (zext R8:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002342def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002343 "movz{bl|x} {$src, $dst|$dst, $src}",
2344 [(set R32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002345def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002346 "movz{wl|x} {$src, $dst|$dst, $src}",
2347 [(set R32:$dst, (zext R16:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002348def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002349 "movz{wl|x} {$src, $dst|$dst, $src}",
2350 [(set R32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2351
Nate Begemanf1702ac2005-06-27 21:20:31 +00002352//===----------------------------------------------------------------------===//
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002353// XMM Floating point support (requires SSE / SSE2)
Nate Begemanf1702ac2005-06-27 21:20:31 +00002354//===----------------------------------------------------------------------===//
2355
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002356def MOVSSrr : I<0x10, MRMSrcReg, (ops FR32:$dst, FR32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002357 "movss {$src, $dst|$dst, $src}", []>,
2358 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002359def MOVSDrr : I<0x10, MRMSrcReg, (ops FR64:$dst, FR64:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002360 "movsd {$src, $dst|$dst, $src}", []>,
2361 Requires<[HasSSE2]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002362
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002363def MOVSSrm : I<0x10, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
2364 "movss {$src, $dst|$dst, $src}",
2365 [(set FR32:$dst, (loadf32 addr:$src))]>,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002366 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002367def MOVSSmr : I<0x11, MRMDestMem, (ops f32mem:$dst, FR32:$src),
2368 "movss {$src, $dst|$dst, $src}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002369 [(store FR32:$src, addr:$dst)]>,
2370 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002371def MOVSDrm : I<0x10, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
2372 "movsd {$src, $dst|$dst, $src}",
2373 [(set FR64:$dst, (loadf64 addr:$src))]>,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002374 Requires<[HasSSE2]>, XD;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002375def MOVSDmr : I<0x11, MRMDestMem, (ops f64mem:$dst, FR64:$src),
2376 "movsd {$src, $dst|$dst, $src}",
2377 [(store FR64:$src, addr:$dst)]>,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002378 Requires<[HasSSE2]>, XD;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002379
2380def CVTTSD2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, FR64:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002381 "cvttsd2si {$src, $dst|$dst, $src}",
2382 [(set R32:$dst, (fp_to_sint FR64:$src))]>,
2383 Requires<[HasSSE2]>, XD;
Nate Begeman16b04f32005-07-15 00:38:55 +00002384def CVTTSD2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f64mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002385 "cvttsd2si {$src, $dst|$dst, $src}",
2386 [(set R32:$dst, (fp_to_sint (loadf64 addr:$src)))]>,
2387 Requires<[HasSSE2]>, XD;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002388def CVTTSS2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, FR32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002389 "cvttss2si {$src, $dst|$dst, $src}",
2390 [(set R32:$dst, (fp_to_sint FR32:$src))]>,
2391 Requires<[HasSSE1]>, XS;
Nate Begeman16b04f32005-07-15 00:38:55 +00002392def CVTTSS2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f32mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002393 "cvttss2si {$src, $dst|$dst, $src}",
2394 [(set R32:$dst, (fp_to_sint (loadf32 addr:$src)))]>,
2395 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002396def CVTSD2SSrr: I<0x5A, MRMSrcReg, (ops FR32:$dst, FR64:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002397 "cvtsd2ss {$src, $dst|$dst, $src}",
2398 [(set FR32:$dst, (fround FR64:$src))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002399 Requires<[HasSSE2]>, XS;
2400def CVTSD2SSrm: I<0x5A, MRMSrcMem, (ops FR32:$dst, f64mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002401 "cvtsd2ss {$src, $dst|$dst, $src}",
2402 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002403 Requires<[HasSSE2]>, XS;
2404def CVTSS2SDrr: I<0x5A, MRMSrcReg, (ops FR64:$dst, FR32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002405 "cvtss2sd {$src, $dst|$dst, $src}",
2406 [(set FR64:$dst, (fextend FR32:$src))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002407 Requires<[HasSSE2]>, XD;
2408def CVTSS2SDrm: I<0x5A, MRMSrcMem, (ops FR64:$dst, f32mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002409 "cvtss2sd {$src, $dst|$dst, $src}",
2410 [(set FR64:$dst, (fextend (loadf32 addr:$src)))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002411 Requires<[HasSSE2]>, XD;
2412def CVTSI2SSrr: I<0x2A, MRMSrcReg, (ops FR32:$dst, R32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002413 "cvtsi2ss {$src, $dst|$dst, $src}",
2414 [(set FR32:$dst, (sint_to_fp R32:$src))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002415 Requires<[HasSSE2]>, XS;
2416def CVTSI2SSrm: I<0x2A, MRMSrcMem, (ops FR32:$dst, i32mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002417 "cvtsi2ss {$src, $dst|$dst, $src}",
2418 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002419 Requires<[HasSSE2]>, XS;
2420def CVTSI2SDrr: I<0x2A, MRMSrcReg, (ops FR64:$dst, R32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002421 "cvtsi2sd {$src, $dst|$dst, $src}",
2422 [(set FR64:$dst, (sint_to_fp R32:$src))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002423 Requires<[HasSSE2]>, XD;
2424def CVTSI2SDrm: I<0x2A, MRMSrcMem, (ops FR64:$dst, i32mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002425 "cvtsi2sd {$src, $dst|$dst, $src}",
2426 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002427 Requires<[HasSSE2]>, XD;
Nate Begemanf63be7d2005-07-06 18:59:04 +00002428
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002429def SQRTSSrm : I<0x51, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002430 "sqrtss {$src, $dst|$dst, $src}",
2431 [(set FR32:$dst, (fsqrt (loadf32 addr:$src)))]>,
2432 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002433def SQRTSSrr : I<0x51, MRMSrcReg, (ops FR32:$dst, FR32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002434 "sqrtss {$src, $dst|$dst, $src}",
2435 [(set FR32:$dst, (fsqrt FR32:$src))]>,
2436 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002437def SQRTSDrm : I<0x51, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002438 "sqrtsd {$src, $dst|$dst, $src}",
2439 [(set FR64:$dst, (fsqrt (loadf64 addr:$src)))]>,
2440 Requires<[HasSSE2]>, XD;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002441def SQRTSDrr : I<0x51, MRMSrcReg, (ops FR64:$dst, FR64:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002442 "sqrtsd {$src, $dst|$dst, $src}",
2443 [(set FR64:$dst, (fsqrt FR64:$src))]>,
2444 Requires<[HasSSE2]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002445
Evan Chengd9558e02006-01-06 00:43:03 +00002446def UCOMISDrr: I<0x2E, MRMSrcReg, (ops FR64:$src1, FR64:$src2),
2447 "ucomisd {$src2, $src1|$src1, $src2}",
2448 [(set STATUS, (X86cmp FR64:$src1, FR64:$src2))]>,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002449 Requires<[HasSSE2]>, TB, OpSize;
Evan Chengd9558e02006-01-06 00:43:03 +00002450def UCOMISDrm: I<0x2E, MRMSrcMem, (ops FR64:$src1, f64mem:$src2),
2451 "ucomisd {$src2, $src1|$src1, $src2}",
2452 [(set STATUS, (X86cmp FR64:$src1, (loadf64 addr:$src2)))]>,
2453 Imp<[],[STATUS]>, Requires<[HasSSE2]>, TB, OpSize;
2454def UCOMISSrr: I<0x2E, MRMSrcReg, (ops FR32:$src1, FR32:$src2),
2455 "ucomiss {$src2, $src1|$src1, $src2}",
2456 [(set STATUS, (X86cmp FR32:$src1, FR32:$src2))]>,
2457 Imp<[],[STATUS]>, Requires<[HasSSE1]>, TB;
2458def UCOMISSrm: I<0x2E, MRMSrcMem, (ops FR32:$src1, f32mem:$src2),
2459 "ucomiss {$src2, $src1|$src1, $src2}",
2460 [(set STATUS, (X86cmp FR32:$src1, (loadf32 addr:$src2)))]>,
2461 Imp<[],[STATUS]>, Requires<[HasSSE1]>, TB;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002462
Evan Chengf0701842005-11-29 19:38:52 +00002463// Pseudo-instructions that map fld0 to xorps/xorpd for sse.
Nate Begeman1c73c7b2005-08-03 23:26:28 +00002464// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002465def FLD0SS : I<0x57, MRMSrcReg, (ops FR32:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002466 "xorps $dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Evan Cheng650d6882006-01-05 02:08:37 +00002467 Requires<[HasSSE1]>, TB;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002468def FLD0SD : I<0x57, MRMSrcReg, (ops FR64:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002469 "xorpd $dst, $dst", [(set FR64:$dst, fp64imm0)]>,
Evan Cheng650d6882006-01-05 02:08:37 +00002470 Requires<[HasSSE2]>, TB, OpSize;
Nate Begeman1c73c7b2005-08-03 23:26:28 +00002471
Nate Begemanf1702ac2005-06-27 21:20:31 +00002472let isTwoAddress = 1 in {
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002473// SSE Scalar Arithmetic
Nate Begemanf1702ac2005-06-27 21:20:31 +00002474let isCommutable = 1 in {
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002475def ADDSSrr : I<0x58, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002476 "addss {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002477 [(set FR32:$dst, (fadd FR32:$src1, FR32:$src2))]>,
2478 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002479def ADDSDrr : I<0x58, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002480 "addsd {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002481 [(set FR64:$dst, (fadd FR64:$src1, FR64:$src2))]>,
2482 Requires<[HasSSE2]>, XD;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002483def MULSSrr : I<0x59, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002484 "mulss {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002485 [(set FR32:$dst, (fmul FR32:$src1, FR32:$src2))]>,
2486 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002487def MULSDrr : I<0x59, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002488 "mulsd {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002489 [(set FR64:$dst, (fmul FR64:$src1, FR64:$src2))]>,
2490 Requires<[HasSSE2]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002491}
Nate Begemanf1702ac2005-06-27 21:20:31 +00002492
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002493def ADDSSrm : I<0x58, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2494 "addss {$src2, $dst|$dst, $src2}",
2495 [(set FR32:$dst, (fadd FR32:$src1, (loadf32 addr:$src2)))]>,
2496 Requires<[HasSSE1]>, XS;
2497def ADDSDrm : I<0x58, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2498 "addsd {$src2, $dst|$dst, $src2}",
2499 [(set FR64:$dst, (fadd FR64:$src1, (loadf64 addr:$src2)))]>,
2500 Requires<[HasSSE2]>, XD;
2501def MULSSrm : I<0x59, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2502 "mulss {$src2, $dst|$dst, $src2}",
2503 [(set FR32:$dst, (fmul FR32:$src1, (loadf32 addr:$src2)))]>,
2504 Requires<[HasSSE1]>, XS;
2505def MULSDrm : I<0x59, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2506 "mulsd {$src2, $dst|$dst, $src2}",
2507 [(set FR64:$dst, (fmul FR64:$src1, (loadf64 addr:$src2)))]>,
2508 Requires<[HasSSE2]>, XD;
2509
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002510def DIVSSrr : I<0x5E, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002511 "divss {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002512 [(set FR32:$dst, (fdiv FR32:$src1, FR32:$src2))]>,
2513 Requires<[HasSSE1]>, XS;
2514def DIVSSrm : I<0x5E, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2515 "divss {$src2, $dst|$dst, $src2}",
2516 [(set FR32:$dst, (fdiv FR32:$src1, (loadf32 addr:$src2)))]>,
2517 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002518def DIVSDrr : I<0x5E, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002519 "divsd {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002520 [(set FR64:$dst, (fdiv FR64:$src1, FR64:$src2))]>,
2521 Requires<[HasSSE2]>, XD;
2522def DIVSDrm : I<0x5E, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2523 "divsd {$src2, $dst|$dst, $src2}",
2524 [(set FR64:$dst, (fdiv FR64:$src1, (loadf64 addr:$src2)))]>,
2525 Requires<[HasSSE2]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002526
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002527def SUBSSrr : I<0x5C, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002528 "subss {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002529 [(set FR32:$dst, (fsub FR32:$src1, FR32:$src2))]>,
2530 Requires<[HasSSE1]>, XS;
2531def SUBSSrm : I<0x5C, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2532 "subss {$src2, $dst|$dst, $src2}",
2533 [(set FR32:$dst, (fsub FR32:$src1, (loadf32 addr:$src2)))]>,
2534 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002535def SUBSDrr : I<0x5C, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002536 "subsd {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002537 [(set FR64:$dst, (fsub FR64:$src1, FR64:$src2))]>,
2538 Requires<[HasSSE2]>, XD;
2539def SUBSDrm : I<0x5C, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2540 "subsd {$src2, $dst|$dst, $src2}",
2541 [(set FR64:$dst, (fsub FR64:$src1, (loadf64 addr:$src2)))]>,
2542 Requires<[HasSSE2]>, XD;
2543
2544// SSE Logical
2545let isCommutable = 1 in {
2546def ANDPSrr : I<0x54, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2547 "andps {$src2, $dst|$dst, $src2}", []>,
2548 Requires<[HasSSE1]>, TB;
2549def ANDPDrr : I<0x54, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2550 "andpd {$src2, $dst|$dst, $src2}", []>,
2551 Requires<[HasSSE2]>, TB, OpSize;
2552def ORPSrr : I<0x56, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2553 "orps {$src2, $dst|$dst, $src2}", []>,
2554 Requires<[HasSSE1]>, TB;
2555def ORPDrr : I<0x56, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2556 "orpd {$src2, $dst|$dst, $src2}", []>,
2557 Requires<[HasSSE2]>, TB, OpSize;
2558def XORPSrr : I<0x57, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2559 "xorps {$src2, $dst|$dst, $src2}", []>,
2560 Requires<[HasSSE1]>, TB;
2561def XORPDrr : I<0x57, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2562 "xorpd {$src2, $dst|$dst, $src2}", []>,
2563 Requires<[HasSSE2]>, TB, OpSize;
2564}
2565def ANDNPSrr : I<0x55, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2566 "andnps {$src2, $dst|$dst, $src2}", []>,
2567 Requires<[HasSSE1]>, TB;
2568def ANDNPDrr : I<0x55, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2569 "andnpd {$src2, $dst|$dst, $src2}", []>,
2570 Requires<[HasSSE2]>, TB, OpSize;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002571
2572def CMPSSrr : I<0xC2, MRMSrcReg,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002573 (ops FR32:$dst, FR32:$src1, FR32:$src, SSECC:$cc),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002574 "cmp${cc}ss {$src, $dst|$dst, $src}", []>,
2575 Requires<[HasSSE1]>, XS;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002576def CMPSSrm : I<0xC2, MRMSrcMem,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002577 (ops FR32:$dst, FR32:$src1, f32mem:$src, SSECC:$cc),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002578 "cmp${cc}ss {$src, $dst|$dst, $src}", []>,
2579 Requires<[HasSSE1]>, XS;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002580def CMPSDrr : I<0xC2, MRMSrcReg,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002581 (ops FR64:$dst, FR64:$src1, FR64:$src, SSECC:$cc),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002582 "cmp${cc}sd {$src, $dst|$dst, $src}", []>,
2583 Requires<[HasSSE1]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002584def CMPSDrm : I<0xC2, MRMSrcMem,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002585 (ops FR64:$dst, FR64:$src1, f64mem:$src, SSECC:$cc),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002586 "cmp${cc}sd {$src, $dst|$dst, $src}", []>,
2587 Requires<[HasSSE2]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002588}
Chris Lattner1cca5e32003-08-03 21:54:21 +00002589
2590//===----------------------------------------------------------------------===//
Chris Lattnerc515ad12005-12-21 07:50:26 +00002591// Floating Point Stack Support
Chris Lattner1cca5e32003-08-03 21:54:21 +00002592//===----------------------------------------------------------------------===//
2593
Chris Lattner58fe4592005-12-21 07:47:04 +00002594// Floating point support. All FP Stack operations are represented with two
2595// instructions here. The first instruction, generated by the instruction
2596// selector, uses "RFP" registers: a traditional register file to reference
2597// floating point values. These instructions are all psuedo instructions and
2598// use the "Fp" prefix. The second instruction is defined with FPI, which is
2599// the actual instruction emitted by the assembler. The FP stackifier pass
2600// converts one to the other after register allocation occurs.
2601//
2602// Note that the FpI instruction should have instruction selection info (e.g.
2603// a pattern) and the FPI instruction should have emission info (e.g. opcode
2604// encoding and asm printing info).
Chris Lattner1cca5e32003-08-03 21:54:21 +00002605
Chris Lattner58fe4592005-12-21 07:47:04 +00002606// FPI - Floating Point Instruction template.
2607class FPI<bits<8> o, Format F, dag ops, string asm> : I<o, F, ops, asm, []> {}
2608
Evan Cheng510e4782006-01-09 23:10:28 +00002609// FpI_ - Floating Point Psuedo Instruction template. Not Predicated.
2610class FpI_<dag ops, FPFormat fp, list<dag> pattern>
2611 : X86Inst<0, Pseudo, NoImm, ops, ""> {
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002612 let FPForm = fp; let FPFormBits = FPForm.Value;
2613 let Pattern = pattern;
2614}
2615
Chris Lattner58fe4592005-12-21 07:47:04 +00002616// Random Pseudo Instructions.
Evan Cheng510e4782006-01-09 23:10:28 +00002617def FpGETRESULT : FpI_<(ops RFP:$dst), SpecialFP,
2618 [(set RFP:$dst, X86fpget)]>; // FPR = ST(0)
Evan Chengd90eb7f2006-01-05 00:27:02 +00002619
Evan Chenge3413162006-01-09 18:33:28 +00002620let noResults = 1 in
Evan Cheng510e4782006-01-09 23:10:28 +00002621 def FpSETRESULT : FpI_<(ops RFP:$src), SpecialFP,
2622 [(X86fpset RFP:$src)]>, Imp<[], [ST0]>; // ST(0) = FPR
Evan Cheng2b4ea792005-12-26 09:11:45 +00002623
Evan Cheng510e4782006-01-09 23:10:28 +00002624// FpI - Floating Point Psuedo Instruction template. Predicated on FPStack.
2625class FpI<dag ops, FPFormat fp, list<dag> pattern> :
2626 FpI_<ops, fp, pattern>, Requires<[FPStack]>;
2627
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002628
Evan Cheng171049d2005-12-23 22:14:32 +00002629def FpMOV : FpI<(ops RFP:$dst, RFP:$src), SpecialFP, []>; // f1 = fmov f2
Chris Lattner1cca5e32003-08-03 21:54:21 +00002630
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002631// Arithmetic
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002632// Add, Sub, Mul, Div.
2633def FpADD : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2634 [(set RFP:$dst, (fadd RFP:$src1, RFP:$src2))]>;
2635def FpSUB : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2636 [(set RFP:$dst, (fsub RFP:$src1, RFP:$src2))]>;
2637def FpMUL : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2638 [(set RFP:$dst, (fmul RFP:$src1, RFP:$src2))]>;
2639def FpDIV : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2640 [(set RFP:$dst, (fdiv RFP:$src1, RFP:$src2))]>;
2641
2642class FPST0rInst<bits<8> o, string asm>
2643 : FPI<o, AddRegFrm, (ops RST:$op), asm>, D8;
2644class FPrST0Inst<bits<8> o, string asm>
2645 : FPI<o, AddRegFrm, (ops RST:$op), asm>, DC;
2646class FPrST0PInst<bits<8> o, string asm>
2647 : FPI<o, AddRegFrm, (ops RST:$op), asm>, DE;
2648
Chris Lattner58fe4592005-12-21 07:47:04 +00002649// Binary Ops with a memory source.
2650def FpADD32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002651 [(set RFP:$dst, (fadd RFP:$src1,
2652 (extloadf64f32 addr:$src2)))]>;
2653 // ST(0) = ST(0) + [mem32]
Chris Lattner58fe4592005-12-21 07:47:04 +00002654def FpADD64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002655 [(set RFP:$dst, (fadd RFP:$src1, (loadf64 addr:$src2)))]>;
2656 // ST(0) = ST(0) + [mem64]
Chris Lattner58fe4592005-12-21 07:47:04 +00002657def FpMUL32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002658 [(set RFP:$dst, (fmul RFP:$src1,
2659 (extloadf64f32 addr:$src2)))]>;
2660 // ST(0) = ST(0) * [mem32]
Chris Lattner58fe4592005-12-21 07:47:04 +00002661def FpMUL64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002662 [(set RFP:$dst, (fmul RFP:$src1, (loadf64 addr:$src2)))]>;
2663 // ST(0) = ST(0) * [mem64]
Chris Lattner58fe4592005-12-21 07:47:04 +00002664def FpSUB32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002665 [(set RFP:$dst, (fsub RFP:$src1,
2666 (extloadf64f32 addr:$src2)))]>;
2667 // ST(0) = ST(0) - [mem32]
Chris Lattner58fe4592005-12-21 07:47:04 +00002668def FpSUB64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002669 [(set RFP:$dst, (fsub RFP:$src1, (loadf64 addr:$src2)))]>;
2670 // ST(0) = ST(0) - [mem64]
Chris Lattner58fe4592005-12-21 07:47:04 +00002671def FpSUBR32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Chengd90eb7f2006-01-05 00:27:02 +00002672 [(set RFP:$dst, (fsub (extloadf64f32 addr:$src2),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002673 RFP:$src1))]>;
2674 // ST(0) = [mem32] - ST(0)
Chris Lattner58fe4592005-12-21 07:47:04 +00002675def FpSUBR64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002676 [(set RFP:$dst, (fsub (loadf64 addr:$src2), RFP:$src1))]>;
2677 // ST(0) = [mem64] - ST(0)
Chris Lattner58fe4592005-12-21 07:47:04 +00002678def FpDIV32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002679 [(set RFP:$dst, (fdiv RFP:$src1,
2680 (extloadf64f32 addr:$src2)))]>;
2681 // ST(0) = ST(0) / [mem32]
Chris Lattner58fe4592005-12-21 07:47:04 +00002682def FpDIV64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002683 [(set RFP:$dst, (fdiv RFP:$src1, (loadf64 addr:$src2)))]>;
2684 // ST(0) = ST(0) / [mem64]
Chris Lattner58fe4592005-12-21 07:47:04 +00002685def FpDIVR32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002686 [(set RFP:$dst, (fdiv (extloadf64f32 addr:$src2),
2687 RFP:$src1))]>;
2688 // ST(0) = [mem32] / ST(0)
Chris Lattner58fe4592005-12-21 07:47:04 +00002689def FpDIVR64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002690 [(set RFP:$dst, (fdiv (loadf64 addr:$src2), RFP:$src1))]>;
2691 // ST(0) = [mem64] / ST(0)
Chris Lattner58fe4592005-12-21 07:47:04 +00002692
2693
2694def FADD32m : FPI<0xD8, MRM0m, (ops f32mem:$src), "fadd{s} $src">;
2695def FADD64m : FPI<0xDC, MRM0m, (ops f64mem:$src), "fadd{l} $src">;
2696def FMUL32m : FPI<0xD8, MRM1m, (ops f32mem:$src), "fmul{s} $src">;
2697def FMUL64m : FPI<0xDC, MRM1m, (ops f64mem:$src), "fmul{l} $src">;
2698def FSUB32m : FPI<0xD8, MRM4m, (ops f32mem:$src), "fsub{s} $src">;
2699def FSUB64m : FPI<0xDC, MRM4m, (ops f64mem:$src), "fsub{l} $src">;
2700def FSUBR32m : FPI<0xD8, MRM5m, (ops f32mem:$src), "fsubr{s} $src">;
2701def FSUBR64m : FPI<0xDC, MRM5m, (ops f64mem:$src), "fsubr{l} $src">;
2702def FDIV32m : FPI<0xD8, MRM6m, (ops f32mem:$src), "fdiv{s} $src">;
2703def FDIV64m : FPI<0xDC, MRM6m, (ops f64mem:$src), "fdiv{l} $src">;
2704def FDIVR32m : FPI<0xD8, MRM7m, (ops f32mem:$src), "fdivr{s} $src">;
2705def FDIVR64m : FPI<0xDC, MRM7m, (ops f64mem:$src), "fdivr{l} $src">;
2706
2707// FIXME: Implement these when we have a dag-dag isel!
Evan Chengf7100622006-01-10 22:22:02 +00002708def FpIADD16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2709 [(set RFP:$dst, (fadd RFP:$src1,
2710 (sint_to_fp (loadi16 addr:$src2))))]>;
2711 // ST(0) = ST(0) + [mem16int]
2712def FpIADD32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2713 [(set RFP:$dst, (fadd RFP:$src1,
2714 (sint_to_fp (loadi32 addr:$src2))))]>;
2715 // ST(0) = ST(0) + [mem32int]
2716def FpIMUL16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2717 [(set RFP:$dst, (fmul RFP:$src1,
2718 (sint_to_fp (loadi16 addr:$src2))))]>;
2719 // ST(0) = ST(0) * [mem16int]
2720def FpIMUL32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2721 [(set RFP:$dst, (fmul RFP:$src1,
2722 (sint_to_fp (loadi32 addr:$src2))))]>;
2723 // ST(0) = ST(0) * [mem32int]
2724def FpISUB16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2725 [(set RFP:$dst, (fsub RFP:$src1,
2726 (sint_to_fp (loadi16 addr:$src2))))]>;
2727 // ST(0) = ST(0) - [mem16int]
2728def FpISUB32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2729 [(set RFP:$dst, (fsub RFP:$src1,
2730 (sint_to_fp (loadi32 addr:$src2))))]>;
2731 // ST(0) = ST(0) - [mem32int]
2732def FpISUBR16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2733 [(set RFP:$dst, (fsub (sint_to_fp (loadi16 addr:$src2)),
2734 RFP:$src1))]>;
2735 // ST(0) = [mem16int] - ST(0)
2736def FpISUBR32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2737 [(set RFP:$dst, (fsub (sint_to_fp (loadi32 addr:$src2)),
2738 RFP:$src1))]>;
2739 // ST(0) = [mem32int] - ST(0)
2740def FpIDIV16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2741 [(set RFP:$dst, (fdiv RFP:$src1,
2742 (sint_to_fp (loadi16 addr:$src2))))]>;
2743 // ST(0) = ST(0) / [mem16int]
2744def FpIDIV32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2745 [(set RFP:$dst, (fdiv RFP:$src1,
2746 (sint_to_fp (loadi32 addr:$src2))))]>;
2747 // ST(0) = ST(0) / [mem32int]
2748def FpIDIVR16m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2749 [(set RFP:$dst, (fdiv (sint_to_fp (loadi16 addr:$src2)),
2750 RFP:$src1))]>;
2751 // ST(0) = [mem16int] / ST(0)
2752def FpIDIVR32m : FpI<(ops RFP:$dst, RFP:$src1, i16mem:$src2), OneArgFPRW,
2753 [(set RFP:$dst, (fdiv (sint_to_fp (loadi32 addr:$src2)),
2754 RFP:$src1))]>;
2755 // ST(0) = [mem32int] / ST(0)
Chris Lattner58fe4592005-12-21 07:47:04 +00002756
Evan Chengf7100622006-01-10 22:22:02 +00002757def FIADD16m : FPI<0xDE, MRM0m, (ops i16mem:$src), "fiadd{s} $src">;
2758def FIADD32m : FPI<0xDA, MRM0m, (ops i32mem:$src), "fiadd{l} $src">;
2759def FIMUL16m : FPI<0xDE, MRM1m, (ops i16mem:$src), "fimul{s} $src">;
2760def FIMUL32m : FPI<0xDA, MRM1m, (ops i32mem:$src), "fimul{l} $src">;
2761def FISUB16m : FPI<0xDE, MRM4m, (ops i16mem:$src), "fisub{s} $src">;
2762def FISUB32m : FPI<0xDA, MRM4m, (ops i32mem:$src), "fisub{l} $src">;
2763def FISUBR16m : FPI<0xDE, MRM5m, (ops i16mem:$src), "fisubr{s} $src">;
2764def FISUBR32m : FPI<0xDA, MRM5m, (ops i32mem:$src), "fisubr{l} $src">;
2765def FIDIV16m : FPI<0xDE, MRM6m, (ops i16mem:$src), "fidiv{s} $src">;
2766def FIDIV32m : FPI<0xDA, MRM6m, (ops i32mem:$src), "fidiv{s} $src">;
2767def FIDIVR16m : FPI<0xDE, MRM7m, (ops i16mem:$src), "fidivr{s} $src">;
2768def FIDIVR32m : FPI<0xDA, MRM7m, (ops i32mem:$src), "fidivr{s} $src">;
Chris Lattner58fe4592005-12-21 07:47:04 +00002769
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002770// NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
2771// of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
2772// we have to put some 'r's in and take them out of weird places.
2773def FADDST0r : FPST0rInst <0xC0, "fadd $op">;
2774def FADDrST0 : FPrST0Inst <0xC0, "fadd {%ST(0), $op|$op, %ST(0)}">;
2775def FADDPrST0 : FPrST0PInst<0xC0, "faddp $op">;
2776def FSUBRST0r : FPST0rInst <0xE8, "fsubr $op">;
2777def FSUBrST0 : FPrST0Inst <0xE8, "fsub{r} {%ST(0), $op|$op, %ST(0)}">;
2778def FSUBPrST0 : FPrST0PInst<0xE8, "fsub{r}p $op">;
2779def FSUBST0r : FPST0rInst <0xE0, "fsub $op">;
2780def FSUBRrST0 : FPrST0Inst <0xE0, "fsub{|r} {%ST(0), $op|$op, %ST(0)}">;
2781def FSUBRPrST0 : FPrST0PInst<0xE0, "fsub{|r}p $op">;
2782def FMULST0r : FPST0rInst <0xC8, "fmul $op">;
2783def FMULrST0 : FPrST0Inst <0xC8, "fmul {%ST(0), $op|$op, %ST(0)}">;
2784def FMULPrST0 : FPrST0PInst<0xC8, "fmulp $op">;
2785def FDIVRST0r : FPST0rInst <0xF8, "fdivr $op">;
2786def FDIVrST0 : FPrST0Inst <0xF8, "fdiv{r} {%ST(0), $op|$op, %ST(0)}">;
2787def FDIVPrST0 : FPrST0PInst<0xF8, "fdiv{r}p $op">;
2788def FDIVST0r : FPST0rInst <0xF0, "fdiv $op">;
2789def FDIVRrST0 : FPrST0Inst <0xF0, "fdiv{|r} {%ST(0), $op|$op, %ST(0)}">;
2790def FDIVRPrST0 : FPrST0PInst<0xF0, "fdiv{|r}p $op">;
2791
2792
2793// Unary operations.
2794def FpCHS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2795 [(set RFP:$dst, (fneg RFP:$src))]>;
2796def FpABS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2797 [(set RFP:$dst, (fabs RFP:$src))]>;
2798def FpSQRT : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2799 [(set RFP:$dst, (fsqrt RFP:$src))]>;
2800def FpSIN : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2801 [(set RFP:$dst, (fsin RFP:$src))]>;
2802def FpCOS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2803 [(set RFP:$dst, (fcos RFP:$src))]>;
2804def FpTST : FpI<(ops RFP:$src), OneArgFP,
2805 []>;
2806
2807def FCHS : FPI<0xE0, RawFrm, (ops), "fchs">, D9;
2808def FABS : FPI<0xE1, RawFrm, (ops), "fabs">, D9;
2809def FSQRT : FPI<0xFA, RawFrm, (ops), "fsqrt">, D9;
2810def FSIN : FPI<0xFE, RawFrm, (ops), "fsin">, D9;
2811def FCOS : FPI<0xFF, RawFrm, (ops), "fcos">, D9;
2812def FTST : FPI<0xE4, RawFrm, (ops), "ftst">, D9;
2813
2814
Chris Lattner58fe4592005-12-21 07:47:04 +00002815// Floating point cmovs.
2816let isTwoAddress = 1 in {
Evan Chengaaca22c2006-01-10 20:26:56 +00002817 def FpCMOVB : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2818 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2819 X86_COND_B, STATUS))]>;
2820 def FpCMOVBE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2821 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2822 X86_COND_BE, STATUS))]>;
2823 def FpCMOVE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2824 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2825 X86_COND_E, STATUS))]>;
2826 def FpCMOVP : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2827 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2828 X86_COND_P, STATUS))]>;
2829 def FpCMOVAE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2830 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2831 X86_COND_AE, STATUS))]>;
2832 def FpCMOVA : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2833 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2834 X86_COND_A, STATUS))]>;
2835 def FpCMOVNE : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2836 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2837 X86_COND_NE, STATUS))]>;
2838 def FpCMOVNP : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), CondMovFP,
2839 [(set RFP:$dst, (X86cmov RFP:$src1, RFP:$src2,
2840 X86_COND_NP, STATUS))]>;
Chris Lattner58fe4592005-12-21 07:47:04 +00002841}
2842
2843def FCMOVB : FPI<0xC0, AddRegFrm, (ops RST:$op),
2844 "fcmovb {$op, %ST(0)|%ST(0), $op}">, DA;
2845def FCMOVBE : FPI<0xD0, AddRegFrm, (ops RST:$op),
2846 "fcmovbe {$op, %ST(0)|%ST(0), $op}">, DA;
2847def FCMOVE : FPI<0xC8, AddRegFrm, (ops RST:$op),
2848 "fcmove {$op, %ST(0)|%ST(0), $op}">, DA;
2849def FCMOVP : FPI<0xD8, AddRegFrm, (ops RST:$op),
2850 "fcmovu {$op, %ST(0)|%ST(0), $op}">, DA;
2851def FCMOVAE : FPI<0xC0, AddRegFrm, (ops RST:$op),
2852 "fcmovae {$op, %ST(0)|%ST(0), $op}">, DB;
2853def FCMOVA : FPI<0xD0, AddRegFrm, (ops RST:$op),
2854 "fcmova {$op, %ST(0)|%ST(0), $op}">, DB;
2855def FCMOVNE : FPI<0xC8, AddRegFrm, (ops RST:$op),
2856 "fcmovne {$op, %ST(0)|%ST(0), $op}">, DB;
2857def FCMOVNP : FPI<0xD8, AddRegFrm, (ops RST:$op),
2858 "fcmovnu {$op, %ST(0)|%ST(0), $op}">, DB;
2859
2860// Floating point loads & stores.
2861def FpLD32m : FpI<(ops RFP:$dst, f32mem:$src), ZeroArgFP,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002862 [(set RFP:$dst, (extloadf64f32 addr:$src))]>;
Chris Lattner58fe4592005-12-21 07:47:04 +00002863def FpLD64m : FpI<(ops RFP:$dst, f64mem:$src), ZeroArgFP,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002864 [(set RFP:$dst, (loadf64 addr:$src))]>;
Chris Lattner58fe4592005-12-21 07:47:04 +00002865def FpILD16m : FpI<(ops RFP:$dst, i16mem:$src), ZeroArgFP,
Evan Chengf7100622006-01-10 22:22:02 +00002866 [(set RFP:$dst, (sint_to_fp (loadi16 addr:$src)))]>;
Chris Lattner58fe4592005-12-21 07:47:04 +00002867def FpILD32m : FpI<(ops RFP:$dst, i32mem:$src), ZeroArgFP,
Evan Chengf7100622006-01-10 22:22:02 +00002868 [(set RFP:$dst, (sint_to_fp (loadi32 addr:$src)))]>;
Chris Lattner58fe4592005-12-21 07:47:04 +00002869def FpILD64m : FpI<(ops RFP:$dst, i64mem:$src), ZeroArgFP,
Evan Chengf7100622006-01-10 22:22:02 +00002870 [(set RFP:$dst, (X86fild64m addr:$src))]>;
Evan Chengb077b842005-12-21 02:39:21 +00002871
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002872def FpST32m : FpI<(ops f32mem:$op, RFP:$src), OneArgFP,
2873 [(truncstore RFP:$src, addr:$op, f32)]>;
2874def FpST64m : FpI<(ops f64mem:$op, RFP:$src), OneArgFP,
2875 [(store RFP:$src, addr:$op)]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +00002876
Chris Lattner58fe4592005-12-21 07:47:04 +00002877def FpSTP32m : FpI<(ops f32mem:$op, RFP:$src), OneArgFP, []>;
2878def FpSTP64m : FpI<(ops f64mem:$op, RFP:$src), OneArgFP, []>;
2879def FpIST16m : FpI<(ops i16mem:$op, RFP:$src), OneArgFP, []>;
2880def FpIST32m : FpI<(ops i32mem:$op, RFP:$src), OneArgFP, []>;
2881def FpIST64m : FpI<(ops i64mem:$op, RFP:$src), OneArgFP, []>;
Alkis Evlogimenos978f6292004-09-08 16:54:54 +00002882
Chris Lattner58fe4592005-12-21 07:47:04 +00002883def FLD32m : FPI<0xD9, MRM0m, (ops f32mem:$src), "fld{s} $src">;
2884def FLD64m : FPI<0xDD, MRM0m, (ops f64mem:$src), "fld{l} $src">;
2885def FILD16m : FPI<0xDF, MRM0m, (ops i16mem:$src), "fild{s} $src">;
2886def FILD32m : FPI<0xDB, MRM0m, (ops i32mem:$src), "fild{l} $src">;
2887def FILD64m : FPI<0xDF, MRM5m, (ops i64mem:$src), "fild{ll} $src">;
2888def FST32m : FPI<0xD9, MRM2m, (ops f32mem:$dst), "fst{s} $dst">;
2889def FST64m : FPI<0xDD, MRM2m, (ops f64mem:$dst), "fst{l} $dst">;
2890def FSTP32m : FPI<0xD9, MRM3m, (ops f32mem:$dst), "fstp{s} $dst">;
2891def FSTP64m : FPI<0xDD, MRM3m, (ops f64mem:$dst), "fstp{l} $dst">;
2892def FIST16m : FPI<0xDF, MRM2m, (ops i16mem:$dst), "fist{s} $dst">;
2893def FIST32m : FPI<0xDB, MRM2m, (ops i32mem:$dst), "fist{l} $dst">;
2894def FISTP16m : FPI<0xDF, MRM3m, (ops i16mem:$dst), "fistp{s} $dst">;
2895def FISTP32m : FPI<0xDB, MRM3m, (ops i32mem:$dst), "fistp{l} $dst">;
2896def FISTP64m : FPI<0xDF, MRM7m, (ops i64mem:$dst), "fistp{ll} $dst">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002897
Chris Lattner58fe4592005-12-21 07:47:04 +00002898// FP Stack manipulation instructions.
2899def FLDrr : FPI<0xC0, AddRegFrm, (ops RST:$op), "fld $op">, D9;
2900def FSTrr : FPI<0xD0, AddRegFrm, (ops RST:$op), "fst $op">, DD;
2901def FSTPrr : FPI<0xD8, AddRegFrm, (ops RST:$op), "fstp $op">, DD;
2902def FXCH : FPI<0xC8, AddRegFrm, (ops RST:$op), "fxch $op">, D9;
Chris Lattner490e86f2004-04-11 20:24:15 +00002903
Chris Lattner58fe4592005-12-21 07:47:04 +00002904// Floating point constant loads.
Evan Cheng650d6882006-01-05 02:08:37 +00002905def FpLD0 : FpI<(ops RFP:$dst), ZeroArgFP,
2906 [(set RFP:$dst, fp64imm0)]>;
2907def FpLD1 : FpI<(ops RFP:$dst), ZeroArgFP,
2908 [(set RFP:$dst, fp64imm1)]>;
2909
Chris Lattner58fe4592005-12-21 07:47:04 +00002910def FLD0 : FPI<0xEE, RawFrm, (ops), "fldz">, D9;
2911def FLD1 : FPI<0xE8, RawFrm, (ops), "fld1">, D9;
Chris Lattner490e86f2004-04-11 20:24:15 +00002912
Chris Lattner1c54a852004-03-31 22:02:13 +00002913
Chris Lattner58fe4592005-12-21 07:47:04 +00002914// Floating point compares.
Evan Chengd9558e02006-01-06 00:43:03 +00002915def FpUCOMr : FpI<(ops RFP:$lhs, RFP:$rhs), CompareFP,
Chris Lattner58fe4592005-12-21 07:47:04 +00002916 []>; // FPSW = cmp ST(0) with ST(i)
Evan Chengd9558e02006-01-06 00:43:03 +00002917def FpUCOMIr : FpI<(ops RFP:$lhs, RFP:$rhs), CompareFP,
2918 [(set STATUS, (X86cmp RFP:$lhs, RFP:$rhs))]>,
2919 Imp<[],[STATUS]>; // CC = cmp ST(0) with ST(i)
Chris Lattner1cca5e32003-08-03 21:54:21 +00002920
Chris Lattner58fe4592005-12-21 07:47:04 +00002921def FUCOMr : FPI<0xE0, AddRegFrm, // FPSW = cmp ST(0) with ST(i)
2922 (ops RST:$reg),
2923 "fucom $reg">, DD, Imp<[ST0],[]>;
2924def FUCOMPr : FPI<0xE8, AddRegFrm, // FPSW = cmp ST(0) with ST(i), pop
2925 (ops RST:$reg),
2926 "fucomp $reg">, DD, Imp<[ST0],[]>;
2927def FUCOMPPr : FPI<0xE9, RawFrm, // cmp ST(0) with ST(1), pop, pop
2928 (ops),
2929 "fucompp">, DA, Imp<[ST0],[]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002930
Chris Lattner58fe4592005-12-21 07:47:04 +00002931def FUCOMIr : FPI<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i)
2932 (ops RST:$reg),
2933 "fucomi {$reg, %ST(0)|%ST(0), $reg}">, DB, Imp<[ST0],[]>;
2934def FUCOMIPr : FPI<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i), pop
2935 (ops RST:$reg),
2936 "fucomip {$reg, %ST(0)|%ST(0), $reg}">, DF, Imp<[ST0],[]>;
Chris Lattner0e967d42004-08-01 08:13:11 +00002937
Chris Lattnera1b5e162004-04-12 01:38:55 +00002938
Chris Lattner58fe4592005-12-21 07:47:04 +00002939// Floating point flag ops.
Chris Lattner3a173df2004-10-03 20:35:00 +00002940def FNSTSW8r : I<0xE0, RawFrm, // AX = fp flags
Evan Chengf0701842005-11-29 19:38:52 +00002941 (ops), "fnstsw", []>, DF, Imp<[],[AX]>;
Chris Lattner96563df2004-08-01 06:01:00 +00002942
Chris Lattner3a173df2004-10-03 20:35:00 +00002943def FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world
Evan Chengf0701842005-11-29 19:38:52 +00002944 (ops i16mem:$dst), "fnstcw $dst", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002945def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
Evan Chengf0701842005-11-29 19:38:52 +00002946 (ops i16mem:$dst), "fldcw $dst", []>;
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002947
2948
2949//===----------------------------------------------------------------------===//
2950// Miscellaneous Instructions
2951//===----------------------------------------------------------------------===//
2952
Evan Chenge3413162006-01-09 18:33:28 +00002953def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
2954 TB, Imp<[],[EAX,EDX]>;
Evan Chengcfa260b2006-01-06 02:31:59 +00002955
Evan Cheng510e4782006-01-09 23:10:28 +00002956
2957//===----------------------------------------------------------------------===//
2958// Non-Instruction Patterns
2959//===----------------------------------------------------------------------===//
2960
Evan Cheng002fe9b2006-01-12 07:56:47 +00002961// GlobalAddress and ExternalSymbol
Evan Cheng77e90432006-01-12 19:36:31 +00002962def : Pat<(i32 globaladdr:$dst), (MOV32ri tglobaladdr:$dst)>;
2963def : Pat<(i32 externalsym:$dst), (MOV32ri texternalsym:$dst)>;
Evan Cheng002fe9b2006-01-12 07:56:47 +00002964
Evan Cheng510e4782006-01-09 23:10:28 +00002965// Calls
2966def : Pat<(X86call tglobaladdr:$dst),
2967 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng8700e142006-01-11 06:09:51 +00002968def : Pat<(X86call texternalsym:$dst),
2969 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002970
2971// X86 specific add which produces a flag.
2972def : Pat<(X86addflag R32:$src1, R32:$src2),
2973 (ADD32rr R32:$src1, R32:$src2)>;
2974def : Pat<(X86addflag R32:$src1, (load addr:$src2)),
2975 (ADD32rm R32:$src1, addr:$src2)>;
2976def : Pat<(X86addflag R32:$src1, imm:$src2),
2977 (ADD32ri R32:$src1, imm:$src2)>;
2978def : Pat<(X86addflag R32:$src1, i32immSExt8:$src2),
2979 (ADD32ri8 R32:$src1, i32immSExt8:$src2)>;
2980
2981def : Pat<(X86subflag R32:$src1, R32:$src2),
2982 (SUB32rr R32:$src1, R32:$src2)>;
2983def : Pat<(X86subflag R32:$src1, (load addr:$src2)),
2984 (SUB32rm R32:$src1, addr:$src2)>;
2985def : Pat<(X86subflag R32:$src1, imm:$src2),
2986 (SUB32ri R32:$src1, imm:$src2)>;
2987def : Pat<(X86subflag R32:$src1, i32immSExt8:$src2),
2988 (SUB32ri8 R32:$src1, i32immSExt8:$src2)>;
2989
2990// {s|z}extload bool -> {s|z}extload byte
2991def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2992def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2993def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2994def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2995
2996// extload bool -> extload byte
2997def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2998
2999// anyext -> zext
3000def : Pat<(i16 (anyext R8 :$src)), (MOVZX16rr8 R8 :$src)>;
3001def : Pat<(i32 (anyext R8 :$src)), (MOVZX32rr8 R8 :$src)>;
3002def : Pat<(i32 (anyext R16:$src)), (MOVZX32rr16 R16:$src)>;
3003
3004// Required for RET of f32 / f64 values.
3005def : Pat<(X86fld addr:$src, f32), (FpLD32m addr:$src)>;
3006def : Pat<(X86fld addr:$src, f64), (FpLD64m addr:$src)>;
3007
3008// Required for CALL which return f32 / f64 values.
3009def : Pat<(X86fst RFP:$src, addr:$op, f32), (FpST32m addr:$op, RFP:$src)>;
3010def : Pat<(X86fst RFP:$src, addr:$op, f64), (FpST64m addr:$op, RFP:$src)>;
3011
3012// Floatin point constant -0.0 and -1.0
3013def : Pat<(f64 fp64immneg0), (FpCHS (FpLD0))>, Requires<[FPStack]>;
3014def : Pat<(f64 fp64immneg1), (FpCHS (FpLD1))>, Requires<[FPStack]>;
3015
Evan Cheng510e4782006-01-09 23:10:28 +00003016// RFP undef
3017def : Pat<(f64 (undef)), (FpLD0)>, Requires<[FPStack]>;
3018
3019
Evan Chengcfa260b2006-01-06 02:31:59 +00003020//===----------------------------------------------------------------------===//
3021// Some peepholes
3022//===----------------------------------------------------------------------===//
3023
3024// (shl x, 1) ==> (add x, x)
3025def : Pat<(shl R8 :$src1, (i8 1)), (ADD8rr R8 :$src1, R8 :$src1)>;
3026def : Pat<(shl R16:$src1, (i8 1)), (ADD16rr R16:$src1, R16:$src1)>;
3027def : Pat<(shl R32:$src1, (i8 1)), (ADD32rr R32:$src1, R32:$src1)>;