blob: 5fa7be74903a03df4001995d986b9fcc3ab73eeb [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
42def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
43
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,
54 [SDNPOutFlag]>;
55def X86test : SDNode<"X86ISD::TEST", SDTX86CmpTest,
56 [SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000057
Evan Chenge3413162006-01-09 18:33:28 +000058def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000059 [SDNPInFlag, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000060def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000061 [SDNPHasChain, SDNPInFlag]>;
Evan Cheng5ee4ccc2006-01-12 08:27:59 +000062def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000063 [SDNPInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000064
Evan Chenge3413162006-01-09 18:33:28 +000065def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
66 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000067
Evan Chenge3413162006-01-09 18:33:28 +000068def X86callseq_start :
69 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
70 [SDNPHasChain]>;
71def X86callseq_end :
72 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Chris Lattneraf63bb02006-01-24 05:17:12 +000073 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000074
Evan Chenge3413162006-01-09 18:33:28 +000075def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
76 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +000077
Evan Chengfb914c42006-05-20 01:40:16 +000078def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
Evan Chengfea89c12006-04-27 08:40:39 +000079 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
80
Evan Cheng67f92a72006-01-11 22:15:48 +000081def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Evan Cheng99256422006-03-07 23:34:23 +000082 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Cheng67f92a72006-01-11 22:15:48 +000083def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Evan Cheng99256422006-03-07 23:34:23 +000084 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Cheng67f92a72006-01-11 22:15:48 +000085
Evan Chenge3413162006-01-09 18:33:28 +000086def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
87 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000088
Evan Cheng71fb8342006-02-25 10:02:21 +000089def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
90
Evan Chengaed7c722005-12-17 01:24:02 +000091//===----------------------------------------------------------------------===//
92// X86 Operand Definitions.
93//
94
Chris Lattner66fa1dc2004-08-11 02:25:00 +000095// *mem - Operand definitions for the funky X86 addressing mode operands.
96//
Evan Chengaf78ef52006-05-17 21:21:41 +000097class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +000098 let PrintMethod = printMethod;
Chris Lattner6adaf792005-11-19 07:01:30 +000099 let NumMIOperands = 4;
Evan Cheng069287d2006-05-16 07:21:53 +0000100 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000101}
Nate Begeman391c5d22005-11-30 18:54:35 +0000102
Chris Lattner45432512005-12-17 19:47:05 +0000103def i8mem : X86MemOperand<"printi8mem">;
104def i16mem : X86MemOperand<"printi16mem">;
105def i32mem : X86MemOperand<"printi32mem">;
106def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000107def i128mem : X86MemOperand<"printi128mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000108def f32mem : X86MemOperand<"printf32mem">;
109def f64mem : X86MemOperand<"printf64mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000110def f128mem : X86MemOperand<"printf128mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000111
Nate Begeman16b04f32005-07-15 00:38:55 +0000112def SSECC : Operand<i8> {
113 let PrintMethod = "printSSECC";
114}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000115
Evan Cheng7ccced62006-02-18 00:15:05 +0000116def piclabel: Operand<i32> {
117 let PrintMethod = "printPICLabel";
118}
119
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000120// A couple of more descriptive operand definitions.
121// 16-bits but only 8 bits are significant.
122def i16i8imm : Operand<i16>;
123// 32-bits but only 8 bits are significant.
124def i32i8imm : Operand<i32>;
125
Evan Chengd35b8c12005-12-04 08:19:43 +0000126// Branch targets have OtherVT type.
127def brtarget : Operand<OtherVT>;
128
Evan Chengaed7c722005-12-17 01:24:02 +0000129//===----------------------------------------------------------------------===//
130// X86 Complex Pattern Definitions.
131//
132
Evan Chengec693f72005-12-08 02:01:35 +0000133// Define X86 specific addressing mode.
Evan Chengaf78ef52006-05-17 21:21:41 +0000134def addr : ComplexPattern<iPTR, 4, "SelectAddr", []>;
135def leaaddr : ComplexPattern<iPTR, 4, "SelectLEAAddr",
Evan Chenge6ad27e2006-05-30 06:59:36 +0000136 [add, mul, shl, or, frameindex]>;
Evan Chengec693f72005-12-08 02:01:35 +0000137
Evan Chengaed7c722005-12-17 01:24:02 +0000138//===----------------------------------------------------------------------===//
139// X86 Instruction Format Definitions.
140//
141
Chris Lattner1cca5e32003-08-03 21:54:21 +0000142// Format specifies the encoding used by the instruction. This is part of the
143// ad-hoc solution used to emit machine instruction encodings by our machine
144// code emitter.
Evan Cheng3c55c542006-02-01 06:13:50 +0000145class Format<bits<6> val> {
146 bits<6> Value = val;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000147}
148
149def Pseudo : Format<0>; def RawFrm : Format<1>;
150def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
151def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
152def MRMSrcMem : Format<6>;
Alkis Evlogimenos169584e2004-02-27 18:55:12 +0000153def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
154def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
155def MRM6r : Format<22>; def MRM7r : Format<23>;
156def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
157def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
158def MRM6m : Format<30>; def MRM7m : Format<31>;
Evan Cheng3c55c542006-02-01 06:13:50 +0000159def MRMInitReg : Format<32>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000160
Evan Chengaed7c722005-12-17 01:24:02 +0000161//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000162// X86 Instruction Predicate Definitions.
Evan Chengffcb95b2006-02-21 19:13:53 +0000163def HasMMX : Predicate<"Subtarget->hasMMX()">;
Chris Lattner259e97c2006-01-31 19:43:35 +0000164def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
Evan Cheng559806f2006-01-27 08:10:46 +0000165def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
166def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
167def FPStack : Predicate<"!Subtarget->hasSSE2()">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000168
169//===----------------------------------------------------------------------===//
Evan Chengaed7c722005-12-17 01:24:02 +0000170// X86 specific pattern fragments.
171//
172
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000173// ImmType - This specifies the immediate type used by an instruction. This is
Chris Lattner1cca5e32003-08-03 21:54:21 +0000174// part of the ad-hoc solution used to emit machine instruction encodings by our
175// machine code emitter.
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000176class ImmType<bits<2> val> {
177 bits<2> Value = val;
178}
179def NoImm : ImmType<0>;
180def Imm8 : ImmType<1>;
181def Imm16 : ImmType<2>;
182def Imm32 : ImmType<3>;
183
Chris Lattner1cca5e32003-08-03 21:54:21 +0000184// FPFormat - This specifies what form this FP instruction has. This is used by
185// the Floating-Point stackifier pass.
186class FPFormat<bits<3> val> {
187 bits<3> Value = val;
188}
189def NotFP : FPFormat<0>;
190def ZeroArgFP : FPFormat<1>;
191def OneArgFP : FPFormat<2>;
192def OneArgFPRW : FPFormat<3>;
193def TwoArgFP : FPFormat<4>;
Chris Lattnerab8decc2004-06-11 04:41:24 +0000194def CompareFP : FPFormat<5>;
195def CondMovFP : FPFormat<6>;
196def SpecialFP : FPFormat<7>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000197
198
Chris Lattner3a173df2004-10-03 20:35:00 +0000199class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
200 : Instruction {
Chris Lattnerc8f45872003-08-04 04:59:56 +0000201 let Namespace = "X86";
Chris Lattner1cca5e32003-08-03 21:54:21 +0000202
Chris Lattner1cca5e32003-08-03 21:54:21 +0000203 bits<8> Opcode = opcod;
204 Format Form = f;
Evan Cheng3c55c542006-02-01 06:13:50 +0000205 bits<6> FormBits = Form.Value;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000206 ImmType ImmT = i;
207 bits<2> ImmTypeBits = ImmT.Value;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000208
Chris Lattnerc96bb812004-08-11 07:12:04 +0000209 dag OperandList = ops;
210 string AsmString = AsmStr;
211
John Criswell4ffff9e2004-04-08 20:31:47 +0000212 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000213 // Attributes specific to X86 instructions...
John Criswell4ffff9e2004-04-08 20:31:47 +0000214 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000215 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
John Criswell4ffff9e2004-04-08 20:31:47 +0000216
Chris Lattner1cca5e32003-08-03 21:54:21 +0000217 bits<4> Prefix = 0; // Which prefix byte does this inst have?
218 FPFormat FPForm; // What flavor of FP instruction is this?
219 bits<3> FPFormBits = 0;
220}
221
222class Imp<list<Register> uses, list<Register> defs> {
223 list<Register> Uses = uses;
224 list<Register> Defs = defs;
225}
226
227
228// Prefix byte classes which are used to indicate to the ad-hoc machine code
229// emitter that various prefix bytes are required.
230class OpSize { bit hasOpSizePrefix = 1; }
231class TB { bits<4> Prefix = 1; }
Chris Lattner915e5e52004-02-12 17:53:22 +0000232class REP { bits<4> Prefix = 2; }
233class D8 { bits<4> Prefix = 3; }
234class D9 { bits<4> Prefix = 4; }
235class DA { bits<4> Prefix = 5; }
236class DB { bits<4> Prefix = 6; }
237class DC { bits<4> Prefix = 7; }
238class DD { bits<4> Prefix = 8; }
239class DE { bits<4> Prefix = 9; }
240class DF { bits<4> Prefix = 10; }
Nate Begemanf1702ac2005-06-27 21:20:31 +0000241class XD { bits<4> Prefix = 11; }
242class XS { bits<4> Prefix = 12; }
Chris Lattner1cca5e32003-08-03 21:54:21 +0000243
244
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000245//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000246// Pattern fragments...
247//
Evan Chengd9558e02006-01-06 00:43:03 +0000248
249// X86 specific condition code. These correspond to CondCode in
250// X86ISelLowering.h. They must be kept in synch.
251def X86_COND_A : PatLeaf<(i8 0)>;
252def X86_COND_AE : PatLeaf<(i8 1)>;
253def X86_COND_B : PatLeaf<(i8 2)>;
254def X86_COND_BE : PatLeaf<(i8 3)>;
255def X86_COND_E : PatLeaf<(i8 4)>;
256def X86_COND_G : PatLeaf<(i8 5)>;
257def X86_COND_GE : PatLeaf<(i8 6)>;
258def X86_COND_L : PatLeaf<(i8 7)>;
259def X86_COND_LE : PatLeaf<(i8 8)>;
260def X86_COND_NE : PatLeaf<(i8 9)>;
261def X86_COND_NO : PatLeaf<(i8 10)>;
262def X86_COND_NP : PatLeaf<(i8 11)>;
263def X86_COND_NS : PatLeaf<(i8 12)>;
264def X86_COND_O : PatLeaf<(i8 13)>;
265def X86_COND_P : PatLeaf<(i8 14)>;
266def X86_COND_S : PatLeaf<(i8 15)>;
267
Evan Cheng9b6b6422005-12-13 00:14:11 +0000268def i16immSExt8 : PatLeaf<(i16 imm), [{
269 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000270 // sign extended field.
Evan Cheng09e3c802006-05-19 18:40:54 +0000271 return (int16_t)N->getValue() == (int8_t)N->getValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000272}]>;
273
Evan Cheng9b6b6422005-12-13 00:14:11 +0000274def i32immSExt8 : PatLeaf<(i32 imm), [{
275 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000276 // sign extended field.
Evan Cheng09e3c802006-05-19 18:40:54 +0000277 return (int32_t)N->getValue() == (int8_t)N->getValue();
Evan Chengb3558542005-12-13 00:01:09 +0000278}]>;
279
Evan Cheng605c4152005-12-13 01:57:51 +0000280// Helper fragments for loads.
Evan Cheng09e3c802006-05-19 18:40:54 +0000281def loadiPTR : PatFrag<(ops node:$ptr), (iPTR (load node:$ptr))>;
282
Evan Cheng7a7e8372005-12-14 02:22:27 +0000283def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
284def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
285def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
Evan Cheng11e15b32006-04-03 20:53:28 +0000286def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000287
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000288def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
289def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000290
291def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i1))>;
292def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i1))>;
293def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i8))>;
294def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i8))>;
295def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i16))>;
296
Evan Chenge5d93432006-01-17 07:02:46 +0000297def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextload node:$ptr, i1))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000298def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i1))>;
299def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i1))>;
300def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i8))>;
301def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i8))>;
302def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i16))>;
303
Evan Cheng38bcbaf2005-12-23 07:31:11 +0000304def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extload node:$ptr, i1))>;
Evan Cheng47137242006-05-05 08:23:07 +0000305def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extload node:$ptr, i1))>;
306def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extload node:$ptr, i1))>;
307def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extload node:$ptr, i8))>;
308def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extload node:$ptr, i8))>;
309def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extload node:$ptr, i16))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000310
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000311//===----------------------------------------------------------------------===//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000312// Instruction templates...
313
Evan Chengf0701842005-11-29 19:38:52 +0000314class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
315 : X86Inst<o, f, NoImm, ops, asm> {
316 let Pattern = pattern;
317}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000318class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
319 : X86Inst<o, f, Imm8 , ops, asm> {
320 let Pattern = pattern;
321}
Chris Lattner78432fe2005-11-17 02:01:55 +0000322class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
323 : X86Inst<o, f, Imm16, ops, asm> {
324 let Pattern = pattern;
325}
Chris Lattner7a125372005-11-16 22:59:19 +0000326class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
327 : X86Inst<o, f, Imm32, ops, asm> {
328 let Pattern = pattern;
329}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000330
Chris Lattner1cca5e32003-08-03 21:54:21 +0000331//===----------------------------------------------------------------------===//
332// Instruction list...
333//
334
Evan Chengd90eb7f2006-01-05 00:27:02 +0000335def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
Evan Chenge3413162006-01-09 18:33:28 +0000336 [(X86callseq_start imm:$amt)]>;
Chris Lattner43ef1312005-09-14 21:10:24 +0000337def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
Evan Chengd90eb7f2006-01-05 00:27:02 +0000338 "#ADJCALLSTACKUP",
Evan Chenge3413162006-01-09 18:33:28 +0000339 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
Evan Chengf0701842005-11-29 19:38:52 +0000340def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
341def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000342def IMPLICIT_DEF_GR8 : I<0, Pseudo, (ops GR8:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000343 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000344 [(set GR8:$dst, (undef))]>;
345def IMPLICIT_DEF_GR16 : I<0, Pseudo, (ops GR16:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000346 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000347 [(set GR16:$dst, (undef))]>;
348def IMPLICIT_DEF_GR32 : I<0, Pseudo, (ops GR32:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000349 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000350 [(set GR32:$dst, (undef))]>;
Evan Cheng4a460802006-01-11 00:33:36 +0000351
352// Nop
353def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
354
Evan Cheng8f7f7122006-05-05 05:40:20 +0000355// Truncate
Evan Cheng069287d2006-05-16 07:21:53 +0000356def TRUNC_GR32_GR8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR32_:$src),
Evan Chengcbe70e12006-05-31 22:34:26 +0000357 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000358def TRUNC_GR16_GR8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR16_:$src),
Evan Chengcbe70e12006-05-31 22:34:26 +0000359 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000360def TRUNC_GR32_GR16 : I<0x89, MRMDestReg, (ops GR16:$dst, GR32:$src),
Evan Chengcbe70e12006-05-31 22:34:26 +0000361 "mov{w} {${src:subreg16}, $dst|$dst, ${src:subreg16}}",
Evan Cheng069287d2006-05-16 07:21:53 +0000362 [(set GR16:$dst, (trunc GR32:$src))]>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000363
Chris Lattner1cca5e32003-08-03 21:54:21 +0000364//===----------------------------------------------------------------------===//
365// Control Flow Instructions...
366//
367
Chris Lattner1be48112005-05-13 17:56:48 +0000368// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000369let isTerminator = 1, isReturn = 1, isBarrier = 1,
370 hasCtrlDep = 1, noResults = 1 in {
Evan Chenge3413162006-01-09 18:33:28 +0000371 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
372 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
373 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000374}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000375
376// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng2b4ea792005-12-26 09:11:45 +0000377let isBranch = 1, isTerminator = 1, noResults = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000378 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
379 I<opcode, RawFrm, ops, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000380
Nate Begeman37efe672006-04-22 18:53:45 +0000381// Indirect branches
Chris Lattner62cce392004-07-31 02:10:53 +0000382let isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000383 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000384
Nate Begeman37efe672006-04-22 18:53:45 +0000385let isBranch = 1, isTerminator = 1, noResults = 1, isBarrier = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000386 def JMP32r : I<0xFF, MRM4r, (ops GR32:$dst), "jmp{l} {*}$dst",
387 [(brind GR32:$dst)]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000388 def JMP32m : I<0xFF, MRM4m, (ops i32mem:$dst), "jmp{l} {*}$dst",
Evan Cheng09e3c802006-05-19 18:40:54 +0000389 [(brind (loadiPTR addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000390}
391
392// Conditional branches
Evan Cheng898101c2005-12-19 23:12:38 +0000393def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000394 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000395def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000396 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000397def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000398 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000399def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000400 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000401def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000402 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000403def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000404 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000405
Evan Chengd35b8c12005-12-04 08:19:43 +0000406def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000407 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000408def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000409 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000410def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000411 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000412def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000413 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000414
Evan Chengd9558e02006-01-06 00:43:03 +0000415def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000416 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000417def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000418 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000419def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000420 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000421def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000422 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000423def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000424 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000425def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000426 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000427
428//===----------------------------------------------------------------------===//
429// Call Instructions...
430//
Evan Chenge3413162006-01-09 18:33:28 +0000431let isCall = 1, noResults = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000432 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000433 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Nate Begeman16b04f32005-07-15 00:38:55 +0000434 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengfae29942006-06-14 22:24:55 +0000435 def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst, variable_ops),
436 "call ${dst:call}", []>;
437 def CALL32r : I<0xFF, MRM2r, (ops GR32:$dst, variable_ops),
438 "call {*}$dst", [(X86call GR32:$dst)]>;
439 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst, variable_ops),
440 "call {*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000441 }
442
Chris Lattner1e9448b2005-05-15 03:10:37 +0000443// Tail call stuff.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000444let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Chris Lattnera3b8c572006-02-06 23:41:19 +0000445 def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call} # TAIL CALL", []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000446let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Cheng069287d2006-05-16 07:21:53 +0000447 def TAILJMPr : I<0xFF, MRM4r, (ops GR32:$dst), "jmp {*}$dst # TAIL CALL", []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000448let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000449 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
450 "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000451
452// ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
453// way, except that it is marked as being a terminator. This causes the epilog
454// inserter to insert reloads of callee saved registers BEFORE this. We need
455// this until we have a more accurate way of tracking where the stack pointer is
456// within a function.
457let isTerminator = 1, isTwoAddress = 1 in
Evan Cheng069287d2006-05-16 07:21:53 +0000458 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000459 "add{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000460
Chris Lattner1cca5e32003-08-03 21:54:21 +0000461//===----------------------------------------------------------------------===//
462// Miscellaneous Instructions...
463//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000464def LEAVE : I<0xC9, RawFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000465 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000466def POP32r : I<0x58, AddRegFrm,
Evan Cheng069287d2006-05-16 07:21:53 +0000467 (ops GR32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000468
Evan Cheng7ccced62006-02-18 00:15:05 +0000469def MovePCtoStack : I<0, Pseudo, (ops piclabel:$label),
470 "call $label", []>;
471
Evan Cheng069287d2006-05-16 07:21:53 +0000472let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000473 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng069287d2006-05-16 07:21:53 +0000474 (ops GR32:$dst, GR32:$src),
Nate Begemand88fc032006-01-14 03:14:10 +0000475 "bswap{l} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000476 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000477
Evan Cheng069287d2006-05-16 07:21:53 +0000478def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
479 (ops GR8:$src1, GR8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000480 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000481def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
482 (ops GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000483 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000484def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
485 (ops GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000486 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattnerfc752712004-08-01 09:52:59 +0000487
Chris Lattner3a173df2004-10-03 20:35:00 +0000488def XCHG8mr : I<0x86, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000489 (ops i8mem:$src1, GR8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000490 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000491def XCHG16mr : I<0x87, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000492 (ops i16mem:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000493 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000494def XCHG32mr : I<0x87, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000495 (ops i32mem:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000496 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000497def XCHG8rm : I<0x86, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000498 (ops GR8:$src1, i8mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000499 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000500def XCHG16rm : I<0x87, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000501 (ops GR16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000502 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000503def XCHG32rm : I<0x87, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000504 (ops GR32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000505 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000506
Chris Lattner3a173df2004-10-03 20:35:00 +0000507def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000508 (ops GR16:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000509 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000510def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000511 (ops GR32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000512 "lea{l} {$src|$dst}, {$dst|$src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000513 [(set GR32:$dst, leaaddr:$src)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000514
Evan Cheng67f92a72006-01-11 22:15:48 +0000515def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
516 [(X86rep_movs i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000517 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000518def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
519 [(X86rep_movs i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000520 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Cheng94b14532006-06-02 21:09:10 +0000521def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsl|rep movsd}",
Evan Cheng67f92a72006-01-11 22:15:48 +0000522 [(X86rep_movs i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000523 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Chris Lattner915e5e52004-02-12 17:53:22 +0000524
Evan Cheng67f92a72006-01-11 22:15:48 +0000525def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
526 [(X86rep_stos i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000527 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000528def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
529 [(X86rep_stos i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000530 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Cheng67f92a72006-01-11 22:15:48 +0000531def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
532 [(X86rep_stos i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000533 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
534
Chris Lattnerb89abef2004-02-14 04:45:37 +0000535
Chris Lattner1cca5e32003-08-03 21:54:21 +0000536//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000537// Input/Output Instructions...
538//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000539def IN8rr : I<0xEC, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000540 "in{b} {%dx, %al|%AL, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000541 []>, Imp<[DX], [AL]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000542def IN16rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000543 "in{w} {%dx, %ax|%AX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000544 []>, Imp<[DX], [AX]>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000545def IN32rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000546 "in{l} {%dx, %eax|%EAX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000547 []>, Imp<[DX],[EAX]>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000548
Evan Chenga5386b02005-12-20 07:38:38 +0000549def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
550 "in{b} {$port, %al|%AL, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000551 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000552 Imp<[], [AL]>;
553def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
554 "in{w} {$port, %ax|%AX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000555 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000556 Imp<[], [AX]>, OpSize;
557def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
558 "in{l} {$port, %eax|%EAX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000559 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000560 Imp<[],[EAX]>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000561
Evan Cheng8d202232005-12-05 23:09:43 +0000562def OUT8rr : I<0xEE, RawFrm, (ops),
563 "out{b} {%al, %dx|%DX, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000564 []>, Imp<[DX, AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000565def OUT16rr : I<0xEF, RawFrm, (ops),
566 "out{w} {%ax, %dx|%DX, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000567 []>, Imp<[DX, AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000568def OUT32rr : I<0xEF, RawFrm, (ops),
569 "out{l} {%eax, %dx|%DX, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000570 []>, Imp<[DX, EAX], []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000571
Evan Cheng8d202232005-12-05 23:09:43 +0000572def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
573 "out{b} {%al, $port|$port, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000574 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000575 Imp<[AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000576def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
577 "out{w} {%ax, $port|$port, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000578 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000579 Imp<[AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000580def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
581 "out{l} {%eax, $port|$port, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000582 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000583 Imp<[EAX], []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000584
585//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000586// Move Instructions...
587//
Evan Cheng069287d2006-05-16 07:21:53 +0000588def MOV8rr : I<0x88, MRMDestReg, (ops GR8 :$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000589 "mov{b} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000590def MOV16rr : I<0x89, MRMDestReg, (ops GR16:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000591 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000592def MOV32rr : I<0x89, MRMDestReg, (ops GR32:$dst, GR32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000593 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000594def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops GR8 :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000595 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000596 [(set GR8:$dst, imm:$src)]>;
597def MOV16ri : Ii16<0xB8, AddRegFrm, (ops GR16:$dst, i16imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000598 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000599 [(set GR16:$dst, imm:$src)]>, OpSize;
600def MOV32ri : Ii32<0xB8, AddRegFrm, (ops GR32:$dst, i32imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000601 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000602 [(set GR32:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000603def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000604 "mov{b} {$src, $dst|$dst, $src}",
605 [(store (i8 imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000606def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000607 "mov{w} {$src, $dst|$dst, $src}",
608 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000609def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000610 "mov{l} {$src, $dst|$dst, $src}",
611 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000612
Evan Cheng069287d2006-05-16 07:21:53 +0000613def MOV8rm : I<0x8A, MRMSrcMem, (ops GR8 :$dst, i8mem :$src),
Evan Chengec693f72005-12-08 02:01:35 +0000614 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000615 [(set GR8:$dst, (load addr:$src))]>;
616def MOV16rm : I<0x8B, MRMSrcMem, (ops GR16:$dst, i16mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000617 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000618 [(set GR16:$dst, (load addr:$src))]>, OpSize;
619def MOV32rm : I<0x8B, MRMSrcMem, (ops GR32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000620 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000621 [(set GR32:$dst, (load addr:$src))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000622
Evan Cheng069287d2006-05-16 07:21:53 +0000623def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, GR8 :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000624 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000625 [(store GR8:$src, addr:$dst)]>;
626def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000627 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000628 [(store GR16:$src, addr:$dst)]>, OpSize;
629def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000630 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000631 [(store GR32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000632
Chris Lattner1cca5e32003-08-03 21:54:21 +0000633//===----------------------------------------------------------------------===//
634// Fixed-Register Multiplication and Division Instructions...
635//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000636
Chris Lattnerc8f45872003-08-04 04:59:56 +0000637// Extra precision multiplication
Evan Cheng069287d2006-05-16 07:21:53 +0000638def MUL8r : I<0xF6, MRM4r, (ops GR8:$src), "mul{b} $src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000639 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
640 // This probably ought to be moved to a def : Pat<> if the
641 // syntax can be accepted.
Evan Cheng069287d2006-05-16 07:21:53 +0000642 [(set AL, (mul AL, GR8:$src))]>,
643 Imp<[AL],[AX]>; // AL,AH = AL*GR8
644def MUL16r : I<0xF7, MRM4r, (ops GR16:$src), "mul{w} $src", []>,
645 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
646def MUL32r : I<0xF7, MRM4r, (ops GR32:$src), "mul{l} $src", []>,
647 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Chris Lattner57a02302004-08-11 04:31:00 +0000648def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
Evan Chengcf74a7c2006-01-15 10:05:20 +0000649 "mul{b} $src",
650 // 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.
653 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
654 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner57a02302004-08-11 04:31:00 +0000655def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000656 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
657 OpSize; // AX,DX = AX*[mem16]
Chris Lattner57a02302004-08-11 04:31:00 +0000658def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000659 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000660
Evan Cheng069287d2006-05-16 07:21:53 +0000661def IMUL8r : I<0xF6, MRM5r, (ops GR8:$src), "imul{b} $src", []>,
662 Imp<[AL],[AX]>; // AL,AH = AL*GR8
663def IMUL16r : I<0xF7, MRM5r, (ops GR16:$src), "imul{w} $src", []>,
664 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
665def IMUL32r : I<0xF7, MRM5r, (ops GR32:$src), "imul{l} $src", []>,
666 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Chris Lattner1e6a7152005-04-06 04:19:22 +0000667def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000668 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000669def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000670 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
671 OpSize; // AX,DX = AX*[mem16]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000672def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000673 "imul{l} $src", []>,
674 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000675
Chris Lattnerc8f45872003-08-04 04:59:56 +0000676// unsigned division/remainder
Evan Cheng069287d2006-05-16 07:21:53 +0000677def DIV8r : I<0xF6, MRM6r, (ops GR8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000678 "div{b} $src", []>, Imp<[AX],[AX]>;
Evan Cheng069287d2006-05-16 07:21:53 +0000679def DIV16r : I<0xF7, MRM6r, (ops GR16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000680 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000681def DIV32r : I<0xF7, MRM6r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000682 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000683def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000684 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000685def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000686 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000687def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000688 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000689
Chris Lattnerfc752712004-08-01 09:52:59 +0000690// Signed division/remainder.
Evan Cheng069287d2006-05-16 07:21:53 +0000691def IDIV8r : I<0xF6, MRM7r, (ops GR8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000692 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Evan Cheng069287d2006-05-16 07:21:53 +0000693def IDIV16r: I<0xF7, MRM7r, (ops GR16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000694 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000695def IDIV32r: I<0xF7, MRM7r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000696 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000697def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000698 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000699def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000700 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000701def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000702 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattnerc8f45872003-08-04 04:59:56 +0000703
Chris Lattner1cca5e32003-08-03 21:54:21 +0000704
Chris Lattner1cca5e32003-08-03 21:54:21 +0000705//===----------------------------------------------------------------------===//
706// Two address Instructions...
707//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000708let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000709
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000710// Conditional moves
Evan Cheng069287d2006-05-16 07:21:53 +0000711def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
712 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000713 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000714 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000715 X86_COND_B))]>,
716 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000717def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
718 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000719 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000720 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000721 X86_COND_B))]>,
722 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000723def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
724 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000725 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000726 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000727 X86_COND_B))]>,
728 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000729def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
730 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000731 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000732 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000733 X86_COND_B))]>,
734 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000735
Evan Cheng069287d2006-05-16 07:21:53 +0000736def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
737 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000738 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000739 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000740 X86_COND_AE))]>,
741 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000742def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
743 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000744 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000745 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000746 X86_COND_AE))]>,
747 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000748def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
749 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000750 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000751 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000752 X86_COND_AE))]>,
753 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000754def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
755 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000756 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000757 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000758 X86_COND_AE))]>,
759 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000760
Evan Cheng069287d2006-05-16 07:21:53 +0000761def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
762 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000763 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000764 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000765 X86_COND_E))]>,
766 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000767def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
768 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000769 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000770 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000771 X86_COND_E))]>,
772 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000773def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
774 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000775 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000776 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000777 X86_COND_E))]>,
778 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000779def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
780 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000781 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000782 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000783 X86_COND_E))]>,
784 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000785
Evan Cheng069287d2006-05-16 07:21:53 +0000786def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
787 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000788 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000789 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000790 X86_COND_NE))]>,
791 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000792def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
793 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000794 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000795 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000796 X86_COND_NE))]>,
797 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000798def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
799 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000800 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000801 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000802 X86_COND_NE))]>,
803 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000804def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
805 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000806 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000807 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000808 X86_COND_NE))]>,
809 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000810
Evan Cheng069287d2006-05-16 07:21:53 +0000811def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
812 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000813 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000814 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000815 X86_COND_BE))]>,
816 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000817def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
818 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000819 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000820 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000821 X86_COND_BE))]>,
822 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000823def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
824 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000825 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000826 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000827 X86_COND_BE))]>,
828 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000829def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
830 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000831 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000832 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000833 X86_COND_BE))]>,
834 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000835
Evan Cheng069287d2006-05-16 07:21:53 +0000836def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
837 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000838 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000839 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000840 X86_COND_A))]>,
841 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000842def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
843 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000844 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000845 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000846 X86_COND_A))]>,
847 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000848def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
849 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000850 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000851 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000852 X86_COND_A))]>,
853 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000854def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
855 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000856 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000857 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000858 X86_COND_A))]>,
859 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000860
Evan Cheng069287d2006-05-16 07:21:53 +0000861def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
862 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000863 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000864 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000865 X86_COND_L))]>,
866 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000867def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
868 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000869 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000870 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000871 X86_COND_L))]>,
872 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000873def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
874 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000875 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000876 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000877 X86_COND_L))]>,
878 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000879def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
880 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000881 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000882 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000883 X86_COND_L))]>,
884 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000885
Evan Cheng069287d2006-05-16 07:21:53 +0000886def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
887 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000888 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000889 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000890 X86_COND_GE))]>,
891 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000892def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
893 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000894 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000895 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000896 X86_COND_GE))]>,
897 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000898def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
899 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000900 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000901 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000902 X86_COND_GE))]>,
903 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000904def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
905 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000906 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000907 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000908 X86_COND_GE))]>,
909 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000910
Evan Cheng069287d2006-05-16 07:21:53 +0000911def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
912 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000913 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000914 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000915 X86_COND_LE))]>,
916 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000917def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
918 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000919 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000920 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000921 X86_COND_LE))]>,
922 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000923def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
924 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000925 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000926 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000927 X86_COND_LE))]>,
928 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000929def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
930 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000931 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000932 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000933 X86_COND_LE))]>,
934 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000935
Evan Cheng069287d2006-05-16 07:21:53 +0000936def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
937 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000938 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000939 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000940 X86_COND_G))]>,
941 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000942def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
943 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000944 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000945 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000946 X86_COND_G))]>,
947 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000948def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
949 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000950 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000951 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000952 X86_COND_G))]>,
953 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000954def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
955 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000956 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000957 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000958 X86_COND_G))]>,
959 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000960
Evan Cheng069287d2006-05-16 07:21:53 +0000961def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
962 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000963 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000964 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000965 X86_COND_S))]>,
966 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000967def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
968 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000969 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000970 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000971 X86_COND_S))]>,
972 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000973def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
974 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000975 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000976 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000977 X86_COND_S))]>,
978 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000979def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
980 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000981 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000982 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000983 X86_COND_S))]>,
984 TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000985
Evan Cheng069287d2006-05-16 07:21:53 +0000986def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
987 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000988 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000989 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000990 X86_COND_NS))]>,
991 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000992def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
993 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000994 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000995 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000996 X86_COND_NS))]>,
997 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000998def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
999 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001000 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001001 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001002 X86_COND_NS))]>,
1003 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001004def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1005 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001006 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001007 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001008 X86_COND_NS))]>,
1009 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001010
Evan Cheng069287d2006-05-16 07:21:53 +00001011def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1012 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001013 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001014 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001015 X86_COND_P))]>,
1016 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001017def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1018 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001019 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001020 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001021 X86_COND_P))]>,
1022 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001023def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1024 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001025 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001026 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001027 X86_COND_P))]>,
1028 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001029def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1030 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001031 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001032 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001033 X86_COND_P))]>,
1034 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001035
Evan Cheng069287d2006-05-16 07:21:53 +00001036def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1037 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001038 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001039 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001040 X86_COND_NP))]>,
1041 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001042def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1043 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001044 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001045 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001046 X86_COND_NP))]>,
1047 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001048def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1049 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001050 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001051 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001052 X86_COND_NP))]>,
1053 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001054def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1055 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001056 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001057 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001058 X86_COND_NP))]>,
1059 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001060
1061
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001062// unary instructions
Evan Cheng069287d2006-05-16 07:21:53 +00001063def NEG8r : I<0xF6, MRM3r, (ops GR8 :$dst, GR8 :$src), "neg{b} $dst",
1064 [(set GR8:$dst, (ineg GR8:$src))]>;
1065def NEG16r : I<0xF7, MRM3r, (ops GR16:$dst, GR16:$src), "neg{w} $dst",
1066 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1067def NEG32r : I<0xF7, MRM3r, (ops GR32:$dst, GR32:$src), "neg{l} $dst",
1068 [(set GR32:$dst, (ineg GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001069let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001070 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001071 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001072 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001073 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001074 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001075 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1076
Chris Lattner57a02302004-08-11 04:31:00 +00001077}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001078
Evan Cheng069287d2006-05-16 07:21:53 +00001079def NOT8r : I<0xF6, MRM2r, (ops GR8 :$dst, GR8 :$src), "not{b} $dst",
1080 [(set GR8:$dst, (not GR8:$src))]>;
1081def NOT16r : I<0xF7, MRM2r, (ops GR16:$dst, GR16:$src), "not{w} $dst",
1082 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1083def NOT32r : I<0xF7, MRM2r, (ops GR32:$dst, GR32:$src), "not{l} $dst",
1084 [(set GR32:$dst, (not GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001085let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001086 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001087 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001088 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001089 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001090 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001091 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001092}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001093
Evan Chengb51a0592005-12-10 00:48:20 +00001094// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng069287d2006-05-16 07:21:53 +00001095def INC8r : I<0xFE, MRM0r, (ops GR8 :$dst, GR8 :$src), "inc{b} $dst",
1096 [(set GR8:$dst, (add GR8:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001097let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengf7eb5d02006-07-11 19:49:49 +00001098def INC16r : I<0x40, AddRegFrm, (ops GR16:$dst, GR16:$src), "inc{w} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001099 [(set GR16:$dst, (add GR16:$src, 1))]>, OpSize;
Evan Chengf7eb5d02006-07-11 19:49:49 +00001100def INC32r : I<0x40, AddRegFrm, (ops GR32:$dst, GR32:$src), "inc{l} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001101 [(set GR32:$dst, (add GR32:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001102}
Chris Lattner57a02302004-08-11 04:31:00 +00001103let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001104 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001105 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001106 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001107 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001108 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001109 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001110}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001111
Evan Cheng069287d2006-05-16 07:21:53 +00001112def DEC8r : I<0xFE, MRM1r, (ops GR8 :$dst, GR8 :$src), "dec{b} $dst",
1113 [(set GR8:$dst, (add GR8:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001114let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengf7eb5d02006-07-11 19:49:49 +00001115def DEC16r : I<0x48, AddRegFrm, (ops GR16:$dst, GR16:$src), "dec{w} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001116 [(set GR16:$dst, (add GR16:$src, -1))]>, OpSize;
Evan Chengf7eb5d02006-07-11 19:49:49 +00001117def DEC32r : I<0x48, AddRegFrm, (ops GR32:$dst, GR32:$src), "dec{l} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001118 [(set GR32:$dst, (add GR32:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001119}
Chris Lattner57a02302004-08-11 04:31:00 +00001120
1121let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001122 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001123 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001124 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001125 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001126 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001127 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001128}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001129
1130// Logical operators...
Chris Lattnercc65bee2005-01-02 02:35:46 +00001131let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001132def AND8rr : I<0x20, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001133 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001134 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001135 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001136def AND16rr : I<0x21, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001137 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001138 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001139 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001140def AND32rr : I<0x21, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001141 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001142 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001143 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001144}
Chris Lattner57a02302004-08-11 04:31:00 +00001145
Chris Lattner3a173df2004-10-03 20:35:00 +00001146def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001147 (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001148 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001149 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001150def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001151 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001152 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001153 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001154def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001155 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001156 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001157 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001158
Chris Lattner3a173df2004-10-03 20:35:00 +00001159def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001160 (ops GR8 :$dst, GR8 :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001161 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001162 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001163def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001164 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001165 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001166 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001167def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001168 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001169 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001170 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001171def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001172 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001173 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001174 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001175 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001176def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001177 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001178 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001179 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001180
1181let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001182 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001183 (ops i8mem :$dst, GR8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001184 "and{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001185 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001186 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001187 (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001188 "and{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001189 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001190 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001191 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001192 (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001193 "and{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001194 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001195 def AND8mi : Ii8<0x80, MRM4m,
1196 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001197 "and{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001198 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001199 def AND16mi : Ii16<0x81, MRM4m,
1200 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001201 "and{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001202 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001203 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001204 def AND32mi : Ii32<0x81, MRM4m,
1205 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001206 "and{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001207 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001208 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001209 (ops i16mem:$dst, i16i8imm :$src),
1210 "and{w} {$src, $dst|$dst, $src}",
1211 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1212 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001213 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001214 (ops i32mem:$dst, i32i8imm :$src),
1215 "and{l} {$src, $dst|$dst, $src}",
Evan Chenge3703d42006-01-14 01:18:49 +00001216 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001217}
1218
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001219
Chris Lattnercc65bee2005-01-02 02:35:46 +00001220let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001221def OR8rr : I<0x08, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001222 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001223 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1224def OR16rr : I<0x09, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001225 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001226 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1227def OR32rr : I<0x09, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001228 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001229 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001230}
Evan Cheng069287d2006-05-16 07:21:53 +00001231def OR8rm : I<0x0A, MRMSrcMem , (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001232 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001233 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1234def OR16rm : I<0x0B, MRMSrcMem , (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001235 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001236 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1237def OR32rm : I<0x0B, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001238 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001239 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001240
Evan Cheng069287d2006-05-16 07:21:53 +00001241def OR8ri : Ii8 <0x80, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001242 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001243 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1244def OR16ri : Ii16<0x81, MRM1r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001245 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001246 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1247def OR32ri : Ii32<0x81, MRM1r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001248 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001249 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001250
Evan Cheng069287d2006-05-16 07:21:53 +00001251def OR16ri8 : Ii8<0x83, MRM1r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001252 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001253 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1254def OR32ri8 : Ii8<0x83, MRM1r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001255 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001256 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001257let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001258 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, GR8:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001259 "or{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001260 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1261 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001262 "or{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001263 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1264 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001265 "or{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001266 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001267 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001268 "or{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001269 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001270 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001271 "or{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001272 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001273 OpSize;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001274 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001275 "or{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001276 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng0ef3a772005-12-13 01:41:36 +00001277 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1278 "or{w} {$src, $dst|$dst, $src}",
1279 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1280 OpSize;
1281 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1282 "or{l} {$src, $dst|$dst, $src}",
1283 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001284}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001285
1286
Chris Lattnercc65bee2005-01-02 02:35:46 +00001287let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001288def XOR8rr : I<0x30, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001289 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001290 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001291 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001292def XOR16rr : I<0x31, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001293 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001294 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001295 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001296def XOR32rr : I<0x31, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001297 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001298 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001299 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001300}
1301
Chris Lattner3a173df2004-10-03 20:35:00 +00001302def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001303 (ops GR8 :$dst, GR8:$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001304 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001305 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001306def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001307 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001308 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001309 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001310def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001311 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001312 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001313 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001314
Chris Lattner3a173df2004-10-03 20:35:00 +00001315def XOR8ri : Ii8<0x80, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001316 (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001317 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001318 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001319def XOR16ri : Ii16<0x81, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001320 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001321 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001322 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001323def XOR32ri : Ii32<0x81, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001324 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001325 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001326 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001327def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001328 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001329 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001330 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001331 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001332def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001333 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001334 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001335 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001336let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001337 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001338 (ops i8mem :$dst, GR8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001339 "xor{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001340 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001341 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001342 (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001343 "xor{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001344 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001345 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001346 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001347 (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001348 "xor{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001349 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001350 def XOR8mi : Ii8<0x80, MRM6m,
1351 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001352 "xor{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001353 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001354 def XOR16mi : Ii16<0x81, MRM6m,
1355 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001356 "xor{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001357 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001358 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001359 def XOR32mi : Ii32<0x81, MRM6m,
1360 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001361 "xor{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001362 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001363 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001364 (ops i16mem:$dst, i16i8imm :$src),
1365 "xor{w} {$src, $dst|$dst, $src}",
1366 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1367 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001368 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001369 (ops i32mem:$dst, i32i8imm :$src),
1370 "xor{l} {$src, $dst|$dst, $src}",
1371 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001372}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001373
1374// Shift instructions
Evan Cheng069287d2006-05-16 07:21:53 +00001375def SHL8rCL : I<0xD2, MRM4r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001376 "shl{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001377 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
1378def SHL16rCL : I<0xD3, MRM4r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001379 "shl{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001380 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1381def SHL32rCL : I<0xD3, MRM4r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001382 "shl{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001383 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001384
Evan Cheng069287d2006-05-16 07:21:53 +00001385def SHL8ri : Ii8<0xC0, MRM4r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001386 "shl{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001387 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001388let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001389def SHL16ri : Ii8<0xC1, MRM4r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001390 "shl{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001391 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1392def SHL32ri : Ii8<0xC1, MRM4r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001393 "shl{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001394 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001395}
Chris Lattnerf29ed092004-08-11 05:07:25 +00001396
Evan Cheng09c54572006-06-29 00:36:51 +00001397// Shift left by one. Not used because (add x, x) is slightly cheaper.
1398def SHL8r1 : I<0xD0, MRM4r, (ops GR8 :$dst, GR8 :$src1),
1399 "shl{b} {$dst|$dst}", []>;
1400def SHL16r1 : I<0xD1, MRM4r, (ops GR16:$dst, GR16:$src1),
1401 "shl{w} {$dst|$dst}", []>, OpSize;
1402def SHL32r1 : I<0xD1, MRM4r, (ops GR32:$dst, GR32:$src1),
1403 "shl{l} {$dst|$dst}", []>;
1404
Chris Lattnerf29ed092004-08-11 05:07:25 +00001405let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001406 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001407 "shl{b} {%cl, $dst|$dst, %CL}",
1408 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1409 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001410 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001411 "shl{w} {%cl, $dst|$dst, %CL}",
1412 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1413 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001414 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001415 "shl{l} {%cl, $dst|$dst, %CL}",
1416 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1417 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001418 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001419 "shl{b} {$src, $dst|$dst, $src}",
1420 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001421 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001422 "shl{w} {$src, $dst|$dst, $src}",
1423 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1424 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001425 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001426 "shl{l} {$src, $dst|$dst, $src}",
1427 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001428
1429 // Shift by 1
1430 def SHL8m1 : I<0xD0, MRM4m, (ops i8mem :$dst),
1431 "shl{b} $dst",
1432 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1433 def SHL16m1 : I<0xD1, MRM4m, (ops i16mem:$dst),
1434 "shl{w} $dst",
1435 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1436 OpSize;
1437 def SHL32m1 : I<0xD1, MRM4m, (ops i32mem:$dst),
1438 "shl{l} $dst",
1439 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001440}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001441
Evan Cheng069287d2006-05-16 07:21:53 +00001442def SHR8rCL : I<0xD2, MRM5r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001443 "shr{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001444 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
1445def SHR16rCL : I<0xD3, MRM5r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001446 "shr{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001447 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1448def SHR32rCL : I<0xD3, MRM5r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001449 "shr{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001450 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001451
Evan Cheng069287d2006-05-16 07:21:53 +00001452def SHR8ri : Ii8<0xC0, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001453 "shr{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001454 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1455def SHR16ri : Ii8<0xC1, MRM5r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001456 "shr{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001457 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1458def SHR32ri : Ii8<0xC1, MRM5r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001459 "shr{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001460 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001461
Evan Cheng09c54572006-06-29 00:36:51 +00001462// Shift by 1
1463def SHR8r1 : I<0xD0, MRM5r, (ops GR8:$dst, GR8:$src1),
1464 "shr{b} $dst",
1465 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1466def SHR16r1 : I<0xD1, MRM5r, (ops GR16:$dst, GR16:$src1),
1467 "shr{w} $dst",
1468 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1469def SHR32r1 : I<0xD1, MRM5r, (ops GR32:$dst, GR32:$src1),
1470 "shr{l} $dst",
1471 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1472
Chris Lattner57a02302004-08-11 04:31:00 +00001473let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001474 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001475 "shr{b} {%cl, $dst|$dst, %CL}",
1476 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1477 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001478 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001479 "shr{w} {%cl, $dst|$dst, %CL}",
1480 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1481 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001482 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001483 "shr{l} {%cl, $dst|$dst, %CL}",
1484 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1485 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001486 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001487 "shr{b} {$src, $dst|$dst, $src}",
1488 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001489 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001490 "shr{w} {$src, $dst|$dst, $src}",
1491 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1492 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001493 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001494 "shr{l} {$src, $dst|$dst, $src}",
1495 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001496
1497 // Shift by 1
1498 def SHR8m1 : I<0xD0, MRM5m, (ops i8mem :$dst),
1499 "shr{b} $dst",
1500 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1501 def SHR16m1 : I<0xD1, MRM5m, (ops i16mem:$dst),
1502 "shr{w} $dst",
1503 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1504 def SHR32m1 : I<0xD1, MRM5m, (ops i32mem:$dst),
1505 "shr{l} $dst",
1506 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001507}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001508
Evan Cheng069287d2006-05-16 07:21:53 +00001509def SAR8rCL : I<0xD2, MRM7r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001510 "sar{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001511 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
1512def SAR16rCL : I<0xD3, MRM7r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001513 "sar{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001514 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1515def SAR32rCL : I<0xD3, MRM7r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001516 "sar{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001517 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001518
Evan Cheng069287d2006-05-16 07:21:53 +00001519def SAR8ri : Ii8<0xC0, MRM7r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001520 "sar{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001521 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1522def SAR16ri : Ii8<0xC1, MRM7r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001523 "sar{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001524 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001525 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001526def SAR32ri : Ii8<0xC1, MRM7r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001527 "sar{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001528 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001529
1530// Shift by 1
1531def SAR8r1 : I<0xD0, MRM7r, (ops GR8 :$dst, GR8 :$src1),
1532 "sar{b} $dst",
1533 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1534def SAR16r1 : I<0xD1, MRM7r, (ops GR16:$dst, GR16:$src1),
1535 "sar{w} $dst",
1536 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1537def SAR32r1 : I<0xD1, MRM7r, (ops GR32:$dst, GR32:$src1),
1538 "sar{l} $dst",
1539 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1540
Chris Lattnerf29ed092004-08-11 05:07:25 +00001541let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001542 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001543 "sar{b} {%cl, $dst|$dst, %CL}",
1544 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1545 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001546 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001547 "sar{w} {%cl, $dst|$dst, %CL}",
1548 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1549 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001550 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001551 "sar{l} {%cl, $dst|$dst, %CL}",
1552 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1553 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001554 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001555 "sar{b} {$src, $dst|$dst, $src}",
1556 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001557 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001558 "sar{w} {$src, $dst|$dst, $src}",
1559 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1560 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001561 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001562 "sar{l} {$src, $dst|$dst, $src}",
1563 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001564
1565 // Shift by 1
1566 def SAR8m1 : I<0xD0, MRM7m, (ops i8mem :$dst),
1567 "sar{b} $dst",
1568 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1569 def SAR16m1 : I<0xD1, MRM7m, (ops i16mem:$dst),
1570 "sar{w} $dst",
1571 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1572 OpSize;
1573 def SAR32m1 : I<0xD1, MRM7m, (ops i32mem:$dst),
1574 "sar{l} $dst",
1575 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001576}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001577
Chris Lattner40ff6332005-01-19 07:50:03 +00001578// Rotate instructions
1579// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng069287d2006-05-16 07:21:53 +00001580def ROL8rCL : I<0xD2, MRM0r, (ops GR8 :$dst, GR8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001581 "rol{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001582 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
1583def ROL16rCL : I<0xD3, MRM0r, (ops GR16:$dst, GR16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001584 "rol{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001585 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1586def ROL32rCL : I<0xD3, MRM0r, (ops GR32:$dst, GR32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001587 "rol{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001588 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001589
Evan Cheng069287d2006-05-16 07:21:53 +00001590def ROL8ri : Ii8<0xC0, MRM0r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001591 "rol{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001592 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1593def ROL16ri : Ii8<0xC1, MRM0r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001594 "rol{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001595 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1596def ROL32ri : Ii8<0xC1, MRM0r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001597 "rol{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001598 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001599
Evan Cheng09c54572006-06-29 00:36:51 +00001600// Rotate by 1
1601def ROL8r1 : I<0xD0, MRM0r, (ops GR8 :$dst, GR8 :$src1),
1602 "rol{b} $dst",
1603 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1604def ROL16r1 : I<0xD1, MRM0r, (ops GR16:$dst, GR16:$src1),
1605 "rol{w} $dst",
1606 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1607def ROL32r1 : I<0xD1, MRM0r, (ops GR32:$dst, GR32:$src1),
1608 "rol{l} $dst",
1609 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1610
Chris Lattner40ff6332005-01-19 07:50:03 +00001611let isTwoAddress = 0 in {
1612 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001613 "rol{b} {%cl, $dst|$dst, %CL}",
1614 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1615 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001616 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001617 "rol{w} {%cl, $dst|$dst, %CL}",
1618 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1619 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001620 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001621 "rol{l} {%cl, $dst|$dst, %CL}",
1622 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1623 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001624 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001625 "rol{b} {$src, $dst|$dst, $src}",
1626 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001627 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001628 "rol{w} {$src, $dst|$dst, $src}",
1629 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1630 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001631 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001632 "rol{l} {$src, $dst|$dst, $src}",
1633 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001634
1635 // Rotate by 1
1636 def ROL8m1 : I<0xD0, MRM0m, (ops i8mem :$dst),
1637 "rol{b} $dst",
1638 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1639 def ROL16m1 : I<0xD1, MRM0m, (ops i16mem:$dst),
1640 "rol{w} $dst",
1641 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1642 OpSize;
1643 def ROL32m1 : I<0xD1, MRM0m, (ops i32mem:$dst),
1644 "rol{l} $dst",
1645 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001646}
1647
Evan Cheng069287d2006-05-16 07:21:53 +00001648def ROR8rCL : I<0xD2, MRM1r, (ops GR8 :$dst, GR8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001649 "ror{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001650 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
1651def ROR16rCL : I<0xD3, MRM1r, (ops GR16:$dst, GR16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001652 "ror{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001653 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1654def ROR32rCL : I<0xD3, MRM1r, (ops GR32:$dst, GR32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001655 "ror{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001656 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001657
Evan Cheng069287d2006-05-16 07:21:53 +00001658def ROR8ri : Ii8<0xC0, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001659 "ror{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001660 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1661def ROR16ri : Ii8<0xC1, MRM1r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001662 "ror{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001663 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1664def ROR32ri : Ii8<0xC1, MRM1r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001665 "ror{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001666 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001667
1668// Rotate by 1
1669def ROR8r1 : I<0xD0, MRM1r, (ops GR8 :$dst, GR8 :$src1),
1670 "ror{b} $dst",
1671 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1672def ROR16r1 : I<0xD1, MRM1r, (ops GR16:$dst, GR16:$src1),
1673 "ror{w} $dst",
1674 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1675def ROR32r1 : I<0xD1, MRM1r, (ops GR32:$dst, GR32:$src1),
1676 "ror{l} $dst",
1677 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1678
Chris Lattner40ff6332005-01-19 07:50:03 +00001679let isTwoAddress = 0 in {
1680 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001681 "ror{b} {%cl, $dst|$dst, %CL}",
1682 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1683 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001684 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001685 "ror{w} {%cl, $dst|$dst, %CL}",
1686 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1687 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001688 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001689 "ror{l} {%cl, $dst|$dst, %CL}",
1690 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1691 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001692 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001693 "ror{b} {$src, $dst|$dst, $src}",
1694 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001695 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001696 "ror{w} {$src, $dst|$dst, $src}",
1697 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1698 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001699 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001700 "ror{l} {$src, $dst|$dst, $src}",
1701 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001702
1703 // Rotate by 1
1704 def ROR8m1 : I<0xD0, MRM1m, (ops i8mem :$dst),
1705 "ror{b} $dst",
1706 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1707 def ROR16m1 : I<0xD1, MRM1m, (ops i16mem:$dst),
1708 "ror{w} $dst",
1709 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1710 OpSize;
1711 def ROR32m1 : I<0xD1, MRM1m, (ops i32mem:$dst),
1712 "ror{l} $dst",
1713 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001714}
1715
1716
1717
1718// Double shift instructions (generalizations of rotate)
Evan Cheng069287d2006-05-16 07:21:53 +00001719def SHLD32rrCL : I<0xA5, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001720 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001721 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001722 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001723def SHRD32rrCL : I<0xAD, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001724 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001725 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001726 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001727def SHLD16rrCL : I<0xA5, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001728 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001729 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001730 Imp<[CL],[]>, TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001731def SHRD16rrCL : I<0xAD, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001732 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001733 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001734 Imp<[CL],[]>, TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001735
1736let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001737def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001738 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001739 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001740 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001741 (i8 imm:$src3)))]>,
1742 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001743def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001744 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001745 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001746 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001747 (i8 imm:$src3)))]>,
1748 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001749def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001750 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001751 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001752 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001753 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001754 TB, OpSize;
1755def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001756 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001757 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001758 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001759 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001760 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001761}
Chris Lattner0e967d42004-08-01 08:13:11 +00001762
Chris Lattner57a02302004-08-11 04:31:00 +00001763let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001764 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001765 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001766 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001767 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001768 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001769 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001770 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001771 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001772 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001773 Imp<[CL],[]>, TB;
1774 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001775 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001776 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001777 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001778 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001779 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001780 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001781 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001782 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001783 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001784 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001785 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001786
Evan Cheng069287d2006-05-16 07:21:53 +00001787 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001788 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001789 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001790 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001791 Imp<[CL],[]>, TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001792 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001793 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001794 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001795 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001796 Imp<[CL],[]>, TB, OpSize;
1797 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001798 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001799 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001800 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001801 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001802 TB, OpSize;
1803 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001804 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001805 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001806 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001807 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001808 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001809}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001810
1811
Chris Lattnercc65bee2005-01-02 02:35:46 +00001812// Arithmetic.
1813let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001814def ADD8rr : I<0x00, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001815 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001816 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001817let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001818def ADD16rr : I<0x01, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001819 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001820 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1821def ADD32rr : I<0x01, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001822 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001823 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001824} // end isConvertibleToThreeAddress
1825} // end isCommutable
Evan Cheng069287d2006-05-16 07:21:53 +00001826def ADD8rm : I<0x02, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001827 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001828 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1829def ADD16rm : I<0x03, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001830 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001831 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
1832def ADD32rm : I<0x03, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001833 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001834 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001835
Evan Cheng069287d2006-05-16 07:21:53 +00001836def ADD8ri : Ii8<0x80, MRM0r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001837 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001838 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001839
1840let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001841def ADD16ri : Ii16<0x81, MRM0r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001842 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001843 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1844def ADD32ri : Ii32<0x81, MRM0r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001845 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001846 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00001847def ADD16ri8 : Ii8<0x83, MRM0r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001848 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001849 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001850 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001851def ADD32ri8 : Ii8<0x83, MRM0r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001852 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001853 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00001854}
Chris Lattner57a02302004-08-11 04:31:00 +00001855
1856let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001857 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001858 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001859 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1860 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001861 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001862 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001863 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001864 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001865 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001866 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001867 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001868 "add{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001869 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001870 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001871 "add{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001872 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001873 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001874 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001875 "add{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001876 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengee93f9d2005-12-12 19:45:23 +00001877 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1878 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001879 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1880 OpSize;
Evan Chengee93f9d2005-12-12 19:45:23 +00001881 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1882 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001883 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001884}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001885
Chris Lattner10197ff2005-01-03 01:27:59 +00001886let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001887def ADC32rr : I<0x11, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001888 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001889 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001890}
Evan Cheng069287d2006-05-16 07:21:53 +00001891def ADC32rm : I<0x13, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001892 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001893 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1894def ADC32ri : Ii32<0x81, MRM2r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001895 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001896 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1897def ADC32ri8 : Ii8<0x83, MRM2r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001898 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001899 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001900
1901let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001902 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001903 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001904 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001905 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001906 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001907 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chenge3413162006-01-09 18:33:28 +00001908 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1909 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001910 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001911}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001912
Evan Cheng069287d2006-05-16 07:21:53 +00001913def SUB8rr : I<0x28, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001914 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001915 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1916def SUB16rr : I<0x29, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001917 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001918 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1919def SUB32rr : I<0x29, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001920 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001921 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1922def SUB8rm : I<0x2A, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001923 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001924 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1925def SUB16rm : I<0x2B, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001926 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001927 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1928def SUB32rm : I<0x2B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001929 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001930 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001931
Evan Cheng069287d2006-05-16 07:21:53 +00001932def SUB8ri : Ii8 <0x80, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001933 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001934 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1935def SUB16ri : Ii16<0x81, MRM5r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001936 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001937 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1938def SUB32ri : Ii32<0x81, MRM5r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001939 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001940 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1941def SUB16ri8 : Ii8<0x83, MRM5r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001942 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001943 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001944 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001945def SUB32ri8 : Ii8<0x83, MRM5r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001946 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001947 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001948let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001949 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001950 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001951 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
1952 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001953 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001954 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001955 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001956 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001957 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001958 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001959 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001960 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001961 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001962 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001963 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001964 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001965 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001966 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001967 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001968 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengd160d482005-12-12 21:54:05 +00001969 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1970 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001971 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1972 OpSize;
Evan Chengd160d482005-12-12 21:54:05 +00001973 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1974 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001975 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001976}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001977
Evan Cheng069287d2006-05-16 07:21:53 +00001978def SBB32rr : I<0x19, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001979 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001980 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001981
Chris Lattner57a02302004-08-11 04:31:00 +00001982let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001983 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001984 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001985 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001986 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001987 "sbb{b} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001988 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001989 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001990 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001991 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chenge3413162006-01-09 18:33:28 +00001992 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
1993 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001994 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001995}
Evan Cheng069287d2006-05-16 07:21:53 +00001996def SBB32rm : I<0x1B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001997 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001998 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
1999def SBB32ri : Ii32<0x81, MRM3r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002000 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002001 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2002def SBB32ri8 : Ii8<0x83, MRM3r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002003 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002004 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002005
Chris Lattner10197ff2005-01-03 01:27:59 +00002006let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00002007def IMUL16rr : I<0xAF, MRMSrcReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002008 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002009 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2010def IMUL32rr : I<0xAF, MRMSrcReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002011 "imul{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002012 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002013}
Evan Cheng069287d2006-05-16 07:21:53 +00002014def IMUL16rm : I<0xAF, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002015 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002016 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002017 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002018def IMUL32rm : I<0xAF, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002019 "imul{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002020 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002021
2022} // end Two Address instructions
2023
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002024// Suprisingly enough, these are not two address instructions!
Evan Cheng069287d2006-05-16 07:21:53 +00002025def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2026 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00002027 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002028 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2029def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2030 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00002031 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002032 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2033def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2034 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002035 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002036 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002037 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002038def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2039 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002040 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002041 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002042
Evan Cheng069287d2006-05-16 07:21:53 +00002043def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2044 (ops GR16:$dst, i16mem:$src1, i16imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002045 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002046 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
Evan Chengf281e022005-12-12 23:47:46 +00002047 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002048def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2049 (ops GR32:$dst, i32mem:$src1, i32imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002050 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002051 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2052def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2053 (ops GR16:$dst, i16mem:$src1, i16i8imm :$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002054 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002055 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002056 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002057def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2058 (ops GR32:$dst, i32mem:$src1, i32i8imm: $src2),
Evan Chengf281e022005-12-12 23:47:46 +00002059 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002060 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002061
2062//===----------------------------------------------------------------------===//
2063// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002064//
Chris Lattnercc65bee2005-01-02 02:35:46 +00002065let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng069287d2006-05-16 07:21:53 +00002066def TEST8rr : I<0x84, MRMDestReg, (ops GR8:$src1, GR8:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002067 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002068 [(X86test GR8:$src1, GR8:$src2)]>;
2069def TEST16rr : I<0x85, MRMDestReg, (ops GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002070 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002071 [(X86test GR16:$src1, GR16:$src2)]>, OpSize;
2072def TEST32rr : I<0x85, MRMDestReg, (ops GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002073 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002074 [(X86test GR32:$src1, GR32:$src2)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002075}
Evan Cheng069287d2006-05-16 07:21:53 +00002076def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, GR8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002077 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002078 [(X86test (loadi8 addr:$src1), GR8:$src2)]>;
2079def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002080 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002081 [(X86test (loadi16 addr:$src1), GR16:$src2)]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002082 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002083def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002084 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002085 [(X86test (loadi32 addr:$src1), GR32:$src2)]>;
2086def TEST8rm : I<0x84, MRMSrcMem, (ops GR8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002087 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002088 [(X86test GR8:$src1, (loadi8 addr:$src2))]>;
2089def TEST16rm : I<0x85, MRMSrcMem, (ops GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002090 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002091 [(X86test GR16:$src1, (loadi16 addr:$src2))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002092 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002093def TEST32rm : I<0x85, MRMSrcMem, (ops GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002094 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002095 [(X86test GR32:$src1, (loadi32 addr:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002096
Evan Cheng069287d2006-05-16 07:21:53 +00002097def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2098 (ops GR8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002099 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002100 [(X86test GR8:$src1, imm:$src2)]>;
2101def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2102 (ops GR16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002103 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002104 [(X86test GR16:$src1, imm:$src2)]>, OpSize;
2105def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2106 (ops GR32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002107 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002108 [(X86test GR32:$src1, imm:$src2)]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002109def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengaed7c722005-12-17 01:24:02 +00002110 (ops i8mem:$src1, i8imm:$src2),
2111 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002112 [(X86test (loadi8 addr:$src1), imm:$src2)]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002113def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2114 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002115 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002116 [(X86test (loadi16 addr:$src1), imm:$src2)]>,
2117 OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002118def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2119 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002120 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002121 [(X86test (loadi32 addr:$src1), imm:$src2)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002122
2123
2124// Condition code ops, incl. set if equal/not equal/...
Evan Chengf0701842005-11-29 19:38:52 +00002125def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2126def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002127
Chris Lattner3a173df2004-10-03 20:35:00 +00002128def SETEr : I<0x94, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002129 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002130 "sete $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002131 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2132 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002133def SETEm : I<0x94, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002134 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002135 "sete $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002136 [(store (X86setcc X86_COND_E), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002137 TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002138def SETNEr : I<0x95, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002139 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002140 "setne $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002141 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2142 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002143def SETNEm : I<0x95, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002144 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002145 "setne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002146 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002147 TB; // [mem8] = !=
2148def SETLr : I<0x9C, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002149 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002150 "setl $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002151 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2152 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002153def SETLm : I<0x9C, MRM0m,
2154 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002155 "setl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002156 [(store (X86setcc X86_COND_L), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002157 TB; // [mem8] = < signed
2158def SETGEr : I<0x9D, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002159 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002160 "setge $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002161 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2162 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002163def SETGEm : I<0x9D, MRM0m,
2164 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002165 "setge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002166 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002167 TB; // [mem8] = >= signed
2168def SETLEr : I<0x9E, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002169 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002170 "setle $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002171 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2172 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002173def SETLEm : I<0x9E, MRM0m,
2174 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002175 "setle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002176 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002177 TB; // [mem8] = <= signed
2178def SETGr : I<0x9F, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002179 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002180 "setg $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002181 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2182 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002183def SETGm : I<0x9F, MRM0m,
2184 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002185 "setg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002186 [(store (X86setcc X86_COND_G), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002187 TB; // [mem8] = > signed
2188
2189def SETBr : I<0x92, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002190 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002191 "setb $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002192 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2193 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002194def SETBm : I<0x92, MRM0m,
2195 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002196 "setb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002197 [(store (X86setcc X86_COND_B), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002198 TB; // [mem8] = < unsign
2199def SETAEr : I<0x93, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002200 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002201 "setae $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002202 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2203 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002204def SETAEm : I<0x93, MRM0m,
2205 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002206 "setae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002207 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002208 TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002209def SETBEr : I<0x96, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002210 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002211 "setbe $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002212 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2213 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002214def SETBEm : I<0x96, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002215 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002216 "setbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002217 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002218 TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002219def SETAr : I<0x97, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002220 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002221 "seta $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002222 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2223 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002224def SETAm : I<0x97, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002225 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002226 "seta $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002227 [(store (X86setcc X86_COND_A), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002228 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002229
Chris Lattner3a173df2004-10-03 20:35:00 +00002230def SETSr : I<0x98, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002231 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002232 "sets $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002233 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2234 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002235def SETSm : I<0x98, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002236 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002237 "sets $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002238 [(store (X86setcc X86_COND_S), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002239 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002240def SETNSr : I<0x99, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002241 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002242 "setns $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002243 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2244 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002245def SETNSm : I<0x99, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002246 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002247 "setns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002248 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002249 TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002250def SETPr : I<0x9A, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002251 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002252 "setp $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002253 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2254 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002255def SETPm : I<0x9A, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002256 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002257 "setp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002258 [(store (X86setcc X86_COND_P), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002259 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002260def SETNPr : I<0x9B, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002261 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002262 "setnp $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002263 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2264 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002265def SETNPm : I<0x9B, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002266 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002267 "setnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002268 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002269 TB; // [mem8] = not parity
Chris Lattner1cca5e32003-08-03 21:54:21 +00002270
2271// Integer comparisons
Chris Lattner3a173df2004-10-03 20:35:00 +00002272def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002273 (ops GR8 :$src1, GR8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002274 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002275 [(X86cmp GR8:$src1, GR8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002276def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002277 (ops GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002278 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002279 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002280def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002281 (ops GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002282 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002283 [(X86cmp GR32:$src1, GR32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002284def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002285 (ops i8mem :$src1, GR8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002286 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002287 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002288def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002289 (ops i16mem:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002290 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002291 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002292def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002293 (ops i32mem:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002294 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002295 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002296def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002297 (ops GR8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002298 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002299 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002300def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002301 (ops GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002302 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002303 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002304def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002305 (ops GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002306 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002307 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002308def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002309 (ops GR8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002310 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002311 [(X86cmp GR8:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002312def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002313 (ops GR16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002314 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002315 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002316def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002317 (ops GR32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002318 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002319 [(X86cmp GR32:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002320def CMP8mi : Ii8 <0x80, MRM7m,
2321 (ops i8mem :$src1, i8imm :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002322 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002323 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002324def CMP16mi : Ii16<0x81, MRM7m,
2325 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002326 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002327 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002328def CMP32mi : Ii32<0x81, MRM7m,
2329 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002330 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002331 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002332def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002333 (ops GR16:$src1, i16i8imm:$src2),
Nate Begemance944822006-03-23 01:29:48 +00002334 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002335 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002336def CMP16mi8 : Ii8<0x83, MRM7m,
Nate Begemance944822006-03-23 01:29:48 +00002337 (ops i16mem:$src1, i16i8imm:$src2),
2338 "cmp{w} {$src2, $src1|$src1, $src2}",
2339 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002340def CMP32mi8 : Ii8<0x83, MRM7m,
Nate Begemance944822006-03-23 01:29:48 +00002341 (ops i32mem:$src1, i32i8imm:$src2),
2342 "cmp{l} {$src2, $src1|$src1, $src2}",
2343 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002344def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002345 (ops GR32:$src1, i32i8imm:$src2),
Nate Begemance944822006-03-23 01:29:48 +00002346 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002347 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002348
2349// Sign/Zero extenders
Evan Cheng069287d2006-05-16 07:21:53 +00002350def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002351 "movs{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002352 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
2353def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002354 "movs{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002355 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2356def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002357 "movs{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002358 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2359def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002360 "movs{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002361 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2362def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops GR32:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002363 "movs{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002364 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2365def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002366 "movs{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002367 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002368
Evan Cheng069287d2006-05-16 07:21:53 +00002369def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002370 "movz{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002371 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
2372def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002373 "movz{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002374 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2375def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002376 "movz{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002377 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2378def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002379 "movz{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002380 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2381def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops GR32:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002382 "movz{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002383 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2384def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002385 "movz{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002386 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00002387
Evan Chengf91c1012006-05-31 22:05:11 +00002388def CBW : I<0x98, RawFrm, (ops),
2389 "{cbtw|cbw}", []>, Imp<[AL],[AX]>; // AX = signext(AL)
2390def CWDE : I<0x98, RawFrm, (ops),
2391 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2392
2393def CWD : I<0x99, RawFrm, (ops),
2394 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>; // DX:AX = signext(AX)
2395def CDQ : I<0x99, RawFrm, (ops),
2396 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2397
Nate Begemanf1702ac2005-06-27 21:20:31 +00002398//===----------------------------------------------------------------------===//
Evan Cheng747a90d2006-02-21 02:24:38 +00002399// Miscellaneous Instructions
2400//===----------------------------------------------------------------------===//
2401
2402def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
2403 TB, Imp<[],[EAX,EDX]>;
2404
Evan Cheng747a90d2006-02-21 02:24:38 +00002405//===----------------------------------------------------------------------===//
2406// Alias Instructions
2407//===----------------------------------------------------------------------===//
2408
2409// Alias instructions that map movr0 to xor.
2410// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Cheng069287d2006-05-16 07:21:53 +00002411def MOV8r0 : I<0x30, MRMInitReg, (ops GR8 :$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002412 "xor{b} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002413 [(set GR8:$dst, 0)]>;
2414def MOV16r0 : I<0x31, MRMInitReg, (ops GR16:$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002415 "xor{w} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002416 [(set GR16:$dst, 0)]>, OpSize;
2417def MOV32r0 : I<0x31, MRMInitReg, (ops GR32:$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002418 "xor{l} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002419 [(set GR32:$dst, 0)]>;
Evan Cheng747a90d2006-02-21 02:24:38 +00002420
Evan Cheng069287d2006-05-16 07:21:53 +00002421// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2422// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2423def MOV16to16_ : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002424 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002425def MOV32to32_ : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002426 "mov{l} {$src, $dst|$dst, $src}", []>;
2427
Evan Cheng069287d2006-05-16 07:21:53 +00002428def MOV16_rr : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002429 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002430def MOV32_rr : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002431 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +00002432def MOV16_rm : I<0x8B, MRMSrcMem, (ops GR16_:$dst, i16mem:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002433 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002434def MOV32_rm : I<0x8B, MRMSrcMem, (ops GR32_:$dst, i32mem:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002435 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +00002436def MOV16_mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002437 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002438def MOV32_mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002439 "mov{l} {$src, $dst|$dst, $src}", []>;
2440
Evan Cheng510e4782006-01-09 23:10:28 +00002441//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00002442// DWARF Pseudo Instructions
2443//
2444
2445def DWARF_LOC : I<0, Pseudo, (ops i32imm:$line, i32imm:$col, i32imm:$file),
2446 "; .loc $file, $line, $col",
2447 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2448 (i32 imm:$file))]>;
2449
2450def DWARF_LABEL : I<0, Pseudo, (ops i32imm:$id),
2451 "\nLdebug_loc${id:debug}:",
2452 [(dwarf_label (i32 imm:$id))]>;
2453
2454//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00002455// Non-Instruction Patterns
2456//===----------------------------------------------------------------------===//
2457
Evan Cheng71fb8342006-02-25 10:02:21 +00002458// ConstantPool GlobalAddress, ExternalSymbol
2459def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00002460def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002461def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2462def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2463
Evan Cheng069287d2006-05-16 07:21:53 +00002464def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2465 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2466def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2467 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2468def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2469 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2470def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2471 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002472
Evan Chengfc8feb12006-05-19 07:30:36 +00002473def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002474 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00002475def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002476 (MOV32mi addr:$dst, texternalsym:$src)>;
2477
Evan Cheng510e4782006-01-09 23:10:28 +00002478// Calls
Evan Cheng069287d2006-05-16 07:21:53 +00002479def : Pat<(X86tailcall GR32:$dst),
2480 (CALL32r GR32:$dst)>;
Evan Chengfea89c12006-04-27 08:40:39 +00002481
Evan Chengfea89c12006-04-27 08:40:39 +00002482def : Pat<(X86tailcall tglobaladdr:$dst),
2483 (CALLpcrel32 tglobaladdr:$dst)>;
2484def : Pat<(X86tailcall texternalsym:$dst),
2485 (CALLpcrel32 texternalsym:$dst)>;
2486
2487
2488
Evan Cheng510e4782006-01-09 23:10:28 +00002489def : Pat<(X86call tglobaladdr:$dst),
2490 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng8700e142006-01-11 06:09:51 +00002491def : Pat<(X86call texternalsym:$dst),
2492 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002493
2494// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00002495def : Pat<(addc GR32:$src1, GR32:$src2),
2496 (ADD32rr GR32:$src1, GR32:$src2)>;
2497def : Pat<(addc GR32:$src1, (load addr:$src2)),
2498 (ADD32rm GR32:$src1, addr:$src2)>;
2499def : Pat<(addc GR32:$src1, imm:$src2),
2500 (ADD32ri GR32:$src1, imm:$src2)>;
2501def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2502 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002503
Evan Cheng069287d2006-05-16 07:21:53 +00002504def : Pat<(subc GR32:$src1, GR32:$src2),
2505 (SUB32rr GR32:$src1, GR32:$src2)>;
2506def : Pat<(subc GR32:$src1, (load addr:$src2)),
2507 (SUB32rm GR32:$src1, addr:$src2)>;
2508def : Pat<(subc GR32:$src1, imm:$src2),
2509 (SUB32ri GR32:$src1, imm:$src2)>;
2510def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2511 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002512
Evan Chengb8414332006-01-13 21:45:19 +00002513def : Pat<(truncstore (i8 imm:$src), addr:$dst, i1),
2514 (MOV8mi addr:$dst, imm:$src)>;
Evan Cheng069287d2006-05-16 07:21:53 +00002515def : Pat<(truncstore GR8:$src, addr:$dst, i1),
2516 (MOV8mr addr:$dst, GR8:$src)>;
Evan Chengb8414332006-01-13 21:45:19 +00002517
Evan Cheng510e4782006-01-09 23:10:28 +00002518// {s|z}extload bool -> {s|z}extload byte
2519def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2520def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
Evan Chenge5d93432006-01-17 07:02:46 +00002521def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002522def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2523def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2524
2525// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00002526def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2527def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2528def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2529def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2530def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2531def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002532
2533// anyext -> zext
Evan Cheng069287d2006-05-16 07:21:53 +00002534def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2535def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2536def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng6e16ee52006-03-25 09:45:48 +00002537def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2538def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2539def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002540
Evan Chengcfa260b2006-01-06 02:31:59 +00002541//===----------------------------------------------------------------------===//
2542// Some peepholes
2543//===----------------------------------------------------------------------===//
2544
2545// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00002546def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2547def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2548def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002549
Evan Cheng956044c2006-01-19 23:26:24 +00002550// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002551def : Pat<(or (srl GR32:$src1, CL:$amt),
2552 (shl GR32:$src2, (sub 32, CL:$amt))),
2553 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002554
Evan Cheng21d54432006-01-20 01:13:30 +00002555def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002556 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2557 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002558
Evan Cheng956044c2006-01-19 23:26:24 +00002559// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002560def : Pat<(or (shl GR32:$src1, CL:$amt),
2561 (srl GR32:$src2, (sub 32, CL:$amt))),
2562 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002563
Evan Cheng21d54432006-01-20 01:13:30 +00002564def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002565 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2566 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002567
Evan Cheng956044c2006-01-19 23:26:24 +00002568// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002569def : Pat<(or (srl GR16:$src1, CL:$amt),
2570 (shl GR16:$src2, (sub 16, CL:$amt))),
2571 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002572
Evan Cheng21d54432006-01-20 01:13:30 +00002573def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002574 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2575 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002576
Evan Cheng956044c2006-01-19 23:26:24 +00002577// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002578def : Pat<(or (shl GR16:$src1, CL:$amt),
2579 (srl GR16:$src2, (sub 16, CL:$amt))),
2580 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002581
2582def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002583 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2584 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00002585
2586
2587//===----------------------------------------------------------------------===//
2588// Floating Point Stack Support
2589//===----------------------------------------------------------------------===//
2590
2591include "X86InstrFPStack.td"
2592
2593//===----------------------------------------------------------------------===//
2594// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2595//===----------------------------------------------------------------------===//
2596
2597include "X86InstrMMX.td"
2598
2599//===----------------------------------------------------------------------===//
2600// XMM Floating point support (requires SSE / SSE2)
2601//===----------------------------------------------------------------------===//
2602
2603include "X86InstrSSE.td"