blob: fc41dfa2e42017d16fe732af6b593815c50a2ec9 [file] [log] [blame]
Arnold Schwaighofer48abc5c2007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
John Criswell856ba762003-10-21 15:17:13 +00007//
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 Chenge5f62042007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng0488db92007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000029
Bill Wendlingd350e022008-12-12 21:15:41 +000030def SDTUnaryArithOvf : SDTypeProfile<1, 1,
31 [SDTCisInt<0>]>;
32def SDTBinaryArithOvf : SDTypeProfile<1, 2,
33 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
34 SDTCisInt<0>]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +000035
Evan Chenge5f62042007-09-29 00:00:36 +000036def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng0488db92007-09-25 01:57:46 +000037 [SDTCisVT<0, OtherVT>,
38 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000039
Evan Chenge5f62042007-09-29 00:00:36 +000040def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng0488db92007-09-25 01:57:46 +000041 [SDTCisVT<0, i8>,
42 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000043
Andrew Lenharth26ed8692008-03-01 21:52:34 +000044def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
45 SDTCisVT<2, i8>]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000046def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth26ed8692008-03-01 21:52:34 +000047
Dale Johannesen48c1bc22008-10-02 18:53:47 +000048def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
49 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattner447ff682008-03-11 03:23:40 +000050def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000051
Bill Wendlingc69107c2007-11-13 09:19:02 +000052def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
53def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
54 SDTCisVT<1, i32> ]>;
Evan Chenge3413162006-01-09 18:33:28 +000055
Dan Gohmand35121a2008-05-29 19:57:41 +000056def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000057
Evan Cheng67f92a72006-01-11 22:15:48 +000058def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
59
Evan Chenge3413162006-01-09 18:33:28 +000060def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000061
Evan Cheng71fb8342006-02-25 10:02:21 +000062def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
63
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000064def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
65
66def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
67
Anton Korobeynikov2365f512007-07-14 14:06:15 +000068def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
69
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000070def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
71
Evan Cheng18efe262007-12-14 02:13:44 +000072def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
73def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Evan Chenge3413162006-01-09 18:33:28 +000074def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
75def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000076
Evan Chenge5f62042007-09-29 00:00:36 +000077def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Evan Chengb077b842005-12-21 02:39:21 +000078
Dan Gohmanc7a37d42008-12-23 22:45:23 +000079def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
80
Evan Chenge5f62042007-09-29 00:00:36 +000081def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +000082def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +000083 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +000084def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Chengb077b842005-12-21 02:39:21 +000085
Andrew Lenharth26ed8692008-03-01 21:52:34 +000086def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
87 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
88 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000089def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
90 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
91 SDNPMayLoad]>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +000092def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
93 [SDNPHasChain, SDNPMayStore,
94 SDNPMayLoad, SDNPMemOperand]>;
95def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
96 [SDNPHasChain, SDNPMayStore,
97 SDNPMayLoad, SDNPMemOperand]>;
98def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
99 [SDNPHasChain, SDNPMayStore,
100 SDNPMayLoad, SDNPMemOperand]>;
101def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
102 [SDNPHasChain, SDNPMayStore,
103 SDNPMayLoad, SDNPMemOperand]>;
104def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
105 [SDNPHasChain, SDNPMayStore,
106 SDNPMayLoad, SDNPMemOperand]>;
107def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
108 [SDNPHasChain, SDNPMayStore,
109 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen880ae362008-10-03 22:25:52 +0000110def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
111 [SDNPHasChain, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
Evan Chenge3413162006-01-09 18:33:28 +0000113def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
114 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000115
Evan Chenge3413162006-01-09 18:33:28 +0000116def X86callseq_start :
117 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +0000118 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +0000119def X86callseq_end :
120 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000121 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000122
Evan Chenge3413162006-01-09 18:33:28 +0000123def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
124 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +0000125
Evan Chengfb914c42006-05-20 01:40:16 +0000126def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
Evan Chengfea89c12006-04-27 08:40:39 +0000127 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
128
Evan Cheng67f92a72006-01-11 22:15:48 +0000129def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000130 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000131def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
133 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000134
Evan Chenge3413162006-01-09 18:33:28 +0000135def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000136 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000137
Evan Cheng0085a282006-11-30 21:55:46 +0000138def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
139def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000140
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000141def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000142 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000143def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
144
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000145def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
146 [SDNPHasChain]>;
147
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000148def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
149 [SDNPHasChain, SDNPOptInFlag]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000150
Bill Wendlingd350e022008-12-12 21:15:41 +0000151def X86add_ovf : SDNode<"X86ISD::ADD", SDTBinaryArithOvf>;
152def X86sub_ovf : SDNode<"X86ISD::SUB", SDTBinaryArithOvf>;
153def X86smul_ovf : SDNode<"X86ISD::SMUL", SDTBinaryArithOvf>;
154def X86umul_ovf : SDNode<"X86ISD::UMUL", SDTUnaryArithOvf>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +0000155
Evan Chengaed7c722005-12-17 01:24:02 +0000156//===----------------------------------------------------------------------===//
157// X86 Operand Definitions.
158//
159
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000160// *mem - Operand definitions for the funky X86 addressing mode operands.
161//
Evan Chengaf78ef52006-05-17 21:21:41 +0000162class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000163 let PrintMethod = printMethod;
Evan Cheng25ab6902006-09-08 06:48:29 +0000164 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000165}
Nate Begeman391c5d22005-11-30 18:54:35 +0000166
Chris Lattner45432512005-12-17 19:47:05 +0000167def i8mem : X86MemOperand<"printi8mem">;
168def i16mem : X86MemOperand<"printi16mem">;
169def i32mem : X86MemOperand<"printi32mem">;
170def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000171def i128mem : X86MemOperand<"printi128mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000172def f32mem : X86MemOperand<"printf32mem">;
173def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000174def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000175def f128mem : X86MemOperand<"printf128mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000176
Evan Cheng25ab6902006-09-08 06:48:29 +0000177def lea32mem : Operand<i32> {
178 let PrintMethod = "printi32mem";
Evan Cheng25ab6902006-09-08 06:48:29 +0000179 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
180}
181
Nate Begeman16b04f32005-07-15 00:38:55 +0000182def SSECC : Operand<i8> {
183 let PrintMethod = "printSSECC";
184}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000185
Evan Cheng7ccced62006-02-18 00:15:05 +0000186def piclabel: Operand<i32> {
187 let PrintMethod = "printPICLabel";
188}
189
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000190// A couple of more descriptive operand definitions.
191// 16-bits but only 8 bits are significant.
192def i16i8imm : Operand<i16>;
193// 32-bits but only 8 bits are significant.
194def i32i8imm : Operand<i32>;
195
Evan Chengd35b8c12005-12-04 08:19:43 +0000196// Branch targets have OtherVT type.
197def brtarget : Operand<OtherVT>;
198
Evan Chengaed7c722005-12-17 01:24:02 +0000199//===----------------------------------------------------------------------===//
200// X86 Complex Pattern Definitions.
201//
202
Evan Chengec693f72005-12-08 02:01:35 +0000203// Define X86 specific addressing mode.
Evan Chengaf9db752006-10-11 21:03:53 +0000204def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000205def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Evan Chengaf9db752006-10-11 21:03:53 +0000206 [add, mul, shl, or, frameindex], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000207
Evan Chengaed7c722005-12-17 01:24:02 +0000208//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000209// X86 Instruction Predicate Definitions.
Evan Cheng28b514392006-12-05 19:50:18 +0000210def HasMMX : Predicate<"Subtarget->hasMMX()">;
211def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
212def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
213def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000214def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000215def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
216def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000217def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
218def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000219def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
220def In64BitMode : Predicate<"Subtarget->is64Bit()">;
221def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
222def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
223def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000224def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000225def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000226
227//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000228// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000229//
230
Evan Chengc64a1a92007-07-31 08:04:03 +0000231include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000232
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000233//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000234// Pattern fragments...
235//
Evan Chengd9558e02006-01-06 00:43:03 +0000236
237// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000238// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000239def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
240def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
241def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
242def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
243def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
244def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
245def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
246def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
247def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
248def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000249def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000250def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000251def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000252def X86_COND_O : PatLeaf<(i8 13)>;
253def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
254def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000255
Evan Cheng9b6b6422005-12-13 00:14:11 +0000256def i16immSExt8 : PatLeaf<(i16 imm), [{
257 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000258 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000259 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000260}]>;
261
Evan Cheng9b6b6422005-12-13 00:14:11 +0000262def i32immSExt8 : PatLeaf<(i32 imm), [{
263 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000264 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000265 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Evan Chengb3558542005-12-13 00:01:09 +0000266}]>;
267
Evan Cheng605c4152005-12-13 01:57:51 +0000268// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000269// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
270// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000271def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000272 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman67ca6be2008-08-20 15:24:22 +0000273 ISD::LoadExtType ExtType = LD->getExtensionType();
274 if (ExtType == ISD::NON_EXTLOAD)
275 return true;
276 if (ExtType == ISD::EXTLOAD)
277 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000278 return false;
279}]>;
280
Dan Gohman33586292008-10-15 06:50:19 +0000281def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengca57f782008-09-24 23:27:55 +0000282 LoadSDNode *LD = cast<LoadSDNode>(N);
Evan Chengca57f782008-09-24 23:27:55 +0000283 ISD::LoadExtType ExtType = LD->getExtensionType();
284 if (ExtType == ISD::EXTLOAD)
285 return LD->getAlignment() >= 2 && !LD->isVolatile();
286 return false;
287}]>;
288
Dan Gohman33586292008-10-15 06:50:19 +0000289def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000290 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman67ca6be2008-08-20 15:24:22 +0000291 ISD::LoadExtType ExtType = LD->getExtensionType();
292 if (ExtType == ISD::NON_EXTLOAD)
293 return true;
294 if (ExtType == ISD::EXTLOAD)
295 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000296 return false;
297}]>;
298
Dan Gohman33586292008-10-15 06:50:19 +0000299def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengd47e0b62008-09-29 17:26:18 +0000300 LoadSDNode *LD = cast<LoadSDNode>(N);
301 if (LD->isVolatile())
302 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000303 ISD::LoadExtType ExtType = LD->getExtensionType();
304 if (ExtType == ISD::NON_EXTLOAD)
305 return true;
306 if (ExtType == ISD::EXTLOAD)
307 return LD->getAlignment() >= 4;
308 return false;
309}]>;
310
Evan Cheng7a7e8372005-12-14 02:22:27 +0000311def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Evan Cheng11e15b32006-04-03 20:53:28 +0000312def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000313
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000314def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
315def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen59a58732007-08-05 18:49:15 +0000316def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000317
Evan Cheng466685d2006-10-09 20:57:25 +0000318def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
319def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
320def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000321
Evan Cheng466685d2006-10-09 20:57:25 +0000322def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
323def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
324def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
325def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
326def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
327def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000328
Evan Cheng466685d2006-10-09 20:57:25 +0000329def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
330def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
331def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
332def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
333def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
334def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000335
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000336
337// An 'and' node with a single use.
338def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000339 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000340}]>;
341
Dan Gohman74feef22008-10-17 01:23:35 +0000342// 'shld' and 'shrd' instruction patterns. Note that even though these have
343// the srl and shl in their patterns, the C++ code must still check for them,
344// because predicates are tested before children nodes are explored.
345
346def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
347 (or (srl node:$src1, node:$amt1),
348 (shl node:$src2, node:$amt2)), [{
349 assert(N->getOpcode() == ISD::OR);
350 return N->getOperand(0).getOpcode() == ISD::SRL &&
351 N->getOperand(1).getOpcode() == ISD::SHL &&
352 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
353 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
354 N->getOperand(0).getConstantOperandVal(1) ==
355 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
356}]>;
357
358def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
359 (or (shl node:$src1, node:$amt1),
360 (srl node:$src2, node:$amt2)), [{
361 assert(N->getOpcode() == ISD::OR);
362 return N->getOperand(0).getOpcode() == ISD::SHL &&
363 N->getOperand(1).getOpcode() == ISD::SRL &&
364 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
365 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
366 N->getOperand(0).getConstantOperandVal(1) ==
367 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
368}]>;
369
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000370//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000371// Instruction list...
372//
373
Chris Lattnerf18c0742006-10-12 17:42:56 +0000374// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
375// a stack adjustment and the codegen must know that they may modify the stack
376// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000377// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
378// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000379let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000380def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
381 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000382 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000383 Requires<[In32BitMode]>;
384def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
385 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000386 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000387 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000388}
Evan Cheng4a460802006-01-11 00:33:36 +0000389
390// Nop
Chris Lattnerba7e7562008-01-10 07:59:24 +0000391let neverHasSideEffects = 1 in
392 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Evan Cheng4a460802006-01-11 00:33:36 +0000393
Evan Cheng0475ab52008-01-05 00:41:47 +0000394// PIC base
Dan Gohman2662d552008-10-01 04:14:30 +0000395let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerba7e7562008-01-10 07:59:24 +0000396 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
397 "call\t$label\n\tpop{l}\t$reg", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000398
Chris Lattner1cca5e32003-08-03 21:54:21 +0000399//===----------------------------------------------------------------------===//
400// Control Flow Instructions...
401//
402
Chris Lattner1be48112005-05-13 17:56:48 +0000403// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000404let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000405 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000406 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000407 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000408 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000409 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
410 "ret\t$amt",
Evan Chenge3413162006-01-09 18:33:28 +0000411 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000412}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000413
414// All branches are RawFrm, Void, Branch, and Terminators
Evan Chengffbacca2007-07-21 00:34:19 +0000415let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000416 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
417 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000418
Evan Chengec3bc392006-09-07 19:03:48 +0000419let isBranch = 1, isBarrier = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000420 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000421
Owen Anderson20ab2902007-11-12 07:39:39 +0000422// Indirect branches
423let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000424 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000425 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000426 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000427 [(brind (loadi32 addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000428}
429
430// Conditional branches
Evan Cheng0488db92007-09-25 01:57:46 +0000431let Uses = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000432def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000433 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000434def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000435 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000436def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000437 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000438def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000439 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000440def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000441 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000442def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000443 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000444
Dan Gohmanb1576f52007-07-31 20:11:57 +0000445def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000446 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000447def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000448 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000449def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000450 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000451def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000452 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000453
Dan Gohmanb1576f52007-07-31 20:11:57 +0000454def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000455 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000456def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000457 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000458def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000459 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000460def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000461 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000462def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000463 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000464def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000465 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng0488db92007-09-25 01:57:46 +0000466} // Uses = [EFLAGS]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000467
468//===----------------------------------------------------------------------===//
469// Call Instructions...
470//
Evan Chengffbacca2007-07-21 00:34:19 +0000471let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000472 // All calls clobber the non-callee saved registers. ESP is marked as
473 // a use to prevent stack-pointer assignments that appear immediately
474 // before calls from potentially appearing dead. Uses for argument
475 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000476 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000477 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000478 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
479 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000480 Uses = [ESP] in {
Evan Chengf02ca692007-12-22 02:26:46 +0000481 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
482 "call\t${dst:call}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000483 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000484 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000485 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000486 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000487 }
488
Chris Lattner1e9448b2005-05-15 03:10:37 +0000489// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000490
Chris Lattner447ff682008-03-11 03:23:40 +0000491def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000492 "#TAILCALL",
493 []>;
494
Evan Chengffbacca2007-07-21 00:34:19 +0000495let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000496def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000497 "#TC_RETURN $dst $offset",
498 []>;
499
500let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000501def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000502 "#TC_RETURN $dst $offset",
503 []>;
504
505let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer30e62c02008-04-30 09:16:33 +0000506
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000507 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000508 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000509let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000510 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
511 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000512let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000513 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000514 "jmp\t{*}$dst # TAILCALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000515
Chris Lattner1cca5e32003-08-03 21:54:21 +0000516//===----------------------------------------------------------------------===//
517// Miscellaneous Instructions...
518//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000519let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000520def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000521 (outs), (ins), "leave", []>;
522
Chris Lattnerba7e7562008-01-10 07:59:24 +0000523let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
524let mayLoad = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000525def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000526
Chris Lattnerba7e7562008-01-10 07:59:24 +0000527let mayStore = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000528def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000529}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000530
Chris Lattnerba7e7562008-01-10 07:59:24 +0000531let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000532def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000533let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000534def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000535
Evan Cheng069287d2006-05-16 07:21:53 +0000536let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000537 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000538 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000539 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000540 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000541
Chris Lattner1cca5e32003-08-03 21:54:21 +0000542
Evan Cheng18efe262007-12-14 02:13:44 +0000543// Bit scan instructions.
544let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000545def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000546 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000547 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000548def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000549 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000550 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
551 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000552def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000553 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000554 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000555def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000556 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000557 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
558 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000559
Evan Chengfd9e4732007-12-14 18:49:43 +0000560def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000561 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000562 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000563def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000564 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000565 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
566 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000567def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000568 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000569 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000570def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000571 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000572 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
573 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000574} // Defs = [EFLAGS]
575
Chris Lattnerba7e7562008-01-10 07:59:24 +0000576let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000577def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000578 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000579 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000580let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000581def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000582 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000583 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000584 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000585
Evan Cheng071a2792007-09-11 19:55:27 +0000586let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000587def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000588 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000589def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000590 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000591def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000592 [(X86rep_movs i32)]>, REP;
593}
Chris Lattner915e5e52004-02-12 17:53:22 +0000594
Evan Cheng071a2792007-09-11 19:55:27 +0000595let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000596def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000597 [(X86rep_stos i8)]>, REP;
598let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000599def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000600 [(X86rep_stos i16)]>, REP, OpSize;
601let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000602def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000603 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000604
Evan Cheng071a2792007-09-11 19:55:27 +0000605let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000606def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000607 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000608
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000609let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000610def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000611}
612
Chris Lattner1cca5e32003-08-03 21:54:21 +0000613//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000614// Input/Output Instructions...
615//
Evan Cheng071a2792007-09-11 19:55:27 +0000616let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000617def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000618 "in{b}\t{%dx, %al|%AL, %DX}", []>;
619let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000620def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000621 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
622let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000623def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000624 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000625
Evan Cheng071a2792007-09-11 19:55:27 +0000626let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000627def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000628 "in{b}\t{$port, %al|%AL, $port}", []>;
629let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000630def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000631 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
632let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000633def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000634 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000635
Evan Cheng071a2792007-09-11 19:55:27 +0000636let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000637def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000638 "out{b}\t{%al, %dx|%DX, %AL}", []>;
639let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000640def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000641 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
642let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000643def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000644 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000645
Evan Cheng071a2792007-09-11 19:55:27 +0000646let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000647def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000648 "out{b}\t{%al, $port|$port, %AL}", []>;
649let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000650def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000651 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
652let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000653def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000654 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000655
656//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000657// Move Instructions...
658//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000659let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000660def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000661 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000662def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000663 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000664def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000665 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000666}
Evan Cheng359e9372008-06-18 08:13:07 +0000667let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000668def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000669 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000670 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000671def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000672 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000673 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000674def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000675 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000676 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000677}
Evan Cheng64d80e32007-07-19 01:14:50 +0000678def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000679 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000680 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000681def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000682 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000683 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000684def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000685 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000686 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000687
Dan Gohman15511cf2008-12-03 18:15:48 +0000688let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000689def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000690 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000691 [(set GR8:$dst, (load addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000692def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000693 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000694 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000695def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000696 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000697 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +0000698}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000699
Evan Cheng64d80e32007-07-19 01:14:50 +0000700def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000701 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000702 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000703def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000704 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000705 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000706def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000707 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000708 [(store GR32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000709
Chris Lattner1cca5e32003-08-03 21:54:21 +0000710//===----------------------------------------------------------------------===//
711// Fixed-Register Multiplication and Division Instructions...
712//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000713
Chris Lattnerc8f45872003-08-04 04:59:56 +0000714// Extra precision multiplication
Evan Cheng24f2ea32007-09-14 21:48:26 +0000715let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000716def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000717 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
718 // This probably ought to be moved to a def : Pat<> if the
719 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000720 [(set AL, (mul AL, GR8:$src)),
721 (implicit EFLAGS)]>; // AL,AH = AL*GR8
722
Chris Lattnera731c9f2008-01-11 07:18:17 +0000723let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000724def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
725 "mul{w}\t$src",
726 []>, OpSize; // AX,DX = AX*GR16
727
Chris Lattnera731c9f2008-01-11 07:18:17 +0000728let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000729def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
730 "mul{l}\t$src",
731 []>; // EAX,EDX = EAX*GR32
732
Evan Cheng24f2ea32007-09-14 21:48:26 +0000733let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000734def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000735 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000736 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
737 // This probably ought to be moved to a def : Pat<> if the
738 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000739 [(set AL, (mul AL, (loadi8 addr:$src))),
740 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
741
Chris Lattnerba7e7562008-01-10 07:59:24 +0000742let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000743let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000744def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000745 "mul{w}\t$src",
746 []>, OpSize; // AX,DX = AX*[mem16]
747
Evan Cheng24f2ea32007-09-14 21:48:26 +0000748let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000749def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000750 "mul{l}\t$src",
751 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000752}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000753
Chris Lattnerba7e7562008-01-10 07:59:24 +0000754let neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000755let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +0000756def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
757 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +0000758let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000759def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +0000760 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +0000761let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +0000762def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
763 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +0000764let mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000765let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000766def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000767 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +0000768let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000769def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000770 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
771let Defs = [EAX,EDX], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000772def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000773 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000774}
Dan Gohmanc99da132008-11-18 21:29:14 +0000775} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +0000776
Chris Lattnerc8f45872003-08-04 04:59:56 +0000777// unsigned division/remainder
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000778let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000779def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000780 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000781let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000782def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000783 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000784let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000785def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000786 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000787let mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000788let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000789def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000790 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000791let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000792def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000793 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000794let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000795def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000796 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000797}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000798
Chris Lattnerfc752712004-08-01 09:52:59 +0000799// Signed division/remainder.
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000800let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000801def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000802 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000803let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000804def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000805 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000806let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000807def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000808 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000809let mayLoad = 1, mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000810let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000811def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000812 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000813let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000814def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000815 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000816let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000817def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000818 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000819}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000820
Chris Lattner1cca5e32003-08-03 21:54:21 +0000821//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000822// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000823//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000824let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000825
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000826// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +0000827let Uses = [EFLAGS] in {
Evan Cheng7ad42d92007-10-05 23:13:21 +0000828let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000829def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000830 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000831 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000832 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000833 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000834 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000835def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000836 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000837 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000838 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000839 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000840 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000841
Evan Cheng069287d2006-05-16 07:21:53 +0000842def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000843 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000844 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000845 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000846 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000847 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000848def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000849 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000850 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000851 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000852 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000853 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000854def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000855 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000856 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000857 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000858 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000859 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000860def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000861 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000862 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000863 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000864 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000865 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000866def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000867 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000868 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000869 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000870 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000871 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000872def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000873 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000874 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000875 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000876 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000877 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000878def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000879 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000880 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000881 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000882 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000883 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000884def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000885 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000886 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000887 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000888 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000889 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000890def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000891 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000892 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000893 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000894 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000895 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000896def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000897 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000898 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000899 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000900 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000901 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000902def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000903 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000904 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000905 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000906 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000907 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000908def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000909 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000910 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000911 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000912 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000913 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000914def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000915 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000916 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000917 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000918 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000919 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000920def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000921 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000922 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000923 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000924 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000925 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000926def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000927 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000928 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000929 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000930 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000931 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000932def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000933 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000934 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000935 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000936 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000937 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000938def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000939 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000940 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000941 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000942 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000943 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000944def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000945 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000946 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000947 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000948 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000949 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000950def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000951 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000952 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000953 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000954 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000955 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000956def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000957 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000958 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000959 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000960 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000961 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000962def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000963 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000964 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000965 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000966 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000967 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000968def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000969 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000970 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000971 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000972 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000973 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000974def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000975 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000976 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000977 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000978 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000979 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000980def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000981 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000982 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000983 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000984 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000985 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000986def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000987 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000988 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000989 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000990 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000991 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000992def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000993 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000994 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000995 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000996 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000997 TB;
Evan Cheng7ad42d92007-10-05 23:13:21 +0000998} // isCommutable = 1
999
Evan Cheng069287d2006-05-16 07:21:53 +00001000def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +00001001 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001002 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001003 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00001004 X86_COND_NP, EFLAGS))]>,
1005 TB;
Evan Cheng7ad42d92007-10-05 23:13:21 +00001006
1007def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1008 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1009 "cmovb\t{$src2, $dst|$dst, $src2}",
1010 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1011 X86_COND_B, EFLAGS))]>,
1012 TB, OpSize;
1013def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1014 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1015 "cmovb\t{$src2, $dst|$dst, $src2}",
1016 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1017 X86_COND_B, EFLAGS))]>,
1018 TB;
1019def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1020 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1021 "cmovae\t{$src2, $dst|$dst, $src2}",
1022 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1023 X86_COND_AE, EFLAGS))]>,
1024 TB, OpSize;
1025def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1026 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1027 "cmovae\t{$src2, $dst|$dst, $src2}",
1028 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1029 X86_COND_AE, EFLAGS))]>,
1030 TB;
1031def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1032 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1033 "cmove\t{$src2, $dst|$dst, $src2}",
1034 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1035 X86_COND_E, EFLAGS))]>,
1036 TB, OpSize;
1037def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1038 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1039 "cmove\t{$src2, $dst|$dst, $src2}",
1040 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1041 X86_COND_E, EFLAGS))]>,
1042 TB;
1043def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1044 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1045 "cmovne\t{$src2, $dst|$dst, $src2}",
1046 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1047 X86_COND_NE, EFLAGS))]>,
1048 TB, OpSize;
1049def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1050 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1051 "cmovne\t{$src2, $dst|$dst, $src2}",
1052 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1053 X86_COND_NE, EFLAGS))]>,
1054 TB;
1055def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1056 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1057 "cmovbe\t{$src2, $dst|$dst, $src2}",
1058 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1059 X86_COND_BE, EFLAGS))]>,
1060 TB, OpSize;
1061def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1062 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1063 "cmovbe\t{$src2, $dst|$dst, $src2}",
1064 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1065 X86_COND_BE, EFLAGS))]>,
1066 TB;
1067def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1068 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1069 "cmova\t{$src2, $dst|$dst, $src2}",
1070 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1071 X86_COND_A, EFLAGS))]>,
1072 TB, OpSize;
1073def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1074 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1075 "cmova\t{$src2, $dst|$dst, $src2}",
1076 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1077 X86_COND_A, EFLAGS))]>,
1078 TB;
1079def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1080 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1081 "cmovl\t{$src2, $dst|$dst, $src2}",
1082 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1083 X86_COND_L, EFLAGS))]>,
1084 TB, OpSize;
1085def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1086 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1087 "cmovl\t{$src2, $dst|$dst, $src2}",
1088 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1089 X86_COND_L, EFLAGS))]>,
1090 TB;
1091def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1092 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1093 "cmovge\t{$src2, $dst|$dst, $src2}",
1094 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1095 X86_COND_GE, EFLAGS))]>,
1096 TB, OpSize;
1097def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1098 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1099 "cmovge\t{$src2, $dst|$dst, $src2}",
1100 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1101 X86_COND_GE, EFLAGS))]>,
1102 TB;
1103def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1104 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1105 "cmovle\t{$src2, $dst|$dst, $src2}",
1106 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1107 X86_COND_LE, EFLAGS))]>,
1108 TB, OpSize;
1109def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1110 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1111 "cmovle\t{$src2, $dst|$dst, $src2}",
1112 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1113 X86_COND_LE, EFLAGS))]>,
1114 TB;
1115def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1116 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1117 "cmovg\t{$src2, $dst|$dst, $src2}",
1118 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1119 X86_COND_G, EFLAGS))]>,
1120 TB, OpSize;
1121def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1122 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1123 "cmovg\t{$src2, $dst|$dst, $src2}",
1124 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1125 X86_COND_G, EFLAGS))]>,
1126 TB;
1127def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1128 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1129 "cmovs\t{$src2, $dst|$dst, $src2}",
1130 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1131 X86_COND_S, EFLAGS))]>,
1132 TB, OpSize;
1133def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1134 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1135 "cmovs\t{$src2, $dst|$dst, $src2}",
1136 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1137 X86_COND_S, EFLAGS))]>,
1138 TB;
1139def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1140 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1141 "cmovns\t{$src2, $dst|$dst, $src2}",
1142 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1143 X86_COND_NS, EFLAGS))]>,
1144 TB, OpSize;
1145def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1146 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1147 "cmovns\t{$src2, $dst|$dst, $src2}",
1148 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1149 X86_COND_NS, EFLAGS))]>,
1150 TB;
1151def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1152 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1153 "cmovp\t{$src2, $dst|$dst, $src2}",
1154 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1155 X86_COND_P, EFLAGS))]>,
1156 TB, OpSize;
1157def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1158 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1159 "cmovp\t{$src2, $dst|$dst, $src2}",
1160 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1161 X86_COND_P, EFLAGS))]>,
1162 TB;
1163def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1164 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1165 "cmovnp\t{$src2, $dst|$dst, $src2}",
1166 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1167 X86_COND_NP, EFLAGS))]>,
1168 TB, OpSize;
Evan Cheng0488db92007-09-25 01:57:46 +00001169} // Uses = [EFLAGS]
1170
1171
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001172// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001173let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001174let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001175def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001176 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001177def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001178 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001179def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001180 [(set GR32:$dst, (ineg GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001181let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001182 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001183 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001184 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001185 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001186 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001187 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1188
Chris Lattner57a02302004-08-11 04:31:00 +00001189}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001190} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001191
Dan Gohmanb1576f52007-07-31 20:11:57 +00001192def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001193 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001194def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001195 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001196def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001197 [(set GR32:$dst, (not GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001198let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001199 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001200 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001201 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001202 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001203 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001204 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001205}
Evan Cheng1693e482006-07-19 00:27:29 +00001206} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001207
Evan Chengb51a0592005-12-10 00:48:20 +00001208// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001209let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001210let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001211def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001212 [(set GR8:$dst, (add GR8:$src, 1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001213let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001214def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001215 [(set GR16:$dst, (add GR16:$src, 1))]>,
1216 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001217def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001218 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001219}
Evan Cheng1693e482006-07-19 00:27:29 +00001220let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001221 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001222 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001223 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001224 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1225 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001226 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001227 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1228 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001229}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001230
Evan Cheng1693e482006-07-19 00:27:29 +00001231let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001232def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001233 [(set GR8:$dst, (add GR8:$src, -1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001234let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001235def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001236 [(set GR16:$dst, (add GR16:$src, -1))]>,
1237 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001238def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001239 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001240}
Chris Lattner57a02302004-08-11 04:31:00 +00001241
Evan Cheng1693e482006-07-19 00:27:29 +00001242let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001243 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001244 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001245 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001246 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1247 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001248 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001249 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1250 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001251}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001252} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001253
1254// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001255let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001256let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001257def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001258 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001259 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001260 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001261def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001262 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001263 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001264 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001265def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001266 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001267 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001268 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001269}
Chris Lattner57a02302004-08-11 04:31:00 +00001270
Chris Lattner3a173df2004-10-03 20:35:00 +00001271def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001272 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001273 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001274 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001275def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001276 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001277 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001278 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001279def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001280 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001281 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001282 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001283
Chris Lattner3a173df2004-10-03 20:35:00 +00001284def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001285 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001286 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001287 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001288def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001289 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001290 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001291 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001292def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001293 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001294 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001295 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001296def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001297 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001298 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001299 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001300 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001301def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001302 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001303 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001304 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001305
1306let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001307 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001308 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001309 "and{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001310 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001311 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001312 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001313 "and{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001314 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001315 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001316 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001317 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001318 "and{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001319 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001320 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001321 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001322 "and{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001323 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001324 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001325 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001326 "and{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001327 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001328 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001329 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001330 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001331 "and{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001332 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001333 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001334 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001335 "and{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001336 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1337 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001338 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001339 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001340 "and{l}\t{$src, $dst|$dst, $src}",
Evan Chenge3703d42006-01-14 01:18:49 +00001341 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001342}
1343
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001344
Chris Lattnercc65bee2005-01-02 02:35:46 +00001345let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001346def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001347 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001348 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001349def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001350 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001351 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001352def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001353 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001354 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001355}
Evan Cheng64d80e32007-07-19 01:14:50 +00001356def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001357 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001358 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001359def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001360 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001361 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001362def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001363 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001364 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001365
Evan Cheng64d80e32007-07-19 01:14:50 +00001366def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001367 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001368 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001369def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001370 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001371 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001372def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001373 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001374 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001375
Evan Cheng64d80e32007-07-19 01:14:50 +00001376def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001377 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001378 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001379def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001380 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001381 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001382let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001383 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001384 "or{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001385 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001386 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001387 "or{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001388 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001389 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001390 "or{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001391 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001392 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001393 "or{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001394 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001395 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001396 "or{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001397 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001398 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001399 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001400 "or{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001401 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001402 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001403 "or{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001404 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1405 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001406 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001407 "or{l}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001408 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001409} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001410
1411
Evan Cheng359e9372008-06-18 08:13:07 +00001412let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001413 def XOR8rr : I<0x30, MRMDestReg,
1414 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1415 "xor{b}\t{$src2, $dst|$dst, $src2}",
1416 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1417 def XOR16rr : I<0x31, MRMDestReg,
1418 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1419 "xor{w}\t{$src2, $dst|$dst, $src2}",
1420 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1421 def XOR32rr : I<0x31, MRMDestReg,
1422 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1423 "xor{l}\t{$src2, $dst|$dst, $src2}",
1424 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng359e9372008-06-18 08:13:07 +00001425} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00001426
Chris Lattner3a173df2004-10-03 20:35:00 +00001427def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001428 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001429 "xor{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001430 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001431def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001432 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001433 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001434 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1435 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001436def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001437 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001438 "xor{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001439 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001440
Bill Wendling75cf88f2008-05-29 03:46:36 +00001441def XOR8ri : Ii8<0x80, MRM6r,
1442 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1443 "xor{b}\t{$src2, $dst|$dst, $src2}",
1444 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1445def XOR16ri : Ii16<0x81, MRM6r,
1446 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1447 "xor{w}\t{$src2, $dst|$dst, $src2}",
1448 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1449def XOR32ri : Ii32<0x81, MRM6r,
1450 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1451 "xor{l}\t{$src2, $dst|$dst, $src2}",
1452 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1453def XOR16ri8 : Ii8<0x83, MRM6r,
1454 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1455 "xor{w}\t{$src2, $dst|$dst, $src2}",
1456 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1457 OpSize;
1458def XOR32ri8 : Ii8<0x83, MRM6r,
1459 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1460 "xor{l}\t{$src2, $dst|$dst, $src2}",
1461 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001462
Chris Lattner57a02302004-08-11 04:31:00 +00001463let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001464 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001465 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001466 "xor{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001467 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001468 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001469 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001470 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001471 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001472 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001473 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001474 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001475 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001476 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001477 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001478 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001479 "xor{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001480 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001481 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001482 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001483 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001484 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001485 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001486 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001487 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001488 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001489 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001490 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001491 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001492 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001493 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1494 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001495 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001496 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001497 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001498 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001499} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00001500} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001501
1502// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00001503let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00001504let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001505def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001506 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001507 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001508def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001509 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001510 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001511def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001512 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001513 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001514} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00001515
Evan Cheng64d80e32007-07-19 01:14:50 +00001516def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001517 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001518 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001519let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001520def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001521 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001522 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001523def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001524 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001525 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf9b3f372008-01-11 18:00:50 +00001526// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1527// cheaper.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001528} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00001529
Chris Lattnerf29ed092004-08-11 05:07:25 +00001530let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001531 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001532 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001533 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001534 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001535 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001536 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001537 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001538 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001539 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001540 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1541 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001542 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001543 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001544 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001545 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001546 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001547 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1548 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001549 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001550 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001551 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001552
1553 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001554 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001555 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001556 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001557 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001558 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001559 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1560 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001561 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001562 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001563 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001564}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001565
Evan Cheng071a2792007-09-11 19:55:27 +00001566let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001567def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001568 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001569 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001570def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001571 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001572 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001573def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001574 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001575 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1576}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001577
Evan Cheng64d80e32007-07-19 01:14:50 +00001578def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001579 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001580 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001581def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001582 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001583 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001584def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001585 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001586 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001587
Evan Cheng09c54572006-06-29 00:36:51 +00001588// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001589def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001590 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001591 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001592def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001593 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001594 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001595def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001596 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001597 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1598
Chris Lattner57a02302004-08-11 04:31:00 +00001599let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001600 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001601 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001602 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001603 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001604 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001605 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001606 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001607 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001608 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001609 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001610 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1611 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001612 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001613 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001614 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001615 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001616 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001617 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1618 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001619 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001620 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001621 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001622
1623 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001624 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001625 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001626 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001627 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001628 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001629 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001630 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001631 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001632 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001633}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001634
Evan Cheng071a2792007-09-11 19:55:27 +00001635let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001636def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001637 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001638 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001639def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001640 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001641 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001642def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001643 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001644 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1645}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001646
Evan Cheng64d80e32007-07-19 01:14:50 +00001647def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001648 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001649 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001650def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001651 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001652 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001653 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001654def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001655 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001656 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001657
1658// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001659def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001660 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001661 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001662def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001663 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001664 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001665def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001666 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001667 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1668
Chris Lattnerf29ed092004-08-11 05:07:25 +00001669let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001670 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001671 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001672 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001673 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001674 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001675 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001676 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001677 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001678 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001679 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1680 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001681 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001682 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001683 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001684 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001685 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001686 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1687 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001688 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001689 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001690 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001691
1692 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001693 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001694 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001695 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001696 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001697 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001698 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1699 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001700 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001701 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001702 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001703}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001704
Chris Lattner40ff6332005-01-19 07:50:03 +00001705// Rotate instructions
1706// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00001707let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001708def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001709 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001710 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001711def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001712 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001713 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001714def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001715 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001716 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1717}
Chris Lattner40ff6332005-01-19 07:50:03 +00001718
Evan Cheng64d80e32007-07-19 01:14:50 +00001719def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001720 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001721 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001722def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001723 "rol{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001724 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001725def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001726 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001727 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001728
Evan Cheng09c54572006-06-29 00:36:51 +00001729// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001730def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001731 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001732 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001733def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001734 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001735 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001736def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001737 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001738 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1739
Chris Lattner40ff6332005-01-19 07:50:03 +00001740let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001741 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001742 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001743 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001744 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001745 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001746 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001747 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001748 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001749 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001750 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1751 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001752 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001753 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001754 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001755 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001756 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001757 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1758 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001759 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001760 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001761 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001762
1763 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001764 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001765 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001766 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001767 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001768 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001769 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1770 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001771 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001772 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001773 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001774}
1775
Evan Cheng071a2792007-09-11 19:55:27 +00001776let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001777def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001778 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001779 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001780def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001781 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001782 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001783def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001784 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001785 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1786}
Chris Lattner40ff6332005-01-19 07:50:03 +00001787
Evan Cheng64d80e32007-07-19 01:14:50 +00001788def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001789 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001790 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001791def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001792 "ror{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001793 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001794def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001795 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001796 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001797
1798// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001799def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001800 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001801 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001802def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001803 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001804 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001805def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001806 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001807 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1808
Chris Lattner40ff6332005-01-19 07:50:03 +00001809let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001810 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001811 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001812 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001813 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001814 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001815 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001816 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001817 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001818 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001819 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1820 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001821 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001822 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001823 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001824 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001825 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001826 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1827 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001828 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001829 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001830 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001831
1832 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001833 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001834 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001835 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001836 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001837 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001838 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1839 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001840 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001841 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001842 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001843}
1844
1845
1846
1847// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00001848let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001849def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001850 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001851 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001852def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001853 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001854 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001855def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001856 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001857 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001858 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001859def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001860 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001861 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001862 TB, OpSize;
1863}
Chris Lattner41e431b2005-01-19 07:11:01 +00001864
1865let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001866def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001867 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001868 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001869 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001870 (i8 imm:$src3)))]>,
1871 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001872def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001873 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001874 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001875 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001876 (i8 imm:$src3)))]>,
1877 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001878def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001879 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001880 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001881 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001882 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001883 TB, OpSize;
1884def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001885 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001886 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001887 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001888 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001889 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001890}
Chris Lattner0e967d42004-08-01 08:13:11 +00001891
Chris Lattner57a02302004-08-11 04:31:00 +00001892let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001893 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001894 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001895 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001896 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001897 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001898 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001899 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001900 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001901 addr:$dst)]>, TB;
1902 }
Chris Lattner3a173df2004-10-03 20:35:00 +00001903 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001904 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001905 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001906 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001907 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001908 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001909 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001910 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001911 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001912 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001913 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001914 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001915
Evan Cheng071a2792007-09-11 19:55:27 +00001916 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001917 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001918 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001919 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001920 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001921 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001922 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001923 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001924 addr:$dst)]>, TB, OpSize;
1925 }
Chris Lattner0df53d22005-01-19 07:31:24 +00001926 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001927 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001928 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001929 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001930 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001931 TB, OpSize;
1932 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001933 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001934 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001935 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001936 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001937 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001938}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001939} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001940
1941
Chris Lattnercc65bee2005-01-02 02:35:46 +00001942// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001943let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001944let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00001945// Register-Register Addition
1946def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1947 (ins GR8 :$src1, GR8 :$src2),
1948 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00001949 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingab55ebd2008-12-12 00:56:36 +00001950 (implicit EFLAGS)]>;
1951
Chris Lattnercc65bee2005-01-02 02:35:46 +00001952let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00001953// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00001954def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1955 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001956 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00001957 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
1958 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00001959def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1960 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001961 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00001962 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
1963 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001964} // end isConvertibleToThreeAddress
1965} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00001966
1967// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00001968def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1969 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001970 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00001971 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
1972 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00001973def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1974 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001975 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00001976 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
1977 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00001978def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1979 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001980 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00001981 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
1982 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001983
Bill Wendlingab55ebd2008-12-12 00:56:36 +00001984// Register-Integer Addition
1985def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1986 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00001987 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
1988 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00001989
Chris Lattnercc65bee2005-01-02 02:35:46 +00001990let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00001991// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00001992def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1993 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001994 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00001995 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
1996 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00001997def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1998 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001999 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002000 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2001 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002002def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2003 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002004 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002005 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2006 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002007def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2008 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002009 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002010 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2011 (implicit EFLAGS)]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002012}
Chris Lattner57a02302004-08-11 04:31:00 +00002013
2014let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002015 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002016 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002017 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002018 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2019 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002020 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002021 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002022 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2023 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002024 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002025 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002026 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2027 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002028 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002029 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002030 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2031 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002032 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002033 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002034 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2035 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002036 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002037 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002038 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2039 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002040 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002041 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002042 [(store (add (load addr:$dst), i16immSExt8:$src2),
2043 addr:$dst),
2044 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002045 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002046 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002047 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002048 addr:$dst),
2049 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002050}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002051
Evan Cheng3154cb62007-10-05 17:59:57 +00002052let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002053let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00002054def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002055 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002056 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002057}
Evan Cheng64d80e32007-07-19 01:14:50 +00002058def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002059 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002060 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002061def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002062 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002063 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002064def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002065 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002066 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002067
2068let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002069 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002070 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002071 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002072 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002073 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002074 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002075 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002076 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling9f248742008-12-02 00:07:05 +00002077 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002078}
Evan Cheng3154cb62007-10-05 17:59:57 +00002079} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002080
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002081// Register-Register Subtraction
2082def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2083 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002084 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2085 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002086def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2087 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002088 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2089 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002090def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2091 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002092 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2093 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002094
2095// Register-Memory Subtraction
2096def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2097 (ins GR8 :$src1, i8mem :$src2),
2098 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002099 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2100 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002101def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2102 (ins GR16:$src1, i16mem:$src2),
2103 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002104 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2105 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002106def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2107 (ins GR32:$src1, i32mem:$src2),
2108 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002109 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2110 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002111
2112// Register-Integer Subtraction
2113def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2114 (ins GR8:$src1, i8imm:$src2),
2115 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002116 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2117 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002118def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2119 (ins GR16:$src1, i16imm:$src2),
2120 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002121 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2122 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002123def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2124 (ins GR32:$src1, i32imm:$src2),
2125 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002126 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2127 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002128def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2129 (ins GR16:$src1, i16i8imm:$src2),
2130 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002131 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2132 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002133def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2134 (ins GR32:$src1, i32i8imm:$src2),
2135 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002136 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2137 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002138
Chris Lattner57a02302004-08-11 04:31:00 +00002139let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002140 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002141 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002142 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002143 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2144 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002145 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002146 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002147 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2148 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002149 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002150 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002151 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2152 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002153
2154 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002155 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002156 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002157 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2158 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002159 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002160 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002161 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2162 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002163 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002164 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002165 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2166 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002167 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002168 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002169 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002170 addr:$dst),
2171 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002172 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002173 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002174 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002175 addr:$dst),
2176 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002177}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002178
Evan Cheng3154cb62007-10-05 17:59:57 +00002179let Uses = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002180def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002181 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng24f2ea32007-09-14 21:48:26 +00002182 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00002183
Chris Lattner57a02302004-08-11 04:31:00 +00002184let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002185 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002186 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002187 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002188 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002189 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002190 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002191 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002192 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002193 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002194 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002195 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng24f2ea32007-09-14 21:48:26 +00002196 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002197}
Evan Cheng64d80e32007-07-19 01:14:50 +00002198def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002199 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002200 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002201def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002202 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002203 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002204def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002205 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002206 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00002207} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00002208} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002209
Evan Cheng24f2ea32007-09-14 21:48:26 +00002210let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002211let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00002212// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002213def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002214 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002215 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2216 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002217def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002218 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002219 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2220 (implicit EFLAGS)]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002221}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002222
Bill Wendlingd350e022008-12-12 21:15:41 +00002223// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002224def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2225 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002226 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002227 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2228 (implicit EFLAGS)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002229def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002230 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002231 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2232 (implicit EFLAGS)]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002233} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002234} // end Two Address instructions
2235
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002236// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00002237let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00002238// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002239def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002240 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002241 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002242 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2243 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002244def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002245 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002246 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002247 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2248 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002249def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002250 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002251 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002252 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2253 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002254def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002255 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002256 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002257 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2258 (implicit EFLAGS)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002259
Bill Wendlingd350e022008-12-12 21:15:41 +00002260// Memory-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002261def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002262 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002263 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002264 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2265 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002266def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002267 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002268 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002269 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2270 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002271def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002272 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002273 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002274 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002275 i16immSExt8:$src2)),
2276 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002277def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002278 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002279 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002280 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002281 i32immSExt8:$src2)),
2282 (implicit EFLAGS)]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002283} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002284
2285//===----------------------------------------------------------------------===//
2286// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002287//
Evan Cheng0488db92007-09-25 01:57:46 +00002288let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002289let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng64d80e32007-07-19 01:14:50 +00002290def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002291 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002292 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002293 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002294def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002295 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002296 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002297 (implicit EFLAGS)]>,
2298 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002299def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002300 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002301 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002302 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002303}
Evan Cheng734503b2006-09-11 02:19:56 +00002304
Evan Cheng64d80e32007-07-19 01:14:50 +00002305def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002306 "test{b}\t{$src2, $src1|$src1, $src2}",
2307 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2308 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002309def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002310 "test{w}\t{$src2, $src1|$src1, $src2}",
2311 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2312 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002313def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002314 "test{l}\t{$src2, $src1|$src1, $src2}",
2315 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2316 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002317
Evan Cheng069287d2006-05-16 07:21:53 +00002318def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002319 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002320 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002321 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002322 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002323def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002324 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002325 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002326 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002327 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002328def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002329 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002330 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002331 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002332 (implicit EFLAGS)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002333
Evan Chenge5f62042007-09-29 00:00:36 +00002334def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002335 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002336 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002337 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2338 (implicit EFLAGS)]>;
2339def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002340 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002341 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002342 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2343 (implicit EFLAGS)]>, OpSize;
2344def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002345 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002346 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002347 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng0488db92007-09-25 01:57:46 +00002348 (implicit EFLAGS)]>;
2349} // Defs = [EFLAGS]
2350
2351
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002352// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00002353let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002354def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00002355let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002356def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002357
Evan Cheng0488db92007-09-25 01:57:46 +00002358let Uses = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002359def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002360 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002361 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002362 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002363 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002364def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002365 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002366 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002367 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002368 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00002369
Chris Lattner3a173df2004-10-03 20:35:00 +00002370def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002371 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002372 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002373 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002374 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002375def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002376 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002377 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002378 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002379 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00002380
Evan Chengd5781fc2005-12-21 20:21:51 +00002381def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002382 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002383 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002384 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002385 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002386def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002387 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002388 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002389 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002390 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00002391
Evan Chengd5781fc2005-12-21 20:21:51 +00002392def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002393 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002394 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002395 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002396 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002397def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002398 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002399 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002400 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002401 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002402
Evan Chengd5781fc2005-12-21 20:21:51 +00002403def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002404 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002405 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002406 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002407 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002408def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002409 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002410 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002411 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002412 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002413
Evan Chengd5781fc2005-12-21 20:21:51 +00002414def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002415 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002416 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002417 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002418 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002419def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002420 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002421 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002422 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002423 TB; // [mem8] = > signed
2424
2425def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002426 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002427 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002428 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002429 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002430def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002431 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002432 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002433 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002434 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002435
Evan Chengd5781fc2005-12-21 20:21:51 +00002436def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002437 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002438 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002439 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002440 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002441def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002442 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002443 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002444 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002445 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002446
Chris Lattner3a173df2004-10-03 20:35:00 +00002447def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002448 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002449 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002450 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002451 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002452def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002453 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002454 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002455 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002456 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002457
Chris Lattner3a173df2004-10-03 20:35:00 +00002458def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002459 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002460 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002461 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002462 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002463def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002464 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002465 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002466 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002467 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002468
Chris Lattner3a173df2004-10-03 20:35:00 +00002469def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002470 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002471 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002472 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002473 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002474def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002475 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002476 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002477 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002478 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002479def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002480 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002481 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002482 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002483 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002484def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002485 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002486 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002487 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002488 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00002489
Chris Lattner3a173df2004-10-03 20:35:00 +00002490def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002491 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002492 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002493 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002494 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002495def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002496 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002497 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002498 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002499 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002500def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002501 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002502 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002503 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002504 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002505def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002506 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002507 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002508 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002509 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00002510
2511def SETOr : I<0x90, MRM0r,
2512 (outs GR8 :$dst), (ins),
2513 "seto\t$dst",
2514 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2515 TB; // GR8 = overflow
2516def SETOm : I<0x90, MRM0m,
2517 (outs), (ins i8mem:$dst),
2518 "seto\t$dst",
2519 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2520 TB; // [mem8] = overflow
2521def SETNOr : I<0x91, MRM0r,
2522 (outs GR8 :$dst), (ins),
2523 "setno\t$dst",
2524 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2525 TB; // GR8 = not overflow
2526def SETNOm : I<0x91, MRM0m,
2527 (outs), (ins i8mem:$dst),
2528 "setno\t$dst",
2529 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2530 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00002531} // Uses = [EFLAGS]
2532
Chris Lattner1cca5e32003-08-03 21:54:21 +00002533
2534// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00002535let Defs = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002536def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002537 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002538 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002539 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002540def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002541 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002542 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002543 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002544def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002545 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002546 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002547 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002548def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002549 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002550 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002551 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2552 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002553def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002554 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002555 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002556 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2557 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002558def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002559 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002560 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002561 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2562 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002563def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002564 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002565 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002566 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2567 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002568def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002569 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002570 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002571 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2572 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002573def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002574 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002575 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002576 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2577 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002578def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002579 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002580 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002581 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002582def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002583 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002584 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002585 [(X86cmp GR16:$src1, imm:$src2),
2586 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002587def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002588 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002589 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002590 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002591def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002592 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002593 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002594 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2595 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002596def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002597 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002598 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002599 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2600 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002601def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002602 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002603 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002604 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2605 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002606def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002607 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002608 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002609 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2610 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002611def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002612 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002613 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002614 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2615 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002616def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002617 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002618 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002619 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2620 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002621def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002622 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002623 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002624 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00002625 (implicit EFLAGS)]>;
2626} // Defs = [EFLAGS]
2627
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002628// Bit tests.
2629// TODO: BT with immediate operands
2630// TODO: BTC, BTR, and BTS
2631let Defs = [EFLAGS] in {
2632def BT16rr : I<0xA3, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
2633 "bt{w}\t{$src2, $src1|$src1, $src2}",
2634 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00002635 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002636def BT32rr : I<0xA3, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
2637 "bt{l}\t{$src2, $src1|$src1, $src2}",
2638 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00002639 (implicit EFLAGS)]>, TB;
2640def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002641 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerd1e32292008-12-25 01:27:10 +00002642 [(X86bt (loadi16 addr:$src1), GR16:$src2),
Evan Chengccb69762009-01-02 05:35:45 +00002643 (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00002644def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002645 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerd1e32292008-12-25 01:27:10 +00002646 [(X86bt (loadi32 addr:$src1), GR32:$src2),
Evan Chengccb69762009-01-02 05:35:45 +00002647 (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002648} // Defs = [EFLAGS]
2649
Chris Lattner1cca5e32003-08-03 21:54:21 +00002650// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00002651// Use movsbl intead of movsbw; we don't care about the high 16 bits
2652// of the register here. This has a smaller encoding and avoids a
2653// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002654def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002655 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2656 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002657def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002658 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2659 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002660def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002661 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002662 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002663def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002664 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002665 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002666def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002667 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002668 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002669def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002670 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002671 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002672
Dan Gohman11ba3b12008-07-30 18:09:17 +00002673// Use movzbl intead of movzbw; we don't care about the high 16 bits
2674// of the register here. This has a smaller encoding and avoids a
2675// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002676def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002677 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2678 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002679def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002680 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2681 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002682def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002683 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002684 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002685def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002686 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002687 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002688def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002689 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002690 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002691def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002692 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002693 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00002694
Chris Lattnerba7e7562008-01-10 07:59:24 +00002695let neverHasSideEffects = 1 in {
2696 let Defs = [AX], Uses = [AL] in
2697 def CBW : I<0x98, RawFrm, (outs), (ins),
2698 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2699 let Defs = [EAX], Uses = [AX] in
2700 def CWDE : I<0x98, RawFrm, (outs), (ins),
2701 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00002702
Chris Lattnerba7e7562008-01-10 07:59:24 +00002703 let Defs = [AX,DX], Uses = [AX] in
2704 def CWD : I<0x99, RawFrm, (outs), (ins),
2705 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2706 let Defs = [EAX,EDX], Uses = [EAX] in
2707 def CDQ : I<0x99, RawFrm, (outs), (ins),
2708 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2709}
Evan Cheng747a90d2006-02-21 02:24:38 +00002710
Evan Cheng747a90d2006-02-21 02:24:38 +00002711//===----------------------------------------------------------------------===//
2712// Alias Instructions
2713//===----------------------------------------------------------------------===//
2714
2715// Alias instructions that map movr0 to xor.
2716// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002717let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002718def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002719 "xor{b}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002720 [(set GR8:$dst, 0)]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00002721// Use xorl instead of xorw since we don't care about the high 16 bits,
2722// it's smaller, and it avoids a partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002723def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002724 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2725 [(set GR16:$dst, 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002726def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002727 "xor{l}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002728 [(set GR32:$dst, 0)]>;
Dan Gohman1ab79892007-09-07 21:32:51 +00002729}
Evan Cheng747a90d2006-02-21 02:24:38 +00002730
Evan Cheng069287d2006-05-16 07:21:53 +00002731// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2732// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerba7e7562008-01-10 07:59:24 +00002733let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002734def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002735 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002736def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002737 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002738
Evan Cheng64d80e32007-07-19 01:14:50 +00002739def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002740 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002741def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002742 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002743} // neverHasSideEffects
2744
Dan Gohman15511cf2008-12-03 18:15:48 +00002745let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002746def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002747 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002748def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002749 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng2f394262007-08-30 05:49:43 +00002750}
Chris Lattnerba7e7562008-01-10 07:59:24 +00002751let mayStore = 1, neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002752def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002753 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002754def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002755 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002756}
Evan Cheng403be7e2006-05-08 08:01:26 +00002757
Evan Cheng510e4782006-01-09 23:10:28 +00002758//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002759// Thread Local Storage Instructions
2760//
2761
Evan Cheng071a2792007-09-11 19:55:27 +00002762let Uses = [EBX] in
Anton Korobeynikov6625eff2008-05-04 21:36:32 +00002763def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2764 "leal\t${sym:mem}(,%ebx,1), $dst",
2765 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002766
Lauro Ramos Venancio7d2cc2b2007-04-22 22:50:52 +00002767let AddedComplexity = 10 in
Anton Korobeynikov6625eff2008-05-04 21:36:32 +00002768def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002769 "movl\t%gs:($src), $dst",
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002770 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2771
2772let AddedComplexity = 15 in
Nicolas Geoffrayb74f3702008-10-25 15:22:06 +00002773def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002774 "movl\t%gs:${src:mem}, $dst",
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002775 [(set GR32:$dst,
Nicolas Geoffrayb74f3702008-10-25 15:22:06 +00002776 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
2777 SegGS;
Lauro Ramos Venancio7d2cc2b2007-04-22 22:50:52 +00002778
Nicolas Geoffrayb74f3702008-10-25 15:22:06 +00002779def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002780 "movl\t%gs:0, $dst",
Nicolas Geoffrayb74f3702008-10-25 15:22:06 +00002781 [(set GR32:$dst, X86TLStp)]>, SegGS;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002782
2783//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00002784// DWARF Pseudo Instructions
2785//
2786
Evan Cheng64d80e32007-07-19 01:14:50 +00002787def DWARF_LOC : I<0, Pseudo, (outs),
2788 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman6b5766e2007-09-24 19:25:06 +00002789 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Evan Cheng3c992d22006-03-07 02:02:57 +00002790 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2791 (i32 imm:$file))]>;
2792
Evan Cheng3c992d22006-03-07 02:02:57 +00002793//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00002794// EH Pseudo Instructions
2795//
2796let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Chengffbacca2007-07-21 00:34:19 +00002797 hasCtrlDep = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002798def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002799 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00002800 [(X86ehret GR32:$addr)]>;
2801
2802}
2803
2804//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00002805// Atomic support
2806//
Andrew Lenharthea7da502008-03-01 13:37:02 +00002807
Evan Chengbb6939d2008-04-19 01:20:30 +00002808// Atomic swap. These are just normal xchg instructions. But since a memory
2809// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00002810let Constraints = "$val = $dst" in {
Evan Chengbb6939d2008-04-19 01:20:30 +00002811def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2812 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2813 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2814def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2815 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2816 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2817 OpSize;
2818def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2819 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2820 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2821}
2822
Evan Cheng7e032802008-04-18 20:55:36 +00002823// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002824let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002825def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002826 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002827 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002828}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002829let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovf88a6fa2008-07-22 16:22:48 +00002830def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002831 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00002832 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2833}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002834
2835let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002836def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002837 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002838 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002839}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002840let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002841def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002842 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002843 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002844}
2845
Evan Cheng7e032802008-04-18 20:55:36 +00002846// Atomic exchange and add
2847let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2848def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002849 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00002850 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00002851 TB, LOCK;
2852def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002853 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00002854 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00002855 TB, OpSize, LOCK;
2856def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002857 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00002858 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00002859 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002860}
2861
Mon P Wang28873102008-06-25 08:15:39 +00002862// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00002863let Constraints = "$val = $dst", Defs = [EFLAGS],
2864 usesCustomDAGSchedInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00002865def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002866 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002867 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002868def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002869 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002870 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002871def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002872 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002873 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00002874def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002875 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002876 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002877def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002878 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002879 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002880def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002881 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002882 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002883def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002884 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002885 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002886def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002887 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002888 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002889
2890def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002891 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002892 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002893def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002894 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002895 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002896def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002897 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002898 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002899def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002900 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002901 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002902def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002903 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002904 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002905def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002906 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002907 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002908def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002909 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002910 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002911def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002912 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002913 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002914
2915def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002916 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002917 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002918def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002919 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002920 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002921def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002922 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002923 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002924def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002925 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002926 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00002927}
2928
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002929let Constraints = "$val1 = $dst1, $val2 = $dst2",
2930 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
2931 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00002932 mayLoad = 1, mayStore = 1,
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002933 usesCustomDAGSchedInserter = 1 in {
2934def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2935 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002936 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002937def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2938 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002939 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002940def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2941 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002942 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002943def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2944 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002945 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002946def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2947 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002948 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002949def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2950 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002951 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00002952def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2953 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00002954 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002955}
2956
Andrew Lenharthab0b9492008-02-21 06:45:13 +00002957//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00002958// Non-Instruction Patterns
2959//===----------------------------------------------------------------------===//
2960
Bill Wendling056292f2008-09-16 21:48:12 +00002961// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00002962def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00002963def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00002964def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002965def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2966def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2967
Evan Cheng069287d2006-05-16 07:21:53 +00002968def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2969 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2970def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2971 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2972def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2973 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2974def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2975 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002976
Evan Chengfc8feb12006-05-19 07:30:36 +00002977def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002978 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00002979def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002980 (MOV32mi addr:$dst, texternalsym:$src)>;
2981
Evan Cheng510e4782006-01-09 23:10:28 +00002982// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002983// tailcall stuff
Evan Cheng069287d2006-05-16 07:21:53 +00002984def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002985 (TAILCALL)>;
Evan Chengfea89c12006-04-27 08:40:39 +00002986
Evan Cheng25ab6902006-09-08 06:48:29 +00002987def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002988 (TAILCALL)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002989def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002990 (TAILCALL)>;
2991
2992def : Pat<(X86tcret GR32:$dst, imm:$off),
2993 (TCRETURNri GR32:$dst, imm:$off)>;
2994
2995def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2996 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2997
2998def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2999 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Evan Chengfea89c12006-04-27 08:40:39 +00003000
Evan Cheng25ab6902006-09-08 06:48:29 +00003001def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00003002 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00003003def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00003004 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003005
3006// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00003007def : Pat<(addc GR32:$src1, GR32:$src2),
3008 (ADD32rr GR32:$src1, GR32:$src2)>;
3009def : Pat<(addc GR32:$src1, (load addr:$src2)),
3010 (ADD32rm GR32:$src1, addr:$src2)>;
3011def : Pat<(addc GR32:$src1, imm:$src2),
3012 (ADD32ri GR32:$src1, imm:$src2)>;
3013def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3014 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003015
Evan Cheng069287d2006-05-16 07:21:53 +00003016def : Pat<(subc GR32:$src1, GR32:$src2),
3017 (SUB32rr GR32:$src1, GR32:$src2)>;
3018def : Pat<(subc GR32:$src1, (load addr:$src2)),
3019 (SUB32rm GR32:$src1, addr:$src2)>;
3020def : Pat<(subc GR32:$src1, imm:$src2),
3021 (SUB32ri GR32:$src1, imm:$src2)>;
3022def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3023 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003024
Chris Lattnerffc0b262006-09-07 20:33:45 +00003025// Comparisons.
3026
3027// TEST R,R is smaller than CMP R,0
Evan Chenge5f62042007-09-29 00:00:36 +00003028def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003029 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003030def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003031 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003032def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003033 (TEST32rr GR32:$src1, GR32:$src1)>;
3034
Duncan Sandsf9c98e62008-01-23 20:39:46 +00003035// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00003036def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003037def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3038def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3039
3040// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00003041def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00003042def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3043 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00003044def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00003045def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3046 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00003047def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3048def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003049
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003050// anyext
Bill Wendling449416d2008-08-22 20:51:05 +00003051def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3052 Requires<[In32BitMode]>;
3053def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3054 Requires<[In32BitMode]>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003055def : Pat<(i32 (anyext GR16:$src)),
3056 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003057
Evan Cheng1314b002007-12-13 00:43:27 +00003058// (and (i32 load), 255) -> (zextload i8)
Evan Chengd47e0b62008-09-29 17:26:18 +00003059def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3060 (MOVZX32rm8 addr:$src)>;
3061def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3062 (MOVZX32rm16 addr:$src)>;
Evan Cheng1314b002007-12-13 00:43:27 +00003063
Evan Chengcfa260b2006-01-06 02:31:59 +00003064//===----------------------------------------------------------------------===//
3065// Some peepholes
3066//===----------------------------------------------------------------------===//
3067
Dan Gohman63f97202008-10-17 01:33:43 +00003068// Odd encoding trick: -128 fits into an 8-bit immediate field while
3069// +128 doesn't, so in this special case use a sub instead of an add.
3070def : Pat<(add GR16:$src1, 128),
3071 (SUB16ri8 GR16:$src1, -128)>;
3072def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3073 (SUB16mi8 addr:$dst, -128)>;
3074def : Pat<(add GR32:$src1, 128),
3075 (SUB32ri8 GR32:$src1, -128)>;
3076def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3077 (SUB32mi8 addr:$dst, -128)>;
3078
Dan Gohman11ba3b12008-07-30 18:09:17 +00003079// r & (2^16-1) ==> movz
3080def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003081 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00003082// r & (2^8-1) ==> movz
3083def : Pat<(and GR32:$src1, 0xff),
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003084 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3085 x86_subreg_8bit)))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003086 Requires<[In32BitMode]>;
3087// r & (2^8-1) ==> movz
3088def : Pat<(and GR16:$src1, 0xff),
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003089 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3090 x86_subreg_8bit)))>,
3091 Requires<[In32BitMode]>;
3092
3093// sext_inreg patterns
3094def : Pat<(sext_inreg GR32:$src, i16),
3095 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3096def : Pat<(sext_inreg GR32:$src, i8),
3097 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3098 x86_subreg_8bit)))>,
3099 Requires<[In32BitMode]>;
3100def : Pat<(sext_inreg GR16:$src, i8),
3101 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3102 x86_subreg_8bit)))>,
3103 Requires<[In32BitMode]>;
3104
3105// trunc patterns
3106def : Pat<(i16 (trunc GR32:$src)),
3107 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3108def : Pat<(i8 (trunc GR32:$src)),
3109 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3110 Requires<[In32BitMode]>;
3111def : Pat<(i8 (trunc GR16:$src)),
3112 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003113 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00003114
Evan Chengcfa260b2006-01-06 02:31:59 +00003115// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00003116def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3117def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3118def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003119
Evan Chengeb9f8922008-08-30 02:03:58 +00003120// (shl x (and y, 31)) ==> (shl x, y)
3121def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3122 (SHL8rCL GR8:$src1)>;
3123def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3124 (SHL16rCL GR16:$src1)>;
3125def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3126 (SHL32rCL GR32:$src1)>;
3127def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3128 (SHL8mCL addr:$dst)>;
3129def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3130 (SHL16mCL addr:$dst)>;
3131def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3132 (SHL32mCL addr:$dst)>;
3133
3134def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3135 (SHR8rCL GR8:$src1)>;
3136def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3137 (SHR16rCL GR16:$src1)>;
3138def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3139 (SHR32rCL GR32:$src1)>;
3140def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3141 (SHR8mCL addr:$dst)>;
3142def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3143 (SHR16mCL addr:$dst)>;
3144def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3145 (SHR32mCL addr:$dst)>;
3146
3147def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3148 (SAR8rCL GR8:$src1)>;
3149def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3150 (SAR16rCL GR16:$src1)>;
3151def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3152 (SAR32rCL GR32:$src1)>;
3153def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3154 (SAR8mCL addr:$dst)>;
3155def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3156 (SAR16mCL addr:$dst)>;
3157def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3158 (SAR32mCL addr:$dst)>;
3159
Evan Cheng956044c2006-01-19 23:26:24 +00003160// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003161def : Pat<(or (srl GR32:$src1, CL:$amt),
3162 (shl GR32:$src2, (sub 32, CL:$amt))),
3163 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003164
Evan Cheng21d54432006-01-20 01:13:30 +00003165def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003166 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3167 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003168
Dan Gohman74feef22008-10-17 01:23:35 +00003169def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3170 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3171 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3172
3173def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3174 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3175 addr:$dst),
3176 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3177
3178def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3179 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3180
3181def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3182 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3183 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3184
Evan Cheng956044c2006-01-19 23:26:24 +00003185// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003186def : Pat<(or (shl GR32:$src1, CL:$amt),
3187 (srl GR32:$src2, (sub 32, CL:$amt))),
3188 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003189
Evan Cheng21d54432006-01-20 01:13:30 +00003190def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003191 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3192 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003193
Dan Gohman74feef22008-10-17 01:23:35 +00003194def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3195 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3196 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3197
3198def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3199 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3200 addr:$dst),
3201 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3202
3203def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3204 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3205
3206def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3207 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3208 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3209
Evan Cheng956044c2006-01-19 23:26:24 +00003210// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003211def : Pat<(or (srl GR16:$src1, CL:$amt),
3212 (shl GR16:$src2, (sub 16, CL:$amt))),
3213 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003214
Evan Cheng21d54432006-01-20 01:13:30 +00003215def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003216 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3217 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003218
Dan Gohman74feef22008-10-17 01:23:35 +00003219def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3220 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3221 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3222
3223def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3224 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3225 addr:$dst),
3226 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3227
3228def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3229 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3230
3231def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3232 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3233 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3234
Evan Cheng956044c2006-01-19 23:26:24 +00003235// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003236def : Pat<(or (shl GR16:$src1, CL:$amt),
3237 (srl GR16:$src2, (sub 16, CL:$amt))),
3238 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003239
3240def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003241 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3242 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003243
Dan Gohman74feef22008-10-17 01:23:35 +00003244def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3245 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3246 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3247
3248def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3249 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3250 addr:$dst),
3251 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3252
3253def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3254 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3255
3256def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3257 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3258 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3259
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003260//===----------------------------------------------------------------------===//
Bill Wendlingd350e022008-12-12 21:15:41 +00003261// Overflow Patterns
3262//===----------------------------------------------------------------------===//
3263
3264// Register-Register Addition with Overflow
3265def : Pat<(parallel (X86add_ovf GR8:$src1, GR8:$src2),
3266 (implicit EFLAGS)),
3267 (ADD8rr GR8:$src1, GR8:$src2)>;
3268
3269// Register-Register Addition with Overflow
3270def : Pat<(parallel (X86add_ovf GR16:$src1, GR16:$src2),
3271 (implicit EFLAGS)),
3272 (ADD16rr GR16:$src1, GR16:$src2)>;
3273def : Pat<(parallel (X86add_ovf GR32:$src1, GR32:$src2),
3274 (implicit EFLAGS)),
3275 (ADD32rr GR32:$src1, GR32:$src2)>;
3276
3277// Register-Memory Addition with Overflow
3278def : Pat<(parallel (X86add_ovf GR8:$src1, (load addr:$src2)),
3279 (implicit EFLAGS)),
3280 (ADD8rm GR8:$src1, addr:$src2)>;
3281def : Pat<(parallel (X86add_ovf GR16:$src1, (load addr:$src2)),
3282 (implicit EFLAGS)),
3283 (ADD16rm GR16:$src1, addr:$src2)>;
3284def : Pat<(parallel (X86add_ovf GR32:$src1, (load addr:$src2)),
3285 (implicit EFLAGS)),
3286 (ADD32rm GR32:$src1, addr:$src2)>;
3287
3288// Register-Integer Addition with Overflow
3289def : Pat<(parallel (X86add_ovf GR8:$src1, imm:$src2),
3290 (implicit EFLAGS)),
3291 (ADD8ri GR8:$src1, imm:$src2)>;
3292
3293// Register-Integer Addition with Overflow
3294def : Pat<(parallel (X86add_ovf GR16:$src1, imm:$src2),
3295 (implicit EFLAGS)),
3296 (ADD16ri GR16:$src1, imm:$src2)>;
3297def : Pat<(parallel (X86add_ovf GR32:$src1, imm:$src2),
3298 (implicit EFLAGS)),
3299 (ADD32ri GR32:$src1, imm:$src2)>;
3300def : Pat<(parallel (X86add_ovf GR16:$src1, i16immSExt8:$src2),
3301 (implicit EFLAGS)),
3302 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3303def : Pat<(parallel (X86add_ovf GR32:$src1, i32immSExt8:$src2),
3304 (implicit EFLAGS)),
3305 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3306
3307// Memory-Register Addition with Overflow
3308def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR8:$src2),
3309 addr:$dst),
3310 (implicit EFLAGS)),
3311 (ADD8mr addr:$dst, GR8:$src2)>;
3312def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR16:$src2),
3313 addr:$dst),
3314 (implicit EFLAGS)),
3315 (ADD16mr addr:$dst, GR16:$src2)>;
3316def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR32:$src2),
3317 addr:$dst),
3318 (implicit EFLAGS)),
3319 (ADD32mr addr:$dst, GR32:$src2)>;
3320def : Pat<(parallel (store (X86add_ovf (loadi8 addr:$dst), imm:$src2),
3321 addr:$dst),
3322 (implicit EFLAGS)),
3323 (ADD8mi addr:$dst, imm:$src2)>;
3324def : Pat<(parallel (store (X86add_ovf (loadi16 addr:$dst), imm:$src2),
3325 addr:$dst),
3326 (implicit EFLAGS)),
3327 (ADD16mi addr:$dst, imm:$src2)>;
3328def : Pat<(parallel (store (X86add_ovf (loadi32 addr:$dst), imm:$src2),
3329 addr:$dst),
3330 (implicit EFLAGS)),
3331 (ADD32mi addr:$dst, imm:$src2)>;
3332def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i16immSExt8:$src2),
3333 addr:$dst),
3334 (implicit EFLAGS)),
3335 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3336def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i32immSExt8:$src2),
3337 addr:$dst),
3338 (implicit EFLAGS)),
3339 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3340
3341// Register-Register Subtraction with Overflow
3342def : Pat<(parallel (X86sub_ovf GR8:$src1, GR8:$src2),
3343 (implicit EFLAGS)),
3344 (SUB8rr GR8:$src1, GR8:$src2)>;
3345def : Pat<(parallel (X86sub_ovf GR16:$src1, GR16:$src2),
3346 (implicit EFLAGS)),
3347 (SUB16rr GR16:$src1, GR16:$src2)>;
3348def : Pat<(parallel (X86sub_ovf GR32:$src1, GR32:$src2),
3349 (implicit EFLAGS)),
3350 (SUB32rr GR32:$src1, GR32:$src2)>;
3351
3352// Register-Memory Subtraction with Overflow
3353def : Pat<(parallel (X86sub_ovf GR8:$src1, (load addr:$src2)),
3354 (implicit EFLAGS)),
3355 (SUB8rm GR8:$src1, addr:$src2)>;
3356def : Pat<(parallel (X86sub_ovf GR16:$src1, (load addr:$src2)),
3357 (implicit EFLAGS)),
3358 (SUB16rm GR16:$src1, addr:$src2)>;
3359def : Pat<(parallel (X86sub_ovf GR32:$src1, (load addr:$src2)),
3360 (implicit EFLAGS)),
3361 (SUB32rm GR32:$src1, addr:$src2)>;
3362
3363// Register-Integer Subtraction with Overflow
3364def : Pat<(parallel (X86sub_ovf GR8:$src1, imm:$src2),
3365 (implicit EFLAGS)),
3366 (SUB8ri GR8:$src1, imm:$src2)>;
3367def : Pat<(parallel (X86sub_ovf GR16:$src1, imm:$src2),
3368 (implicit EFLAGS)),
3369 (SUB16ri GR16:$src1, imm:$src2)>;
3370def : Pat<(parallel (X86sub_ovf GR32:$src1, imm:$src2),
3371 (implicit EFLAGS)),
3372 (SUB32ri GR32:$src1, imm:$src2)>;
3373def : Pat<(parallel (X86sub_ovf GR16:$src1, i16immSExt8:$src2),
3374 (implicit EFLAGS)),
3375 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3376def : Pat<(parallel (X86sub_ovf GR32:$src1, i32immSExt8:$src2),
3377 (implicit EFLAGS)),
3378 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3379
3380// Memory-Register Subtraction with Overflow
3381def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR8:$src2),
3382 addr:$dst),
3383 (implicit EFLAGS)),
3384 (SUB8mr addr:$dst, GR8:$src2)>;
3385def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR16:$src2),
3386 addr:$dst),
3387 (implicit EFLAGS)),
3388 (SUB16mr addr:$dst, GR16:$src2)>;
3389def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR32:$src2),
3390 addr:$dst),
3391 (implicit EFLAGS)),
3392 (SUB32mr addr:$dst, GR32:$src2)>;
3393
3394// Memory-Integer Subtraction with Overflow
3395def : Pat<(parallel (store (X86sub_ovf (loadi8 addr:$dst), imm:$src2),
3396 addr:$dst),
3397 (implicit EFLAGS)),
3398 (SUB8mi addr:$dst, imm:$src2)>;
3399def : Pat<(parallel (store (X86sub_ovf (loadi16 addr:$dst), imm:$src2),
3400 addr:$dst),
3401 (implicit EFLAGS)),
3402 (SUB16mi addr:$dst, imm:$src2)>;
3403def : Pat<(parallel (store (X86sub_ovf (loadi32 addr:$dst), imm:$src2),
3404 addr:$dst),
3405 (implicit EFLAGS)),
3406 (SUB32mi addr:$dst, imm:$src2)>;
3407def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i16immSExt8:$src2),
3408 addr:$dst),
3409 (implicit EFLAGS)),
3410 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3411def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i32immSExt8:$src2),
3412 addr:$dst),
3413 (implicit EFLAGS)),
3414 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3415
3416
3417// Register-Register Signed Integer Multiply with Overflow
3418def : Pat<(parallel (X86smul_ovf GR16:$src1, GR16:$src2),
3419 (implicit EFLAGS)),
3420 (IMUL16rr GR16:$src1, GR16:$src2)>;
3421def : Pat<(parallel (X86smul_ovf GR32:$src1, GR32:$src2),
3422 (implicit EFLAGS)),
3423 (IMUL32rr GR32:$src1, GR32:$src2)>;
3424
3425// Register-Memory Signed Integer Multiply with Overflow
3426def : Pat<(parallel (X86smul_ovf GR16:$src1, (load addr:$src2)),
3427 (implicit EFLAGS)),
3428 (IMUL16rm GR16:$src1, addr:$src2)>;
3429def : Pat<(parallel (X86smul_ovf GR32:$src1, (load addr:$src2)),
3430 (implicit EFLAGS)),
3431 (IMUL32rm GR32:$src1, addr:$src2)>;
3432
3433// Register-Integer Signed Integer Multiply with Overflow
3434def : Pat<(parallel (X86smul_ovf GR16:$src1, imm:$src2),
3435 (implicit EFLAGS)),
3436 (IMUL16rri GR16:$src1, imm:$src2)>;
3437def : Pat<(parallel (X86smul_ovf GR32:$src1, imm:$src2),
3438 (implicit EFLAGS)),
3439 (IMUL32rri GR32:$src1, imm:$src2)>;
3440def : Pat<(parallel (X86smul_ovf GR16:$src1, i16immSExt8:$src2),
3441 (implicit EFLAGS)),
3442 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
3443def : Pat<(parallel (X86smul_ovf GR32:$src1, i32immSExt8:$src2),
3444 (implicit EFLAGS)),
3445 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3446
3447// Memory-Integer Signed Integer Multiply with Overflow
3448def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
3449 (implicit EFLAGS)),
3450 (IMUL16rmi addr:$src1, imm:$src2)>;
3451def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
3452 (implicit EFLAGS)),
3453 (IMUL32rmi addr:$src1, imm:$src2)>;
3454def : Pat<(parallel (X86smul_ovf (load addr:$src1), i16immSExt8:$src2),
3455 (implicit EFLAGS)),
3456 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
3457def : Pat<(parallel (X86smul_ovf (load addr:$src1), i32immSExt8:$src2),
3458 (implicit EFLAGS)),
3459 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3460
3461//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003462// Floating Point Stack Support
3463//===----------------------------------------------------------------------===//
3464
3465include "X86InstrFPStack.td"
3466
3467//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00003468// X86-64 Support
3469//===----------------------------------------------------------------------===//
3470
Chris Lattner36fe6d22008-01-10 05:50:42 +00003471include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00003472
3473//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003474// XMM Floating point support (requires SSE / SSE2)
3475//===----------------------------------------------------------------------===//
3476
3477include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00003478
3479//===----------------------------------------------------------------------===//
3480// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3481//===----------------------------------------------------------------------===//
3482
3483include "X86InstrMMX.td"