blob: 6831428c6ea775f6f33061c713233ac57b94f75e [file] [log] [blame]
Chris Lattner1cca5e32003-08-03 21:54:21 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00009//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
Evan Chengaed7c722005-12-17 01:24:02 +000016//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
Evan Chenge3413162006-01-09 18:33:28 +000020def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
Evan Cheng71fb9ad2006-01-26 00:29:36 +000024def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000025
Evan Cheng71fb9ad2006-01-26 00:29:36 +000026def SDTX86Cmov : SDTypeProfile<1, 3,
Evan Chengaed7c722005-12-17 01:24:02 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000028 SDTCisVT<3, i8>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000029
Evan Cheng71fb9ad2006-01-26 00:29:36 +000030def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000032
Evan Cheng71fb9ad2006-01-26 00:29:36 +000033def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000035
Evan Chengd9558e02006-01-06 00:43:03 +000036def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000037
Evan Chenge3413162006-01-09 18:33:28 +000038def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
40 SDTCisVT<1, i32> ]>;
41
42def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
43
44def SDTX86FpGet : SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>;
45def SDTX86FpSet : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
46
Evan Cheng38bcbaf2005-12-23 07:31:11 +000047def SDTX86Fld : SDTypeProfile<1, 2, [SDTCisVT<0, f64>,
Evan Chengb077b842005-12-21 02:39:21 +000048 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000049def SDTX86Fst : SDTypeProfile<0, 3, [SDTCisFP<0>,
50 SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>]>;
Evan Chenga3195e82006-01-12 22:54:21 +000051def SDTX86Fild : SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisPtrTy<1>,
52 SDTCisVT<2, OtherVT>]>;
Evan Cheng0cc39452006-01-16 21:21:29 +000053def SDTX86FpToIMem: SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisPtrTy<1>]>;
Evan Chengb077b842005-12-21 02:39:21 +000054
Evan Cheng67f92a72006-01-11 22:15:48 +000055def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
56
Evan Chenge3413162006-01-09 18:33:28 +000057def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000058
Evan Cheng71fb8342006-02-25 10:02:21 +000059def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
60
Evan Chenge3413162006-01-09 18:33:28 +000061def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
62def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000063
Evan Chengef6ffb12006-01-31 03:14:29 +000064def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp,
65 [SDNPCommutative, SDNPAssociative]>;
Evan Cheng223547a2006-01-31 22:28:30 +000066def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp,
67 [SDNPCommutative, SDNPAssociative]>;
Evan Chengef6ffb12006-01-31 03:14:29 +000068
Evan Cheng71fb9ad2006-01-26 00:29:36 +000069def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
70 [SDNPOutFlag]>;
71def X86test : SDNode<"X86ISD::TEST", SDTX86CmpTest,
72 [SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000073
Evan Chenge3413162006-01-09 18:33:28 +000074def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000075 [SDNPInFlag, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000076def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000077 [SDNPHasChain, SDNPInFlag]>;
Evan Cheng5ee4ccc2006-01-12 08:27:59 +000078def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
Evan Cheng71fb9ad2006-01-26 00:29:36 +000079 [SDNPInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000080
Evan Chenge3413162006-01-09 18:33:28 +000081def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
82 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000083
Evan Chenge3413162006-01-09 18:33:28 +000084def X86callseq_start :
85 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
86 [SDNPHasChain]>;
87def X86callseq_end :
88 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Chris Lattneraf63bb02006-01-24 05:17:12 +000089 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +000090
Evan Chenge3413162006-01-09 18:33:28 +000091def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
92 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +000093
Evan Chenge3413162006-01-09 18:33:28 +000094def X86fpget : SDNode<"X86ISD::FP_GET_RESULT", SDTX86FpGet,
Evan Cheng42ef0bc2006-01-17 00:19:47 +000095 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +000096def X86fpset : SDNode<"X86ISD::FP_SET_RESULT", SDTX86FpSet,
97 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000098
Evan Chenge3413162006-01-09 18:33:28 +000099def X86fld : SDNode<"X86ISD::FLD", SDTX86Fld,
100 [SDNPHasChain]>;
101def X86fst : SDNode<"X86ISD::FST", SDTX86Fst,
Evan Cheng42ef0bc2006-01-17 00:19:47 +0000102 [SDNPHasChain, SDNPInFlag]>;
Evan Chenga3195e82006-01-12 22:54:21 +0000103def X86fild : SDNode<"X86ISD::FILD", SDTX86Fild,
Evan Chenge3de85b2006-02-04 02:20:30 +0000104 [SDNPHasChain]>;
105def X86fildflag: SDNode<"X86ISD::FILD_FLAG",SDTX86Fild,
Evan Cheng6dab0532006-01-30 08:02:57 +0000106 [SDNPHasChain, SDNPOutFlag]>;
Evan Cheng0cc39452006-01-16 21:21:29 +0000107def X86fp_to_i16mem : SDNode<"X86ISD::FP_TO_INT16_IN_MEM", SDTX86FpToIMem,
108 [SDNPHasChain]>;
109def X86fp_to_i32mem : SDNode<"X86ISD::FP_TO_INT32_IN_MEM", SDTX86FpToIMem,
110 [SDNPHasChain]>;
111def X86fp_to_i64mem : SDNode<"X86ISD::FP_TO_INT64_IN_MEM", SDTX86FpToIMem,
112 [SDNPHasChain]>;
Evan Chenge3413162006-01-09 18:33:28 +0000113
Evan Cheng67f92a72006-01-11 22:15:48 +0000114def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
115 [SDNPHasChain, SDNPInFlag]>;
116def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
117 [SDNPHasChain, SDNPInFlag]>;
118
Evan Chenge3413162006-01-09 18:33:28 +0000119def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
120 [SDNPHasChain, SDNPOutFlag]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000121
Evan Cheng020d2e82006-02-23 20:41:18 +0000122def X86loadp : SDNode<"X86ISD::LOAD_PACK", SDTLoad,
Evan Cheng223547a2006-01-31 22:28:30 +0000123 [SDNPHasChain]>;
124
Evan Cheng71fb8342006-02-25 10:02:21 +0000125def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
126
Evan Chengaed7c722005-12-17 01:24:02 +0000127//===----------------------------------------------------------------------===//
128// X86 Operand Definitions.
129//
130
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000131// *mem - Operand definitions for the funky X86 addressing mode operands.
132//
Chris Lattner45432512005-12-17 19:47:05 +0000133class X86MemOperand<string printMethod> : Operand<i32> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000134 let PrintMethod = printMethod;
Chris Lattner6adaf792005-11-19 07:01:30 +0000135 let NumMIOperands = 4;
136 let MIOperandInfo = (ops R32, i8imm, R32, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000137}
Nate Begeman391c5d22005-11-30 18:54:35 +0000138
Chris Lattner45432512005-12-17 19:47:05 +0000139def i8mem : X86MemOperand<"printi8mem">;
140def i16mem : X86MemOperand<"printi16mem">;
141def i32mem : X86MemOperand<"printi32mem">;
142def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000143def i128mem : X86MemOperand<"printi128mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000144def f32mem : X86MemOperand<"printf32mem">;
145def f64mem : X86MemOperand<"printf64mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000146def f128mem : X86MemOperand<"printf128mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000147
Nate Begeman16b04f32005-07-15 00:38:55 +0000148def SSECC : Operand<i8> {
149 let PrintMethod = "printSSECC";
150}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000151
Evan Cheng7ccced62006-02-18 00:15:05 +0000152def piclabel: Operand<i32> {
153 let PrintMethod = "printPICLabel";
154}
155
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000156// A couple of more descriptive operand definitions.
157// 16-bits but only 8 bits are significant.
158def i16i8imm : Operand<i16>;
159// 32-bits but only 8 bits are significant.
160def i32i8imm : Operand<i32>;
161
Evan Chengd35b8c12005-12-04 08:19:43 +0000162// Branch targets have OtherVT type.
163def brtarget : Operand<OtherVT>;
164
Evan Chengaed7c722005-12-17 01:24:02 +0000165//===----------------------------------------------------------------------===//
166// X86 Complex Pattern Definitions.
167//
168
Evan Chengec693f72005-12-08 02:01:35 +0000169// Define X86 specific addressing mode.
Evan Cheng670fd8f2005-12-08 02:15:07 +0000170def addr : ComplexPattern<i32, 4, "SelectAddr", []>;
Evan Cheng502c5bb2005-12-15 08:31:04 +0000171def leaaddr : ComplexPattern<i32, 4, "SelectLEAAddr",
Evan Cheng71fb8342006-02-25 10:02:21 +0000172 [add, mul, shl, frameindex]>;
Evan Chengec693f72005-12-08 02:01:35 +0000173
Evan Chengaed7c722005-12-17 01:24:02 +0000174//===----------------------------------------------------------------------===//
175// X86 Instruction Format Definitions.
176//
177
Chris Lattner1cca5e32003-08-03 21:54:21 +0000178// Format specifies the encoding used by the instruction. This is part of the
179// ad-hoc solution used to emit machine instruction encodings by our machine
180// code emitter.
Evan Cheng3c55c542006-02-01 06:13:50 +0000181class Format<bits<6> val> {
182 bits<6> Value = val;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000183}
184
185def Pseudo : Format<0>; def RawFrm : Format<1>;
186def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
187def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
188def MRMSrcMem : Format<6>;
Alkis Evlogimenos169584e2004-02-27 18:55:12 +0000189def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
190def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
191def MRM6r : Format<22>; def MRM7r : Format<23>;
192def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
193def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
194def MRM6m : Format<30>; def MRM7m : Format<31>;
Evan Cheng3c55c542006-02-01 06:13:50 +0000195def MRMInitReg : Format<32>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000196
Evan Chengaed7c722005-12-17 01:24:02 +0000197//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000198// X86 Instruction Predicate Definitions.
Evan Chengffcb95b2006-02-21 19:13:53 +0000199def HasMMX : Predicate<"Subtarget->hasMMX()">;
Chris Lattner259e97c2006-01-31 19:43:35 +0000200def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
Evan Cheng559806f2006-01-27 08:10:46 +0000201def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
202def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
203def FPStack : Predicate<"!Subtarget->hasSSE2()">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000204
205//===----------------------------------------------------------------------===//
Evan Chengaed7c722005-12-17 01:24:02 +0000206// X86 specific pattern fragments.
207//
208
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000209// ImmType - This specifies the immediate type used by an instruction. This is
Chris Lattner1cca5e32003-08-03 21:54:21 +0000210// part of the ad-hoc solution used to emit machine instruction encodings by our
211// machine code emitter.
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000212class ImmType<bits<2> val> {
213 bits<2> Value = val;
214}
215def NoImm : ImmType<0>;
216def Imm8 : ImmType<1>;
217def Imm16 : ImmType<2>;
218def Imm32 : ImmType<3>;
219
Chris Lattner1cca5e32003-08-03 21:54:21 +0000220// FPFormat - This specifies what form this FP instruction has. This is used by
221// the Floating-Point stackifier pass.
222class FPFormat<bits<3> val> {
223 bits<3> Value = val;
224}
225def NotFP : FPFormat<0>;
226def ZeroArgFP : FPFormat<1>;
227def OneArgFP : FPFormat<2>;
228def OneArgFPRW : FPFormat<3>;
229def TwoArgFP : FPFormat<4>;
Chris Lattnerab8decc2004-06-11 04:41:24 +0000230def CompareFP : FPFormat<5>;
231def CondMovFP : FPFormat<6>;
232def SpecialFP : FPFormat<7>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000233
234
Chris Lattner3a173df2004-10-03 20:35:00 +0000235class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
236 : Instruction {
Chris Lattnerc8f45872003-08-04 04:59:56 +0000237 let Namespace = "X86";
Chris Lattner1cca5e32003-08-03 21:54:21 +0000238
Chris Lattner1cca5e32003-08-03 21:54:21 +0000239 bits<8> Opcode = opcod;
240 Format Form = f;
Evan Cheng3c55c542006-02-01 06:13:50 +0000241 bits<6> FormBits = Form.Value;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000242 ImmType ImmT = i;
243 bits<2> ImmTypeBits = ImmT.Value;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000244
Chris Lattnerc96bb812004-08-11 07:12:04 +0000245 dag OperandList = ops;
246 string AsmString = AsmStr;
247
John Criswell4ffff9e2004-04-08 20:31:47 +0000248 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000249 // Attributes specific to X86 instructions...
John Criswell4ffff9e2004-04-08 20:31:47 +0000250 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000251 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
John Criswell4ffff9e2004-04-08 20:31:47 +0000252
Chris Lattner1cca5e32003-08-03 21:54:21 +0000253 bits<4> Prefix = 0; // Which prefix byte does this inst have?
254 FPFormat FPForm; // What flavor of FP instruction is this?
255 bits<3> FPFormBits = 0;
256}
257
258class Imp<list<Register> uses, list<Register> defs> {
259 list<Register> Uses = uses;
260 list<Register> Defs = defs;
261}
262
263
264// Prefix byte classes which are used to indicate to the ad-hoc machine code
265// emitter that various prefix bytes are required.
266class OpSize { bit hasOpSizePrefix = 1; }
267class TB { bits<4> Prefix = 1; }
Chris Lattner915e5e52004-02-12 17:53:22 +0000268class REP { bits<4> Prefix = 2; }
269class D8 { bits<4> Prefix = 3; }
270class D9 { bits<4> Prefix = 4; }
271class DA { bits<4> Prefix = 5; }
272class DB { bits<4> Prefix = 6; }
273class DC { bits<4> Prefix = 7; }
274class DD { bits<4> Prefix = 8; }
275class DE { bits<4> Prefix = 9; }
276class DF { bits<4> Prefix = 10; }
Nate Begemanf1702ac2005-06-27 21:20:31 +0000277class XD { bits<4> Prefix = 11; }
278class XS { bits<4> Prefix = 12; }
Chris Lattner1cca5e32003-08-03 21:54:21 +0000279
280
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000281//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000282// Pattern fragments...
283//
Evan Chengd9558e02006-01-06 00:43:03 +0000284
285// X86 specific condition code. These correspond to CondCode in
286// X86ISelLowering.h. They must be kept in synch.
287def X86_COND_A : PatLeaf<(i8 0)>;
288def X86_COND_AE : PatLeaf<(i8 1)>;
289def X86_COND_B : PatLeaf<(i8 2)>;
290def X86_COND_BE : PatLeaf<(i8 3)>;
291def X86_COND_E : PatLeaf<(i8 4)>;
292def X86_COND_G : PatLeaf<(i8 5)>;
293def X86_COND_GE : PatLeaf<(i8 6)>;
294def X86_COND_L : PatLeaf<(i8 7)>;
295def X86_COND_LE : PatLeaf<(i8 8)>;
296def X86_COND_NE : PatLeaf<(i8 9)>;
297def X86_COND_NO : PatLeaf<(i8 10)>;
298def X86_COND_NP : PatLeaf<(i8 11)>;
299def X86_COND_NS : PatLeaf<(i8 12)>;
300def X86_COND_O : PatLeaf<(i8 13)>;
301def X86_COND_P : PatLeaf<(i8 14)>;
302def X86_COND_S : PatLeaf<(i8 15)>;
303
Evan Cheng9b6b6422005-12-13 00:14:11 +0000304def i16immSExt8 : PatLeaf<(i16 imm), [{
305 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000306 // sign extended field.
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000307 return (int)N->getValue() == (signed char)N->getValue();
308}]>;
309
Evan Cheng9b6b6422005-12-13 00:14:11 +0000310def i32immSExt8 : PatLeaf<(i32 imm), [{
311 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000312 // sign extended field.
313 return (int)N->getValue() == (signed char)N->getValue();
314}]>;
315
Evan Cheng9b6b6422005-12-13 00:14:11 +0000316def i16immZExt8 : PatLeaf<(i16 imm), [{
317 // i16immZExt8 predicate - True if the 16-bit immediate fits in a 8-bit zero
Evan Chengb3558542005-12-13 00:01:09 +0000318 // extended field.
Chris Lattner3d36a9f2005-12-05 02:40:25 +0000319 return (unsigned)N->getValue() == (unsigned char)N->getValue();
320}]>;
321
Evan Cheng650d6882006-01-05 02:08:37 +0000322def fp32imm0 : PatLeaf<(f32 fpimm), [{
323 return N->isExactlyValue(+0.0);
324}]>;
325
326def fp64imm0 : PatLeaf<(f64 fpimm), [{
327 return N->isExactlyValue(+0.0);
328}]>;
329
330def fp64immneg0 : PatLeaf<(f64 fpimm), [{
331 return N->isExactlyValue(-0.0);
332}]>;
333
334def fp64imm1 : PatLeaf<(f64 fpimm), [{
335 return N->isExactlyValue(+1.0);
336}]>;
337
338def fp64immneg1 : PatLeaf<(f64 fpimm), [{
339 return N->isExactlyValue(-1.0);
340}]>;
341
Evan Cheng605c4152005-12-13 01:57:51 +0000342// Helper fragments for loads.
Evan Cheng7a7e8372005-12-14 02:22:27 +0000343def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
344def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
345def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000346def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
347def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000348
Evan Cheng470a6ad2006-02-22 02:26:30 +0000349def X86loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>;
350def X86loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>;
351
Evan Cheng7a7e8372005-12-14 02:22:27 +0000352def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i1))>;
353def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i1))>;
354def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextload node:$ptr, i8))>;
355def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i8))>;
356def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextload node:$ptr, i16))>;
357
Evan Chenge5d93432006-01-17 07:02:46 +0000358def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextload node:$ptr, i1))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000359def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i1))>;
360def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i1))>;
361def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextload node:$ptr, i8))>;
362def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i8))>;
363def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextload node:$ptr, i16))>;
364
Evan Cheng38bcbaf2005-12-23 07:31:11 +0000365def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extload node:$ptr, i1))>;
366def extloadf64f32 : PatFrag<(ops node:$ptr), (f64 (extload node:$ptr, f32))>;
Evan Cheng605c4152005-12-13 01:57:51 +0000367
Evan Cheng747a90d2006-02-21 02:24:38 +0000368def X86loadpf32 : PatFrag<(ops node:$ptr), (f32 (X86loadp node:$ptr))>;
369def X86loadpf64 : PatFrag<(ops node:$ptr), (f64 (X86loadp node:$ptr))>;
370
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000371//===----------------------------------------------------------------------===//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000372// Instruction templates...
373
Evan Chengf0701842005-11-29 19:38:52 +0000374class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
375 : X86Inst<o, f, NoImm, ops, asm> {
376 let Pattern = pattern;
377}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000378class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
379 : X86Inst<o, f, Imm8 , ops, asm> {
380 let Pattern = pattern;
381}
Chris Lattner78432fe2005-11-17 02:01:55 +0000382class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
383 : X86Inst<o, f, Imm16, ops, asm> {
384 let Pattern = pattern;
385}
Chris Lattner7a125372005-11-16 22:59:19 +0000386class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
387 : X86Inst<o, f, Imm32, ops, asm> {
388 let Pattern = pattern;
389}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000390
Chris Lattner1cca5e32003-08-03 21:54:21 +0000391//===----------------------------------------------------------------------===//
392// Instruction list...
393//
394
Evan Chengd90eb7f2006-01-05 00:27:02 +0000395def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN",
Evan Chenge3413162006-01-09 18:33:28 +0000396 [(X86callseq_start imm:$amt)]>;
Chris Lattner43ef1312005-09-14 21:10:24 +0000397def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
Evan Chengd90eb7f2006-01-05 00:27:02 +0000398 "#ADJCALLSTACKUP",
Evan Chenge3413162006-01-09 18:33:28 +0000399 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
Evan Chengf0701842005-11-29 19:38:52 +0000400def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
401def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
Evan Cheng510e4782006-01-09 23:10:28 +0000402def IMPLICIT_DEF_R8 : I<0, Pseudo, (ops R8:$dst),
403 "#IMPLICIT_DEF $dst",
404 [(set R8:$dst, (undef))]>;
405def IMPLICIT_DEF_R16 : I<0, Pseudo, (ops R16:$dst),
406 "#IMPLICIT_DEF $dst",
407 [(set R16:$dst, (undef))]>;
408def IMPLICIT_DEF_R32 : I<0, Pseudo, (ops R32:$dst),
409 "#IMPLICIT_DEF $dst",
410 [(set R32:$dst, (undef))]>;
Evan Cheng4a460802006-01-11 00:33:36 +0000411
412// Nop
413def NOOP : I<0x90, RawFrm, (ops), "nop", []>;
414
Chris Lattner1cca5e32003-08-03 21:54:21 +0000415//===----------------------------------------------------------------------===//
416// Control Flow Instructions...
417//
418
Chris Lattner1be48112005-05-13 17:56:48 +0000419// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000420let isTerminator = 1, isReturn = 1, isBarrier = 1,
421 hasCtrlDep = 1, noResults = 1 in {
Evan Chenge3413162006-01-09 18:33:28 +0000422 def RET : I<0xC3, RawFrm, (ops), "ret", [(X86retflag 0)]>;
423 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt",
424 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000425}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000426
427// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng2b4ea792005-12-26 09:11:45 +0000428let isBranch = 1, isTerminator = 1, noResults = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000429 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
430 I<opcode, RawFrm, ops, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000431
Evan Cheng4a460802006-01-11 00:33:36 +0000432// Conditional branches
Chris Lattner62cce392004-07-31 02:10:53 +0000433let isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000434 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000435
436def JE : IBr<0x84, (ops brtarget:$dst), "je $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000437 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000438def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000439 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000440def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000441 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000442def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000443 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000444def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000445 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000446def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000447 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000448
Evan Chengd35b8c12005-12-04 08:19:43 +0000449def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000450 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000451def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000452 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000453def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000454 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000455def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000456 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000457
Evan Chengd9558e02006-01-06 00:43:03 +0000458def JS : IBr<0x88, (ops brtarget:$dst), "js $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000459 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000460def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000461 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000462def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000463 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Evan Chengd9558e02006-01-06 00:43:03 +0000464def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000465 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000466def JO : IBr<0x80, (ops brtarget:$dst), "jo $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000467 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Evan Cheng4a460802006-01-11 00:33:36 +0000468def JNO : IBr<0x81, (ops brtarget:$dst), "jno $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000469 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000470
471//===----------------------------------------------------------------------===//
472// Call Instructions...
473//
Evan Chenge3413162006-01-09 18:33:28 +0000474let isCall = 1, noResults = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000475 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000476 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Nate Begeman16b04f32005-07-15 00:38:55 +0000477 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Chris Lattnera3b8c572006-02-06 23:41:19 +0000478 def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst), "call ${dst:call}",
Evan Chengd90eb7f2006-01-05 00:27:02 +0000479 []>;
480 def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst",
Evan Chenge3413162006-01-09 18:33:28 +0000481 [(X86call R32:$dst)]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000482 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst), "call {*}$dst",
Evan Chenge3413162006-01-09 18:33:28 +0000483 [(X86call (loadi32 addr:$dst))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000484 }
485
Chris Lattner1e9448b2005-05-15 03:10:37 +0000486// Tail call stuff.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000487let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Chris Lattnera3b8c572006-02-06 23:41:19 +0000488 def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call} # TAIL CALL", []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000489let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000490 def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
Evan Cheng2b4ea792005-12-26 09:11:45 +0000491let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000492 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
493 "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000494
495// ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
496// way, except that it is marked as being a terminator. This causes the epilog
497// inserter to insert reloads of callee saved registers BEFORE this. We need
498// this until we have a more accurate way of tracking where the stack pointer is
499// within a function.
500let isTerminator = 1, isTwoAddress = 1 in
501 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000502 "add{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000503
Chris Lattner1cca5e32003-08-03 21:54:21 +0000504//===----------------------------------------------------------------------===//
505// Miscellaneous Instructions...
506//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000507def LEAVE : I<0xC9, RawFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000508 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000509def POP32r : I<0x58, AddRegFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000510 (ops R32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000511
Evan Cheng7ccced62006-02-18 00:15:05 +0000512def MovePCtoStack : I<0, Pseudo, (ops piclabel:$label),
513 "call $label", []>;
514
Chris Lattner3a173df2004-10-03 20:35:00 +0000515let isTwoAddress = 1 in // R32 = bswap R32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000516 def BSWAP32r : I<0xC8, AddRegFrm,
Nate Begemand88fc032006-01-14 03:14:10 +0000517 (ops R32:$dst, R32:$src),
518 "bswap{l} $dst",
519 [(set R32:$dst, (bswap R32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000520
Chris Lattner30bf2d82004-08-10 20:17:41 +0000521def XCHG8rr : I<0x86, MRMDestReg, // xchg R8, R8
Chris Lattner3a173df2004-10-03 20:35:00 +0000522 (ops R8:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000523 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000524def XCHG16rr : I<0x87, MRMDestReg, // xchg R16, R16
Chris Lattner3a173df2004-10-03 20:35:00 +0000525 (ops R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000526 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000527def XCHG32rr : I<0x87, MRMDestReg, // xchg R32, R32
Chris Lattner3a173df2004-10-03 20:35:00 +0000528 (ops R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000529 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattnerfc752712004-08-01 09:52:59 +0000530
Chris Lattner3a173df2004-10-03 20:35:00 +0000531def XCHG8mr : I<0x86, MRMDestMem,
532 (ops i8mem:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000533 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000534def XCHG16mr : I<0x87, MRMDestMem,
535 (ops i16mem:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000536 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000537def XCHG32mr : I<0x87, MRMDestMem,
538 (ops i32mem:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000539 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000540def XCHG8rm : I<0x86, MRMSrcMem,
541 (ops R8:$src1, i8mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000542 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000543def XCHG16rm : I<0x87, MRMSrcMem,
544 (ops R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000545 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000546def XCHG32rm : I<0x87, MRMSrcMem,
547 (ops R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000548 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000549
Chris Lattner3a173df2004-10-03 20:35:00 +0000550def LEA16r : I<0x8D, MRMSrcMem,
551 (ops R16:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000552 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000553def LEA32r : I<0x8D, MRMSrcMem,
554 (ops R32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000555 "lea{l} {$src|$dst}, {$dst|$src}",
556 [(set R32:$dst, leaaddr:$src)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000557
Evan Cheng67f92a72006-01-11 22:15:48 +0000558def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}",
559 [(X86rep_movs i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000560 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000561def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}",
562 [(X86rep_movs i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000563 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Cheng67f92a72006-01-11 22:15:48 +0000564def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsd|rep movsd}",
565 [(X86rep_movs i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000566 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Chris Lattner915e5e52004-02-12 17:53:22 +0000567
Evan Cheng67f92a72006-01-11 22:15:48 +0000568def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}",
569 [(X86rep_stos i8)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000570 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Cheng67f92a72006-01-11 22:15:48 +0000571def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}",
572 [(X86rep_stos i16)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000573 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Cheng67f92a72006-01-11 22:15:48 +0000574def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}",
575 [(X86rep_stos i32)]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000576 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
577
Chris Lattnerb89abef2004-02-14 04:45:37 +0000578
Chris Lattner1cca5e32003-08-03 21:54:21 +0000579//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000580// Input/Output Instructions...
581//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000582def IN8rr : I<0xEC, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000583 "in{b} {%dx, %al|%AL, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000584 []>, Imp<[DX], [AL]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000585def IN16rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000586 "in{w} {%dx, %ax|%AX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000587 []>, Imp<[DX], [AX]>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000588def IN32rr : I<0xED, RawFrm, (ops),
Evan Chenga5386b02005-12-20 07:38:38 +0000589 "in{l} {%dx, %eax|%EAX, %DX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000590 []>, Imp<[DX],[EAX]>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000591
Evan Chenga5386b02005-12-20 07:38:38 +0000592def IN8ri : Ii8<0xE4, RawFrm, (ops i16i8imm:$port),
593 "in{b} {$port, %al|%AL, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000594 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000595 Imp<[], [AL]>;
596def IN16ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
597 "in{w} {$port, %ax|%AX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000598 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000599 Imp<[], [AX]>, OpSize;
600def IN32ri : Ii8<0xE5, RawFrm, (ops i16i8imm:$port),
601 "in{l} {$port, %eax|%EAX, $port}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000602 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000603 Imp<[],[EAX]>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000604
Evan Cheng8d202232005-12-05 23:09:43 +0000605def OUT8rr : I<0xEE, RawFrm, (ops),
606 "out{b} {%al, %dx|%DX, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000607 []>, Imp<[DX, AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000608def OUT16rr : I<0xEF, RawFrm, (ops),
609 "out{w} {%ax, %dx|%DX, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000610 []>, Imp<[DX, AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000611def OUT32rr : I<0xEF, RawFrm, (ops),
612 "out{l} {%eax, %dx|%DX, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000613 []>, Imp<[DX, EAX], []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000614
Evan Cheng8d202232005-12-05 23:09:43 +0000615def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
616 "out{b} {%al, $port|$port, %AL}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000617 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000618 Imp<[AL], []>;
Evan Cheng8d202232005-12-05 23:09:43 +0000619def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
620 "out{w} {%ax, $port|$port, %AX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000621 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000622 Imp<[AX], []>, OpSize;
Evan Cheng8d202232005-12-05 23:09:43 +0000623def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
624 "out{l} {%eax, $port|$port, %EAX}",
Chris Lattner41edaa02006-03-03 00:19:58 +0000625 []>,
Evan Chenga5386b02005-12-20 07:38:38 +0000626 Imp<[EAX], []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000627
628//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000629// Move Instructions...
630//
Chris Lattner3a173df2004-10-03 20:35:00 +0000631def MOV8rr : I<0x88, MRMDestReg, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000632 "mov{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000633def MOV16rr : I<0x89, MRMDestReg, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000634 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000635def MOV32rr : I<0x89, MRMDestReg, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000636 "mov{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000637def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops R8 :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000638 "mov{b} {$src, $dst|$dst, $src}",
639 [(set R8:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000640def MOV16ri : Ii16<0xB8, AddRegFrm, (ops R16:$dst, i16imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000641 "mov{w} {$src, $dst|$dst, $src}",
642 [(set R16:$dst, imm:$src)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000643def MOV32ri : Ii32<0xB8, AddRegFrm, (ops R32:$dst, i32imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000644 "mov{l} {$src, $dst|$dst, $src}",
645 [(set R32:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000646def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000647 "mov{b} {$src, $dst|$dst, $src}",
648 [(store (i8 imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000649def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000650 "mov{w} {$src, $dst|$dst, $src}",
651 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000652def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000653 "mov{l} {$src, $dst|$dst, $src}",
654 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000655
Chris Lattner3a173df2004-10-03 20:35:00 +0000656def MOV8rm : I<0x8A, MRMSrcMem, (ops R8 :$dst, i8mem :$src),
Evan Chengec693f72005-12-08 02:01:35 +0000657 "mov{b} {$src, $dst|$dst, $src}",
658 [(set R8:$dst, (load addr:$src))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000659def MOV16rm : I<0x8B, MRMSrcMem, (ops R16:$dst, i16mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000660 "mov{w} {$src, $dst|$dst, $src}",
661 [(set R16:$dst, (load addr:$src))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000662def MOV32rm : I<0x8B, MRMSrcMem, (ops R32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000663 "mov{l} {$src, $dst|$dst, $src}",
664 [(set R32:$dst, (load addr:$src))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000665
Chris Lattner3a173df2004-10-03 20:35:00 +0000666def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, R8 :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000667 "mov{b} {$src, $dst|$dst, $src}",
668 [(store R8:$src, addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000669def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, R16:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000670 "mov{w} {$src, $dst|$dst, $src}",
671 [(store R16:$src, addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000672def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, R32:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000673 "mov{l} {$src, $dst|$dst, $src}",
674 [(store R32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000675
Chris Lattner1cca5e32003-08-03 21:54:21 +0000676//===----------------------------------------------------------------------===//
677// Fixed-Register Multiplication and Division Instructions...
678//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000679
Chris Lattnerc8f45872003-08-04 04:59:56 +0000680// Extra precision multiplication
Evan Chengcf74a7c2006-01-15 10:05:20 +0000681def MUL8r : I<0xF6, MRM4r, (ops R8:$src), "mul{b} $src",
682 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
683 // This probably ought to be moved to a def : Pat<> if the
684 // syntax can be accepted.
685 [(set AL, (mul AL, R8:$src))]>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000686 Imp<[AL],[AX]>; // AL,AH = AL*R8
Evan Chengf0701842005-11-29 19:38:52 +0000687def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul{w} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000688 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
Evan Chengf0701842005-11-29 19:38:52 +0000689def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul{l} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000690 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
Chris Lattner57a02302004-08-11 04:31:00 +0000691def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
Evan Chengcf74a7c2006-01-15 10:05:20 +0000692 "mul{b} $src",
693 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
694 // This probably ought to be moved to a def : Pat<> if the
695 // syntax can be accepted.
696 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
697 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner57a02302004-08-11 04:31:00 +0000698def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000699 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
700 OpSize; // AX,DX = AX*[mem16]
Chris Lattner57a02302004-08-11 04:31:00 +0000701def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000702 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000703
Evan Chengf0701842005-11-29 19:38:52 +0000704def IMUL8r : I<0xF6, MRM5r, (ops R8:$src), "imul{b} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000705 Imp<[AL],[AX]>; // AL,AH = AL*R8
Evan Chengf0701842005-11-29 19:38:52 +0000706def IMUL16r : I<0xF7, MRM5r, (ops R16:$src), "imul{w} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000707 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
Evan Chengf0701842005-11-29 19:38:52 +0000708def IMUL32r : I<0xF7, MRM5r, (ops R32:$src), "imul{l} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000709 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
710def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000711 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000712def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000713 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
714 OpSize; // AX,DX = AX*[mem16]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000715def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000716 "imul{l} $src", []>,
717 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000718
Chris Lattnerc8f45872003-08-04 04:59:56 +0000719// unsigned division/remainder
Chris Lattner3a173df2004-10-03 20:35:00 +0000720def DIV8r : I<0xF6, MRM6r, (ops R8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000721 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000722def DIV16r : I<0xF7, MRM6r, (ops R16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000723 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000724def DIV32r : I<0xF7, MRM6r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000725 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000726def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000727 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000728def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000729 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000730def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000731 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000732
Chris Lattnerfc752712004-08-01 09:52:59 +0000733// Signed division/remainder.
Chris Lattner3a173df2004-10-03 20:35:00 +0000734def IDIV8r : I<0xF6, MRM7r, (ops R8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000735 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000736def IDIV16r: I<0xF7, MRM7r, (ops R16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000737 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000738def IDIV32r: I<0xF7, MRM7r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000739 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000740def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000741 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000742def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000743 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000744def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000745 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattnerc8f45872003-08-04 04:59:56 +0000746
Chris Lattnerfc752712004-08-01 09:52:59 +0000747// Sign-extenders for division.
Chris Lattner3a173df2004-10-03 20:35:00 +0000748def CBW : I<0x98, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000749 "{cbtw|cbw}", []>, Imp<[AL],[AH]>; // AX = signext(AL)
Chris Lattner3a173df2004-10-03 20:35:00 +0000750def CWD : I<0x99, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000751 "{cwtd|cwd}", []>, Imp<[AX],[DX]>; // DX:AX = signext(AX)
Chris Lattner3a173df2004-10-03 20:35:00 +0000752def CDQ : I<0x99, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000753 "{cltd|cdq}", []>, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
Chris Lattnerfc752712004-08-01 09:52:59 +0000754
Chris Lattner1cca5e32003-08-03 21:54:21 +0000755
Chris Lattner1cca5e32003-08-03 21:54:21 +0000756//===----------------------------------------------------------------------===//
757// Two address Instructions...
758//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000759let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000760
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000761// Conditional moves
Chris Lattner3a173df2004-10-03 20:35:00 +0000762def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, R16 = R16
763 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000764 "cmovb {$src2, $dst|$dst, $src2}",
765 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000766 X86_COND_B))]>,
767 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000768def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, R16 = [mem16]
769 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000770 "cmovb {$src2, $dst|$dst, $src2}",
771 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000772 X86_COND_B))]>,
773 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000774def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, R32 = R32
775 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000776 "cmovb {$src2, $dst|$dst, $src2}",
777 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000778 X86_COND_B))]>,
779 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000780def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, R32 = [mem32]
781 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000782 "cmovb {$src2, $dst|$dst, $src2}",
783 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000784 X86_COND_B))]>,
785 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000786
Chris Lattner3a173df2004-10-03 20:35:00 +0000787def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, R16 = R16
788 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000789 "cmovae {$src2, $dst|$dst, $src2}",
790 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000791 X86_COND_AE))]>,
792 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000793def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, R16 = [mem16]
794 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000795 "cmovae {$src2, $dst|$dst, $src2}",
796 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000797 X86_COND_AE))]>,
798 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000799def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, R32 = R32
800 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000801 "cmovae {$src2, $dst|$dst, $src2}",
802 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000803 X86_COND_AE))]>,
804 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000805def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, R32 = [mem32]
806 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000807 "cmovae {$src2, $dst|$dst, $src2}",
808 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000809 X86_COND_AE))]>,
810 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000811
Chris Lattner3a173df2004-10-03 20:35:00 +0000812def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, R16 = R16
813 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000814 "cmove {$src2, $dst|$dst, $src2}",
815 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000816 X86_COND_E))]>,
817 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000818def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, R16 = [mem16]
819 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000820 "cmove {$src2, $dst|$dst, $src2}",
821 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000822 X86_COND_E))]>,
823 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000824def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, R32 = R32
825 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000826 "cmove {$src2, $dst|$dst, $src2}",
827 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000828 X86_COND_E))]>,
829 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000830def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, R32 = [mem32]
831 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000832 "cmove {$src2, $dst|$dst, $src2}",
833 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000834 X86_COND_E))]>,
835 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000836
Chris Lattner3a173df2004-10-03 20:35:00 +0000837def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, R16 = R16
838 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000839 "cmovne {$src2, $dst|$dst, $src2}",
840 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000841 X86_COND_NE))]>,
842 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000843def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, R16 = [mem16]
844 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000845 "cmovne {$src2, $dst|$dst, $src2}",
846 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000847 X86_COND_NE))]>,
848 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000849def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, R32 = R32
850 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000851 "cmovne {$src2, $dst|$dst, $src2}",
852 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000853 X86_COND_NE))]>,
854 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000855def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, R32 = [mem32]
856 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000857 "cmovne {$src2, $dst|$dst, $src2}",
858 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000859 X86_COND_NE))]>,
860 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000861
Chris Lattner3a173df2004-10-03 20:35:00 +0000862def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, R16 = R16
863 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000864 "cmovbe {$src2, $dst|$dst, $src2}",
865 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000866 X86_COND_BE))]>,
867 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000868def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, R16 = [mem16]
869 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000870 "cmovbe {$src2, $dst|$dst, $src2}",
871 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000872 X86_COND_BE))]>,
873 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000874def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, R32 = R32
875 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000876 "cmovbe {$src2, $dst|$dst, $src2}",
877 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000878 X86_COND_BE))]>,
879 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000880def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, R32 = [mem32]
881 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000882 "cmovbe {$src2, $dst|$dst, $src2}",
883 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000884 X86_COND_BE))]>,
885 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000886
Chris Lattner3a173df2004-10-03 20:35:00 +0000887def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, R16 = R16
888 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000889 "cmova {$src2, $dst|$dst, $src2}",
890 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000891 X86_COND_A))]>,
892 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000893def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, R16 = [mem16]
894 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000895 "cmova {$src2, $dst|$dst, $src2}",
896 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000897 X86_COND_A))]>,
898 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000899def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, R32 = R32
900 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000901 "cmova {$src2, $dst|$dst, $src2}",
902 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000903 X86_COND_A))]>,
904 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000905def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, R32 = [mem32]
906 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +0000907 "cmova {$src2, $dst|$dst, $src2}",
908 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000909 X86_COND_A))]>,
910 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000911
912def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, R16 = R16
913 (ops R16:$dst, R16:$src1, R16:$src2),
914 "cmovl {$src2, $dst|$dst, $src2}",
915 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000916 X86_COND_L))]>,
917 TB, OpSize;
Evan Chengaed7c722005-12-17 01:24:02 +0000918def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, R16 = [mem16]
919 (ops R16:$dst, R16:$src1, i16mem:$src2),
920 "cmovl {$src2, $dst|$dst, $src2}",
921 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000922 X86_COND_L))]>,
923 TB, OpSize;
Evan Chengaed7c722005-12-17 01:24:02 +0000924def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, R32 = R32
925 (ops R32:$dst, R32:$src1, R32:$src2),
926 "cmovl {$src2, $dst|$dst, $src2}",
927 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000928 X86_COND_L))]>,
929 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000930def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, R32 = [mem32]
931 (ops R32:$dst, R32:$src1, i32mem:$src2),
932 "cmovl {$src2, $dst|$dst, $src2}",
933 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000934 X86_COND_L))]>,
935 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000936
937def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, R16 = R16
938 (ops R16:$dst, R16:$src1, R16:$src2),
939 "cmovge {$src2, $dst|$dst, $src2}",
940 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000941 X86_COND_GE))]>,
942 TB, OpSize;
Evan Chengaed7c722005-12-17 01:24:02 +0000943def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, R16 = [mem16]
944 (ops R16:$dst, R16:$src1, i16mem:$src2),
945 "cmovge {$src2, $dst|$dst, $src2}",
946 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000947 X86_COND_GE))]>,
948 TB, OpSize;
Evan Chengaed7c722005-12-17 01:24:02 +0000949def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, R32 = R32
950 (ops R32:$dst, R32:$src1, R32:$src2),
951 "cmovge {$src2, $dst|$dst, $src2}",
952 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000953 X86_COND_GE))]>,
954 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000955def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, R32 = [mem32]
956 (ops R32:$dst, R32:$src1, i32mem:$src2),
957 "cmovge {$src2, $dst|$dst, $src2}",
958 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000959 X86_COND_GE))]>,
960 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000961
962def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, R16 = R16
963 (ops R16:$dst, R16:$src1, R16:$src2),
964 "cmovle {$src2, $dst|$dst, $src2}",
965 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000966 X86_COND_LE))]>,
967 TB, OpSize;
Evan Chengaed7c722005-12-17 01:24:02 +0000968def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, R16 = [mem16]
969 (ops R16:$dst, R16:$src1, i16mem:$src2),
970 "cmovle {$src2, $dst|$dst, $src2}",
971 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000972 X86_COND_LE))]>,
973 TB, OpSize;
Evan Chengaed7c722005-12-17 01:24:02 +0000974def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, R32 = R32
975 (ops R32:$dst, R32:$src1, R32:$src2),
976 "cmovle {$src2, $dst|$dst, $src2}",
977 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000978 X86_COND_LE))]>,
979 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000980def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, R32 = [mem32]
981 (ops R32:$dst, R32:$src1, i32mem:$src2),
982 "cmovle {$src2, $dst|$dst, $src2}",
983 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000984 X86_COND_LE))]>,
985 TB;
Evan Chengaed7c722005-12-17 01:24:02 +0000986
987def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, R16 = R16
988 (ops R16:$dst, R16:$src1, R16:$src2),
989 "cmovg {$src2, $dst|$dst, $src2}",
990 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000991 X86_COND_G))]>,
992 TB, OpSize;
Evan Chengaed7c722005-12-17 01:24:02 +0000993def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, R16 = [mem16]
994 (ops R16:$dst, R16:$src1, i16mem:$src2),
995 "cmovg {$src2, $dst|$dst, $src2}",
996 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000997 X86_COND_G))]>,
998 TB, OpSize;
Evan Chengaed7c722005-12-17 01:24:02 +0000999def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, R32 = R32
1000 (ops R32:$dst, R32:$src1, R32:$src2),
1001 "cmovg {$src2, $dst|$dst, $src2}",
1002 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001003 X86_COND_G))]>,
1004 TB;
Evan Chengaed7c722005-12-17 01:24:02 +00001005def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, R32 = [mem32]
1006 (ops R32:$dst, R32:$src1, i32mem:$src2),
1007 "cmovg {$src2, $dst|$dst, $src2}",
1008 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001009 X86_COND_G))]>,
1010 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001011
Chris Lattner3a173df2004-10-03 20:35:00 +00001012def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, R16 = R16
1013 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001014 "cmovs {$src2, $dst|$dst, $src2}",
1015 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001016 X86_COND_S))]>,
1017 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001018def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, R16 = [mem16]
1019 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001020 "cmovs {$src2, $dst|$dst, $src2}",
1021 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001022 X86_COND_S))]>,
1023 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001024def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, R32 = R32
1025 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001026 "cmovs {$src2, $dst|$dst, $src2}",
1027 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001028 X86_COND_S))]>,
1029 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001030def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, R32 = [mem32]
1031 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001032 "cmovs {$src2, $dst|$dst, $src2}",
1033 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001034 X86_COND_S))]>,
1035 TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001036
Chris Lattner3a173df2004-10-03 20:35:00 +00001037def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, R16 = R16
1038 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001039 "cmovns {$src2, $dst|$dst, $src2}",
1040 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001041 X86_COND_NS))]>,
1042 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001043def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, R16 = [mem16]
1044 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001045 "cmovns {$src2, $dst|$dst, $src2}",
1046 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001047 X86_COND_NS))]>,
1048 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001049def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, R32 = R32
1050 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001051 "cmovns {$src2, $dst|$dst, $src2}",
1052 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001053 X86_COND_NS))]>,
1054 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001055def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, R32 = [mem32]
1056 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001057 "cmovns {$src2, $dst|$dst, $src2}",
1058 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001059 X86_COND_NS))]>,
1060 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +00001061
Chris Lattner57fbfb52005-01-10 22:09:33 +00001062def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, R16 = R16
1063 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001064 "cmovp {$src2, $dst|$dst, $src2}",
1065 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001066 X86_COND_P))]>,
1067 TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001068def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, R16 = [mem16]
1069 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001070 "cmovp {$src2, $dst|$dst, $src2}",
1071 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001072 X86_COND_P))]>,
1073 TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001074def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, R32 = R32
1075 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001076 "cmovp {$src2, $dst|$dst, $src2}",
1077 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001078 X86_COND_P))]>,
1079 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001080def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, R32 = [mem32]
1081 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001082 "cmovp {$src2, $dst|$dst, $src2}",
1083 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001084 X86_COND_P))]>,
1085 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001086
Chris Lattner57fbfb52005-01-10 22:09:33 +00001087def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, R16 = R16
1088 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001089 "cmovnp {$src2, $dst|$dst, $src2}",
1090 [(set R16:$dst, (X86cmov R16:$src1, R16:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001091 X86_COND_NP))]>,
1092 TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001093def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, R16 = [mem16]
1094 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001095 "cmovnp {$src2, $dst|$dst, $src2}",
1096 [(set R16:$dst, (X86cmov R16:$src1, (loadi16 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001097 X86_COND_NP))]>,
1098 TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001099def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, R32 = R32
1100 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001101 "cmovnp {$src2, $dst|$dst, $src2}",
1102 [(set R32:$dst, (X86cmov R32:$src1, R32:$src2,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001103 X86_COND_NP))]>,
1104 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001105def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, R32 = [mem32]
1106 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd9558e02006-01-06 00:43:03 +00001107 "cmovnp {$src2, $dst|$dst, $src2}",
1108 [(set R32:$dst, (X86cmov R32:$src1, (loadi32 addr:$src2),
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001109 X86_COND_NP))]>,
1110 TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001111
1112
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001113// unary instructions
Evan Chengf0701842005-11-29 19:38:52 +00001114def NEG8r : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg{b} $dst",
1115 [(set R8:$dst, (ineg R8:$src))]>;
1116def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg{w} $dst",
1117 [(set R16:$dst, (ineg R16:$src))]>, OpSize;
1118def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg{l} $dst",
1119 [(set R32:$dst, (ineg R32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001120let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001121 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001122 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001123 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001124 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001125 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001126 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1127
Chris Lattner57a02302004-08-11 04:31:00 +00001128}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001129
Evan Chengf0701842005-11-29 19:38:52 +00001130def NOT8r : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not{b} $dst",
1131 [(set R8:$dst, (not R8:$src))]>;
1132def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not{w} $dst",
1133 [(set R16:$dst, (not R16:$src))]>, OpSize;
1134def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not{l} $dst",
1135 [(set R32:$dst, (not R32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001136let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001137 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001138 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001139 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001140 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +00001141 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001142 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001143}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001144
Evan Chengb51a0592005-12-10 00:48:20 +00001145// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Chengf0701842005-11-29 19:38:52 +00001146def INC8r : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc{b} $dst",
1147 [(set R8:$dst, (add R8:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001148let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengf0701842005-11-29 19:38:52 +00001149def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc{w} $dst",
1150 [(set R16:$dst, (add R16:$src, 1))]>, OpSize;
1151def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc{l} $dst",
1152 [(set R32:$dst, (add R32:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001153}
Chris Lattner57a02302004-08-11 04:31:00 +00001154let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001155 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001156 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001157 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001158 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001159 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001160 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001161}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001162
Evan Chengb51a0592005-12-10 00:48:20 +00001163def DEC8r : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec{b} $dst",
1164 [(set R8:$dst, (add R8:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001165let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb51a0592005-12-10 00:48:20 +00001166def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec{w} $dst",
1167 [(set R16:$dst, (add R16:$src, -1))]>, OpSize;
1168def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec{l} $dst",
1169 [(set R32:$dst, (add R32:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001170}
Chris Lattner57a02302004-08-11 04:31:00 +00001171
1172let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +00001173 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001174 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +00001175 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001176 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +00001177 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001178 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001179}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001180
1181// Logical operators...
Chris Lattnercc65bee2005-01-02 02:35:46 +00001182let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001183def AND8rr : I<0x20, MRMDestReg,
1184 (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001185 "and{b} {$src2, $dst|$dst, $src2}",
1186 [(set R8:$dst, (and R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001187def AND16rr : I<0x21, MRMDestReg,
1188 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001189 "and{w} {$src2, $dst|$dst, $src2}",
1190 [(set R16:$dst, (and R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001191def AND32rr : I<0x21, MRMDestReg,
1192 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001193 "and{l} {$src2, $dst|$dst, $src2}",
1194 [(set R32:$dst, (and R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001195}
Chris Lattner57a02302004-08-11 04:31:00 +00001196
Chris Lattner3a173df2004-10-03 20:35:00 +00001197def AND8rm : I<0x22, MRMSrcMem,
1198 (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001199 "and{b} {$src2, $dst|$dst, $src2}",
1200 [(set R8:$dst, (and R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001201def AND16rm : I<0x23, MRMSrcMem,
1202 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001203 "and{w} {$src2, $dst|$dst, $src2}",
1204 [(set R16:$dst, (and R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001205def AND32rm : I<0x23, MRMSrcMem,
1206 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001207 "and{l} {$src2, $dst|$dst, $src2}",
1208 [(set R32:$dst, (and R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001209
Chris Lattner3a173df2004-10-03 20:35:00 +00001210def AND8ri : Ii8<0x80, MRM4r,
1211 (ops R8 :$dst, R8 :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001212 "and{b} {$src2, $dst|$dst, $src2}",
1213 [(set R8:$dst, (and R8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001214def AND16ri : Ii16<0x81, MRM4r,
1215 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001216 "and{w} {$src2, $dst|$dst, $src2}",
1217 [(set R16:$dst, (and R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001218def AND32ri : Ii32<0x81, MRM4r,
1219 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001220 "and{l} {$src2, $dst|$dst, $src2}",
1221 [(set R32:$dst, (and R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001222def AND16ri8 : Ii8<0x83, MRM4r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001223 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1224 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001225 [(set R16:$dst, (and R16:$src1, i16immSExt8:$src2))]>,
1226 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001227def AND32ri8 : Ii8<0x83, MRM4r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001228 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1229 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001230 [(set R32:$dst, (and R32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001231
1232let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001233 def AND8mr : I<0x20, MRMDestMem,
1234 (ops i8mem :$dst, R8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001235 "and{b} {$src, $dst|$dst, $src}",
1236 [(store (and (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001237 def AND16mr : I<0x21, MRMDestMem,
1238 (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001239 "and{w} {$src, $dst|$dst, $src}",
1240 [(store (and (load addr:$dst), R16:$src), addr:$dst)]>,
1241 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001242 def AND32mr : I<0x21, MRMDestMem,
1243 (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001244 "and{l} {$src, $dst|$dst, $src}",
1245 [(store (and (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001246 def AND8mi : Ii8<0x80, MRM4m,
1247 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001248 "and{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001249 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001250 def AND16mi : Ii16<0x81, MRM4m,
1251 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001252 "and{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001253 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001254 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001255 def AND32mi : Ii32<0x81, MRM4m,
1256 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001257 "and{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001258 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001259 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001260 (ops i16mem:$dst, i16i8imm :$src),
1261 "and{w} {$src, $dst|$dst, $src}",
1262 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1263 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001264 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001265 (ops i32mem:$dst, i32i8imm :$src),
1266 "and{l} {$src, $dst|$dst, $src}",
Evan Chenge3703d42006-01-14 01:18:49 +00001267 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001268}
1269
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001270
Chris Lattnercc65bee2005-01-02 02:35:46 +00001271let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Chris Lattner36b68902004-08-10 21:21:30 +00001272def OR8rr : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001273 "or{b} {$src2, $dst|$dst, $src2}",
1274 [(set R8:$dst, (or R8:$src1, R8:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001275def OR16rr : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001276 "or{w} {$src2, $dst|$dst, $src2}",
1277 [(set R16:$dst, (or R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001278def OR32rr : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001279 "or{l} {$src2, $dst|$dst, $src2}",
1280 [(set R32:$dst, (or R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001281}
Chris Lattner57a02302004-08-11 04:31:00 +00001282def OR8rm : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001283 "or{b} {$src2, $dst|$dst, $src2}",
1284 [(set R8:$dst, (or R8:$src1, (load addr:$src2)))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001285def OR16rm : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001286 "or{w} {$src2, $dst|$dst, $src2}",
1287 [(set R16:$dst, (or R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001288def OR32rm : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001289 "or{l} {$src2, $dst|$dst, $src2}",
1290 [(set R32:$dst, (or R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001291
Chris Lattner36b68902004-08-10 21:21:30 +00001292def OR8ri : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001293 "or{b} {$src2, $dst|$dst, $src2}",
1294 [(set R8:$dst, (or R8:$src1, imm:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001295def OR16ri : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001296 "or{w} {$src2, $dst|$dst, $src2}",
1297 [(set R16:$dst, (or R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001298def OR32ri : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001299 "or{l} {$src2, $dst|$dst, $src2}",
1300 [(set R32:$dst, (or R32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001301
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001302def OR16ri8 : Ii8<0x83, MRM1r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1303 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001304 [(set R16:$dst, (or R16:$src1, i16immSExt8:$src2))]>, OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001305def OR32ri8 : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1306 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001307 [(set R32:$dst, (or R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001308let isTwoAddress = 0 in {
Chris Lattnerf29ed092004-08-11 05:07:25 +00001309 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001310 "or{b} {$src, $dst|$dst, $src}",
1311 [(store (or (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001312 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001313 "or{w} {$src, $dst|$dst, $src}",
1314 [(store (or (load addr:$dst), R16:$src), addr:$dst)]>, OpSize;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001315 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001316 "or{l} {$src, $dst|$dst, $src}",
1317 [(store (or (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001318 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001319 "or{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001320 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001321 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001322 "or{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001323 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001324 OpSize;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001325 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001326 "or{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001327 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng0ef3a772005-12-13 01:41:36 +00001328 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
1329 "or{w} {$src, $dst|$dst, $src}",
1330 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1331 OpSize;
1332 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
1333 "or{l} {$src, $dst|$dst, $src}",
1334 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001335}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001336
1337
Chris Lattnercc65bee2005-01-02 02:35:46 +00001338let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001339def XOR8rr : I<0x30, MRMDestReg,
1340 (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001341 "xor{b} {$src2, $dst|$dst, $src2}",
1342 [(set R8:$dst, (xor R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001343def XOR16rr : I<0x31, MRMDestReg,
1344 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001345 "xor{w} {$src2, $dst|$dst, $src2}",
1346 [(set R16:$dst, (xor R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001347def XOR32rr : I<0x31, MRMDestReg,
1348 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001349 "xor{l} {$src2, $dst|$dst, $src2}",
1350 [(set R32:$dst, (xor R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001351}
1352
Chris Lattner3a173df2004-10-03 20:35:00 +00001353def XOR8rm : I<0x32, MRMSrcMem ,
1354 (ops R8 :$dst, R8:$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001355 "xor{b} {$src2, $dst|$dst, $src2}",
1356 [(set R8:$dst, (xor R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001357def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001358 (ops R16:$dst, R16:$src1, i16mem:$src2),
1359 "xor{w} {$src2, $dst|$dst, $src2}",
1360 [(set R16:$dst, (xor R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001361def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001362 (ops R32:$dst, R32:$src1, i32mem:$src2),
1363 "xor{l} {$src2, $dst|$dst, $src2}",
1364 [(set R32:$dst, (xor R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001365
Chris Lattner3a173df2004-10-03 20:35:00 +00001366def XOR8ri : Ii8<0x80, MRM6r,
1367 (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001368 "xor{b} {$src2, $dst|$dst, $src2}",
1369 [(set R8:$dst, (xor R8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001370def XOR16ri : Ii16<0x81, MRM6r,
1371 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001372 "xor{w} {$src2, $dst|$dst, $src2}",
1373 [(set R16:$dst, (xor R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001374def XOR32ri : Ii32<0x81, MRM6r,
1375 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001376 "xor{l} {$src2, $dst|$dst, $src2}",
1377 [(set R32:$dst, (xor R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001378def XOR16ri8 : Ii8<0x83, MRM6r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001379 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1380 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001381 [(set R16:$dst, (xor R16:$src1, i16immSExt8:$src2))]>,
1382 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001383def XOR32ri8 : Ii8<0x83, MRM6r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001384 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1385 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001386 [(set R32:$dst, (xor R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001387let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001388 def XOR8mr : I<0x30, MRMDestMem,
1389 (ops i8mem :$dst, R8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001390 "xor{b} {$src, $dst|$dst, $src}",
1391 [(store (xor (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001392 def XOR16mr : I<0x31, MRMDestMem,
1393 (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001394 "xor{w} {$src, $dst|$dst, $src}",
1395 [(store (xor (load addr:$dst), R16:$src), addr:$dst)]>,
1396 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001397 def XOR32mr : I<0x31, MRMDestMem,
1398 (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001399 "xor{l} {$src, $dst|$dst, $src}",
1400 [(store (xor (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001401 def XOR8mi : Ii8<0x80, MRM6m,
1402 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001403 "xor{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001404 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001405 def XOR16mi : Ii16<0x81, MRM6m,
1406 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001407 "xor{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001408 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001409 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001410 def XOR32mi : Ii32<0x81, MRM6m,
1411 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +00001412 "xor{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001413 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001414 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001415 (ops i16mem:$dst, i16i8imm :$src),
1416 "xor{w} {$src, $dst|$dst, $src}",
1417 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1418 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001419 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001420 (ops i32mem:$dst, i32i8imm :$src),
1421 "xor{l} {$src, $dst|$dst, $src}",
1422 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001423}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001424
1425// Shift instructions
Chris Lattner3a173df2004-10-03 20:35:00 +00001426def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001427 "shl{b} {%cl, $dst|$dst, %CL}",
1428 [(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001429def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001430 "shl{w} {%cl, $dst|$dst, %CL}",
1431 [(set R16:$dst, (shl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001432def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001433 "shl{l} {%cl, $dst|$dst, %CL}",
1434 [(set R32:$dst, (shl R32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001435
Chris Lattner36b68902004-08-10 21:21:30 +00001436def SHL8ri : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001437 "shl{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001438 [(set R8:$dst, (shl R8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001439let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001440def SHL16ri : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001441 "shl{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001442 [(set R16:$dst, (shl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1443def SHL32ri : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001444 "shl{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001445 [(set R32:$dst, (shl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001446}
Chris Lattnerf29ed092004-08-11 05:07:25 +00001447
1448let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001449 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001450 "shl{b} {%cl, $dst|$dst, %CL}",
1451 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1452 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001453 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001454 "shl{w} {%cl, $dst|$dst, %CL}",
1455 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1456 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001457 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001458 "shl{l} {%cl, $dst|$dst, %CL}",
1459 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1460 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001461 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001462 "shl{b} {$src, $dst|$dst, $src}",
1463 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001464 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001465 "shl{w} {$src, $dst|$dst, $src}",
1466 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1467 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001468 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001469 "shl{l} {$src, $dst|$dst, $src}",
1470 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001471}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001472
Chris Lattner3a173df2004-10-03 20:35:00 +00001473def SHR8rCL : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001474 "shr{b} {%cl, $dst|$dst, %CL}",
1475 [(set R8:$dst, (srl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001476def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001477 "shr{w} {%cl, $dst|$dst, %CL}",
1478 [(set R16:$dst, (srl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001479def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001480 "shr{l} {%cl, $dst|$dst, %CL}",
1481 [(set R32:$dst, (srl R32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001482
Chris Lattner3a173df2004-10-03 20:35:00 +00001483def SHR8ri : Ii8<0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001484 "shr{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001485 [(set R8:$dst, (srl R8:$src1, (i8 imm:$src2)))]>;
1486def SHR16ri : Ii8<0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001487 "shr{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001488 [(set R16:$dst, (srl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1489def SHR32ri : Ii8<0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001490 "shr{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001491 [(set R32:$dst, (srl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001492
Chris Lattner57a02302004-08-11 04:31:00 +00001493let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001494 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001495 "shr{b} {%cl, $dst|$dst, %CL}",
1496 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1497 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001498 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001499 "shr{w} {%cl, $dst|$dst, %CL}",
1500 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1501 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001502 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001503 "shr{l} {%cl, $dst|$dst, %CL}",
1504 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1505 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001506 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001507 "shr{b} {$src, $dst|$dst, $src}",
1508 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001509 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001510 "shr{w} {$src, $dst|$dst, $src}",
1511 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1512 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001513 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001514 "shr{l} {$src, $dst|$dst, $src}",
1515 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001516}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001517
Chris Lattner3a173df2004-10-03 20:35:00 +00001518def SAR8rCL : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001519 "sar{b} {%cl, $dst|$dst, %CL}",
1520 [(set R8:$dst, (sra R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001521def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001522 "sar{w} {%cl, $dst|$dst, %CL}",
1523 [(set R16:$dst, (sra R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001524def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001525 "sar{l} {%cl, $dst|$dst, %CL}",
1526 [(set R32:$dst, (sra R32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001527
Chris Lattner36b68902004-08-10 21:21:30 +00001528def SAR8ri : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001529 "sar{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001530 [(set R8:$dst, (sra R8:$src1, (i8 imm:$src2)))]>;
1531def SAR16ri : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001532 "sar{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001533 [(set R16:$dst, (sra R16:$src1, (i8 imm:$src2)))]>,
1534 OpSize;
1535def SAR32ri : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001536 "sar{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001537 [(set R32:$dst, (sra R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001538let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001539 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001540 "sar{b} {%cl, $dst|$dst, %CL}",
1541 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1542 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001543 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001544 "sar{w} {%cl, $dst|$dst, %CL}",
1545 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1546 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001547 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001548 "sar{l} {%cl, $dst|$dst, %CL}",
1549 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1550 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001551 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001552 "sar{b} {$src, $dst|$dst, $src}",
1553 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001554 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001555 "sar{w} {$src, $dst|$dst, $src}",
1556 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1557 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001558 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001559 "sar{l} {$src, $dst|$dst, $src}",
1560 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001561}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001562
Chris Lattner40ff6332005-01-19 07:50:03 +00001563// Rotate instructions
1564// FIXME: provide shorter instructions when imm8 == 1
1565def ROL8rCL : I<0xD2, MRM0r, (ops R8 :$dst, R8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001566 "rol{b} {%cl, $dst|$dst, %CL}",
1567 [(set R8:$dst, (rotl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001568def ROL16rCL : I<0xD3, MRM0r, (ops R16:$dst, R16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001569 "rol{w} {%cl, $dst|$dst, %CL}",
1570 [(set R16:$dst, (rotl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001571def ROL32rCL : I<0xD3, MRM0r, (ops R32:$dst, R32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001572 "rol{l} {%cl, $dst|$dst, %CL}",
1573 [(set R32:$dst, (rotl R32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001574
1575def ROL8ri : Ii8<0xC0, MRM0r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001576 "rol{b} {$src2, $dst|$dst, $src2}",
1577 [(set R8:$dst, (rotl R8:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001578def ROL16ri : Ii8<0xC1, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001579 "rol{w} {$src2, $dst|$dst, $src2}",
1580 [(set R16:$dst, (rotl R16:$src1, (i8 imm:$src2)))]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001581def ROL32ri : Ii8<0xC1, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001582 "rol{l} {$src2, $dst|$dst, $src2}",
1583 [(set R32:$dst, (rotl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001584
1585let isTwoAddress = 0 in {
1586 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001587 "rol{b} {%cl, $dst|$dst, %CL}",
1588 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1589 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001590 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001591 "rol{w} {%cl, $dst|$dst, %CL}",
1592 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1593 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001594 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001595 "rol{l} {%cl, $dst|$dst, %CL}",
1596 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1597 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001598 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001599 "rol{b} {$src, $dst|$dst, $src}",
1600 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001601 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001602 "rol{w} {$src, $dst|$dst, $src}",
1603 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1604 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001605 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001606 "rol{l} {$src, $dst|$dst, $src}",
1607 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001608}
1609
1610def ROR8rCL : I<0xD2, MRM1r, (ops R8 :$dst, R8 :$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001611 "ror{b} {%cl, $dst|$dst, %CL}",
1612 [(set R8:$dst, (rotr R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001613def ROR16rCL : I<0xD3, MRM1r, (ops R16:$dst, R16:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001614 "ror{w} {%cl, $dst|$dst, %CL}",
1615 [(set R16:$dst, (rotr R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001616def ROR32rCL : I<0xD3, MRM1r, (ops R32:$dst, R32:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001617 "ror{l} {%cl, $dst|$dst, %CL}",
1618 [(set R32:$dst, (rotr R32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001619
1620def ROR8ri : Ii8<0xC0, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001621 "ror{b} {$src2, $dst|$dst, $src2}",
1622 [(set R8:$dst, (rotr R8:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001623def ROR16ri : Ii8<0xC1, MRM1r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001624 "ror{w} {$src2, $dst|$dst, $src2}",
1625 [(set R16:$dst, (rotr R16:$src1, (i8 imm:$src2)))]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001626def ROR32ri : Ii8<0xC1, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Evan Chengeb422a72006-01-11 23:20:05 +00001627 "ror{l} {$src2, $dst|$dst, $src2}",
1628 [(set R32:$dst, (rotr R32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001629let isTwoAddress = 0 in {
1630 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001631 "ror{b} {%cl, $dst|$dst, %CL}",
1632 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1633 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001634 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001635 "ror{w} {%cl, $dst|$dst, %CL}",
1636 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1637 Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001638 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
Evan Chengeb422a72006-01-11 23:20:05 +00001639 "ror{l} {%cl, $dst|$dst, %CL}",
1640 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1641 Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001642 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001643 "ror{b} {$src, $dst|$dst, $src}",
1644 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001645 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001646 "ror{w} {$src, $dst|$dst, $src}",
1647 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1648 OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001649 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
Evan Chengeb422a72006-01-11 23:20:05 +00001650 "ror{l} {$src, $dst|$dst, $src}",
1651 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001652}
1653
1654
1655
1656// Double shift instructions (generalizations of rotate)
Chris Lattner57a02302004-08-11 04:31:00 +00001657def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001658 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1659 [(set R32:$dst, (X86shld R32:$src1, R32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001660 Imp<[CL],[]>, TB;
Chris Lattner57a02302004-08-11 04:31:00 +00001661def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001662 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1663 [(set R32:$dst, (X86shrd R32:$src1, R32:$src2, CL))]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001664 Imp<[CL],[]>, TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001665def SHLD16rrCL : I<0xA5, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001666 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1667 [(set R16:$dst, (X86shld R16:$src1, R16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001668 Imp<[CL],[]>, TB, OpSize;
1669def SHRD16rrCL : I<0xAD, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001670 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1671 [(set R16:$dst, (X86shrd R16:$src1, R16:$src2, CL))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001672 Imp<[CL],[]>, TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001673
1674let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001675def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1676 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001677 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1678 [(set R32:$dst, (X86shld R32:$src1, R32:$src2,
1679 (i8 imm:$src3)))]>,
1680 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001681def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1682 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001683 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1684 [(set R32:$dst, (X86shrd R32:$src1, R32:$src2,
1685 (i8 imm:$src3)))]>,
1686 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001687def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1688 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001689 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1690 [(set R16:$dst, (X86shld R16:$src1, R16:$src2,
1691 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001692 TB, OpSize;
1693def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1694 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001695 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1696 [(set R16:$dst, (X86shrd R16:$src1, R16:$src2,
1697 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001698 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001699}
Chris Lattner0e967d42004-08-01 08:13:11 +00001700
Chris Lattner57a02302004-08-11 04:31:00 +00001701let isTwoAddress = 0 in {
1702 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001703 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1704 [(store (X86shld (loadi32 addr:$dst), R32:$src2, CL),
1705 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001706 Imp<[CL],[]>, TB;
Chris Lattner57a02302004-08-11 04:31:00 +00001707 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001708 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}",
1709 [(store (X86shrd (loadi32 addr:$dst), R32:$src2, CL),
1710 addr:$dst)]>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001711 Imp<[CL],[]>, TB;
1712 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1713 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001714 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1715 [(store (X86shld (loadi32 addr:$dst), R32:$src2,
1716 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001717 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001718 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1719 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001720 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}",
1721 [(store (X86shrd (loadi32 addr:$dst), R32:$src2,
1722 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001723 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001724
1725 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001726 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1727 [(store (X86shld (loadi16 addr:$dst), R16:$src2, CL),
1728 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001729 Imp<[CL],[]>, TB, OpSize;
1730 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001731 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}",
1732 [(store (X86shrd (loadi16 addr:$dst), R16:$src2, CL),
1733 addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001734 Imp<[CL],[]>, TB, OpSize;
1735 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1736 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001737 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1738 [(store (X86shld (loadi16 addr:$dst), R16:$src2,
1739 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001740 TB, OpSize;
1741 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1742 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
Evan Chenge3413162006-01-09 18:33:28 +00001743 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}",
1744 [(store (X86shrd (loadi16 addr:$dst), R16:$src2,
1745 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001746 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001747}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001748
1749
Chris Lattnercc65bee2005-01-02 02:35:46 +00001750// Arithmetic.
1751let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001752def ADD8rr : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001753 "add{b} {$src2, $dst|$dst, $src2}",
1754 [(set R8:$dst, (add R8:$src1, R8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001755let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3a173df2004-10-03 20:35:00 +00001756def ADD16rr : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001757 "add{w} {$src2, $dst|$dst, $src2}",
1758 [(set R16:$dst, (add R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001759def ADD32rr : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001760 "add{l} {$src2, $dst|$dst, $src2}",
1761 [(set R32:$dst, (add R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001762} // end isConvertibleToThreeAddress
1763} // end isCommutable
Chris Lattner3a173df2004-10-03 20:35:00 +00001764def ADD8rm : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001765 "add{b} {$src2, $dst|$dst, $src2}",
1766 [(set R8:$dst, (add R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001767def ADD16rm : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001768 "add{w} {$src2, $dst|$dst, $src2}",
1769 [(set R16:$dst, (add R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001770def ADD32rm : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001771 "add{l} {$src2, $dst|$dst, $src2}",
1772 [(set R32:$dst, (add R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001773
Chris Lattner3a173df2004-10-03 20:35:00 +00001774def ADD8ri : Ii8<0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001775 "add{b} {$src2, $dst|$dst, $src2}",
1776 [(set R8:$dst, (add R8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001777
1778let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3a173df2004-10-03 20:35:00 +00001779def ADD16ri : Ii16<0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001780 "add{w} {$src2, $dst|$dst, $src2}",
1781 [(set R16:$dst, (add R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001782def ADD32ri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001783 "add{l} {$src2, $dst|$dst, $src2}",
1784 [(set R32:$dst, (add R32:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001785}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001786
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001787// FIXME: move ADD16ri8 above ADD16ri to optimize for space.
1788def ADD16ri8 : Ii8<0x83, MRM0r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1789 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001790 [(set R16:$dst, (add R16:$src1, i16immSExt8:$src2))]>,
1791 OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001792def ADD32ri8 : Ii8<0x83, MRM0r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1793 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001794 [(set R32:$dst, (add R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001795
1796let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001797 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001798 "add{b} {$src2, $dst|$dst, $src2}",
1799 [(store (add (load addr:$dst), R8:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001800 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001801 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001802 [(store (add (load addr:$dst), R16:$src2), addr:$dst)]>,
1803 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001804 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001805 "add{l} {$src2, $dst|$dst, $src2}",
1806 [(store (add (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001807 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001808 "add{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001809 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001810 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001811 "add{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001812 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001813 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001814 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001815 "add{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001816 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengee93f9d2005-12-12 19:45:23 +00001817 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1818 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001819 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1820 OpSize;
Evan Chengee93f9d2005-12-12 19:45:23 +00001821 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1822 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001823 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001824}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001825
Chris Lattner10197ff2005-01-03 01:27:59 +00001826let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001827def ADC32rr : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001828 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001829 [(set R32:$dst, (adde R32:$src1, R32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001830}
Chris Lattner3a173df2004-10-03 20:35:00 +00001831def ADC32rm : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001832 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001833 [(set R32:$dst, (adde R32:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001834def ADC32ri : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001835 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001836 [(set R32:$dst, (adde R32:$src1, imm:$src2))]>;
Evan Chenge3413162006-01-09 18:33:28 +00001837def ADC32ri8 : Ii8<0x83, MRM2r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1838 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001839 [(set R32:$dst, (adde R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001840
1841let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001842 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001843 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001844 [(store (adde (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001845 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001846 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001847 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chenge3413162006-01-09 18:33:28 +00001848 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i32i8imm :$src2),
1849 "adc{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001850 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001851}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001852
Chris Lattner3a173df2004-10-03 20:35:00 +00001853def SUB8rr : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001854 "sub{b} {$src2, $dst|$dst, $src2}",
1855 [(set R8:$dst, (sub R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001856def SUB16rr : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001857 "sub{w} {$src2, $dst|$dst, $src2}",
1858 [(set R16:$dst, (sub R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001859def SUB32rr : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001860 "sub{l} {$src2, $dst|$dst, $src2}",
1861 [(set R32:$dst, (sub R32:$src1, R32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001862def SUB8rm : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001863 "sub{b} {$src2, $dst|$dst, $src2}",
1864 [(set R8:$dst, (sub R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001865def SUB16rm : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001866 "sub{w} {$src2, $dst|$dst, $src2}",
1867 [(set R16:$dst, (sub R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001868def SUB32rm : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001869 "sub{l} {$src2, $dst|$dst, $src2}",
1870 [(set R32:$dst, (sub R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001871
Chris Lattner36b68902004-08-10 21:21:30 +00001872def SUB8ri : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001873 "sub{b} {$src2, $dst|$dst, $src2}",
1874 [(set R8:$dst, (sub R8:$src1, imm:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001875def SUB16ri : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001876 "sub{w} {$src2, $dst|$dst, $src2}",
1877 [(set R16:$dst, (sub R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001878def SUB32ri : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001879 "sub{l} {$src2, $dst|$dst, $src2}",
1880 [(set R32:$dst, (sub R32:$src1, imm:$src2))]>;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001881def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1882 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001883 [(set R16:$dst, (sub R16:$src1, i16immSExt8:$src2))]>,
1884 OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001885def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1886 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001887 [(set R32:$dst, (sub R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001888let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001889 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001890 "sub{b} {$src2, $dst|$dst, $src2}",
1891 [(store (sub (load addr:$dst), R8:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001892 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001893 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001894 [(store (sub (load addr:$dst), R16:$src2), addr:$dst)]>,
1895 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001896 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001897 "sub{l} {$src2, $dst|$dst, $src2}",
1898 [(store (sub (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001899 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001900 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001901 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001902 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001903 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001904 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001905 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001906 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001907 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001908 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengd160d482005-12-12 21:54:05 +00001909 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1910 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001911 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1912 OpSize;
Evan Chengd160d482005-12-12 21:54:05 +00001913 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1914 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001915 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001916}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001917
Chris Lattner3a173df2004-10-03 20:35:00 +00001918def SBB32rr : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001919 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001920 [(set R32:$dst, (sube R32:$src1, R32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001921
Chris Lattner57a02302004-08-11 04:31:00 +00001922let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001923 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001924 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001925 [(store (sube (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001926 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001927 "sbb{b} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001928 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001929 def SBB16mi : Ii32<0x81, MRM3m, (ops i16mem:$dst, i16imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001930 "sbb{w} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001931 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Chenge3413162006-01-09 18:33:28 +00001932 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001933 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001934 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001935 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chenge3413162006-01-09 18:33:28 +00001936 def SBB16mi8 : Ii8<0x83, MRM3m, (ops i16mem:$dst, i16i8imm :$src2),
1937 "sbb{w} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001938 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Chenge3413162006-01-09 18:33:28 +00001939 OpSize;
1940 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i32i8imm :$src2),
1941 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001942 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001943}
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001944def SBB8ri : Ii8<0x80, MRM3r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001945 "sbb{b} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001946 [(set R8:$dst, (sube R8:$src1, imm:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001947def SBB16ri : Ii16<0x81, MRM3r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001948 "sbb{w} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001949 [(set R16:$dst, (sube R16:$src1, imm:$src2))]>, OpSize;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001950
Chris Lattner57a02302004-08-11 04:31:00 +00001951def SBB32rm : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001952 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001953 [(set R32:$dst, (sube R32:$src1, (load addr:$src2)))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001954def SBB32ri : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Evan Chenge3413162006-01-09 18:33:28 +00001955 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001956 [(set R32:$dst, (sube R32:$src1, imm:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001957
Evan Chenge3413162006-01-09 18:33:28 +00001958def SBB16ri8 : Ii8<0x83, MRM3r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1959 "sbb{w} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001960 [(set R16:$dst, (sube R16:$src1, i16immSExt8:$src2))]>,
Evan Chenge3413162006-01-09 18:33:28 +00001961 OpSize;
1962def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1963 "sbb{l} {$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00001964 [(set R32:$dst, (sube R32:$src1, i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001965
Chris Lattner10197ff2005-01-03 01:27:59 +00001966let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001967def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001968 "imul{w} {$src2, $dst|$dst, $src2}",
1969 [(set R16:$dst, (mul R16:$src1, R16:$src2))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001970def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001971 "imul{l} {$src2, $dst|$dst, $src2}",
1972 [(set R32:$dst, (mul R32:$src1, R32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00001973}
Chris Lattner3a173df2004-10-03 20:35:00 +00001974def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001975 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001976 [(set R16:$dst, (mul R16:$src1, (load addr:$src2)))]>,
1977 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001978def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001979 "imul{l} {$src2, $dst|$dst, $src2}",
1980 [(set R32:$dst, (mul R32:$src1, (load addr:$src2)))]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001981
1982} // end Two Address instructions
1983
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001984// Suprisingly enough, these are not two address instructions!
Chris Lattner3a173df2004-10-03 20:35:00 +00001985def IMUL16rri : Ii16<0x69, MRMSrcReg, // R16 = R16*I16
1986 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001987 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Chengf281e022005-12-12 23:47:46 +00001988 [(set R16:$dst, (mul R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001989def IMUL32rri : Ii32<0x69, MRMSrcReg, // R32 = R32*I32
1990 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001991 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1992 [(set R32:$dst, (mul R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001993def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // R16 = R16*I8
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001994 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1995 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001996 [(set R16:$dst, (mul R16:$src1, i16immSExt8:$src2))]>,
1997 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001998def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // R32 = R32*I8
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001999 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
2000 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00002001 [(set R32:$dst, (mul R32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002002
Chris Lattner3a173df2004-10-03 20:35:00 +00002003def IMUL16rmi : Ii16<0x69, MRMSrcMem, // R16 = [mem16]*I16
Evan Chengf281e022005-12-12 23:47:46 +00002004 (ops R16:$dst, i16mem:$src1, i16imm:$src2),
2005 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
2006 [(set R16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2007 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002008def IMUL32rmi : Ii32<0x69, MRMSrcMem, // R32 = [mem32]*I32
2009 (ops R32:$dst, i32mem:$src1, i32imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00002010 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
2011 [(set R32:$dst, (mul (load addr:$src1), imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002012def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // R16 = [mem16]*I8
Evan Chengf281e022005-12-12 23:47:46 +00002013 (ops R16:$dst, i16mem:$src1, i16i8imm :$src2),
2014 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00002015 [(set R16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2016 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002017def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // R32 = [mem32]*I8
Evan Chengf281e022005-12-12 23:47:46 +00002018 (ops R32:$dst, i32mem:$src1, i32i8imm: $src2),
2019 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00002020 [(set R32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002021
2022//===----------------------------------------------------------------------===//
2023// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002024//
Chris Lattnercc65bee2005-01-02 02:35:46 +00002025let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Chris Lattner36b68902004-08-10 21:21:30 +00002026def TEST8rr : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002027 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002028 [(X86test R8:$src1, R8:$src2)]>;
Chris Lattner36b68902004-08-10 21:21:30 +00002029def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002030 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002031 [(X86test R16:$src1, R16:$src2)]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00002032def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002033 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002034 [(X86test R32:$src1, R32:$src2)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002035}
Chris Lattner57a02302004-08-11 04:31:00 +00002036def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002037 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002038 [(X86test (loadi8 addr:$src1), R8:$src2)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002039def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002040 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002041 [(X86test (loadi16 addr:$src1), R16:$src2)]>,
2042 OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002043def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002044 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002045 [(X86test (loadi32 addr:$src1), R32:$src2)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002046def TEST8rm : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002047 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002048 [(X86test R8:$src1, (loadi8 addr:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002049def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002050 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002051 [(X86test R16:$src1, (loadi16 addr:$src2))]>,
2052 OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002053def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002054 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002055 [(X86test R32:$src1, (loadi32 addr:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002056
Chris Lattner707c6fe2004-10-04 01:38:10 +00002057def TEST8ri : Ii8 <0xF6, MRM0r, // flags = R8 & imm8
2058 (ops R8:$src1, i8imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002059 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002060 [(X86test R8:$src1, imm:$src2)]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002061def TEST16ri : Ii16<0xF7, MRM0r, // flags = R16 & imm16
2062 (ops R16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002063 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002064 [(X86test R16:$src1, imm:$src2)]>, OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002065def TEST32ri : Ii32<0xF7, MRM0r, // flags = R32 & imm32
2066 (ops R32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002067 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002068 [(X86test R32:$src1, imm:$src2)]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002069def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengaed7c722005-12-17 01:24:02 +00002070 (ops i8mem:$src1, i8imm:$src2),
2071 "test{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002072 [(X86test (loadi8 addr:$src1), imm:$src2)]>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002073def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
2074 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002075 "test{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002076 [(X86test (loadi16 addr:$src1), imm:$src2)]>,
2077 OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00002078def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
2079 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002080 "test{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002081 [(X86test (loadi32 addr:$src1), imm:$src2)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002082
2083
2084// Condition code ops, incl. set if equal/not equal/...
Evan Chengf0701842005-11-29 19:38:52 +00002085def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
2086def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002087
Chris Lattner3a173df2004-10-03 20:35:00 +00002088def SETEr : I<0x94, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002089 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002090 "sete $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002091 [(set R8:$dst, (X86setcc X86_COND_E))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002092 TB; // R8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002093def SETEm : I<0x94, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002094 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002095 "sete $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002096 [(store (X86setcc X86_COND_E), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002097 TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002098def SETNEr : I<0x95, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002099 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002100 "setne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002101 [(set R8:$dst, (X86setcc X86_COND_NE))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002102 TB; // R8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002103def SETNEm : I<0x95, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002104 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002105 "setne $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002106 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002107 TB; // [mem8] = !=
2108def SETLr : I<0x9C, MRM0r,
2109 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002110 "setl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002111 [(set R8:$dst, (X86setcc X86_COND_L))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002112 TB; // R8 = < signed
2113def SETLm : I<0x9C, MRM0m,
2114 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002115 "setl $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002116 [(store (X86setcc X86_COND_L), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002117 TB; // [mem8] = < signed
2118def SETGEr : I<0x9D, MRM0r,
2119 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002120 "setge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002121 [(set R8:$dst, (X86setcc X86_COND_GE))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002122 TB; // R8 = >= signed
2123def SETGEm : I<0x9D, MRM0m,
2124 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002125 "setge $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002126 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002127 TB; // [mem8] = >= signed
2128def SETLEr : I<0x9E, MRM0r,
2129 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002130 "setle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002131 [(set R8:$dst, (X86setcc X86_COND_LE))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002132 TB; // R8 = <= signed
2133def SETLEm : I<0x9E, MRM0m,
2134 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002135 "setle $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002136 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002137 TB; // [mem8] = <= signed
2138def SETGr : I<0x9F, MRM0r,
2139 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002140 "setg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002141 [(set R8:$dst, (X86setcc X86_COND_G))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002142 TB; // R8 = > signed
2143def SETGm : I<0x9F, MRM0m,
2144 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002145 "setg $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002146 [(store (X86setcc X86_COND_G), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002147 TB; // [mem8] = > signed
2148
2149def SETBr : I<0x92, MRM0r,
2150 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002151 "setb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002152 [(set R8:$dst, (X86setcc X86_COND_B))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002153 TB; // R8 = < unsign
2154def SETBm : I<0x92, MRM0m,
2155 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002156 "setb $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002157 [(store (X86setcc X86_COND_B), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002158 TB; // [mem8] = < unsign
2159def SETAEr : I<0x93, MRM0r,
2160 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002161 "setae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002162 [(set R8:$dst, (X86setcc X86_COND_AE))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002163 TB; // R8 = >= unsign
2164def SETAEm : I<0x93, MRM0m,
2165 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002166 "setae $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002167 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002168 TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002169def SETBEr : I<0x96, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002170 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002171 "setbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002172 [(set R8:$dst, (X86setcc X86_COND_BE))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002173 TB; // R8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002174def SETBEm : I<0x96, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002175 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002176 "setbe $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002177 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002178 TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002179def SETAr : I<0x97, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002180 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002181 "seta $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002182 [(set R8:$dst, (X86setcc X86_COND_A))]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002183 TB; // R8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002184def SETAm : I<0x97, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002185 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002186 "seta $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002187 [(store (X86setcc X86_COND_A), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002188 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002189
Chris Lattner3a173df2004-10-03 20:35:00 +00002190def SETSr : I<0x98, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002191 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002192 "sets $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002193 [(set R8:$dst, (X86setcc X86_COND_S))]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002194 TB; // R8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002195def SETSm : I<0x98, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002196 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002197 "sets $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002198 [(store (X86setcc X86_COND_S), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002199 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002200def SETNSr : I<0x99, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002201 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002202 "setns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002203 [(set R8:$dst, (X86setcc X86_COND_NS))]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002204 TB; // R8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002205def SETNSm : I<0x99, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002206 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002207 "setns $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002208 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002209 TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002210def SETPr : I<0x9A, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002211 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002212 "setp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002213 [(set R8:$dst, (X86setcc X86_COND_P))]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002214 TB; // R8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002215def SETPm : I<0x9A, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002216 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002217 "setp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002218 [(store (X86setcc X86_COND_P), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002219 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002220def SETNPr : I<0x9B, MRM0r,
Chris Lattner9fb24222005-12-21 05:34:58 +00002221 (ops R8 :$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002222 "setnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002223 [(set R8:$dst, (X86setcc X86_COND_NP))]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002224 TB; // R8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002225def SETNPm : I<0x9B, MRM0m,
Chris Lattner9fb24222005-12-21 05:34:58 +00002226 (ops i8mem:$dst),
Evan Chengd9558e02006-01-06 00:43:03 +00002227 "setnp $dst",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002228 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002229 TB; // [mem8] = not parity
Chris Lattner1cca5e32003-08-03 21:54:21 +00002230
2231// Integer comparisons
Chris Lattner3a173df2004-10-03 20:35:00 +00002232def CMP8rr : I<0x38, MRMDestReg,
2233 (ops R8 :$src1, R8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002234 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002235 [(X86cmp R8:$src1, R8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002236def CMP16rr : I<0x39, MRMDestReg,
2237 (ops R16:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002238 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002239 [(X86cmp R16:$src1, R16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002240def CMP32rr : I<0x39, MRMDestReg,
2241 (ops R32:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002242 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002243 [(X86cmp R32:$src1, R32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002244def CMP8mr : I<0x38, MRMDestMem,
2245 (ops i8mem :$src1, R8 :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002246 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002247 [(X86cmp (loadi8 addr:$src1), R8:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002248def CMP16mr : I<0x39, MRMDestMem,
2249 (ops i16mem:$src1, R16:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002250 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002251 [(X86cmp (loadi16 addr:$src1), R16:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002252def CMP32mr : I<0x39, MRMDestMem,
2253 (ops i32mem:$src1, R32:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002254 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002255 [(X86cmp (loadi32 addr:$src1), R32:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002256def CMP8rm : I<0x3A, MRMSrcMem,
2257 (ops R8 :$src1, i8mem :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002258 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002259 [(X86cmp R8:$src1, (loadi8 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002260def CMP16rm : I<0x3B, MRMSrcMem,
2261 (ops R16:$src1, i16mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002262 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002263 [(X86cmp R16:$src1, (loadi16 addr:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002264def CMP32rm : I<0x3B, MRMSrcMem,
2265 (ops R32:$src1, i32mem:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002266 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002267 [(X86cmp R32:$src1, (loadi32 addr:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002268def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengaed7c722005-12-17 01:24:02 +00002269 (ops R8:$src1, i8imm:$src2),
2270 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002271 [(X86cmp R8:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002272def CMP16ri : Ii16<0x81, MRM7r,
2273 (ops R16:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002274 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002275 [(X86cmp R16:$src1, imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002276def CMP32ri : Ii32<0x81, MRM7r,
2277 (ops R32:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002278 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002279 [(X86cmp R32:$src1, imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002280def CMP8mi : Ii8 <0x80, MRM7m,
2281 (ops i8mem :$src1, i8imm :$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002282 "cmp{b} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002283 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002284def CMP16mi : Ii16<0x81, MRM7m,
2285 (ops i16mem:$src1, i16imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002286 "cmp{w} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002287 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002288def CMP32mi : Ii32<0x81, MRM7m,
2289 (ops i32mem:$src1, i32imm:$src2),
Evan Chengaed7c722005-12-17 01:24:02 +00002290 "cmp{l} {$src2, $src1|$src1, $src2}",
Evan Cheng71fb9ad2006-01-26 00:29:36 +00002291 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002292
2293// Sign/Zero extenders
Chris Lattner3a173df2004-10-03 20:35:00 +00002294def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002295 "movs{bw|x} {$src, $dst|$dst, $src}",
2296 [(set R16:$dst, (sext R8:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002297def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002298 "movs{bw|x} {$src, $dst|$dst, $src}",
2299 [(set R16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002300def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002301 "movs{bl|x} {$src, $dst|$dst, $src}",
2302 [(set R32:$dst, (sext R8:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002303def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002304 "movs{bl|x} {$src, $dst|$dst, $src}",
2305 [(set R32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002306def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002307 "movs{wl|x} {$src, $dst|$dst, $src}",
2308 [(set R32:$dst, (sext R16:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002309def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002310 "movs{wl|x} {$src, $dst|$dst, $src}",
2311 [(set R32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002312
Chris Lattner3a173df2004-10-03 20:35:00 +00002313def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002314 "movz{bw|x} {$src, $dst|$dst, $src}",
2315 [(set R16:$dst, (zext R8:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002316def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002317 "movz{bw|x} {$src, $dst|$dst, $src}",
2318 [(set R16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002319def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00002320 "movz{bl|x} {$src, $dst|$dst, $src}",
2321 [(set R32:$dst, (zext R8:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002322def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002323 "movz{bl|x} {$src, $dst|$dst, $src}",
2324 [(set R32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002325def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00002326 "movz{wl|x} {$src, $dst|$dst, $src}",
2327 [(set R32:$dst, (zext R16:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002328def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src),
Evan Cheng7a7e8372005-12-14 02:22:27 +00002329 "movz{wl|x} {$src, $dst|$dst, $src}",
2330 [(set R32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2331
Nate Begemanf1702ac2005-06-27 21:20:31 +00002332//===----------------------------------------------------------------------===//
Evan Cheng747a90d2006-02-21 02:24:38 +00002333// Miscellaneous Instructions
2334//===----------------------------------------------------------------------===//
2335
2336def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
2337 TB, Imp<[],[EAX,EDX]>;
2338
Evan Cheng747a90d2006-02-21 02:24:38 +00002339//===----------------------------------------------------------------------===//
2340// Alias Instructions
2341//===----------------------------------------------------------------------===//
2342
2343// Alias instructions that map movr0 to xor.
2344// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
2345def MOV8r0 : I<0x30, MRMInitReg, (ops R8 :$dst),
2346 "xor{b} $dst, $dst",
2347 [(set R8:$dst, 0)]>;
2348def MOV16r0 : I<0x31, MRMInitReg, (ops R16:$dst),
2349 "xor{w} $dst, $dst",
2350 [(set R16:$dst, 0)]>, OpSize;
2351def MOV32r0 : I<0x31, MRMInitReg, (ops R32:$dst),
2352 "xor{l} $dst, $dst",
2353 [(set R32:$dst, 0)]>;
2354
Evan Cheng510e4782006-01-09 23:10:28 +00002355//===----------------------------------------------------------------------===//
2356// Non-Instruction Patterns
2357//===----------------------------------------------------------------------===//
2358
Evan Cheng71fb8342006-02-25 10:02:21 +00002359// ConstantPool GlobalAddress, ExternalSymbol
2360def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2361def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2362def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2363
2364def : Pat<(add R32:$src1, (X86Wrapper tconstpool:$src2)),
2365 (ADD32ri R32:$src1, tconstpool:$src2)>;
2366def : Pat<(add R32:$src1, (X86Wrapper tglobaladdr :$src2)),
2367 (ADD32ri R32:$src1, tglobaladdr:$src2)>;
2368def : Pat<(add R32:$src1, (X86Wrapper texternalsym:$src2)),
2369 (ADD32ri R32:$src1, texternalsym:$src2)>;
2370
2371def : Pat<(store (X86Wrapper tconstpool:$src), addr:$dst),
2372 (MOV32mi addr:$dst, tconstpool:$src)>;
2373def : Pat<(store (X86Wrapper tglobaladdr:$src), addr:$dst),
2374 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2375def : Pat<(store (X86Wrapper texternalsym:$src), addr:$dst),
2376 (MOV32mi addr:$dst, texternalsym:$src)>;
2377
Evan Cheng510e4782006-01-09 23:10:28 +00002378// Calls
2379def : Pat<(X86call tglobaladdr:$dst),
2380 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng8700e142006-01-11 06:09:51 +00002381def : Pat<(X86call texternalsym:$dst),
2382 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002383
2384// X86 specific add which produces a flag.
Nate Begeman551bf3f2006-02-17 05:43:56 +00002385def : Pat<(addc R32:$src1, R32:$src2),
Evan Cheng510e4782006-01-09 23:10:28 +00002386 (ADD32rr R32:$src1, R32:$src2)>;
Nate Begeman551bf3f2006-02-17 05:43:56 +00002387def : Pat<(addc R32:$src1, (load addr:$src2)),
Evan Cheng510e4782006-01-09 23:10:28 +00002388 (ADD32rm R32:$src1, addr:$src2)>;
Nate Begeman551bf3f2006-02-17 05:43:56 +00002389def : Pat<(addc R32:$src1, imm:$src2),
Evan Cheng510e4782006-01-09 23:10:28 +00002390 (ADD32ri R32:$src1, imm:$src2)>;
Nate Begeman551bf3f2006-02-17 05:43:56 +00002391def : Pat<(addc R32:$src1, i32immSExt8:$src2),
Evan Cheng510e4782006-01-09 23:10:28 +00002392 (ADD32ri8 R32:$src1, i32immSExt8:$src2)>;
2393
Nate Begeman551bf3f2006-02-17 05:43:56 +00002394def : Pat<(subc R32:$src1, R32:$src2),
Evan Cheng510e4782006-01-09 23:10:28 +00002395 (SUB32rr R32:$src1, R32:$src2)>;
Nate Begeman551bf3f2006-02-17 05:43:56 +00002396def : Pat<(subc R32:$src1, (load addr:$src2)),
Evan Cheng510e4782006-01-09 23:10:28 +00002397 (SUB32rm R32:$src1, addr:$src2)>;
Nate Begeman551bf3f2006-02-17 05:43:56 +00002398def : Pat<(subc R32:$src1, imm:$src2),
Evan Cheng510e4782006-01-09 23:10:28 +00002399 (SUB32ri R32:$src1, imm:$src2)>;
Nate Begeman551bf3f2006-02-17 05:43:56 +00002400def : Pat<(subc R32:$src1, i32immSExt8:$src2),
Evan Cheng510e4782006-01-09 23:10:28 +00002401 (SUB32ri8 R32:$src1, i32immSExt8:$src2)>;
2402
Evan Chengb8414332006-01-13 21:45:19 +00002403def : Pat<(truncstore (i8 imm:$src), addr:$dst, i1),
2404 (MOV8mi addr:$dst, imm:$src)>;
2405def : Pat<(truncstore R8:$src, addr:$dst, i1),
2406 (MOV8mr addr:$dst, R8:$src)>;
2407
Evan Cheng510e4782006-01-09 23:10:28 +00002408// {s|z}extload bool -> {s|z}extload byte
2409def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2410def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
Evan Chenge5d93432006-01-17 07:02:46 +00002411def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002412def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2413def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2414
2415// extload bool -> extload byte
2416def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2417
2418// anyext -> zext
2419def : Pat<(i16 (anyext R8 :$src)), (MOVZX16rr8 R8 :$src)>;
2420def : Pat<(i32 (anyext R8 :$src)), (MOVZX32rr8 R8 :$src)>;
2421def : Pat<(i32 (anyext R16:$src)), (MOVZX32rr16 R16:$src)>;
2422
Evan Chengcfa260b2006-01-06 02:31:59 +00002423//===----------------------------------------------------------------------===//
2424// Some peepholes
2425//===----------------------------------------------------------------------===//
2426
2427// (shl x, 1) ==> (add x, x)
2428def : Pat<(shl R8 :$src1, (i8 1)), (ADD8rr R8 :$src1, R8 :$src1)>;
2429def : Pat<(shl R16:$src1, (i8 1)), (ADD16rr R16:$src1, R16:$src1)>;
2430def : Pat<(shl R32:$src1, (i8 1)), (ADD32rr R32:$src1, R32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002431
Evan Cheng956044c2006-01-19 23:26:24 +00002432// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng68b951a2006-01-19 01:56:29 +00002433def : Pat<(or (srl R32:$src1, CL:$amt),
2434 (shl R32:$src2, (sub 32, CL:$amt))),
2435 (SHRD32rrCL R32:$src1, R32:$src2)>;
2436
Evan Cheng21d54432006-01-20 01:13:30 +00002437def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2438 (shl R32:$src2, (sub 32, CL:$amt))), addr:$dst),
2439 (SHRD32mrCL addr:$dst, R32:$src2)>;
2440
Evan Cheng956044c2006-01-19 23:26:24 +00002441// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng68b951a2006-01-19 01:56:29 +00002442def : Pat<(or (shl R32:$src1, CL:$amt),
2443 (srl R32:$src2, (sub 32, CL:$amt))),
2444 (SHLD32rrCL R32:$src1, R32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00002445
Evan Cheng21d54432006-01-20 01:13:30 +00002446def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2447 (srl R32:$src2, (sub 32, CL:$amt))), addr:$dst),
2448 (SHLD32mrCL addr:$dst, R32:$src2)>;
2449
Evan Cheng956044c2006-01-19 23:26:24 +00002450// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2451def : Pat<(or (srl R16:$src1, CL:$amt),
2452 (shl R16:$src2, (sub 16, CL:$amt))),
2453 (SHRD16rrCL R16:$src1, R16:$src2)>;
2454
Evan Cheng21d54432006-01-20 01:13:30 +00002455def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2456 (shl R16:$src2, (sub 16, CL:$amt))), addr:$dst),
2457 (SHRD16mrCL addr:$dst, R16:$src2)>;
2458
Evan Cheng956044c2006-01-19 23:26:24 +00002459// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2460def : Pat<(or (shl R16:$src1, CL:$amt),
2461 (srl R16:$src2, (sub 16, CL:$amt))),
2462 (SHLD16rrCL R16:$src1, R16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00002463
2464def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2465 (srl R16:$src2, (sub 16, CL:$amt))), addr:$dst),
2466 (SHLD16mrCL addr:$dst, R16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00002467
2468
2469//===----------------------------------------------------------------------===//
2470// Floating Point Stack Support
2471//===----------------------------------------------------------------------===//
2472
2473include "X86InstrFPStack.td"
2474
2475//===----------------------------------------------------------------------===//
2476// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2477//===----------------------------------------------------------------------===//
2478
2479include "X86InstrMMX.td"
2480
2481//===----------------------------------------------------------------------===//
2482// XMM Floating point support (requires SSE / SSE2)
2483//===----------------------------------------------------------------------===//
2484
2485include "X86InstrSSE.td"