blob: 11c67bff062b61fd5067f3aad07cb44abbc6e612 [file] [log] [blame]
Chris Lattner1cca5e32003-08-03 21:54:21 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00009//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
Evan Chengaed7c722005-12-17 01:24:02 +000016//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
Evan Chenge3413162006-01-09 18:33:28 +000020def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
Evan Cheng71fb9ad2006-01-26 00:29:36 +000024def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000025
Evan Cheng71fb9ad2006-01-26 00:29:36 +000026def SDTX86Cmov : SDTypeProfile<1, 3,
Evan Chengaed7c722005-12-17 01:24:02 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000028 SDTCisVT<3, i8>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000029
Evan Cheng71fb9ad2006-01-26 00:29:36 +000030def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000032
Evan Cheng71fb9ad2006-01-26 00:29:36 +000033def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000035
Evan Chengd9558e02006-01-06 00:43:03 +000036def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000037
Evan Chenge3413162006-01-09 18:33:28 +000038def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
40 SDTCisVT<1, i32> ]>;
41
Evan Cheng25ab6902006-09-08 06:48:29 +000042def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000043
Evan Cheng67f92a72006-01-11 22:15:48 +000044def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
45
Evan Chenge3413162006-01-09 18:33:28 +000046def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000047
Evan Cheng71fb8342006-02-25 10:02:21 +000048def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
49
Evan Chenge3413162006-01-09 18:33:28 +000050def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
51def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000052
Evan Cheng71fb9ad2006-01-26 00:29:36 +000053def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
Evan Cheng734503b2006-09-11 02:19:56 +000054 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000055
Evan Chenge3413162006-01-09 18:33:28 +000056def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000057 [SDNPInFlag, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000058def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000059 [SDNPHasChain, SDNPInFlag]>;
Evan Cheng5ee4ccc2006-01-12 08:27:59 +000060def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000061 [SDNPInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000062
Evan Chenge3413162006-01-09 18:33:28 +000063def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
64 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000065
Evan Chenge3413162006-01-09 18:33:28 +000066def X86callseq_start :
67 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +000068 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000069def X86callseq_end :
70 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Chris Lattneraf63bb02006-01-24 05:17:12 +000071 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000072
Evan Chenge3413162006-01-09 18:33:28 +000073def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
74 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +000075
Evan Chengfb914c42006-05-20 01:40:16 +000076def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
Evan Chengfea89c12006-04-27 08:40:39 +000077 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
78
Evan Cheng67f92a72006-01-11 22:15:48 +000079def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Evan Cheng99256422006-03-07 23:34:23 +000080 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Cheng67f92a72006-01-11 22:15:48 +000081def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Evan Cheng99256422006-03-07 23:34:23 +000082 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Cheng67f92a72006-01-11 22:15:48 +000083
Evan Chenge3413162006-01-09 18:33:28 +000084def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
85 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000086
Evan Cheng71fb8342006-02-25 10:02:21 +000087def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
88
Evan Chengaed7c722005-12-17 01:24:02 +000089//===----------------------------------------------------------------------===//
90// X86 Operand Definitions.
91//
92
Chris Lattner66fa1dc2004-08-11 02:25:00 +000093// *mem - Operand definitions for the funky X86 addressing mode operands.
94//
Evan Chengaf78ef52006-05-17 21:21:41 +000095class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +000096 let PrintMethod = printMethod;
Chris Lattner6adaf792005-11-19 07:01:30 +000097 let NumMIOperands = 4;
Evan Cheng25ab6902006-09-08 06:48:29 +000098 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +000099}
Nate Begeman391c5d22005-11-30 18:54:35 +0000100
Chris Lattner45432512005-12-17 19:47:05 +0000101def i8mem : X86MemOperand<"printi8mem">;
102def i16mem : X86MemOperand<"printi16mem">;
103def i32mem : X86MemOperand<"printi32mem">;
104def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000105def i128mem : X86MemOperand<"printi128mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000106def f32mem : X86MemOperand<"printf32mem">;
107def f64mem : X86MemOperand<"printf64mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000108def f128mem : X86MemOperand<"printf128mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000109
Evan Cheng25ab6902006-09-08 06:48:29 +0000110def lea32mem : Operand<i32> {
111 let PrintMethod = "printi32mem";
112 let NumMIOperands = 4;
113 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
114}
115
Nate Begeman16b04f32005-07-15 00:38:55 +0000116def SSECC : Operand<i8> {
117 let PrintMethod = "printSSECC";
118}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000119
Evan Cheng7ccced62006-02-18 00:15:05 +0000120def piclabel: Operand<i32> {
121 let PrintMethod = "printPICLabel";
122}
123
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000124// A couple of more descriptive operand definitions.
125// 16-bits but only 8 bits are significant.
126def i16i8imm : Operand<i16>;
127// 32-bits but only 8 bits are significant.
128def i32i8imm : Operand<i32>;
129
Evan Chengd35b8c12005-12-04 08:19:43 +0000130// Branch targets have OtherVT type.
131def brtarget : Operand<OtherVT>;
132
Evan Chengaed7c722005-12-17 01:24:02 +0000133//===----------------------------------------------------------------------===//
134// X86 Complex Pattern Definitions.
135//
136
Evan Chengec693f72005-12-08 02:01:35 +0000137// Define X86 specific addressing mode.
Evan Chengaf9db752006-10-11 21:03:53 +0000138def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000139def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Evan Chengaf9db752006-10-11 21:03:53 +0000140 [add, mul, shl, or, frameindex], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000141
Evan Chengaed7c722005-12-17 01:24:02 +0000142//===----------------------------------------------------------------------===//
143// X86 Instruction Format Definitions.
144//
145
Chris Lattner1cca5e32003-08-03 21:54:21 +0000146// Format specifies the encoding used by the instruction. This is part of the
147// ad-hoc solution used to emit machine instruction encodings by our machine
148// code emitter.
Evan Cheng3c55c542006-02-01 06:13:50 +0000149class Format<bits<6> val> {
150 bits<6> Value = val;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000151}
152
153def Pseudo : Format<0>; def RawFrm : Format<1>;
154def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
155def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
156def MRMSrcMem : Format<6>;
Alkis Evlogimenos169584e2004-02-27 18:55:12 +0000157def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
158def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
159def MRM6r : Format<22>; def MRM7r : Format<23>;
160def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
161def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
162def MRM6m : Format<30>; def MRM7m : Format<31>;
Evan Cheng3c55c542006-02-01 06:13:50 +0000163def MRMInitReg : Format<32>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000164
Evan Chengaed7c722005-12-17 01:24:02 +0000165//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000166// X86 Instruction Predicate Definitions.
Evan Cheng25ab6902006-09-08 06:48:29 +0000167def HasMMX : Predicate<"Subtarget->hasMMX()">;
168def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
169def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
170def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
171def FPStack : Predicate<"!Subtarget->hasSSE2()">;
172def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
173def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000174
175//===----------------------------------------------------------------------===//
Evan Chengaed7c722005-12-17 01:24:02 +0000176// X86 specific pattern fragments.
177//
178
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000179// ImmType - This specifies the immediate type used by an instruction. This is
Chris Lattner1cca5e32003-08-03 21:54:21 +0000180// part of the ad-hoc solution used to emit machine instruction encodings by our
181// machine code emitter.
Evan Cheng25ab6902006-09-08 06:48:29 +0000182class ImmType<bits<3> val> {
183 bits<3> Value = val;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000184}
185def NoImm : ImmType<0>;
186def Imm8 : ImmType<1>;
187def Imm16 : ImmType<2>;
188def Imm32 : ImmType<3>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000189def Imm64 : ImmType<4>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000190
Chris Lattner1cca5e32003-08-03 21:54:21 +0000191// FPFormat - This specifies what form this FP instruction has. This is used by
192// the Floating-Point stackifier pass.
193class FPFormat<bits<3> val> {
194 bits<3> Value = val;
195}
196def NotFP : FPFormat<0>;
197def ZeroArgFP : FPFormat<1>;
198def OneArgFP : FPFormat<2>;
199def OneArgFPRW : FPFormat<3>;
200def TwoArgFP : FPFormat<4>;
Chris Lattnerab8decc2004-06-11 04:41:24 +0000201def CompareFP : FPFormat<5>;
202def CondMovFP : FPFormat<6>;
203def SpecialFP : FPFormat<7>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000204
205
Chris Lattner3a173df2004-10-03 20:35:00 +0000206class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
207 : Instruction {
Chris Lattnerc8f45872003-08-04 04:59:56 +0000208 let Namespace = "X86";
Chris Lattner1cca5e32003-08-03 21:54:21 +0000209
Chris Lattner1cca5e32003-08-03 21:54:21 +0000210 bits<8> Opcode = opcod;
211 Format Form = f;
Evan Cheng3c55c542006-02-01 06:13:50 +0000212 bits<6> FormBits = Form.Value;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000213 ImmType ImmT = i;
Evan Cheng25ab6902006-09-08 06:48:29 +0000214 bits<3> ImmTypeBits = ImmT.Value;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000215
Chris Lattnerc96bb812004-08-11 07:12:04 +0000216 dag OperandList = ops;
217 string AsmString = AsmStr;
218
John Criswell4ffff9e2004-04-08 20:31:47 +0000219 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000220 // Attributes specific to X86 instructions...
John Criswell4ffff9e2004-04-08 20:31:47 +0000221 //
Evan Cheng25ab6902006-09-08 06:48:29 +0000222 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
223 bit hasAdSizePrefix = 0; // Does this inst have a 0x67 prefix?
John Criswell4ffff9e2004-04-08 20:31:47 +0000224
Chris Lattner1cca5e32003-08-03 21:54:21 +0000225 bits<4> Prefix = 0; // Which prefix byte does this inst have?
Evan Cheng25ab6902006-09-08 06:48:29 +0000226 bit hasREX_WPrefix = 0; // Does this inst requires the REX.W prefix?
Chris Lattner1cca5e32003-08-03 21:54:21 +0000227 FPFormat FPForm; // What flavor of FP instruction is this?
228 bits<3> FPFormBits = 0;
229}
230
231class Imp<list<Register> uses, list<Register> defs> {
232 list<Register> Uses = uses;
233 list<Register> Defs = defs;
234}
235
236
237// Prefix byte classes which are used to indicate to the ad-hoc machine code
238// emitter that various prefix bytes are required.
239class OpSize { bit hasOpSizePrefix = 1; }
Evan Cheng25ab6902006-09-08 06:48:29 +0000240class AdSize { bit hasAdSizePrefix = 1; }
241class REX_W { bit hasREX_WPrefix = 1; }
Chris Lattner1cca5e32003-08-03 21:54:21 +0000242class TB { bits<4> Prefix = 1; }
Chris Lattner915e5e52004-02-12 17:53:22 +0000243class REP { bits<4> Prefix = 2; }
244class D8 { bits<4> Prefix = 3; }
245class D9 { bits<4> Prefix = 4; }
246class DA { bits<4> Prefix = 5; }
247class DB { bits<4> Prefix = 6; }
248class DC { bits<4> Prefix = 7; }
249class DD { bits<4> Prefix = 8; }
250class DE { bits<4> Prefix = 9; }
251class DF { bits<4> Prefix = 10; }
Nate Begemanf1702ac2005-06-27 21:20:31 +0000252class XD { bits<4> Prefix = 11; }
253class XS { bits<4> Prefix = 12; }
Chris Lattner1cca5e32003-08-03 21:54:21 +0000254
255
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000256//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000257// Pattern fragments...
258//
Evan Chengd9558e02006-01-06 00:43:03 +0000259
260// X86 specific condition code. These correspond to CondCode in
261// X86ISelLowering.h. They must be kept in synch.
262def X86_COND_A : PatLeaf<(i8 0)>;
263def X86_COND_AE : PatLeaf<(i8 1)>;
264def X86_COND_B : PatLeaf<(i8 2)>;
265def X86_COND_BE : PatLeaf<(i8 3)>;
266def X86_COND_E : PatLeaf<(i8 4)>;
267def X86_COND_G : PatLeaf<(i8 5)>;
268def X86_COND_GE : PatLeaf<(i8 6)>;
269def X86_COND_L : PatLeaf<(i8 7)>;
270def X86_COND_LE : PatLeaf<(i8 8)>;
271def X86_COND_NE : PatLeaf<(i8 9)>;
272def X86_COND_NO : PatLeaf<(i8 10)>;
273def X86_COND_NP : PatLeaf<(i8 11)>;
274def X86_COND_NS : PatLeaf<(i8 12)>;
275def X86_COND_O : PatLeaf<(i8 13)>;
276def X86_COND_P : PatLeaf<(i8 14)>;
277def X86_COND_S : PatLeaf<(i8 15)>;
278
Evan Cheng9b6b6422005-12-13 00:14:11 +0000279def i16immSExt8 : PatLeaf<(i16 imm), [{
280 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000281 // sign extended field.
Evan Cheng09e3c802006-05-19 18:40:54 +0000282 return (int16_t)N->getValue() == (int8_t)N->getValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000283}]>;
284
Evan Cheng9b6b6422005-12-13 00:14:11 +0000285def i32immSExt8 : PatLeaf<(i32 imm), [{
286 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000287 // sign extended field.
Evan Cheng09e3c802006-05-19 18:40:54 +0000288 return (int32_t)N->getValue() == (int8_t)N->getValue();
Evan Chengb3558542005-12-13 00:01:09 +0000289}]>;
290
Evan Cheng605c4152005-12-13 01:57:51 +0000291// Helper fragments for loads.
Evan Cheng7a7e8372005-12-14 02:22:27 +0000292def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
293def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
294def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
Evan Cheng11e15b32006-04-03 20:53:28 +0000295def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000296
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000297def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
298def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000299
Evan Cheng466685d2006-10-09 20:57:25 +0000300def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
301def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
302def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
303def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
304def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000305
Evan Cheng466685d2006-10-09 20:57:25 +0000306def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
307def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
308def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
309def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
310def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
311def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000312
Evan Cheng466685d2006-10-09 20:57:25 +0000313def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
314def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
315def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
316def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
317def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
318def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000319
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000320//===----------------------------------------------------------------------===//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000321// Instruction templates...
Evan Cheng25ab6902006-09-08 06:48:29 +0000322//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000323
Evan Chengf0701842005-11-29 19:38:52 +0000324class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
325 : X86Inst<o, f, NoImm, ops, asm> {
326 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000327 let CodeSize = 3;
Evan Chengf0701842005-11-29 19:38:52 +0000328}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000329class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
330 : X86Inst<o, f, Imm8 , ops, asm> {
331 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000332 let CodeSize = 3;
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000333}
Chris Lattner78432fe2005-11-17 02:01:55 +0000334class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
335 : X86Inst<o, f, Imm16, ops, asm> {
336 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000337 let CodeSize = 3;
Chris Lattner78432fe2005-11-17 02:01:55 +0000338}
Chris Lattner7a125372005-11-16 22:59:19 +0000339class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
340 : X86Inst<o, f, Imm32, ops, asm> {
341 let Pattern = pattern;
Evan Cheng1693e482006-07-19 00:27:29 +0000342 let CodeSize = 3;
Chris Lattner7a125372005-11-16 22:59:19 +0000343}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000344
Chris Lattner1cca5e32003-08-03 21:54:21 +0000345//===----------------------------------------------------------------------===//
346// Instruction list...
347//
348
Evan Chengd90eb7f2006-01-05 00:27:02 +0000349def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
Evan Chenge3413162006-01-09 18:33:28 +0000350 [(X86callseq_start imm:$amt)]>;
Chris Lattner43ef1312005-09-14 21:10:24 +0000351def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
Evan Chengd90eb7f2006-01-05 00:27:02 +0000352 "#ADJCALLSTACKUP",
Evan Chenge3413162006-01-09 18:33:28 +0000353 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
Evan Chengf0701842005-11-29 19:38:52 +0000354def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
355def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000356def IMPLICIT_DEF_GR8 : I<0, Pseudo, (ops GR8:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000357 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000358 [(set GR8:$dst, (undef))]>;
359def IMPLICIT_DEF_GR16 : I<0, Pseudo, (ops GR16:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000360 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000361 [(set GR16:$dst, (undef))]>;
362def IMPLICIT_DEF_GR32 : I<0, Pseudo, (ops GR32:$dst),
Evan Cheng510e4782006-01-09 23:10:28 +0000363 "#IMPLICIT_DEF $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000364 [(set GR32:$dst, (undef))]>;
Evan Cheng4a460802006-01-11 00:33:36 +0000365
366// Nop
367def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
368
Evan Cheng8f7f7122006-05-05 05:40:20 +0000369// Truncate
Evan Cheng25ab6902006-09-08 06:48:29 +0000370def TRUNC_32_to8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR32_:$src),
371 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}", []>;
372def TRUNC_16_to8 : I<0x88, MRMDestReg, (ops GR8:$dst, GR16_:$src),
373 "mov{b} {${src:subreg8}, $dst|$dst, ${src:subreg8}}", []>;
374def TRUNC_32to16 : I<0x89, MRMDestReg, (ops GR16:$dst, GR32:$src),
375 "mov{w} {${src:subreg16}, $dst|$dst, ${src:subreg16}}",
376 [(set GR16:$dst, (trunc GR32:$src))]>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000377
Chris Lattner1cca5e32003-08-03 21:54:21 +0000378//===----------------------------------------------------------------------===//
379// Control Flow Instructions...
380//
381
Chris Lattner1be48112005-05-13 17:56:48 +0000382// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000383let isTerminator = 1, isReturn = 1, isBarrier = 1,
384 hasCtrlDep = 1, noResults = 1 in {
Evan Chenge3413162006-01-09 18:33:28 +0000385 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
386 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
387 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000388}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000389
390// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng2b4ea792005-12-26 09:11:45 +0000391let isBranch = 1, isTerminator = 1, noResults = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000392 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
393 I<opcode, RawFrm, ops, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000394
Nate Begeman37efe672006-04-22 18:53:45 +0000395// Indirect branches
Evan Chengec3bc392006-09-07 19:03:48 +0000396let isBranch = 1, isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000397 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000398
Nate Begeman37efe672006-04-22 18:53:45 +0000399let isBranch = 1, isTerminator = 1, noResults = 1, isBarrier = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000400 def JMP32r : I<0xFF, MRM4r, (ops GR32:$dst), "jmp{l} {*}$dst",
401 [(brind GR32:$dst)]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000402 def JMP32m : I<0xFF, MRM4m, (ops i32mem:$dst), "jmp{l} {*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000403 [(brind (loadi32 addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000404}
405
406// Conditional branches
Evan Cheng898101c2005-12-19 23:12:38 +0000407def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000408 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000409def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000410 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000411def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000412 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000413def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000414 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000415def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000416 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000417def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000418 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000419
Evan Chengd35b8c12005-12-04 08:19:43 +0000420def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000421 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000422def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000423 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000424def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000425 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000426def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000427 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000428
Evan Chengd9558e02006-01-06 00:43:03 +0000429def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000430 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000431def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000432 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000433def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000434 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000435def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000436 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000437def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000438 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000439def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000440 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000441
442//===----------------------------------------------------------------------===//
443// Call Instructions...
444//
Evan Chenge3413162006-01-09 18:33:28 +0000445let isCall = 1, noResults = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000446 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000447 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Nate Begeman16b04f32005-07-15 00:38:55 +0000448 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengfae29942006-06-14 22:24:55 +0000449 def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst, variable_ops),
450 "call ${dst:call}", []>;
451 def CALL32r : I<0xFF, MRM2r, (ops GR32:$dst, variable_ops),
452 "call {*}$dst", [(X86call GR32:$dst)]>;
453 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst, variable_ops),
454 "call {*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000455 }
456
Chris Lattner1e9448b2005-05-15 03:10:37 +0000457// Tail call stuff.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000458let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf10c17f2006-09-22 21:43:59 +0000459 def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call} # TAIL CALL",
460 []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000461let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf10c17f2006-09-22 21:43:59 +0000462 def TAILJMPr : I<0xFF, MRM4r, (ops GR32:$dst), "jmp {*}$dst # TAIL CALL",
463 []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000464let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000465 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
466 "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000467
Chris Lattner1cca5e32003-08-03 21:54:21 +0000468//===----------------------------------------------------------------------===//
469// Miscellaneous Instructions...
470//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000471def LEAVE : I<0xC9, RawFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000472 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000473def POP32r : I<0x58, AddRegFrm,
Evan Cheng069287d2006-05-16 07:21:53 +0000474 (ops GR32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000475
Evan Cheng7ccced62006-02-18 00:15:05 +0000476def MovePCtoStack : I<0, Pseudo, (ops piclabel:$label),
477 "call $label", []>;
478
Evan Cheng069287d2006-05-16 07:21:53 +0000479let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000480 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng069287d2006-05-16 07:21:53 +0000481 (ops GR32:$dst, GR32:$src),
Nate Begemand88fc032006-01-14 03:14:10 +0000482 "bswap{l} $dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000483 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000484
Evan Cheng069287d2006-05-16 07:21:53 +0000485def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
486 (ops GR8:$src1, GR8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000487 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000488def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
489 (ops GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000490 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000491def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
492 (ops GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000493 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattnerfc752712004-08-01 09:52:59 +0000494
Chris Lattner3a173df2004-10-03 20:35:00 +0000495def XCHG8mr : I<0x86, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000496 (ops i8mem:$src1, GR8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000497 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000498def XCHG16mr : I<0x87, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000499 (ops i16mem:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000500 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000501def XCHG32mr : I<0x87, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000502 (ops i32mem:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000503 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000504def XCHG8rm : I<0x86, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000505 (ops GR8:$src1, i8mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000506 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000507def XCHG16rm : I<0x87, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000508 (ops GR16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000509 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000510def XCHG32rm : I<0x87, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000511 (ops GR32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000512 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000513
Chris Lattner3a173df2004-10-03 20:35:00 +0000514def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +0000515 (ops GR16:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000516 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000517def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng25ab6902006-09-08 06:48:29 +0000518 (ops GR32:$dst, lea32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000519 "lea{l} {$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000520 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000521
Evan Cheng67f92a72006-01-11 22:15:48 +0000522def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
523 [(X86rep_movs i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000524 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000525def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
526 [(X86rep_movs i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000527 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Cheng94b14532006-06-02 21:09:10 +0000528def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsl|rep movsd}",
Evan Cheng67f92a72006-01-11 22:15:48 +0000529 [(X86rep_movs i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000530 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Chris Lattner915e5e52004-02-12 17:53:22 +0000531
Evan Cheng67f92a72006-01-11 22:15:48 +0000532def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
533 [(X86rep_stos i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000534 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000535def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
536 [(X86rep_stos i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000537 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Cheng67f92a72006-01-11 22:15:48 +0000538def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
539 [(X86rep_stos i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000540 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
541
Chris Lattnerb89abef2004-02-14 04:45:37 +0000542
Chris Lattner1cca5e32003-08-03 21:54:21 +0000543//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000544// Input/Output Instructions...
545//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000546def IN8rr : I<0xEC, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000547 "in{b} {%dx, %al|%AL, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000548 []>, Imp<[DX], [AL]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000549def IN16rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000550 "in{w} {%dx, %ax|%AX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000551 []>, Imp<[DX], [AX]>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000552def IN32rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000553 "in{l} {%dx, %eax|%EAX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000554 []>, Imp<[DX],[EAX]>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000555
Evan Chenga5386b02005-12-20 07:38:38 +0000556def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
557 "in{b} {$port, %al|%AL, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000558 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000559 Imp<[], [AL]>;
560def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
561 "in{w} {$port, %ax|%AX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000562 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000563 Imp<[], [AX]>, OpSize;
564def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
565 "in{l} {$port, %eax|%EAX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000566 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000567 Imp<[],[EAX]>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000568
Evan Cheng8d202232005-12-05 23:09:43 +0000569def OUT8rr : I<0xEE, RawFrm, (ops),
570 "out{b} {%al, %dx|%DX, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000571 []>, Imp<[DX, AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000572def OUT16rr : I<0xEF, RawFrm, (ops),
573 "out{w} {%ax, %dx|%DX, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000574 []>, Imp<[DX, AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000575def OUT32rr : I<0xEF, RawFrm, (ops),
576 "out{l} {%eax, %dx|%DX, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000577 []>, Imp<[DX, EAX], []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000578
Evan Cheng8d202232005-12-05 23:09:43 +0000579def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
580 "out{b} {%al, $port|$port, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000581 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000582 Imp<[AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000583def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
584 "out{w} {%ax, $port|$port, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000585 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000586 Imp<[AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000587def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
588 "out{l} {%eax, $port|$port, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000589 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000590 Imp<[EAX], []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000591
592//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000593// Move Instructions...
594//
Evan Cheng069287d2006-05-16 07:21:53 +0000595def MOV8rr : I<0x88, MRMDestReg, (ops GR8 :$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000596 "mov{b} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000597def MOV16rr : I<0x89, MRMDestReg, (ops GR16:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000598 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000599def MOV32rr : I<0x89, MRMDestReg, (ops GR32:$dst, GR32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000600 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +0000601def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops GR8 :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000602 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000603 [(set GR8:$dst, imm:$src)]>;
604def MOV16ri : Ii16<0xB8, AddRegFrm, (ops GR16:$dst, i16imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000605 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000606 [(set GR16:$dst, imm:$src)]>, OpSize;
607def MOV32ri : Ii32<0xB8, AddRegFrm, (ops GR32:$dst, i32imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000608 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000609 [(set GR32:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000610def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000611 "mov{b} {$src, $dst|$dst, $src}",
612 [(store (i8 imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000613def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000614 "mov{w} {$src, $dst|$dst, $src}",
615 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000616def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000617 "mov{l} {$src, $dst|$dst, $src}",
618 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000619
Evan Cheng069287d2006-05-16 07:21:53 +0000620def MOV8rm : I<0x8A, MRMSrcMem, (ops GR8 :$dst, i8mem :$src),
Evan Chengec693f72005-12-08 02:01:35 +0000621 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000622 [(set GR8:$dst, (load addr:$src))]>;
623def MOV16rm : I<0x8B, MRMSrcMem, (ops GR16:$dst, i16mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000624 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000625 [(set GR16:$dst, (load addr:$src))]>, OpSize;
626def MOV32rm : I<0x8B, MRMSrcMem, (ops GR32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000627 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000628 [(set GR32:$dst, (load addr:$src))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000629
Evan Cheng069287d2006-05-16 07:21:53 +0000630def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, GR8 :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000631 "mov{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000632 [(store GR8:$src, addr:$dst)]>;
633def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000634 "mov{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000635 [(store GR16:$src, addr:$dst)]>, OpSize;
636def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000637 "mov{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000638 [(store GR32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000639
Chris Lattner1cca5e32003-08-03 21:54:21 +0000640//===----------------------------------------------------------------------===//
641// Fixed-Register Multiplication and Division Instructions...
642//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000643
Chris Lattnerc8f45872003-08-04 04:59:56 +0000644// Extra precision multiplication
Evan Cheng069287d2006-05-16 07:21:53 +0000645def MUL8r : I<0xF6, MRM4r, (ops GR8:$src), "mul{b} $src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000646 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
647 // This probably ought to be moved to a def : Pat<> if the
648 // syntax can be accepted.
Evan Cheng069287d2006-05-16 07:21:53 +0000649 [(set AL, (mul AL, GR8:$src))]>,
650 Imp<[AL],[AX]>; // AL,AH = AL*GR8
651def MUL16r : I<0xF7, MRM4r, (ops GR16:$src), "mul{w} $src", []>,
652 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
653def MUL32r : I<0xF7, MRM4r, (ops GR32:$src), "mul{l} $src", []>,
654 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Chris Lattner57a02302004-08-11 04:31:00 +0000655def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
Evan Chengcf74a7c2006-01-15 10:05:20 +0000656 "mul{b} $src",
657 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
658 // This probably ought to be moved to a def : Pat<> if the
659 // syntax can be accepted.
660 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
661 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner57a02302004-08-11 04:31:00 +0000662def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000663 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
664 OpSize; // AX,DX = AX*[mem16]
Chris Lattner57a02302004-08-11 04:31:00 +0000665def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000666 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000667
Evan Cheng069287d2006-05-16 07:21:53 +0000668def IMUL8r : I<0xF6, MRM5r, (ops GR8:$src), "imul{b} $src", []>,
669 Imp<[AL],[AX]>; // AL,AH = AL*GR8
670def IMUL16r : I<0xF7, MRM5r, (ops GR16:$src), "imul{w} $src", []>,
671 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
672def IMUL32r : I<0xF7, MRM5r, (ops GR32:$src), "imul{l} $src", []>,
673 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Chris Lattner1e6a7152005-04-06 04:19:22 +0000674def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000675 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000676def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000677 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
678 OpSize; // AX,DX = AX*[mem16]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000679def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000680 "imul{l} $src", []>,
681 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000682
Chris Lattnerc8f45872003-08-04 04:59:56 +0000683// unsigned division/remainder
Evan Cheng069287d2006-05-16 07:21:53 +0000684def DIV8r : I<0xF6, MRM6r, (ops GR8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000685 "div{b} $src", []>, Imp<[AX],[AX]>;
Evan Cheng069287d2006-05-16 07:21:53 +0000686def DIV16r : I<0xF7, MRM6r, (ops GR16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000687 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000688def DIV32r : I<0xF7, MRM6r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000689 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000690def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000691 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000692def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000693 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000694def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000695 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000696
Chris Lattnerfc752712004-08-01 09:52:59 +0000697// Signed division/remainder.
Evan Cheng069287d2006-05-16 07:21:53 +0000698def IDIV8r : I<0xF6, MRM7r, (ops GR8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000699 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Evan Cheng069287d2006-05-16 07:21:53 +0000700def IDIV16r: I<0xF7, MRM7r, (ops GR16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000701 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000702def IDIV32r: I<0xF7, MRM7r, (ops GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000703 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000704def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000705 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000706def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000707 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000708def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000709 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattnerc8f45872003-08-04 04:59:56 +0000710
Chris Lattner1cca5e32003-08-03 21:54:21 +0000711
Chris Lattner1cca5e32003-08-03 21:54:21 +0000712//===----------------------------------------------------------------------===//
713// Two address Instructions...
714//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000715let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000716
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000717// Conditional moves
Evan Cheng069287d2006-05-16 07:21:53 +0000718def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
719 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000720 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000721 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000722 X86_COND_B))]>,
723 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000724def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
725 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000726 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000727 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000728 X86_COND_B))]>,
729 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000730def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
731 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000732 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000733 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000734 X86_COND_B))]>,
735 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000736def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
737 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000738 "cmovb {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000739 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000740 X86_COND_B))]>,
741 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000742
Evan Cheng069287d2006-05-16 07:21:53 +0000743def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
744 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000745 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000746 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000747 X86_COND_AE))]>,
748 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000749def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
750 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000751 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000752 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000753 X86_COND_AE))]>,
754 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000755def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
756 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000757 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000758 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000759 X86_COND_AE))]>,
760 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000761def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
762 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000763 "cmovae {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000764 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000765 X86_COND_AE))]>,
766 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000767
Evan Cheng069287d2006-05-16 07:21:53 +0000768def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
769 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000770 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000771 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000772 X86_COND_E))]>,
773 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000774def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
775 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000776 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000777 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000778 X86_COND_E))]>,
779 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000780def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
781 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000782 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000783 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000784 X86_COND_E))]>,
785 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000786def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
787 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000788 "cmove {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000789 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000790 X86_COND_E))]>,
791 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000792
Evan Cheng069287d2006-05-16 07:21:53 +0000793def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
794 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000795 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000796 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000797 X86_COND_NE))]>,
798 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000799def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
800 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000801 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000802 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000803 X86_COND_NE))]>,
804 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000805def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
806 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000807 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000808 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000809 X86_COND_NE))]>,
810 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000811def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
812 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000813 "cmovne {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000814 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000815 X86_COND_NE))]>,
816 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000817
Evan Cheng069287d2006-05-16 07:21:53 +0000818def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
819 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000820 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000821 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000822 X86_COND_BE))]>,
823 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000824def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
825 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000826 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000827 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000828 X86_COND_BE))]>,
829 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000830def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
831 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000832 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000833 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000834 X86_COND_BE))]>,
835 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000836def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
837 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000838 "cmovbe {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000839 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000840 X86_COND_BE))]>,
841 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000842
Evan Cheng069287d2006-05-16 07:21:53 +0000843def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
844 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000845 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000846 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000847 X86_COND_A))]>,
848 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000849def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
850 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000851 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000852 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000853 X86_COND_A))]>,
854 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000855def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
856 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000857 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000858 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000859 X86_COND_A))]>,
860 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000861def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
862 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000863 "cmova {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000864 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000865 X86_COND_A))]>,
866 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000867
Evan Cheng069287d2006-05-16 07:21:53 +0000868def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
869 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000870 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000871 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000872 X86_COND_L))]>,
873 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000874def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
875 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000876 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000877 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000878 X86_COND_L))]>,
879 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000880def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
881 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000882 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000883 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000884 X86_COND_L))]>,
885 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000886def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
887 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000888 "cmovl {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000889 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000890 X86_COND_L))]>,
891 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000892
Evan Cheng069287d2006-05-16 07:21:53 +0000893def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
894 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000895 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000896 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000897 X86_COND_GE))]>,
898 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000899def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
900 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000901 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000902 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000903 X86_COND_GE))]>,
904 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000905def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
906 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000907 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000908 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000909 X86_COND_GE))]>,
910 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000911def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
912 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000913 "cmovge {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000914 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000915 X86_COND_GE))]>,
916 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000917
Evan Cheng069287d2006-05-16 07:21:53 +0000918def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
919 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000920 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000921 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000922 X86_COND_LE))]>,
923 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000924def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
925 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000926 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000927 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000928 X86_COND_LE))]>,
929 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000930def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
931 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000932 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000933 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000934 X86_COND_LE))]>,
935 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000936def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
937 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000938 "cmovle {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000939 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000940 X86_COND_LE))]>,
941 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000942
Evan Cheng069287d2006-05-16 07:21:53 +0000943def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
944 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000945 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000946 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000947 X86_COND_G))]>,
948 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000949def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
950 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000951 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000952 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000953 X86_COND_G))]>,
954 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000955def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
956 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000957 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000958 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000959 X86_COND_G))]>,
960 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000961def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
962 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000963 "cmovg {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000964 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000965 X86_COND_G))]>,
966 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000967
Evan Cheng069287d2006-05-16 07:21:53 +0000968def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
969 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000970 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000971 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000972 X86_COND_S))]>,
973 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000974def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
975 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000976 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000977 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000978 X86_COND_S))]>,
979 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000980def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
981 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000982 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000983 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000984 X86_COND_S))]>,
985 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000986def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
987 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000988 "cmovs {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000989 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000990 X86_COND_S))]>,
991 TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000992
Evan Cheng069287d2006-05-16 07:21:53 +0000993def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
994 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +0000995 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000996 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000997 X86_COND_NS))]>,
998 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000999def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1000 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001001 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001002 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001003 X86_COND_NS))]>,
1004 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001005def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
1006 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001007 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001008 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001009 X86_COND_NS))]>,
1010 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001011def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1012 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001013 "cmovns {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001014 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001015 X86_COND_NS))]>,
1016 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001017
Evan Cheng069287d2006-05-16 07:21:53 +00001018def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
1019 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001020 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001021 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001022 X86_COND_P))]>,
1023 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001024def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1025 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001026 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001027 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001028 X86_COND_P))]>,
1029 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001030def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
1031 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001032 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001033 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001034 X86_COND_P))]>,
1035 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001036def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1037 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001038 "cmovp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001039 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001040 X86_COND_P))]>,
1041 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001042
Evan Cheng069287d2006-05-16 07:21:53 +00001043def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
1044 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001045 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001046 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001047 X86_COND_NP))]>,
1048 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001049def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1050 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001051 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001052 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001053 X86_COND_NP))]>,
1054 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001055def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
1056 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001057 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001058 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001059 X86_COND_NP))]>,
1060 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001061def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1062 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001063 "cmovnp {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001064 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001065 X86_COND_NP))]>,
1066 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001067
1068
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001069// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001070let CodeSize = 2 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001071def NEG8r : I<0xF6, MRM3r, (ops GR8 :$dst, GR8 :$src), "neg{b} $dst",
1072 [(set GR8:$dst, (ineg GR8:$src))]>;
1073def NEG16r : I<0xF7, MRM3r, (ops GR16:$dst, GR16:$src), "neg{w} $dst",
1074 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
1075def NEG32r : I<0xF7, MRM3r, (ops GR32:$dst, GR32:$src), "neg{l} $dst",
1076 [(set GR32:$dst, (ineg GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001077let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001078 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001079 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001080 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001081 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001082 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001083 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1084
Chris Lattner57a02302004-08-11 04:31:00 +00001085}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001086
Evan Cheng069287d2006-05-16 07:21:53 +00001087def NOT8r : I<0xF6, MRM2r, (ops GR8 :$dst, GR8 :$src), "not{b} $dst",
1088 [(set GR8:$dst, (not GR8:$src))]>;
1089def NOT16r : I<0xF7, MRM2r, (ops GR16:$dst, GR16:$src), "not{w} $dst",
1090 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
1091def NOT32r : I<0xF7, MRM2r, (ops GR32:$dst, GR32:$src), "not{l} $dst",
1092 [(set GR32:$dst, (not GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001093let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001094 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001095 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001096 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001097 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001098 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001099 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001100}
Evan Cheng1693e482006-07-19 00:27:29 +00001101} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001102
Evan Chengb51a0592005-12-10 00:48:20 +00001103// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng1693e482006-07-19 00:27:29 +00001104let CodeSize = 2 in
Evan Cheng069287d2006-05-16 07:21:53 +00001105def INC8r : I<0xFE, MRM0r, (ops GR8 :$dst, GR8 :$src), "inc{b} $dst",
1106 [(set GR8:$dst, (add GR8:$src, 1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001107let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Evan Chengf7eb5d02006-07-11 19:49:49 +00001108def INC16r : I<0x40, AddRegFrm, (ops GR16:$dst, GR16:$src), "inc{w} $dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001109 [(set GR16:$dst, (add GR16:$src, 1))]>,
1110 OpSize, Requires<[In32BitMode]>;
Evan Chengf7eb5d02006-07-11 19:49:49 +00001111def INC32r : I<0x40, AddRegFrm, (ops GR32:$dst, GR32:$src), "inc{l} $dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001112 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001113}
Evan Cheng1693e482006-07-19 00:27:29 +00001114let isTwoAddress = 0, CodeSize = 2 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001115 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001116 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001117 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001118 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001119 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001120 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001121}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001122
Evan Cheng1693e482006-07-19 00:27:29 +00001123let CodeSize = 2 in
Evan Cheng069287d2006-05-16 07:21:53 +00001124def DEC8r : I<0xFE, MRM1r, (ops GR8 :$dst, GR8 :$src), "dec{b} $dst",
1125 [(set GR8:$dst, (add GR8:$src, -1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001126let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Evan Chengf7eb5d02006-07-11 19:49:49 +00001127def DEC16r : I<0x48, AddRegFrm, (ops GR16:$dst, GR16:$src), "dec{w} $dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001128 [(set GR16:$dst, (add GR16:$src, -1))]>,
1129 OpSize, Requires<[In32BitMode]>;
Evan Chengf7eb5d02006-07-11 19:49:49 +00001130def DEC32r : I<0x48, AddRegFrm, (ops GR32:$dst, GR32:$src), "dec{l} $dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001131 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001132}
Chris Lattner57a02302004-08-11 04:31:00 +00001133
Evan Cheng1693e482006-07-19 00:27:29 +00001134let isTwoAddress = 0, CodeSize = 2 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001135 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001136 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001137 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001138 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001139 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001140 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001141}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001142
1143// Logical operators...
Chris Lattnercc65bee2005-01-02 02:35:46 +00001144let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001145def AND8rr : I<0x20, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001146 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001147 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001148 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001149def AND16rr : I<0x21, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001150 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001151 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001152 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001153def AND32rr : I<0x21, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001154 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001155 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001156 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001157}
Chris Lattner57a02302004-08-11 04:31:00 +00001158
Chris Lattner3a173df2004-10-03 20:35:00 +00001159def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001160 (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001161 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001162 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001163def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001164 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001165 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001166 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001167def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001168 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001169 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001170 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001171
Chris Lattner3a173df2004-10-03 20:35:00 +00001172def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001173 (ops GR8 :$dst, GR8 :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001174 "and{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001175 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001176def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001177 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001178 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001179 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001180def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001181 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001182 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001183 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001184def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001185 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001186 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001187 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001188 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001189def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng069287d2006-05-16 07:21:53 +00001190 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001191 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001192 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001193
1194let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001195 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001196 (ops i8mem :$dst, GR8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001197 "and{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001198 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001199 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001200 (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001201 "and{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001202 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001203 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001204 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001205 (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001206 "and{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001207 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001208 def AND8mi : Ii8<0x80, MRM4m,
1209 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001210 "and{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001211 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001212 def AND16mi : Ii16<0x81, MRM4m,
1213 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001214 "and{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001215 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001216 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001217 def AND32mi : Ii32<0x81, MRM4m,
1218 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001219 "and{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001220 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001221 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001222 (ops i16mem:$dst, i16i8imm :$src),
1223 "and{w} {$src, $dst|$dst, $src}",
1224 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1225 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001226 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001227 (ops i32mem:$dst, i32i8imm :$src),
1228 "and{l} {$src, $dst|$dst, $src}",
Evan Chenge3703d42006-01-14 01:18:49 +00001229 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001230}
1231
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001232
Chris Lattnercc65bee2005-01-02 02:35:46 +00001233let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001234def OR8rr : I<0x08, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001235 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001236 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
1237def OR16rr : I<0x09, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001238 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001239 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
1240def OR32rr : I<0x09, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001241 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001242 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001243}
Evan Cheng069287d2006-05-16 07:21:53 +00001244def OR8rm : I<0x0A, MRMSrcMem , (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001245 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001246 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
1247def OR16rm : I<0x0B, MRMSrcMem , (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001248 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001249 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
1250def OR32rm : I<0x0B, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001251 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001252 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001253
Evan Cheng069287d2006-05-16 07:21:53 +00001254def OR8ri : Ii8 <0x80, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001255 "or{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001256 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
1257def OR16ri : Ii16<0x81, MRM1r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001258 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001259 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
1260def OR32ri : Ii32<0x81, MRM1r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001261 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001262 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001263
Evan Cheng069287d2006-05-16 07:21:53 +00001264def OR16ri8 : Ii8<0x83, MRM1r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001265 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001266 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1267def OR32ri8 : Ii8<0x83, MRM1r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001268 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001269 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001270let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001271 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, GR8:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001272 "or{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001273 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
1274 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001275 "or{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001276 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
1277 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001278 "or{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001279 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001280 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001281 "or{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001282 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001283 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001284 "or{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001285 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001286 OpSize;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001287 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001288 "or{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001289 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng0ef3a772005-12-13 01:41:36 +00001290 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1291 "or{w} {$src, $dst|$dst, $src}",
1292 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1293 OpSize;
1294 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1295 "or{l} {$src, $dst|$dst, $src}",
1296 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001297}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001298
1299
Chris Lattnercc65bee2005-01-02 02:35:46 +00001300let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001301def XOR8rr : I<0x30, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001302 (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001303 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001304 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001305def XOR16rr : I<0x31, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001306 (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001307 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001308 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001309def XOR32rr : I<0x31, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001310 (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001311 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001312 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001313}
1314
Chris Lattner3a173df2004-10-03 20:35:00 +00001315def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001316 (ops GR8 :$dst, GR8:$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001317 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001318 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001319def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001320 (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001321 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001322 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001323def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng069287d2006-05-16 07:21:53 +00001324 (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001325 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001326 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001327
Chris Lattner3a173df2004-10-03 20:35:00 +00001328def XOR8ri : Ii8<0x80, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001329 (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001330 "xor{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001331 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001332def XOR16ri : Ii16<0x81, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001333 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001334 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001335 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001336def XOR32ri : Ii32<0x81, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001337 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001338 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001339 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001340def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001341 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001342 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001343 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001344 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001345def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Cheng069287d2006-05-16 07:21:53 +00001346 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001347 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001348 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001349let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001350 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001351 (ops i8mem :$dst, GR8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001352 "xor{b} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001353 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001354 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001355 (ops i16mem:$dst, GR16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001356 "xor{w} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001357 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001358 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001359 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001360 (ops i32mem:$dst, GR32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001361 "xor{l} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001362 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001363 def XOR8mi : Ii8<0x80, MRM6m,
1364 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001365 "xor{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001366 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001367 def XOR16mi : Ii16<0x81, MRM6m,
1368 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001369 "xor{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001370 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001371 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001372 def XOR32mi : Ii32<0x81, MRM6m,
1373 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001374 "xor{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001375 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001376 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001377 (ops i16mem:$dst, i16i8imm :$src),
1378 "xor{w} {$src, $dst|$dst, $src}",
1379 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1380 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001381 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001382 (ops i32mem:$dst, i32i8imm :$src),
1383 "xor{l} {$src, $dst|$dst, $src}",
1384 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001385}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001386
1387// Shift instructions
Evan Cheng069287d2006-05-16 07:21:53 +00001388def SHL8rCL : I<0xD2, MRM4r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001389 "shl{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001390 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
1391def SHL16rCL : I<0xD3, MRM4r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001392 "shl{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001393 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1394def SHL32rCL : I<0xD3, MRM4r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001395 "shl{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001396 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001397
Evan Cheng069287d2006-05-16 07:21:53 +00001398def SHL8ri : Ii8<0xC0, MRM4r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001399 "shl{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001400 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001401let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001402def SHL16ri : Ii8<0xC1, MRM4r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001403 "shl{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001404 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1405def SHL32ri : Ii8<0xC1, MRM4r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001406 "shl{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001407 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001408}
Chris Lattnerf29ed092004-08-11 05:07:25 +00001409
Evan Cheng09c54572006-06-29 00:36:51 +00001410// Shift left by one. Not used because (add x, x) is slightly cheaper.
1411def SHL8r1 : I<0xD0, MRM4r, (ops GR8 :$dst, GR8 :$src1),
Evan Chengcbac2fa2006-07-20 21:37:39 +00001412 "shl{b} $dst", []>;
Evan Cheng09c54572006-06-29 00:36:51 +00001413def SHL16r1 : I<0xD1, MRM4r, (ops GR16:$dst, GR16:$src1),
Evan Chengcbac2fa2006-07-20 21:37:39 +00001414 "shl{w} $dst", []>, OpSize;
Evan Cheng09c54572006-06-29 00:36:51 +00001415def SHL32r1 : I<0xD1, MRM4r, (ops GR32:$dst, GR32:$src1),
Evan Chengcbac2fa2006-07-20 21:37:39 +00001416 "shl{l} $dst", []>;
Evan Cheng09c54572006-06-29 00:36:51 +00001417
Chris Lattnerf29ed092004-08-11 05:07:25 +00001418let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001419 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001420 "shl{b} {%cl, $dst|$dst, %CL}",
1421 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1422 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001423 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001424 "shl{w} {%cl, $dst|$dst, %CL}",
1425 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1426 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001427 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001428 "shl{l} {%cl, $dst|$dst, %CL}",
1429 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1430 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001431 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001432 "shl{b} {$src, $dst|$dst, $src}",
1433 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001434 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001435 "shl{w} {$src, $dst|$dst, $src}",
1436 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1437 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001438 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001439 "shl{l} {$src, $dst|$dst, $src}",
1440 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001441
1442 // Shift by 1
1443 def SHL8m1 : I<0xD0, MRM4m, (ops i8mem :$dst),
1444 "shl{b} $dst",
1445 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1446 def SHL16m1 : I<0xD1, MRM4m, (ops i16mem:$dst),
1447 "shl{w} $dst",
1448 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1449 OpSize;
1450 def SHL32m1 : I<0xD1, MRM4m, (ops i32mem:$dst),
1451 "shl{l} $dst",
1452 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001453}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001454
Evan Cheng069287d2006-05-16 07:21:53 +00001455def SHR8rCL : I<0xD2, MRM5r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001456 "shr{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001457 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
1458def SHR16rCL : I<0xD3, MRM5r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001459 "shr{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001460 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1461def SHR32rCL : I<0xD3, MRM5r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001462 "shr{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001463 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001464
Evan Cheng069287d2006-05-16 07:21:53 +00001465def SHR8ri : Ii8<0xC0, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001466 "shr{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001467 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
1468def SHR16ri : Ii8<0xC1, MRM5r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001469 "shr{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001470 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1471def SHR32ri : Ii8<0xC1, MRM5r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001472 "shr{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001473 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001474
Evan Cheng09c54572006-06-29 00:36:51 +00001475// Shift by 1
1476def SHR8r1 : I<0xD0, MRM5r, (ops GR8:$dst, GR8:$src1),
1477 "shr{b} $dst",
1478 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
1479def SHR16r1 : I<0xD1, MRM5r, (ops GR16:$dst, GR16:$src1),
1480 "shr{w} $dst",
1481 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
1482def SHR32r1 : I<0xD1, MRM5r, (ops GR32:$dst, GR32:$src1),
1483 "shr{l} $dst",
1484 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1485
Chris Lattner57a02302004-08-11 04:31:00 +00001486let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001487 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001488 "shr{b} {%cl, $dst|$dst, %CL}",
1489 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1490 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001491 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001492 "shr{w} {%cl, $dst|$dst, %CL}",
1493 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1494 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001495 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001496 "shr{l} {%cl, $dst|$dst, %CL}",
1497 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1498 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001499 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001500 "shr{b} {$src, $dst|$dst, $src}",
1501 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001502 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001503 "shr{w} {$src, $dst|$dst, $src}",
1504 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1505 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001506 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001507 "shr{l} {$src, $dst|$dst, $src}",
1508 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001509
1510 // Shift by 1
1511 def SHR8m1 : I<0xD0, MRM5m, (ops i8mem :$dst),
1512 "shr{b} $dst",
1513 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1514 def SHR16m1 : I<0xD1, MRM5m, (ops i16mem:$dst),
1515 "shr{w} $dst",
1516 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
1517 def SHR32m1 : I<0xD1, MRM5m, (ops i32mem:$dst),
1518 "shr{l} $dst",
1519 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001520}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001521
Evan Cheng069287d2006-05-16 07:21:53 +00001522def SAR8rCL : I<0xD2, MRM7r, (ops GR8 :$dst, GR8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001523 "sar{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001524 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
1525def SAR16rCL : I<0xD3, MRM7r, (ops GR16:$dst, GR16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001526 "sar{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001527 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1528def SAR32rCL : I<0xD3, MRM7r, (ops GR32:$dst, GR32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001529 "sar{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001530 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001531
Evan Cheng069287d2006-05-16 07:21:53 +00001532def SAR8ri : Ii8<0xC0, MRM7r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001533 "sar{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001534 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
1535def SAR16ri : Ii8<0xC1, MRM7r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001536 "sar{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001537 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001538 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001539def SAR32ri : Ii8<0xC1, MRM7r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001540 "sar{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001541 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001542
1543// Shift by 1
1544def SAR8r1 : I<0xD0, MRM7r, (ops GR8 :$dst, GR8 :$src1),
1545 "sar{b} $dst",
1546 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
1547def SAR16r1 : I<0xD1, MRM7r, (ops GR16:$dst, GR16:$src1),
1548 "sar{w} $dst",
1549 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
1550def SAR32r1 : I<0xD1, MRM7r, (ops GR32:$dst, GR32:$src1),
1551 "sar{l} $dst",
1552 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1553
Chris Lattnerf29ed092004-08-11 05:07:25 +00001554let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001555 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001556 "sar{b} {%cl, $dst|$dst, %CL}",
1557 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1558 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001559 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001560 "sar{w} {%cl, $dst|$dst, %CL}",
1561 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1562 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001563 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001564 "sar{l} {%cl, $dst|$dst, %CL}",
1565 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1566 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001567 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001568 "sar{b} {$src, $dst|$dst, $src}",
1569 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001570 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001571 "sar{w} {$src, $dst|$dst, $src}",
1572 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1573 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001574 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001575 "sar{l} {$src, $dst|$dst, $src}",
1576 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001577
1578 // Shift by 1
1579 def SAR8m1 : I<0xD0, MRM7m, (ops i8mem :$dst),
1580 "sar{b} $dst",
1581 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1582 def SAR16m1 : I<0xD1, MRM7m, (ops i16mem:$dst),
1583 "sar{w} $dst",
1584 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1585 OpSize;
1586 def SAR32m1 : I<0xD1, MRM7m, (ops i32mem:$dst),
1587 "sar{l} $dst",
1588 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001589}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001590
Chris Lattner40ff6332005-01-19 07:50:03 +00001591// Rotate instructions
1592// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng069287d2006-05-16 07:21:53 +00001593def ROL8rCL : I<0xD2, MRM0r, (ops GR8 :$dst, GR8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001594 "rol{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001595 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
1596def ROL16rCL : I<0xD3, MRM0r, (ops GR16:$dst, GR16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001597 "rol{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001598 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1599def ROL32rCL : I<0xD3, MRM0r, (ops GR32:$dst, GR32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001600 "rol{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001601 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001602
Evan Cheng069287d2006-05-16 07:21:53 +00001603def ROL8ri : Ii8<0xC0, MRM0r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001604 "rol{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001605 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
1606def ROL16ri : Ii8<0xC1, MRM0r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001607 "rol{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001608 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1609def ROL32ri : Ii8<0xC1, MRM0r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001610 "rol{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001611 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001612
Evan Cheng09c54572006-06-29 00:36:51 +00001613// Rotate by 1
1614def ROL8r1 : I<0xD0, MRM0r, (ops GR8 :$dst, GR8 :$src1),
1615 "rol{b} $dst",
1616 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
1617def ROL16r1 : I<0xD1, MRM0r, (ops GR16:$dst, GR16:$src1),
1618 "rol{w} $dst",
1619 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
1620def ROL32r1 : I<0xD1, MRM0r, (ops GR32:$dst, GR32:$src1),
1621 "rol{l} $dst",
1622 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1623
Chris Lattner40ff6332005-01-19 07:50:03 +00001624let isTwoAddress = 0 in {
1625 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001626 "rol{b} {%cl, $dst|$dst, %CL}",
1627 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1628 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001629 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001630 "rol{w} {%cl, $dst|$dst, %CL}",
1631 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1632 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001633 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001634 "rol{l} {%cl, $dst|$dst, %CL}",
1635 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1636 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001637 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001638 "rol{b} {$src, $dst|$dst, $src}",
1639 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001640 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001641 "rol{w} {$src, $dst|$dst, $src}",
1642 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1643 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001644 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001645 "rol{l} {$src, $dst|$dst, $src}",
1646 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001647
1648 // Rotate by 1
1649 def ROL8m1 : I<0xD0, MRM0m, (ops i8mem :$dst),
1650 "rol{b} $dst",
1651 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1652 def ROL16m1 : I<0xD1, MRM0m, (ops i16mem:$dst),
1653 "rol{w} $dst",
1654 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1655 OpSize;
1656 def ROL32m1 : I<0xD1, MRM0m, (ops i32mem:$dst),
1657 "rol{l} $dst",
1658 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001659}
1660
Evan Cheng069287d2006-05-16 07:21:53 +00001661def ROR8rCL : I<0xD2, MRM1r, (ops GR8 :$dst, GR8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001662 "ror{b} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001663 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
1664def ROR16rCL : I<0xD3, MRM1r, (ops GR16:$dst, GR16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001665 "ror{w} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001666 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
1667def ROR32rCL : I<0xD3, MRM1r, (ops GR32:$dst, GR32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001668 "ror{l} {%cl, $dst|$dst, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001669 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001670
Evan Cheng069287d2006-05-16 07:21:53 +00001671def ROR8ri : Ii8<0xC0, MRM1r, (ops GR8 :$dst, GR8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001672 "ror{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001673 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
1674def ROR16ri : Ii8<0xC1, MRM1r, (ops GR16:$dst, GR16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001675 "ror{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001676 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
1677def ROR32ri : Ii8<0xC1, MRM1r, (ops GR32:$dst, GR32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001678 "ror{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001679 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001680
1681// Rotate by 1
1682def ROR8r1 : I<0xD0, MRM1r, (ops GR8 :$dst, GR8 :$src1),
1683 "ror{b} $dst",
1684 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
1685def ROR16r1 : I<0xD1, MRM1r, (ops GR16:$dst, GR16:$src1),
1686 "ror{w} $dst",
1687 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
1688def ROR32r1 : I<0xD1, MRM1r, (ops GR32:$dst, GR32:$src1),
1689 "ror{l} $dst",
1690 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1691
Chris Lattner40ff6332005-01-19 07:50:03 +00001692let isTwoAddress = 0 in {
1693 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001694 "ror{b} {%cl, $dst|$dst, %CL}",
1695 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1696 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001697 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001698 "ror{w} {%cl, $dst|$dst, %CL}",
1699 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1700 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001701 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001702 "ror{l} {%cl, $dst|$dst, %CL}",
1703 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1704 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001705 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001706 "ror{b} {$src, $dst|$dst, $src}",
1707 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001708 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001709 "ror{w} {$src, $dst|$dst, $src}",
1710 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1711 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001712 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001713 "ror{l} {$src, $dst|$dst, $src}",
1714 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001715
1716 // Rotate by 1
1717 def ROR8m1 : I<0xD0, MRM1m, (ops i8mem :$dst),
1718 "ror{b} $dst",
1719 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
1720 def ROR16m1 : I<0xD1, MRM1m, (ops i16mem:$dst),
1721 "ror{w} $dst",
1722 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1723 OpSize;
1724 def ROR32m1 : I<0xD1, MRM1m, (ops i32mem:$dst),
1725 "ror{l} $dst",
1726 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001727}
1728
1729
1730
1731// Double shift instructions (generalizations of rotate)
Evan Cheng069287d2006-05-16 07:21:53 +00001732def SHLD32rrCL : I<0xA5, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001733 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001734 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001735 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001736def SHRD32rrCL : I<0xAD, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001737 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001738 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001739 Imp<[CL],[]>, TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001740def SHLD16rrCL : I<0xA5, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001741 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001742 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001743 Imp<[CL],[]>, TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001744def SHRD16rrCL : I<0xAD, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001745 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001746 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001747 Imp<[CL],[]>, TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001748
1749let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001750def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001751 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001752 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001753 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001754 (i8 imm:$src3)))]>,
1755 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001756def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001757 (ops GR32:$dst, GR32:$src1, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001758 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001759 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001760 (i8 imm:$src3)))]>,
1761 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001762def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001763 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001764 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001765 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001766 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001767 TB, OpSize;
1768def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00001769 (ops GR16:$dst, GR16:$src1, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001770 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001771 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001772 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001773 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001774}
Chris Lattner0e967d42004-08-01 08:13:11 +00001775
Chris Lattner57a02302004-08-11 04:31:00 +00001776let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001777 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001778 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001779 [(store (X86shld (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;
Evan Cheng069287d2006-05-16 07:21:53 +00001782 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001783 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001784 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001785 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001786 Imp<[CL],[]>, TB;
1787 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001788 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001789 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001790 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001791 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001792 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001793 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001794 (ops i32mem:$dst, GR32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001795 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001796 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001797 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001798 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001799
Evan Cheng069287d2006-05-16 07:21:53 +00001800 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001801 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001802 [(store (X86shld (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;
Evan Cheng069287d2006-05-16 07:21:53 +00001805 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001806 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001807 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Chenge3413162006-01-09 18:33:28 +00001808 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001809 Imp<[CL],[]>, TB, OpSize;
1810 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001811 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001812 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001813 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001814 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001815 TB, OpSize;
1816 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00001817 (ops i16mem:$dst, GR16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001818 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001819 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001820 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001821 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001822}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001823
1824
Chris Lattnercc65bee2005-01-02 02:35:46 +00001825// Arithmetic.
1826let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001827def ADD8rr : I<0x00, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001828 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001829 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001830let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001831def ADD16rr : I<0x01, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001832 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001833 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
1834def ADD32rr : I<0x01, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001835 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001836 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001837} // end isConvertibleToThreeAddress
1838} // end isCommutable
Evan Cheng069287d2006-05-16 07:21:53 +00001839def ADD8rm : I<0x02, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001840 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001841 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
1842def ADD16rm : I<0x03, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001843 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001844 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
1845def ADD32rm : I<0x03, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001846 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001847 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001848
Evan Cheng069287d2006-05-16 07:21:53 +00001849def ADD8ri : Ii8<0x80, MRM0r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001850 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001851 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001852
1853let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng069287d2006-05-16 07:21:53 +00001854def ADD16ri : Ii16<0x81, MRM0r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001855 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001856 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
1857def ADD32ri : Ii32<0x81, MRM0r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001858 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001859 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng069287d2006-05-16 07:21:53 +00001860def ADD16ri8 : Ii8<0x83, MRM0r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001861 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001862 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001863 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001864def ADD32ri8 : Ii8<0x83, MRM0r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001865 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001866 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00001867}
Chris Lattner57a02302004-08-11 04:31:00 +00001868
1869let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001870 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001871 "add{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001872 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
1873 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001874 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001875 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001876 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001877 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001878 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001879 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001880 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001881 "add{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001882 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001883 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001884 "add{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001885 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001886 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001887 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001888 "add{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001889 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengee93f9d2005-12-12 19:45:23 +00001890 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1891 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001892 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1893 OpSize;
Evan Chengee93f9d2005-12-12 19:45:23 +00001894 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1895 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001896 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001897}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001898
Chris Lattner10197ff2005-01-03 01:27:59 +00001899let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00001900def ADC32rr : I<0x11, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001901 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001902 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001903}
Evan Cheng069287d2006-05-16 07:21:53 +00001904def ADC32rm : I<0x13, MRMSrcMem , (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001905 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001906 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
1907def ADC32ri : Ii32<0x81, MRM2r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001908 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001909 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
1910def ADC32ri8 : Ii8<0x83, MRM2r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001911 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001912 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001913
1914let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001915 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001916 "adc{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001917 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001918 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001919 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001920 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chenge3413162006-01-09 18:33:28 +00001921 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1922 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001923 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001924}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001925
Evan Cheng069287d2006-05-16 07:21:53 +00001926def SUB8rr : I<0x28, MRMDestReg, (ops GR8 :$dst, GR8 :$src1, GR8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001927 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001928 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
1929def SUB16rr : I<0x29, MRMDestReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001930 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001931 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
1932def SUB32rr : I<0x29, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001933 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001934 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
1935def SUB8rm : I<0x2A, MRMSrcMem, (ops GR8 :$dst, GR8 :$src1, i8mem :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001936 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001937 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
1938def SUB16rm : I<0x2B, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001939 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001940 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
1941def SUB32rm : I<0x2B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001942 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001943 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001944
Evan Cheng069287d2006-05-16 07:21:53 +00001945def SUB8ri : Ii8 <0x80, MRM5r, (ops GR8:$dst, GR8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001946 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001947 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
1948def SUB16ri : Ii16<0x81, MRM5r, (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001949 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001950 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
1951def SUB32ri : Ii32<0x81, MRM5r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001952 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001953 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
1954def SUB16ri8 : Ii8<0x83, MRM5r, (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001955 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001956 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001957 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001958def SUB32ri8 : Ii8<0x83, MRM5r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001959 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001960 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001961let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001962 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, GR8 :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001963 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001964 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
1965 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, GR16:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001966 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001967 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001968 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001969 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001970 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001971 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001972 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001973 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001974 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001975 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001976 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001977 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001978 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001979 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001980 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001981 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengd160d482005-12-12 21:54:05 +00001982 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1983 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001984 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1985 OpSize;
Evan Chengd160d482005-12-12 21:54:05 +00001986 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1987 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001988 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001989}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001990
Evan Cheng069287d2006-05-16 07:21:53 +00001991def SBB32rr : I<0x19, MRMDestReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001992 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001993 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001994
Chris Lattner57a02302004-08-11 04:31:00 +00001995let isTwoAddress = 0 in {
Evan Cheng069287d2006-05-16 07:21:53 +00001996 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, GR32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001997 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001998 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001999 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002000 "sbb{b} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002001 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002002 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002003 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002004 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chenge3413162006-01-09 18:33:28 +00002005 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
2006 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002007 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002008}
Evan Cheng069287d2006-05-16 07:21:53 +00002009def SBB32rm : I<0x1B, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002010 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002011 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
2012def SBB32ri : Ii32<0x81, MRM3r, (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002013 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002014 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
2015def SBB32ri8 : Ii8<0x83, MRM3r, (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00002016 "sbb{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002017 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002018
Chris Lattner10197ff2005-01-03 01:27:59 +00002019let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Cheng069287d2006-05-16 07:21:53 +00002020def IMUL16rr : I<0xAF, MRMSrcReg, (ops GR16:$dst, GR16:$src1, GR16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002021 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002022 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
2023def IMUL32rr : I<0xAF, MRMSrcReg, (ops GR32:$dst, GR32:$src1, GR32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00002024 "imul{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002025 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002026}
Evan Cheng069287d2006-05-16 07:21:53 +00002027def IMUL16rm : I<0xAF, MRMSrcMem, (ops GR16:$dst, GR16:$src1, i16mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002028 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002029 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002030 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002031def IMUL32rm : I<0xAF, MRMSrcMem, (ops GR32:$dst, GR32:$src1, i32mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002032 "imul{l} {$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002033 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002034
2035} // end Two Address instructions
2036
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002037// Suprisingly enough, these are not two address instructions!
Evan Cheng069287d2006-05-16 07:21:53 +00002038def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
2039 (ops GR16:$dst, GR16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00002040 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002041 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2042def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
2043 (ops GR32:$dst, GR32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00002044 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002045 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2046def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
2047 (ops GR16:$dst, GR16:$src1, i16i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002048 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002049 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002050 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002051def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
2052 (ops GR32:$dst, GR32:$src1, i32i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002053 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002054 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002055
Evan Cheng069287d2006-05-16 07:21:53 +00002056def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
2057 (ops GR16:$dst, i16mem:$src1, i16imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002058 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002059 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
Evan Chengf281e022005-12-12 23:47:46 +00002060 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002061def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
2062 (ops GR32:$dst, i32mem:$src1, i32imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002063 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002064 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2065def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
2066 (ops GR16:$dst, i16mem:$src1, i16i8imm :$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002067 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002068 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002069 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002070def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
2071 (ops GR32:$dst, i32mem:$src1, i32i8imm: $src2),
Evan Chengf281e022005-12-12 23:47:46 +00002072 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002073 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002074
2075//===----------------------------------------------------------------------===//
2076// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002077//
Chris Lattnercc65bee2005-01-02 02:35:46 +00002078let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng069287d2006-05-16 07:21:53 +00002079def TEST8rr : I<0x84, MRMDestReg, (ops GR8:$src1, GR8:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002080 "test{b} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002081 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002082def TEST16rr : I<0x85, MRMDestReg, (ops GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002083 "test{w} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002084 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002085def TEST32rr : I<0x85, MRMDestReg, (ops GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002086 "test{l} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002087 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002088}
Evan Cheng734503b2006-09-11 02:19:56 +00002089
Evan Cheng069287d2006-05-16 07:21:53 +00002090def TEST8rm : I<0x84, MRMSrcMem, (ops GR8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002091 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002092 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002093def TEST16rm : I<0x85, MRMSrcMem, (ops GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002094 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002095 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002096 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002097def TEST32rm : I<0x85, MRMSrcMem, (ops GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002098 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002099 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002100
Evan Cheng069287d2006-05-16 07:21:53 +00002101def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
2102 (ops GR8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002103 "test{b} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002104 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002105def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
2106 (ops GR16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002107 "test{w} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002108 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002109def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
2110 (ops GR32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002111 "test{l} {$src2, $src1|$src1, $src2}",
Chris Lattnerffc0b262006-09-07 20:33:45 +00002112 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002113
Chris Lattner707c6fe2004-10-04 01:38:10 +00002114def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengaed7c722005-12-17 01:24:02 +00002115 (ops i8mem:$src1, i8imm:$src2),
2116 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002117 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002118def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2119 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002120 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002121 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002122 OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002123def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2124 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002125 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng734503b2006-09-11 02:19:56 +00002126 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002127
2128
2129// Condition code ops, incl. set if equal/not equal/...
Evan Chengf0701842005-11-29 19:38:52 +00002130def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2131def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002132
Chris Lattner3a173df2004-10-03 20:35:00 +00002133def SETEr : I<0x94, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002134 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002135 "sete $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002136 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2137 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002138def SETEm : I<0x94, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002139 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002140 "sete $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002141 [(store (X86setcc X86_COND_E), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002142 TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002143def SETNEr : I<0x95, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002144 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002145 "setne $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002146 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2147 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002148def SETNEm : I<0x95, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002149 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002150 "setne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002151 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002152 TB; // [mem8] = !=
2153def SETLr : I<0x9C, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002154 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002155 "setl $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002156 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2157 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002158def SETLm : I<0x9C, MRM0m,
2159 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002160 "setl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002161 [(store (X86setcc X86_COND_L), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002162 TB; // [mem8] = < signed
2163def SETGEr : I<0x9D, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002164 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002165 "setge $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002166 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2167 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002168def SETGEm : I<0x9D, MRM0m,
2169 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002170 "setge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002171 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002172 TB; // [mem8] = >= signed
2173def SETLEr : I<0x9E, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002174 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002175 "setle $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002176 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2177 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002178def SETLEm : I<0x9E, MRM0m,
2179 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002180 "setle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002181 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002182 TB; // [mem8] = <= signed
2183def SETGr : I<0x9F, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002184 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002185 "setg $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002186 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2187 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002188def SETGm : I<0x9F, MRM0m,
2189 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002190 "setg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002191 [(store (X86setcc X86_COND_G), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002192 TB; // [mem8] = > signed
2193
2194def SETBr : I<0x92, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002195 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002196 "setb $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002197 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2198 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002199def SETBm : I<0x92, MRM0m,
2200 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002201 "setb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002202 [(store (X86setcc X86_COND_B), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002203 TB; // [mem8] = < unsign
2204def SETAEr : I<0x93, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002205 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002206 "setae $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002207 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2208 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002209def SETAEm : I<0x93, MRM0m,
2210 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002211 "setae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002212 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002213 TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002214def SETBEr : I<0x96, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002215 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002216 "setbe $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002217 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2218 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002219def SETBEm : I<0x96, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002220 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002221 "setbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002222 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002223 TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002224def SETAr : I<0x97, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002225 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002226 "seta $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002227 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2228 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002229def SETAm : I<0x97, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002230 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002231 "seta $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002232 [(store (X86setcc X86_COND_A), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002233 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002234
Chris Lattner3a173df2004-10-03 20:35:00 +00002235def SETSr : I<0x98, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002236 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002237 "sets $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002238 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2239 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002240def SETSm : I<0x98, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002241 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002242 "sets $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002243 [(store (X86setcc X86_COND_S), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002244 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002245def SETNSr : I<0x99, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002246 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002247 "setns $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002248 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2249 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002250def SETNSm : I<0x99, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002251 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002252 "setns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002253 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002254 TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002255def SETPr : I<0x9A, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002256 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002257 "setp $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002258 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2259 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002260def SETPm : I<0x9A, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002261 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002262 "setp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002263 [(store (X86setcc X86_COND_P), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002264 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002265def SETNPr : I<0x9B, MRM0r,
Evan Cheng069287d2006-05-16 07:21:53 +00002266 (ops GR8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002267 "setnp $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002268 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2269 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002270def SETNPm : I<0x9B, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002271 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002272 "setnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002273 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002274 TB; // [mem8] = not parity
Chris Lattner1cca5e32003-08-03 21:54:21 +00002275
2276// Integer comparisons
Chris Lattner3a173df2004-10-03 20:35:00 +00002277def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002278 (ops GR8 :$src1, GR8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002279 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002280 [(X86cmp GR8:$src1, GR8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002281def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002282 (ops GR16:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002283 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002284 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002285def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng069287d2006-05-16 07:21:53 +00002286 (ops GR32:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002287 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002288 [(X86cmp GR32:$src1, GR32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002289def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002290 (ops i8mem :$src1, GR8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002291 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002292 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002293def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002294 (ops i16mem:$src1, GR16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002295 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002296 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002297def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002298 (ops i32mem:$src1, GR32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002299 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002300 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002301def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002302 (ops GR8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002303 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002304 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002305def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002306 (ops GR16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002307 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002308 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002309def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng069287d2006-05-16 07:21:53 +00002310 (ops GR32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002311 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002312 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002313def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002314 (ops GR8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002315 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002316 [(X86cmp GR8:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002317def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002318 (ops GR16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002319 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002320 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002321def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002322 (ops GR32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002323 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002324 [(X86cmp GR32:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002325def CMP8mi : Ii8 <0x80, MRM7m,
2326 (ops i8mem :$src1, i8imm :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002327 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002328 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002329def CMP16mi : Ii16<0x81, MRM7m,
2330 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002331 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002332 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002333def CMP32mi : Ii32<0x81, MRM7m,
2334 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002335 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002336 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002337def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002338 (ops GR16:$src1, i16i8imm:$src2),
Nate Begemance944822006-03-23 01:29:48 +00002339 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002340 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002341def CMP16mi8 : Ii8<0x83, MRM7m,
Nate Begemance944822006-03-23 01:29:48 +00002342 (ops i16mem:$src1, i16i8imm:$src2),
2343 "cmp{w} {$src2, $src1|$src1, $src2}",
2344 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002345def CMP32mi8 : Ii8<0x83, MRM7m,
Nate Begemance944822006-03-23 01:29:48 +00002346 (ops i32mem:$src1, i32i8imm:$src2),
2347 "cmp{l} {$src2, $src1|$src1, $src2}",
2348 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002349def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng069287d2006-05-16 07:21:53 +00002350 (ops GR32:$src1, i32i8imm:$src2),
Nate Begemance944822006-03-23 01:29:48 +00002351 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002352 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002353
2354// Sign/Zero extenders
Evan Cheng069287d2006-05-16 07:21:53 +00002355def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002356 "movs{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002357 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
2358def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002359 "movs{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002360 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
2361def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002362 "movs{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002363 [(set GR32:$dst, (sext GR8:$src))]>, TB;
2364def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002365 "movs{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002366 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
2367def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops GR32:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002368 "movs{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002369 [(set GR32:$dst, (sext GR16:$src))]>, TB;
2370def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002371 "movs{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002372 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002373
Evan Cheng069287d2006-05-16 07:21:53 +00002374def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops GR16:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002375 "movz{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002376 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
2377def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops GR16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002378 "movz{bw|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002379 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
2380def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops GR32:$dst, GR8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002381 "movz{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002382 [(set GR32:$dst, (zext GR8:$src))]>, TB;
2383def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops GR32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002384 "movz{bl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002385 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
2386def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops GR32:$dst, GR16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002387 "movz{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002388 [(set GR32:$dst, (zext GR16:$src))]>, TB;
2389def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops GR32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002390 "movz{wl|x} {$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002391 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00002392
Evan Chengf91c1012006-05-31 22:05:11 +00002393def CBW : I<0x98, RawFrm, (ops),
2394 "{cbtw|cbw}", []>, Imp<[AL],[AX]>; // AX = signext(AL)
2395def CWDE : I<0x98, RawFrm, (ops),
2396 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2397
2398def CWD : I<0x99, RawFrm, (ops),
2399 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>; // DX:AX = signext(AX)
2400def CDQ : I<0x99, RawFrm, (ops),
2401 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2402
Nate Begemanf1702ac2005-06-27 21:20:31 +00002403//===----------------------------------------------------------------------===//
Evan Cheng747a90d2006-02-21 02:24:38 +00002404// Miscellaneous Instructions
2405//===----------------------------------------------------------------------===//
2406
2407def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
2408 TB, Imp<[],[EAX,EDX]>;
2409
Evan Cheng747a90d2006-02-21 02:24:38 +00002410//===----------------------------------------------------------------------===//
2411// Alias Instructions
2412//===----------------------------------------------------------------------===//
2413
2414// Alias instructions that map movr0 to xor.
2415// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Cheng069287d2006-05-16 07:21:53 +00002416def MOV8r0 : I<0x30, MRMInitReg, (ops GR8 :$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002417 "xor{b} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002418 [(set GR8:$dst, 0)]>;
2419def MOV16r0 : I<0x31, MRMInitReg, (ops GR16:$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002420 "xor{w} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002421 [(set GR16:$dst, 0)]>, OpSize;
2422def MOV32r0 : I<0x31, MRMInitReg, (ops GR32:$dst),
Evan Cheng747a90d2006-02-21 02:24:38 +00002423 "xor{l} $dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002424 [(set GR32:$dst, 0)]>;
Evan Cheng747a90d2006-02-21 02:24:38 +00002425
Evan Cheng069287d2006-05-16 07:21:53 +00002426// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2427// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
2428def MOV16to16_ : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002429 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002430def MOV32to32_ : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002431 "mov{l} {$src, $dst|$dst, $src}", []>;
2432
Evan Cheng069287d2006-05-16 07:21:53 +00002433def MOV16_rr : I<0x89, MRMDestReg, (ops GR16_:$dst, GR16_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002434 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002435def MOV32_rr : I<0x89, MRMDestReg, (ops GR32_:$dst, GR32_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002436 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +00002437def MOV16_rm : I<0x8B, MRMSrcMem, (ops GR16_:$dst, i16mem:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002438 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002439def MOV32_rm : I<0x8B, MRMSrcMem, (ops GR32_:$dst, i32mem:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002440 "mov{l} {$src, $dst|$dst, $src}", []>;
Evan Cheng069287d2006-05-16 07:21:53 +00002441def MOV16_mr : I<0x89, MRMDestMem, (ops i16mem:$dst, GR16_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002442 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002443def MOV32_mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32_:$src),
Evan Cheng403be7e2006-05-08 08:01:26 +00002444 "mov{l} {$src, $dst|$dst, $src}", []>;
2445
Evan Cheng510e4782006-01-09 23:10:28 +00002446//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00002447// DWARF Pseudo Instructions
2448//
2449
2450def DWARF_LOC : I<0, Pseudo, (ops i32imm:$line, i32imm:$col, i32imm:$file),
2451 "; .loc $file, $line, $col",
2452 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2453 (i32 imm:$file))]>;
2454
2455def DWARF_LABEL : I<0, Pseudo, (ops i32imm:$id),
2456 "\nLdebug_loc${id:debug}:",
2457 [(dwarf_label (i32 imm:$id))]>;
2458
2459//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00002460// Non-Instruction Patterns
2461//===----------------------------------------------------------------------===//
2462
Evan Cheng25ab6902006-09-08 06:48:29 +00002463// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00002464def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00002465def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002466def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2467def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2468
Evan Cheng069287d2006-05-16 07:21:53 +00002469def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2470 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2471def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2472 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2473def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2474 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2475def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2476 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002477
Evan Chengfc8feb12006-05-19 07:30:36 +00002478def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002479 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00002480def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002481 (MOV32mi addr:$dst, texternalsym:$src)>;
2482
Evan Cheng510e4782006-01-09 23:10:28 +00002483// Calls
Evan Cheng069287d2006-05-16 07:21:53 +00002484def : Pat<(X86tailcall GR32:$dst),
Evan Cheng25ab6902006-09-08 06:48:29 +00002485 (CALL32r GR32:$dst)>;
Evan Chengfea89c12006-04-27 08:40:39 +00002486
Evan Cheng25ab6902006-09-08 06:48:29 +00002487def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Evan Chengfea89c12006-04-27 08:40:39 +00002488 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002489def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Evan Chengfea89c12006-04-27 08:40:39 +00002490 (CALLpcrel32 texternalsym:$dst)>;
2491
Evan Cheng25ab6902006-09-08 06:48:29 +00002492def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00002493 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002494def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00002495 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002496
2497// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00002498def : Pat<(addc GR32:$src1, GR32:$src2),
2499 (ADD32rr GR32:$src1, GR32:$src2)>;
2500def : Pat<(addc GR32:$src1, (load addr:$src2)),
2501 (ADD32rm GR32:$src1, addr:$src2)>;
2502def : Pat<(addc GR32:$src1, imm:$src2),
2503 (ADD32ri GR32:$src1, imm:$src2)>;
2504def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2505 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002506
Evan Cheng069287d2006-05-16 07:21:53 +00002507def : Pat<(subc GR32:$src1, GR32:$src2),
2508 (SUB32rr GR32:$src1, GR32:$src2)>;
2509def : Pat<(subc GR32:$src1, (load addr:$src2)),
2510 (SUB32rm GR32:$src1, addr:$src2)>;
2511def : Pat<(subc GR32:$src1, imm:$src2),
2512 (SUB32ri GR32:$src1, imm:$src2)>;
2513def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2514 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002515
Evan Chengb8414332006-01-13 21:45:19 +00002516def : Pat<(truncstore (i8 imm:$src), addr:$dst, i1),
2517 (MOV8mi addr:$dst, imm:$src)>;
Evan Cheng069287d2006-05-16 07:21:53 +00002518def : Pat<(truncstore GR8:$src, addr:$dst, i1),
2519 (MOV8mr addr:$dst, GR8:$src)>;
Evan Chengb8414332006-01-13 21:45:19 +00002520
Chris Lattnerffc0b262006-09-07 20:33:45 +00002521// Comparisons.
2522
2523// TEST R,R is smaller than CMP R,0
2524def : Pat<(X86cmp GR8:$src1, 0),
2525 (TEST8rr GR8:$src1, GR8:$src1)>;
2526def : Pat<(X86cmp GR16:$src1, 0),
2527 (TEST16rr GR16:$src1, GR16:$src1)>;
2528def : Pat<(X86cmp GR32:$src1, 0),
2529 (TEST32rr GR32:$src1, GR32:$src1)>;
2530
Evan Cheng510e4782006-01-09 23:10:28 +00002531// {s|z}extload bool -> {s|z}extload byte
2532def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2533def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
Evan Chenge5d93432006-01-17 07:02:46 +00002534def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002535def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2536def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2537
2538// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00002539def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2540def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2541def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2542def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2543def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2544def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002545
2546// anyext -> zext
Evan Cheng069287d2006-05-16 07:21:53 +00002547def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2548def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2549def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Evan Cheng6e16ee52006-03-25 09:45:48 +00002550def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2551def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2552def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002553
Evan Chengcfa260b2006-01-06 02:31:59 +00002554//===----------------------------------------------------------------------===//
2555// Some peepholes
2556//===----------------------------------------------------------------------===//
2557
2558// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00002559def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2560def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2561def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002562
Evan Cheng956044c2006-01-19 23:26:24 +00002563// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002564def : Pat<(or (srl GR32:$src1, CL:$amt),
2565 (shl GR32:$src2, (sub 32, CL:$amt))),
2566 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002567
Evan Cheng21d54432006-01-20 01:13:30 +00002568def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002569 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2570 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002571
Evan Cheng956044c2006-01-19 23:26:24 +00002572// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002573def : Pat<(or (shl GR32:$src1, CL:$amt),
2574 (srl GR32:$src2, (sub 32, CL:$amt))),
2575 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002576
Evan Cheng21d54432006-01-20 01:13:30 +00002577def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002578 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2579 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002580
Evan Cheng956044c2006-01-19 23:26:24 +00002581// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002582def : Pat<(or (srl GR16:$src1, CL:$amt),
2583 (shl GR16:$src2, (sub 16, CL:$amt))),
2584 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002585
Evan Cheng21d54432006-01-20 01:13:30 +00002586def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002587 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2588 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002589
Evan Cheng956044c2006-01-19 23:26:24 +00002590// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002591def : Pat<(or (shl GR16:$src1, CL:$amt),
2592 (srl GR16:$src2, (sub 16, CL:$amt))),
2593 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002594
2595def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00002596 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2597 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00002598
2599
2600//===----------------------------------------------------------------------===//
2601// Floating Point Stack Support
2602//===----------------------------------------------------------------------===//
2603
2604include "X86InstrFPStack.td"
2605
2606//===----------------------------------------------------------------------===//
2607// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2608//===----------------------------------------------------------------------===//
2609
2610include "X86InstrMMX.td"
2611
2612//===----------------------------------------------------------------------===//
2613// XMM Floating point support (requires SSE / SSE2)
2614//===----------------------------------------------------------------------===//
2615
2616include "X86InstrSSE.td"
Evan Cheng25ab6902006-09-08 06:48:29 +00002617
2618//===----------------------------------------------------------------------===//
2619// X86-64 Support
2620//===----------------------------------------------------------------------===//
2621
2622include "X86InstrX86-64.td"