blob: 77944ba6d70eb6c53c447b56c4f8f943904aa5ee [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,
Evan Chengbb7b8442006-08-11 09:03:33 +000070 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000071def 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;
Evan Cheng1693e482006-07-19 00:27:29 +0000317 let CodeSize = 3;
Evan Chengf0701842005-11-29 19:38:52 +0000318}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000319class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
320 : X86Inst<o, f, Imm8 , ops, asm> {
321 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000322 let CodeSize = 3;
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000323}
Chris Lattner78432fe2005-11-17 02:01:55 +0000324class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
325 : X86Inst<o, f, Imm16, ops, asm> {
326 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000327 let CodeSize = 3;
Chris Lattner78432fe2005-11-17 02:01:55 +0000328}
Chris Lattner7a125372005-11-16 22:59:19 +0000329class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
330 : X86Inst<o, f, Imm32, ops, asm> {
331 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000332 let CodeSize = 3;
Chris Lattner7a125372005-11-16 22:59:19 +0000333}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000334
Chris Lattner1cca5e32003-08-03 21:54:21 +0000335//===----------------------------------------------------------------------===//
336// Instruction list...
337//
338
Evan Chengd90eb7f2006-01-05 00:27:02 +0000339def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
Evan Chenge3413162006-01-09 18:33:28 +0000340 [(X86callseq_start imm:$amt)]>;
Chris Lattner43ef1312005-09-14 21:10:24 +0000341def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
Evan Chengd90eb7f2006-01-05 00:27:02 +0000342 "#ADJCALLSTACKUP",
Evan Chenge3413162006-01-09 18:33:28 +0000343 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
Evan Chengf0701842005-11-29 19:38:52 +0000344def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
345def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000346def IMPLICIT_DEF_GR8 : I<0, Pseudo, (ops GR8:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000347 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000348 [(set GR8:$dst, (undef))]>;
349def IMPLICIT_DEF_GR16 : I<0, Pseudo, (ops GR16:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000350 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000351 [(set GR16:$dst, (undef))]>;
352def IMPLICIT_DEF_GR32 : I<0, Pseudo, (ops GR32:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000353 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000354 [(set GR32:$dst, (undef))]>;
Evan Cheng4a460802006-01-11 00:33:36 +0000355
356// Nop
357def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
358
Evan Cheng8f7f7122006-05-05 05:40:20 +0000359// Truncate
Evan Cheng069287d2006-05-16 07:21:53 +0000360def TRUNC_GR32_GR8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR32_:$src),
Evan Chengcbe70e12006-05-31 22:34:26 +0000361 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000362def TRUNC_GR16_GR8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR16_:$src),
Evan Chengcbe70e12006-05-31 22:34:26 +0000363 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000364def TRUNC_GR32_GR16 : I<0x89, MRMDestReg, (ops GR16:$dst, GR32:$src),
Evan Chengcbe70e12006-05-31 22:34:26 +0000365 "mov{w} {${src:subreg16}, $dst|$dst, ${src:subreg16}}",
Evan Cheng069287d2006-05-16 07:21:53 +0000366 [(set GR16:$dst, (trunc GR32:$src))]>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000367
Chris Lattner1cca5e32003-08-03 21:54:21 +0000368//===----------------------------------------------------------------------===//
369// Control Flow Instructions...
370//
371
Chris Lattner1be48112005-05-13 17:56:48 +0000372// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000373let isTerminator = 1, isReturn = 1, isBarrier = 1,
374 hasCtrlDep = 1, noResults = 1 in {
Evan Chenge3413162006-01-09 18:33:28 +0000375 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
376 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
377 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000378}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000379
380// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng2b4ea792005-12-26 09:11:45 +0000381let isBranch = 1, isTerminator = 1, noResults = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000382 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
383 I<opcode, RawFrm, ops, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000384
Nate Begeman37efe672006-04-22 18:53:45 +0000385// Indirect branches
Evan Chengec3bc392006-09-07 19:03:48 +0000386let isBranch = 1, isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000387 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000388
Nate Begeman37efe672006-04-22 18:53:45 +0000389let isBranch = 1, isTerminator = 1, noResults = 1, isBarrier = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000390 def JMP32r : I<0xFF, MRM4r, (ops GR32:$dst), "jmp{l} {*}$dst",
391 [(brind GR32:$dst)]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000392 def JMP32m : I<0xFF, MRM4m, (ops i32mem:$dst), "jmp{l} {*}$dst",
Evan Cheng09e3c802006-05-19 18:40:54 +0000393 [(brind (loadiPTR addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000394}
395
396// Conditional branches
Evan Cheng898101c2005-12-19 23:12:38 +0000397def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000398 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000399def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000400 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000401def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000402 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000403def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000404 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000405def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000406 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000407def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000408 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000409
Evan Chengd35b8c12005-12-04 08:19:43 +0000410def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000411 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000412def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000413 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000414def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000415 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000416def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000417 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000418
Evan Chengd9558e02006-01-06 00:43:03 +0000419def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000420 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000421def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000422 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000423def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000424 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000425def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000426 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000427def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000428 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000429def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000430 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000431
432//===----------------------------------------------------------------------===//
433// Call Instructions...
434//
Evan Chenge3413162006-01-09 18:33:28 +0000435let isCall = 1, noResults = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000436 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000437 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Nate Begeman16b04f32005-07-15 00:38:55 +0000438 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengfae29942006-06-14 22:24:55 +0000439 def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst, variable_ops),
440 "call ${dst:call}", []>;
441 def CALL32r : I<0xFF, MRM2r, (ops GR32:$dst, variable_ops),
442 "call {*}$dst", [(X86call GR32:$dst)]>;
443 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst, variable_ops),
444 "call {*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000445 }
446
Chris Lattner1e9448b2005-05-15 03:10:37 +0000447// Tail call stuff.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000448let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Chris Lattnera3b8c572006-02-06 23:41:19 +0000449 def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call} # TAIL CALL", []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000450let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Cheng069287d2006-05-16 07:21:53 +0000451 def TAILJMPr : I<0xFF, MRM4r, (ops GR32:$dst), "jmp {*}$dst # TAIL CALL", []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000452let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000453 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
454 "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000455
456// ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
457// way, except that it is marked as being a terminator. This causes the epilog
458// inserter to insert reloads of callee saved registers BEFORE this. We need
459// this until we have a more accurate way of tracking where the stack pointer is
460// within a function.
461let isTerminator = 1, isTwoAddress = 1 in
Evan Cheng069287d2006-05-16 07:21:53 +0000462 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000463 "add{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000464
Chris Lattner1cca5e32003-08-03 21:54:21 +0000465//===----------------------------------------------------------------------===//
466// Miscellaneous Instructions...
467//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000468def LEAVE : I<0xC9, RawFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000469 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000470def POP32r : I<0x58, AddRegFrm,
Evan Cheng069287d2006-05-16 07:21:53 +0000471 (ops GR32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000472
Evan Cheng7ccced62006-02-18 00:15:05 +0000473def MovePCtoStack : I<0, Pseudo, (ops piclabel:$label),
474 "call $label", []>;
475
Evan Cheng069287d2006-05-16 07:21:53 +0000476let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000477 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng069287d2006-05-16 07:21:53 +0000478 (ops GR32:$dst, GR32:$src),
Nate Begemand88fc032006-01-14 03:14:10 +0000479 "bswap{l} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000480 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000481
Evan Cheng069287d2006-05-16 07:21:53 +0000482def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
483 (ops GR8:$src1, GR8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000484 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000485def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
486 (ops GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000487 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000488def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
489 (ops GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000490 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattnerfc752712004-08-01 09:52:59 +0000491
Chris Lattner3a173df2004-10-03 20:35:00 +0000492def XCHG8mr : I<0x86, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000493 (ops i8mem:$src1, GR8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000494 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000495def XCHG16mr : I<0x87, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000496 (ops i16mem:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000497 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000498def XCHG32mr : I<0x87, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000499 (ops i32mem:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000500 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000501def XCHG8rm : I<0x86, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000502 (ops GR8:$src1, i8mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000503 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000504def XCHG16rm : I<0x87, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000505 (ops GR16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000506 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000507def XCHG32rm : I<0x87, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000508 (ops GR32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000509 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000510
Chris Lattner3a173df2004-10-03 20:35:00 +0000511def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000512 (ops GR16:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000513 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000514def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000515 (ops GR32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000516 "lea{l} {$src|$dst}, {$dst|$src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000517 [(set GR32:$dst, leaaddr:$src)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000518
Evan Cheng67f92a72006-01-11 22:15:48 +0000519def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
520 [(X86rep_movs i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000521 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000522def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
523 [(X86rep_movs i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000524 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Cheng94b14532006-06-02 21:09:10 +0000525def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsl|rep movsd}",
Evan Cheng67f92a72006-01-11 22:15:48 +0000526 [(X86rep_movs i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000527 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Chris Lattner915e5e52004-02-12 17:53:22 +0000528
Evan Cheng67f92a72006-01-11 22:15:48 +0000529def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
530 [(X86rep_stos i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000531 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000532def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
533 [(X86rep_stos i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000534 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Cheng67f92a72006-01-11 22:15:48 +0000535def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
536 [(X86rep_stos i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000537 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
538
Chris Lattnerb89abef2004-02-14 04:45:37 +0000539
Chris Lattner1cca5e32003-08-03 21:54:21 +0000540//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000541// Input/Output Instructions...
542//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000543def IN8rr : I<0xEC, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000544 "in{b} {%dx, %al|%AL, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000545 []>, Imp<[DX], [AL]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000546def IN16rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000547 "in{w} {%dx, %ax|%AX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000548 []>, Imp<[DX], [AX]>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000549def IN32rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000550 "in{l} {%dx, %eax|%EAX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000551 []>, Imp<[DX],[EAX]>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000552
Evan Chenga5386b02005-12-20 07:38:38 +0000553def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
554 "in{b} {$port, %al|%AL, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000555 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000556 Imp<[], [AL]>;
557def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
558 "in{w} {$port, %ax|%AX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000559 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000560 Imp<[], [AX]>, OpSize;
561def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
562 "in{l} {$port, %eax|%EAX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000563 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000564 Imp<[],[EAX]>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000565
Evan Cheng8d202232005-12-05 23:09:43 +0000566def OUT8rr : I<0xEE, RawFrm, (ops),
567 "out{b} {%al, %dx|%DX, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000568 []>, Imp<[DX, AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000569def OUT16rr : I<0xEF, RawFrm, (ops),
570 "out{w} {%ax, %dx|%DX, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000571 []>, Imp<[DX, AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000572def OUT32rr : I<0xEF, RawFrm, (ops),
573 "out{l} {%eax, %dx|%DX, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000574 []>, Imp<[DX, EAX], []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000575
Evan Cheng8d202232005-12-05 23:09:43 +0000576def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
577 "out{b} {%al, $port|$port, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000578 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000579 Imp<[AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000580def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
581 "out{w} {%ax, $port|$port, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000582 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000583 Imp<[AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000584def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
585 "out{l} {%eax, $port|$port, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000586 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000587 Imp<[EAX], []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000588
589//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000590// Move Instructions...
591//
Evan Cheng069287d2006-05-16 07:21:53 +0000592def MOV8rr : I<0x88, MRMDestReg, (ops GR8 :$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000593 "mov{b} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000594def MOV16rr : I<0x89, MRMDestReg, (ops GR16:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000595 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000596def MOV32rr : I<0x89, MRMDestReg, (ops GR32:$dst, GR32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000597 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000598def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops GR8 :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000599 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000600 [(set GR8:$dst, imm:$src)]>;
601def MOV16ri : Ii16<0xB8, AddRegFrm, (ops GR16:$dst, i16imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000602 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000603 [(set GR16:$dst, imm:$src)]>, OpSize;
604def MOV32ri : Ii32<0xB8, AddRegFrm, (ops GR32:$dst, i32imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000605 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000606 [(set GR32:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000607def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000608 "mov{b} {$src, $dst|$dst, $src}",
609 [(store (i8 imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000610def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000611 "mov{w} {$src, $dst|$dst, $src}",
612 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000613def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000614 "mov{l} {$src, $dst|$dst, $src}",
615 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000616
Evan Cheng069287d2006-05-16 07:21:53 +0000617def MOV8rm : I<0x8A, MRMSrcMem, (ops GR8 :$dst, i8mem :$src),
Evan Chengec693f72005-12-08 02:01:35 +0000618 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000619 [(set GR8:$dst, (load addr:$src))]>;
620def MOV16rm : I<0x8B, MRMSrcMem, (ops GR16:$dst, i16mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000621 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000622 [(set GR16:$dst, (load addr:$src))]>, OpSize;
623def MOV32rm : I<0x8B, MRMSrcMem, (ops GR32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000624 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000625 [(set GR32:$dst, (load addr:$src))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000626
Evan Cheng069287d2006-05-16 07:21:53 +0000627def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, GR8 :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000628 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000629 [(store GR8:$src, addr:$dst)]>;
630def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000631 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000632 [(store GR16:$src, addr:$dst)]>, OpSize;
633def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000634 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000635 [(store GR32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000636
Chris Lattner1cca5e32003-08-03 21:54:21 +0000637//===----------------------------------------------------------------------===//
638// Fixed-Register Multiplication and Division Instructions...
639//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000640
Chris Lattnerc8f45872003-08-04 04:59:56 +0000641// Extra precision multiplication
Evan Cheng069287d2006-05-16 07:21:53 +0000642def MUL8r : I<0xF6, MRM4r, (ops GR8:$src), "mul{b} $src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000643 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
644 // This probably ought to be moved to a def : Pat<> if the
645 // syntax can be accepted.
Evan Cheng069287d2006-05-16 07:21:53 +0000646 [(set AL, (mul AL, GR8:$src))]>,
647 Imp<[AL],[AX]>; // AL,AH = AL*GR8
648def MUL16r : I<0xF7, MRM4r, (ops GR16:$src), "mul{w} $src", []>,
649 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
650def MUL32r : I<0xF7, MRM4r, (ops GR32:$src), "mul{l} $src", []>,
651 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Chris Lattner57a02302004-08-11 04:31:00 +0000652def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
Evan Chengcf74a7c2006-01-15 10:05:20 +0000653 "mul{b} $src",
654 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
655 // This probably ought to be moved to a def : Pat<> if the
656 // syntax can be accepted.
657 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
658 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner57a02302004-08-11 04:31:00 +0000659def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000660 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
661 OpSize; // AX,DX = AX*[mem16]
Chris Lattner57a02302004-08-11 04:31:00 +0000662def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000663 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000664
Evan Cheng069287d2006-05-16 07:21:53 +0000665def IMUL8r : I<0xF6, MRM5r, (ops GR8:$src), "imul{b} $src", []>,
666 Imp<[AL],[AX]>; // AL,AH = AL*GR8
667def IMUL16r : I<0xF7, MRM5r, (ops GR16:$src), "imul{w} $src", []>,
668 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
669def IMUL32r : I<0xF7, MRM5r, (ops GR32:$src), "imul{l} $src", []>,
670 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Chris Lattner1e6a7152005-04-06 04:19:22 +0000671def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000672 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000673def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000674 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
675 OpSize; // AX,DX = AX*[mem16]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000676def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000677 "imul{l} $src", []>,
678 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000679
Chris Lattnerc8f45872003-08-04 04:59:56 +0000680// unsigned division/remainder
Evan Cheng069287d2006-05-16 07:21:53 +0000681def DIV8r : I<0xF6, MRM6r, (ops GR8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000682 "div{b} $src", []>, Imp<[AX],[AX]>;
Evan Cheng069287d2006-05-16 07:21:53 +0000683def DIV16r : I<0xF7, MRM6r, (ops GR16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000684 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000685def DIV32r : I<0xF7, MRM6r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000686 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000687def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000688 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000689def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000690 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000691def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000692 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000693
Chris Lattnerfc752712004-08-01 09:52:59 +0000694// Signed division/remainder.
Evan Cheng069287d2006-05-16 07:21:53 +0000695def IDIV8r : I<0xF6, MRM7r, (ops GR8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000696 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Evan Cheng069287d2006-05-16 07:21:53 +0000697def IDIV16r: I<0xF7, MRM7r, (ops GR16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000698 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000699def IDIV32r: I<0xF7, MRM7r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000700 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000701def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000702 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000703def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000704 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000705def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000706 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattnerc8f45872003-08-04 04:59:56 +0000707
Chris Lattner1cca5e32003-08-03 21:54:21 +0000708
Chris Lattner1cca5e32003-08-03 21:54:21 +0000709//===----------------------------------------------------------------------===//
710// Two address Instructions...
711//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000712let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000713
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000714// Conditional moves
Evan Cheng069287d2006-05-16 07:21:53 +0000715def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
716 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000717 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000718 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000719 X86_COND_B))]>,
720 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000721def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
722 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000723 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000724 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000725 X86_COND_B))]>,
726 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000727def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
728 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000729 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000730 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000731 X86_COND_B))]>,
732 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000733def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
734 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000735 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000736 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000737 X86_COND_B))]>,
738 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000739
Evan Cheng069287d2006-05-16 07:21:53 +0000740def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
741 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000742 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000743 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000744 X86_COND_AE))]>,
745 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000746def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
747 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000748 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000749 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000750 X86_COND_AE))]>,
751 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000752def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
753 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000754 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000755 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000756 X86_COND_AE))]>,
757 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000758def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
759 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000760 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000761 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000762 X86_COND_AE))]>,
763 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000764
Evan Cheng069287d2006-05-16 07:21:53 +0000765def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
766 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000767 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000768 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000769 X86_COND_E))]>,
770 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000771def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
772 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000773 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000774 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000775 X86_COND_E))]>,
776 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000777def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
778 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000779 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000780 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000781 X86_COND_E))]>,
782 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000783def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
784 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000785 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000786 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000787 X86_COND_E))]>,
788 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000789
Evan Cheng069287d2006-05-16 07:21:53 +0000790def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
791 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000792 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000793 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000794 X86_COND_NE))]>,
795 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000796def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
797 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000798 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000799 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000800 X86_COND_NE))]>,
801 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000802def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
803 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000804 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000805 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000806 X86_COND_NE))]>,
807 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000808def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
809 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000810 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000811 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000812 X86_COND_NE))]>,
813 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000814
Evan Cheng069287d2006-05-16 07:21:53 +0000815def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
816 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000817 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000818 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000819 X86_COND_BE))]>,
820 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000821def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
822 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000823 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000824 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000825 X86_COND_BE))]>,
826 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000827def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
828 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000829 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000830 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000831 X86_COND_BE))]>,
832 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000833def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
834 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000835 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000836 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000837 X86_COND_BE))]>,
838 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000839
Evan Cheng069287d2006-05-16 07:21:53 +0000840def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
841 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000842 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000843 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000844 X86_COND_A))]>,
845 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000846def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
847 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000848 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000849 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000850 X86_COND_A))]>,
851 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000852def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
853 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000854 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000855 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000856 X86_COND_A))]>,
857 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000858def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
859 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000860 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000861 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000862 X86_COND_A))]>,
863 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000864
Evan Cheng069287d2006-05-16 07:21:53 +0000865def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
866 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000867 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000868 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000869 X86_COND_L))]>,
870 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000871def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
872 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000873 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000874 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000875 X86_COND_L))]>,
876 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000877def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
878 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000879 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000880 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000881 X86_COND_L))]>,
882 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000883def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
884 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000885 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000886 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000887 X86_COND_L))]>,
888 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000889
Evan Cheng069287d2006-05-16 07:21:53 +0000890def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
891 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000892 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000893 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000894 X86_COND_GE))]>,
895 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000896def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
897 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000898 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000899 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000900 X86_COND_GE))]>,
901 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000902def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
903 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000904 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000905 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000906 X86_COND_GE))]>,
907 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000908def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
909 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000910 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000911 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000912 X86_COND_GE))]>,
913 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000914
Evan Cheng069287d2006-05-16 07:21:53 +0000915def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
916 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000917 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000918 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000919 X86_COND_LE))]>,
920 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000921def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
922 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000923 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000924 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000925 X86_COND_LE))]>,
926 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000927def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
928 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000929 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000930 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000931 X86_COND_LE))]>,
932 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000933def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
934 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000935 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000936 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000937 X86_COND_LE))]>,
938 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000939
Evan Cheng069287d2006-05-16 07:21:53 +0000940def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
941 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000942 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000943 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000944 X86_COND_G))]>,
945 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000946def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
947 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000948 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000949 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000950 X86_COND_G))]>,
951 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000952def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
953 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000954 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000955 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000956 X86_COND_G))]>,
957 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000958def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
959 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000960 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000961 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000962 X86_COND_G))]>,
963 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000964
Evan Cheng069287d2006-05-16 07:21:53 +0000965def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
966 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000967 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000968 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000969 X86_COND_S))]>,
970 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000971def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
972 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000973 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000974 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000975 X86_COND_S))]>,
976 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000977def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
978 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000979 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000980 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000981 X86_COND_S))]>,
982 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000983def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
984 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000985 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000986 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000987 X86_COND_S))]>,
988 TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000989
Evan Cheng069287d2006-05-16 07:21:53 +0000990def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
991 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000992 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000993 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000994 X86_COND_NS))]>,
995 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000996def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
997 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000998 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000999 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001000 X86_COND_NS))]>,
1001 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001002def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1003 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001004 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001005 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001006 X86_COND_NS))]>,
1007 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001008def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1009 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001010 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001011 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001012 X86_COND_NS))]>,
1013 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001014
Evan Cheng069287d2006-05-16 07:21:53 +00001015def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1016 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001017 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001018 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001019 X86_COND_P))]>,
1020 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001021def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1022 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001023 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001024 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001025 X86_COND_P))]>,
1026 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001027def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1028 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001029 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001030 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001031 X86_COND_P))]>,
1032 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001033def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1034 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001035 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001036 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001037 X86_COND_P))]>,
1038 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001039
Evan Cheng069287d2006-05-16 07:21:53 +00001040def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1041 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001042 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001043 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001044 X86_COND_NP))]>,
1045 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001046def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1047 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001048 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001049 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001050 X86_COND_NP))]>,
1051 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001052def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1053 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001054 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001055 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001056 X86_COND_NP))]>,
1057 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001058def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1059 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001060 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001061 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001062 X86_COND_NP))]>,
1063 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001064
1065
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001066// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001067let CodeSize = 2 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001068def NEG8r : I<0xF6, MRM3r, (ops GR8 :$dst, GR8 :$src), "neg{b} $dst",
1069 [(set GR8:$dst, (ineg GR8:$src))]>;
1070def NEG16r : I<0xF7, MRM3r, (ops GR16:$dst, GR16:$src), "neg{w} $dst",
1071 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1072def NEG32r : I<0xF7, MRM3r, (ops GR32:$dst, GR32:$src), "neg{l} $dst",
1073 [(set GR32:$dst, (ineg GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001074let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001075 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001076 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001077 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001078 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001079 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001080 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1081
Chris Lattner57a02302004-08-11 04:31:00 +00001082}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001083
Evan Cheng069287d2006-05-16 07:21:53 +00001084def NOT8r : I<0xF6, MRM2r, (ops GR8 :$dst, GR8 :$src), "not{b} $dst",
1085 [(set GR8:$dst, (not GR8:$src))]>;
1086def NOT16r : I<0xF7, MRM2r, (ops GR16:$dst, GR16:$src), "not{w} $dst",
1087 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1088def NOT32r : I<0xF7, MRM2r, (ops GR32:$dst, GR32:$src), "not{l} $dst",
1089 [(set GR32:$dst, (not GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001090let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001091 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001092 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001093 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001094 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001095 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001096 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001097}
Evan Cheng1693e482006-07-19 00:27:29 +00001098} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001099
Evan Chengb51a0592005-12-10 00:48:20 +00001100// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng1693e482006-07-19 00:27:29 +00001101let CodeSize = 2 in
Evan Cheng069287d2006-05-16 07:21:53 +00001102def INC8r : I<0xFE, MRM0r, (ops GR8 :$dst, GR8 :$src), "inc{b} $dst",
1103 [(set GR8:$dst, (add GR8:$src, 1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001104let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Evan Chengf7eb5d02006-07-11 19:49:49 +00001105def INC16r : I<0x40, AddRegFrm, (ops GR16:$dst, GR16:$src), "inc{w} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001106 [(set GR16:$dst, (add GR16:$src, 1))]>, OpSize;
Evan Chengf7eb5d02006-07-11 19:49:49 +00001107def INC32r : I<0x40, AddRegFrm, (ops GR32:$dst, GR32:$src), "inc{l} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001108 [(set GR32:$dst, (add GR32:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001109}
Evan Cheng1693e482006-07-19 00:27:29 +00001110let isTwoAddress = 0, CodeSize = 2 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001111 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001112 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001113 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001114 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001115 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001116 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001117}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001118
Evan Cheng1693e482006-07-19 00:27:29 +00001119let CodeSize = 2 in
Evan Cheng069287d2006-05-16 07:21:53 +00001120def DEC8r : I<0xFE, MRM1r, (ops GR8 :$dst, GR8 :$src), "dec{b} $dst",
1121 [(set GR8:$dst, (add GR8:$src, -1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001122let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Evan Chengf7eb5d02006-07-11 19:49:49 +00001123def DEC16r : I<0x48, AddRegFrm, (ops GR16:$dst, GR16:$src), "dec{w} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001124 [(set GR16:$dst, (add GR16:$src, -1))]>, OpSize;
Evan Chengf7eb5d02006-07-11 19:49:49 +00001125def DEC32r : I<0x48, AddRegFrm, (ops GR32:$dst, GR32:$src), "dec{l} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001126 [(set GR32:$dst, (add GR32:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001127}
Chris Lattner57a02302004-08-11 04:31:00 +00001128
Evan Cheng1693e482006-07-19 00:27:29 +00001129let isTwoAddress = 0, CodeSize = 2 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001130 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001131 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001132 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001133 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001134 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001135 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001136}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001137
1138// Logical operators...
Chris Lattnercc65bee2005-01-02 02:35:46 +00001139let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001140def AND8rr : I<0x20, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001141 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001142 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001143 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001144def AND16rr : I<0x21, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001145 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001146 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001147 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001148def AND32rr : I<0x21, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001149 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001150 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001151 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001152}
Chris Lattner57a02302004-08-11 04:31:00 +00001153
Chris Lattner3a173df2004-10-03 20:35:00 +00001154def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001155 (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001156 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001157 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001158def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001159 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001160 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001161 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001162def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001163 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001164 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001165 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001166
Chris Lattner3a173df2004-10-03 20:35:00 +00001167def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001168 (ops GR8 :$dst, GR8 :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001169 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001170 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001171def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001172 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001173 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001174 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001175def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001176 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001177 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001178 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001179def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001180 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001181 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001182 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001183 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001184def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001185 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001186 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001187 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001188
1189let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001190 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001191 (ops i8mem :$dst, GR8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001192 "and{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001193 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001194 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001195 (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001196 "and{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001197 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001198 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001199 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001200 (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001201 "and{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001202 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001203 def AND8mi : Ii8<0x80, MRM4m,
1204 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001205 "and{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001206 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001207 def AND16mi : Ii16<0x81, MRM4m,
1208 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001209 "and{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001210 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001211 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001212 def AND32mi : Ii32<0x81, MRM4m,
1213 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001214 "and{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001215 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001216 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001217 (ops i16mem:$dst, i16i8imm :$src),
1218 "and{w} {$src, $dst|$dst, $src}",
1219 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1220 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001221 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001222 (ops i32mem:$dst, i32i8imm :$src),
1223 "and{l} {$src, $dst|$dst, $src}",
Evan Chenge3703d42006-01-14 01:18:49 +00001224 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001225}
1226
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001227
Chris Lattnercc65bee2005-01-02 02:35:46 +00001228let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001229def OR8rr : I<0x08, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001230 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001231 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1232def OR16rr : I<0x09, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001233 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001234 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1235def OR32rr : I<0x09, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001236 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001237 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001238}
Evan Cheng069287d2006-05-16 07:21:53 +00001239def OR8rm : I<0x0A, MRMSrcMem , (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001240 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001241 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1242def OR16rm : I<0x0B, MRMSrcMem , (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001243 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001244 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1245def OR32rm : I<0x0B, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001246 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001247 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001248
Evan Cheng069287d2006-05-16 07:21:53 +00001249def OR8ri : Ii8 <0x80, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001250 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001251 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1252def OR16ri : Ii16<0x81, MRM1r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001253 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001254 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1255def OR32ri : Ii32<0x81, MRM1r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001256 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001257 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001258
Evan Cheng069287d2006-05-16 07:21:53 +00001259def OR16ri8 : Ii8<0x83, MRM1r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001260 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001261 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1262def OR32ri8 : Ii8<0x83, MRM1r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001263 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001264 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001265let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001266 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, GR8:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001267 "or{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001268 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1269 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001270 "or{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001271 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1272 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001273 "or{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001274 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001275 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001276 "or{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001277 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001278 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001279 "or{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001280 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001281 OpSize;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001282 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001283 "or{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001284 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng0ef3a772005-12-13 01:41:36 +00001285 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1286 "or{w} {$src, $dst|$dst, $src}",
1287 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1288 OpSize;
1289 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1290 "or{l} {$src, $dst|$dst, $src}",
1291 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001292}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001293
1294
Chris Lattnercc65bee2005-01-02 02:35:46 +00001295let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001296def XOR8rr : I<0x30, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001297 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001298 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001299 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001300def XOR16rr : I<0x31, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001301 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001302 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001303 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001304def XOR32rr : I<0x31, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001305 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001306 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001307 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001308}
1309
Chris Lattner3a173df2004-10-03 20:35:00 +00001310def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001311 (ops GR8 :$dst, GR8:$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001312 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001313 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001314def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001315 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001316 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001317 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001318def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001319 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001320 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001321 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001322
Chris Lattner3a173df2004-10-03 20:35:00 +00001323def XOR8ri : Ii8<0x80, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001324 (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001325 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001326 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001327def XOR16ri : Ii16<0x81, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001328 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001329 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001330 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001331def XOR32ri : Ii32<0x81, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001332 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001333 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001334 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001335def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001336 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001337 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001338 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001339 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001340def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001341 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001342 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001343 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001344let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001345 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001346 (ops i8mem :$dst, GR8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001347 "xor{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001348 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001349 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001350 (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001351 "xor{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001352 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001353 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001354 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001355 (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001356 "xor{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001357 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001358 def XOR8mi : Ii8<0x80, MRM6m,
1359 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001360 "xor{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001361 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001362 def XOR16mi : Ii16<0x81, MRM6m,
1363 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001364 "xor{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001365 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001366 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001367 def XOR32mi : Ii32<0x81, MRM6m,
1368 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001369 "xor{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001370 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001371 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001372 (ops i16mem:$dst, i16i8imm :$src),
1373 "xor{w} {$src, $dst|$dst, $src}",
1374 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1375 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001376 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001377 (ops i32mem:$dst, i32i8imm :$src),
1378 "xor{l} {$src, $dst|$dst, $src}",
1379 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001380}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001381
1382// Shift instructions
Evan Cheng069287d2006-05-16 07:21:53 +00001383def SHL8rCL : I<0xD2, MRM4r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001384 "shl{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001385 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
1386def SHL16rCL : I<0xD3, MRM4r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001387 "shl{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001388 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1389def SHL32rCL : I<0xD3, MRM4r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001390 "shl{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001391 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001392
Evan Cheng069287d2006-05-16 07:21:53 +00001393def SHL8ri : Ii8<0xC0, MRM4r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001394 "shl{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001395 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001396let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001397def SHL16ri : Ii8<0xC1, MRM4r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001398 "shl{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001399 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1400def SHL32ri : Ii8<0xC1, MRM4r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001401 "shl{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001402 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001403}
Chris Lattnerf29ed092004-08-11 05:07:25 +00001404
Evan Cheng09c54572006-06-29 00:36:51 +00001405// Shift left by one. Not used because (add x, x) is slightly cheaper.
1406def SHL8r1 : I<0xD0, MRM4r, (ops GR8 :$dst, GR8 :$src1),
Evan Chengcbac2fa2006-07-20 21:37:39 +00001407 "shl{b} $dst", []>;
Evan Cheng09c54572006-06-29 00:36:51 +00001408def SHL16r1 : I<0xD1, MRM4r, (ops GR16:$dst, GR16:$src1),
Evan Chengcbac2fa2006-07-20 21:37:39 +00001409 "shl{w} $dst", []>, OpSize;
Evan Cheng09c54572006-06-29 00:36:51 +00001410def SHL32r1 : I<0xD1, MRM4r, (ops GR32:$dst, GR32:$src1),
Evan Chengcbac2fa2006-07-20 21:37:39 +00001411 "shl{l} $dst", []>;
Evan Cheng09c54572006-06-29 00:36:51 +00001412
Chris Lattnerf29ed092004-08-11 05:07:25 +00001413let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001414 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001415 "shl{b} {%cl, $dst|$dst, %CL}",
1416 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1417 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001418 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001419 "shl{w} {%cl, $dst|$dst, %CL}",
1420 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1421 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001422 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001423 "shl{l} {%cl, $dst|$dst, %CL}",
1424 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1425 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001426 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001427 "shl{b} {$src, $dst|$dst, $src}",
1428 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001429 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001430 "shl{w} {$src, $dst|$dst, $src}",
1431 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1432 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001433 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001434 "shl{l} {$src, $dst|$dst, $src}",
1435 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001436
1437 // Shift by 1
1438 def SHL8m1 : I<0xD0, MRM4m, (ops i8mem :$dst),
1439 "shl{b} $dst",
1440 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1441 def SHL16m1 : I<0xD1, MRM4m, (ops i16mem:$dst),
1442 "shl{w} $dst",
1443 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1444 OpSize;
1445 def SHL32m1 : I<0xD1, MRM4m, (ops i32mem:$dst),
1446 "shl{l} $dst",
1447 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001448}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001449
Evan Cheng069287d2006-05-16 07:21:53 +00001450def SHR8rCL : I<0xD2, MRM5r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001451 "shr{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001452 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
1453def SHR16rCL : I<0xD3, MRM5r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001454 "shr{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001455 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1456def SHR32rCL : I<0xD3, MRM5r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001457 "shr{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001458 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001459
Evan Cheng069287d2006-05-16 07:21:53 +00001460def SHR8ri : Ii8<0xC0, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001461 "shr{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001462 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1463def SHR16ri : Ii8<0xC1, MRM5r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001464 "shr{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001465 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1466def SHR32ri : Ii8<0xC1, MRM5r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001467 "shr{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001468 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001469
Evan Cheng09c54572006-06-29 00:36:51 +00001470// Shift by 1
1471def SHR8r1 : I<0xD0, MRM5r, (ops GR8:$dst, GR8:$src1),
1472 "shr{b} $dst",
1473 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1474def SHR16r1 : I<0xD1, MRM5r, (ops GR16:$dst, GR16:$src1),
1475 "shr{w} $dst",
1476 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1477def SHR32r1 : I<0xD1, MRM5r, (ops GR32:$dst, GR32:$src1),
1478 "shr{l} $dst",
1479 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1480
Chris Lattner57a02302004-08-11 04:31:00 +00001481let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001482 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001483 "shr{b} {%cl, $dst|$dst, %CL}",
1484 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1485 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001486 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001487 "shr{w} {%cl, $dst|$dst, %CL}",
1488 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1489 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001490 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001491 "shr{l} {%cl, $dst|$dst, %CL}",
1492 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1493 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001494 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001495 "shr{b} {$src, $dst|$dst, $src}",
1496 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001497 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001498 "shr{w} {$src, $dst|$dst, $src}",
1499 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1500 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001501 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001502 "shr{l} {$src, $dst|$dst, $src}",
1503 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001504
1505 // Shift by 1
1506 def SHR8m1 : I<0xD0, MRM5m, (ops i8mem :$dst),
1507 "shr{b} $dst",
1508 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1509 def SHR16m1 : I<0xD1, MRM5m, (ops i16mem:$dst),
1510 "shr{w} $dst",
1511 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1512 def SHR32m1 : I<0xD1, MRM5m, (ops i32mem:$dst),
1513 "shr{l} $dst",
1514 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001515}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001516
Evan Cheng069287d2006-05-16 07:21:53 +00001517def SAR8rCL : I<0xD2, MRM7r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001518 "sar{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001519 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
1520def SAR16rCL : I<0xD3, MRM7r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001521 "sar{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001522 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1523def SAR32rCL : I<0xD3, MRM7r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001524 "sar{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001525 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001526
Evan Cheng069287d2006-05-16 07:21:53 +00001527def SAR8ri : Ii8<0xC0, MRM7r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001528 "sar{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001529 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1530def SAR16ri : Ii8<0xC1, MRM7r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001531 "sar{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001532 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001533 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001534def SAR32ri : Ii8<0xC1, MRM7r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001535 "sar{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001536 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001537
1538// Shift by 1
1539def SAR8r1 : I<0xD0, MRM7r, (ops GR8 :$dst, GR8 :$src1),
1540 "sar{b} $dst",
1541 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1542def SAR16r1 : I<0xD1, MRM7r, (ops GR16:$dst, GR16:$src1),
1543 "sar{w} $dst",
1544 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1545def SAR32r1 : I<0xD1, MRM7r, (ops GR32:$dst, GR32:$src1),
1546 "sar{l} $dst",
1547 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1548
Chris Lattnerf29ed092004-08-11 05:07:25 +00001549let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001550 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001551 "sar{b} {%cl, $dst|$dst, %CL}",
1552 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1553 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001554 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001555 "sar{w} {%cl, $dst|$dst, %CL}",
1556 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1557 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001558 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001559 "sar{l} {%cl, $dst|$dst, %CL}",
1560 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1561 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001562 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001563 "sar{b} {$src, $dst|$dst, $src}",
1564 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001565 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001566 "sar{w} {$src, $dst|$dst, $src}",
1567 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1568 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001569 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001570 "sar{l} {$src, $dst|$dst, $src}",
1571 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001572
1573 // Shift by 1
1574 def SAR8m1 : I<0xD0, MRM7m, (ops i8mem :$dst),
1575 "sar{b} $dst",
1576 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1577 def SAR16m1 : I<0xD1, MRM7m, (ops i16mem:$dst),
1578 "sar{w} $dst",
1579 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1580 OpSize;
1581 def SAR32m1 : I<0xD1, MRM7m, (ops i32mem:$dst),
1582 "sar{l} $dst",
1583 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001584}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001585
Chris Lattner40ff6332005-01-19 07:50:03 +00001586// Rotate instructions
1587// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng069287d2006-05-16 07:21:53 +00001588def ROL8rCL : I<0xD2, MRM0r, (ops GR8 :$dst, GR8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001589 "rol{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001590 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
1591def ROL16rCL : I<0xD3, MRM0r, (ops GR16:$dst, GR16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001592 "rol{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001593 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1594def ROL32rCL : I<0xD3, MRM0r, (ops GR32:$dst, GR32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001595 "rol{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001596 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001597
Evan Cheng069287d2006-05-16 07:21:53 +00001598def ROL8ri : Ii8<0xC0, MRM0r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001599 "rol{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001600 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1601def ROL16ri : Ii8<0xC1, MRM0r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001602 "rol{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001603 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1604def ROL32ri : Ii8<0xC1, MRM0r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001605 "rol{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001606 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001607
Evan Cheng09c54572006-06-29 00:36:51 +00001608// Rotate by 1
1609def ROL8r1 : I<0xD0, MRM0r, (ops GR8 :$dst, GR8 :$src1),
1610 "rol{b} $dst",
1611 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1612def ROL16r1 : I<0xD1, MRM0r, (ops GR16:$dst, GR16:$src1),
1613 "rol{w} $dst",
1614 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1615def ROL32r1 : I<0xD1, MRM0r, (ops GR32:$dst, GR32:$src1),
1616 "rol{l} $dst",
1617 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1618
Chris Lattner40ff6332005-01-19 07:50:03 +00001619let isTwoAddress = 0 in {
1620 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001621 "rol{b} {%cl, $dst|$dst, %CL}",
1622 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1623 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001624 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001625 "rol{w} {%cl, $dst|$dst, %CL}",
1626 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1627 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001628 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001629 "rol{l} {%cl, $dst|$dst, %CL}",
1630 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1631 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001632 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001633 "rol{b} {$src, $dst|$dst, $src}",
1634 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001635 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001636 "rol{w} {$src, $dst|$dst, $src}",
1637 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1638 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001639 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001640 "rol{l} {$src, $dst|$dst, $src}",
1641 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001642
1643 // Rotate by 1
1644 def ROL8m1 : I<0xD0, MRM0m, (ops i8mem :$dst),
1645 "rol{b} $dst",
1646 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1647 def ROL16m1 : I<0xD1, MRM0m, (ops i16mem:$dst),
1648 "rol{w} $dst",
1649 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1650 OpSize;
1651 def ROL32m1 : I<0xD1, MRM0m, (ops i32mem:$dst),
1652 "rol{l} $dst",
1653 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001654}
1655
Evan Cheng069287d2006-05-16 07:21:53 +00001656def ROR8rCL : I<0xD2, MRM1r, (ops GR8 :$dst, GR8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001657 "ror{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001658 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
1659def ROR16rCL : I<0xD3, MRM1r, (ops GR16:$dst, GR16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001660 "ror{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001661 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1662def ROR32rCL : I<0xD3, MRM1r, (ops GR32:$dst, GR32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001663 "ror{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001664 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001665
Evan Cheng069287d2006-05-16 07:21:53 +00001666def ROR8ri : Ii8<0xC0, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001667 "ror{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001668 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1669def ROR16ri : Ii8<0xC1, MRM1r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001670 "ror{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001671 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1672def ROR32ri : Ii8<0xC1, MRM1r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001673 "ror{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001674 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001675
1676// Rotate by 1
1677def ROR8r1 : I<0xD0, MRM1r, (ops GR8 :$dst, GR8 :$src1),
1678 "ror{b} $dst",
1679 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1680def ROR16r1 : I<0xD1, MRM1r, (ops GR16:$dst, GR16:$src1),
1681 "ror{w} $dst",
1682 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1683def ROR32r1 : I<0xD1, MRM1r, (ops GR32:$dst, GR32:$src1),
1684 "ror{l} $dst",
1685 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1686
Chris Lattner40ff6332005-01-19 07:50:03 +00001687let isTwoAddress = 0 in {
1688 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001689 "ror{b} {%cl, $dst|$dst, %CL}",
1690 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1691 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001692 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001693 "ror{w} {%cl, $dst|$dst, %CL}",
1694 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1695 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001696 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001697 "ror{l} {%cl, $dst|$dst, %CL}",
1698 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1699 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001700 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001701 "ror{b} {$src, $dst|$dst, $src}",
1702 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001703 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001704 "ror{w} {$src, $dst|$dst, $src}",
1705 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1706 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001707 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001708 "ror{l} {$src, $dst|$dst, $src}",
1709 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001710
1711 // Rotate by 1
1712 def ROR8m1 : I<0xD0, MRM1m, (ops i8mem :$dst),
1713 "ror{b} $dst",
1714 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1715 def ROR16m1 : I<0xD1, MRM1m, (ops i16mem:$dst),
1716 "ror{w} $dst",
1717 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1718 OpSize;
1719 def ROR32m1 : I<0xD1, MRM1m, (ops i32mem:$dst),
1720 "ror{l} $dst",
1721 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001722}
1723
1724
1725
1726// Double shift instructions (generalizations of rotate)
Evan Cheng069287d2006-05-16 07:21:53 +00001727def SHLD32rrCL : I<0xA5, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001728 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001729 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001730 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001731def SHRD32rrCL : I<0xAD, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001732 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001733 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001734 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001735def SHLD16rrCL : I<0xA5, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001736 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001737 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001738 Imp<[CL],[]>, TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001739def SHRD16rrCL : I<0xAD, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001740 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001741 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001742 Imp<[CL],[]>, TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001743
1744let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001745def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001746 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001747 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001748 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001749 (i8 imm:$src3)))]>,
1750 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001751def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001752 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001753 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001754 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001755 (i8 imm:$src3)))]>,
1756 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001757def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001758 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001759 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001760 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001761 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001762 TB, OpSize;
1763def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001764 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001765 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001766 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001767 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001768 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001769}
Chris Lattner0e967d42004-08-01 08:13:11 +00001770
Chris Lattner57a02302004-08-11 04:31:00 +00001771let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001772 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001773 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001774 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001775 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001776 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001777 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001778 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001779 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001780 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001781 Imp<[CL],[]>, TB;
1782 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001783 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001784 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001785 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001786 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001787 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001788 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001789 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001790 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001791 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001792 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001793 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001794
Evan Cheng069287d2006-05-16 07:21:53 +00001795 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001796 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001797 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001798 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001799 Imp<[CL],[]>, TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001800 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001801 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001802 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001803 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001804 Imp<[CL],[]>, TB, OpSize;
1805 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001806 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001807 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001808 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001809 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001810 TB, OpSize;
1811 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001812 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001813 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001814 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001815 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001816 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001817}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001818
1819
Chris Lattnercc65bee2005-01-02 02:35:46 +00001820// Arithmetic.
1821let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001822def ADD8rr : I<0x00, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001823 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001824 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001825let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001826def ADD16rr : I<0x01, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001827 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001828 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1829def ADD32rr : I<0x01, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001830 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001831 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001832} // end isConvertibleToThreeAddress
1833} // end isCommutable
Evan Cheng069287d2006-05-16 07:21:53 +00001834def ADD8rm : I<0x02, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001835 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001836 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1837def ADD16rm : I<0x03, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001838 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001839 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
1840def ADD32rm : I<0x03, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001841 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001842 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001843
Evan Cheng069287d2006-05-16 07:21:53 +00001844def ADD8ri : Ii8<0x80, MRM0r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001845 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001846 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001847
1848let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001849def ADD16ri : Ii16<0x81, MRM0r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001850 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001851 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1852def ADD32ri : Ii32<0x81, MRM0r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001853 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001854 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00001855def ADD16ri8 : Ii8<0x83, MRM0r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001856 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001857 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001858 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001859def ADD32ri8 : Ii8<0x83, MRM0r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001860 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001861 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00001862}
Chris Lattner57a02302004-08-11 04:31:00 +00001863
1864let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001865 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001866 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001867 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1868 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001869 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001870 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001871 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001872 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001873 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001874 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001875 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001876 "add{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001877 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001878 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001879 "add{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001880 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001881 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001882 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001883 "add{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001884 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengee93f9d2005-12-12 19:45:23 +00001885 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1886 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001887 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1888 OpSize;
Evan Chengee93f9d2005-12-12 19:45:23 +00001889 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1890 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001891 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001892}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001893
Chris Lattner10197ff2005-01-03 01:27:59 +00001894let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001895def ADC32rr : I<0x11, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001896 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001897 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001898}
Evan Cheng069287d2006-05-16 07:21:53 +00001899def ADC32rm : I<0x13, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001900 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001901 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1902def ADC32ri : Ii32<0x81, MRM2r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001903 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001904 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1905def ADC32ri8 : Ii8<0x83, MRM2r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001906 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001907 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001908
1909let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001910 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001911 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001912 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001913 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001914 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001915 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chenge3413162006-01-09 18:33:28 +00001916 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1917 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001918 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001919}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001920
Evan Cheng069287d2006-05-16 07:21:53 +00001921def SUB8rr : I<0x28, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001922 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001923 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1924def SUB16rr : I<0x29, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001925 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001926 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1927def SUB32rr : I<0x29, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001928 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001929 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1930def SUB8rm : I<0x2A, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001931 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001932 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1933def SUB16rm : I<0x2B, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001934 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001935 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1936def SUB32rm : I<0x2B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001937 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001938 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001939
Evan Cheng069287d2006-05-16 07:21:53 +00001940def SUB8ri : Ii8 <0x80, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001941 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001942 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1943def SUB16ri : Ii16<0x81, MRM5r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001944 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001945 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1946def SUB32ri : Ii32<0x81, MRM5r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001947 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001948 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1949def SUB16ri8 : Ii8<0x83, MRM5r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001950 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001951 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001952 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001953def SUB32ri8 : Ii8<0x83, MRM5r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001954 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001955 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001956let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001957 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001958 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001959 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
1960 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001961 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001962 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001963 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001964 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001965 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001966 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001967 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001968 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001969 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001970 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001971 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001972 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001973 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001974 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001975 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001976 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengd160d482005-12-12 21:54:05 +00001977 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1978 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001979 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1980 OpSize;
Evan Chengd160d482005-12-12 21:54:05 +00001981 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1982 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001983 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001984}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001985
Evan Cheng069287d2006-05-16 07:21:53 +00001986def SBB32rr : I<0x19, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001987 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001988 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001989
Chris Lattner57a02302004-08-11 04:31:00 +00001990let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001991 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001992 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001993 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001994 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001995 "sbb{b} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001996 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001997 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001998 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001999 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chenge3413162006-01-09 18:33:28 +00002000 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
2001 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002002 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002003}
Evan Cheng069287d2006-05-16 07:21:53 +00002004def SBB32rm : I<0x1B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002005 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002006 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2007def SBB32ri : Ii32<0x81, MRM3r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002008 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002009 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2010def SBB32ri8 : Ii8<0x83, MRM3r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002011 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002012 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002013
Chris Lattner10197ff2005-01-03 01:27:59 +00002014let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00002015def IMUL16rr : I<0xAF, MRMSrcReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002016 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002017 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2018def IMUL32rr : I<0xAF, MRMSrcReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002019 "imul{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002020 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002021}
Evan Cheng069287d2006-05-16 07:21:53 +00002022def IMUL16rm : I<0xAF, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002023 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002024 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002025 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002026def IMUL32rm : I<0xAF, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002027 "imul{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002028 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002029
2030} // end Two Address instructions
2031
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002032// Suprisingly enough, these are not two address instructions!
Evan Cheng069287d2006-05-16 07:21:53 +00002033def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2034 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00002035 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002036 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2037def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2038 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00002039 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002040 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2041def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2042 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002043 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002044 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002045 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002046def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2047 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002048 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002049 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002050
Evan Cheng069287d2006-05-16 07:21:53 +00002051def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2052 (ops GR16:$dst, i16mem:$src1, i16imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002053 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002054 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
Evan Chengf281e022005-12-12 23:47:46 +00002055 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002056def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2057 (ops GR32:$dst, i32mem:$src1, i32imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002058 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002059 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2060def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2061 (ops GR16:$dst, i16mem:$src1, i16i8imm :$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002062 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002063 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002064 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002065def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2066 (ops GR32:$dst, i32mem:$src1, i32i8imm: $src2),
Evan Chengf281e022005-12-12 23:47:46 +00002067 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002068 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002069
2070//===----------------------------------------------------------------------===//
2071// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002072//
Chris Lattnercc65bee2005-01-02 02:35:46 +00002073let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng069287d2006-05-16 07:21:53 +00002074def TEST8rr : I<0x84, MRMDestReg, (ops GR8:$src1, GR8:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002075 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002076 [(X86test GR8:$src1, GR8:$src2)]>;
2077def TEST16rr : I<0x85, MRMDestReg, (ops GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002078 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002079 [(X86test GR16:$src1, GR16:$src2)]>, OpSize;
2080def TEST32rr : I<0x85, MRMDestReg, (ops GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002081 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002082 [(X86test GR32:$src1, GR32:$src2)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002083}
Evan Cheng069287d2006-05-16 07:21:53 +00002084def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, GR8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002085 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002086 [(X86test (loadi8 addr:$src1), GR8:$src2)]>;
2087def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002088 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002089 [(X86test (loadi16 addr:$src1), GR16:$src2)]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002090 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002091def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002092 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002093 [(X86test (loadi32 addr:$src1), GR32:$src2)]>;
2094def TEST8rm : I<0x84, MRMSrcMem, (ops GR8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002095 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002096 [(X86test GR8:$src1, (loadi8 addr:$src2))]>;
2097def TEST16rm : I<0x85, MRMSrcMem, (ops GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002098 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002099 [(X86test GR16:$src1, (loadi16 addr:$src2))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002100 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002101def TEST32rm : I<0x85, MRMSrcMem, (ops GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002102 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002103 [(X86test GR32:$src1, (loadi32 addr:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002104
Evan Cheng069287d2006-05-16 07:21:53 +00002105def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2106 (ops GR8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002107 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002108 [(X86test GR8:$src1, imm:$src2)]>;
2109def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2110 (ops GR16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002111 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002112 [(X86test GR16:$src1, imm:$src2)]>, OpSize;
2113def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2114 (ops GR32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002115 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002116 [(X86test GR32:$src1, imm:$src2)]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002117def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengaed7c722005-12-17 01:24:02 +00002118 (ops i8mem:$src1, i8imm:$src2),
2119 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002120 [(X86test (loadi8 addr:$src1), imm:$src2)]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002121def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2122 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002123 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002124 [(X86test (loadi16 addr:$src1), imm:$src2)]>,
2125 OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002126def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2127 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002128 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002129 [(X86test (loadi32 addr:$src1), imm:$src2)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002130
2131
2132// Condition code ops, incl. set if equal/not equal/...
Evan Chengf0701842005-11-29 19:38:52 +00002133def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2134def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002135
Chris Lattner3a173df2004-10-03 20:35:00 +00002136def SETEr : I<0x94, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002137 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002138 "sete $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002139 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2140 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002141def SETEm : I<0x94, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002142 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002143 "sete $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002144 [(store (X86setcc X86_COND_E), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002145 TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002146def SETNEr : I<0x95, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002147 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002148 "setne $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002149 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2150 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002151def SETNEm : I<0x95, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002152 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002153 "setne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002154 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002155 TB; // [mem8] = !=
2156def SETLr : I<0x9C, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002157 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002158 "setl $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002159 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2160 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002161def SETLm : I<0x9C, MRM0m,
2162 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002163 "setl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002164 [(store (X86setcc X86_COND_L), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002165 TB; // [mem8] = < signed
2166def SETGEr : I<0x9D, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002167 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002168 "setge $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002169 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2170 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002171def SETGEm : I<0x9D, MRM0m,
2172 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002173 "setge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002174 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002175 TB; // [mem8] = >= signed
2176def SETLEr : I<0x9E, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002177 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002178 "setle $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002179 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2180 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002181def SETLEm : I<0x9E, MRM0m,
2182 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002183 "setle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002184 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002185 TB; // [mem8] = <= signed
2186def SETGr : I<0x9F, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002187 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002188 "setg $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002189 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2190 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002191def SETGm : I<0x9F, MRM0m,
2192 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002193 "setg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002194 [(store (X86setcc X86_COND_G), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002195 TB; // [mem8] = > signed
2196
2197def SETBr : I<0x92, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002198 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002199 "setb $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002200 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2201 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002202def SETBm : I<0x92, MRM0m,
2203 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002204 "setb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002205 [(store (X86setcc X86_COND_B), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002206 TB; // [mem8] = < unsign
2207def SETAEr : I<0x93, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002208 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002209 "setae $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002210 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2211 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002212def SETAEm : I<0x93, MRM0m,
2213 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002214 "setae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002215 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002216 TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002217def SETBEr : I<0x96, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002218 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002219 "setbe $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002220 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2221 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002222def SETBEm : I<0x96, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002223 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002224 "setbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002225 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002226 TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002227def SETAr : I<0x97, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002228 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002229 "seta $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002230 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2231 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002232def SETAm : I<0x97, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002233 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002234 "seta $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002235 [(store (X86setcc X86_COND_A), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002236 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002237
Chris Lattner3a173df2004-10-03 20:35:00 +00002238def SETSr : I<0x98, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002239 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002240 "sets $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002241 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2242 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002243def SETSm : I<0x98, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002244 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002245 "sets $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002246 [(store (X86setcc X86_COND_S), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002247 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002248def SETNSr : I<0x99, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002249 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002250 "setns $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002251 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2252 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002253def SETNSm : I<0x99, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002254 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002255 "setns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002256 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002257 TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002258def SETPr : I<0x9A, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002259 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002260 "setp $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002261 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2262 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002263def SETPm : I<0x9A, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002264 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002265 "setp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002266 [(store (X86setcc X86_COND_P), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002267 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002268def SETNPr : I<0x9B, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002269 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002270 "setnp $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002271 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2272 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002273def SETNPm : I<0x9B, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002274 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002275 "setnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002276 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002277 TB; // [mem8] = not parity
Chris Lattner1cca5e32003-08-03 21:54:21 +00002278
2279// Integer comparisons
Chris Lattner3a173df2004-10-03 20:35:00 +00002280def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002281 (ops GR8 :$src1, GR8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002282 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002283 [(X86cmp GR8:$src1, GR8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002284def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002285 (ops GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002286 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002287 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002288def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002289 (ops GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002290 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002291 [(X86cmp GR32:$src1, GR32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002292def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002293 (ops i8mem :$src1, GR8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002294 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002295 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002296def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002297 (ops i16mem:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002298 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002299 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002300def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002301 (ops i32mem:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002302 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002303 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002304def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002305 (ops GR8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002306 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002307 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002308def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002309 (ops GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002310 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002311 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002312def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002313 (ops GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002314 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002315 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002316def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002317 (ops GR8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002318 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002319 [(X86cmp GR8:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002320def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002321 (ops GR16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002322 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002323 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002324def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002325 (ops GR32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002326 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002327 [(X86cmp GR32:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002328def CMP8mi : Ii8 <0x80, MRM7m,
2329 (ops i8mem :$src1, i8imm :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002330 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002331 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002332def CMP16mi : Ii16<0x81, MRM7m,
2333 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002334 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002335 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002336def CMP32mi : Ii32<0x81, MRM7m,
2337 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002338 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002339 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002340def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002341 (ops GR16:$src1, i16i8imm:$src2),
Nate Begemance944822006-03-23 01:29:48 +00002342 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002343 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002344def CMP16mi8 : Ii8<0x83, MRM7m,
Nate Begemance944822006-03-23 01:29:48 +00002345 (ops i16mem:$src1, i16i8imm:$src2),
2346 "cmp{w} {$src2, $src1|$src1, $src2}",
2347 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002348def CMP32mi8 : Ii8<0x83, MRM7m,
Nate Begemance944822006-03-23 01:29:48 +00002349 (ops i32mem:$src1, i32i8imm:$src2),
2350 "cmp{l} {$src2, $src1|$src1, $src2}",
2351 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002352def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002353 (ops GR32:$src1, i32i8imm:$src2),
Nate Begemance944822006-03-23 01:29:48 +00002354 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002355 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002356
2357// Sign/Zero extenders
Evan Cheng069287d2006-05-16 07:21:53 +00002358def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002359 "movs{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002360 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
2361def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002362 "movs{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002363 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2364def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002365 "movs{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002366 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2367def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002368 "movs{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002369 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2370def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops GR32:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002371 "movs{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002372 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2373def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002374 "movs{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002375 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002376
Evan Cheng069287d2006-05-16 07:21:53 +00002377def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002378 "movz{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002379 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
2380def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002381 "movz{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002382 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2383def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002384 "movz{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002385 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2386def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002387 "movz{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002388 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2389def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops GR32:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002390 "movz{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002391 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2392def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002393 "movz{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002394 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00002395
Evan Chengf91c1012006-05-31 22:05:11 +00002396def CBW : I<0x98, RawFrm, (ops),
2397 "{cbtw|cbw}", []>, Imp<[AL],[AX]>; // AX = signext(AL)
2398def CWDE : I<0x98, RawFrm, (ops),
2399 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2400
2401def CWD : I<0x99, RawFrm, (ops),
2402 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>; // DX:AX = signext(AX)
2403def CDQ : I<0x99, RawFrm, (ops),
2404 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2405
Nate Begemanf1702ac2005-06-27 21:20:31 +00002406//===----------------------------------------------------------------------===//
Evan Cheng747a90d2006-02-21 02:24:38 +00002407// Miscellaneous Instructions
2408//===----------------------------------------------------------------------===//
2409
2410def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
2411 TB, Imp<[],[EAX,EDX]>;
2412
Evan Cheng747a90d2006-02-21 02:24:38 +00002413//===----------------------------------------------------------------------===//
2414// Alias Instructions
2415//===----------------------------------------------------------------------===//
2416
2417// Alias instructions that map movr0 to xor.
2418// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Cheng069287d2006-05-16 07:21:53 +00002419def MOV8r0 : I<0x30, MRMInitReg, (ops GR8 :$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002420 "xor{b} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002421 [(set GR8:$dst, 0)]>;
2422def MOV16r0 : I<0x31, MRMInitReg, (ops GR16:$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002423 "xor{w} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002424 [(set GR16:$dst, 0)]>, OpSize;
2425def MOV32r0 : I<0x31, MRMInitReg, (ops GR32:$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002426 "xor{l} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002427 [(set GR32:$dst, 0)]>;
Evan Cheng747a90d2006-02-21 02:24:38 +00002428
Evan Cheng069287d2006-05-16 07:21:53 +00002429// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2430// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2431def MOV16to16_ : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002432 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002433def MOV32to32_ : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002434 "mov{l} {$src, $dst|$dst, $src}", []>;
2435
Evan Cheng069287d2006-05-16 07:21:53 +00002436def MOV16_rr : I<0x89, MRMDestReg, (ops GR16_:$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_rr : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002439 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +00002440def MOV16_rm : I<0x8B, MRMSrcMem, (ops GR16_:$dst, i16mem:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002441 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002442def MOV32_rm : I<0x8B, MRMSrcMem, (ops GR32_:$dst, i32mem:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002443 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +00002444def MOV16_mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002445 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002446def MOV32_mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002447 "mov{l} {$src, $dst|$dst, $src}", []>;
2448
Evan Cheng510e4782006-01-09 23:10:28 +00002449//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00002450// DWARF Pseudo Instructions
2451//
2452
2453def DWARF_LOC : I<0, Pseudo, (ops i32imm:$line, i32imm:$col, i32imm:$file),
2454 "; .loc $file, $line, $col",
2455 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2456 (i32 imm:$file))]>;
2457
2458def DWARF_LABEL : I<0, Pseudo, (ops i32imm:$id),
2459 "\nLdebug_loc${id:debug}:",
2460 [(dwarf_label (i32 imm:$id))]>;
2461
2462//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00002463// Non-Instruction Patterns
2464//===----------------------------------------------------------------------===//
2465
Evan Cheng71fb8342006-02-25 10:02:21 +00002466// ConstantPool GlobalAddress, ExternalSymbol
2467def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00002468def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002469def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2470def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2471
Evan Cheng069287d2006-05-16 07:21:53 +00002472def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2473 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2474def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2475 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2476def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2477 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2478def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2479 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002480
Evan Chengfc8feb12006-05-19 07:30:36 +00002481def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002482 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00002483def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002484 (MOV32mi addr:$dst, texternalsym:$src)>;
2485
Evan Cheng510e4782006-01-09 23:10:28 +00002486// Calls
Evan Cheng069287d2006-05-16 07:21:53 +00002487def : Pat<(X86tailcall GR32:$dst),
2488 (CALL32r GR32:$dst)>;
Evan Chengfea89c12006-04-27 08:40:39 +00002489
Evan Chengfea89c12006-04-27 08:40:39 +00002490def : Pat<(X86tailcall tglobaladdr:$dst),
2491 (CALLpcrel32 tglobaladdr:$dst)>;
2492def : Pat<(X86tailcall texternalsym:$dst),
2493 (CALLpcrel32 texternalsym:$dst)>;
2494
2495
2496
Evan Cheng510e4782006-01-09 23:10:28 +00002497def : Pat<(X86call tglobaladdr:$dst),
2498 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng8700e142006-01-11 06:09:51 +00002499def : Pat<(X86call texternalsym:$dst),
2500 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002501
2502// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00002503def : Pat<(addc GR32:$src1, GR32:$src2),
2504 (ADD32rr GR32:$src1, GR32:$src2)>;
2505def : Pat<(addc GR32:$src1, (load addr:$src2)),
2506 (ADD32rm GR32:$src1, addr:$src2)>;
2507def : Pat<(addc GR32:$src1, imm:$src2),
2508 (ADD32ri GR32:$src1, imm:$src2)>;
2509def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2510 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002511
Evan Cheng069287d2006-05-16 07:21:53 +00002512def : Pat<(subc GR32:$src1, GR32:$src2),
2513 (SUB32rr GR32:$src1, GR32:$src2)>;
2514def : Pat<(subc GR32:$src1, (load addr:$src2)),
2515 (SUB32rm GR32:$src1, addr:$src2)>;
2516def : Pat<(subc GR32:$src1, imm:$src2),
2517 (SUB32ri GR32:$src1, imm:$src2)>;
2518def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2519 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002520
Evan Chengb8414332006-01-13 21:45:19 +00002521def : Pat<(truncstore (i8 imm:$src), addr:$dst, i1),
2522 (MOV8mi addr:$dst, imm:$src)>;
Evan Cheng069287d2006-05-16 07:21:53 +00002523def : Pat<(truncstore GR8:$src, addr:$dst, i1),
2524 (MOV8mr addr:$dst, GR8:$src)>;
Evan Chengb8414332006-01-13 21:45:19 +00002525
Evan Cheng510e4782006-01-09 23:10:28 +00002526// {s|z}extload bool -> {s|z}extload byte
2527def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2528def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
Evan Chenge5d93432006-01-17 07:02:46 +00002529def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002530def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2531def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2532
2533// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00002534def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2535def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2536def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2537def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2538def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2539def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002540
2541// anyext -> zext
Evan Cheng069287d2006-05-16 07:21:53 +00002542def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2543def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2544def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng6e16ee52006-03-25 09:45:48 +00002545def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2546def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2547def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002548
Evan Chengcfa260b2006-01-06 02:31:59 +00002549//===----------------------------------------------------------------------===//
2550// Some peepholes
2551//===----------------------------------------------------------------------===//
2552
2553// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00002554def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2555def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2556def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002557
Evan Cheng956044c2006-01-19 23:26:24 +00002558// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002559def : Pat<(or (srl GR32:$src1, CL:$amt),
2560 (shl GR32:$src2, (sub 32, CL:$amt))),
2561 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002562
Evan Cheng21d54432006-01-20 01:13:30 +00002563def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002564 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2565 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002566
Evan Cheng956044c2006-01-19 23:26:24 +00002567// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002568def : Pat<(or (shl GR32:$src1, CL:$amt),
2569 (srl GR32:$src2, (sub 32, CL:$amt))),
2570 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002571
Evan Cheng21d54432006-01-20 01:13:30 +00002572def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002573 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2574 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002575
Evan Cheng956044c2006-01-19 23:26:24 +00002576// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002577def : Pat<(or (srl GR16:$src1, CL:$amt),
2578 (shl GR16:$src2, (sub 16, CL:$amt))),
2579 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002580
Evan Cheng21d54432006-01-20 01:13:30 +00002581def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002582 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2583 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002584
Evan Cheng956044c2006-01-19 23:26:24 +00002585// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002586def : Pat<(or (shl GR16:$src1, CL:$amt),
2587 (srl GR16:$src2, (sub 16, CL:$amt))),
2588 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002589
2590def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002591 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2592 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00002593
2594
2595//===----------------------------------------------------------------------===//
2596// Floating Point Stack Support
2597//===----------------------------------------------------------------------===//
2598
2599include "X86InstrFPStack.td"
2600
2601//===----------------------------------------------------------------------===//
2602// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2603//===----------------------------------------------------------------------===//
2604
2605include "X86InstrMMX.td"
2606
2607//===----------------------------------------------------------------------===//
2608// XMM Floating point support (requires SSE / SSE2)
2609//===----------------------------------------------------------------------===//
2610
2611include "X86InstrSSE.td"