blob: 93f9e02802215d589f31a0ff2042dafe177aa438 [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
Nate Begeman51a04372009-01-26 01:24:32 +0000311def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
312 LoadSDNode *LD = cast<LoadSDNode>(N);
313 const Value *Src = LD->getSrcValue();
314 if (!Src)
315 return false;
316 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
317 return PT->getAddressSpace() == 256;
318 return false;
319}]>;
320
Evan Cheng7a7e8372005-12-14 02:22:27 +0000321def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Evan Cheng11e15b32006-04-03 20:53:28 +0000322def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000323
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000324def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
325def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen59a58732007-08-05 18:49:15 +0000326def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000327
Evan Cheng466685d2006-10-09 20:57:25 +0000328def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
329def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
330def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000331
Evan Cheng466685d2006-10-09 20:57:25 +0000332def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
333def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
334def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
335def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
336def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
337def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000338
Evan Cheng466685d2006-10-09 20:57:25 +0000339def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
340def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
341def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
342def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
343def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
344def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000345
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000346
347// An 'and' node with a single use.
348def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000349 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000350}]>;
351
Dan Gohman74feef22008-10-17 01:23:35 +0000352// 'shld' and 'shrd' instruction patterns. Note that even though these have
353// the srl and shl in their patterns, the C++ code must still check for them,
354// because predicates are tested before children nodes are explored.
355
356def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
357 (or (srl node:$src1, node:$amt1),
358 (shl node:$src2, node:$amt2)), [{
359 assert(N->getOpcode() == ISD::OR);
360 return N->getOperand(0).getOpcode() == ISD::SRL &&
361 N->getOperand(1).getOpcode() == ISD::SHL &&
362 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
363 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
364 N->getOperand(0).getConstantOperandVal(1) ==
365 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
366}]>;
367
368def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
369 (or (shl node:$src1, node:$amt1),
370 (srl node:$src2, node:$amt2)), [{
371 assert(N->getOpcode() == ISD::OR);
372 return N->getOperand(0).getOpcode() == ISD::SHL &&
373 N->getOperand(1).getOpcode() == ISD::SRL &&
374 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
375 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
376 N->getOperand(0).getConstantOperandVal(1) ==
377 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
378}]>;
379
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000380//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000381// Instruction list...
382//
383
Chris Lattnerf18c0742006-10-12 17:42:56 +0000384// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
385// a stack adjustment and the codegen must know that they may modify the stack
386// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000387// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
388// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000389let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000390def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
391 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000392 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000393 Requires<[In32BitMode]>;
394def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
395 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000396 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000397 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000398}
Evan Cheng4a460802006-01-11 00:33:36 +0000399
400// Nop
Chris Lattnerba7e7562008-01-10 07:59:24 +0000401let neverHasSideEffects = 1 in
402 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Evan Cheng4a460802006-01-11 00:33:36 +0000403
Evan Cheng0475ab52008-01-05 00:41:47 +0000404// PIC base
Dan Gohman2662d552008-10-01 04:14:30 +0000405let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerba7e7562008-01-10 07:59:24 +0000406 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
407 "call\t$label\n\tpop{l}\t$reg", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000408
Chris Lattner1cca5e32003-08-03 21:54:21 +0000409//===----------------------------------------------------------------------===//
410// Control Flow Instructions...
411//
412
Chris Lattner1be48112005-05-13 17:56:48 +0000413// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000414let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000415 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000416 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000417 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000418 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000419 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
420 "ret\t$amt",
Evan Chenge3413162006-01-09 18:33:28 +0000421 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000422}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000423
424// All branches are RawFrm, Void, Branch, and Terminators
Evan Chengffbacca2007-07-21 00:34:19 +0000425let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000426 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
427 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000428
Evan Chengec3bc392006-09-07 19:03:48 +0000429let isBranch = 1, isBarrier = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000430 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000431
Owen Anderson20ab2902007-11-12 07:39:39 +0000432// Indirect branches
433let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000434 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000435 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000436 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000437 [(brind (loadi32 addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000438}
439
440// Conditional branches
Evan Cheng0488db92007-09-25 01:57:46 +0000441let Uses = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000442def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000443 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000444def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000445 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000446def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000447 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000448def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000449 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000450def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000451 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000452def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000453 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000454
Dan Gohmanb1576f52007-07-31 20:11:57 +0000455def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000456 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000457def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000458 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000459def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000460 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000461def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000462 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000463
Dan Gohmanb1576f52007-07-31 20:11:57 +0000464def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000465 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000466def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000467 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000468def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000469 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000470def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000471 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000472def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000473 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000474def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000475 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng0488db92007-09-25 01:57:46 +0000476} // Uses = [EFLAGS]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000477
478//===----------------------------------------------------------------------===//
479// Call Instructions...
480//
Evan Chengffbacca2007-07-21 00:34:19 +0000481let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000482 // All calls clobber the non-callee saved registers. ESP is marked as
483 // a use to prevent stack-pointer assignments that appear immediately
484 // before calls from potentially appearing dead. Uses for argument
485 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000486 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000487 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000488 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
489 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000490 Uses = [ESP] in {
Evan Chengf02ca692007-12-22 02:26:46 +0000491 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
492 "call\t${dst:call}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000493 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000494 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000495 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000496 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000497 }
498
Chris Lattner1e9448b2005-05-15 03:10:37 +0000499// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000500
Chris Lattner447ff682008-03-11 03:23:40 +0000501def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000502 "#TAILCALL",
503 []>;
504
Evan Chengffbacca2007-07-21 00:34:19 +0000505let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000506def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000507 "#TC_RETURN $dst $offset",
508 []>;
509
510let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000511def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000512 "#TC_RETURN $dst $offset",
513 []>;
514
515let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer30e62c02008-04-30 09:16:33 +0000516
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000517 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000518 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000519let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000520 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
521 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000522let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000523 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000524 "jmp\t{*}$dst # TAILCALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000525
Chris Lattner1cca5e32003-08-03 21:54:21 +0000526//===----------------------------------------------------------------------===//
527// Miscellaneous Instructions...
528//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000529let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000530def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000531 (outs), (ins), "leave", []>;
532
Chris Lattnerba7e7562008-01-10 07:59:24 +0000533let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
534let mayLoad = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000535def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000536
Chris Lattnerba7e7562008-01-10 07:59:24 +0000537let mayStore = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000538def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000539}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000540
Chris Lattnerba7e7562008-01-10 07:59:24 +0000541let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000542def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000543let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000544def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000545
Evan Cheng069287d2006-05-16 07:21:53 +0000546let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000547 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000548 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000549 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000550 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000551
Chris Lattner1cca5e32003-08-03 21:54:21 +0000552
Evan Cheng18efe262007-12-14 02:13:44 +0000553// Bit scan instructions.
554let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000555def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000556 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000557 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000558def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000559 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000560 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
561 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000562def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000563 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000564 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000565def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000566 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000567 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
568 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000569
Evan Chengfd9e4732007-12-14 18:49:43 +0000570def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000571 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000572 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000573def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000574 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000575 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
576 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000577def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000578 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000579 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000580def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000581 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000582 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
583 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000584} // Defs = [EFLAGS]
585
Chris Lattnerba7e7562008-01-10 07:59:24 +0000586let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000587def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000588 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000589 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000590let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000591def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000592 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000593 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000594 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000595
Evan Cheng071a2792007-09-11 19:55:27 +0000596let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000597def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000598 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000599def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000600 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000601def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000602 [(X86rep_movs i32)]>, REP;
603}
Chris Lattner915e5e52004-02-12 17:53:22 +0000604
Evan Cheng071a2792007-09-11 19:55:27 +0000605let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000606def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000607 [(X86rep_stos i8)]>, REP;
608let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000609def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000610 [(X86rep_stos i16)]>, REP, OpSize;
611let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000612def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000613 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000614
Evan Cheng071a2792007-09-11 19:55:27 +0000615let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000616def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000617 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000618
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000619let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000620def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000621}
622
Chris Lattner1cca5e32003-08-03 21:54:21 +0000623//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000624// Input/Output Instructions...
625//
Evan Cheng071a2792007-09-11 19:55:27 +0000626let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000627def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000628 "in{b}\t{%dx, %al|%AL, %DX}", []>;
629let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000630def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000631 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
632let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000633def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000634 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000635
Evan Cheng071a2792007-09-11 19:55:27 +0000636let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000637def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000638 "in{b}\t{$port, %al|%AL, $port}", []>;
639let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000640def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000641 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
642let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000643def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000644 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000645
Evan Cheng071a2792007-09-11 19:55:27 +0000646let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000647def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000648 "out{b}\t{%al, %dx|%DX, %AL}", []>;
649let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000650def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000651 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
652let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000653def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000654 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000655
Evan Cheng071a2792007-09-11 19:55:27 +0000656let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000657def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000658 "out{b}\t{%al, $port|$port, %AL}", []>;
659let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000660def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000661 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
662let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000663def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000664 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000665
666//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000667// Move Instructions...
668//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000669let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000670def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000671 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000672def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000673 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000674def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000675 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000676}
Evan Cheng359e9372008-06-18 08:13:07 +0000677let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000678def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000679 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000680 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000681def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000682 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000683 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000684def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000685 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000686 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000687}
Evan Cheng64d80e32007-07-19 01:14:50 +0000688def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000689 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000690 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000691def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000692 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000693 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000694def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000695 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000696 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000697
Dan Gohman15511cf2008-12-03 18:15:48 +0000698let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000699def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000700 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000701 [(set GR8:$dst, (load addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000702def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000703 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000704 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000705def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000706 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000707 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +0000708}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000709
Evan Cheng64d80e32007-07-19 01:14:50 +0000710def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000711 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000712 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000713def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000714 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000715 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000716def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000717 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000718 [(store GR32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000719
Chris Lattner1cca5e32003-08-03 21:54:21 +0000720//===----------------------------------------------------------------------===//
721// Fixed-Register Multiplication and Division Instructions...
722//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000723
Chris Lattnerc8f45872003-08-04 04:59:56 +0000724// Extra precision multiplication
Evan Cheng24f2ea32007-09-14 21:48:26 +0000725let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000726def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000727 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
728 // This probably ought to be moved to a def : Pat<> if the
729 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000730 [(set AL, (mul AL, GR8:$src)),
731 (implicit EFLAGS)]>; // AL,AH = AL*GR8
732
Chris Lattnera731c9f2008-01-11 07:18:17 +0000733let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000734def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
735 "mul{w}\t$src",
736 []>, OpSize; // AX,DX = AX*GR16
737
Chris Lattnera731c9f2008-01-11 07:18:17 +0000738let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000739def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
740 "mul{l}\t$src",
741 []>; // EAX,EDX = EAX*GR32
742
Evan Cheng24f2ea32007-09-14 21:48:26 +0000743let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000744def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000745 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000746 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
747 // This probably ought to be moved to a def : Pat<> if the
748 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000749 [(set AL, (mul AL, (loadi8 addr:$src))),
750 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
751
Chris Lattnerba7e7562008-01-10 07:59:24 +0000752let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000753let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000754def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000755 "mul{w}\t$src",
756 []>, OpSize; // AX,DX = AX*[mem16]
757
Evan Cheng24f2ea32007-09-14 21:48:26 +0000758let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000759def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000760 "mul{l}\t$src",
761 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000762}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000763
Chris Lattnerba7e7562008-01-10 07:59:24 +0000764let neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000765let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +0000766def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
767 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +0000768let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000769def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +0000770 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +0000771let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +0000772def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
773 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +0000774let mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000775let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000776def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000777 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +0000778let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000779def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000780 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
781let Defs = [EAX,EDX], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000782def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000783 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000784}
Dan Gohmanc99da132008-11-18 21:29:14 +0000785} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +0000786
Chris Lattnerc8f45872003-08-04 04:59:56 +0000787// unsigned division/remainder
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000788let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000789def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = 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 DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = 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 DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000796 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000797let mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000798let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000799def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000800 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000801let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000802def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000803 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000804let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000805def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000806 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000807}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000808
Chris Lattnerfc752712004-08-01 09:52:59 +0000809// Signed division/remainder.
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000810let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000811def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = 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 IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = 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 IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000818 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000819let mayLoad = 1, mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000820let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000821def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000822 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000823let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000824def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000825 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000826let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000827def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000828 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000829}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000830
Chris Lattner1cca5e32003-08-03 21:54:21 +0000831//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000832// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000833//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000834let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000835
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000836// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +0000837let Uses = [EFLAGS] in {
Evan Cheng7ad42d92007-10-05 23:13:21 +0000838let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000839def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000840 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000841 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000842 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000843 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000844 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000845def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000846 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000847 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000848 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000849 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000850 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000851def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000852 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000853 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000854 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000855 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000856 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000857def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000858 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000859 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000860 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000861 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000862 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000863def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000864 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000865 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000866 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000867 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000868 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000869def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000870 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000871 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000872 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000873 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000874 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000875def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000876 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000877 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000878 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000879 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000880 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000881def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000882 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000883 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000884 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000885 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000886 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000887def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000888 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000889 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000890 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000891 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000892 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000893def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000894 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000895 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000896 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000897 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000898 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000899def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000900 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000901 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000902 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000903 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000904 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000905def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000906 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000907 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000908 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000909 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000910 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000911def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000912 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000913 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000914 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000915 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000916 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000917def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000918 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000919 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000920 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000921 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000922 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000923def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000924 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000925 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000926 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000927 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000928 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000929def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000930 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000931 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000932 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000933 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000934 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000935def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000936 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000937 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000938 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000939 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000940 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000941def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000942 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000943 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000944 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000945 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000946 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000947def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000948 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000949 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000950 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000951 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000952 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000953def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000954 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000955 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000956 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000957 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000958 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000959def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000960 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000961 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000962 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000963 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000964 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000965def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000966 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000967 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000968 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000969 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000970 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000971def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000972 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000973 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000974 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000975 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000976 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000977def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000978 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000979 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000980 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000981 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000982 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000983def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000984 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000985 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000986 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000987 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000988 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000989def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000990 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000991 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000992 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000993 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000994 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000995def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000996 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000997 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000998 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000999 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001000 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001001def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001002 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001003 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001004 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001005 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001006 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001007def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1008 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1009 "cmovo\t{$src2, $dst|$dst, $src2}",
1010 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1011 X86_COND_O, EFLAGS))]>,
1012 TB, OpSize;
1013def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1014 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1015 "cmovo\t{$src2, $dst|$dst, $src2}",
1016 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1017 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001018 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001019def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1020 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1021 "cmovno\t{$src2, $dst|$dst, $src2}",
1022 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1023 X86_COND_NO, EFLAGS))]>,
1024 TB, OpSize;
1025def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1026 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1027 "cmovno\t{$src2, $dst|$dst, $src2}",
1028 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1029 X86_COND_NO, EFLAGS))]>,
1030 TB;
1031} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001032
1033def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1034 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1035 "cmovb\t{$src2, $dst|$dst, $src2}",
1036 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1037 X86_COND_B, EFLAGS))]>,
1038 TB, OpSize;
1039def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1040 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1041 "cmovb\t{$src2, $dst|$dst, $src2}",
1042 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1043 X86_COND_B, EFLAGS))]>,
1044 TB;
1045def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1046 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1047 "cmovae\t{$src2, $dst|$dst, $src2}",
1048 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1049 X86_COND_AE, EFLAGS))]>,
1050 TB, OpSize;
1051def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1052 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1053 "cmovae\t{$src2, $dst|$dst, $src2}",
1054 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1055 X86_COND_AE, EFLAGS))]>,
1056 TB;
1057def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1058 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1059 "cmove\t{$src2, $dst|$dst, $src2}",
1060 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1061 X86_COND_E, EFLAGS))]>,
1062 TB, OpSize;
1063def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1064 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1065 "cmove\t{$src2, $dst|$dst, $src2}",
1066 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1067 X86_COND_E, EFLAGS))]>,
1068 TB;
1069def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1070 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1071 "cmovne\t{$src2, $dst|$dst, $src2}",
1072 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1073 X86_COND_NE, EFLAGS))]>,
1074 TB, OpSize;
1075def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1076 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1077 "cmovne\t{$src2, $dst|$dst, $src2}",
1078 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1079 X86_COND_NE, EFLAGS))]>,
1080 TB;
1081def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1082 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1083 "cmovbe\t{$src2, $dst|$dst, $src2}",
1084 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1085 X86_COND_BE, EFLAGS))]>,
1086 TB, OpSize;
1087def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1088 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1089 "cmovbe\t{$src2, $dst|$dst, $src2}",
1090 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1091 X86_COND_BE, EFLAGS))]>,
1092 TB;
1093def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1094 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1095 "cmova\t{$src2, $dst|$dst, $src2}",
1096 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1097 X86_COND_A, EFLAGS))]>,
1098 TB, OpSize;
1099def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1100 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1101 "cmova\t{$src2, $dst|$dst, $src2}",
1102 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1103 X86_COND_A, EFLAGS))]>,
1104 TB;
1105def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1106 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1107 "cmovl\t{$src2, $dst|$dst, $src2}",
1108 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1109 X86_COND_L, EFLAGS))]>,
1110 TB, OpSize;
1111def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1112 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1113 "cmovl\t{$src2, $dst|$dst, $src2}",
1114 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1115 X86_COND_L, EFLAGS))]>,
1116 TB;
1117def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1118 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1119 "cmovge\t{$src2, $dst|$dst, $src2}",
1120 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1121 X86_COND_GE, EFLAGS))]>,
1122 TB, OpSize;
1123def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1124 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1125 "cmovge\t{$src2, $dst|$dst, $src2}",
1126 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1127 X86_COND_GE, EFLAGS))]>,
1128 TB;
1129def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1130 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1131 "cmovle\t{$src2, $dst|$dst, $src2}",
1132 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1133 X86_COND_LE, EFLAGS))]>,
1134 TB, OpSize;
1135def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1136 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1137 "cmovle\t{$src2, $dst|$dst, $src2}",
1138 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1139 X86_COND_LE, EFLAGS))]>,
1140 TB;
1141def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1142 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1143 "cmovg\t{$src2, $dst|$dst, $src2}",
1144 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1145 X86_COND_G, EFLAGS))]>,
1146 TB, OpSize;
1147def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1148 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1149 "cmovg\t{$src2, $dst|$dst, $src2}",
1150 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1151 X86_COND_G, EFLAGS))]>,
1152 TB;
1153def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1154 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1155 "cmovs\t{$src2, $dst|$dst, $src2}",
1156 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1157 X86_COND_S, EFLAGS))]>,
1158 TB, OpSize;
1159def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1160 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1161 "cmovs\t{$src2, $dst|$dst, $src2}",
1162 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1163 X86_COND_S, EFLAGS))]>,
1164 TB;
1165def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1166 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1167 "cmovns\t{$src2, $dst|$dst, $src2}",
1168 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1169 X86_COND_NS, EFLAGS))]>,
1170 TB, OpSize;
1171def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1172 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1173 "cmovns\t{$src2, $dst|$dst, $src2}",
1174 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1175 X86_COND_NS, EFLAGS))]>,
1176 TB;
1177def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1178 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1179 "cmovp\t{$src2, $dst|$dst, $src2}",
1180 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1181 X86_COND_P, EFLAGS))]>,
1182 TB, OpSize;
1183def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1184 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1185 "cmovp\t{$src2, $dst|$dst, $src2}",
1186 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1187 X86_COND_P, EFLAGS))]>,
1188 TB;
1189def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1190 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1191 "cmovnp\t{$src2, $dst|$dst, $src2}",
1192 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1193 X86_COND_NP, EFLAGS))]>,
1194 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001195def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1196 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1197 "cmovnp\t{$src2, $dst|$dst, $src2}",
1198 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1199 X86_COND_NP, EFLAGS))]>,
1200 TB;
1201def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1202 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1203 "cmovo\t{$src2, $dst|$dst, $src2}",
1204 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1205 X86_COND_O, EFLAGS))]>,
1206 TB, OpSize;
1207def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1208 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1209 "cmovo\t{$src2, $dst|$dst, $src2}",
1210 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1211 X86_COND_O, EFLAGS))]>,
1212 TB;
1213def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1214 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1215 "cmovno\t{$src2, $dst|$dst, $src2}",
1216 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1217 X86_COND_NO, EFLAGS))]>,
1218 TB, OpSize;
1219def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1220 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1221 "cmovno\t{$src2, $dst|$dst, $src2}",
1222 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1223 X86_COND_NO, EFLAGS))]>,
1224 TB;
Evan Cheng0488db92007-09-25 01:57:46 +00001225} // Uses = [EFLAGS]
1226
1227
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001228// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001229let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001230let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001231def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001232 [(set GR8:$dst, (ineg GR8:$src)),
1233 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001234def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001235 [(set GR16:$dst, (ineg GR16:$src)),
1236 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001237def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001238 [(set GR32:$dst, (ineg GR32:$src)),
1239 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001240let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001241 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001242 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1243 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001244 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001245 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1246 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001247 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001248 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1249 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001250}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001251} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001252
Evan Chengaaf414c2009-01-21 02:09:05 +00001253// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1254let AddedComplexity = 15 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001255def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001256 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001257def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001258 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001259def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001260 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001261}
Chris Lattner57a02302004-08-11 04:31:00 +00001262let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001263 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001264 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001265 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001266 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001267 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001268 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001269}
Evan Cheng1693e482006-07-19 00:27:29 +00001270} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001271
Evan Chengb51a0592005-12-10 00:48:20 +00001272// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001273let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001274let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001275def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001276 [(set GR8:$dst, (add GR8:$src, 1)),
1277 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001278let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001279def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001280 [(set GR16:$dst, (add GR16:$src, 1)),
1281 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001282 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001283def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001284 [(set GR32:$dst, (add GR32:$src, 1)),
1285 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001286}
Evan Cheng1693e482006-07-19 00:27:29 +00001287let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001288 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001289 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1290 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001291 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001292 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1293 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001294 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001295 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001296 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1297 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001298 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001299}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001300
Evan Cheng1693e482006-07-19 00:27:29 +00001301let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001302def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001303 [(set GR8:$dst, (add GR8:$src, -1)),
1304 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001305let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001306def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001307 [(set GR16:$dst, (add GR16:$src, -1)),
1308 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001309 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001310def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001311 [(set GR32:$dst, (add GR32:$src, -1)),
1312 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001313}
Chris Lattner57a02302004-08-11 04:31:00 +00001314
Evan Cheng1693e482006-07-19 00:27:29 +00001315let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001316 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001317 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1318 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001319 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001320 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1321 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001322 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001323 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001324 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1325 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001326 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001327}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001328} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001329
1330// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001331let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001332let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001333def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001334 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001335 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001336 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1337 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001338def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001339 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001340 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001341 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1342 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001343def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001344 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001345 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001346 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1347 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001348}
Chris Lattner57a02302004-08-11 04:31:00 +00001349
Chris Lattner3a173df2004-10-03 20:35:00 +00001350def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001351 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001352 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001353 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))),
1354 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001355def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001356 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001357 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001358 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))),
1359 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001360def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001361 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001362 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001363 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2))),
1364 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001365
Chris Lattner3a173df2004-10-03 20:35:00 +00001366def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001367 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001368 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001369 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1370 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001371def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001372 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001373 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001374 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1375 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001376def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001377 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001378 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001379 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1380 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001381def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001382 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001383 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001384 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1385 (implicit EFLAGS)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001386 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001387def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001388 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001389 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001390 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1391 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001392
1393let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001394 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001395 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001396 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001397 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1398 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001399 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001400 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001401 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001402 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1403 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001404 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001405 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001406 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001407 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001408 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1409 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001410 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001411 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001412 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001413 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1414 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001415 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001416 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001417 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001418 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1419 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001420 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001421 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001422 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001423 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001424 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1425 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001426 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001427 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001428 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001429 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1430 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001431 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001432 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001433 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001434 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001435 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1436 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001437}
1438
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001439
Chris Lattnercc65bee2005-01-02 02:35:46 +00001440let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001441def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001442 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001443 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1444 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001445def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001446 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001447 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1448 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001449def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001450 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001451 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1452 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001453}
Evan Cheng64d80e32007-07-19 01:14:50 +00001454def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001455 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001456 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1457 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001458def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001459 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001460 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1461 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001462def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001463 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001464 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1465 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001466
Evan Cheng64d80e32007-07-19 01:14:50 +00001467def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001468 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001469 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1470 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001471def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001472 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001473 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1474 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001475def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001476 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001477 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1478 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001479
Evan Cheng64d80e32007-07-19 01:14:50 +00001480def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001481 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001482 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1483 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001484def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001485 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001486 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1487 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001488let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001489 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001490 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001491 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1492 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001493 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001494 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001495 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1496 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001497 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001498 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001499 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1500 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001501 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001502 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001503 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1504 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001505 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001506 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001507 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1508 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001509 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001510 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001511 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001512 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1513 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001514 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001515 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001516 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1517 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001518 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001519 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001520 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001521 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1522 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001523} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001524
1525
Evan Cheng359e9372008-06-18 08:13:07 +00001526let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001527 def XOR8rr : I<0x30, MRMDestReg,
1528 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1529 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001530 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1531 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001532 def XOR16rr : I<0x31, MRMDestReg,
1533 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1534 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001535 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1536 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001537 def XOR32rr : I<0x31, MRMDestReg,
1538 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1539 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001540 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1541 (implicit EFLAGS)]>;
Evan Cheng359e9372008-06-18 08:13:07 +00001542} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00001543
Chris Lattner3a173df2004-10-03 20:35:00 +00001544def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001545 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001546 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001547 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1548 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001549def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001550 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001551 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001552 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1553 (implicit EFLAGS)]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001554 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001555def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001556 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001557 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001558 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1559 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001560
Bill Wendling75cf88f2008-05-29 03:46:36 +00001561def XOR8ri : Ii8<0x80, MRM6r,
1562 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1563 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001564 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1565 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001566def XOR16ri : Ii16<0x81, MRM6r,
1567 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1568 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001569 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1570 (implicit EFLAGS)]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001571def XOR32ri : Ii32<0x81, MRM6r,
1572 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1573 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001574 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1575 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001576def XOR16ri8 : Ii8<0x83, MRM6r,
1577 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1578 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001579 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1580 (implicit EFLAGS)]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00001581 OpSize;
1582def XOR32ri8 : Ii8<0x83, MRM6r,
1583 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1584 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001585 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1586 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001587
Chris Lattner57a02302004-08-11 04:31:00 +00001588let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001589 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001590 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001591 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001592 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1593 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001594 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001595 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001596 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001597 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1598 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001599 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001600 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001601 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001602 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001603 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1604 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001605 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001606 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001607 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001608 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1609 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001610 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001611 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001612 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001613 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1614 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001615 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001616 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001617 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001618 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001619 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1620 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001621 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001622 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001623 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001624 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1625 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001626 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001627 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001628 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001629 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001630 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1631 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001632} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00001633} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001634
1635// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00001636let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00001637let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001638def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001639 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001640 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001641def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001642 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001643 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001644def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001645 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001646 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001647} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00001648
Evan Cheng64d80e32007-07-19 01:14:50 +00001649def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001650 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001651 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001652let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001653def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001654 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001655 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001656def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001657 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001658 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf9b3f372008-01-11 18:00:50 +00001659// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1660// cheaper.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001661} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00001662
Chris Lattnerf29ed092004-08-11 05:07:25 +00001663let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001664 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001665 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001666 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001667 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001668 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001669 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001670 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001671 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001672 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001673 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1674 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001675 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001676 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001677 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001678 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001679 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001680 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1681 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001682 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001683 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001684 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001685
1686 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001687 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001688 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001689 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001690 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001691 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001692 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1693 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001694 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001695 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001696 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001697}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001698
Evan Cheng071a2792007-09-11 19:55:27 +00001699let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001700def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001701 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001702 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001703def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001704 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001705 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001706def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001707 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001708 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1709}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001710
Evan Cheng64d80e32007-07-19 01:14:50 +00001711def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001712 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001713 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001714def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001715 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001716 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001717def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001718 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001719 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001720
Evan Cheng09c54572006-06-29 00:36:51 +00001721// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001722def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001723 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001724 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001725def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001726 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001727 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001728def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001729 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001730 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1731
Chris Lattner57a02302004-08-11 04:31:00 +00001732let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001733 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001734 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001735 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001736 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001737 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001738 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001739 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001740 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001741 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001742 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001743 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1744 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001745 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001746 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001747 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001748 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001749 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001750 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1751 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001752 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001753 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001754 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001755
1756 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001757 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001758 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001759 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001760 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001761 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001762 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001763 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001764 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001765 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001766}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001767
Evan Cheng071a2792007-09-11 19:55:27 +00001768let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001769def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001770 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001771 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001772def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001773 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001774 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001775def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001776 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001777 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1778}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001779
Evan Cheng64d80e32007-07-19 01:14:50 +00001780def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001781 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001782 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001783def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001784 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001785 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001786 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001787def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001788 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001789 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001790
1791// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001792def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001793 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001794 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001795def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001796 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001797 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001798def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001799 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001800 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1801
Chris Lattnerf29ed092004-08-11 05:07:25 +00001802let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001803 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001804 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001805 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001806 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001807 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001808 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001809 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001810 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001811 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001812 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1813 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001814 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001815 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001816 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001817 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001818 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001819 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1820 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001821 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001822 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001823 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001824
1825 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001826 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001827 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001828 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001829 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001830 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001831 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1832 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001833 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001834 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001835 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001836}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001837
Chris Lattner40ff6332005-01-19 07:50:03 +00001838// Rotate instructions
1839// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00001840let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001841def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001842 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001843 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001844def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001845 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001846 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001847def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001848 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001849 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1850}
Chris Lattner40ff6332005-01-19 07:50:03 +00001851
Evan Cheng64d80e32007-07-19 01:14:50 +00001852def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001853 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001854 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001855def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001856 "rol{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001857 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001858def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001859 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001860 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001861
Evan Cheng09c54572006-06-29 00:36:51 +00001862// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001863def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001864 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001865 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001866def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001867 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001868 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001869def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001870 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001871 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1872
Chris Lattner40ff6332005-01-19 07:50:03 +00001873let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001874 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001875 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001876 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001877 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001878 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001879 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001880 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001881 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001882 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001883 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1884 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001885 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001886 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001887 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001888 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001889 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001890 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1891 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001892 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001893 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001894 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001895
1896 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001897 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001898 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001899 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001900 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001901 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001902 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1903 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001904 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001905 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001906 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001907}
1908
Evan Cheng071a2792007-09-11 19:55:27 +00001909let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001910def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001911 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001912 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001913def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001914 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001915 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001916def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001917 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001918 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1919}
Chris Lattner40ff6332005-01-19 07:50:03 +00001920
Evan Cheng64d80e32007-07-19 01:14:50 +00001921def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001922 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001923 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001924def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001925 "ror{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001926 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001927def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001928 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001929 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001930
1931// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001932def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001933 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001934 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001935def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001936 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001937 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001938def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001939 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001940 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1941
Chris Lattner40ff6332005-01-19 07:50:03 +00001942let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001943 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001944 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001945 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001946 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001947 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001948 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001949 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001950 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001951 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001952 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1953 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001954 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001955 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001956 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001957 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001958 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001959 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1960 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001961 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001962 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001963 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001964
1965 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001966 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001967 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001968 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001969 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001970 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001971 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1972 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001973 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001974 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001975 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001976}
1977
1978
1979
1980// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00001981let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001982def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001983 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001984 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001985def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001986 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001987 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001988def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001989 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001990 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001991 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001992def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001993 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001994 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001995 TB, OpSize;
1996}
Chris Lattner41e431b2005-01-19 07:11:01 +00001997
1998let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001999def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002000 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002001 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002002 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002003 (i8 imm:$src3)))]>,
2004 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002005def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002006 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002007 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002008 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002009 (i8 imm:$src3)))]>,
2010 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002011def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002012 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002013 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002014 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002015 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002016 TB, OpSize;
2017def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002018 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002019 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002020 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002021 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002022 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002023}
Chris Lattner0e967d42004-08-01 08:13:11 +00002024
Chris Lattner57a02302004-08-11 04:31:00 +00002025let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002026 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002027 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002028 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002029 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002030 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002031 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002032 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002033 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002034 addr:$dst)]>, TB;
2035 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002036 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002037 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002038 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002039 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002040 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002041 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002042 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002043 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002044 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002045 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002046 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002047 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002048
Evan Cheng071a2792007-09-11 19:55:27 +00002049 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002050 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002051 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002052 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002053 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002054 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002055 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002056 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002057 addr:$dst)]>, TB, OpSize;
2058 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002059 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002060 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002061 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002062 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002063 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002064 TB, OpSize;
2065 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002066 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002067 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002068 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002069 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002070 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002071}
Evan Cheng24f2ea32007-09-14 21:48:26 +00002072} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002073
2074
Chris Lattnercc65bee2005-01-02 02:35:46 +00002075// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002076let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002077let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002078// Register-Register Addition
2079def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2080 (ins GR8 :$src1, GR8 :$src2),
2081 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002082 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002083 (implicit EFLAGS)]>;
2084
Chris Lattnercc65bee2005-01-02 02:35:46 +00002085let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002086// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002087def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2088 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002089 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002090 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2091 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002092def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2093 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002094 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002095 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2096 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002097} // end isConvertibleToThreeAddress
2098} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002099
2100// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002101def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2102 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002103 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002104 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2105 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002106def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2107 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002108 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002109 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2110 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002111def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2112 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002113 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002114 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2115 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002116
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002117// Register-Integer Addition
2118def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2119 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002120 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2121 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002122
Chris Lattnercc65bee2005-01-02 02:35:46 +00002123let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002124// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002125def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2126 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002127 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002128 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2129 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002130def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2131 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002132 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002133 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2134 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002135def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2136 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002137 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002138 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2139 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002140def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2141 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002142 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002143 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2144 (implicit EFLAGS)]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002145}
Chris Lattner57a02302004-08-11 04:31:00 +00002146
2147let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002148 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002149 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002150 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002151 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2152 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002153 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002154 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002155 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2156 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002157 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002158 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002159 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2160 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002161 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002162 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002163 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2164 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002165 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002166 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002167 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2168 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002169 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002170 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002171 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2172 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002173 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002174 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002175 [(store (add (load addr:$dst), i16immSExt8:$src2),
2176 addr:$dst),
2177 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002178 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002179 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002180 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002181 addr:$dst),
2182 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002183}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002184
Evan Cheng3154cb62007-10-05 17:59:57 +00002185let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002186let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00002187def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002188 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002189 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002190}
Evan Cheng64d80e32007-07-19 01:14:50 +00002191def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002192 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002193 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002194def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002195 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002196 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002197def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002198 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002199 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002200
2201let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002202 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002203 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002204 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002205 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002206 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlinge3b3c002008-12-01 23:44:08 +00002207 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002208 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002209 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling9f248742008-12-02 00:07:05 +00002210 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002211}
Evan Cheng3154cb62007-10-05 17:59:57 +00002212} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002213
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002214// Register-Register Subtraction
2215def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2216 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002217 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2218 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002219def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2220 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002221 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2222 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002223def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2224 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002225 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2226 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002227
2228// Register-Memory Subtraction
2229def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2230 (ins GR8 :$src1, i8mem :$src2),
2231 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002232 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2233 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002234def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2235 (ins GR16:$src1, i16mem:$src2),
2236 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002237 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2238 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002239def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2240 (ins GR32:$src1, i32mem:$src2),
2241 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002242 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2243 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002244
2245// Register-Integer Subtraction
2246def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2247 (ins GR8:$src1, i8imm:$src2),
2248 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002249 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2250 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002251def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2252 (ins GR16:$src1, i16imm:$src2),
2253 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002254 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2255 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002256def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2257 (ins GR32:$src1, i32imm:$src2),
2258 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002259 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2260 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002261def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2262 (ins GR16:$src1, i16i8imm:$src2),
2263 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002264 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2265 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002266def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2267 (ins GR32:$src1, i32i8imm:$src2),
2268 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002269 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2270 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002271
Chris Lattner57a02302004-08-11 04:31:00 +00002272let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002273 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002274 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002275 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002276 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2277 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002278 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002279 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002280 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2281 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002282 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002283 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002284 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2285 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002286
2287 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002288 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002289 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002290 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2291 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002292 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002293 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002294 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2295 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002296 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002297 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002298 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2299 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002300 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002301 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002302 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002303 addr:$dst),
2304 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002305 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002306 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002307 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002308 addr:$dst),
2309 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002310}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002311
Evan Cheng3154cb62007-10-05 17:59:57 +00002312let Uses = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002313def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002314 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng24f2ea32007-09-14 21:48:26 +00002315 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00002316
Chris Lattner57a02302004-08-11 04:31:00 +00002317let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002318 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002319 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002320 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002321 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002322 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002323 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002324 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002325 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002326 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002327 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002328 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng24f2ea32007-09-14 21:48:26 +00002329 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002330}
Evan Cheng64d80e32007-07-19 01:14:50 +00002331def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002332 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002333 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002334def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002335 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002336 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002337def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002338 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002339 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00002340} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00002341} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002342
Evan Cheng24f2ea32007-09-14 21:48:26 +00002343let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002344let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00002345// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002346def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002347 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002348 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2349 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002350def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002351 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002352 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2353 (implicit EFLAGS)]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002354}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002355
Bill Wendlingd350e022008-12-12 21:15:41 +00002356// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002357def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2358 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002359 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002360 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2361 (implicit EFLAGS)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002362def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002363 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002364 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2365 (implicit EFLAGS)]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002366} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002367} // end Two Address instructions
2368
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002369// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00002370let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00002371// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002372def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002373 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002374 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002375 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2376 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002377def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002378 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002379 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002380 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2381 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002382def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002383 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002384 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002385 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2386 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002387def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002388 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002389 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002390 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2391 (implicit EFLAGS)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002392
Bill Wendlingd350e022008-12-12 21:15:41 +00002393// Memory-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002394def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002395 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002396 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002397 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2398 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002399def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002400 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002401 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002402 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2403 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002404def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002405 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002406 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002407 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002408 i16immSExt8:$src2)),
2409 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002410def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002411 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002412 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002413 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002414 i32immSExt8:$src2)),
2415 (implicit EFLAGS)]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002416} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002417
2418//===----------------------------------------------------------------------===//
2419// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002420//
Evan Cheng0488db92007-09-25 01:57:46 +00002421let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002422let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng64d80e32007-07-19 01:14:50 +00002423def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002424 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002425 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002426 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002427def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002428 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002429 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002430 (implicit EFLAGS)]>,
2431 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002432def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002433 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002434 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002435 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002436}
Evan Cheng734503b2006-09-11 02:19:56 +00002437
Evan Cheng64d80e32007-07-19 01:14:50 +00002438def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002439 "test{b}\t{$src2, $src1|$src1, $src2}",
2440 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2441 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002442def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002443 "test{w}\t{$src2, $src1|$src1, $src2}",
2444 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2445 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002446def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002447 "test{l}\t{$src2, $src1|$src1, $src2}",
2448 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2449 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002450
Evan Cheng069287d2006-05-16 07:21:53 +00002451def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002452 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002453 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002454 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002455 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002456def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002457 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002458 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002459 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002460 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002461def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002462 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002463 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002464 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002465 (implicit EFLAGS)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002466
Evan Chenge5f62042007-09-29 00:00:36 +00002467def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002468 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002469 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002470 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2471 (implicit EFLAGS)]>;
2472def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002473 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002474 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002475 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2476 (implicit EFLAGS)]>, OpSize;
2477def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002478 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002479 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002480 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng0488db92007-09-25 01:57:46 +00002481 (implicit EFLAGS)]>;
2482} // Defs = [EFLAGS]
2483
2484
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002485// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00002486let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002487def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00002488let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002489def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002490
Evan Cheng0488db92007-09-25 01:57:46 +00002491let Uses = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002492def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002493 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002494 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002495 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002496 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002497def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002498 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002499 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002500 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002501 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00002502
Chris Lattner3a173df2004-10-03 20:35:00 +00002503def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002504 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002505 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002506 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002507 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002508def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002509 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002510 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002511 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002512 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00002513
Evan Chengd5781fc2005-12-21 20:21:51 +00002514def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002515 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002516 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002517 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002518 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002519def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002520 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002521 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002522 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002523 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00002524
Evan Chengd5781fc2005-12-21 20:21:51 +00002525def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002526 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002527 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002528 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002529 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002530def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002531 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002532 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002533 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002534 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002535
Evan Chengd5781fc2005-12-21 20:21:51 +00002536def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002537 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002538 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002539 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002540 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002541def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002542 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002543 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002544 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002545 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002546
Evan Chengd5781fc2005-12-21 20:21:51 +00002547def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002548 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002549 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002550 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002551 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002552def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002553 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002554 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002555 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002556 TB; // [mem8] = > signed
2557
2558def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002559 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002560 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002561 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002562 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002563def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002564 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002565 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002566 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002567 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002568
Evan Chengd5781fc2005-12-21 20:21:51 +00002569def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002570 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002571 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002572 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002573 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002574def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002575 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002576 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002577 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002578 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002579
Chris Lattner3a173df2004-10-03 20:35:00 +00002580def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002581 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002582 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002583 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002584 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002585def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002586 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002587 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002588 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002589 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002590
Chris Lattner3a173df2004-10-03 20:35:00 +00002591def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002592 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002593 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002594 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002595 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002596def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002597 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002598 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002599 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002600 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002601
Chris Lattner3a173df2004-10-03 20:35:00 +00002602def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002603 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002604 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002605 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002606 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002607def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002608 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002609 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002610 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002611 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002612def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002613 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002614 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002615 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002616 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002617def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002618 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002619 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002620 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002621 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00002622
Chris Lattner3a173df2004-10-03 20:35:00 +00002623def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002624 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002625 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002626 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002627 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002628def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002629 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002630 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002631 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002632 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002633def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002634 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002635 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002636 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002637 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002638def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002639 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002640 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002641 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002642 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00002643
2644def SETOr : I<0x90, MRM0r,
2645 (outs GR8 :$dst), (ins),
2646 "seto\t$dst",
2647 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2648 TB; // GR8 = overflow
2649def SETOm : I<0x90, MRM0m,
2650 (outs), (ins i8mem:$dst),
2651 "seto\t$dst",
2652 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2653 TB; // [mem8] = overflow
2654def SETNOr : I<0x91, MRM0r,
2655 (outs GR8 :$dst), (ins),
2656 "setno\t$dst",
2657 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2658 TB; // GR8 = not overflow
2659def SETNOm : I<0x91, MRM0m,
2660 (outs), (ins i8mem:$dst),
2661 "setno\t$dst",
2662 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2663 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00002664} // Uses = [EFLAGS]
2665
Chris Lattner1cca5e32003-08-03 21:54:21 +00002666
2667// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00002668let Defs = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002669def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002670 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002671 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002672 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002673def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002674 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002675 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002676 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002677def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002678 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002679 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002680 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002681def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002682 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002683 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002684 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2685 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002686def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002687 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002688 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002689 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2690 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002691def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002692 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002693 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002694 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2695 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002696def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002697 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002698 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002699 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2700 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002701def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002702 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002703 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002704 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2705 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002706def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002707 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002708 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002709 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2710 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002711def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002712 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002713 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002714 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002715def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002716 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002717 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002718 [(X86cmp GR16:$src1, imm:$src2),
2719 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002720def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002721 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002722 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002723 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002724def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002725 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002726 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002727 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2728 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002729def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002730 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002731 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002732 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2733 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002734def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002735 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002736 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002737 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2738 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002739def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002740 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002741 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002742 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2743 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002744def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002745 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002746 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002747 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2748 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002749def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002750 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002751 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002752 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2753 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002754def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002755 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002756 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002757 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00002758 (implicit EFLAGS)]>;
2759} // Defs = [EFLAGS]
2760
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002761// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002762// TODO: BTC, BTR, and BTS
2763let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00002764def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002765 "bt{w}\t{$src2, $src1|$src1, $src2}",
2766 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00002767 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00002768def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002769 "bt{l}\t{$src2, $src1|$src1, $src2}",
2770 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00002771 (implicit EFLAGS)]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00002772
2773// Unlike with the register+register form, the memory+register form of the
2774// bt instruction does not ignore the high bits of the index. From ISel's
2775// perspective, this is pretty bizarre. Disable these instructions for now.
2776//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2777// "bt{w}\t{$src2, $src1|$src1, $src2}",
2778// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2779// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2780//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2781// "bt{l}\t{$src2, $src1|$src1, $src2}",
2782// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2783// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00002784
2785def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2786 "bt{w}\t{$src2, $src1|$src1, $src2}",
2787 [(X86bt GR16:$src1, i16immSExt8:$src2),
2788 (implicit EFLAGS)]>, OpSize, TB;
2789def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2790 "bt{l}\t{$src2, $src1|$src1, $src2}",
2791 [(X86bt GR32:$src1, i32immSExt8:$src2),
2792 (implicit EFLAGS)]>, TB;
2793// Note that these instructions don't need FastBTMem because that
2794// only applies when the other operand is in a register. When it's
2795// an immediate, bt is still fast.
2796def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2797 "bt{w}\t{$src2, $src1|$src1, $src2}",
2798 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2799 (implicit EFLAGS)]>, OpSize, TB;
2800def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2801 "bt{l}\t{$src2, $src1|$src1, $src2}",
2802 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2803 (implicit EFLAGS)]>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002804} // Defs = [EFLAGS]
2805
Chris Lattner1cca5e32003-08-03 21:54:21 +00002806// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00002807// Use movsbl intead of movsbw; we don't care about the high 16 bits
2808// of the register here. This has a smaller encoding and avoids a
2809// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002810def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002811 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2812 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002813def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002814 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2815 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002816def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002817 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002818 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002819def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002820 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002821 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002822def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002823 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002824 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002825def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002826 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002827 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002828
Dan Gohman11ba3b12008-07-30 18:09:17 +00002829// Use movzbl intead of movzbw; we don't care about the high 16 bits
2830// of the register here. This has a smaller encoding and avoids a
2831// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002832def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002833 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2834 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002835def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002836 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2837 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002838def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002839 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002840 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002841def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002842 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002843 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002844def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002845 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002846 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002847def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002848 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002849 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00002850
Chris Lattnerba7e7562008-01-10 07:59:24 +00002851let neverHasSideEffects = 1 in {
2852 let Defs = [AX], Uses = [AL] in
2853 def CBW : I<0x98, RawFrm, (outs), (ins),
2854 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2855 let Defs = [EAX], Uses = [AX] in
2856 def CWDE : I<0x98, RawFrm, (outs), (ins),
2857 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00002858
Chris Lattnerba7e7562008-01-10 07:59:24 +00002859 let Defs = [AX,DX], Uses = [AX] in
2860 def CWD : I<0x99, RawFrm, (outs), (ins),
2861 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2862 let Defs = [EAX,EDX], Uses = [EAX] in
2863 def CDQ : I<0x99, RawFrm, (outs), (ins),
2864 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2865}
Evan Cheng747a90d2006-02-21 02:24:38 +00002866
Evan Cheng747a90d2006-02-21 02:24:38 +00002867//===----------------------------------------------------------------------===//
2868// Alias Instructions
2869//===----------------------------------------------------------------------===//
2870
2871// Alias instructions that map movr0 to xor.
2872// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002873let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002874def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002875 "xor{b}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002876 [(set GR8:$dst, 0)]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00002877// Use xorl instead of xorw since we don't care about the high 16 bits,
2878// it's smaller, and it avoids a partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002879def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002880 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2881 [(set GR16:$dst, 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002882def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002883 "xor{l}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002884 [(set GR32:$dst, 0)]>;
Dan Gohman1ab79892007-09-07 21:32:51 +00002885}
Evan Cheng747a90d2006-02-21 02:24:38 +00002886
Evan Cheng069287d2006-05-16 07:21:53 +00002887// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2888// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengb3379fb2009-02-05 08:42:55 +00002889let neverHasSideEffects = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002890def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002891 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002892def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002893 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002894
Evan Cheng64d80e32007-07-19 01:14:50 +00002895def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002896 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002897def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002898 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002899} // neverHasSideEffects
2900
Dan Gohman15511cf2008-12-03 18:15:48 +00002901let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002902def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002903 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002904def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002905 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng2f394262007-08-30 05:49:43 +00002906}
Chris Lattnerba7e7562008-01-10 07:59:24 +00002907let mayStore = 1, neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002908def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002909 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002910def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002911 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002912}
Evan Cheng403be7e2006-05-08 08:01:26 +00002913
Evan Cheng510e4782006-01-09 23:10:28 +00002914//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002915// Thread Local Storage Instructions
2916//
2917
Evan Cheng071a2792007-09-11 19:55:27 +00002918let Uses = [EBX] in
Anton Korobeynikov6625eff2008-05-04 21:36:32 +00002919def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2920 "leal\t${sym:mem}(,%ebx,1), $dst",
2921 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002922
Lauro Ramos Venancio7d2cc2b2007-04-22 22:50:52 +00002923let AddedComplexity = 10 in
Anton Korobeynikov6625eff2008-05-04 21:36:32 +00002924def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002925 "movl\t%gs:($src), $dst",
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002926 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2927
2928let AddedComplexity = 15 in
Nicolas Geoffrayb74f3702008-10-25 15:22:06 +00002929def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002930 "movl\t%gs:${src:mem}, $dst",
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002931 [(set GR32:$dst,
Nicolas Geoffrayb74f3702008-10-25 15:22:06 +00002932 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
2933 SegGS;
Lauro Ramos Venancio7d2cc2b2007-04-22 22:50:52 +00002934
Nicolas Geoffrayb74f3702008-10-25 15:22:06 +00002935def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002936 "movl\t%gs:0, $dst",
Nicolas Geoffrayb74f3702008-10-25 15:22:06 +00002937 [(set GR32:$dst, X86TLStp)]>, SegGS;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002938
Nate Begeman51a04372009-01-26 01:24:32 +00002939let AddedComplexity = 5 in
2940def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
2941 "movl\t%gs:$src, $dst",
2942 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
2943
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002944//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00002945// DWARF Pseudo Instructions
2946//
2947
Evan Cheng64d80e32007-07-19 01:14:50 +00002948def DWARF_LOC : I<0, Pseudo, (outs),
2949 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman6b5766e2007-09-24 19:25:06 +00002950 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Evan Cheng3c992d22006-03-07 02:02:57 +00002951 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2952 (i32 imm:$file))]>;
2953
Evan Cheng3c992d22006-03-07 02:02:57 +00002954//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00002955// EH Pseudo Instructions
2956//
2957let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Chengffbacca2007-07-21 00:34:19 +00002958 hasCtrlDep = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002959def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002960 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00002961 [(X86ehret GR32:$addr)]>;
2962
2963}
2964
2965//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00002966// Atomic support
2967//
Andrew Lenharthea7da502008-03-01 13:37:02 +00002968
Evan Chengbb6939d2008-04-19 01:20:30 +00002969// Atomic swap. These are just normal xchg instructions. But since a memory
2970// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00002971let Constraints = "$val = $dst" in {
Evan Chengbb6939d2008-04-19 01:20:30 +00002972def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2973 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2974 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2975def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2976 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2977 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2978 OpSize;
2979def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2980 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2981 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2982}
2983
Evan Cheng7e032802008-04-18 20:55:36 +00002984// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002985let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002986def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002987 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002988 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002989}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002990let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovf88a6fa2008-07-22 16:22:48 +00002991def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002992 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00002993 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2994}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002995
2996let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002997def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002998 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002999 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003000}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003001let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003002def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesen140be2d2008-08-19 18:47:28 +00003003 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003004 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003005}
3006
Evan Cheng7e032802008-04-18 20:55:36 +00003007// Atomic exchange and add
3008let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3009def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesen140be2d2008-08-19 18:47:28 +00003010 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003011 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003012 TB, LOCK;
3013def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesen140be2d2008-08-19 18:47:28 +00003014 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003015 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003016 TB, OpSize, LOCK;
3017def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesen140be2d2008-08-19 18:47:28 +00003018 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003019 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003020 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003021}
3022
Mon P Wang28873102008-06-25 08:15:39 +00003023// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00003024let Constraints = "$val = $dst", Defs = [EFLAGS],
3025 usesCustomDAGSchedInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00003026def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003027 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003028 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003029def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003030 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003031 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003032def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003033 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003034 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00003035def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003036 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003037 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003038def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003039 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003040 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003041def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003042 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003043 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003044def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003045 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003046 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003047def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003048 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003049 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003050
3051def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003052 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003053 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003054def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003055 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003056 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003057def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003058 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003059 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003060def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003061 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003062 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003063def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003064 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003065 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003066def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003067 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003068 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003069def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003070 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003071 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003072def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003073 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003074 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003075
3076def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003077 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003078 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003079def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003080 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003081 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003082def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003083 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003084 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003085def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003086 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003087 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00003088}
3089
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003090let Constraints = "$val1 = $dst1, $val2 = $dst2",
3091 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3092 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00003093 mayLoad = 1, mayStore = 1,
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003094 usesCustomDAGSchedInserter = 1 in {
3095def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3096 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003097 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003098def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3099 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003100 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003101def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3102 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003103 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003104def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3105 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003106 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003107def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3108 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003109 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003110def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3111 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003112 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00003113def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3114 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003115 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003116}
3117
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003118//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00003119// Non-Instruction Patterns
3120//===----------------------------------------------------------------------===//
3121
Bill Wendling056292f2008-09-16 21:48:12 +00003122// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00003123def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00003124def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00003125def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00003126def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3127def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3128
Evan Cheng069287d2006-05-16 07:21:53 +00003129def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3130 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3131def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3132 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3133def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3134 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3135def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3136 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00003137
Evan Chengfc8feb12006-05-19 07:30:36 +00003138def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00003139 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00003140def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00003141 (MOV32mi addr:$dst, texternalsym:$src)>;
3142
Evan Cheng510e4782006-01-09 23:10:28 +00003143// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003144// tailcall stuff
Evan Cheng069287d2006-05-16 07:21:53 +00003145def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003146 (TAILCALL)>;
Evan Chengfea89c12006-04-27 08:40:39 +00003147
Evan Cheng25ab6902006-09-08 06:48:29 +00003148def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003149 (TAILCALL)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00003150def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003151 (TAILCALL)>;
3152
3153def : Pat<(X86tcret GR32:$dst, imm:$off),
3154 (TCRETURNri GR32:$dst, imm:$off)>;
3155
3156def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3157 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3158
3159def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3160 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Evan Chengfea89c12006-04-27 08:40:39 +00003161
Evan Cheng25ab6902006-09-08 06:48:29 +00003162def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00003163 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00003164def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00003165 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003166
3167// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00003168def : Pat<(addc GR32:$src1, GR32:$src2),
3169 (ADD32rr GR32:$src1, GR32:$src2)>;
3170def : Pat<(addc GR32:$src1, (load addr:$src2)),
3171 (ADD32rm GR32:$src1, addr:$src2)>;
3172def : Pat<(addc GR32:$src1, imm:$src2),
3173 (ADD32ri GR32:$src1, imm:$src2)>;
3174def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3175 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003176
Evan Cheng069287d2006-05-16 07:21:53 +00003177def : Pat<(subc GR32:$src1, GR32:$src2),
3178 (SUB32rr GR32:$src1, GR32:$src2)>;
3179def : Pat<(subc GR32:$src1, (load addr:$src2)),
3180 (SUB32rm GR32:$src1, addr:$src2)>;
3181def : Pat<(subc GR32:$src1, imm:$src2),
3182 (SUB32ri GR32:$src1, imm:$src2)>;
3183def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3184 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003185
Chris Lattnerffc0b262006-09-07 20:33:45 +00003186// Comparisons.
3187
3188// TEST R,R is smaller than CMP R,0
Evan Chenge5f62042007-09-29 00:00:36 +00003189def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003190 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003191def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003192 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003193def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003194 (TEST32rr GR32:$src1, GR32:$src1)>;
3195
Dan Gohmanfbb74862009-01-07 01:00:24 +00003196// Conditional moves with folded loads with operands swapped and conditions
3197// inverted.
3198def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3199 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3200def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3201 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3202def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3203 (CMOVB16rm GR16:$src2, addr:$src1)>;
3204def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3205 (CMOVB32rm GR32:$src2, addr:$src1)>;
3206def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3207 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3208def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3209 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3210def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3211 (CMOVE16rm GR16:$src2, addr:$src1)>;
3212def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3213 (CMOVE32rm GR32:$src2, addr:$src1)>;
3214def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3215 (CMOVA16rm GR16:$src2, addr:$src1)>;
3216def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3217 (CMOVA32rm GR32:$src2, addr:$src1)>;
3218def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3219 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3220def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3221 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3222def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3223 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3224def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3225 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3226def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3227 (CMOVL16rm GR16:$src2, addr:$src1)>;
3228def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3229 (CMOVL32rm GR32:$src2, addr:$src1)>;
3230def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3231 (CMOVG16rm GR16:$src2, addr:$src1)>;
3232def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3233 (CMOVG32rm GR32:$src2, addr:$src1)>;
3234def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3235 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3236def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3237 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3238def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3239 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3240def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3241 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3242def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3243 (CMOVP16rm GR16:$src2, addr:$src1)>;
3244def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3245 (CMOVP32rm GR32:$src2, addr:$src1)>;
3246def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3247 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3248def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3249 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3250def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3251 (CMOVS16rm GR16:$src2, addr:$src1)>;
3252def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3253 (CMOVS32rm GR32:$src2, addr:$src1)>;
3254def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3255 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3256def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3257 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3258def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3259 (CMOVO16rm GR16:$src2, addr:$src1)>;
3260def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3261 (CMOVO32rm GR32:$src2, addr:$src1)>;
3262
Duncan Sandsf9c98e62008-01-23 20:39:46 +00003263// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00003264def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003265def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3266def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3267
3268// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00003269def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00003270def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3271 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00003272def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00003273def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3274 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00003275def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3276def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003277
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003278// anyext
Bill Wendling449416d2008-08-22 20:51:05 +00003279def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3280 Requires<[In32BitMode]>;
3281def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3282 Requires<[In32BitMode]>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003283def : Pat<(i32 (anyext GR16:$src)),
3284 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003285
Evan Cheng1314b002007-12-13 00:43:27 +00003286// (and (i32 load), 255) -> (zextload i8)
Evan Chengd47e0b62008-09-29 17:26:18 +00003287def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3288 (MOVZX32rm8 addr:$src)>;
3289def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3290 (MOVZX32rm16 addr:$src)>;
Evan Cheng1314b002007-12-13 00:43:27 +00003291
Evan Chengcfa260b2006-01-06 02:31:59 +00003292//===----------------------------------------------------------------------===//
3293// Some peepholes
3294//===----------------------------------------------------------------------===//
3295
Dan Gohman63f97202008-10-17 01:33:43 +00003296// Odd encoding trick: -128 fits into an 8-bit immediate field while
3297// +128 doesn't, so in this special case use a sub instead of an add.
3298def : Pat<(add GR16:$src1, 128),
3299 (SUB16ri8 GR16:$src1, -128)>;
3300def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3301 (SUB16mi8 addr:$dst, -128)>;
3302def : Pat<(add GR32:$src1, 128),
3303 (SUB32ri8 GR32:$src1, -128)>;
3304def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3305 (SUB32mi8 addr:$dst, -128)>;
3306
Dan Gohman11ba3b12008-07-30 18:09:17 +00003307// r & (2^16-1) ==> movz
3308def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003309 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00003310// r & (2^8-1) ==> movz
3311def : Pat<(and GR32:$src1, 0xff),
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003312 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3313 x86_subreg_8bit)))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003314 Requires<[In32BitMode]>;
3315// r & (2^8-1) ==> movz
3316def : Pat<(and GR16:$src1, 0xff),
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003317 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3318 x86_subreg_8bit)))>,
3319 Requires<[In32BitMode]>;
3320
3321// sext_inreg patterns
3322def : Pat<(sext_inreg GR32:$src, i16),
3323 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3324def : Pat<(sext_inreg GR32:$src, i8),
3325 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3326 x86_subreg_8bit)))>,
3327 Requires<[In32BitMode]>;
3328def : Pat<(sext_inreg GR16:$src, i8),
3329 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3330 x86_subreg_8bit)))>,
3331 Requires<[In32BitMode]>;
3332
3333// trunc patterns
3334def : Pat<(i16 (trunc GR32:$src)),
3335 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3336def : Pat<(i8 (trunc GR32:$src)),
3337 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3338 Requires<[In32BitMode]>;
3339def : Pat<(i8 (trunc GR16:$src)),
3340 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003341 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00003342
Evan Chengcfa260b2006-01-06 02:31:59 +00003343// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00003344def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3345def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3346def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003347
Evan Chengeb9f8922008-08-30 02:03:58 +00003348// (shl x (and y, 31)) ==> (shl x, y)
3349def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3350 (SHL8rCL GR8:$src1)>;
3351def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3352 (SHL16rCL GR16:$src1)>;
3353def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3354 (SHL32rCL GR32:$src1)>;
3355def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3356 (SHL8mCL addr:$dst)>;
3357def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3358 (SHL16mCL addr:$dst)>;
3359def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3360 (SHL32mCL addr:$dst)>;
3361
3362def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3363 (SHR8rCL GR8:$src1)>;
3364def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3365 (SHR16rCL GR16:$src1)>;
3366def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3367 (SHR32rCL GR32:$src1)>;
3368def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3369 (SHR8mCL addr:$dst)>;
3370def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3371 (SHR16mCL addr:$dst)>;
3372def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3373 (SHR32mCL addr:$dst)>;
3374
3375def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3376 (SAR8rCL GR8:$src1)>;
3377def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3378 (SAR16rCL GR16:$src1)>;
3379def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3380 (SAR32rCL GR32:$src1)>;
3381def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3382 (SAR8mCL addr:$dst)>;
3383def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3384 (SAR16mCL addr:$dst)>;
3385def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3386 (SAR32mCL addr:$dst)>;
3387
Evan Cheng956044c2006-01-19 23:26:24 +00003388// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003389def : Pat<(or (srl GR32:$src1, CL:$amt),
3390 (shl GR32:$src2, (sub 32, CL:$amt))),
3391 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003392
Evan Cheng21d54432006-01-20 01:13:30 +00003393def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003394 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3395 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003396
Dan Gohman74feef22008-10-17 01:23:35 +00003397def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3398 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3399 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3400
3401def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3402 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3403 addr:$dst),
3404 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3405
3406def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3407 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3408
3409def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3410 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3411 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3412
Evan Cheng956044c2006-01-19 23:26:24 +00003413// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003414def : Pat<(or (shl GR32:$src1, CL:$amt),
3415 (srl GR32:$src2, (sub 32, CL:$amt))),
3416 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003417
Evan Cheng21d54432006-01-20 01:13:30 +00003418def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003419 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3420 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003421
Dan Gohman74feef22008-10-17 01:23:35 +00003422def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3423 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3424 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3425
3426def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3427 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3428 addr:$dst),
3429 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3430
3431def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3432 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3433
3434def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3435 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3436 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3437
Evan Cheng956044c2006-01-19 23:26:24 +00003438// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003439def : Pat<(or (srl GR16:$src1, CL:$amt),
3440 (shl GR16:$src2, (sub 16, CL:$amt))),
3441 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003442
Evan Cheng21d54432006-01-20 01:13:30 +00003443def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003444 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3445 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003446
Dan Gohman74feef22008-10-17 01:23:35 +00003447def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3448 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3449 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3450
3451def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3452 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3453 addr:$dst),
3454 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3455
3456def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3457 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3458
3459def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3460 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3461 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3462
Evan Cheng956044c2006-01-19 23:26:24 +00003463// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003464def : Pat<(or (shl GR16:$src1, CL:$amt),
3465 (srl GR16:$src2, (sub 16, CL:$amt))),
3466 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003467
3468def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003469 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3470 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003471
Dan Gohman74feef22008-10-17 01:23:35 +00003472def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3473 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3474 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3475
3476def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3477 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3478 addr:$dst),
3479 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3480
3481def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3482 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3483
3484def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3485 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3486 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3487
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003488//===----------------------------------------------------------------------===//
Bill Wendlingd350e022008-12-12 21:15:41 +00003489// Overflow Patterns
3490//===----------------------------------------------------------------------===//
3491
3492// Register-Register Addition with Overflow
3493def : Pat<(parallel (X86add_ovf GR8:$src1, GR8:$src2),
3494 (implicit EFLAGS)),
3495 (ADD8rr GR8:$src1, GR8:$src2)>;
3496
3497// Register-Register Addition with Overflow
3498def : Pat<(parallel (X86add_ovf GR16:$src1, GR16:$src2),
3499 (implicit EFLAGS)),
3500 (ADD16rr GR16:$src1, GR16:$src2)>;
3501def : Pat<(parallel (X86add_ovf GR32:$src1, GR32:$src2),
3502 (implicit EFLAGS)),
3503 (ADD32rr GR32:$src1, GR32:$src2)>;
3504
3505// Register-Memory Addition with Overflow
3506def : Pat<(parallel (X86add_ovf GR8:$src1, (load addr:$src2)),
3507 (implicit EFLAGS)),
3508 (ADD8rm GR8:$src1, addr:$src2)>;
3509def : Pat<(parallel (X86add_ovf GR16:$src1, (load addr:$src2)),
3510 (implicit EFLAGS)),
3511 (ADD16rm GR16:$src1, addr:$src2)>;
3512def : Pat<(parallel (X86add_ovf GR32:$src1, (load addr:$src2)),
3513 (implicit EFLAGS)),
3514 (ADD32rm GR32:$src1, addr:$src2)>;
3515
3516// Register-Integer Addition with Overflow
3517def : Pat<(parallel (X86add_ovf GR8:$src1, imm:$src2),
3518 (implicit EFLAGS)),
3519 (ADD8ri GR8:$src1, imm:$src2)>;
3520
3521// Register-Integer Addition with Overflow
3522def : Pat<(parallel (X86add_ovf GR16:$src1, imm:$src2),
3523 (implicit EFLAGS)),
3524 (ADD16ri GR16:$src1, imm:$src2)>;
3525def : Pat<(parallel (X86add_ovf GR32:$src1, imm:$src2),
3526 (implicit EFLAGS)),
3527 (ADD32ri GR32:$src1, imm:$src2)>;
3528def : Pat<(parallel (X86add_ovf GR16:$src1, i16immSExt8:$src2),
3529 (implicit EFLAGS)),
3530 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3531def : Pat<(parallel (X86add_ovf GR32:$src1, i32immSExt8:$src2),
3532 (implicit EFLAGS)),
3533 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3534
3535// Memory-Register Addition with Overflow
3536def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR8:$src2),
3537 addr:$dst),
3538 (implicit EFLAGS)),
3539 (ADD8mr addr:$dst, GR8:$src2)>;
3540def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR16:$src2),
3541 addr:$dst),
3542 (implicit EFLAGS)),
3543 (ADD16mr addr:$dst, GR16:$src2)>;
3544def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR32:$src2),
3545 addr:$dst),
3546 (implicit EFLAGS)),
3547 (ADD32mr addr:$dst, GR32:$src2)>;
3548def : Pat<(parallel (store (X86add_ovf (loadi8 addr:$dst), imm:$src2),
3549 addr:$dst),
3550 (implicit EFLAGS)),
3551 (ADD8mi addr:$dst, imm:$src2)>;
3552def : Pat<(parallel (store (X86add_ovf (loadi16 addr:$dst), imm:$src2),
3553 addr:$dst),
3554 (implicit EFLAGS)),
3555 (ADD16mi addr:$dst, imm:$src2)>;
3556def : Pat<(parallel (store (X86add_ovf (loadi32 addr:$dst), imm:$src2),
3557 addr:$dst),
3558 (implicit EFLAGS)),
3559 (ADD32mi addr:$dst, imm:$src2)>;
3560def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i16immSExt8:$src2),
3561 addr:$dst),
3562 (implicit EFLAGS)),
3563 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3564def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i32immSExt8:$src2),
3565 addr:$dst),
3566 (implicit EFLAGS)),
3567 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3568
3569// Register-Register Subtraction with Overflow
3570def : Pat<(parallel (X86sub_ovf GR8:$src1, GR8:$src2),
3571 (implicit EFLAGS)),
3572 (SUB8rr GR8:$src1, GR8:$src2)>;
3573def : Pat<(parallel (X86sub_ovf GR16:$src1, GR16:$src2),
3574 (implicit EFLAGS)),
3575 (SUB16rr GR16:$src1, GR16:$src2)>;
3576def : Pat<(parallel (X86sub_ovf GR32:$src1, GR32:$src2),
3577 (implicit EFLAGS)),
3578 (SUB32rr GR32:$src1, GR32:$src2)>;
3579
3580// Register-Memory Subtraction with Overflow
3581def : Pat<(parallel (X86sub_ovf GR8:$src1, (load addr:$src2)),
3582 (implicit EFLAGS)),
3583 (SUB8rm GR8:$src1, addr:$src2)>;
3584def : Pat<(parallel (X86sub_ovf GR16:$src1, (load addr:$src2)),
3585 (implicit EFLAGS)),
3586 (SUB16rm GR16:$src1, addr:$src2)>;
3587def : Pat<(parallel (X86sub_ovf GR32:$src1, (load addr:$src2)),
3588 (implicit EFLAGS)),
3589 (SUB32rm GR32:$src1, addr:$src2)>;
3590
3591// Register-Integer Subtraction with Overflow
3592def : Pat<(parallel (X86sub_ovf GR8:$src1, imm:$src2),
3593 (implicit EFLAGS)),
3594 (SUB8ri GR8:$src1, imm:$src2)>;
3595def : Pat<(parallel (X86sub_ovf GR16:$src1, imm:$src2),
3596 (implicit EFLAGS)),
3597 (SUB16ri GR16:$src1, imm:$src2)>;
3598def : Pat<(parallel (X86sub_ovf GR32:$src1, imm:$src2),
3599 (implicit EFLAGS)),
3600 (SUB32ri GR32:$src1, imm:$src2)>;
3601def : Pat<(parallel (X86sub_ovf GR16:$src1, i16immSExt8:$src2),
3602 (implicit EFLAGS)),
3603 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3604def : Pat<(parallel (X86sub_ovf GR32:$src1, i32immSExt8:$src2),
3605 (implicit EFLAGS)),
3606 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3607
3608// Memory-Register Subtraction with Overflow
3609def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR8:$src2),
3610 addr:$dst),
3611 (implicit EFLAGS)),
3612 (SUB8mr addr:$dst, GR8:$src2)>;
3613def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR16:$src2),
3614 addr:$dst),
3615 (implicit EFLAGS)),
3616 (SUB16mr addr:$dst, GR16:$src2)>;
3617def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR32:$src2),
3618 addr:$dst),
3619 (implicit EFLAGS)),
3620 (SUB32mr addr:$dst, GR32:$src2)>;
3621
3622// Memory-Integer Subtraction with Overflow
3623def : Pat<(parallel (store (X86sub_ovf (loadi8 addr:$dst), imm:$src2),
3624 addr:$dst),
3625 (implicit EFLAGS)),
3626 (SUB8mi addr:$dst, imm:$src2)>;
3627def : Pat<(parallel (store (X86sub_ovf (loadi16 addr:$dst), imm:$src2),
3628 addr:$dst),
3629 (implicit EFLAGS)),
3630 (SUB16mi addr:$dst, imm:$src2)>;
3631def : Pat<(parallel (store (X86sub_ovf (loadi32 addr:$dst), imm:$src2),
3632 addr:$dst),
3633 (implicit EFLAGS)),
3634 (SUB32mi addr:$dst, imm:$src2)>;
3635def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i16immSExt8:$src2),
3636 addr:$dst),
3637 (implicit EFLAGS)),
3638 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3639def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i32immSExt8:$src2),
3640 addr:$dst),
3641 (implicit EFLAGS)),
3642 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3643
3644
3645// Register-Register Signed Integer Multiply with Overflow
3646def : Pat<(parallel (X86smul_ovf GR16:$src1, GR16:$src2),
3647 (implicit EFLAGS)),
3648 (IMUL16rr GR16:$src1, GR16:$src2)>;
3649def : Pat<(parallel (X86smul_ovf GR32:$src1, GR32:$src2),
3650 (implicit EFLAGS)),
3651 (IMUL32rr GR32:$src1, GR32:$src2)>;
3652
3653// Register-Memory Signed Integer Multiply with Overflow
3654def : Pat<(parallel (X86smul_ovf GR16:$src1, (load addr:$src2)),
3655 (implicit EFLAGS)),
3656 (IMUL16rm GR16:$src1, addr:$src2)>;
3657def : Pat<(parallel (X86smul_ovf GR32:$src1, (load addr:$src2)),
3658 (implicit EFLAGS)),
3659 (IMUL32rm GR32:$src1, addr:$src2)>;
3660
3661// Register-Integer Signed Integer Multiply with Overflow
3662def : Pat<(parallel (X86smul_ovf GR16:$src1, imm:$src2),
3663 (implicit EFLAGS)),
3664 (IMUL16rri GR16:$src1, imm:$src2)>;
3665def : Pat<(parallel (X86smul_ovf GR32:$src1, imm:$src2),
3666 (implicit EFLAGS)),
3667 (IMUL32rri GR32:$src1, imm:$src2)>;
3668def : Pat<(parallel (X86smul_ovf GR16:$src1, i16immSExt8:$src2),
3669 (implicit EFLAGS)),
3670 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
3671def : Pat<(parallel (X86smul_ovf GR32:$src1, i32immSExt8:$src2),
3672 (implicit EFLAGS)),
3673 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3674
3675// Memory-Integer Signed Integer Multiply with Overflow
3676def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
3677 (implicit EFLAGS)),
3678 (IMUL16rmi addr:$src1, imm:$src2)>;
3679def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
3680 (implicit EFLAGS)),
3681 (IMUL32rmi addr:$src1, imm:$src2)>;
3682def : Pat<(parallel (X86smul_ovf (load addr:$src1), i16immSExt8:$src2),
3683 (implicit EFLAGS)),
3684 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
3685def : Pat<(parallel (X86smul_ovf (load addr:$src1), i32immSExt8:$src2),
3686 (implicit EFLAGS)),
3687 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3688
Evan Cheng6a86bd72009-01-27 03:30:42 +00003689// Optimize multiple with overflow by 2.
3690let AddedComplexity = 2 in {
3691def : Pat<(parallel (X86smul_ovf GR16:$src1, 2),
3692 (implicit EFLAGS)),
3693 (ADD16rr GR16:$src1, GR16:$src1)>;
3694
3695def : Pat<(parallel (X86smul_ovf GR32:$src1, 2),
3696 (implicit EFLAGS)),
3697 (ADD32rr GR32:$src1, GR32:$src1)>;
3698}
3699
Bill Wendlingd350e022008-12-12 21:15:41 +00003700//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003701// Floating Point Stack Support
3702//===----------------------------------------------------------------------===//
3703
3704include "X86InstrFPStack.td"
3705
3706//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00003707// X86-64 Support
3708//===----------------------------------------------------------------------===//
3709
Chris Lattner36fe6d22008-01-10 05:50:42 +00003710include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00003711
3712//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003713// XMM Floating point support (requires SSE / SSE2)
3714//===----------------------------------------------------------------------===//
3715
3716include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00003717
3718//===----------------------------------------------------------------------===//
3719// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3720//===----------------------------------------------------------------------===//
3721
3722include "X86InstrMMX.td"