blob: f7a5af20f9994537461dcaaec5a08123a9c468ed [file] [log] [blame]
Chris Lattner1cca5e32003-08-03 21:54:21 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00009//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
Evan Chengaed7c722005-12-17 01:24:02 +000016//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
Evan Chenge3413162006-01-09 18:33:28 +000020def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
Evan Cheng71fb9ad2006-01-26 00:29:36 +000024def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000025
Evan Cheng71fb9ad2006-01-26 00:29:36 +000026def SDTX86Cmov : SDTypeProfile<1, 3,
Evan Chengaed7c722005-12-17 01:24:02 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000028 SDTCisVT<3, i8>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000029
Evan Cheng71fb9ad2006-01-26 00:29:36 +000030def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000032
Evan Cheng71fb9ad2006-01-26 00:29:36 +000033def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000035
Evan Chengd9558e02006-01-06 00:43:03 +000036def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000037
Evan Chenge3413162006-01-09 18:33:28 +000038def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
40 SDTCisVT<1, i32> ]>;
41
Evan Cheng25ab6902006-09-08 06:48:29 +000042def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000043
Evan Cheng67f92a72006-01-11 22:15:48 +000044def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
45
Evan Chenge3413162006-01-09 18:33:28 +000046def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000047
Evan Cheng71fb8342006-02-25 10:02:21 +000048def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
49
Evan Chenge3413162006-01-09 18:33:28 +000050def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
51def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000052
Evan Cheng71fb9ad2006-01-26 00:29:36 +000053def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
Evan Cheng734503b2006-09-11 02:19:56 +000054 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000055
Evan Chenge3413162006-01-09 18:33:28 +000056def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000057 [SDNPInFlag, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000058def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000059 [SDNPHasChain, SDNPInFlag]>;
Evan Cheng5ee4ccc2006-01-12 08:27:59 +000060def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000061 [SDNPInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000062
Evan Chenge3413162006-01-09 18:33:28 +000063def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
64 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000065
Evan Chenge3413162006-01-09 18:33:28 +000066def X86callseq_start :
67 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +000068 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000069def X86callseq_end :
70 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Chris Lattneraf63bb02006-01-24 05:17:12 +000071 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000072
Evan Chenge3413162006-01-09 18:33:28 +000073def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
74 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +000075
Evan Chengfb914c42006-05-20 01:40:16 +000076def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
Evan Chengfea89c12006-04-27 08:40:39 +000077 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
78
Evan Cheng67f92a72006-01-11 22:15:48 +000079def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Evan Cheng99256422006-03-07 23:34:23 +000080 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Cheng67f92a72006-01-11 22:15:48 +000081def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Evan Cheng99256422006-03-07 23:34:23 +000082 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Cheng67f92a72006-01-11 22:15:48 +000083
Evan Chenge3413162006-01-09 18:33:28 +000084def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
85 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000086
Evan Cheng71fb8342006-02-25 10:02:21 +000087def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
88
Evan Chengaed7c722005-12-17 01:24:02 +000089//===----------------------------------------------------------------------===//
90// X86 Operand Definitions.
91//
92
Chris Lattner66fa1dc2004-08-11 02:25:00 +000093// *mem - Operand definitions for the funky X86 addressing mode operands.
94//
Evan Chengaf78ef52006-05-17 21:21:41 +000095class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +000096 let PrintMethod = printMethod;
Chris Lattner6adaf792005-11-19 07:01:30 +000097 let NumMIOperands = 4;
Evan Cheng25ab6902006-09-08 06:48:29 +000098 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +000099}
Nate Begeman391c5d22005-11-30 18:54:35 +0000100
Chris Lattner45432512005-12-17 19:47:05 +0000101def i8mem : X86MemOperand<"printi8mem">;
102def i16mem : X86MemOperand<"printi16mem">;
103def i32mem : X86MemOperand<"printi32mem">;
104def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000105def i128mem : X86MemOperand<"printi128mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000106def f32mem : X86MemOperand<"printf32mem">;
107def f64mem : X86MemOperand<"printf64mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000108def f128mem : X86MemOperand<"printf128mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000109
Evan Cheng25ab6902006-09-08 06:48:29 +0000110def lea32mem : Operand<i32> {
111 let PrintMethod = "printi32mem";
112 let NumMIOperands = 4;
113 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
114}
115
Nate Begeman16b04f32005-07-15 00:38:55 +0000116def SSECC : Operand<i8> {
117 let PrintMethod = "printSSECC";
118}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000119
Evan Cheng7ccced62006-02-18 00:15:05 +0000120def piclabel: Operand<i32> {
121 let PrintMethod = "printPICLabel";
122}
123
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000124// A couple of more descriptive operand definitions.
125// 16-bits but only 8 bits are significant.
126def i16i8imm : Operand<i16>;
127// 32-bits but only 8 bits are significant.
128def i32i8imm : Operand<i32>;
129
Evan Chengd35b8c12005-12-04 08:19:43 +0000130// Branch targets have OtherVT type.
131def brtarget : Operand<OtherVT>;
132
Evan Chengaed7c722005-12-17 01:24:02 +0000133//===----------------------------------------------------------------------===//
134// X86 Complex Pattern Definitions.
135//
136
Evan Chengec693f72005-12-08 02:01:35 +0000137// Define X86 specific addressing mode.
Evan Chengaf9db752006-10-11 21:03:53 +0000138def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000139def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Evan Chengaf9db752006-10-11 21:03:53 +0000140 [add, mul, shl, or, frameindex], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000141
Evan Chengaed7c722005-12-17 01:24:02 +0000142//===----------------------------------------------------------------------===//
143// X86 Instruction Format Definitions.
144//
145
Chris Lattner1cca5e32003-08-03 21:54:21 +0000146// Format specifies the encoding used by the instruction. This is part of the
147// ad-hoc solution used to emit machine instruction encodings by our machine
148// code emitter.
Evan Cheng3c55c542006-02-01 06:13:50 +0000149class Format<bits<6> val> {
150 bits<6> Value = val;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000151}
152
153def Pseudo : Format<0>; def RawFrm : Format<1>;
154def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
155def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
156def MRMSrcMem : Format<6>;
Alkis Evlogimenos169584e2004-02-27 18:55:12 +0000157def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
158def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
159def MRM6r : Format<22>; def MRM7r : Format<23>;
160def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
161def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
162def MRM6m : Format<30>; def MRM7m : Format<31>;
Evan Cheng3c55c542006-02-01 06:13:50 +0000163def MRMInitReg : Format<32>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000164
Evan Chengaed7c722005-12-17 01:24:02 +0000165//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000166// X86 Instruction Predicate Definitions.
Evan Cheng25ab6902006-09-08 06:48:29 +0000167def HasMMX : Predicate<"Subtarget->hasMMX()">;
168def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
169def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
170def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
171def FPStack : Predicate<"!Subtarget->hasSSE2()">;
172def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
173def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000174
175//===----------------------------------------------------------------------===//
Evan Chengaed7c722005-12-17 01:24:02 +0000176// X86 specific pattern fragments.
177//
178
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000179// ImmType - This specifies the immediate type used by an instruction. This is
Chris Lattner1cca5e32003-08-03 21:54:21 +0000180// part of the ad-hoc solution used to emit machine instruction encodings by our
181// machine code emitter.
Evan Cheng25ab6902006-09-08 06:48:29 +0000182class ImmType<bits<3> val> {
183 bits<3> Value = val;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000184}
185def NoImm : ImmType<0>;
186def Imm8 : ImmType<1>;
187def Imm16 : ImmType<2>;
188def Imm32 : ImmType<3>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000189def Imm64 : ImmType<4>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000190
Chris Lattner1cca5e32003-08-03 21:54:21 +0000191// FPFormat - This specifies what form this FP instruction has. This is used by
192// the Floating-Point stackifier pass.
193class FPFormat<bits<3> val> {
194 bits<3> Value = val;
195}
196def NotFP : FPFormat<0>;
197def ZeroArgFP : FPFormat<1>;
198def OneArgFP : FPFormat<2>;
199def OneArgFPRW : FPFormat<3>;
200def TwoArgFP : FPFormat<4>;
Chris Lattnerab8decc2004-06-11 04:41:24 +0000201def CompareFP : FPFormat<5>;
202def CondMovFP : FPFormat<6>;
203def SpecialFP : FPFormat<7>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000204
205
Chris Lattner3a173df2004-10-03 20:35:00 +0000206class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
207 : Instruction {
Chris Lattnerc8f45872003-08-04 04:59:56 +0000208 let Namespace = "X86";
Chris Lattner1cca5e32003-08-03 21:54:21 +0000209
Chris Lattner1cca5e32003-08-03 21:54:21 +0000210 bits<8> Opcode = opcod;
211 Format Form = f;
Evan Cheng3c55c542006-02-01 06:13:50 +0000212 bits<6> FormBits = Form.Value;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000213 ImmType ImmT = i;
Evan Cheng25ab6902006-09-08 06:48:29 +0000214 bits<3> ImmTypeBits = ImmT.Value;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000215
Chris Lattnerc96bb812004-08-11 07:12:04 +0000216 dag OperandList = ops;
217 string AsmString = AsmStr;
218
John Criswell4ffff9e2004-04-08 20:31:47 +0000219 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000220 // Attributes specific to X86 instructions...
John Criswell4ffff9e2004-04-08 20:31:47 +0000221 //
Evan Cheng25ab6902006-09-08 06:48:29 +0000222 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
223 bit hasAdSizePrefix = 0; // Does this inst have a 0x67 prefix?
John Criswell4ffff9e2004-04-08 20:31:47 +0000224
Chris Lattner1cca5e32003-08-03 21:54:21 +0000225 bits<4> Prefix = 0; // Which prefix byte does this inst have?
Evan Cheng25ab6902006-09-08 06:48:29 +0000226 bit hasREX_WPrefix = 0; // Does this inst requires the REX.W prefix?
Chris Lattner1cca5e32003-08-03 21:54:21 +0000227 FPFormat FPForm; // What flavor of FP instruction is this?
228 bits<3> FPFormBits = 0;
229}
230
231class Imp<list<Register> uses, list<Register> defs> {
232 list<Register> Uses = uses;
233 list<Register> Defs = defs;
234}
235
236
237// Prefix byte classes which are used to indicate to the ad-hoc machine code
238// emitter that various prefix bytes are required.
239class OpSize { bit hasOpSizePrefix = 1; }
Evan Cheng25ab6902006-09-08 06:48:29 +0000240class AdSize { bit hasAdSizePrefix = 1; }
241class REX_W { bit hasREX_WPrefix = 1; }
Chris Lattner1cca5e32003-08-03 21:54:21 +0000242class TB { bits<4> Prefix = 1; }
Chris Lattner915e5e52004-02-12 17:53:22 +0000243class REP { bits<4> Prefix = 2; }
244class D8 { bits<4> Prefix = 3; }
245class D9 { bits<4> Prefix = 4; }
246class DA { bits<4> Prefix = 5; }
247class DB { bits<4> Prefix = 6; }
248class DC { bits<4> Prefix = 7; }
249class DD { bits<4> Prefix = 8; }
250class DE { bits<4> Prefix = 9; }
251class DF { bits<4> Prefix = 10; }
Nate Begemanf1702ac2005-06-27 21:20:31 +0000252class XD { bits<4> Prefix = 11; }
253class XS { bits<4> Prefix = 12; }
Chris Lattner1cca5e32003-08-03 21:54:21 +0000254
255
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000256//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000257// Pattern fragments...
258//
Evan Chengd9558e02006-01-06 00:43:03 +0000259
260// X86 specific condition code. These correspond to CondCode in
261// X86ISelLowering.h. They must be kept in synch.
262def X86_COND_A : PatLeaf<(i8 0)>;
263def X86_COND_AE : PatLeaf<(i8 1)>;
264def X86_COND_B : PatLeaf<(i8 2)>;
265def X86_COND_BE : PatLeaf<(i8 3)>;
266def X86_COND_E : PatLeaf<(i8 4)>;
267def X86_COND_G : PatLeaf<(i8 5)>;
268def X86_COND_GE : PatLeaf<(i8 6)>;
269def X86_COND_L : PatLeaf<(i8 7)>;
270def X86_COND_LE : PatLeaf<(i8 8)>;
271def X86_COND_NE : PatLeaf<(i8 9)>;
272def X86_COND_NO : PatLeaf<(i8 10)>;
273def X86_COND_NP : PatLeaf<(i8 11)>;
274def X86_COND_NS : PatLeaf<(i8 12)>;
275def X86_COND_O : PatLeaf<(i8 13)>;
276def X86_COND_P : PatLeaf<(i8 14)>;
277def X86_COND_S : PatLeaf<(i8 15)>;
278
Evan Cheng9b6b6422005-12-13 00:14:11 +0000279def i16immSExt8 : PatLeaf<(i16 imm), [{
280 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000281 // sign extended field.
Evan Cheng09e3c802006-05-19 18:40:54 +0000282 return (int16_t)N->getValue() == (int8_t)N->getValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000283}]>;
284
Evan Cheng9b6b6422005-12-13 00:14:11 +0000285def i32immSExt8 : PatLeaf<(i32 imm), [{
286 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000287 // sign extended field.
Evan Cheng09e3c802006-05-19 18:40:54 +0000288 return (int32_t)N->getValue() == (int8_t)N->getValue();
Evan Chengb3558542005-12-13 00:01:09 +0000289}]>;
290
Evan Cheng605c4152005-12-13 01:57:51 +0000291// Helper fragments for loads.
Evan Cheng7a7e8372005-12-14 02:22:27 +0000292def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
293def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
294def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
Evan Cheng11e15b32006-04-03 20:53:28 +0000295def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000296
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000297def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
298def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000299
Evan Cheng466685d2006-10-09 20:57:25 +0000300def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
301def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
302def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
303def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
304def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000305
Evan Cheng466685d2006-10-09 20:57:25 +0000306def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
307def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
308def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
309def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
310def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
311def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000312
Evan Cheng466685d2006-10-09 20:57:25 +0000313def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
314def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
315def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
316def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
317def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
318def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000319
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000320//===----------------------------------------------------------------------===//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000321// Instruction templates...
Evan Cheng25ab6902006-09-08 06:48:29 +0000322//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000323
Evan Chengf0701842005-11-29 19:38:52 +0000324class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
325 : X86Inst<o, f, NoImm, ops, asm> {
326 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000327 let CodeSize = 3;
Evan Chengf0701842005-11-29 19:38:52 +0000328}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000329class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
330 : X86Inst<o, f, Imm8 , ops, asm> {
331 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000332 let CodeSize = 3;
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000333}
Chris Lattner78432fe2005-11-17 02:01:55 +0000334class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
335 : X86Inst<o, f, Imm16, ops, asm> {
336 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000337 let CodeSize = 3;
Chris Lattner78432fe2005-11-17 02:01:55 +0000338}
Chris Lattner7a125372005-11-16 22:59:19 +0000339class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
340 : X86Inst<o, f, Imm32, ops, asm> {
341 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000342 let CodeSize = 3;
Chris Lattner7a125372005-11-16 22:59:19 +0000343}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000344
Chris Lattner1cca5e32003-08-03 21:54:21 +0000345//===----------------------------------------------------------------------===//
346// Instruction list...
347//
348
Chris Lattnerf18c0742006-10-12 17:42:56 +0000349// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
350// a stack adjustment and the codegen must know that they may modify the stack
351// pointer before prolog-epilog rewriting occurs.
Evan Chengd90eb7f2006-01-05 00:27:02 +0000352def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
Chris Lattnerf18c0742006-10-12 17:42:56 +0000353 [(X86callseq_start imm:$amt)]>, Imp<[ESP],[ESP]>;
Chris Lattner43ef1312005-09-14 21:10:24 +0000354def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
Evan Chengd90eb7f2006-01-05 00:27:02 +0000355 "#ADJCALLSTACKUP",
Chris Lattnerf18c0742006-10-12 17:42:56 +0000356 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
357 Imp<[ESP],[ESP]>;
Evan Chengf0701842005-11-29 19:38:52 +0000358def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
359def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000360def IMPLICIT_DEF_GR8 : I<0, Pseudo, (ops GR8:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000361 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000362 [(set GR8:$dst, (undef))]>;
363def IMPLICIT_DEF_GR16 : I<0, Pseudo, (ops GR16:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000364 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000365 [(set GR16:$dst, (undef))]>;
366def IMPLICIT_DEF_GR32 : I<0, Pseudo, (ops GR32:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000367 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000368 [(set GR32:$dst, (undef))]>;
Evan Cheng4a460802006-01-11 00:33:36 +0000369
370// Nop
371def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
372
Evan Cheng8f7f7122006-05-05 05:40:20 +0000373// Truncate
Evan Cheng25ab6902006-09-08 06:48:29 +0000374def TRUNC_32_to8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR32_:$src),
375 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}", []>;
376def TRUNC_16_to8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR16_:$src),
377 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}}", []>;
378def TRUNC_32to16 : I<0x89, MRMDestReg, (ops GR16:$dst, GR32:$src),
379 "mov{w} {${src:subreg16}, $dst|$dst, ${src:subreg16}}",
380 [(set GR16:$dst, (trunc GR32:$src))]>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000381
Chris Lattner1cca5e32003-08-03 21:54:21 +0000382//===----------------------------------------------------------------------===//
383// Control Flow Instructions...
384//
385
Chris Lattner1be48112005-05-13 17:56:48 +0000386// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000387let isTerminator = 1, isReturn = 1, isBarrier = 1,
388 hasCtrlDep = 1, noResults = 1 in {
Evan Chenge3413162006-01-09 18:33:28 +0000389 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
390 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
391 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000392}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000393
394// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng2b4ea792005-12-26 09:11:45 +0000395let isBranch = 1, isTerminator = 1, noResults = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000396 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
397 I<opcode, RawFrm, ops, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000398
Nate Begeman37efe672006-04-22 18:53:45 +0000399// Indirect branches
Evan Chengec3bc392006-09-07 19:03:48 +0000400let isBranch = 1, isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000401 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000402
Nate Begeman37efe672006-04-22 18:53:45 +0000403let isBranch = 1, isTerminator = 1, noResults = 1, isBarrier = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000404 def JMP32r : I<0xFF, MRM4r, (ops GR32:$dst), "jmp{l} {*}$dst",
405 [(brind GR32:$dst)]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000406 def JMP32m : I<0xFF, MRM4m, (ops i32mem:$dst), "jmp{l} {*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000407 [(brind (loadi32 addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000408}
409
410// Conditional branches
Evan Cheng898101c2005-12-19 23:12:38 +0000411def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000412 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000413def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000414 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000415def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000416 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000417def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000418 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000419def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000420 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000421def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000422 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000423
Evan Chengd35b8c12005-12-04 08:19:43 +0000424def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000425 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000426def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000427 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000428def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000429 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000430def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000431 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000432
Evan Chengd9558e02006-01-06 00:43:03 +0000433def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000434 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000435def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000436 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000437def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000438 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000439def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000440 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000441def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000442 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000443def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000444 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000445
446//===----------------------------------------------------------------------===//
447// Call Instructions...
448//
Evan Chenge3413162006-01-09 18:33:28 +0000449let isCall = 1, noResults = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000450 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000451 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Nate Begeman16b04f32005-07-15 00:38:55 +0000452 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengfae29942006-06-14 22:24:55 +0000453 def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst, variable_ops),
454 "call ${dst:call}", []>;
455 def CALL32r : I<0xFF, MRM2r, (ops GR32:$dst, variable_ops),
456 "call {*}$dst", [(X86call GR32:$dst)]>;
457 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst, variable_ops),
458 "call {*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000459 }
460
Chris Lattner1e9448b2005-05-15 03:10:37 +0000461// Tail call stuff.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000462let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf10c17f2006-09-22 21:43:59 +0000463 def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call} # TAIL CALL",
464 []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000465let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf10c17f2006-09-22 21:43:59 +0000466 def TAILJMPr : I<0xFF, MRM4r, (ops GR32:$dst), "jmp {*}$dst # TAIL CALL",
467 []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000468let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000469 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
470 "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000471
Chris Lattner1cca5e32003-08-03 21:54:21 +0000472//===----------------------------------------------------------------------===//
473// Miscellaneous Instructions...
474//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000475def LEAVE : I<0xC9, RawFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000476 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000477def POP32r : I<0x58, AddRegFrm,
Evan Cheng069287d2006-05-16 07:21:53 +0000478 (ops GR32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000479
Evan Cheng7ccced62006-02-18 00:15:05 +0000480def MovePCtoStack : I<0, Pseudo, (ops piclabel:$label),
481 "call $label", []>;
482
Evan Cheng069287d2006-05-16 07:21:53 +0000483let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000484 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng069287d2006-05-16 07:21:53 +0000485 (ops GR32:$dst, GR32:$src),
Nate Begemand88fc032006-01-14 03:14:10 +0000486 "bswap{l} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000487 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000488
Evan Cheng069287d2006-05-16 07:21:53 +0000489def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
490 (ops GR8:$src1, GR8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000491 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000492def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
493 (ops GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000494 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000495def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
496 (ops GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000497 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattnerfc752712004-08-01 09:52:59 +0000498
Chris Lattner3a173df2004-10-03 20:35:00 +0000499def XCHG8mr : I<0x86, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000500 (ops i8mem:$src1, GR8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000501 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000502def XCHG16mr : I<0x87, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000503 (ops i16mem:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000504 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000505def XCHG32mr : I<0x87, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000506 (ops i32mem:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000507 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000508def XCHG8rm : I<0x86, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000509 (ops GR8:$src1, i8mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000510 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000511def XCHG16rm : I<0x87, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000512 (ops GR16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000513 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000514def XCHG32rm : I<0x87, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000515 (ops GR32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000516 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000517
Chris Lattner3a173df2004-10-03 20:35:00 +0000518def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000519 (ops GR16:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000520 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000521def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng25ab6902006-09-08 06:48:29 +0000522 (ops GR32:$dst, lea32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000523 "lea{l} {$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000524 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000525
Evan Cheng67f92a72006-01-11 22:15:48 +0000526def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
527 [(X86rep_movs i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000528 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000529def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
530 [(X86rep_movs i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000531 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Cheng94b14532006-06-02 21:09:10 +0000532def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsl|rep movsd}",
Evan Cheng67f92a72006-01-11 22:15:48 +0000533 [(X86rep_movs i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000534 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Chris Lattner915e5e52004-02-12 17:53:22 +0000535
Evan Cheng67f92a72006-01-11 22:15:48 +0000536def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
537 [(X86rep_stos i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000538 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000539def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
540 [(X86rep_stos i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000541 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Cheng67f92a72006-01-11 22:15:48 +0000542def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
543 [(X86rep_stos i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000544 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
545
Chris Lattnerb89abef2004-02-14 04:45:37 +0000546
Chris Lattner1cca5e32003-08-03 21:54:21 +0000547//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000548// Input/Output Instructions...
549//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000550def IN8rr : I<0xEC, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000551 "in{b} {%dx, %al|%AL, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000552 []>, Imp<[DX], [AL]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000553def IN16rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000554 "in{w} {%dx, %ax|%AX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000555 []>, Imp<[DX], [AX]>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000556def IN32rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000557 "in{l} {%dx, %eax|%EAX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000558 []>, Imp<[DX],[EAX]>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000559
Evan Chenga5386b02005-12-20 07:38:38 +0000560def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
561 "in{b} {$port, %al|%AL, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000562 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000563 Imp<[], [AL]>;
564def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
565 "in{w} {$port, %ax|%AX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000566 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000567 Imp<[], [AX]>, OpSize;
568def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
569 "in{l} {$port, %eax|%EAX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000570 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000571 Imp<[],[EAX]>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000572
Evan Cheng8d202232005-12-05 23:09:43 +0000573def OUT8rr : I<0xEE, RawFrm, (ops),
574 "out{b} {%al, %dx|%DX, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000575 []>, Imp<[DX, AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000576def OUT16rr : I<0xEF, RawFrm, (ops),
577 "out{w} {%ax, %dx|%DX, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000578 []>, Imp<[DX, AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000579def OUT32rr : I<0xEF, RawFrm, (ops),
580 "out{l} {%eax, %dx|%DX, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000581 []>, Imp<[DX, EAX], []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000582
Evan Cheng8d202232005-12-05 23:09:43 +0000583def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
584 "out{b} {%al, $port|$port, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000585 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000586 Imp<[AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000587def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
588 "out{w} {%ax, $port|$port, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000589 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000590 Imp<[AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000591def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
592 "out{l} {%eax, $port|$port, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000593 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000594 Imp<[EAX], []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000595
596//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000597// Move Instructions...
598//
Evan Cheng069287d2006-05-16 07:21:53 +0000599def MOV8rr : I<0x88, MRMDestReg, (ops GR8 :$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000600 "mov{b} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000601def MOV16rr : I<0x89, MRMDestReg, (ops GR16:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000602 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000603def MOV32rr : I<0x89, MRMDestReg, (ops GR32:$dst, GR32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000604 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000605def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops GR8 :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000606 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000607 [(set GR8:$dst, imm:$src)]>;
608def MOV16ri : Ii16<0xB8, AddRegFrm, (ops GR16:$dst, i16imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000609 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000610 [(set GR16:$dst, imm:$src)]>, OpSize;
611def MOV32ri : Ii32<0xB8, AddRegFrm, (ops GR32:$dst, i32imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000612 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000613 [(set GR32:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000614def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000615 "mov{b} {$src, $dst|$dst, $src}",
616 [(store (i8 imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000617def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000618 "mov{w} {$src, $dst|$dst, $src}",
619 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000620def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000621 "mov{l} {$src, $dst|$dst, $src}",
622 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000623
Evan Cheng069287d2006-05-16 07:21:53 +0000624def MOV8rm : I<0x8A, MRMSrcMem, (ops GR8 :$dst, i8mem :$src),
Evan Chengec693f72005-12-08 02:01:35 +0000625 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000626 [(set GR8:$dst, (load addr:$src))]>;
627def MOV16rm : I<0x8B, MRMSrcMem, (ops GR16:$dst, i16mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000628 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000629 [(set GR16:$dst, (load addr:$src))]>, OpSize;
630def MOV32rm : I<0x8B, MRMSrcMem, (ops GR32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000631 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000632 [(set GR32:$dst, (load addr:$src))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000633
Evan Cheng069287d2006-05-16 07:21:53 +0000634def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, GR8 :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000635 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000636 [(store GR8:$src, addr:$dst)]>;
637def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000638 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000639 [(store GR16:$src, addr:$dst)]>, OpSize;
640def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000641 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000642 [(store GR32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000643
Chris Lattner1cca5e32003-08-03 21:54:21 +0000644//===----------------------------------------------------------------------===//
645// Fixed-Register Multiplication and Division Instructions...
646//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000647
Chris Lattnerc8f45872003-08-04 04:59:56 +0000648// Extra precision multiplication
Evan Cheng069287d2006-05-16 07:21:53 +0000649def MUL8r : I<0xF6, MRM4r, (ops GR8:$src), "mul{b} $src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000650 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
651 // This probably ought to be moved to a def : Pat<> if the
652 // syntax can be accepted.
Evan Cheng069287d2006-05-16 07:21:53 +0000653 [(set AL, (mul AL, GR8:$src))]>,
654 Imp<[AL],[AX]>; // AL,AH = AL*GR8
655def MUL16r : I<0xF7, MRM4r, (ops GR16:$src), "mul{w} $src", []>,
656 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
657def MUL32r : I<0xF7, MRM4r, (ops GR32:$src), "mul{l} $src", []>,
658 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Chris Lattner57a02302004-08-11 04:31:00 +0000659def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
Evan Chengcf74a7c2006-01-15 10:05:20 +0000660 "mul{b} $src",
661 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
662 // This probably ought to be moved to a def : Pat<> if the
663 // syntax can be accepted.
664 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
665 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner57a02302004-08-11 04:31:00 +0000666def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000667 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
668 OpSize; // AX,DX = AX*[mem16]
Chris Lattner57a02302004-08-11 04:31:00 +0000669def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000670 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000671
Evan Cheng069287d2006-05-16 07:21:53 +0000672def IMUL8r : I<0xF6, MRM5r, (ops GR8:$src), "imul{b} $src", []>,
673 Imp<[AL],[AX]>; // AL,AH = AL*GR8
674def IMUL16r : I<0xF7, MRM5r, (ops GR16:$src), "imul{w} $src", []>,
675 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
676def IMUL32r : I<0xF7, MRM5r, (ops GR32:$src), "imul{l} $src", []>,
677 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Chris Lattner1e6a7152005-04-06 04:19:22 +0000678def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000679 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000680def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000681 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
682 OpSize; // AX,DX = AX*[mem16]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000683def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000684 "imul{l} $src", []>,
685 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000686
Chris Lattnerc8f45872003-08-04 04:59:56 +0000687// unsigned division/remainder
Evan Cheng069287d2006-05-16 07:21:53 +0000688def DIV8r : I<0xF6, MRM6r, (ops GR8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000689 "div{b} $src", []>, Imp<[AX],[AX]>;
Evan Cheng069287d2006-05-16 07:21:53 +0000690def DIV16r : I<0xF7, MRM6r, (ops GR16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000691 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000692def DIV32r : I<0xF7, MRM6r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000693 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000694def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000695 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000696def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000697 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000698def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000699 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000700
Chris Lattnerfc752712004-08-01 09:52:59 +0000701// Signed division/remainder.
Evan Cheng069287d2006-05-16 07:21:53 +0000702def IDIV8r : I<0xF6, MRM7r, (ops GR8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000703 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Evan Cheng069287d2006-05-16 07:21:53 +0000704def IDIV16r: I<0xF7, MRM7r, (ops GR16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000705 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000706def IDIV32r: I<0xF7, MRM7r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000707 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000708def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000709 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000710def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000711 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000712def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000713 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattnerc8f45872003-08-04 04:59:56 +0000714
Chris Lattner1cca5e32003-08-03 21:54:21 +0000715
Chris Lattner1cca5e32003-08-03 21:54:21 +0000716//===----------------------------------------------------------------------===//
717// Two address Instructions...
718//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000719let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000720
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000721// Conditional moves
Evan Cheng069287d2006-05-16 07:21:53 +0000722def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
723 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000724 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000725 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000726 X86_COND_B))]>,
727 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000728def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
729 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000730 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000731 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000732 X86_COND_B))]>,
733 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000734def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
735 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000736 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000737 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000738 X86_COND_B))]>,
739 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000740def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
741 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000742 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000743 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000744 X86_COND_B))]>,
745 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000746
Evan Cheng069287d2006-05-16 07:21:53 +0000747def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
748 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000749 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000750 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000751 X86_COND_AE))]>,
752 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000753def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
754 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000755 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000756 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000757 X86_COND_AE))]>,
758 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000759def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
760 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000761 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000762 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000763 X86_COND_AE))]>,
764 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000765def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
766 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000767 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000768 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000769 X86_COND_AE))]>,
770 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000771
Evan Cheng069287d2006-05-16 07:21:53 +0000772def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
773 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000774 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000775 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000776 X86_COND_E))]>,
777 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000778def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
779 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000780 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000781 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000782 X86_COND_E))]>,
783 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000784def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
785 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000786 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000787 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000788 X86_COND_E))]>,
789 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000790def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
791 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000792 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000793 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000794 X86_COND_E))]>,
795 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000796
Evan Cheng069287d2006-05-16 07:21:53 +0000797def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
798 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000799 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000800 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000801 X86_COND_NE))]>,
802 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000803def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
804 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000805 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000806 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000807 X86_COND_NE))]>,
808 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000809def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
810 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000811 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000812 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000813 X86_COND_NE))]>,
814 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000815def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
816 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000817 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000818 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000819 X86_COND_NE))]>,
820 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000821
Evan Cheng069287d2006-05-16 07:21:53 +0000822def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
823 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000824 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000825 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000826 X86_COND_BE))]>,
827 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000828def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
829 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000830 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000831 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000832 X86_COND_BE))]>,
833 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000834def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
835 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000836 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000837 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000838 X86_COND_BE))]>,
839 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000840def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
841 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000842 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000843 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000844 X86_COND_BE))]>,
845 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000846
Evan Cheng069287d2006-05-16 07:21:53 +0000847def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
848 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000849 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000850 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000851 X86_COND_A))]>,
852 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000853def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
854 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000855 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000856 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000857 X86_COND_A))]>,
858 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000859def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
860 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000861 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000862 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000863 X86_COND_A))]>,
864 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000865def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
866 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000867 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000868 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000869 X86_COND_A))]>,
870 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000871
Evan Cheng069287d2006-05-16 07:21:53 +0000872def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
873 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000874 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000875 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000876 X86_COND_L))]>,
877 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000878def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
879 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000880 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000881 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000882 X86_COND_L))]>,
883 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000884def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
885 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000886 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000887 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000888 X86_COND_L))]>,
889 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000890def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
891 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000892 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000893 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000894 X86_COND_L))]>,
895 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000896
Evan Cheng069287d2006-05-16 07:21:53 +0000897def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
898 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000899 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000900 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000901 X86_COND_GE))]>,
902 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000903def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
904 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000905 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000906 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000907 X86_COND_GE))]>,
908 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000909def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
910 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000911 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000912 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000913 X86_COND_GE))]>,
914 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000915def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
916 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000917 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000918 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000919 X86_COND_GE))]>,
920 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000921
Evan Cheng069287d2006-05-16 07:21:53 +0000922def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
923 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000924 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000925 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000926 X86_COND_LE))]>,
927 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000928def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
929 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000930 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000931 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000932 X86_COND_LE))]>,
933 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000934def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
935 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000936 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000937 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000938 X86_COND_LE))]>,
939 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000940def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
941 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000942 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000943 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000944 X86_COND_LE))]>,
945 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000946
Evan Cheng069287d2006-05-16 07:21:53 +0000947def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
948 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000949 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000950 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000951 X86_COND_G))]>,
952 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000953def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
954 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000955 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000956 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000957 X86_COND_G))]>,
958 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000959def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
960 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000961 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000962 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000963 X86_COND_G))]>,
964 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000965def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
966 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000967 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000968 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000969 X86_COND_G))]>,
970 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000971
Evan Cheng069287d2006-05-16 07:21:53 +0000972def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
973 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000974 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000975 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000976 X86_COND_S))]>,
977 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000978def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
979 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000980 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000981 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000982 X86_COND_S))]>,
983 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000984def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
985 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000986 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000987 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000988 X86_COND_S))]>,
989 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000990def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
991 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000992 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000993 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000994 X86_COND_S))]>,
995 TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000996
Evan Cheng069287d2006-05-16 07:21:53 +0000997def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
998 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000999 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001000 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001001 X86_COND_NS))]>,
1002 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001003def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1004 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001005 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001006 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001007 X86_COND_NS))]>,
1008 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001009def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1010 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001011 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001012 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001013 X86_COND_NS))]>,
1014 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001015def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1016 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001017 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001018 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001019 X86_COND_NS))]>,
1020 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001021
Evan Cheng069287d2006-05-16 07:21:53 +00001022def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1023 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001024 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001025 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001026 X86_COND_P))]>,
1027 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001028def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1029 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001030 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001031 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001032 X86_COND_P))]>,
1033 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001034def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1035 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001036 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001037 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001038 X86_COND_P))]>,
1039 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001040def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1041 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001042 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001043 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001044 X86_COND_P))]>,
1045 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001046
Evan Cheng069287d2006-05-16 07:21:53 +00001047def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1048 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001049 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001050 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001051 X86_COND_NP))]>,
1052 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001053def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1054 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001055 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001056 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001057 X86_COND_NP))]>,
1058 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001059def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1060 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001061 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001062 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001063 X86_COND_NP))]>,
1064 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001065def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1066 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001067 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001068 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001069 X86_COND_NP))]>,
1070 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001071
1072
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001073// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001074let CodeSize = 2 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001075def NEG8r : I<0xF6, MRM3r, (ops GR8 :$dst, GR8 :$src), "neg{b} $dst",
1076 [(set GR8:$dst, (ineg GR8:$src))]>;
1077def NEG16r : I<0xF7, MRM3r, (ops GR16:$dst, GR16:$src), "neg{w} $dst",
1078 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1079def NEG32r : I<0xF7, MRM3r, (ops GR32:$dst, GR32:$src), "neg{l} $dst",
1080 [(set GR32:$dst, (ineg GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001081let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001082 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001083 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001084 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001085 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001086 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001087 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1088
Chris Lattner57a02302004-08-11 04:31:00 +00001089}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001090
Evan Cheng069287d2006-05-16 07:21:53 +00001091def NOT8r : I<0xF6, MRM2r, (ops GR8 :$dst, GR8 :$src), "not{b} $dst",
1092 [(set GR8:$dst, (not GR8:$src))]>;
1093def NOT16r : I<0xF7, MRM2r, (ops GR16:$dst, GR16:$src), "not{w} $dst",
1094 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1095def NOT32r : I<0xF7, MRM2r, (ops GR32:$dst, GR32:$src), "not{l} $dst",
1096 [(set GR32:$dst, (not GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001097let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001098 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001099 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001100 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001101 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001102 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001103 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001104}
Evan Cheng1693e482006-07-19 00:27:29 +00001105} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001106
Evan Chengb51a0592005-12-10 00:48:20 +00001107// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng1693e482006-07-19 00:27:29 +00001108let CodeSize = 2 in
Evan Cheng069287d2006-05-16 07:21:53 +00001109def INC8r : I<0xFE, MRM0r, (ops GR8 :$dst, GR8 :$src), "inc{b} $dst",
1110 [(set GR8:$dst, (add GR8:$src, 1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001111let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Evan Chengf7eb5d02006-07-11 19:49:49 +00001112def INC16r : I<0x40, AddRegFrm, (ops GR16:$dst, GR16:$src), "inc{w} $dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001113 [(set GR16:$dst, (add GR16:$src, 1))]>,
1114 OpSize, Requires<[In32BitMode]>;
Evan Chengf7eb5d02006-07-11 19:49:49 +00001115def INC32r : I<0x40, AddRegFrm, (ops GR32:$dst, GR32:$src), "inc{l} $dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001116 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001117}
Evan Cheng1693e482006-07-19 00:27:29 +00001118let isTwoAddress = 0, CodeSize = 2 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001119 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001120 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001121 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001122 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001123 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001124 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001125}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001126
Evan Cheng1693e482006-07-19 00:27:29 +00001127let CodeSize = 2 in
Evan Cheng069287d2006-05-16 07:21:53 +00001128def DEC8r : I<0xFE, MRM1r, (ops GR8 :$dst, GR8 :$src), "dec{b} $dst",
1129 [(set GR8:$dst, (add GR8:$src, -1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001130let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Evan Chengf7eb5d02006-07-11 19:49:49 +00001131def DEC16r : I<0x48, AddRegFrm, (ops GR16:$dst, GR16:$src), "dec{w} $dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001132 [(set GR16:$dst, (add GR16:$src, -1))]>,
1133 OpSize, Requires<[In32BitMode]>;
Evan Chengf7eb5d02006-07-11 19:49:49 +00001134def DEC32r : I<0x48, AddRegFrm, (ops GR32:$dst, GR32:$src), "dec{l} $dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001135 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001136}
Chris Lattner57a02302004-08-11 04:31:00 +00001137
Evan Cheng1693e482006-07-19 00:27:29 +00001138let isTwoAddress = 0, CodeSize = 2 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001139 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001140 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001141 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001142 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001143 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001144 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001145}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001146
1147// Logical operators...
Chris Lattnercc65bee2005-01-02 02:35:46 +00001148let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001149def AND8rr : I<0x20, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001150 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001151 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001152 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001153def AND16rr : I<0x21, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001154 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001155 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001156 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001157def AND32rr : I<0x21, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001158 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001159 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001160 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001161}
Chris Lattner57a02302004-08-11 04:31:00 +00001162
Chris Lattner3a173df2004-10-03 20:35:00 +00001163def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001164 (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001165 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001166 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001167def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001168 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001169 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001170 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001171def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001172 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001173 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001174 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001175
Chris Lattner3a173df2004-10-03 20:35:00 +00001176def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001177 (ops GR8 :$dst, GR8 :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001178 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001179 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001180def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001181 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001182 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001183 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001184def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001185 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001186 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001187 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001188def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001189 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001190 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001191 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001192 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001193def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001194 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001195 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001196 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001197
1198let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001199 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001200 (ops i8mem :$dst, GR8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001201 "and{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001202 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001203 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001204 (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001205 "and{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001206 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001207 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001208 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001209 (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001210 "and{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001211 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001212 def AND8mi : Ii8<0x80, MRM4m,
1213 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001214 "and{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001215 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001216 def AND16mi : Ii16<0x81, MRM4m,
1217 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001218 "and{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001219 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001220 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001221 def AND32mi : Ii32<0x81, MRM4m,
1222 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001223 "and{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001224 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001225 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001226 (ops i16mem:$dst, i16i8imm :$src),
1227 "and{w} {$src, $dst|$dst, $src}",
1228 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1229 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001230 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001231 (ops i32mem:$dst, i32i8imm :$src),
1232 "and{l} {$src, $dst|$dst, $src}",
Evan Chenge3703d42006-01-14 01:18:49 +00001233 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001234}
1235
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001236
Chris Lattnercc65bee2005-01-02 02:35:46 +00001237let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001238def OR8rr : I<0x08, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001239 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001240 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1241def OR16rr : I<0x09, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001242 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001243 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1244def OR32rr : I<0x09, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001245 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001246 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001247}
Evan Cheng069287d2006-05-16 07:21:53 +00001248def OR8rm : I<0x0A, MRMSrcMem , (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001249 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001250 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1251def OR16rm : I<0x0B, MRMSrcMem , (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001252 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001253 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1254def OR32rm : I<0x0B, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001255 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001256 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001257
Evan Cheng069287d2006-05-16 07:21:53 +00001258def OR8ri : Ii8 <0x80, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001259 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001260 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1261def OR16ri : Ii16<0x81, MRM1r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001262 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001263 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1264def OR32ri : Ii32<0x81, MRM1r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001265 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001266 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001267
Evan Cheng069287d2006-05-16 07:21:53 +00001268def OR16ri8 : Ii8<0x83, MRM1r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001269 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001270 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1271def OR32ri8 : Ii8<0x83, MRM1r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001272 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001273 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001274let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001275 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, GR8:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001276 "or{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001277 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1278 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001279 "or{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001280 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1281 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001282 "or{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001283 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001284 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001285 "or{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001286 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001287 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001288 "or{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001289 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001290 OpSize;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001291 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001292 "or{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001293 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng0ef3a772005-12-13 01:41:36 +00001294 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1295 "or{w} {$src, $dst|$dst, $src}",
1296 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1297 OpSize;
1298 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1299 "or{l} {$src, $dst|$dst, $src}",
1300 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001301}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001302
1303
Chris Lattnercc65bee2005-01-02 02:35:46 +00001304let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001305def XOR8rr : I<0x30, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001306 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001307 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001308 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001309def XOR16rr : I<0x31, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001310 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001311 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001312 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001313def XOR32rr : I<0x31, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001314 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001315 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001316 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001317}
1318
Chris Lattner3a173df2004-10-03 20:35:00 +00001319def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001320 (ops GR8 :$dst, GR8:$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001321 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001322 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001323def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001324 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001325 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001326 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001327def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001328 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001329 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001330 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001331
Chris Lattner3a173df2004-10-03 20:35:00 +00001332def XOR8ri : Ii8<0x80, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001333 (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001334 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001335 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001336def XOR16ri : Ii16<0x81, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001337 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001338 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001339 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001340def XOR32ri : Ii32<0x81, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001341 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001342 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001343 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001344def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001345 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001346 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001347 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001348 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001349def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001350 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001351 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001352 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001353let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001354 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001355 (ops i8mem :$dst, GR8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001356 "xor{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001357 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001358 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001359 (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001360 "xor{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001361 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001362 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001363 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001364 (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001365 "xor{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001366 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001367 def XOR8mi : Ii8<0x80, MRM6m,
1368 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001369 "xor{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001370 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001371 def XOR16mi : Ii16<0x81, MRM6m,
1372 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001373 "xor{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001374 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001375 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001376 def XOR32mi : Ii32<0x81, MRM6m,
1377 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001378 "xor{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001379 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001380 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001381 (ops i16mem:$dst, i16i8imm :$src),
1382 "xor{w} {$src, $dst|$dst, $src}",
1383 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1384 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001385 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001386 (ops i32mem:$dst, i32i8imm :$src),
1387 "xor{l} {$src, $dst|$dst, $src}",
1388 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001389}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001390
1391// Shift instructions
Evan Cheng069287d2006-05-16 07:21:53 +00001392def SHL8rCL : I<0xD2, MRM4r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001393 "shl{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001394 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
1395def SHL16rCL : I<0xD3, MRM4r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001396 "shl{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001397 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1398def SHL32rCL : I<0xD3, MRM4r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001399 "shl{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001400 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001401
Evan Cheng069287d2006-05-16 07:21:53 +00001402def SHL8ri : Ii8<0xC0, MRM4r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001403 "shl{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001404 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001405let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001406def SHL16ri : Ii8<0xC1, MRM4r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001407 "shl{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001408 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1409def SHL32ri : Ii8<0xC1, MRM4r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001410 "shl{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001411 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001412}
Chris Lattnerf29ed092004-08-11 05:07:25 +00001413
Evan Cheng09c54572006-06-29 00:36:51 +00001414// Shift left by one. Not used because (add x, x) is slightly cheaper.
1415def SHL8r1 : I<0xD0, MRM4r, (ops GR8 :$dst, GR8 :$src1),
Evan Chengcbac2fa2006-07-20 21:37:39 +00001416 "shl{b} $dst", []>;
Evan Cheng09c54572006-06-29 00:36:51 +00001417def SHL16r1 : I<0xD1, MRM4r, (ops GR16:$dst, GR16:$src1),
Evan Chengcbac2fa2006-07-20 21:37:39 +00001418 "shl{w} $dst", []>, OpSize;
Evan Cheng09c54572006-06-29 00:36:51 +00001419def SHL32r1 : I<0xD1, MRM4r, (ops GR32:$dst, GR32:$src1),
Evan Chengcbac2fa2006-07-20 21:37:39 +00001420 "shl{l} $dst", []>;
Evan Cheng09c54572006-06-29 00:36:51 +00001421
Chris Lattnerf29ed092004-08-11 05:07:25 +00001422let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001423 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001424 "shl{b} {%cl, $dst|$dst, %CL}",
1425 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1426 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001427 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001428 "shl{w} {%cl, $dst|$dst, %CL}",
1429 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1430 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001431 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001432 "shl{l} {%cl, $dst|$dst, %CL}",
1433 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1434 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001435 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001436 "shl{b} {$src, $dst|$dst, $src}",
1437 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001438 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001439 "shl{w} {$src, $dst|$dst, $src}",
1440 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1441 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001442 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001443 "shl{l} {$src, $dst|$dst, $src}",
1444 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001445
1446 // Shift by 1
1447 def SHL8m1 : I<0xD0, MRM4m, (ops i8mem :$dst),
1448 "shl{b} $dst",
1449 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1450 def SHL16m1 : I<0xD1, MRM4m, (ops i16mem:$dst),
1451 "shl{w} $dst",
1452 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1453 OpSize;
1454 def SHL32m1 : I<0xD1, MRM4m, (ops i32mem:$dst),
1455 "shl{l} $dst",
1456 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001457}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001458
Evan Cheng069287d2006-05-16 07:21:53 +00001459def SHR8rCL : I<0xD2, MRM5r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001460 "shr{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001461 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
1462def SHR16rCL : I<0xD3, MRM5r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001463 "shr{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001464 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1465def SHR32rCL : I<0xD3, MRM5r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001466 "shr{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001467 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001468
Evan Cheng069287d2006-05-16 07:21:53 +00001469def SHR8ri : Ii8<0xC0, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001470 "shr{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001471 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1472def SHR16ri : Ii8<0xC1, MRM5r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001473 "shr{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001474 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1475def SHR32ri : Ii8<0xC1, MRM5r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001476 "shr{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001477 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001478
Evan Cheng09c54572006-06-29 00:36:51 +00001479// Shift by 1
1480def SHR8r1 : I<0xD0, MRM5r, (ops GR8:$dst, GR8:$src1),
1481 "shr{b} $dst",
1482 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1483def SHR16r1 : I<0xD1, MRM5r, (ops GR16:$dst, GR16:$src1),
1484 "shr{w} $dst",
1485 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1486def SHR32r1 : I<0xD1, MRM5r, (ops GR32:$dst, GR32:$src1),
1487 "shr{l} $dst",
1488 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1489
Chris Lattner57a02302004-08-11 04:31:00 +00001490let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001491 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001492 "shr{b} {%cl, $dst|$dst, %CL}",
1493 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1494 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001495 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001496 "shr{w} {%cl, $dst|$dst, %CL}",
1497 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1498 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001499 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001500 "shr{l} {%cl, $dst|$dst, %CL}",
1501 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1502 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001503 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001504 "shr{b} {$src, $dst|$dst, $src}",
1505 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001506 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001507 "shr{w} {$src, $dst|$dst, $src}",
1508 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1509 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001510 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001511 "shr{l} {$src, $dst|$dst, $src}",
1512 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001513
1514 // Shift by 1
1515 def SHR8m1 : I<0xD0, MRM5m, (ops i8mem :$dst),
1516 "shr{b} $dst",
1517 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1518 def SHR16m1 : I<0xD1, MRM5m, (ops i16mem:$dst),
1519 "shr{w} $dst",
1520 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1521 def SHR32m1 : I<0xD1, MRM5m, (ops i32mem:$dst),
1522 "shr{l} $dst",
1523 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001524}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001525
Evan Cheng069287d2006-05-16 07:21:53 +00001526def SAR8rCL : I<0xD2, MRM7r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001527 "sar{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001528 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
1529def SAR16rCL : I<0xD3, MRM7r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001530 "sar{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001531 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1532def SAR32rCL : I<0xD3, MRM7r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001533 "sar{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001534 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001535
Evan Cheng069287d2006-05-16 07:21:53 +00001536def SAR8ri : Ii8<0xC0, MRM7r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001537 "sar{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001538 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1539def SAR16ri : Ii8<0xC1, MRM7r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001540 "sar{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001541 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001542 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001543def SAR32ri : Ii8<0xC1, MRM7r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001544 "sar{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001545 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001546
1547// Shift by 1
1548def SAR8r1 : I<0xD0, MRM7r, (ops GR8 :$dst, GR8 :$src1),
1549 "sar{b} $dst",
1550 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1551def SAR16r1 : I<0xD1, MRM7r, (ops GR16:$dst, GR16:$src1),
1552 "sar{w} $dst",
1553 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1554def SAR32r1 : I<0xD1, MRM7r, (ops GR32:$dst, GR32:$src1),
1555 "sar{l} $dst",
1556 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1557
Chris Lattnerf29ed092004-08-11 05:07:25 +00001558let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001559 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001560 "sar{b} {%cl, $dst|$dst, %CL}",
1561 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1562 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001563 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001564 "sar{w} {%cl, $dst|$dst, %CL}",
1565 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1566 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001567 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001568 "sar{l} {%cl, $dst|$dst, %CL}",
1569 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1570 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001571 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001572 "sar{b} {$src, $dst|$dst, $src}",
1573 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001574 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001575 "sar{w} {$src, $dst|$dst, $src}",
1576 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1577 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001578 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001579 "sar{l} {$src, $dst|$dst, $src}",
1580 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001581
1582 // Shift by 1
1583 def SAR8m1 : I<0xD0, MRM7m, (ops i8mem :$dst),
1584 "sar{b} $dst",
1585 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1586 def SAR16m1 : I<0xD1, MRM7m, (ops i16mem:$dst),
1587 "sar{w} $dst",
1588 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1589 OpSize;
1590 def SAR32m1 : I<0xD1, MRM7m, (ops i32mem:$dst),
1591 "sar{l} $dst",
1592 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001593}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001594
Chris Lattner40ff6332005-01-19 07:50:03 +00001595// Rotate instructions
1596// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng069287d2006-05-16 07:21:53 +00001597def ROL8rCL : I<0xD2, MRM0r, (ops GR8 :$dst, GR8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001598 "rol{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001599 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
1600def ROL16rCL : I<0xD3, MRM0r, (ops GR16:$dst, GR16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001601 "rol{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001602 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1603def ROL32rCL : I<0xD3, MRM0r, (ops GR32:$dst, GR32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001604 "rol{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001605 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001606
Evan Cheng069287d2006-05-16 07:21:53 +00001607def ROL8ri : Ii8<0xC0, MRM0r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001608 "rol{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001609 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1610def ROL16ri : Ii8<0xC1, MRM0r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001611 "rol{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001612 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1613def ROL32ri : Ii8<0xC1, MRM0r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001614 "rol{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001615 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001616
Evan Cheng09c54572006-06-29 00:36:51 +00001617// Rotate by 1
1618def ROL8r1 : I<0xD0, MRM0r, (ops GR8 :$dst, GR8 :$src1),
1619 "rol{b} $dst",
1620 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1621def ROL16r1 : I<0xD1, MRM0r, (ops GR16:$dst, GR16:$src1),
1622 "rol{w} $dst",
1623 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1624def ROL32r1 : I<0xD1, MRM0r, (ops GR32:$dst, GR32:$src1),
1625 "rol{l} $dst",
1626 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1627
Chris Lattner40ff6332005-01-19 07:50:03 +00001628let isTwoAddress = 0 in {
1629 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001630 "rol{b} {%cl, $dst|$dst, %CL}",
1631 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1632 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001633 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001634 "rol{w} {%cl, $dst|$dst, %CL}",
1635 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1636 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001637 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001638 "rol{l} {%cl, $dst|$dst, %CL}",
1639 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1640 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001641 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001642 "rol{b} {$src, $dst|$dst, $src}",
1643 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001644 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001645 "rol{w} {$src, $dst|$dst, $src}",
1646 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1647 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001648 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001649 "rol{l} {$src, $dst|$dst, $src}",
1650 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001651
1652 // Rotate by 1
1653 def ROL8m1 : I<0xD0, MRM0m, (ops i8mem :$dst),
1654 "rol{b} $dst",
1655 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1656 def ROL16m1 : I<0xD1, MRM0m, (ops i16mem:$dst),
1657 "rol{w} $dst",
1658 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1659 OpSize;
1660 def ROL32m1 : I<0xD1, MRM0m, (ops i32mem:$dst),
1661 "rol{l} $dst",
1662 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001663}
1664
Evan Cheng069287d2006-05-16 07:21:53 +00001665def ROR8rCL : I<0xD2, MRM1r, (ops GR8 :$dst, GR8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001666 "ror{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001667 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
1668def ROR16rCL : I<0xD3, MRM1r, (ops GR16:$dst, GR16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001669 "ror{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001670 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1671def ROR32rCL : I<0xD3, MRM1r, (ops GR32:$dst, GR32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001672 "ror{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001673 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001674
Evan Cheng069287d2006-05-16 07:21:53 +00001675def ROR8ri : Ii8<0xC0, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001676 "ror{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001677 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1678def ROR16ri : Ii8<0xC1, MRM1r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001679 "ror{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001680 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1681def ROR32ri : Ii8<0xC1, MRM1r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001682 "ror{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001683 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001684
1685// Rotate by 1
1686def ROR8r1 : I<0xD0, MRM1r, (ops GR8 :$dst, GR8 :$src1),
1687 "ror{b} $dst",
1688 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1689def ROR16r1 : I<0xD1, MRM1r, (ops GR16:$dst, GR16:$src1),
1690 "ror{w} $dst",
1691 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1692def ROR32r1 : I<0xD1, MRM1r, (ops GR32:$dst, GR32:$src1),
1693 "ror{l} $dst",
1694 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1695
Chris Lattner40ff6332005-01-19 07:50:03 +00001696let isTwoAddress = 0 in {
1697 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001698 "ror{b} {%cl, $dst|$dst, %CL}",
1699 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1700 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001701 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001702 "ror{w} {%cl, $dst|$dst, %CL}",
1703 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1704 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001705 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001706 "ror{l} {%cl, $dst|$dst, %CL}",
1707 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1708 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001709 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001710 "ror{b} {$src, $dst|$dst, $src}",
1711 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001712 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001713 "ror{w} {$src, $dst|$dst, $src}",
1714 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1715 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001716 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001717 "ror{l} {$src, $dst|$dst, $src}",
1718 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001719
1720 // Rotate by 1
1721 def ROR8m1 : I<0xD0, MRM1m, (ops i8mem :$dst),
1722 "ror{b} $dst",
1723 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1724 def ROR16m1 : I<0xD1, MRM1m, (ops i16mem:$dst),
1725 "ror{w} $dst",
1726 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1727 OpSize;
1728 def ROR32m1 : I<0xD1, MRM1m, (ops i32mem:$dst),
1729 "ror{l} $dst",
1730 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001731}
1732
1733
1734
1735// Double shift instructions (generalizations of rotate)
Evan Cheng069287d2006-05-16 07:21:53 +00001736def SHLD32rrCL : I<0xA5, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001737 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001738 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001739 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001740def SHRD32rrCL : I<0xAD, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001741 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001742 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001743 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001744def SHLD16rrCL : I<0xA5, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001745 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001746 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001747 Imp<[CL],[]>, TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001748def SHRD16rrCL : I<0xAD, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001749 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001750 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001751 Imp<[CL],[]>, TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001752
1753let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001754def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001755 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001756 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001757 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001758 (i8 imm:$src3)))]>,
1759 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001760def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001761 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001762 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001763 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001764 (i8 imm:$src3)))]>,
1765 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001766def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001767 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001768 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001769 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001770 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001771 TB, OpSize;
1772def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001773 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001774 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001775 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001776 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001777 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001778}
Chris Lattner0e967d42004-08-01 08:13:11 +00001779
Chris Lattner57a02302004-08-11 04:31:00 +00001780let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001781 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001782 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001783 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001784 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001785 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001786 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001787 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001788 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001789 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001790 Imp<[CL],[]>, TB;
1791 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001792 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001793 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001794 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001795 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001796 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001797 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001798 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001799 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001800 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001801 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001802 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001803
Evan Cheng069287d2006-05-16 07:21:53 +00001804 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001805 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001806 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001807 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001808 Imp<[CL],[]>, TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001809 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001810 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001811 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001812 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001813 Imp<[CL],[]>, TB, OpSize;
1814 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001815 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001816 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001817 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001818 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001819 TB, OpSize;
1820 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001821 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001822 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001823 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001824 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001825 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001826}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001827
1828
Chris Lattnercc65bee2005-01-02 02:35:46 +00001829// Arithmetic.
1830let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001831def ADD8rr : I<0x00, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001832 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001833 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001834let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001835def ADD16rr : I<0x01, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001836 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001837 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1838def ADD32rr : I<0x01, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001839 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001840 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001841} // end isConvertibleToThreeAddress
1842} // end isCommutable
Evan Cheng069287d2006-05-16 07:21:53 +00001843def ADD8rm : I<0x02, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001844 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001845 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1846def ADD16rm : I<0x03, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001847 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001848 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
1849def ADD32rm : I<0x03, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001850 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001851 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001852
Evan Cheng069287d2006-05-16 07:21:53 +00001853def ADD8ri : Ii8<0x80, MRM0r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001854 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001855 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001856
1857let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001858def ADD16ri : Ii16<0x81, MRM0r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001859 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001860 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1861def ADD32ri : Ii32<0x81, MRM0r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001862 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001863 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00001864def ADD16ri8 : Ii8<0x83, MRM0r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001865 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001866 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001867 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001868def ADD32ri8 : Ii8<0x83, MRM0r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001869 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001870 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00001871}
Chris Lattner57a02302004-08-11 04:31:00 +00001872
1873let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001874 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001875 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001876 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1877 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001878 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001879 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001880 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001881 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001882 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001883 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001884 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001885 "add{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001886 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001887 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001888 "add{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001889 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001890 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001891 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001892 "add{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001893 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengee93f9d2005-12-12 19:45:23 +00001894 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1895 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001896 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1897 OpSize;
Evan Chengee93f9d2005-12-12 19:45:23 +00001898 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1899 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001900 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001901}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001902
Chris Lattner10197ff2005-01-03 01:27:59 +00001903let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001904def ADC32rr : I<0x11, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001905 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001906 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001907}
Evan Cheng069287d2006-05-16 07:21:53 +00001908def ADC32rm : I<0x13, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001909 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001910 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1911def ADC32ri : Ii32<0x81, MRM2r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001912 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001913 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1914def ADC32ri8 : Ii8<0x83, MRM2r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001915 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001916 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001917
1918let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001919 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001920 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001921 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001922 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001923 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001924 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chenge3413162006-01-09 18:33:28 +00001925 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1926 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001927 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001928}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001929
Evan Cheng069287d2006-05-16 07:21:53 +00001930def SUB8rr : I<0x28, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001931 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001932 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1933def SUB16rr : I<0x29, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001934 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001935 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1936def SUB32rr : I<0x29, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001937 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001938 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1939def SUB8rm : I<0x2A, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001940 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001941 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1942def SUB16rm : I<0x2B, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001943 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001944 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1945def SUB32rm : I<0x2B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001946 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001947 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001948
Evan Cheng069287d2006-05-16 07:21:53 +00001949def SUB8ri : Ii8 <0x80, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001950 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001951 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1952def SUB16ri : Ii16<0x81, MRM5r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001953 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001954 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1955def SUB32ri : Ii32<0x81, MRM5r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001956 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001957 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1958def SUB16ri8 : Ii8<0x83, MRM5r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001959 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001960 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001961 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001962def SUB32ri8 : Ii8<0x83, MRM5r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001963 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001964 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001965let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001966 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001967 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001968 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
1969 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001970 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001971 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001972 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001973 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001974 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001975 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001976 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001977 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001978 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001979 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001980 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001981 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001982 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001983 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001984 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001985 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengd160d482005-12-12 21:54:05 +00001986 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1987 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001988 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1989 OpSize;
Evan Chengd160d482005-12-12 21:54:05 +00001990 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1991 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001992 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001993}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001994
Evan Cheng069287d2006-05-16 07:21:53 +00001995def SBB32rr : I<0x19, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001996 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001997 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001998
Chris Lattner57a02302004-08-11 04:31:00 +00001999let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00002000 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002001 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002002 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00002003 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002004 "sbb{b} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002005 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002006 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002007 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002008 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chenge3413162006-01-09 18:33:28 +00002009 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
2010 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002011 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002012}
Evan Cheng069287d2006-05-16 07:21:53 +00002013def SBB32rm : I<0x1B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002014 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002015 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2016def SBB32ri : Ii32<0x81, MRM3r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002017 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002018 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2019def SBB32ri8 : Ii8<0x83, MRM3r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002020 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002021 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002022
Chris Lattner10197ff2005-01-03 01:27:59 +00002023let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00002024def IMUL16rr : I<0xAF, MRMSrcReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002025 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002026 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2027def IMUL32rr : I<0xAF, MRMSrcReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002028 "imul{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002029 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002030}
Evan Cheng069287d2006-05-16 07:21:53 +00002031def IMUL16rm : I<0xAF, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002032 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002033 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002034 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002035def IMUL32rm : I<0xAF, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002036 "imul{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002037 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002038
2039} // end Two Address instructions
2040
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002041// Suprisingly enough, these are not two address instructions!
Evan Cheng069287d2006-05-16 07:21:53 +00002042def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2043 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00002044 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002045 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2046def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2047 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00002048 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002049 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2050def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2051 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002052 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002053 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002054 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002055def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2056 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002057 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002058 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002059
Evan Cheng069287d2006-05-16 07:21:53 +00002060def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2061 (ops GR16:$dst, i16mem:$src1, i16imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002062 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002063 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
Evan Chengf281e022005-12-12 23:47:46 +00002064 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002065def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2066 (ops GR32:$dst, i32mem:$src1, i32imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002067 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002068 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2069def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2070 (ops GR16:$dst, i16mem:$src1, i16i8imm :$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002071 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002072 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002073 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002074def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2075 (ops GR32:$dst, i32mem:$src1, i32i8imm: $src2),
Evan Chengf281e022005-12-12 23:47:46 +00002076 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002077 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002078
2079//===----------------------------------------------------------------------===//
2080// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002081//
Chris Lattnercc65bee2005-01-02 02:35:46 +00002082let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng069287d2006-05-16 07:21:53 +00002083def TEST8rr : I<0x84, MRMDestReg, (ops GR8:$src1, GR8:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002084 "test{b} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002085 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002086def TEST16rr : I<0x85, MRMDestReg, (ops GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002087 "test{w} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002088 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002089def TEST32rr : I<0x85, MRMDestReg, (ops GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002090 "test{l} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002091 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002092}
Evan Cheng734503b2006-09-11 02:19:56 +00002093
Evan Cheng069287d2006-05-16 07:21:53 +00002094def TEST8rm : I<0x84, MRMSrcMem, (ops GR8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002095 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002096 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002097def TEST16rm : I<0x85, MRMSrcMem, (ops GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002098 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002099 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002100 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002101def TEST32rm : I<0x85, MRMSrcMem, (ops GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002102 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002103 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002104
Evan Cheng069287d2006-05-16 07:21:53 +00002105def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2106 (ops GR8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002107 "test{b} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002108 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002109def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2110 (ops GR16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002111 "test{w} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002112 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002113def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2114 (ops GR32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002115 "test{l} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002116 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002117
Chris Lattner707c6fe2004-10-04 01:38:10 +00002118def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengaed7c722005-12-17 01:24:02 +00002119 (ops i8mem:$src1, i8imm:$src2),
2120 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002121 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002122def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2123 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002124 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002125 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002126 OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002127def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2128 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002129 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002130 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002131
2132
2133// Condition code ops, incl. set if equal/not equal/...
Evan Chengf0701842005-11-29 19:38:52 +00002134def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2135def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002136
Chris Lattner3a173df2004-10-03 20:35:00 +00002137def SETEr : I<0x94, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002138 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002139 "sete $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002140 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2141 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002142def SETEm : I<0x94, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002143 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002144 "sete $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002145 [(store (X86setcc X86_COND_E), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002146 TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002147def SETNEr : I<0x95, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002148 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002149 "setne $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002150 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2151 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002152def SETNEm : I<0x95, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002153 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002154 "setne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002155 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002156 TB; // [mem8] = !=
2157def SETLr : I<0x9C, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002158 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002159 "setl $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002160 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2161 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002162def SETLm : I<0x9C, MRM0m,
2163 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002164 "setl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002165 [(store (X86setcc X86_COND_L), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002166 TB; // [mem8] = < signed
2167def SETGEr : I<0x9D, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002168 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002169 "setge $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002170 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2171 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002172def SETGEm : I<0x9D, MRM0m,
2173 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002174 "setge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002175 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002176 TB; // [mem8] = >= signed
2177def SETLEr : I<0x9E, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002178 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002179 "setle $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002180 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2181 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002182def SETLEm : I<0x9E, MRM0m,
2183 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002184 "setle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002185 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002186 TB; // [mem8] = <= signed
2187def SETGr : I<0x9F, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002188 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002189 "setg $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002190 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2191 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002192def SETGm : I<0x9F, MRM0m,
2193 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002194 "setg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002195 [(store (X86setcc X86_COND_G), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002196 TB; // [mem8] = > signed
2197
2198def SETBr : I<0x92, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002199 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002200 "setb $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002201 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2202 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002203def SETBm : I<0x92, MRM0m,
2204 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002205 "setb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002206 [(store (X86setcc X86_COND_B), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002207 TB; // [mem8] = < unsign
2208def SETAEr : I<0x93, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002209 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002210 "setae $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002211 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2212 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002213def SETAEm : I<0x93, MRM0m,
2214 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002215 "setae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002216 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002217 TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002218def SETBEr : I<0x96, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002219 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002220 "setbe $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002221 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2222 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002223def SETBEm : I<0x96, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002224 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002225 "setbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002226 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002227 TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002228def SETAr : I<0x97, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002229 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002230 "seta $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002231 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2232 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002233def SETAm : I<0x97, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002234 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002235 "seta $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002236 [(store (X86setcc X86_COND_A), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002237 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002238
Chris Lattner3a173df2004-10-03 20:35:00 +00002239def SETSr : I<0x98, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002240 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002241 "sets $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002242 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2243 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002244def SETSm : I<0x98, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002245 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002246 "sets $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002247 [(store (X86setcc X86_COND_S), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002248 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002249def SETNSr : I<0x99, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002250 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002251 "setns $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002252 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2253 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002254def SETNSm : I<0x99, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002255 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002256 "setns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002257 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002258 TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002259def SETPr : I<0x9A, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002260 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002261 "setp $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002262 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2263 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002264def SETPm : I<0x9A, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002265 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002266 "setp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002267 [(store (X86setcc X86_COND_P), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002268 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002269def SETNPr : I<0x9B, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002270 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002271 "setnp $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002272 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2273 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002274def SETNPm : I<0x9B, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002275 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002276 "setnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002277 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002278 TB; // [mem8] = not parity
Chris Lattner1cca5e32003-08-03 21:54:21 +00002279
2280// Integer comparisons
Chris Lattner3a173df2004-10-03 20:35:00 +00002281def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002282 (ops GR8 :$src1, GR8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002283 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002284 [(X86cmp GR8:$src1, GR8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002285def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002286 (ops GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002287 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002288 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002289def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002290 (ops GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002291 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002292 [(X86cmp GR32:$src1, GR32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002293def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002294 (ops i8mem :$src1, GR8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002295 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002296 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002297def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002298 (ops i16mem:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002299 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002300 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002301def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002302 (ops i32mem:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002303 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002304 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002305def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002306 (ops GR8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002307 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002308 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002309def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002310 (ops GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002311 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002312 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002313def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002314 (ops GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002315 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002316 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002317def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002318 (ops GR8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002319 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002320 [(X86cmp GR8:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002321def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002322 (ops GR16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002323 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002324 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002325def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002326 (ops GR32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002327 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002328 [(X86cmp GR32:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002329def CMP8mi : Ii8 <0x80, MRM7m,
2330 (ops i8mem :$src1, i8imm :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002331 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002332 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002333def CMP16mi : Ii16<0x81, MRM7m,
2334 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002335 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002336 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002337def CMP32mi : Ii32<0x81, MRM7m,
2338 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002339 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002340 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002341def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002342 (ops GR16:$src1, i16i8imm:$src2),
Nate Begemance944822006-03-23 01:29:48 +00002343 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002344 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002345def CMP16mi8 : Ii8<0x83, MRM7m,
Nate Begemance944822006-03-23 01:29:48 +00002346 (ops i16mem:$src1, i16i8imm:$src2),
2347 "cmp{w} {$src2, $src1|$src1, $src2}",
2348 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002349def CMP32mi8 : Ii8<0x83, MRM7m,
Nate Begemance944822006-03-23 01:29:48 +00002350 (ops i32mem:$src1, i32i8imm:$src2),
2351 "cmp{l} {$src2, $src1|$src1, $src2}",
2352 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002353def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002354 (ops GR32:$src1, i32i8imm:$src2),
Nate Begemance944822006-03-23 01:29:48 +00002355 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002356 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002357
2358// Sign/Zero extenders
Evan Cheng069287d2006-05-16 07:21:53 +00002359def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002360 "movs{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002361 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
2362def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002363 "movs{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002364 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2365def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002366 "movs{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002367 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2368def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002369 "movs{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002370 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2371def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops GR32:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002372 "movs{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002373 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2374def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002375 "movs{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002376 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002377
Evan Cheng069287d2006-05-16 07:21:53 +00002378def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002379 "movz{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002380 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
2381def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002382 "movz{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002383 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2384def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002385 "movz{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002386 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2387def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002388 "movz{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002389 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2390def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops GR32:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002391 "movz{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002392 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2393def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002394 "movz{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002395 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00002396
Evan Chengf91c1012006-05-31 22:05:11 +00002397def CBW : I<0x98, RawFrm, (ops),
2398 "{cbtw|cbw}", []>, Imp<[AL],[AX]>; // AX = signext(AL)
2399def CWDE : I<0x98, RawFrm, (ops),
2400 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2401
2402def CWD : I<0x99, RawFrm, (ops),
2403 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>; // DX:AX = signext(AX)
2404def CDQ : I<0x99, RawFrm, (ops),
2405 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2406
Nate Begemanf1702ac2005-06-27 21:20:31 +00002407//===----------------------------------------------------------------------===//
Evan Cheng747a90d2006-02-21 02:24:38 +00002408// Miscellaneous Instructions
2409//===----------------------------------------------------------------------===//
2410
2411def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
2412 TB, Imp<[],[EAX,EDX]>;
2413
Evan Cheng747a90d2006-02-21 02:24:38 +00002414//===----------------------------------------------------------------------===//
2415// Alias Instructions
2416//===----------------------------------------------------------------------===//
2417
2418// Alias instructions that map movr0 to xor.
2419// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Cheng069287d2006-05-16 07:21:53 +00002420def MOV8r0 : I<0x30, MRMInitReg, (ops GR8 :$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002421 "xor{b} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002422 [(set GR8:$dst, 0)]>;
2423def MOV16r0 : I<0x31, MRMInitReg, (ops GR16:$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002424 "xor{w} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002425 [(set GR16:$dst, 0)]>, OpSize;
2426def MOV32r0 : I<0x31, MRMInitReg, (ops GR32:$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002427 "xor{l} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002428 [(set GR32:$dst, 0)]>;
Evan Cheng747a90d2006-02-21 02:24:38 +00002429
Evan Cheng069287d2006-05-16 07:21:53 +00002430// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2431// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2432def MOV16to16_ : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002433 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002434def MOV32to32_ : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002435 "mov{l} {$src, $dst|$dst, $src}", []>;
2436
Evan Cheng069287d2006-05-16 07:21:53 +00002437def MOV16_rr : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002438 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002439def MOV32_rr : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002440 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +00002441def MOV16_rm : I<0x8B, MRMSrcMem, (ops GR16_:$dst, i16mem:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002442 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002443def MOV32_rm : I<0x8B, MRMSrcMem, (ops GR32_:$dst, i32mem:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002444 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +00002445def MOV16_mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002446 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002447def MOV32_mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002448 "mov{l} {$src, $dst|$dst, $src}", []>;
2449
Evan Cheng510e4782006-01-09 23:10:28 +00002450//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00002451// DWARF Pseudo Instructions
2452//
2453
2454def DWARF_LOC : I<0, Pseudo, (ops i32imm:$line, i32imm:$col, i32imm:$file),
2455 "; .loc $file, $line, $col",
2456 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2457 (i32 imm:$file))]>;
2458
2459def DWARF_LABEL : I<0, Pseudo, (ops i32imm:$id),
2460 "\nLdebug_loc${id:debug}:",
2461 [(dwarf_label (i32 imm:$id))]>;
2462
2463//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00002464// Non-Instruction Patterns
2465//===----------------------------------------------------------------------===//
2466
Evan Cheng25ab6902006-09-08 06:48:29 +00002467// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00002468def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00002469def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002470def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2471def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2472
Evan Cheng069287d2006-05-16 07:21:53 +00002473def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2474 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2475def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2476 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2477def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2478 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2479def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2480 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002481
Evan Chengfc8feb12006-05-19 07:30:36 +00002482def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002483 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00002484def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002485 (MOV32mi addr:$dst, texternalsym:$src)>;
2486
Evan Cheng510e4782006-01-09 23:10:28 +00002487// Calls
Evan Cheng069287d2006-05-16 07:21:53 +00002488def : Pat<(X86tailcall GR32:$dst),
Evan Cheng25ab6902006-09-08 06:48:29 +00002489 (CALL32r GR32:$dst)>;
Evan Chengfea89c12006-04-27 08:40:39 +00002490
Evan Cheng25ab6902006-09-08 06:48:29 +00002491def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Evan Chengfea89c12006-04-27 08:40:39 +00002492 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002493def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Evan Chengfea89c12006-04-27 08:40:39 +00002494 (CALLpcrel32 texternalsym:$dst)>;
2495
Evan Cheng25ab6902006-09-08 06:48:29 +00002496def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00002497 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002498def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00002499 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002500
2501// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00002502def : Pat<(addc GR32:$src1, GR32:$src2),
2503 (ADD32rr GR32:$src1, GR32:$src2)>;
2504def : Pat<(addc GR32:$src1, (load addr:$src2)),
2505 (ADD32rm GR32:$src1, addr:$src2)>;
2506def : Pat<(addc GR32:$src1, imm:$src2),
2507 (ADD32ri GR32:$src1, imm:$src2)>;
2508def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2509 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002510
Evan Cheng069287d2006-05-16 07:21:53 +00002511def : Pat<(subc GR32:$src1, GR32:$src2),
2512 (SUB32rr GR32:$src1, GR32:$src2)>;
2513def : Pat<(subc GR32:$src1, (load addr:$src2)),
2514 (SUB32rm GR32:$src1, addr:$src2)>;
2515def : Pat<(subc GR32:$src1, imm:$src2),
2516 (SUB32ri GR32:$src1, imm:$src2)>;
2517def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2518 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002519
Evan Chengb8414332006-01-13 21:45:19 +00002520def : Pat<(truncstore (i8 imm:$src), addr:$dst, i1),
2521 (MOV8mi addr:$dst, imm:$src)>;
Evan Cheng069287d2006-05-16 07:21:53 +00002522def : Pat<(truncstore GR8:$src, addr:$dst, i1),
2523 (MOV8mr addr:$dst, GR8:$src)>;
Evan Chengb8414332006-01-13 21:45:19 +00002524
Chris Lattnerffc0b262006-09-07 20:33:45 +00002525// Comparisons.
2526
2527// TEST R,R is smaller than CMP R,0
2528def : Pat<(X86cmp GR8:$src1, 0),
2529 (TEST8rr GR8:$src1, GR8:$src1)>;
2530def : Pat<(X86cmp GR16:$src1, 0),
2531 (TEST16rr GR16:$src1, GR16:$src1)>;
2532def : Pat<(X86cmp GR32:$src1, 0),
2533 (TEST32rr GR32:$src1, GR32:$src1)>;
2534
Evan Cheng510e4782006-01-09 23:10:28 +00002535// {s|z}extload bool -> {s|z}extload byte
2536def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2537def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
Evan Chenge5d93432006-01-17 07:02:46 +00002538def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002539def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2540def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2541
2542// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00002543def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2544def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2545def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2546def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2547def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2548def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002549
2550// anyext -> zext
Evan Cheng069287d2006-05-16 07:21:53 +00002551def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2552def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2553def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng6e16ee52006-03-25 09:45:48 +00002554def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2555def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2556def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002557
Evan Chengcfa260b2006-01-06 02:31:59 +00002558//===----------------------------------------------------------------------===//
2559// Some peepholes
2560//===----------------------------------------------------------------------===//
2561
2562// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00002563def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2564def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2565def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002566
Evan Cheng956044c2006-01-19 23:26:24 +00002567// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002568def : Pat<(or (srl GR32:$src1, CL:$amt),
2569 (shl GR32:$src2, (sub 32, CL:$amt))),
2570 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002571
Evan Cheng21d54432006-01-20 01:13:30 +00002572def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002573 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2574 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002575
Evan Cheng956044c2006-01-19 23:26:24 +00002576// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002577def : Pat<(or (shl GR32:$src1, CL:$amt),
2578 (srl GR32:$src2, (sub 32, CL:$amt))),
2579 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002580
Evan Cheng21d54432006-01-20 01:13:30 +00002581def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002582 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2583 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002584
Evan Cheng956044c2006-01-19 23:26:24 +00002585// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002586def : Pat<(or (srl GR16:$src1, CL:$amt),
2587 (shl GR16:$src2, (sub 16, CL:$amt))),
2588 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002589
Evan Cheng21d54432006-01-20 01:13:30 +00002590def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002591 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2592 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002593
Evan Cheng956044c2006-01-19 23:26:24 +00002594// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002595def : Pat<(or (shl GR16:$src1, CL:$amt),
2596 (srl GR16:$src2, (sub 16, CL:$amt))),
2597 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002598
2599def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002600 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2601 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00002602
2603
2604//===----------------------------------------------------------------------===//
2605// Floating Point Stack Support
2606//===----------------------------------------------------------------------===//
2607
2608include "X86InstrFPStack.td"
2609
2610//===----------------------------------------------------------------------===//
2611// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2612//===----------------------------------------------------------------------===//
2613
2614include "X86InstrMMX.td"
2615
2616//===----------------------------------------------------------------------===//
2617// XMM Floating point support (requires SSE / SSE2)
2618//===----------------------------------------------------------------------===//
2619
2620include "X86InstrSSE.td"
Evan Cheng25ab6902006-09-08 06:48:29 +00002621
2622//===----------------------------------------------------------------------===//
2623// X86-64 Support
2624//===----------------------------------------------------------------------===//
2625
2626include "X86InstrX86-64.td"