blob: d38840083dbe2941224b1e37cc553e7a35d84c6e [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 Chengd9558e02006-01-06 00:43:03 +000020def SDTX86CmpTest : SDTypeProfile<1, 2, [SDTCisVT<0, FlagVT>, SDTCisSameAs<1, 2>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000021
22def SDTX86Cmov : SDTypeProfile<1, 4,
23 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
Evan Chengd9558e02006-01-06 00:43:03 +000024 SDTCisVT<3, i8>, SDTCisVT<4, FlagVT>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000025
Evan Cheng898101c2005-12-19 23:12:38 +000026def SDTX86BrCond : SDTypeProfile<0, 3,
27 [SDTCisVT<0, OtherVT>,
Evan Chengd9558e02006-01-06 00:43:03 +000028 SDTCisVT<1, i8>, SDTCisVT<2, FlagVT>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000029
Evan Chengd5781fc2005-12-21 20:21:51 +000030def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Chengd9558e02006-01-06 00:43:03 +000031 [SDTCisVT<0, i8>, SDTCisVT<1, i8>,
Evan Chengd5781fc2005-12-21 20:21:51 +000032 SDTCisVT<2, FlagVT>]>;
33
Evan Chengd9558e02006-01-06 00:43:03 +000034def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000035
Evan Cheng38bcbaf2005-12-23 07:31:11 +000036def SDTX86Fld : SDTypeProfile<1, 2, [SDTCisVT<0, f64>,
Evan Chengb077b842005-12-21 02:39:21 +000037 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000038def SDTX86Fst : SDTypeProfile<0, 3, [SDTCisFP<0>,
39 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
Evan Chengb077b842005-12-21 02:39:21 +000040
Evan Chengd90eb7f2006-01-05 00:27:02 +000041
42def SDTX86FpGet : SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>;
Evan Cheng171049d2005-12-23 22:14:32 +000043def SDTX86FpSet : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
Evan Chengb077b842005-12-21 02:39:21 +000044
Evan Chengd5781fc2005-12-21 20:21:51 +000045def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest, []>;
46def X86test : SDNode<"X86ISD::TEST", SDTX86CmpTest, []>;
Evan Chengb077b842005-12-21 02:39:21 +000047
Evan Chengd5781fc2005-12-21 20:21:51 +000048def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov, []>;
Evan Chengd9558e02006-01-06 00:43:03 +000049def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond, [SDNPHasChain]>;
50def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC, []>;
Evan Chengb077b842005-12-21 02:39:21 +000051
Evan Chengd9558e02006-01-06 00:43:03 +000052def X86ret : SDNode<"X86ISD::RET", SDTX86Ret, [SDNPHasChain]>;
53def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret, [SDNPHasChain]>;
Evan Chengb077b842005-12-21 02:39:21 +000054
Evan Chengd5781fc2005-12-21 20:21:51 +000055def X86fld : SDNode<"X86ISD::FLD", SDTX86Fld, [SDNPHasChain]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000056def X86fst : SDNode<"X86ISD::FST", SDTX86Fst, [SDNPHasChain]>;
Evan Chengb077b842005-12-21 02:39:21 +000057
Evan Chengd90eb7f2006-01-05 00:27:02 +000058def X86fpget : SDNode<"X86ISD::FP_GET_RESULT",
59 SDTX86FpGet, [SDNPHasChain]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000060def X86fpset : SDNode<"X86ISD::FP_SET_RESULT",
61 SDTX86FpSet, [SDNPHasChain]>;
Evan Chengaed7c722005-12-17 01:24:02 +000062
Evan Chengd90eb7f2006-01-05 00:27:02 +000063def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
64def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
65 SDTCisVT<1, i32> ]>;
66def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
67 [SDNPHasChain]>;
68def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
69 [SDNPHasChain]>;
70
71def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
72def call : SDNode<"X86ISD::CALL", SDT_X86Call, [SDNPHasChain]>;
73
Evan Chengaed7c722005-12-17 01:24:02 +000074//===----------------------------------------------------------------------===//
75// X86 Operand Definitions.
76//
77
Chris Lattner66fa1dc2004-08-11 02:25:00 +000078// *mem - Operand definitions for the funky X86 addressing mode operands.
79//
Chris Lattner45432512005-12-17 19:47:05 +000080class X86MemOperand<string printMethod> : Operand<i32> {
Nate Begeman391c5d22005-11-30 18:54:35 +000081 let PrintMethod = printMethod;
Chris Lattner6adaf792005-11-19 07:01:30 +000082 let NumMIOperands = 4;
83 let MIOperandInfo = (ops R32, i8imm, R32, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +000084}
Nate Begeman391c5d22005-11-30 18:54:35 +000085
Chris Lattner45432512005-12-17 19:47:05 +000086def i8mem : X86MemOperand<"printi8mem">;
87def i16mem : X86MemOperand<"printi16mem">;
88def i32mem : X86MemOperand<"printi32mem">;
89def i64mem : X86MemOperand<"printi64mem">;
90def f32mem : X86MemOperand<"printf32mem">;
91def f64mem : X86MemOperand<"printf64mem">;
92def f80mem : X86MemOperand<"printf80mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +000093
Nate Begeman16b04f32005-07-15 00:38:55 +000094def SSECC : Operand<i8> {
95 let PrintMethod = "printSSECC";
96}
Chris Lattner66fa1dc2004-08-11 02:25:00 +000097
Chris Lattnerf124d5e2005-11-18 01:04:42 +000098// A couple of more descriptive operand definitions.
99// 16-bits but only 8 bits are significant.
100def i16i8imm : Operand<i16>;
101// 32-bits but only 8 bits are significant.
102def i32i8imm : Operand<i32>;
103
Chris Lattnere4ead0c2004-08-11 06:59:12 +0000104// PCRelative calls need special operand formatting.
105let PrintMethod = "printCallOperand" in
106 def calltarget : Operand<i32>;
107
Evan Chengd35b8c12005-12-04 08:19:43 +0000108// Branch targets have OtherVT type.
109def brtarget : Operand<OtherVT>;
110
Evan Chengaed7c722005-12-17 01:24:02 +0000111//===----------------------------------------------------------------------===//
112// X86 Complex Pattern Definitions.
113//
114
Evan Chengec693f72005-12-08 02:01:35 +0000115// Define X86 specific addressing mode.
Evan Cheng670fd8f2005-12-08 02:15:07 +0000116def addr : ComplexPattern<i32, 4, "SelectAddr", []>;
Evan Cheng502c5bb2005-12-15 08:31:04 +0000117def leaaddr : ComplexPattern<i32, 4, "SelectLEAAddr",
Evan Cheng3a03ebb2005-12-21 23:05:39 +0000118 [add, frameindex, constpool,
119 globaladdr, tglobaladdr, externalsym]>;
Evan Chengec693f72005-12-08 02:01:35 +0000120
Evan Chengaed7c722005-12-17 01:24:02 +0000121//===----------------------------------------------------------------------===//
122// X86 Instruction Format Definitions.
123//
124
Chris Lattner1cca5e32003-08-03 21:54:21 +0000125// Format specifies the encoding used by the instruction. This is part of the
126// ad-hoc solution used to emit machine instruction encodings by our machine
127// code emitter.
128class Format<bits<5> val> {
129 bits<5> Value = val;
130}
131
132def Pseudo : Format<0>; def RawFrm : Format<1>;
133def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
134def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
135def MRMSrcMem : Format<6>;
Alkis Evlogimenos169584e2004-02-27 18:55:12 +0000136def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
137def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
138def MRM6r : Format<22>; def MRM7r : Format<23>;
139def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
140def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
141def MRM6m : Format<30>; def MRM7m : Format<31>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000142
Evan Chengaed7c722005-12-17 01:24:02 +0000143//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000144// X86 Instruction Predicate Definitions.
145def HasSSE1 : Predicate<"X86Vector >= SSE">;
146def HasSSE2 : Predicate<"X86Vector >= SSE2">;
147def HasSSE3 : Predicate<"X86Vector >= SSE3">;
Evan Cheng38bcbaf2005-12-23 07:31:11 +0000148def FPStack : Predicate<"X86Vector < SSE2">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000149
150//===----------------------------------------------------------------------===//
Evan Chengaed7c722005-12-17 01:24:02 +0000151// X86 specific pattern fragments.
152//
153
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000154// ImmType - This specifies the immediate type used by an instruction. This is
Chris Lattner1cca5e32003-08-03 21:54:21 +0000155// part of the ad-hoc solution used to emit machine instruction encodings by our
156// machine code emitter.
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000157class ImmType<bits<2> val> {
158 bits<2> Value = val;
159}
160def NoImm : ImmType<0>;
161def Imm8 : ImmType<1>;
162def Imm16 : ImmType<2>;
163def Imm32 : ImmType<3>;
164
Chris Lattner1cca5e32003-08-03 21:54:21 +0000165// FPFormat - This specifies what form this FP instruction has. This is used by
166// the Floating-Point stackifier pass.
167class FPFormat<bits<3> val> {
168 bits<3> Value = val;
169}
170def NotFP : FPFormat<0>;
171def ZeroArgFP : FPFormat<1>;
172def OneArgFP : FPFormat<2>;
173def OneArgFPRW : FPFormat<3>;
174def TwoArgFP : FPFormat<4>;
Chris Lattnerab8decc2004-06-11 04:41:24 +0000175def CompareFP : FPFormat<5>;
176def CondMovFP : FPFormat<6>;
177def SpecialFP : FPFormat<7>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000178
179
Chris Lattner3a173df2004-10-03 20:35:00 +0000180class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
181 : Instruction {
Chris Lattnerc8f45872003-08-04 04:59:56 +0000182 let Namespace = "X86";
Chris Lattner1cca5e32003-08-03 21:54:21 +0000183
Chris Lattner1cca5e32003-08-03 21:54:21 +0000184 bits<8> Opcode = opcod;
185 Format Form = f;
186 bits<5> FormBits = Form.Value;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000187 ImmType ImmT = i;
188 bits<2> ImmTypeBits = ImmT.Value;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000189
Chris Lattnerc96bb812004-08-11 07:12:04 +0000190 dag OperandList = ops;
191 string AsmString = AsmStr;
192
John Criswell4ffff9e2004-04-08 20:31:47 +0000193 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000194 // Attributes specific to X86 instructions...
John Criswell4ffff9e2004-04-08 20:31:47 +0000195 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000196 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
John Criswell4ffff9e2004-04-08 20:31:47 +0000197
Chris Lattner1cca5e32003-08-03 21:54:21 +0000198 bits<4> Prefix = 0; // Which prefix byte does this inst have?
199 FPFormat FPForm; // What flavor of FP instruction is this?
200 bits<3> FPFormBits = 0;
201}
202
203class Imp<list<Register> uses, list<Register> defs> {
204 list<Register> Uses = uses;
205 list<Register> Defs = defs;
206}
207
208
209// Prefix byte classes which are used to indicate to the ad-hoc machine code
210// emitter that various prefix bytes are required.
211class OpSize { bit hasOpSizePrefix = 1; }
212class TB { bits<4> Prefix = 1; }
Chris Lattner915e5e52004-02-12 17:53:22 +0000213class REP { bits<4> Prefix = 2; }
214class D8 { bits<4> Prefix = 3; }
215class D9 { bits<4> Prefix = 4; }
216class DA { bits<4> Prefix = 5; }
217class DB { bits<4> Prefix = 6; }
218class DC { bits<4> Prefix = 7; }
219class DD { bits<4> Prefix = 8; }
220class DE { bits<4> Prefix = 9; }
221class DF { bits<4> Prefix = 10; }
Nate Begemanf1702ac2005-06-27 21:20:31 +0000222class XD { bits<4> Prefix = 11; }
223class XS { bits<4> Prefix = 12; }
Chris Lattner1cca5e32003-08-03 21:54:21 +0000224
225
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000226//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000227// Pattern fragments...
228//
Evan Chengd9558e02006-01-06 00:43:03 +0000229
230// X86 specific condition code. These correspond to CondCode in
231// X86ISelLowering.h. They must be kept in synch.
232def X86_COND_A : PatLeaf<(i8 0)>;
233def X86_COND_AE : PatLeaf<(i8 1)>;
234def X86_COND_B : PatLeaf<(i8 2)>;
235def X86_COND_BE : PatLeaf<(i8 3)>;
236def X86_COND_E : PatLeaf<(i8 4)>;
237def X86_COND_G : PatLeaf<(i8 5)>;
238def X86_COND_GE : PatLeaf<(i8 6)>;
239def X86_COND_L : PatLeaf<(i8 7)>;
240def X86_COND_LE : PatLeaf<(i8 8)>;
241def X86_COND_NE : PatLeaf<(i8 9)>;
242def X86_COND_NO : PatLeaf<(i8 10)>;
243def X86_COND_NP : PatLeaf<(i8 11)>;
244def X86_COND_NS : PatLeaf<(i8 12)>;
245def X86_COND_O : PatLeaf<(i8 13)>;
246def X86_COND_P : PatLeaf<(i8 14)>;
247def X86_COND_S : PatLeaf<(i8 15)>;
248
Evan Cheng9b6b6422005-12-13 00:14:11 +0000249def i16immSExt8 : PatLeaf<(i16 imm), [{
250 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000251 // sign extended field.
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000252 return (int)N->getValue() == (signed char)N->getValue();
253}]>;
254
Evan Cheng9b6b6422005-12-13 00:14:11 +0000255def i32immSExt8 : PatLeaf<(i32 imm), [{
256 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000257 // sign extended field.
258 return (int)N->getValue() == (signed char)N->getValue();
259}]>;
260
Evan Cheng9b6b6422005-12-13 00:14:11 +0000261def i16immZExt8 : PatLeaf<(i16 imm), [{
262 // i16immZExt8 predicate - True if the 16-bit immediate fits in a 8-bit zero
Evan Chengb3558542005-12-13 00:01:09 +0000263 // extended field.
Chris Lattner3d36a9f2005-12-05 02:40:25 +0000264 return (unsigned)N->getValue() == (unsigned char)N->getValue();
265}]>;
266
Evan Cheng650d6882006-01-05 02:08:37 +0000267def fp32imm0 : PatLeaf<(f32 fpimm), [{
268 return N->isExactlyValue(+0.0);
269}]>;
270
271def fp64imm0 : PatLeaf<(f64 fpimm), [{
272 return N->isExactlyValue(+0.0);
273}]>;
274
275def fp64immneg0 : PatLeaf<(f64 fpimm), [{
276 return N->isExactlyValue(-0.0);
277}]>;
278
279def fp64imm1 : PatLeaf<(f64 fpimm), [{
280 return N->isExactlyValue(+1.0);
281}]>;
282
283def fp64immneg1 : PatLeaf<(f64 fpimm), [{
284 return N->isExactlyValue(-1.0);
285}]>;
286
Evan Cheng605c4152005-12-13 01:57:51 +0000287// Helper fragments for loads.
Evan Cheng7a7e8372005-12-14 02:22:27 +0000288def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
289def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
290def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000291def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
292def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000293
294def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i1))>;
295def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i1))>;
296def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i8))>;
297def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i8))>;
298def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i16))>;
299
300def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i1))>;
301def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i1))>;
302def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i8))>;
303def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i8))>;
304def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i16))>;
305
Evan Cheng38bcbaf2005-12-23 07:31:11 +0000306def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extload node:$ptr, i1))>;
307def extloadf64f32 : PatFrag<(ops node:$ptr), (f64 (extload node:$ptr, f32))>;
Evan Cheng605c4152005-12-13 01:57:51 +0000308
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000309//===----------------------------------------------------------------------===//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000310// Instruction templates...
311
Evan Chengf0701842005-11-29 19:38:52 +0000312class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
313 : X86Inst<o, f, NoImm, ops, asm> {
314 let Pattern = pattern;
315}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000316class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
317 : X86Inst<o, f, Imm8 , ops, asm> {
318 let Pattern = pattern;
319}
Chris Lattner78432fe2005-11-17 02:01:55 +0000320class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
321 : X86Inst<o, f, Imm16, ops, asm> {
322 let Pattern = pattern;
323}
Chris Lattner7a125372005-11-16 22:59:19 +0000324class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
325 : X86Inst<o, f, Imm32, ops, asm> {
326 let Pattern = pattern;
327}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000328
Chris Lattner1cca5e32003-08-03 21:54:21 +0000329//===----------------------------------------------------------------------===//
330// Instruction list...
331//
332
Evan Chengf0701842005-11-29 19:38:52 +0000333def PHI : I<0, Pseudo, (ops variable_ops), "PHINODE", []>; // PHI node.
334def NOOP : I<0x90, RawFrm, (ops), "nop", []>; // nop
Chris Lattner1cca5e32003-08-03 21:54:21 +0000335
Evan Chengd90eb7f2006-01-05 00:27:02 +0000336def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
337 [(callseq_start imm:$amt)]>;
Chris Lattner43ef1312005-09-14 21:10:24 +0000338def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
Evan Chengd90eb7f2006-01-05 00:27:02 +0000339 "#ADJCALLSTACKUP",
340 [(callseq_end imm:$amt1, imm:$amt2)]>;
Evan Chengf0701842005-11-29 19:38:52 +0000341def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
342def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
Alkis Evlogimenose0bb3e72003-12-20 16:22:59 +0000343let isTerminator = 1 in
344 let Defs = [FP0, FP1, FP2, FP3, FP4, FP5, FP6] in
Evan Chengf0701842005-11-29 19:38:52 +0000345 def FP_REG_KILL : I<0, Pseudo, (ops), "#FP_REG_KILL", []>;
Chris Lattner62cce392004-07-31 02:10:53 +0000346
Chris Lattner1cca5e32003-08-03 21:54:21 +0000347//===----------------------------------------------------------------------===//
348// Control Flow Instructions...
349//
350
Chris Lattner1be48112005-05-13 17:56:48 +0000351// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000352let isTerminator = 1, isReturn = 1, isBarrier = 1,
353 hasCtrlDep = 1, noResults = 1 in {
Evan Cheng171049d2005-12-23 22:14:32 +0000354 // FIXME: temporary workaround for return without an incoming flag.
Evan Chengd9558e02006-01-06 00:43:03 +0000355 def RETVOID : I<0xC3, RawFrm, (ops), "ret", [(X86ret 0)]>;
356 def RETIVOID : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
357 [(X86ret imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000358 let hasInFlag = 1 in {
Evan Chengd9558e02006-01-06 00:43:03 +0000359 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
360 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
361 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000362 }
363}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000364
365// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng2b4ea792005-12-26 09:11:45 +0000366let isBranch = 1, isTerminator = 1, noResults = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000367 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
368 I<opcode, RawFrm, ops, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000369
Chris Lattner62cce392004-07-31 02:10:53 +0000370let isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000371 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000372
373def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000374 [(X86brcond bb:$dst, X86_COND_E, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000375def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000376 [(X86brcond bb:$dst, X86_COND_NE, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000377def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000378 [(X86brcond bb:$dst, X86_COND_L, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000379def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000380 [(X86brcond bb:$dst, X86_COND_LE, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000381def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000382 [(X86brcond bb:$dst, X86_COND_G, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000383def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000384 [(X86brcond bb:$dst, X86_COND_GE, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000385
Evan Chengd35b8c12005-12-04 08:19:43 +0000386def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000387 [(X86brcond bb:$dst, X86_COND_B, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000388def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000389 [(X86brcond bb:$dst, X86_COND_BE, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000390def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000391 [(X86brcond bb:$dst, X86_COND_A, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000392def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000393 [(X86brcond bb:$dst, X86_COND_AE, STATUS)]>, Imp<[STATUS],[]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000394
Evan Chengd9558e02006-01-06 00:43:03 +0000395def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
396 [(X86brcond bb:$dst, X86_COND_S, STATUS)]>, Imp<[STATUS],[]>, TB;
397def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
398 [(X86brcond bb:$dst, X86_COND_NS, STATUS)]>, Imp<[STATUS],[]>, TB;
399def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
400 [(X86brcond bb:$dst, X86_COND_P, STATUS)]>, Imp<[STATUS],[]>, TB;
401def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
402 [(X86brcond bb:$dst, X86_COND_NP, STATUS)]>, Imp<[STATUS],[]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000403
404//===----------------------------------------------------------------------===//
405// Call Instructions...
406//
Evan Chengd90eb7f2006-01-05 00:27:02 +0000407// FIXME: How about hasInFlag = 1? A fastcall would require an incoming flag
408// to stick the CopyToRegs to the call.
409let isCall = 1, noResults = 1, hasOutFlag = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000410 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000411 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Nate Begeman16b04f32005-07-15 00:38:55 +0000412 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengd90eb7f2006-01-05 00:27:02 +0000413 def CALLpcrel32 : I<0xE8, RawFrm, (ops calltarget:$dst), "call $dst",
414 []>;
415 def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000416 [(call R32:$dst)]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000417 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst), "call {*}$dst",
Evan Chengd9558e02006-01-06 00:43:03 +0000418 [(call (loadi32 addr:$dst))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000419 }
420
Evan Chengd90eb7f2006-01-05 00:27:02 +0000421def : Pat<(call tglobaladdr:$dst),
422 (CALLpcrel32 tglobaladdr:$dst)>;
423def : Pat<(call externalsym:$dst),
424 (CALLpcrel32 externalsym:$dst)>;
425
Chris Lattner1e9448b2005-05-15 03:10:37 +0000426// Tail call stuff.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000427let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000428 def TAILJMPd : IBr<0xE9, (ops calltarget:$dst), "jmp $dst # TAIL CALL", []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000429let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000430 def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000431let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000432 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
433 "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000434
435// ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
436// way, except that it is marked as being a terminator. This causes the epilog
437// inserter to insert reloads of callee saved registers BEFORE this. We need
438// this until we have a more accurate way of tracking where the stack pointer is
439// within a function.
440let isTerminator = 1, isTwoAddress = 1 in
441 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000442 "add{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000443
Chris Lattner1cca5e32003-08-03 21:54:21 +0000444//===----------------------------------------------------------------------===//
445// Miscellaneous Instructions...
446//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000447def LEAVE : I<0xC9, RawFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000448 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000449def POP32r : I<0x58, AddRegFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000450 (ops R32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000451
Chris Lattner3a173df2004-10-03 20:35:00 +0000452let isTwoAddress = 1 in // R32 = bswap R32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000453 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000454 (ops R32:$dst, R32:$src), "bswap{l} $dst", []>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000455
Chris Lattner30bf2d82004-08-10 20:17:41 +0000456def XCHG8rr : I<0x86, MRMDestReg, // xchg R8, R8
Chris Lattner3a173df2004-10-03 20:35:00 +0000457 (ops R8:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000458 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000459def XCHG16rr : I<0x87, MRMDestReg, // xchg R16, R16
Chris Lattner3a173df2004-10-03 20:35:00 +0000460 (ops R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000461 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000462def XCHG32rr : I<0x87, MRMDestReg, // xchg R32, R32
Chris Lattner3a173df2004-10-03 20:35:00 +0000463 (ops R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000464 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattnerfc752712004-08-01 09:52:59 +0000465
Chris Lattner3a173df2004-10-03 20:35:00 +0000466def XCHG8mr : I<0x86, MRMDestMem,
467 (ops i8mem:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000468 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000469def XCHG16mr : I<0x87, MRMDestMem,
470 (ops i16mem:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000471 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000472def XCHG32mr : I<0x87, MRMDestMem,
473 (ops i32mem:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000474 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000475def XCHG8rm : I<0x86, MRMSrcMem,
476 (ops R8:$src1, i8mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000477 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000478def XCHG16rm : I<0x87, MRMSrcMem,
479 (ops R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000480 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000481def XCHG32rm : I<0x87, MRMSrcMem,
482 (ops R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000483 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000484
Chris Lattner3a173df2004-10-03 20:35:00 +0000485def LEA16r : I<0x8D, MRMSrcMem,
486 (ops R16:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000487 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000488def LEA32r : I<0x8D, MRMSrcMem,
489 (ops R32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000490 "lea{l} {$src|$dst}, {$dst|$src}",
491 [(set R32:$dst, leaaddr:$src)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000492
Evan Chengf0701842005-11-29 19:38:52 +0000493def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000494 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Chengf0701842005-11-29 19:38:52 +0000495def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000496 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Chengf0701842005-11-29 19:38:52 +0000497def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsd|rep movsd}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000498 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Chris Lattner915e5e52004-02-12 17:53:22 +0000499
Evan Chengf0701842005-11-29 19:38:52 +0000500def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000501 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Chengf0701842005-11-29 19:38:52 +0000502def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000503 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Chengf0701842005-11-29 19:38:52 +0000504def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000505 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
506
Chris Lattnerb89abef2004-02-14 04:45:37 +0000507
Chris Lattner1cca5e32003-08-03 21:54:21 +0000508//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000509// Input/Output Instructions...
510//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000511def IN8rr : I<0xEC, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000512 "in{b} {%dx, %al|%AL, %DX}",
513 [(set AL, (readport DX))]>, Imp<[DX], [AL]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000514def IN16rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000515 "in{w} {%dx, %ax|%AX, %DX}",
516 [(set AX, (readport DX))]>, Imp<[DX], [AX]>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000517def IN32rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000518 "in{l} {%dx, %eax|%EAX, %DX}",
519 [(set EAX, (readport DX))]>, Imp<[DX],[EAX]>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000520
Evan Chenga5386b02005-12-20 07:38:38 +0000521def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
522 "in{b} {$port, %al|%AL, $port}",
523 [(set AL, (readport i16immZExt8:$port))]>,
524 Imp<[], [AL]>;
525def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
526 "in{w} {$port, %ax|%AX, $port}",
527 [(set AX, (readport i16immZExt8:$port))]>,
528 Imp<[], [AX]>, OpSize;
529def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
530 "in{l} {$port, %eax|%EAX, $port}",
531 [(set EAX, (readport i16immZExt8:$port))]>,
532 Imp<[],[EAX]>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000533
Evan Cheng8d202232005-12-05 23:09:43 +0000534def OUT8rr : I<0xEE, RawFrm, (ops),
535 "out{b} {%al, %dx|%DX, %AL}",
536 [(writeport AL, DX)]>, Imp<[DX, AL], []>;
537def OUT16rr : I<0xEF, RawFrm, (ops),
538 "out{w} {%ax, %dx|%DX, %AX}",
539 [(writeport AX, DX)]>, Imp<[DX, AX], []>, OpSize;
540def OUT32rr : I<0xEF, RawFrm, (ops),
541 "out{l} {%eax, %dx|%DX, %EAX}",
542 [(writeport EAX, DX)]>, Imp<[DX, EAX], []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000543
Evan Cheng8d202232005-12-05 23:09:43 +0000544def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
545 "out{b} {%al, $port|$port, %AL}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000546 [(writeport AL, i16immZExt8:$port)]>,
Evan Chenga5386b02005-12-20 07:38:38 +0000547 Imp<[AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000548def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
549 "out{w} {%ax, $port|$port, %AX}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000550 [(writeport AX, i16immZExt8:$port)]>,
Evan Chenga5386b02005-12-20 07:38:38 +0000551 Imp<[AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000552def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
553 "out{l} {%eax, $port|$port, %EAX}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000554 [(writeport EAX, i16immZExt8:$port)]>,
Evan Chenga5386b02005-12-20 07:38:38 +0000555 Imp<[EAX], []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000556
557//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000558// Move Instructions...
559//
Chris Lattner3a173df2004-10-03 20:35:00 +0000560def MOV8rr : I<0x88, MRMDestReg, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000561 "mov{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000562def MOV16rr : I<0x89, MRMDestReg, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000563 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000564def MOV32rr : I<0x89, MRMDestReg, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000565 "mov{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000566def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops R8 :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000567 "mov{b} {$src, $dst|$dst, $src}",
568 [(set R8:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000569def MOV16ri : Ii16<0xB8, AddRegFrm, (ops R16:$dst, i16imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000570 "mov{w} {$src, $dst|$dst, $src}",
571 [(set R16:$dst, imm:$src)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000572def MOV32ri : Ii32<0xB8, AddRegFrm, (ops R32:$dst, i32imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000573 "mov{l} {$src, $dst|$dst, $src}",
574 [(set R32:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000575def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000576 "mov{b} {$src, $dst|$dst, $src}",
577 [(store (i8 imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000578def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000579 "mov{w} {$src, $dst|$dst, $src}",
580 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000581def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000582 "mov{l} {$src, $dst|$dst, $src}",
583 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000584
Chris Lattner3a173df2004-10-03 20:35:00 +0000585def MOV8rm : I<0x8A, MRMSrcMem, (ops R8 :$dst, i8mem :$src),
Evan Chengec693f72005-12-08 02:01:35 +0000586 "mov{b} {$src, $dst|$dst, $src}",
587 [(set R8:$dst, (load addr:$src))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000588def MOV16rm : I<0x8B, MRMSrcMem, (ops R16:$dst, i16mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000589 "mov{w} {$src, $dst|$dst, $src}",
590 [(set R16:$dst, (load addr:$src))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000591def MOV32rm : I<0x8B, MRMSrcMem, (ops R32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000592 "mov{l} {$src, $dst|$dst, $src}",
593 [(set R32:$dst, (load addr:$src))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000594
Chris Lattner3a173df2004-10-03 20:35:00 +0000595def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, R8 :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000596 "mov{b} {$src, $dst|$dst, $src}",
597 [(store R8:$src, addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000598def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, R16:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000599 "mov{w} {$src, $dst|$dst, $src}",
600 [(store R16:$src, addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000601def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, R32:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000602 "mov{l} {$src, $dst|$dst, $src}",
603 [(store R32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000604
Chris Lattner1cca5e32003-08-03 21:54:21 +0000605//===----------------------------------------------------------------------===//
606// Fixed-Register Multiplication and Division Instructions...
607//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000608
Chris Lattnerc8f45872003-08-04 04:59:56 +0000609// Extra precision multiplication
Evan Chengf0701842005-11-29 19:38:52 +0000610def MUL8r : I<0xF6, MRM4r, (ops R8:$src), "mul{b} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000611 Imp<[AL],[AX]>; // AL,AH = AL*R8
Evan Chengf0701842005-11-29 19:38:52 +0000612def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul{w} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000613 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
Evan Chengf0701842005-11-29 19:38:52 +0000614def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul{l} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000615 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
Chris Lattner57a02302004-08-11 04:31:00 +0000616def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000617 "mul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner57a02302004-08-11 04:31:00 +0000618def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000619 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
620 OpSize; // AX,DX = AX*[mem16]
Chris Lattner57a02302004-08-11 04:31:00 +0000621def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000622 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000623
Evan Chengf0701842005-11-29 19:38:52 +0000624def IMUL8r : I<0xF6, MRM5r, (ops R8:$src), "imul{b} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000625 Imp<[AL],[AX]>; // AL,AH = AL*R8
Evan Chengf0701842005-11-29 19:38:52 +0000626def IMUL16r : I<0xF7, MRM5r, (ops R16:$src), "imul{w} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000627 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
Evan Chengf0701842005-11-29 19:38:52 +0000628def IMUL32r : I<0xF7, MRM5r, (ops R32:$src), "imul{l} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000629 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
630def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000631 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000632def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000633 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
634 OpSize; // AX,DX = AX*[mem16]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000635def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000636 "imul{l} $src", []>,
637 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000638
Chris Lattnerc8f45872003-08-04 04:59:56 +0000639// unsigned division/remainder
Chris Lattner3a173df2004-10-03 20:35:00 +0000640def DIV8r : I<0xF6, MRM6r, (ops R8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000641 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000642def DIV16r : I<0xF7, MRM6r, (ops R16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000643 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000644def DIV32r : I<0xF7, MRM6r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000645 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000646def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000647 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000648def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000649 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000650def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000651 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000652
Chris Lattnerfc752712004-08-01 09:52:59 +0000653// Signed division/remainder.
Chris Lattner3a173df2004-10-03 20:35:00 +0000654def IDIV8r : I<0xF6, MRM7r, (ops R8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000655 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000656def IDIV16r: I<0xF7, MRM7r, (ops R16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000657 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000658def IDIV32r: I<0xF7, MRM7r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000659 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000660def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000661 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000662def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000663 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000664def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000665 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattnerc8f45872003-08-04 04:59:56 +0000666
Chris Lattnerfc752712004-08-01 09:52:59 +0000667// Sign-extenders for division.
Chris Lattner3a173df2004-10-03 20:35:00 +0000668def CBW : I<0x98, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000669 "{cbtw|cbw}", []>, Imp<[AL],[AH]>; // AX = signext(AL)
Chris Lattner3a173df2004-10-03 20:35:00 +0000670def CWD : I<0x99, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000671 "{cwtd|cwd}", []>, Imp<[AX],[DX]>; // DX:AX = signext(AX)
Chris Lattner3a173df2004-10-03 20:35:00 +0000672def CDQ : I<0x99, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000673 "{cltd|cdq}", []>, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
Chris Lattnerfc752712004-08-01 09:52:59 +0000674
Chris Lattner1cca5e32003-08-03 21:54:21 +0000675
Chris Lattner1cca5e32003-08-03 21:54:21 +0000676//===----------------------------------------------------------------------===//
677// Two address Instructions...
678//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000679let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000680
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000681// Conditional moves
Chris Lattner3a173df2004-10-03 20:35:00 +0000682def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, R16 = R16
683 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000684 "cmovb {$src2, $dst|$dst, $src2}",
685 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000686 X86_COND_B, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000687 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000688def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, R16 = [mem16]
689 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000690 "cmovb {$src2, $dst|$dst, $src2}",
691 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000692 X86_COND_B, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000693 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000694def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, R32 = R32
695 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000696 "cmovb {$src2, $dst|$dst, $src2}",
697 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000698 X86_COND_B, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000699 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000700def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, R32 = [mem32]
701 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000702 "cmovb {$src2, $dst|$dst, $src2}",
703 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000704 X86_COND_B, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000705 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000706
Chris Lattner3a173df2004-10-03 20:35:00 +0000707def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, R16 = R16
708 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000709 "cmovae {$src2, $dst|$dst, $src2}",
710 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000711 X86_COND_AE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000712 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000713def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, R16 = [mem16]
714 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000715 "cmovae {$src2, $dst|$dst, $src2}",
716 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000717 X86_COND_AE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000718 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000719def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, R32 = R32
720 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000721 "cmovae {$src2, $dst|$dst, $src2}",
722 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000723 X86_COND_AE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000724 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000725def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, R32 = [mem32]
726 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000727 "cmovae {$src2, $dst|$dst, $src2}",
728 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000729 X86_COND_AE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000730 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000731
Chris Lattner3a173df2004-10-03 20:35:00 +0000732def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, R16 = R16
733 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000734 "cmove {$src2, $dst|$dst, $src2}",
735 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000736 X86_COND_E, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000737 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000738def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, R16 = [mem16]
739 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000740 "cmove {$src2, $dst|$dst, $src2}",
741 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000742 X86_COND_E, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000743 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000744def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, R32 = R32
745 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000746 "cmove {$src2, $dst|$dst, $src2}",
747 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000748 X86_COND_E, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000749 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000750def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, R32 = [mem32]
751 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000752 "cmove {$src2, $dst|$dst, $src2}",
753 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000754 X86_COND_E, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000755 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000756
Chris Lattner3a173df2004-10-03 20:35:00 +0000757def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, R16 = R16
758 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000759 "cmovne {$src2, $dst|$dst, $src2}",
760 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000761 X86_COND_NE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000762 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000763def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, R16 = [mem16]
764 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000765 "cmovne {$src2, $dst|$dst, $src2}",
766 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000767 X86_COND_NE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000768 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000769def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, R32 = R32
770 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000771 "cmovne {$src2, $dst|$dst, $src2}",
772 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000773 X86_COND_NE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000774 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000775def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, R32 = [mem32]
776 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000777 "cmovne {$src2, $dst|$dst, $src2}",
778 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000779 X86_COND_NE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000780 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000781
Chris Lattner3a173df2004-10-03 20:35:00 +0000782def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, R16 = R16
783 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000784 "cmovbe {$src2, $dst|$dst, $src2}",
785 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000786 X86_COND_BE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000787 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000788def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, R16 = [mem16]
789 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000790 "cmovbe {$src2, $dst|$dst, $src2}",
791 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000792 X86_COND_BE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000793 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000794def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, R32 = R32
795 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000796 "cmovbe {$src2, $dst|$dst, $src2}",
797 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000798 X86_COND_BE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000799 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000800def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, R32 = [mem32]
801 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000802 "cmovbe {$src2, $dst|$dst, $src2}",
803 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000804 X86_COND_BE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000805 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000806
Chris Lattner3a173df2004-10-03 20:35:00 +0000807def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, R16 = R16
808 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000809 "cmova {$src2, $dst|$dst, $src2}",
810 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000811 X86_COND_A, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000812 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000813def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, R16 = [mem16]
814 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000815 "cmova {$src2, $dst|$dst, $src2}",
816 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000817 X86_COND_A, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000818 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000819def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, R32 = R32
820 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000821 "cmova {$src2, $dst|$dst, $src2}",
822 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000823 X86_COND_A, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000824 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000825def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, R32 = [mem32]
826 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000827 "cmova {$src2, $dst|$dst, $src2}",
828 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000829 X86_COND_A, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000830 Imp<[STATUS],[]>, TB;
831
832def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, R16 = R16
833 (ops R16:$dst, R16:$src1, R16:$src2),
834 "cmovl {$src2, $dst|$dst, $src2}",
835 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000836 X86_COND_L, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000837 Imp<[STATUS],[]>, TB, OpSize;
838def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, R16 = [mem16]
839 (ops R16:$dst, R16:$src1, i16mem:$src2),
840 "cmovl {$src2, $dst|$dst, $src2}",
841 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000842 X86_COND_L, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000843 Imp<[STATUS],[]>, TB, OpSize;
844def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, R32 = R32
845 (ops R32:$dst, R32:$src1, R32:$src2),
846 "cmovl {$src2, $dst|$dst, $src2}",
847 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000848 X86_COND_L, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000849 Imp<[STATUS],[]>, TB;
850def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, R32 = [mem32]
851 (ops R32:$dst, R32:$src1, i32mem:$src2),
852 "cmovl {$src2, $dst|$dst, $src2}",
853 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000854 X86_COND_L, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000855 Imp<[STATUS],[]>, TB;
856
857def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, R16 = R16
858 (ops R16:$dst, R16:$src1, R16:$src2),
859 "cmovge {$src2, $dst|$dst, $src2}",
860 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000861 X86_COND_GE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000862 Imp<[STATUS],[]>, TB, OpSize;
863def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, R16 = [mem16]
864 (ops R16:$dst, R16:$src1, i16mem:$src2),
865 "cmovge {$src2, $dst|$dst, $src2}",
866 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000867 X86_COND_GE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000868 Imp<[STATUS],[]>, TB, OpSize;
869def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, R32 = R32
870 (ops R32:$dst, R32:$src1, R32:$src2),
871 "cmovge {$src2, $dst|$dst, $src2}",
872 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000873 X86_COND_GE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000874 Imp<[STATUS],[]>, TB;
875def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, R32 = [mem32]
876 (ops R32:$dst, R32:$src1, i32mem:$src2),
877 "cmovge {$src2, $dst|$dst, $src2}",
878 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000879 X86_COND_GE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000880 Imp<[STATUS],[]>, TB;
881
882def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, R16 = R16
883 (ops R16:$dst, R16:$src1, R16:$src2),
884 "cmovle {$src2, $dst|$dst, $src2}",
885 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000886 X86_COND_LE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000887 Imp<[STATUS],[]>, TB, OpSize;
888def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, R16 = [mem16]
889 (ops R16:$dst, R16:$src1, i16mem:$src2),
890 "cmovle {$src2, $dst|$dst, $src2}",
891 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000892 X86_COND_LE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000893 Imp<[STATUS],[]>, TB, OpSize;
894def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, R32 = R32
895 (ops R32:$dst, R32:$src1, R32:$src2),
896 "cmovle {$src2, $dst|$dst, $src2}",
897 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000898 X86_COND_LE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000899 Imp<[STATUS],[]>, TB;
900def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, R32 = [mem32]
901 (ops R32:$dst, R32:$src1, i32mem:$src2),
902 "cmovle {$src2, $dst|$dst, $src2}",
903 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000904 X86_COND_LE, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000905 Imp<[STATUS],[]>, TB;
906
907def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, R16 = R16
908 (ops R16:$dst, R16:$src1, R16:$src2),
909 "cmovg {$src2, $dst|$dst, $src2}",
910 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000911 X86_COND_G, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000912 Imp<[STATUS],[]>, TB, OpSize;
913def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, R16 = [mem16]
914 (ops R16:$dst, R16:$src1, i16mem:$src2),
915 "cmovg {$src2, $dst|$dst, $src2}",
916 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000917 X86_COND_G, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000918 Imp<[STATUS],[]>, TB, OpSize;
919def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, R32 = R32
920 (ops R32:$dst, R32:$src1, R32:$src2),
921 "cmovg {$src2, $dst|$dst, $src2}",
922 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Chengd9558e02006-01-06 00:43:03 +0000923 X86_COND_G, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000924 Imp<[STATUS],[]>, TB;
925def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, R32 = [mem32]
926 (ops R32:$dst, R32:$src1, i32mem:$src2),
927 "cmovg {$src2, $dst|$dst, $src2}",
928 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000929 X86_COND_G, STATUS))]>,
Evan Chengaed7c722005-12-17 01:24:02 +0000930 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000931
Chris Lattner3a173df2004-10-03 20:35:00 +0000932def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, R16 = R16
933 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000934 "cmovs {$src2, $dst|$dst, $src2}",
935 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
936 X86_COND_S, STATUS))]>,
937 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000938def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, R16 = [mem16]
939 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000940 "cmovs {$src2, $dst|$dst, $src2}",
941 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
942 X86_COND_S, STATUS))]>,
943 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000944def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, R32 = R32
945 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000946 "cmovs {$src2, $dst|$dst, $src2}",
947 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
948 X86_COND_S, STATUS))]>,
949 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000950def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, R32 = [mem32]
951 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000952 "cmovs {$src2, $dst|$dst, $src2}",
953 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
954 X86_COND_S, STATUS))]>,
955 Imp<[STATUS],[]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000956
Chris Lattner3a173df2004-10-03 20:35:00 +0000957def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, R16 = R16
958 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000959 "cmovns {$src2, $dst|$dst, $src2}",
960 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
961 X86_COND_NS, STATUS))]>,
962 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000963def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, R16 = [mem16]
964 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000965 "cmovns {$src2, $dst|$dst, $src2}",
966 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
967 X86_COND_NS, STATUS))]>,
968 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000969def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, R32 = R32
970 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000971 "cmovns {$src2, $dst|$dst, $src2}",
972 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
973 X86_COND_NS, STATUS))]>,
974 Imp<[STATUS],[]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000975def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, R32 = [mem32]
976 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000977 "cmovns {$src2, $dst|$dst, $src2}",
978 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
979 X86_COND_NS, STATUS))]>,
980 Imp<[STATUS],[]>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000981
Chris Lattner57fbfb52005-01-10 22:09:33 +0000982def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, R16 = R16
983 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000984 "cmovp {$src2, $dst|$dst, $src2}",
985 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
986 X86_COND_P, STATUS))]>,
987 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000988def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, R16 = [mem16]
989 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000990 "cmovp {$src2, $dst|$dst, $src2}",
991 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
992 X86_COND_P, STATUS))]>,
993 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000994def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, R32 = R32
995 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000996 "cmovp {$src2, $dst|$dst, $src2}",
997 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
998 X86_COND_P, STATUS))]>,
999 Imp<[STATUS],[]>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001000def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, R32 = [mem32]
1001 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001002 "cmovp {$src2, $dst|$dst, $src2}",
1003 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1004 X86_COND_P, STATUS))]>,
1005 Imp<[STATUS],[]>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001006
Chris Lattner57fbfb52005-01-10 22:09:33 +00001007def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, R16 = R16
1008 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001009 "cmovnp {$src2, $dst|$dst, $src2}",
1010 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
1011 X86_COND_NP, STATUS))]>,
1012 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001013def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, R16 = [mem16]
1014 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001015 "cmovnp {$src2, $dst|$dst, $src2}",
1016 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
1017 X86_COND_NP, STATUS))]>,
1018 Imp<[STATUS],[]>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001019def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, R32 = R32
1020 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001021 "cmovnp {$src2, $dst|$dst, $src2}",
1022 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
1023 X86_COND_NP, STATUS))]>,
1024 Imp<[STATUS],[]>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001025def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, R32 = [mem32]
1026 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001027 "cmovnp {$src2, $dst|$dst, $src2}",
1028 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
1029 X86_COND_NP, STATUS))]>,
1030 Imp<[STATUS],[]>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001031
1032
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001033// unary instructions
Evan Chengf0701842005-11-29 19:38:52 +00001034def NEG8r : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg{b} $dst",
1035 [(set R8:$dst, (ineg R8:$src))]>;
1036def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg{w} $dst",
1037 [(set R16:$dst, (ineg R16:$src))]>, OpSize;
1038def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg{l} $dst",
1039 [(set R32:$dst, (ineg R32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001040let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001041 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001042 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001043 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001044 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001045 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001046 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1047
Chris Lattner57a02302004-08-11 04:31:00 +00001048}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001049
Evan Chengf0701842005-11-29 19:38:52 +00001050def NOT8r : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not{b} $dst",
1051 [(set R8:$dst, (not R8:$src))]>;
1052def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not{w} $dst",
1053 [(set R16:$dst, (not R16:$src))]>, OpSize;
1054def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not{l} $dst",
1055 [(set R32:$dst, (not R32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001056let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001057 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001058 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001059 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001060 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001061 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001062 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001063}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001064
Evan Chengb51a0592005-12-10 00:48:20 +00001065// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Chengf0701842005-11-29 19:38:52 +00001066def INC8r : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc{b} $dst",
1067 [(set R8:$dst, (add R8:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001068let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengf0701842005-11-29 19:38:52 +00001069def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc{w} $dst",
1070 [(set R16:$dst, (add R16:$src, 1))]>, OpSize;
1071def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc{l} $dst",
1072 [(set R32:$dst, (add R32:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001073}
Chris Lattner57a02302004-08-11 04:31:00 +00001074let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001075 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001076 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001077 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001078 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001079 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001080 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001081}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001082
Evan Chengb51a0592005-12-10 00:48:20 +00001083def DEC8r : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec{b} $dst",
1084 [(set R8:$dst, (add R8:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001085let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb51a0592005-12-10 00:48:20 +00001086def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec{w} $dst",
1087 [(set R16:$dst, (add R16:$src, -1))]>, OpSize;
1088def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec{l} $dst",
1089 [(set R32:$dst, (add R32:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001090}
Chris Lattner57a02302004-08-11 04:31:00 +00001091
1092let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001093 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001094 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001095 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001096 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001097 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001098 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001099}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001100
1101// Logical operators...
Chris Lattnercc65bee2005-01-02 02:35:46 +00001102let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001103def AND8rr : I<0x20, MRMDestReg,
1104 (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001105 "and{b} {$src2, $dst|$dst, $src2}",
1106 [(set R8:$dst, (and R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001107def AND16rr : I<0x21, MRMDestReg,
1108 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001109 "and{w} {$src2, $dst|$dst, $src2}",
1110 [(set R16:$dst, (and R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001111def AND32rr : I<0x21, MRMDestReg,
1112 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001113 "and{l} {$src2, $dst|$dst, $src2}",
1114 [(set R32:$dst, (and R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001115}
Chris Lattner57a02302004-08-11 04:31:00 +00001116
Chris Lattner3a173df2004-10-03 20:35:00 +00001117def AND8rm : I<0x22, MRMSrcMem,
1118 (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001119 "and{b} {$src2, $dst|$dst, $src2}",
1120 [(set R8:$dst, (and R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001121def AND16rm : I<0x23, MRMSrcMem,
1122 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001123 "and{w} {$src2, $dst|$dst, $src2}",
1124 [(set R16:$dst, (and R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001125def AND32rm : I<0x23, MRMSrcMem,
1126 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001127 "and{l} {$src2, $dst|$dst, $src2}",
1128 [(set R32:$dst, (and R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001129
Chris Lattner3a173df2004-10-03 20:35:00 +00001130def AND8ri : Ii8<0x80, MRM4r,
1131 (ops R8 :$dst, R8 :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001132 "and{b} {$src2, $dst|$dst, $src2}",
1133 [(set R8:$dst, (and R8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001134def AND16ri : Ii16<0x81, MRM4r,
1135 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001136 "and{w} {$src2, $dst|$dst, $src2}",
1137 [(set R16:$dst, (and R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001138def AND32ri : Ii32<0x81, MRM4r,
1139 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001140 "and{l} {$src2, $dst|$dst, $src2}",
1141 [(set R32:$dst, (and R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001142def AND16ri8 : Ii8<0x83, MRM4r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001143 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1144 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001145 [(set R16:$dst, (and R16:$src1, i16immSExt8:$src2))]>,
1146 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001147def AND32ri8 : Ii8<0x83, MRM4r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001148 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1149 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001150 [(set R32:$dst, (and R32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001151
1152let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001153 def AND8mr : I<0x20, MRMDestMem,
1154 (ops i8mem :$dst, R8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001155 "and{b} {$src, $dst|$dst, $src}",
1156 [(store (and (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001157 def AND16mr : I<0x21, MRMDestMem,
1158 (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001159 "and{w} {$src, $dst|$dst, $src}",
1160 [(store (and (load addr:$dst), R16:$src), addr:$dst)]>,
1161 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001162 def AND32mr : I<0x21, MRMDestMem,
1163 (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001164 "and{l} {$src, $dst|$dst, $src}",
1165 [(store (and (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001166 def AND8mi : Ii8<0x80, MRM4m,
1167 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001168 "and{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001169 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001170 def AND16mi : Ii16<0x81, MRM4m,
1171 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001172 "and{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001173 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001174 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001175 def AND32mi : Ii32<0x81, MRM4m,
1176 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001177 "and{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001178 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001179 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001180 (ops i16mem:$dst, i16i8imm :$src),
1181 "and{w} {$src, $dst|$dst, $src}",
1182 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1183 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001184 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001185 (ops i32mem:$dst, i32i8imm :$src),
1186 "and{l} {$src, $dst|$dst, $src}",
1187 [(store (add (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001188}
1189
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001190
Chris Lattnercc65bee2005-01-02 02:35:46 +00001191let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Chris Lattner36b68902004-08-10 21:21:30 +00001192def OR8rr : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001193 "or{b} {$src2, $dst|$dst, $src2}",
1194 [(set R8:$dst, (or R8:$src1, R8:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001195def OR16rr : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001196 "or{w} {$src2, $dst|$dst, $src2}",
1197 [(set R16:$dst, (or R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001198def OR32rr : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001199 "or{l} {$src2, $dst|$dst, $src2}",
1200 [(set R32:$dst, (or R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001201}
Chris Lattner57a02302004-08-11 04:31:00 +00001202def OR8rm : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001203 "or{b} {$src2, $dst|$dst, $src2}",
1204 [(set R8:$dst, (or R8:$src1, (load addr:$src2)))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001205def OR16rm : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001206 "or{w} {$src2, $dst|$dst, $src2}",
1207 [(set R16:$dst, (or R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001208def OR32rm : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001209 "or{l} {$src2, $dst|$dst, $src2}",
1210 [(set R32:$dst, (or R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001211
Chris Lattner36b68902004-08-10 21:21:30 +00001212def OR8ri : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001213 "or{b} {$src2, $dst|$dst, $src2}",
1214 [(set R8:$dst, (or R8:$src1, imm:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001215def OR16ri : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001216 "or{w} {$src2, $dst|$dst, $src2}",
1217 [(set R16:$dst, (or R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001218def OR32ri : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001219 "or{l} {$src2, $dst|$dst, $src2}",
1220 [(set R32:$dst, (or R32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001221
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001222def OR16ri8 : Ii8<0x83, MRM1r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1223 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001224 [(set R16:$dst, (or R16:$src1, i16immSExt8:$src2))]>, OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001225def OR32ri8 : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1226 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001227 [(set R32:$dst, (or R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001228let isTwoAddress = 0 in {
Chris Lattnerf29ed092004-08-11 05:07:25 +00001229 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001230 "or{b} {$src, $dst|$dst, $src}",
1231 [(store (or (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001232 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001233 "or{w} {$src, $dst|$dst, $src}",
1234 [(store (or (load addr:$dst), R16:$src), addr:$dst)]>, OpSize;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001235 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001236 "or{l} {$src, $dst|$dst, $src}",
1237 [(store (or (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001238 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001239 "or{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001240 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001241 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001242 "or{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001243 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001244 OpSize;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001245 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001246 "or{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001247 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng0ef3a772005-12-13 01:41:36 +00001248 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1249 "or{w} {$src, $dst|$dst, $src}",
1250 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1251 OpSize;
1252 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1253 "or{l} {$src, $dst|$dst, $src}",
1254 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001255}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001256
1257
Chris Lattnercc65bee2005-01-02 02:35:46 +00001258let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001259def XOR8rr : I<0x30, MRMDestReg,
1260 (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001261 "xor{b} {$src2, $dst|$dst, $src2}",
1262 [(set R8:$dst, (xor R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001263def XOR16rr : I<0x31, MRMDestReg,
1264 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001265 "xor{w} {$src2, $dst|$dst, $src2}",
1266 [(set R16:$dst, (xor R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001267def XOR32rr : I<0x31, MRMDestReg,
1268 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001269 "xor{l} {$src2, $dst|$dst, $src2}",
1270 [(set R32:$dst, (xor R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001271}
1272
Chris Lattner3a173df2004-10-03 20:35:00 +00001273def XOR8rm : I<0x32, MRMSrcMem ,
1274 (ops R8 :$dst, R8:$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001275 "xor{b} {$src2, $dst|$dst, $src2}",
1276 [(set R8:$dst, (xor R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001277def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001278 (ops R16:$dst, R16:$src1, i16mem:$src2),
1279 "xor{w} {$src2, $dst|$dst, $src2}",
1280 [(set R16:$dst, (xor R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001281def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001282 (ops R32:$dst, R32:$src1, i32mem:$src2),
1283 "xor{l} {$src2, $dst|$dst, $src2}",
1284 [(set R32:$dst, (xor R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001285
Chris Lattner3a173df2004-10-03 20:35:00 +00001286def XOR8ri : Ii8<0x80, MRM6r,
1287 (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001288 "xor{b} {$src2, $dst|$dst, $src2}",
1289 [(set R8:$dst, (xor R8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001290def XOR16ri : Ii16<0x81, MRM6r,
1291 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001292 "xor{w} {$src2, $dst|$dst, $src2}",
1293 [(set R16:$dst, (xor R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001294def XOR32ri : Ii32<0x81, MRM6r,
1295 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001296 "xor{l} {$src2, $dst|$dst, $src2}",
1297 [(set R32:$dst, (xor R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001298def XOR16ri8 : Ii8<0x83, MRM6r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001299 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1300 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001301 [(set R16:$dst, (xor R16:$src1, i16immSExt8:$src2))]>,
1302 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001303def XOR32ri8 : Ii8<0x83, MRM6r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001304 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1305 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001306 [(set R32:$dst, (xor R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001307let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001308 def XOR8mr : I<0x30, MRMDestMem,
1309 (ops i8mem :$dst, R8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001310 "xor{b} {$src, $dst|$dst, $src}",
1311 [(store (xor (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001312 def XOR16mr : I<0x31, MRMDestMem,
1313 (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001314 "xor{w} {$src, $dst|$dst, $src}",
1315 [(store (xor (load addr:$dst), R16:$src), addr:$dst)]>,
1316 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001317 def XOR32mr : I<0x31, MRMDestMem,
1318 (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001319 "xor{l} {$src, $dst|$dst, $src}",
1320 [(store (xor (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001321 def XOR8mi : Ii8<0x80, MRM6m,
1322 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001323 "xor{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001324 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001325 def XOR16mi : Ii16<0x81, MRM6m,
1326 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001327 "xor{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001328 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001329 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001330 def XOR32mi : Ii32<0x81, MRM6m,
1331 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001332 "xor{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001333 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001334 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001335 (ops i16mem:$dst, i16i8imm :$src),
1336 "xor{w} {$src, $dst|$dst, $src}",
1337 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1338 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001339 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001340 (ops i32mem:$dst, i32i8imm :$src),
1341 "xor{l} {$src, $dst|$dst, $src}",
1342 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001343}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001344
1345// Shift instructions
Chris Lattner3a173df2004-10-03 20:35:00 +00001346def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001347 "shl{b} {%cl, $dst|$dst, %CL}",
1348 [(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001349def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001350 "shl{w} {%cl, $dst|$dst, %CL}",
1351 [(set R16:$dst, (shl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001352def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001353 "shl{l} {%cl, $dst|$dst, %CL}",
1354 [(set R32:$dst, (shl R32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001355
Chris Lattner36b68902004-08-10 21:21:30 +00001356def SHL8ri : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001357 "shl{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001358 [(set R8:$dst, (shl R8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001359let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001360def SHL16ri : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001361 "shl{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001362 [(set R16:$dst, (shl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1363def SHL32ri : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001364 "shl{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001365 [(set R32:$dst, (shl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001366}
Chris Lattnerf29ed092004-08-11 05:07:25 +00001367
1368let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001369 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001370 "shl{b} {%cl, $dst|$dst, %CL}",
1371 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1372 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001373 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001374 "shl{w} {%cl, $dst|$dst, %CL}",
1375 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1376 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001377 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001378 "shl{l} {%cl, $dst|$dst, %CL}",
1379 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1380 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001381 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001382 "shl{b} {$src, $dst|$dst, $src}",
1383 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001384 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001385 "shl{w} {$src, $dst|$dst, $src}",
1386 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1387 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001388 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001389 "shl{l} {$src, $dst|$dst, $src}",
1390 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001391}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001392
Chris Lattner3a173df2004-10-03 20:35:00 +00001393def SHR8rCL : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001394 "shr{b} {%cl, $dst|$dst, %CL}",
1395 [(set R8:$dst, (srl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001396def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001397 "shr{w} {%cl, $dst|$dst, %CL}",
1398 [(set R16:$dst, (srl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001399def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001400 "shr{l} {%cl, $dst|$dst, %CL}",
1401 [(set R32:$dst, (srl R32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001402
Chris Lattner3a173df2004-10-03 20:35:00 +00001403def SHR8ri : Ii8<0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001404 "shr{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001405 [(set R8:$dst, (srl R8:$src1, (i8 imm:$src2)))]>;
1406def SHR16ri : Ii8<0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001407 "shr{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001408 [(set R16:$dst, (srl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1409def SHR32ri : Ii8<0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001410 "shr{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001411 [(set R32:$dst, (srl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001412
Chris Lattner57a02302004-08-11 04:31:00 +00001413let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001414 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001415 "shr{b} {%cl, $dst|$dst, %CL}",
1416 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1417 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001418 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001419 "shr{w} {%cl, $dst|$dst, %CL}",
1420 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1421 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001422 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001423 "shr{l} {%cl, $dst|$dst, %CL}",
1424 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1425 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001426 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001427 "shr{b} {$src, $dst|$dst, $src}",
1428 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001429 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001430 "shr{w} {$src, $dst|$dst, $src}",
1431 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1432 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001433 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001434 "shr{l} {$src, $dst|$dst, $src}",
1435 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001436}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001437
Chris Lattner3a173df2004-10-03 20:35:00 +00001438def SAR8rCL : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001439 "sar{b} {%cl, $dst|$dst, %CL}",
1440 [(set R8:$dst, (sra R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001441def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001442 "sar{w} {%cl, $dst|$dst, %CL}",
1443 [(set R16:$dst, (sra R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001444def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001445 "sar{l} {%cl, $dst|$dst, %CL}",
1446 [(set R32:$dst, (sra R32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001447
Chris Lattner36b68902004-08-10 21:21:30 +00001448def SAR8ri : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001449 "sar{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001450 [(set R8:$dst, (sra R8:$src1, (i8 imm:$src2)))]>;
1451def SAR16ri : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001452 "sar{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001453 [(set R16:$dst, (sra R16:$src1, (i8 imm:$src2)))]>,
1454 OpSize;
1455def SAR32ri : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001456 "sar{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001457 [(set R32:$dst, (sra R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001458let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001459 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001460 "sar{b} {%cl, $dst|$dst, %CL}",
1461 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1462 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001463 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001464 "sar{w} {%cl, $dst|$dst, %CL}",
1465 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1466 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001467 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001468 "sar{l} {%cl, $dst|$dst, %CL}",
1469 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1470 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001471 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001472 "sar{b} {$src, $dst|$dst, $src}",
1473 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001474 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001475 "sar{w} {$src, $dst|$dst, $src}",
1476 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1477 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001478 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001479 "sar{l} {$src, $dst|$dst, $src}",
1480 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001481}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001482
Chris Lattner40ff6332005-01-19 07:50:03 +00001483// Rotate instructions
1484// FIXME: provide shorter instructions when imm8 == 1
1485def ROL8rCL : I<0xD2, MRM0r, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001486 "rol{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001487def ROL16rCL : I<0xD3, MRM0r, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001488 "rol{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001489def ROL32rCL : I<0xD3, MRM0r, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001490 "rol{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001491
1492def ROL8ri : Ii8<0xC0, MRM0r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001493 "rol{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001494def ROL16ri : Ii8<0xC1, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001495 "rol{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001496def ROL32ri : Ii8<0xC1, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001497 "rol{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001498
1499let isTwoAddress = 0 in {
1500 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001501 "rol{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001502 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001503 "rol{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001504 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001505 "rol{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001506 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001507 "rol{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001508 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001509 "rol{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001510 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001511 "rol{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001512}
1513
1514def ROR8rCL : I<0xD2, MRM1r, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001515 "ror{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001516def ROR16rCL : I<0xD3, MRM1r, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001517 "ror{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001518def ROR32rCL : I<0xD3, MRM1r, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001519 "ror{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001520
1521def ROR8ri : Ii8<0xC0, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001522 "ror{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001523def ROR16ri : Ii8<0xC1, MRM1r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001524 "ror{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001525def ROR32ri : Ii8<0xC1, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001526 "ror{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001527let isTwoAddress = 0 in {
1528 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001529 "ror{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001530 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001531 "ror{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001532 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001533 "ror{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001534 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001535 "ror{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001536 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001537 "ror{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001538 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001539 "ror{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001540}
1541
1542
1543
1544// Double shift instructions (generalizations of rotate)
1545
Chris Lattner57a02302004-08-11 04:31:00 +00001546def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001547 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001548 Imp<[CL],[]>, TB;
Chris Lattner57a02302004-08-11 04:31:00 +00001549def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001550 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001551 Imp<[CL],[]>, TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001552def SHLD16rrCL : I<0xA5, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001553 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001554 Imp<[CL],[]>, TB, OpSize;
1555def SHRD16rrCL : I<0xAD, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001556 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001557 Imp<[CL],[]>, TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001558
1559let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001560def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1561 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001562 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001563def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1564 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001565 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>, TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001566def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1567 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001568 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001569 TB, OpSize;
1570def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1571 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001572 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001573 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001574}
Chris Lattner0e967d42004-08-01 08:13:11 +00001575
Chris Lattner57a02302004-08-11 04:31:00 +00001576let isTwoAddress = 0 in {
1577 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001578 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001579 Imp<[CL],[]>, TB;
Chris Lattner57a02302004-08-11 04:31:00 +00001580 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001581 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001582 Imp<[CL],[]>, TB;
1583 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1584 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001585 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1586 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001587 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1588 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001589 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1590 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001591
1592 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001593 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001594 Imp<[CL],[]>, TB, OpSize;
1595 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001596 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001597 Imp<[CL],[]>, TB, OpSize;
1598 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1599 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001600 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001601 TB, OpSize;
1602 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1603 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001604 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001605 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001606}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001607
1608
Chris Lattnercc65bee2005-01-02 02:35:46 +00001609// Arithmetic.
1610let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001611def ADD8rr : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001612 "add{b} {$src2, $dst|$dst, $src2}",
1613 [(set R8:$dst, (add R8:$src1, R8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001614let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3a173df2004-10-03 20:35:00 +00001615def ADD16rr : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001616 "add{w} {$src2, $dst|$dst, $src2}",
1617 [(set R16:$dst, (add R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001618def ADD32rr : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001619 "add{l} {$src2, $dst|$dst, $src2}",
1620 [(set R32:$dst, (add R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001621} // end isConvertibleToThreeAddress
1622} // end isCommutable
Chris Lattner3a173df2004-10-03 20:35:00 +00001623def ADD8rm : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001624 "add{b} {$src2, $dst|$dst, $src2}",
1625 [(set R8:$dst, (add R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001626def ADD16rm : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001627 "add{w} {$src2, $dst|$dst, $src2}",
1628 [(set R16:$dst, (add R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001629def ADD32rm : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001630 "add{l} {$src2, $dst|$dst, $src2}",
1631 [(set R32:$dst, (add R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001632
Chris Lattner3a173df2004-10-03 20:35:00 +00001633def ADD8ri : Ii8<0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001634 "add{b} {$src2, $dst|$dst, $src2}",
1635 [(set R8:$dst, (add R8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001636
1637let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3a173df2004-10-03 20:35:00 +00001638def ADD16ri : Ii16<0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001639 "add{w} {$src2, $dst|$dst, $src2}",
1640 [(set R16:$dst, (add R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001641def ADD32ri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001642 "add{l} {$src2, $dst|$dst, $src2}",
1643 [(set R32:$dst, (add R32:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001644}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001645
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001646// FIXME: move ADD16ri8 above ADD16ri to optimize for space.
1647def ADD16ri8 : Ii8<0x83, MRM0r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1648 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001649 [(set R16:$dst, (add R16:$src1, i16immSExt8:$src2))]>,
1650 OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001651def ADD32ri8 : Ii8<0x83, MRM0r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1652 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001653 [(set R32:$dst, (add R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001654
1655let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001656 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001657 "add{b} {$src2, $dst|$dst, $src2}",
1658 [(store (add (load addr:$dst), R8:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001659 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001660 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001661 [(store (add (load addr:$dst), R16:$src2), addr:$dst)]>,
1662 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001663 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001664 "add{l} {$src2, $dst|$dst, $src2}",
1665 [(store (add (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001666 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001667 "add{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001668 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001669 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001670 "add{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001671 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001672 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001673 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001674 "add{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001675 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengee93f9d2005-12-12 19:45:23 +00001676 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1677 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001678 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1679 OpSize;
Evan Chengee93f9d2005-12-12 19:45:23 +00001680 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1681 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001682 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001683}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001684
Chris Lattner10197ff2005-01-03 01:27:59 +00001685let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001686def ADC32rr : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001687 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001688}
Chris Lattner3a173df2004-10-03 20:35:00 +00001689def ADC32rm : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001690 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001691def ADC32ri : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001692 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001693def ADC32ri8 : Ii8<0x83, MRM2r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001694 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001695
1696let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001697 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001698 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001699 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001700 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001701 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001702 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001703}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001704
Chris Lattner3a173df2004-10-03 20:35:00 +00001705def SUB8rr : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001706 "sub{b} {$src2, $dst|$dst, $src2}",
1707 [(set R8:$dst, (sub R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001708def SUB16rr : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001709 "sub{w} {$src2, $dst|$dst, $src2}",
1710 [(set R16:$dst, (sub R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001711def SUB32rr : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001712 "sub{l} {$src2, $dst|$dst, $src2}",
1713 [(set R32:$dst, (sub R32:$src1, R32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001714def SUB8rm : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001715 "sub{b} {$src2, $dst|$dst, $src2}",
1716 [(set R8:$dst, (sub R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001717def SUB16rm : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001718 "sub{w} {$src2, $dst|$dst, $src2}",
1719 [(set R16:$dst, (sub R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001720def SUB32rm : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001721 "sub{l} {$src2, $dst|$dst, $src2}",
1722 [(set R32:$dst, (sub R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001723
Chris Lattner36b68902004-08-10 21:21:30 +00001724def SUB8ri : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001725 "sub{b} {$src2, $dst|$dst, $src2}",
1726 [(set R8:$dst, (sub R8:$src1, imm:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001727def SUB16ri : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001728 "sub{w} {$src2, $dst|$dst, $src2}",
1729 [(set R16:$dst, (sub R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001730def SUB32ri : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001731 "sub{l} {$src2, $dst|$dst, $src2}",
1732 [(set R32:$dst, (sub R32:$src1, imm:$src2))]>;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001733def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1734 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001735 [(set R16:$dst, (sub R16:$src1, i16immSExt8:$src2))]>,
1736 OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001737def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1738 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001739 [(set R32:$dst, (sub R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001740let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001741 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001742 "sub{b} {$src2, $dst|$dst, $src2}",
1743 [(store (sub (load addr:$dst), R8:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001744 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001745 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001746 [(store (sub (load addr:$dst), R16:$src2), addr:$dst)]>,
1747 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001748 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001749 "sub{l} {$src2, $dst|$dst, $src2}",
1750 [(store (sub (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001751 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001752 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001753 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001754 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001755 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001756 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001757 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001758 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001759 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001760 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengd160d482005-12-12 21:54:05 +00001761 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1762 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001763 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1764 OpSize;
Evan Chengd160d482005-12-12 21:54:05 +00001765 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1766 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001767 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001768}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001769
Chris Lattner3a173df2004-10-03 20:35:00 +00001770def SBB32rr : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001771 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001772
Chris Lattner57a02302004-08-11 04:31:00 +00001773let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001774 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001775 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001776 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001777 "sbb{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001778 def SBB16mi : Ii32<0x81, MRM3m, (ops i16mem:$dst, i16imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001779 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001780 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001781 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001782 def SBB16mi8 : Ii8<0x83, MRM3m, (ops i16mem:$dst, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001783 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001784 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001785 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001786}
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001787def SBB8ri : Ii8<0x80, MRM3r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001788 "sbb{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001789def SBB16ri : Ii16<0x81, MRM3r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001790 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001791
Chris Lattner57a02302004-08-11 04:31:00 +00001792def SBB32rm : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001793 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner36b68902004-08-10 21:21:30 +00001794def SBB32ri : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001795 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001796
Chris Lattner09c750f2004-10-06 14:31:50 +00001797def SBB16ri8 : Ii8<0x83, MRM3r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001798 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001799def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001800 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001801
Chris Lattner10197ff2005-01-03 01:27:59 +00001802let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001803def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001804 "imul{w} {$src2, $dst|$dst, $src2}",
1805 [(set R16:$dst, (mul R16:$src1, R16:$src2))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001806def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001807 "imul{l} {$src2, $dst|$dst, $src2}",
1808 [(set R32:$dst, (mul R32:$src1, R32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00001809}
Chris Lattner3a173df2004-10-03 20:35:00 +00001810def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001811 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001812 [(set R16:$dst, (mul R16:$src1, (load addr:$src2)))]>,
1813 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001814def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001815 "imul{l} {$src2, $dst|$dst, $src2}",
1816 [(set R32:$dst, (mul R32:$src1, (load addr:$src2)))]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001817
1818} // end Two Address instructions
1819
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001820// Suprisingly enough, these are not two address instructions!
Chris Lattner3a173df2004-10-03 20:35:00 +00001821def IMUL16rri : Ii16<0x69, MRMSrcReg, // R16 = R16*I16
1822 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001823 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Chengf281e022005-12-12 23:47:46 +00001824 [(set R16:$dst, (mul R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001825def IMUL32rri : Ii32<0x69, MRMSrcReg, // R32 = R32*I32
1826 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001827 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1828 [(set R32:$dst, (mul R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001829def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // R16 = R16*I8
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001830 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1831 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001832 [(set R16:$dst, (mul R16:$src1, i16immSExt8:$src2))]>,
1833 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001834def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // R32 = R32*I8
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001835 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1836 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001837 [(set R32:$dst, (mul R32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001838
Chris Lattner3a173df2004-10-03 20:35:00 +00001839def IMUL16rmi : Ii16<0x69, MRMSrcMem, // R16 = [mem16]*I16
Evan Chengf281e022005-12-12 23:47:46 +00001840 (ops R16:$dst, i16mem:$src1, i16imm:$src2),
1841 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1842 [(set R16:$dst, (mul (load addr:$src1), imm:$src2))]>,
1843 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001844def IMUL32rmi : Ii32<0x69, MRMSrcMem, // R32 = [mem32]*I32
1845 (ops R32:$dst, i32mem:$src1, i32imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001846 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1847 [(set R32:$dst, (mul (load addr:$src1), imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001848def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // R16 = [mem16]*I8
Evan Chengf281e022005-12-12 23:47:46 +00001849 (ops R16:$dst, i16mem:$src1, i16i8imm :$src2),
1850 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001851 [(set R16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
1852 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001853def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // R32 = [mem32]*I8
Evan Chengf281e022005-12-12 23:47:46 +00001854 (ops R32:$dst, i32mem:$src1, i32i8imm: $src2),
1855 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001856 [(set R32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001857
1858//===----------------------------------------------------------------------===//
1859// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00001860//
Chris Lattnercc65bee2005-01-02 02:35:46 +00001861let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Chris Lattner36b68902004-08-10 21:21:30 +00001862def TEST8rr : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001863 "test{b} {$src2, $src1|$src1, $src2}",
1864 [(set STATUS, (X86test R8:$src1, R8:$src2))]>,
1865 Imp<[],[STATUS]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001866def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001867 "test{w} {$src2, $src1|$src1, $src2}",
1868 [(set STATUS, (X86test R16:$src1, R16:$src2))]>,
1869 Imp<[],[STATUS]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001870def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001871 "test{l} {$src2, $src1|$src1, $src2}",
1872 [(set STATUS, (X86test R32:$src1, R32:$src2))]>,
1873 Imp<[],[STATUS]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001874}
Chris Lattner57a02302004-08-11 04:31:00 +00001875def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001876 "test{b} {$src2, $src1|$src1, $src2}",
1877 [(set STATUS, (X86test (loadi8 addr:$src1), R8:$src2))]>,
1878 Imp<[],[STATUS]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001879def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001880 "test{w} {$src2, $src1|$src1, $src2}",
1881 [(set STATUS, (X86test (loadi16 addr:$src1), R16:$src2))]>,
1882 Imp<[],[STATUS]>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001883def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001884 "test{l} {$src2, $src1|$src1, $src2}",
1885 [(set STATUS, (X86test (loadi32 addr:$src1), R32:$src2))]>,
1886 Imp<[],[STATUS]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001887def TEST8rm : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001888 "test{b} {$src2, $src1|$src1, $src2}",
1889 [(set STATUS, (X86test R8:$src1, (loadi8 addr:$src2)))]>,
1890 Imp<[],[STATUS]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001891def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001892 "test{w} {$src2, $src1|$src1, $src2}",
1893 [(set STATUS, (X86test R16:$src1, (loadi16 addr:$src2)))]>,
1894 Imp<[],[STATUS]>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001895def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001896 "test{l} {$src2, $src1|$src1, $src2}",
1897 [(set STATUS, (X86test R32:$src1, (loadi32 addr:$src2)))]>,
1898 Imp<[],[STATUS]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001899
Chris Lattner707c6fe2004-10-04 01:38:10 +00001900def TEST8ri : Ii8 <0xF6, MRM0r, // flags = R8 & imm8
1901 (ops R8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001902 "test{b} {$src2, $src1|$src1, $src2}",
1903 [(set STATUS, (X86test R8:$src1, imm:$src2))]>,
1904 Imp<[],[STATUS]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001905def TEST16ri : Ii16<0xF7, MRM0r, // flags = R16 & imm16
1906 (ops R16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001907 "test{w} {$src2, $src1|$src1, $src2}",
1908 [(set STATUS, (X86test R16:$src1, imm:$src2))]>,
1909 Imp<[],[STATUS]>, OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001910def TEST32ri : Ii32<0xF7, MRM0r, // flags = R32 & imm32
1911 (ops R32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001912 "test{l} {$src2, $src1|$src1, $src2}",
1913 [(set STATUS, (X86test R32:$src1, imm:$src2))]>,
1914 Imp<[],[STATUS]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001915def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengaed7c722005-12-17 01:24:02 +00001916 (ops i8mem:$src1, i8imm:$src2),
1917 "test{b} {$src2, $src1|$src1, $src2}",
1918 [(set STATUS, (X86test (loadi8 addr:$src1), imm:$src2))]>,
1919 Imp<[],[STATUS]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001920def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
1921 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001922 "test{w} {$src2, $src1|$src1, $src2}",
1923 [(set STATUS, (X86test (loadi16 addr:$src1), imm:$src2))]>,
1924 Imp<[],[STATUS]>, OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001925def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
1926 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00001927 "test{l} {$src2, $src1|$src1, $src2}",
1928 [(set STATUS, (X86test (loadi32 addr:$src1), imm:$src2))]>,
1929 Imp<[],[STATUS]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001930
1931
1932// Condition code ops, incl. set if equal/not equal/...
Evan Chengf0701842005-11-29 19:38:52 +00001933def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
1934def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001935
Chris Lattner3a173df2004-10-03 20:35:00 +00001936def SETEr : I<0x94, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00001937 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001938 "sete $dst",
1939 [(set R8:$dst, (X86setcc X86_COND_E, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001940 TB; // R8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00001941def SETEm : I<0x94, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00001942 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001943 "sete $dst",
1944 [(store (X86setcc X86_COND_E, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001945 TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00001946def SETNEr : I<0x95, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00001947 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001948 "setne $dst",
1949 [(set R8:$dst, (X86setcc X86_COND_NE, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001950 TB; // R8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00001951def SETNEm : I<0x95, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00001952 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001953 "setne $dst",
1954 [(store (X86setcc X86_COND_NE, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001955 TB; // [mem8] = !=
1956def SETLr : I<0x9C, MRM0r,
1957 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001958 "setl $dst",
1959 [(set R8:$dst, (X86setcc X86_COND_L, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001960 TB; // R8 = < signed
1961def SETLm : I<0x9C, MRM0m,
1962 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001963 "setl $dst",
1964 [(store (X86setcc X86_COND_L, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001965 TB; // [mem8] = < signed
1966def SETGEr : I<0x9D, MRM0r,
1967 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001968 "setge $dst",
1969 [(set R8:$dst, (X86setcc X86_COND_GE, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001970 TB; // R8 = >= signed
1971def SETGEm : I<0x9D, MRM0m,
1972 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001973 "setge $dst",
1974 [(store (X86setcc X86_COND_GE, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001975 TB; // [mem8] = >= signed
1976def SETLEr : I<0x9E, MRM0r,
1977 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001978 "setle $dst",
1979 [(set R8:$dst, (X86setcc X86_COND_LE, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001980 TB; // R8 = <= signed
1981def SETLEm : I<0x9E, MRM0m,
1982 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001983 "setle $dst",
1984 [(store (X86setcc X86_COND_LE, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001985 TB; // [mem8] = <= signed
1986def SETGr : I<0x9F, MRM0r,
1987 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001988 "setg $dst",
1989 [(set R8:$dst, (X86setcc X86_COND_G, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001990 TB; // R8 = > signed
1991def SETGm : I<0x9F, MRM0m,
1992 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001993 "setg $dst",
1994 [(store (X86setcc X86_COND_G, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00001995 TB; // [mem8] = > signed
1996
1997def SETBr : I<0x92, MRM0r,
1998 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00001999 "setb $dst",
2000 [(set R8:$dst, (X86setcc X86_COND_B, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002001 TB; // R8 = < unsign
2002def SETBm : I<0x92, MRM0m,
2003 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002004 "setb $dst",
2005 [(store (X86setcc X86_COND_B, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002006 TB; // [mem8] = < unsign
2007def SETAEr : I<0x93, MRM0r,
2008 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002009 "setae $dst",
2010 [(set R8:$dst, (X86setcc X86_COND_AE, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002011 TB; // R8 = >= unsign
2012def SETAEm : I<0x93, MRM0m,
2013 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002014 "setae $dst",
2015 [(store (X86setcc X86_COND_AE, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002016 TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002017def SETBEr : I<0x96, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002018 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002019 "setbe $dst",
2020 [(set R8:$dst, (X86setcc X86_COND_BE, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002021 TB; // R8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002022def SETBEm : I<0x96, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002023 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002024 "setbe $dst",
2025 [(store (X86setcc X86_COND_BE, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002026 TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002027def SETAr : I<0x97, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002028 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002029 "seta $dst",
2030 [(set R8:$dst, (X86setcc X86_COND_A, STATUS))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002031 TB; // R8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002032def SETAm : I<0x97, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002033 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002034 "seta $dst",
2035 [(store (X86setcc X86_COND_A, STATUS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002036 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002037
Chris Lattner3a173df2004-10-03 20:35:00 +00002038def SETSr : I<0x98, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002039 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002040 "sets $dst",
2041 [(set R8:$dst, (X86setcc X86_COND_S, STATUS))]>,
2042 TB; // R8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002043def SETSm : I<0x98, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002044 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002045 "sets $dst",
2046 [(store (X86setcc X86_COND_S, STATUS), addr:$dst)]>,
2047 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002048def SETNSr : I<0x99, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002049 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002050 "setns $dst",
2051 [(set R8:$dst, (X86setcc X86_COND_NS, STATUS))]>,
2052 TB; // R8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002053def SETNSm : I<0x99, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002054 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002055 "setns $dst",
2056 [(store (X86setcc X86_COND_NS, STATUS), addr:$dst)]>,
2057 TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002058def SETPr : I<0x9A, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002059 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002060 "setp $dst",
2061 [(set R8:$dst, (X86setcc X86_COND_P, STATUS))]>,
2062 TB; // R8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002063def SETPm : I<0x9A, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002064 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002065 "setp $dst",
2066 [(store (X86setcc X86_COND_P, STATUS), addr:$dst)]>,
2067 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002068def SETNPr : I<0x9B, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002069 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002070 "setnp $dst",
2071 [(set R8:$dst, (X86setcc X86_COND_NP, STATUS))]>,
2072 TB; // R8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002073def SETNPm : I<0x9B, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002074 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002075 "setnp $dst",
2076 [(store (X86setcc X86_COND_NP, STATUS), addr:$dst)]>,
2077 TB; // [mem8] = not parity
Chris Lattner1cca5e32003-08-03 21:54:21 +00002078
2079// Integer comparisons
Chris Lattner3a173df2004-10-03 20:35:00 +00002080def CMP8rr : I<0x38, MRMDestReg,
2081 (ops R8 :$src1, R8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002082 "cmp{b} {$src2, $src1|$src1, $src2}",
2083 [(set STATUS, (X86cmp R8:$src1, R8:$src2))]>,
2084 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002085def CMP16rr : I<0x39, MRMDestReg,
2086 (ops R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002087 "cmp{w} {$src2, $src1|$src1, $src2}",
2088 [(set STATUS, (X86cmp R16:$src1, R16:$src2))]>,
2089 Imp<[],[STATUS]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002090def CMP32rr : I<0x39, MRMDestReg,
2091 (ops R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002092 "cmp{l} {$src2, $src1|$src1, $src2}",
2093 [(set STATUS, (X86cmp R32:$src1, R32:$src2))]>,
2094 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002095def CMP8mr : I<0x38, MRMDestMem,
2096 (ops i8mem :$src1, R8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002097 "cmp{b} {$src2, $src1|$src1, $src2}",
2098 [(set STATUS, (X86cmp (loadi8 addr:$src1), R8:$src2))]>,
2099 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002100def CMP16mr : I<0x39, MRMDestMem,
2101 (ops i16mem:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002102 "cmp{w} {$src2, $src1|$src1, $src2}",
2103 [(set STATUS, (X86cmp (loadi16 addr:$src1), R16:$src2))]>,
2104 Imp<[],[STATUS]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002105def CMP32mr : I<0x39, MRMDestMem,
2106 (ops i32mem:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002107 "cmp{l} {$src2, $src1|$src1, $src2}",
2108 [(set STATUS, (X86cmp (loadi32 addr:$src1), R32:$src2))]>,
2109 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002110def CMP8rm : I<0x3A, MRMSrcMem,
2111 (ops R8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002112 "cmp{b} {$src2, $src1|$src1, $src2}",
2113 [(set STATUS, (X86cmp R8:$src1, (loadi8 addr:$src2)))]>,
2114 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002115def CMP16rm : I<0x3B, MRMSrcMem,
2116 (ops R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002117 "cmp{w} {$src2, $src1|$src1, $src2}",
2118 [(set STATUS, (X86cmp R16:$src1, (loadi16 addr:$src2)))]>,
2119 Imp<[],[STATUS]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002120def CMP32rm : I<0x3B, MRMSrcMem,
2121 (ops R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002122 "cmp{l} {$src2, $src1|$src1, $src2}",
2123 [(set STATUS, (X86cmp R32:$src1, (loadi32 addr:$src2)))]>,
2124 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002125def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengaed7c722005-12-17 01:24:02 +00002126 (ops R8:$src1, i8imm:$src2),
2127 "cmp{b} {$src2, $src1|$src1, $src2}",
2128 [(set STATUS, (X86cmp R8:$src1, imm:$src2))]>,
2129 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002130def CMP16ri : Ii16<0x81, MRM7r,
2131 (ops R16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002132 "cmp{w} {$src2, $src1|$src1, $src2}",
2133 [(set STATUS, (X86cmp R16:$src1, imm:$src2))]>,
2134 Imp<[],[STATUS]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002135def CMP32ri : Ii32<0x81, MRM7r,
2136 (ops R32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002137 "cmp{l} {$src2, $src1|$src1, $src2}",
2138 [(set STATUS, (X86cmp R32:$src1, imm:$src2))]>,
2139 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002140def CMP8mi : Ii8 <0x80, MRM7m,
2141 (ops i8mem :$src1, i8imm :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002142 "cmp{b} {$src2, $src1|$src1, $src2}",
2143 [(set STATUS, (X86cmp (loadi8 addr:$src1), imm:$src2))]>,
2144 Imp<[],[STATUS]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002145def CMP16mi : Ii16<0x81, MRM7m,
2146 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002147 "cmp{w} {$src2, $src1|$src1, $src2}",
2148 [(set STATUS, (X86cmp (loadi16 addr:$src1), imm:$src2))]>,
2149 Imp<[],[STATUS]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002150def CMP32mi : Ii32<0x81, MRM7m,
2151 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002152 "cmp{l} {$src2, $src1|$src1, $src2}",
2153 [(set STATUS, (X86cmp (loadi32 addr:$src1), imm:$src2))]>,
2154 Imp<[],[STATUS]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002155
2156// Sign/Zero extenders
Chris Lattner3a173df2004-10-03 20:35:00 +00002157def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002158 "movs{bw|x} {$src, $dst|$dst, $src}",
2159 [(set R16:$dst, (sext R8:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002160def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002161 "movs{bw|x} {$src, $dst|$dst, $src}",
2162 [(set R16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002163def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002164 "movs{bl|x} {$src, $dst|$dst, $src}",
2165 [(set R32:$dst, (sext R8:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002166def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002167 "movs{bl|x} {$src, $dst|$dst, $src}",
2168 [(set R32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002169def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002170 "movs{wl|x} {$src, $dst|$dst, $src}",
2171 [(set R32:$dst, (sext R16:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002172def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002173 "movs{wl|x} {$src, $dst|$dst, $src}",
2174 [(set R32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002175
Chris Lattner3a173df2004-10-03 20:35:00 +00002176def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002177 "movz{bw|x} {$src, $dst|$dst, $src}",
2178 [(set R16:$dst, (zext R8:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002179def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002180 "movz{bw|x} {$src, $dst|$dst, $src}",
2181 [(set R16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002182def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002183 "movz{bl|x} {$src, $dst|$dst, $src}",
2184 [(set R32:$dst, (zext R8:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002185def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002186 "movz{bl|x} {$src, $dst|$dst, $src}",
2187 [(set R32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002188def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002189 "movz{wl|x} {$src, $dst|$dst, $src}",
2190 [(set R32:$dst, (zext R16:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002191def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002192 "movz{wl|x} {$src, $dst|$dst, $src}",
2193 [(set R32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2194
2195// Handling 1 bit zextload and sextload
2196def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2197def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2198def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2199def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002200
Evan Chengcb17bac2005-12-15 19:49:23 +00002201// Handling 1 bit extload
2202def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2203
Evan Cheng1aabc4e2005-12-17 01:47:57 +00002204// Modeling anyext as zext
2205def : Pat<(i16 (anyext R8 :$src)), (MOVZX16rr8 R8 :$src)>;
2206def : Pat<(i32 (anyext R8 :$src)), (MOVZX32rr8 R8 :$src)>;
2207def : Pat<(i32 (anyext R16:$src)), (MOVZX32rr16 R16:$src)>;
2208
Nate Begemanf1702ac2005-06-27 21:20:31 +00002209//===----------------------------------------------------------------------===//
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002210// XMM Floating point support (requires SSE / SSE2)
Nate Begemanf1702ac2005-06-27 21:20:31 +00002211//===----------------------------------------------------------------------===//
2212
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002213def MOVSSrr : I<0x10, MRMSrcReg, (ops FR32:$dst, FR32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002214 "movss {$src, $dst|$dst, $src}", []>,
2215 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002216def MOVSDrr : I<0x10, MRMSrcReg, (ops FR64:$dst, FR64:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002217 "movsd {$src, $dst|$dst, $src}", []>,
2218 Requires<[HasSSE2]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002219
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002220def MOVSSrm : I<0x10, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
2221 "movss {$src, $dst|$dst, $src}",
2222 [(set FR32:$dst, (loadf32 addr:$src))]>,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002223 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002224def MOVSSmr : I<0x11, MRMDestMem, (ops f32mem:$dst, FR32:$src),
2225 "movss {$src, $dst|$dst, $src}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002226 [(store FR32:$src, addr:$dst)]>,
2227 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002228def MOVSDrm : I<0x10, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
2229 "movsd {$src, $dst|$dst, $src}",
2230 [(set FR64:$dst, (loadf64 addr:$src))]>,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002231 Requires<[HasSSE2]>, XD;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002232def MOVSDmr : I<0x11, MRMDestMem, (ops f64mem:$dst, FR64:$src),
2233 "movsd {$src, $dst|$dst, $src}",
2234 [(store FR64:$src, addr:$dst)]>,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002235 Requires<[HasSSE2]>, XD;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002236
2237def CVTTSD2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, FR64:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002238 "cvttsd2si {$src, $dst|$dst, $src}",
2239 [(set R32:$dst, (fp_to_sint FR64:$src))]>,
2240 Requires<[HasSSE2]>, XD;
Nate Begeman16b04f32005-07-15 00:38:55 +00002241def CVTTSD2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f64mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002242 "cvttsd2si {$src, $dst|$dst, $src}",
2243 [(set R32:$dst, (fp_to_sint (loadf64 addr:$src)))]>,
2244 Requires<[HasSSE2]>, XD;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002245def CVTTSS2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, FR32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002246 "cvttss2si {$src, $dst|$dst, $src}",
2247 [(set R32:$dst, (fp_to_sint FR32:$src))]>,
2248 Requires<[HasSSE1]>, XS;
Nate Begeman16b04f32005-07-15 00:38:55 +00002249def CVTTSS2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f32mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002250 "cvttss2si {$src, $dst|$dst, $src}",
2251 [(set R32:$dst, (fp_to_sint (loadf32 addr:$src)))]>,
2252 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002253def CVTSD2SSrr: I<0x5A, MRMSrcReg, (ops FR32:$dst, FR64:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002254 "cvtsd2ss {$src, $dst|$dst, $src}",
2255 [(set FR32:$dst, (fround FR64:$src))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002256 Requires<[HasSSE2]>, XS;
2257def CVTSD2SSrm: I<0x5A, MRMSrcMem, (ops FR32:$dst, f64mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002258 "cvtsd2ss {$src, $dst|$dst, $src}",
2259 [(set FR32:$dst, (fround (loadf64 addr:$src)))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002260 Requires<[HasSSE2]>, XS;
2261def CVTSS2SDrr: I<0x5A, MRMSrcReg, (ops FR64:$dst, FR32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002262 "cvtss2sd {$src, $dst|$dst, $src}",
2263 [(set FR64:$dst, (fextend FR32:$src))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002264 Requires<[HasSSE2]>, XD;
2265def CVTSS2SDrm: I<0x5A, MRMSrcMem, (ops FR64:$dst, f32mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002266 "cvtss2sd {$src, $dst|$dst, $src}",
2267 [(set FR64:$dst, (fextend (loadf32 addr:$src)))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002268 Requires<[HasSSE2]>, XD;
2269def CVTSI2SSrr: I<0x2A, MRMSrcReg, (ops FR32:$dst, R32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002270 "cvtsi2ss {$src, $dst|$dst, $src}",
2271 [(set FR32:$dst, (sint_to_fp R32:$src))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002272 Requires<[HasSSE2]>, XS;
2273def CVTSI2SSrm: I<0x2A, MRMSrcMem, (ops FR32:$dst, i32mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002274 "cvtsi2ss {$src, $dst|$dst, $src}",
2275 [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002276 Requires<[HasSSE2]>, XS;
2277def CVTSI2SDrr: I<0x2A, MRMSrcReg, (ops FR64:$dst, R32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002278 "cvtsi2sd {$src, $dst|$dst, $src}",
2279 [(set FR64:$dst, (sint_to_fp R32:$src))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002280 Requires<[HasSSE2]>, XD;
2281def CVTSI2SDrm: I<0x2A, MRMSrcMem, (ops FR64:$dst, i32mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002282 "cvtsi2sd {$src, $dst|$dst, $src}",
2283 [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002284 Requires<[HasSSE2]>, XD;
Nate Begemanf63be7d2005-07-06 18:59:04 +00002285
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002286def SQRTSSrm : I<0x51, MRMSrcMem, (ops FR32:$dst, f32mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002287 "sqrtss {$src, $dst|$dst, $src}",
2288 [(set FR32:$dst, (fsqrt (loadf32 addr:$src)))]>,
2289 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002290def SQRTSSrr : I<0x51, MRMSrcReg, (ops FR32:$dst, FR32:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002291 "sqrtss {$src, $dst|$dst, $src}",
2292 [(set FR32:$dst, (fsqrt FR32:$src))]>,
2293 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002294def SQRTSDrm : I<0x51, MRMSrcMem, (ops FR64:$dst, f64mem:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002295 "sqrtsd {$src, $dst|$dst, $src}",
2296 [(set FR64:$dst, (fsqrt (loadf64 addr:$src)))]>,
2297 Requires<[HasSSE2]>, XD;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002298def SQRTSDrr : I<0x51, MRMSrcReg, (ops FR64:$dst, FR64:$src),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002299 "sqrtsd {$src, $dst|$dst, $src}",
2300 [(set FR64:$dst, (fsqrt FR64:$src))]>,
2301 Requires<[HasSSE2]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002302
Evan Chengd9558e02006-01-06 00:43:03 +00002303def UCOMISDrr: I<0x2E, MRMSrcReg, (ops FR64:$src1, FR64:$src2),
2304 "ucomisd {$src2, $src1|$src1, $src2}",
2305 [(set STATUS, (X86cmp FR64:$src1, FR64:$src2))]>,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002306 Requires<[HasSSE2]>, TB, OpSize;
Evan Chengd9558e02006-01-06 00:43:03 +00002307def UCOMISDrm: I<0x2E, MRMSrcMem, (ops FR64:$src1, f64mem:$src2),
2308 "ucomisd {$src2, $src1|$src1, $src2}",
2309 [(set STATUS, (X86cmp FR64:$src1, (loadf64 addr:$src2)))]>,
2310 Imp<[],[STATUS]>, Requires<[HasSSE2]>, TB, OpSize;
2311def UCOMISSrr: I<0x2E, MRMSrcReg, (ops FR32:$src1, FR32:$src2),
2312 "ucomiss {$src2, $src1|$src1, $src2}",
2313 [(set STATUS, (X86cmp FR32:$src1, FR32:$src2))]>,
2314 Imp<[],[STATUS]>, Requires<[HasSSE1]>, TB;
2315def UCOMISSrm: I<0x2E, MRMSrcMem, (ops FR32:$src1, f32mem:$src2),
2316 "ucomiss {$src2, $src1|$src1, $src2}",
2317 [(set STATUS, (X86cmp FR32:$src1, (loadf32 addr:$src2)))]>,
2318 Imp<[],[STATUS]>, Requires<[HasSSE1]>, TB;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002319
Evan Chengf0701842005-11-29 19:38:52 +00002320// Pseudo-instructions that map fld0 to xorps/xorpd for sse.
Nate Begeman1c73c7b2005-08-03 23:26:28 +00002321// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002322def FLD0SS : I<0x57, MRMSrcReg, (ops FR32:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002323 "xorps $dst, $dst", [(set FR32:$dst, fp32imm0)]>,
Evan Cheng650d6882006-01-05 02:08:37 +00002324 Requires<[HasSSE1]>, TB;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002325def FLD0SD : I<0x57, MRMSrcReg, (ops FR64:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002326 "xorpd $dst, $dst", [(set FR64:$dst, fp64imm0)]>,
Evan Cheng650d6882006-01-05 02:08:37 +00002327 Requires<[HasSSE2]>, TB, OpSize;
Nate Begeman1c73c7b2005-08-03 23:26:28 +00002328
Nate Begemanf1702ac2005-06-27 21:20:31 +00002329let isTwoAddress = 1 in {
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002330// SSE Scalar Arithmetic
Nate Begemanf1702ac2005-06-27 21:20:31 +00002331let isCommutable = 1 in {
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002332def ADDSSrr : I<0x58, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002333 "addss {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002334 [(set FR32:$dst, (fadd FR32:$src1, FR32:$src2))]>,
2335 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002336def ADDSDrr : I<0x58, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002337 "addsd {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002338 [(set FR64:$dst, (fadd FR64:$src1, FR64:$src2))]>,
2339 Requires<[HasSSE2]>, XD;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002340def MULSSrr : I<0x59, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002341 "mulss {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002342 [(set FR32:$dst, (fmul FR32:$src1, FR32:$src2))]>,
2343 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002344def MULSDrr : I<0x59, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002345 "mulsd {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002346 [(set FR64:$dst, (fmul FR64:$src1, FR64:$src2))]>,
2347 Requires<[HasSSE2]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002348}
Nate Begemanf1702ac2005-06-27 21:20:31 +00002349
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002350def ADDSSrm : I<0x58, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2351 "addss {$src2, $dst|$dst, $src2}",
2352 [(set FR32:$dst, (fadd FR32:$src1, (loadf32 addr:$src2)))]>,
2353 Requires<[HasSSE1]>, XS;
2354def ADDSDrm : I<0x58, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2355 "addsd {$src2, $dst|$dst, $src2}",
2356 [(set FR64:$dst, (fadd FR64:$src1, (loadf64 addr:$src2)))]>,
2357 Requires<[HasSSE2]>, XD;
2358def MULSSrm : I<0x59, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2359 "mulss {$src2, $dst|$dst, $src2}",
2360 [(set FR32:$dst, (fmul FR32:$src1, (loadf32 addr:$src2)))]>,
2361 Requires<[HasSSE1]>, XS;
2362def MULSDrm : I<0x59, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2363 "mulsd {$src2, $dst|$dst, $src2}",
2364 [(set FR64:$dst, (fmul FR64:$src1, (loadf64 addr:$src2)))]>,
2365 Requires<[HasSSE2]>, XD;
2366
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002367def DIVSSrr : I<0x5E, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002368 "divss {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002369 [(set FR32:$dst, (fdiv FR32:$src1, FR32:$src2))]>,
2370 Requires<[HasSSE1]>, XS;
2371def DIVSSrm : I<0x5E, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2372 "divss {$src2, $dst|$dst, $src2}",
2373 [(set FR32:$dst, (fdiv FR32:$src1, (loadf32 addr:$src2)))]>,
2374 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002375def DIVSDrr : I<0x5E, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002376 "divsd {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002377 [(set FR64:$dst, (fdiv FR64:$src1, FR64:$src2))]>,
2378 Requires<[HasSSE2]>, XD;
2379def DIVSDrm : I<0x5E, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2380 "divsd {$src2, $dst|$dst, $src2}",
2381 [(set FR64:$dst, (fdiv FR64:$src1, (loadf64 addr:$src2)))]>,
2382 Requires<[HasSSE2]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002383
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002384def SUBSSrr : I<0x5C, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002385 "subss {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002386 [(set FR32:$dst, (fsub FR32:$src1, FR32:$src2))]>,
2387 Requires<[HasSSE1]>, XS;
2388def SUBSSrm : I<0x5C, MRMSrcMem, (ops FR32:$dst, FR32:$src1, f32mem:$src2),
2389 "subss {$src2, $dst|$dst, $src2}",
2390 [(set FR32:$dst, (fsub FR32:$src1, (loadf32 addr:$src2)))]>,
2391 Requires<[HasSSE1]>, XS;
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002392def SUBSDrr : I<0x5C, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002393 "subsd {$src2, $dst|$dst, $src2}",
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002394 [(set FR64:$dst, (fsub FR64:$src1, FR64:$src2))]>,
2395 Requires<[HasSSE2]>, XD;
2396def SUBSDrm : I<0x5C, MRMSrcMem, (ops FR64:$dst, FR64:$src1, f64mem:$src2),
2397 "subsd {$src2, $dst|$dst, $src2}",
2398 [(set FR64:$dst, (fsub FR64:$src1, (loadf64 addr:$src2)))]>,
2399 Requires<[HasSSE2]>, XD;
2400
2401// SSE Logical
2402let isCommutable = 1 in {
2403def ANDPSrr : I<0x54, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2404 "andps {$src2, $dst|$dst, $src2}", []>,
2405 Requires<[HasSSE1]>, TB;
2406def ANDPDrr : I<0x54, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2407 "andpd {$src2, $dst|$dst, $src2}", []>,
2408 Requires<[HasSSE2]>, TB, OpSize;
2409def ORPSrr : I<0x56, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2410 "orps {$src2, $dst|$dst, $src2}", []>,
2411 Requires<[HasSSE1]>, TB;
2412def ORPDrr : I<0x56, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2413 "orpd {$src2, $dst|$dst, $src2}", []>,
2414 Requires<[HasSSE2]>, TB, OpSize;
2415def XORPSrr : I<0x57, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2416 "xorps {$src2, $dst|$dst, $src2}", []>,
2417 Requires<[HasSSE1]>, TB;
2418def XORPDrr : I<0x57, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2419 "xorpd {$src2, $dst|$dst, $src2}", []>,
2420 Requires<[HasSSE2]>, TB, OpSize;
2421}
2422def ANDNPSrr : I<0x55, MRMSrcReg, (ops FR32:$dst, FR32:$src1, FR32:$src2),
2423 "andnps {$src2, $dst|$dst, $src2}", []>,
2424 Requires<[HasSSE1]>, TB;
2425def ANDNPDrr : I<0x55, MRMSrcReg, (ops FR64:$dst, FR64:$src1, FR64:$src2),
2426 "andnpd {$src2, $dst|$dst, $src2}", []>,
2427 Requires<[HasSSE2]>, TB, OpSize;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002428
2429def CMPSSrr : I<0xC2, MRMSrcReg,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002430 (ops FR32:$dst, FR32:$src1, FR32:$src, SSECC:$cc),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002431 "cmp${cc}ss {$src, $dst|$dst, $src}", []>,
2432 Requires<[HasSSE1]>, XS;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002433def CMPSSrm : I<0xC2, MRMSrcMem,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002434 (ops FR32:$dst, FR32:$src1, f32mem:$src, SSECC:$cc),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002435 "cmp${cc}ss {$src, $dst|$dst, $src}", []>,
2436 Requires<[HasSSE1]>, XS;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002437def CMPSDrr : I<0xC2, MRMSrcReg,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002438 (ops FR64:$dst, FR64:$src1, FR64:$src, SSECC:$cc),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002439 "cmp${cc}sd {$src, $dst|$dst, $src}", []>,
2440 Requires<[HasSSE1]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002441def CMPSDrm : I<0xC2, MRMSrcMem,
Evan Chengbbc8ddb2005-12-20 22:59:51 +00002442 (ops FR64:$dst, FR64:$src1, f64mem:$src, SSECC:$cc),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002443 "cmp${cc}sd {$src, $dst|$dst, $src}", []>,
2444 Requires<[HasSSE2]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00002445}
Chris Lattner1cca5e32003-08-03 21:54:21 +00002446
2447//===----------------------------------------------------------------------===//
Chris Lattnerc515ad12005-12-21 07:50:26 +00002448// Floating Point Stack Support
Chris Lattner1cca5e32003-08-03 21:54:21 +00002449//===----------------------------------------------------------------------===//
2450
Chris Lattner58fe4592005-12-21 07:47:04 +00002451// Floating point support. All FP Stack operations are represented with two
2452// instructions here. The first instruction, generated by the instruction
2453// selector, uses "RFP" registers: a traditional register file to reference
2454// floating point values. These instructions are all psuedo instructions and
2455// use the "Fp" prefix. The second instruction is defined with FPI, which is
2456// the actual instruction emitted by the assembler. The FP stackifier pass
2457// converts one to the other after register allocation occurs.
2458//
2459// Note that the FpI instruction should have instruction selection info (e.g.
2460// a pattern) and the FPI instruction should have emission info (e.g. opcode
2461// encoding and asm printing info).
Chris Lattner1cca5e32003-08-03 21:54:21 +00002462
Chris Lattner58fe4592005-12-21 07:47:04 +00002463// FPI - Floating Point Instruction template.
2464class FPI<bits<8> o, Format F, dag ops, string asm> : I<o, F, ops, asm, []> {}
2465
2466// FpI - Floating Point Psuedo Instruction template.
2467class FpI<dag ops, FPFormat fp, list<dag> pattern>
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002468 : X86Inst<0, Pseudo, NoImm, ops, "">, Requires<[FPStack]> {
2469 let FPForm = fp; let FPFormBits = FPForm.Value;
2470 let Pattern = pattern;
2471}
2472
Chris Lattner58fe4592005-12-21 07:47:04 +00002473// Random Pseudo Instructions.
Evan Chengd90eb7f2006-01-05 00:27:02 +00002474let hasInFlag = 1 in
2475 def FpGETRESULT : FpI<(ops RFP:$dst), SpecialFP, []>; // FPR = ST(0)
2476
2477// Do not inline into instruction def. since it isn't predicated on FPStack.
2478def : Pat<(X86fpget), (FpGETRESULT)>;
2479
Evan Cheng2b4ea792005-12-26 09:11:45 +00002480let noResults = 1, hasOutFlag = 1 in
2481 def FpSETRESULT : FpI<(ops RFP:$src), SpecialFP,
2482 []>, Imp<[], [ST0]>; // ST(0) = FPR
2483
Evan Chengd90eb7f2006-01-05 00:27:02 +00002484// Do not inline into instruction def. since it isn't predicated on FPStack.
Evan Cheng2b4ea792005-12-26 09:11:45 +00002485def : Pat<(X86fpset RFP:$src), (FpSETRESULT RFP:$src)>;
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002486
Evan Cheng171049d2005-12-23 22:14:32 +00002487def FpMOV : FpI<(ops RFP:$dst, RFP:$src), SpecialFP, []>; // f1 = fmov f2
Chris Lattner1cca5e32003-08-03 21:54:21 +00002488
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002489// Arithmetic
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002490// Add, Sub, Mul, Div.
2491def FpADD : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2492 [(set RFP:$dst, (fadd RFP:$src1, RFP:$src2))]>;
2493def FpSUB : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2494 [(set RFP:$dst, (fsub RFP:$src1, RFP:$src2))]>;
2495def FpMUL : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2496 [(set RFP:$dst, (fmul RFP:$src1, RFP:$src2))]>;
2497def FpDIV : FpI<(ops RFP:$dst, RFP:$src1, RFP:$src2), TwoArgFP,
2498 [(set RFP:$dst, (fdiv RFP:$src1, RFP:$src2))]>;
2499
2500class FPST0rInst<bits<8> o, string asm>
2501 : FPI<o, AddRegFrm, (ops RST:$op), asm>, D8;
2502class FPrST0Inst<bits<8> o, string asm>
2503 : FPI<o, AddRegFrm, (ops RST:$op), asm>, DC;
2504class FPrST0PInst<bits<8> o, string asm>
2505 : FPI<o, AddRegFrm, (ops RST:$op), asm>, DE;
2506
Chris Lattner58fe4592005-12-21 07:47:04 +00002507// Binary Ops with a memory source.
2508def FpADD32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002509 [(set RFP:$dst, (fadd RFP:$src1,
2510 (extloadf64f32 addr:$src2)))]>;
2511 // ST(0) = ST(0) + [mem32]
Chris Lattner58fe4592005-12-21 07:47:04 +00002512def FpADD64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002513 [(set RFP:$dst, (fadd RFP:$src1, (loadf64 addr:$src2)))]>;
2514 // ST(0) = ST(0) + [mem64]
Chris Lattner58fe4592005-12-21 07:47:04 +00002515def FpMUL32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002516 [(set RFP:$dst, (fmul RFP:$src1,
2517 (extloadf64f32 addr:$src2)))]>;
2518 // ST(0) = ST(0) * [mem32]
Chris Lattner58fe4592005-12-21 07:47:04 +00002519def FpMUL64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002520 [(set RFP:$dst, (fmul RFP:$src1, (loadf64 addr:$src2)))]>;
2521 // ST(0) = ST(0) * [mem64]
Chris Lattner58fe4592005-12-21 07:47:04 +00002522def FpSUB32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002523 [(set RFP:$dst, (fsub RFP:$src1,
2524 (extloadf64f32 addr:$src2)))]>;
2525 // ST(0) = ST(0) - [mem32]
Chris Lattner58fe4592005-12-21 07:47:04 +00002526def FpSUB64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002527 [(set RFP:$dst, (fsub RFP:$src1, (loadf64 addr:$src2)))]>;
2528 // ST(0) = ST(0) - [mem64]
Chris Lattner58fe4592005-12-21 07:47:04 +00002529def FpSUBR32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Chengd90eb7f2006-01-05 00:27:02 +00002530 [(set RFP:$dst, (fsub (extloadf64f32 addr:$src2),
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002531 RFP:$src1))]>;
2532 // ST(0) = [mem32] - ST(0)
Chris Lattner58fe4592005-12-21 07:47:04 +00002533def FpSUBR64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002534 [(set RFP:$dst, (fsub (loadf64 addr:$src2), RFP:$src1))]>;
2535 // ST(0) = [mem64] - ST(0)
Chris Lattner58fe4592005-12-21 07:47:04 +00002536def FpDIV32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002537 [(set RFP:$dst, (fdiv RFP:$src1,
2538 (extloadf64f32 addr:$src2)))]>;
2539 // ST(0) = ST(0) / [mem32]
Chris Lattner58fe4592005-12-21 07:47:04 +00002540def FpDIV64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002541 [(set RFP:$dst, (fdiv RFP:$src1, (loadf64 addr:$src2)))]>;
2542 // ST(0) = ST(0) / [mem64]
Chris Lattner58fe4592005-12-21 07:47:04 +00002543def FpDIVR32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002544 [(set RFP:$dst, (fdiv (extloadf64f32 addr:$src2),
2545 RFP:$src1))]>;
2546 // ST(0) = [mem32] / ST(0)
Chris Lattner58fe4592005-12-21 07:47:04 +00002547def FpDIVR64m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002548 [(set RFP:$dst, (fdiv (loadf64 addr:$src2), RFP:$src1))]>;
2549 // ST(0) = [mem64] / ST(0)
Chris Lattner58fe4592005-12-21 07:47:04 +00002550
2551
2552def FADD32m : FPI<0xD8, MRM0m, (ops f32mem:$src), "fadd{s} $src">;
2553def FADD64m : FPI<0xDC, MRM0m, (ops f64mem:$src), "fadd{l} $src">;
2554def FMUL32m : FPI<0xD8, MRM1m, (ops f32mem:$src), "fmul{s} $src">;
2555def FMUL64m : FPI<0xDC, MRM1m, (ops f64mem:$src), "fmul{l} $src">;
2556def FSUB32m : FPI<0xD8, MRM4m, (ops f32mem:$src), "fsub{s} $src">;
2557def FSUB64m : FPI<0xDC, MRM4m, (ops f64mem:$src), "fsub{l} $src">;
2558def FSUBR32m : FPI<0xD8, MRM5m, (ops f32mem:$src), "fsubr{s} $src">;
2559def FSUBR64m : FPI<0xDC, MRM5m, (ops f64mem:$src), "fsubr{l} $src">;
2560def FDIV32m : FPI<0xD8, MRM6m, (ops f32mem:$src), "fdiv{s} $src">;
2561def FDIV64m : FPI<0xDC, MRM6m, (ops f64mem:$src), "fdiv{l} $src">;
2562def FDIVR32m : FPI<0xD8, MRM7m, (ops f32mem:$src), "fdivr{s} $src">;
2563def FDIVR64m : FPI<0xDC, MRM7m, (ops f64mem:$src), "fdivr{l} $src">;
2564
2565// FIXME: Implement these when we have a dag-dag isel!
2566//def FIADD16m : FPI<0xDE, MRM0m>; // ST(0) = ST(0) + [mem16int]
2567//def FIADD32m : FPI<0xDA, MRM0m>; // ST(0) = ST(0) + [mem32int]
2568//def FIMUL16m : FPI<0xDE, MRM1m>; // ST(0) = ST(0) * [mem16]
2569//def FIMUL32m : FPI<0xDA, MRM1m>; // ST(0) = ST(0) * [mem32]
2570//def FISUB16m : FPI<0xDE, MRM4m>; // ST(0) = ST(0) - [mem16int]
2571//def FISUB32m : FPI<0xDA, MRM4m>; // ST(0) = ST(0) - [mem32int]
2572//def FISUBR16m : FPI<0xDE, MRM5m>; // ST(0) = [mem16int] - ST(0)
2573//def FISUBR32m : FPI<0xDA, MRM5m>; // ST(0) = [mem32int] - ST(0)
2574//def FIDIV16m : FPI<0xDE, MRM6m>; // ST(0) = ST(0) / [mem16int]
2575//def FIDIV32m : FPI<0xDA, MRM6m>; // ST(0) = ST(0) / [mem32int]
2576//def FIDIVR16m : FPI<0xDE, MRM7m>; // ST(0) = [mem16int] / ST(0)
2577//def FIDIVR32m : FPI<0xDA, MRM7m>; // ST(0) = [mem32int] / ST(0)
2578
2579
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002580// NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
2581// of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
2582// we have to put some 'r's in and take them out of weird places.
2583def FADDST0r : FPST0rInst <0xC0, "fadd $op">;
2584def FADDrST0 : FPrST0Inst <0xC0, "fadd {%ST(0), $op|$op, %ST(0)}">;
2585def FADDPrST0 : FPrST0PInst<0xC0, "faddp $op">;
2586def FSUBRST0r : FPST0rInst <0xE8, "fsubr $op">;
2587def FSUBrST0 : FPrST0Inst <0xE8, "fsub{r} {%ST(0), $op|$op, %ST(0)}">;
2588def FSUBPrST0 : FPrST0PInst<0xE8, "fsub{r}p $op">;
2589def FSUBST0r : FPST0rInst <0xE0, "fsub $op">;
2590def FSUBRrST0 : FPrST0Inst <0xE0, "fsub{|r} {%ST(0), $op|$op, %ST(0)}">;
2591def FSUBRPrST0 : FPrST0PInst<0xE0, "fsub{|r}p $op">;
2592def FMULST0r : FPST0rInst <0xC8, "fmul $op">;
2593def FMULrST0 : FPrST0Inst <0xC8, "fmul {%ST(0), $op|$op, %ST(0)}">;
2594def FMULPrST0 : FPrST0PInst<0xC8, "fmulp $op">;
2595def FDIVRST0r : FPST0rInst <0xF8, "fdivr $op">;
2596def FDIVrST0 : FPrST0Inst <0xF8, "fdiv{r} {%ST(0), $op|$op, %ST(0)}">;
2597def FDIVPrST0 : FPrST0PInst<0xF8, "fdiv{r}p $op">;
2598def FDIVST0r : FPST0rInst <0xF0, "fdiv $op">;
2599def FDIVRrST0 : FPrST0Inst <0xF0, "fdiv{|r} {%ST(0), $op|$op, %ST(0)}">;
2600def FDIVRPrST0 : FPrST0PInst<0xF0, "fdiv{|r}p $op">;
2601
2602
2603// Unary operations.
2604def FpCHS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2605 [(set RFP:$dst, (fneg RFP:$src))]>;
2606def FpABS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2607 [(set RFP:$dst, (fabs RFP:$src))]>;
2608def FpSQRT : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2609 [(set RFP:$dst, (fsqrt RFP:$src))]>;
2610def FpSIN : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2611 [(set RFP:$dst, (fsin RFP:$src))]>;
2612def FpCOS : FpI<(ops RFP:$dst, RFP:$src), OneArgFPRW,
2613 [(set RFP:$dst, (fcos RFP:$src))]>;
2614def FpTST : FpI<(ops RFP:$src), OneArgFP,
2615 []>;
2616
2617def FCHS : FPI<0xE0, RawFrm, (ops), "fchs">, D9;
2618def FABS : FPI<0xE1, RawFrm, (ops), "fabs">, D9;
2619def FSQRT : FPI<0xFA, RawFrm, (ops), "fsqrt">, D9;
2620def FSIN : FPI<0xFE, RawFrm, (ops), "fsin">, D9;
2621def FCOS : FPI<0xFF, RawFrm, (ops), "fcos">, D9;
2622def FTST : FPI<0xE4, RawFrm, (ops), "ftst">, D9;
2623
2624
Chris Lattner58fe4592005-12-21 07:47:04 +00002625// Floating point cmovs.
2626let isTwoAddress = 1 in {
2627 def FpCMOVB : FpI<(ops RST:$dst, RFP:$src1, RFP:$src2), CondMovFP, []>;
2628 def FpCMOVBE : FpI<(ops RST:$dst, RFP:$src1, RFP:$src2), CondMovFP, []>;
2629 def FpCMOVE : FpI<(ops RST:$dst, RFP:$src1, RFP:$src2), CondMovFP, []>;
2630 def FpCMOVP : FpI<(ops RST:$dst, RFP:$src1, RFP:$src2), CondMovFP, []>;
2631 def FpCMOVAE : FpI<(ops RST:$dst, RFP:$src1, RFP:$src2), CondMovFP, []>;
2632 def FpCMOVA : FpI<(ops RST:$dst, RFP:$src1, RFP:$src2), CondMovFP, []>;
2633 def FpCMOVNE : FpI<(ops RST:$dst, RFP:$src1, RFP:$src2), CondMovFP, []>;
2634 def FpCMOVNP : FpI<(ops RST:$dst, RFP:$src1, RFP:$src2), CondMovFP, []>;
2635}
2636
2637def FCMOVB : FPI<0xC0, AddRegFrm, (ops RST:$op),
2638 "fcmovb {$op, %ST(0)|%ST(0), $op}">, DA;
2639def FCMOVBE : FPI<0xD0, AddRegFrm, (ops RST:$op),
2640 "fcmovbe {$op, %ST(0)|%ST(0), $op}">, DA;
2641def FCMOVE : FPI<0xC8, AddRegFrm, (ops RST:$op),
2642 "fcmove {$op, %ST(0)|%ST(0), $op}">, DA;
2643def FCMOVP : FPI<0xD8, AddRegFrm, (ops RST:$op),
2644 "fcmovu {$op, %ST(0)|%ST(0), $op}">, DA;
2645def FCMOVAE : FPI<0xC0, AddRegFrm, (ops RST:$op),
2646 "fcmovae {$op, %ST(0)|%ST(0), $op}">, DB;
2647def FCMOVA : FPI<0xD0, AddRegFrm, (ops RST:$op),
2648 "fcmova {$op, %ST(0)|%ST(0), $op}">, DB;
2649def FCMOVNE : FPI<0xC8, AddRegFrm, (ops RST:$op),
2650 "fcmovne {$op, %ST(0)|%ST(0), $op}">, DB;
2651def FCMOVNP : FPI<0xD8, AddRegFrm, (ops RST:$op),
2652 "fcmovnu {$op, %ST(0)|%ST(0), $op}">, DB;
2653
2654// Floating point loads & stores.
2655def FpLD32m : FpI<(ops RFP:$dst, f32mem:$src), ZeroArgFP,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002656 [(set RFP:$dst, (extloadf64f32 addr:$src))]>;
Chris Lattner58fe4592005-12-21 07:47:04 +00002657def FpLD64m : FpI<(ops RFP:$dst, f64mem:$src), ZeroArgFP,
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002658 [(set RFP:$dst, (loadf64 addr:$src))]>;
Chris Lattner58fe4592005-12-21 07:47:04 +00002659def FpILD16m : FpI<(ops RFP:$dst, i16mem:$src), ZeroArgFP,
2660 []>;
2661def FpILD32m : FpI<(ops RFP:$dst, i32mem:$src), ZeroArgFP,
2662 []>;
2663def FpILD64m : FpI<(ops RFP:$dst, i64mem:$src), ZeroArgFP,
2664 []>;
Evan Chengb077b842005-12-21 02:39:21 +00002665
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002666// Required for RET of f32 / f64 values.
2667def : Pat<(X86fld addr:$src, f32), (FpLD32m addr:$src)>;
2668def : Pat<(X86fld addr:$src, f64), (FpLD64m addr:$src)>;
2669
2670def FpST32m : FpI<(ops f32mem:$op, RFP:$src), OneArgFP,
2671 [(truncstore RFP:$src, addr:$op, f32)]>;
2672def FpST64m : FpI<(ops f64mem:$op, RFP:$src), OneArgFP,
2673 [(store RFP:$src, addr:$op)]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +00002674
2675def : Pat<(X86fst RFP:$src, addr:$op, f32), (FpST32m addr:$op, RFP:$src)>;
2676def : Pat<(X86fst RFP:$src, addr:$op, f64), (FpST64m addr:$op, RFP:$src)>;
2677
Chris Lattner58fe4592005-12-21 07:47:04 +00002678def FpSTP32m : FpI<(ops f32mem:$op, RFP:$src), OneArgFP, []>;
2679def FpSTP64m : FpI<(ops f64mem:$op, RFP:$src), OneArgFP, []>;
2680def FpIST16m : FpI<(ops i16mem:$op, RFP:$src), OneArgFP, []>;
2681def FpIST32m : FpI<(ops i32mem:$op, RFP:$src), OneArgFP, []>;
2682def FpIST64m : FpI<(ops i64mem:$op, RFP:$src), OneArgFP, []>;
Alkis Evlogimenos978f6292004-09-08 16:54:54 +00002683
Chris Lattner58fe4592005-12-21 07:47:04 +00002684def FLD32m : FPI<0xD9, MRM0m, (ops f32mem:$src), "fld{s} $src">;
2685def FLD64m : FPI<0xDD, MRM0m, (ops f64mem:$src), "fld{l} $src">;
2686def FILD16m : FPI<0xDF, MRM0m, (ops i16mem:$src), "fild{s} $src">;
2687def FILD32m : FPI<0xDB, MRM0m, (ops i32mem:$src), "fild{l} $src">;
2688def FILD64m : FPI<0xDF, MRM5m, (ops i64mem:$src), "fild{ll} $src">;
2689def FST32m : FPI<0xD9, MRM2m, (ops f32mem:$dst), "fst{s} $dst">;
2690def FST64m : FPI<0xDD, MRM2m, (ops f64mem:$dst), "fst{l} $dst">;
2691def FSTP32m : FPI<0xD9, MRM3m, (ops f32mem:$dst), "fstp{s} $dst">;
2692def FSTP64m : FPI<0xDD, MRM3m, (ops f64mem:$dst), "fstp{l} $dst">;
2693def FIST16m : FPI<0xDF, MRM2m, (ops i16mem:$dst), "fist{s} $dst">;
2694def FIST32m : FPI<0xDB, MRM2m, (ops i32mem:$dst), "fist{l} $dst">;
2695def FISTP16m : FPI<0xDF, MRM3m, (ops i16mem:$dst), "fistp{s} $dst">;
2696def FISTP32m : FPI<0xDB, MRM3m, (ops i32mem:$dst), "fistp{l} $dst">;
2697def FISTP64m : FPI<0xDF, MRM7m, (ops i64mem:$dst), "fistp{ll} $dst">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002698
Chris Lattner58fe4592005-12-21 07:47:04 +00002699// FP Stack manipulation instructions.
2700def FLDrr : FPI<0xC0, AddRegFrm, (ops RST:$op), "fld $op">, D9;
2701def FSTrr : FPI<0xD0, AddRegFrm, (ops RST:$op), "fst $op">, DD;
2702def FSTPrr : FPI<0xD8, AddRegFrm, (ops RST:$op), "fstp $op">, DD;
2703def FXCH : FPI<0xC8, AddRegFrm, (ops RST:$op), "fxch $op">, D9;
Chris Lattner490e86f2004-04-11 20:24:15 +00002704
Chris Lattner58fe4592005-12-21 07:47:04 +00002705// Floating point constant loads.
Evan Cheng650d6882006-01-05 02:08:37 +00002706def FpLD0 : FpI<(ops RFP:$dst), ZeroArgFP,
2707 [(set RFP:$dst, fp64imm0)]>;
2708def FpLD1 : FpI<(ops RFP:$dst), ZeroArgFP,
2709 [(set RFP:$dst, fp64imm1)]>;
2710
2711def : Pat<(f64 fp64immneg0), (FpCHS (FpLD0))>, Requires<[FPStack]>;
2712def : Pat<(f64 fp64immneg1), (FpCHS (FpLD1))>, Requires<[FPStack]>;
Chris Lattner490e86f2004-04-11 20:24:15 +00002713
Chris Lattner58fe4592005-12-21 07:47:04 +00002714def FLD0 : FPI<0xEE, RawFrm, (ops), "fldz">, D9;
2715def FLD1 : FPI<0xE8, RawFrm, (ops), "fld1">, D9;
Chris Lattner490e86f2004-04-11 20:24:15 +00002716
Chris Lattner1c54a852004-03-31 22:02:13 +00002717
Chris Lattner58fe4592005-12-21 07:47:04 +00002718// Floating point compares.
Evan Chengd9558e02006-01-06 00:43:03 +00002719def FpUCOMr : FpI<(ops RFP:$lhs, RFP:$rhs), CompareFP,
Chris Lattner58fe4592005-12-21 07:47:04 +00002720 []>; // FPSW = cmp ST(0) with ST(i)
Evan Chengd9558e02006-01-06 00:43:03 +00002721def FpUCOMIr : FpI<(ops RFP:$lhs, RFP:$rhs), CompareFP,
2722 [(set STATUS, (X86cmp RFP:$lhs, RFP:$rhs))]>,
2723 Imp<[],[STATUS]>; // CC = cmp ST(0) with ST(i)
Chris Lattner1cca5e32003-08-03 21:54:21 +00002724
Chris Lattner58fe4592005-12-21 07:47:04 +00002725def FUCOMr : FPI<0xE0, AddRegFrm, // FPSW = cmp ST(0) with ST(i)
2726 (ops RST:$reg),
2727 "fucom $reg">, DD, Imp<[ST0],[]>;
2728def FUCOMPr : FPI<0xE8, AddRegFrm, // FPSW = cmp ST(0) with ST(i), pop
2729 (ops RST:$reg),
2730 "fucomp $reg">, DD, Imp<[ST0],[]>;
2731def FUCOMPPr : FPI<0xE9, RawFrm, // cmp ST(0) with ST(1), pop, pop
2732 (ops),
2733 "fucompp">, DA, Imp<[ST0],[]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002734
Chris Lattner58fe4592005-12-21 07:47:04 +00002735def FUCOMIr : FPI<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i)
2736 (ops RST:$reg),
2737 "fucomi {$reg, %ST(0)|%ST(0), $reg}">, DB, Imp<[ST0],[]>;
2738def FUCOMIPr : FPI<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i), pop
2739 (ops RST:$reg),
2740 "fucomip {$reg, %ST(0)|%ST(0), $reg}">, DF, Imp<[ST0],[]>;
Chris Lattner0e967d42004-08-01 08:13:11 +00002741
Chris Lattnera1b5e162004-04-12 01:38:55 +00002742
Chris Lattner58fe4592005-12-21 07:47:04 +00002743// Floating point flag ops.
Chris Lattner3a173df2004-10-03 20:35:00 +00002744def FNSTSW8r : I<0xE0, RawFrm, // AX = fp flags
Evan Chengf0701842005-11-29 19:38:52 +00002745 (ops), "fnstsw", []>, DF, Imp<[],[AX]>;
Chris Lattner96563df2004-08-01 06:01:00 +00002746
Chris Lattner3a173df2004-10-03 20:35:00 +00002747def FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world
Evan Chengf0701842005-11-29 19:38:52 +00002748 (ops i16mem:$dst), "fnstcw $dst", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002749def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
Evan Chengf0701842005-11-29 19:38:52 +00002750 (ops i16mem:$dst), "fldcw $dst", []>;
Evan Cheng38bcbaf2005-12-23 07:31:11 +00002751
2752
2753//===----------------------------------------------------------------------===//
2754// Miscellaneous Instructions
2755//===----------------------------------------------------------------------===//
2756
2757def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", []>, TB, Imp<[],[EAX,EDX]>;
Evan Chengcfa260b2006-01-06 02:31:59 +00002758
2759
2760//===----------------------------------------------------------------------===//
2761// Some peepholes
2762//===----------------------------------------------------------------------===//
2763
2764// (shl x, 1) ==> (add x, x)
2765def : Pat<(shl R8 :$src1, (i8 1)), (ADD8rr R8 :$src1, R8 :$src1)>;
2766def : Pat<(shl R16:$src1, (i8 1)), (ADD16rr R16:$src1, R16:$src1)>;
2767def : Pat<(shl R32:$src1, (i8 1)), (ADD32rr R32:$src1, R32:$src1)>;