blob: 16dc366c161f60923c895aa8af1f1174a1c8d77c [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
Evan Chenge5f62042007-09-29 00:00:36 +000030def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng0488db92007-09-25 01:57:46 +000031 [SDTCisVT<0, OtherVT>,
32 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000033
Evan Chenge5f62042007-09-29 00:00:36 +000034def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng0488db92007-09-25 01:57:46 +000035 [SDTCisVT<0, i8>,
36 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000037
Andrew Lenharth26ed8692008-03-01 21:52:34 +000038def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
39 SDTCisVT<2, i8>]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000040def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth26ed8692008-03-01 21:52:34 +000041
Dale Johannesen48c1bc22008-10-02 18:53:47 +000042def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
43 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattner447ff682008-03-11 03:23:40 +000044def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000045
Bill Wendlingc69107c2007-11-13 09:19:02 +000046def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
47def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
48 SDTCisVT<1, i32> ]>;
Evan Chenge3413162006-01-09 18:33:28 +000049
Dan Gohmand35121a2008-05-29 19:57:41 +000050def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000051
Evan Cheng67f92a72006-01-11 22:15:48 +000052def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
53
Evan Chenge3413162006-01-09 18:33:28 +000054def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000055
Evan Cheng71fb8342006-02-25 10:02:21 +000056def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
57
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000058def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
59
60def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
61
Anton Korobeynikov2365f512007-07-14 14:06:15 +000062def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
63
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000064def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
65
Evan Cheng18efe262007-12-14 02:13:44 +000066def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
67def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Evan Chenge3413162006-01-09 18:33:28 +000068def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
69def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000070
Evan Chenge5f62042007-09-29 00:00:36 +000071def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Evan Chengb077b842005-12-21 02:39:21 +000072
Evan Chenge5f62042007-09-29 00:00:36 +000073def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +000074def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +000075 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +000076def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Chengb077b842005-12-21 02:39:21 +000077
Andrew Lenharth26ed8692008-03-01 21:52:34 +000078def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
79 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
80 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000081def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
82 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
83 SDNPMayLoad]>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +000084def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
85 [SDNPHasChain, SDNPMayStore,
86 SDNPMayLoad, SDNPMemOperand]>;
87def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
88 [SDNPHasChain, SDNPMayStore,
89 SDNPMayLoad, SDNPMemOperand]>;
90def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
91 [SDNPHasChain, SDNPMayStore,
92 SDNPMayLoad, SDNPMemOperand]>;
93def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen880ae362008-10-03 22:25:52 +0000102def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
Evan Chenge3413162006-01-09 18:33:28 +0000105def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
106 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000107
Evan Chenge3413162006-01-09 18:33:28 +0000108def X86callseq_start :
109 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +0000110 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +0000111def X86callseq_end :
112 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000113 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000114
Evan Chenge3413162006-01-09 18:33:28 +0000115def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
116 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +0000117
Evan Chengfb914c42006-05-20 01:40:16 +0000118def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
Evan Chengfea89c12006-04-27 08:40:39 +0000119 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
120
Evan Cheng67f92a72006-01-11 22:15:48 +0000121def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000122 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000123def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000124 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
125 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000126
Evan Chenge3413162006-01-09 18:33:28 +0000127def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000128 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000129
Evan Cheng0085a282006-11-30 21:55:46 +0000130def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
131def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000132
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000133def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000134 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000135def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
136
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000137def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
138 [SDNPHasChain]>;
139
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000140def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
141 [SDNPHasChain, SDNPOptInFlag]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000142
Evan Chengaed7c722005-12-17 01:24:02 +0000143//===----------------------------------------------------------------------===//
144// X86 Operand Definitions.
145//
146
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000147// *mem - Operand definitions for the funky X86 addressing mode operands.
148//
Evan Chengaf78ef52006-05-17 21:21:41 +0000149class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000150 let PrintMethod = printMethod;
Evan Cheng25ab6902006-09-08 06:48:29 +0000151 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000152}
Nate Begeman391c5d22005-11-30 18:54:35 +0000153
Chris Lattner45432512005-12-17 19:47:05 +0000154def i8mem : X86MemOperand<"printi8mem">;
155def i16mem : X86MemOperand<"printi16mem">;
156def i32mem : X86MemOperand<"printi32mem">;
157def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000158def i128mem : X86MemOperand<"printi128mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000159def f32mem : X86MemOperand<"printf32mem">;
160def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000161def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000162def f128mem : X86MemOperand<"printf128mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000163
Evan Cheng25ab6902006-09-08 06:48:29 +0000164def lea32mem : Operand<i32> {
165 let PrintMethod = "printi32mem";
Evan Cheng25ab6902006-09-08 06:48:29 +0000166 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
167}
168
Nate Begeman16b04f32005-07-15 00:38:55 +0000169def SSECC : Operand<i8> {
170 let PrintMethod = "printSSECC";
171}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000172
Evan Cheng7ccced62006-02-18 00:15:05 +0000173def piclabel: Operand<i32> {
174 let PrintMethod = "printPICLabel";
175}
176
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000177// A couple of more descriptive operand definitions.
178// 16-bits but only 8 bits are significant.
179def i16i8imm : Operand<i16>;
180// 32-bits but only 8 bits are significant.
181def i32i8imm : Operand<i32>;
182
Evan Chengd35b8c12005-12-04 08:19:43 +0000183// Branch targets have OtherVT type.
184def brtarget : Operand<OtherVT>;
185
Evan Chengaed7c722005-12-17 01:24:02 +0000186//===----------------------------------------------------------------------===//
187// X86 Complex Pattern Definitions.
188//
189
Evan Chengec693f72005-12-08 02:01:35 +0000190// Define X86 specific addressing mode.
Evan Chengaf9db752006-10-11 21:03:53 +0000191def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000192def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Evan Chengaf9db752006-10-11 21:03:53 +0000193 [add, mul, shl, or, frameindex], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000194
Evan Chengaed7c722005-12-17 01:24:02 +0000195//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000196// X86 Instruction Predicate Definitions.
Evan Cheng28b514392006-12-05 19:50:18 +0000197def HasMMX : Predicate<"Subtarget->hasMMX()">;
198def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
199def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
200def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000201def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000202def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
203def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000204def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
205def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000206def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
207def In64BitMode : Predicate<"Subtarget->is64Bit()">;
208def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
209def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
210def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000211def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000212
213//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000214// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000215//
216
Evan Chengc64a1a92007-07-31 08:04:03 +0000217include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000218
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000219//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000220// Pattern fragments...
221//
Evan Chengd9558e02006-01-06 00:43:03 +0000222
223// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000224// X86InstrInfo.h. They must be kept in synch.
Evan Chengd9558e02006-01-06 00:43:03 +0000225def X86_COND_A : PatLeaf<(i8 0)>;
226def X86_COND_AE : PatLeaf<(i8 1)>;
227def X86_COND_B : PatLeaf<(i8 2)>;
228def X86_COND_BE : PatLeaf<(i8 3)>;
229def X86_COND_E : PatLeaf<(i8 4)>;
230def X86_COND_G : PatLeaf<(i8 5)>;
231def X86_COND_GE : PatLeaf<(i8 6)>;
232def X86_COND_L : PatLeaf<(i8 7)>;
233def X86_COND_LE : PatLeaf<(i8 8)>;
234def X86_COND_NE : PatLeaf<(i8 9)>;
235def X86_COND_NO : PatLeaf<(i8 10)>;
236def X86_COND_NP : PatLeaf<(i8 11)>;
237def X86_COND_NS : PatLeaf<(i8 12)>;
238def X86_COND_O : PatLeaf<(i8 13)>;
239def X86_COND_P : PatLeaf<(i8 14)>;
240def X86_COND_S : PatLeaf<(i8 15)>;
241
Evan Cheng9b6b6422005-12-13 00:14:11 +0000242def i16immSExt8 : PatLeaf<(i16 imm), [{
243 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000244 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000245 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000246}]>;
247
Evan Cheng9b6b6422005-12-13 00:14:11 +0000248def i32immSExt8 : PatLeaf<(i32 imm), [{
249 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000250 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000251 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Evan Chengb3558542005-12-13 00:01:09 +0000252}]>;
253
Evan Cheng605c4152005-12-13 01:57:51 +0000254// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000255// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
256// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000257def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000258 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman67ca6be2008-08-20 15:24:22 +0000259 ISD::LoadExtType ExtType = LD->getExtensionType();
260 if (ExtType == ISD::NON_EXTLOAD)
261 return true;
262 if (ExtType == ISD::EXTLOAD)
263 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000264 return false;
265}]>;
266
Dan Gohman33586292008-10-15 06:50:19 +0000267def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengca57f782008-09-24 23:27:55 +0000268 LoadSDNode *LD = cast<LoadSDNode>(N);
Evan Chengca57f782008-09-24 23:27:55 +0000269 ISD::LoadExtType ExtType = LD->getExtensionType();
270 if (ExtType == ISD::EXTLOAD)
271 return LD->getAlignment() >= 2 && !LD->isVolatile();
272 return false;
273}]>;
274
Dan Gohman33586292008-10-15 06:50:19 +0000275def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000276 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman67ca6be2008-08-20 15:24:22 +0000277 ISD::LoadExtType ExtType = LD->getExtensionType();
278 if (ExtType == ISD::NON_EXTLOAD)
279 return true;
280 if (ExtType == ISD::EXTLOAD)
281 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000282 return false;
283}]>;
284
Dan Gohman33586292008-10-15 06:50:19 +0000285def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengd47e0b62008-09-29 17:26:18 +0000286 LoadSDNode *LD = cast<LoadSDNode>(N);
287 if (LD->isVolatile())
288 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000289 ISD::LoadExtType ExtType = LD->getExtensionType();
290 if (ExtType == ISD::NON_EXTLOAD)
291 return true;
292 if (ExtType == ISD::EXTLOAD)
293 return LD->getAlignment() >= 4;
294 return false;
295}]>;
296
Evan Cheng7a7e8372005-12-14 02:22:27 +0000297def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Evan Cheng11e15b32006-04-03 20:53:28 +0000298def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000299
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000300def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
301def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen59a58732007-08-05 18:49:15 +0000302def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000303
Evan Cheng466685d2006-10-09 20:57:25 +0000304def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
305def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
306def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000307
Evan Cheng466685d2006-10-09 20:57:25 +0000308def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
309def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
310def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
311def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
312def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
313def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000314
Evan Cheng466685d2006-10-09 20:57:25 +0000315def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
316def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
317def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
318def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
319def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
320def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000321
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000322
323// An 'and' node with a single use.
324def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000325 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000326}]>;
327
Dan Gohman74feef22008-10-17 01:23:35 +0000328// 'shld' and 'shrd' instruction patterns. Note that even though these have
329// the srl and shl in their patterns, the C++ code must still check for them,
330// because predicates are tested before children nodes are explored.
331
332def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
333 (or (srl node:$src1, node:$amt1),
334 (shl node:$src2, node:$amt2)), [{
335 assert(N->getOpcode() == ISD::OR);
336 return N->getOperand(0).getOpcode() == ISD::SRL &&
337 N->getOperand(1).getOpcode() == ISD::SHL &&
338 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
339 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
340 N->getOperand(0).getConstantOperandVal(1) ==
341 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
342}]>;
343
344def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
345 (or (shl node:$src1, node:$amt1),
346 (srl node:$src2, node:$amt2)), [{
347 assert(N->getOpcode() == ISD::OR);
348 return N->getOperand(0).getOpcode() == ISD::SHL &&
349 N->getOperand(1).getOpcode() == ISD::SRL &&
350 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
351 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
352 N->getOperand(0).getConstantOperandVal(1) ==
353 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
354}]>;
355
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000356//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000357// Instruction list...
358//
359
Chris Lattnerf18c0742006-10-12 17:42:56 +0000360// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
361// a stack adjustment and the codegen must know that they may modify the stack
362// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000363// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
364// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000365let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000366def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
367 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000368 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000369 Requires<[In32BitMode]>;
370def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
371 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000372 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000373 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000374}
Evan Cheng4a460802006-01-11 00:33:36 +0000375
376// Nop
Chris Lattnerba7e7562008-01-10 07:59:24 +0000377let neverHasSideEffects = 1 in
378 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Evan Cheng4a460802006-01-11 00:33:36 +0000379
Evan Cheng0475ab52008-01-05 00:41:47 +0000380// PIC base
Dan Gohman2662d552008-10-01 04:14:30 +0000381let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerba7e7562008-01-10 07:59:24 +0000382 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
383 "call\t$label\n\tpop{l}\t$reg", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000384
Chris Lattner1cca5e32003-08-03 21:54:21 +0000385//===----------------------------------------------------------------------===//
386// Control Flow Instructions...
387//
388
Chris Lattner1be48112005-05-13 17:56:48 +0000389// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000390let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000391 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000392 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000393 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000394 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000395 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
396 "ret\t$amt",
Evan Chenge3413162006-01-09 18:33:28 +0000397 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000398}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000399
400// All branches are RawFrm, Void, Branch, and Terminators
Evan Chengffbacca2007-07-21 00:34:19 +0000401let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000402 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
403 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000404
Evan Chengec3bc392006-09-07 19:03:48 +0000405let isBranch = 1, isBarrier = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000406 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000407
Owen Anderson20ab2902007-11-12 07:39:39 +0000408// Indirect branches
409let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000410 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000411 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000412 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000413 [(brind (loadi32 addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000414}
415
416// Conditional branches
Evan Cheng0488db92007-09-25 01:57:46 +0000417let Uses = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000418def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000419 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000420def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000421 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000422def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000423 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000424def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000425 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000426def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000427 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000428def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000429 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000430
Dan Gohmanb1576f52007-07-31 20:11:57 +0000431def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000432 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000433def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000434 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000435def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000436 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000437def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000438 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000439
Dan Gohmanb1576f52007-07-31 20:11:57 +0000440def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000441 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000442def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000443 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000444def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000445 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000446def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000447 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000448def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000449 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000450def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000451 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng0488db92007-09-25 01:57:46 +0000452} // Uses = [EFLAGS]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000453
454//===----------------------------------------------------------------------===//
455// Call Instructions...
456//
Evan Chengffbacca2007-07-21 00:34:19 +0000457let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000458 // All calls clobber the non-callee saved registers. ESP is marked as
459 // a use to prevent stack-pointer assignments that appear immediately
460 // before calls from potentially appearing dead. Uses for argument
461 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000462 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000463 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Dan Gohman2662d552008-10-01 04:14:30 +0000464 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS],
465 Uses = [ESP] in {
Evan Chengf02ca692007-12-22 02:26:46 +0000466 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
467 "call\t${dst:call}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000468 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000469 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000470 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000471 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000472 }
473
Chris Lattner1e9448b2005-05-15 03:10:37 +0000474// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000475
Chris Lattner447ff682008-03-11 03:23:40 +0000476def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000477 "#TAILCALL",
478 []>;
479
Evan Chengffbacca2007-07-21 00:34:19 +0000480let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000481def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000482 "#TC_RETURN $dst $offset",
483 []>;
484
485let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000486def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000487 "#TC_RETURN $dst $offset",
488 []>;
489
490let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer30e62c02008-04-30 09:16:33 +0000491
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000492 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000493 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000494let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000495 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
496 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000497let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000498 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000499 "jmp\t{*}$dst # TAILCALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000500
Chris Lattner1cca5e32003-08-03 21:54:21 +0000501//===----------------------------------------------------------------------===//
502// Miscellaneous Instructions...
503//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000504let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000505def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000506 (outs), (ins), "leave", []>;
507
Chris Lattnerba7e7562008-01-10 07:59:24 +0000508let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
509let mayLoad = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000510def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000511
Chris Lattnerba7e7562008-01-10 07:59:24 +0000512let mayStore = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000513def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000514}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000515
Chris Lattnerba7e7562008-01-10 07:59:24 +0000516let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000517def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000518let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000519def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000520
Evan Cheng069287d2006-05-16 07:21:53 +0000521let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000522 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000523 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000524 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000525 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000526
Chris Lattner1cca5e32003-08-03 21:54:21 +0000527
Evan Cheng18efe262007-12-14 02:13:44 +0000528// Bit scan instructions.
529let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000530def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000531 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000532 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000533def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000534 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000535 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
536 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000537def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000538 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000539 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000540def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000541 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000542 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
543 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000544
Evan Chengfd9e4732007-12-14 18:49:43 +0000545def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000546 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000547 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000548def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000549 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000550 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
551 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000552def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000553 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000554 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000555def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000556 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000557 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
558 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000559} // Defs = [EFLAGS]
560
Chris Lattnerba7e7562008-01-10 07:59:24 +0000561let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000562def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000563 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000564 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000565let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000566def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000567 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000568 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000569 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000570
Evan Cheng071a2792007-09-11 19:55:27 +0000571let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000572def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000573 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000574def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000575 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000576def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000577 [(X86rep_movs i32)]>, REP;
578}
Chris Lattner915e5e52004-02-12 17:53:22 +0000579
Evan Cheng071a2792007-09-11 19:55:27 +0000580let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000581def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000582 [(X86rep_stos i8)]>, REP;
583let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000584def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000585 [(X86rep_stos i16)]>, REP, OpSize;
586let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000587def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000588 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000589
Evan Cheng071a2792007-09-11 19:55:27 +0000590let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000591def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000592 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000593
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000594let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000595def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000596}
597
Chris Lattner1cca5e32003-08-03 21:54:21 +0000598//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000599// Input/Output Instructions...
600//
Evan Cheng071a2792007-09-11 19:55:27 +0000601let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000602def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000603 "in{b}\t{%dx, %al|%AL, %DX}", []>;
604let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000605def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000606 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
607let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000608def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000609 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000610
Evan Cheng071a2792007-09-11 19:55:27 +0000611let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000612def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000613 "in{b}\t{$port, %al|%AL, $port}", []>;
614let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000615def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000616 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
617let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000618def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000619 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000620
Evan Cheng071a2792007-09-11 19:55:27 +0000621let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000622def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000623 "out{b}\t{%al, %dx|%DX, %AL}", []>;
624let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000625def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000626 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
627let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000628def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000629 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000630
Evan Cheng071a2792007-09-11 19:55:27 +0000631let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000632def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000633 "out{b}\t{%al, $port|$port, %AL}", []>;
634let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000635def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000636 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
637let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000638def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000639 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000640
641//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000642// Move Instructions...
643//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000644let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000645def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000646 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000647def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000648 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000649def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000650 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000651}
Evan Cheng359e9372008-06-18 08:13:07 +0000652let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000653def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000654 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000655 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000656def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000657 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000658 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000659def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000660 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000661 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000662}
Evan Cheng64d80e32007-07-19 01:14:50 +0000663def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000664 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000665 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000666def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000667 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000668 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000669def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000670 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000671 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000672
Chris Lattner834f1ce2008-01-06 23:38:27 +0000673let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000674def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000675 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000676 [(set GR8:$dst, (load addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000677def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000678 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000679 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000680def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000681 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000682 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +0000683}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000684
Evan Cheng64d80e32007-07-19 01:14:50 +0000685def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000686 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000687 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000688def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000689 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000690 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000691def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000692 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000693 [(store GR32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000694
Chris Lattner1cca5e32003-08-03 21:54:21 +0000695//===----------------------------------------------------------------------===//
696// Fixed-Register Multiplication and Division Instructions...
697//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000698
Chris Lattnerc8f45872003-08-04 04:59:56 +0000699// Extra precision multiplication
Evan Cheng24f2ea32007-09-14 21:48:26 +0000700let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000701def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000702 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
703 // This probably ought to be moved to a def : Pat<> if the
704 // syntax can be accepted.
Evan Cheng071a2792007-09-11 19:55:27 +0000705 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Chris Lattnera731c9f2008-01-11 07:18:17 +0000706let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000707def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +0000708 OpSize; // AX,DX = AX*GR16
Chris Lattnera731c9f2008-01-11 07:18:17 +0000709let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +0000710def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
711 // EAX,EDX = EAX*GR32
Evan Cheng24f2ea32007-09-14 21:48:26 +0000712let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000713def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000714 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000715 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
716 // This probably ought to be moved to a def : Pat<> if the
717 // syntax can be accepted.
Evan Cheng071a2792007-09-11 19:55:27 +0000718 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000719let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000720let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000721def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000722 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng24f2ea32007-09-14 21:48:26 +0000723let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000724def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000725 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000726}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000727
Chris Lattnerba7e7562008-01-10 07:59:24 +0000728let neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000729let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +0000730def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
731 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +0000732let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000733def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +0000734 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +0000735let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +0000736def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
737 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +0000738let mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000739let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000740def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000741 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +0000742let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000743def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000744 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
745let Defs = [EAX,EDX], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000746def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000747 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000748}
Chris Lattner1e6a7152005-04-06 04:19:22 +0000749
Chris Lattnerc8f45872003-08-04 04:59:56 +0000750// unsigned division/remainder
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000751let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000752def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000753 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000754let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000755def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000756 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000757let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000758def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000759 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000760let mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000761let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000762def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000763 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000764let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000765def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000766 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000767let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000768def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000769 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000770}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000771
Chris Lattnerfc752712004-08-01 09:52:59 +0000772// Signed division/remainder.
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000773let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000774def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000775 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000776let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000777def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000778 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000779let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000780def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000781 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000782let mayLoad = 1, mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000783let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000784def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000785 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000786let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000787def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000788 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000789let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000790def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000791 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000792}
793} // neverHasSideEffects
Chris Lattner1cca5e32003-08-03 21:54:21 +0000794
Chris Lattner1cca5e32003-08-03 21:54:21 +0000795//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000796// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000797//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000798let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000799
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000800// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +0000801let Uses = [EFLAGS] in {
Evan Cheng7ad42d92007-10-05 23:13:21 +0000802let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000803def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000804 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000805 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000806 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000807 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000808 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000809def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000810 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000811 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000812 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000813 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000814 TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000815
Evan Cheng069287d2006-05-16 07:21:53 +0000816def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000817 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000818 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000819 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000820 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000821 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000822def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000823 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000824 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000825 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000826 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000827 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000828def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000829 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000830 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000831 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000832 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000833 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000834def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000835 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000836 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000837 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000838 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000839 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000840def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000841 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000842 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000843 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000844 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000845 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000846def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000847 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000848 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000849 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000850 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000851 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000852def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000853 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000854 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000855 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000856 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000857 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000858def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000859 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000860 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000861 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000862 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000863 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000864def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000865 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000866 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000867 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000868 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000869 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000870def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000871 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000872 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000873 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000874 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000875 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000876def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000877 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000878 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000879 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000880 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000881 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000882def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000883 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000884 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000885 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000886 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000887 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000888def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000889 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000890 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000891 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000892 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000893 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000894def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000895 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000896 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000897 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000898 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000899 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000900def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000901 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000902 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000903 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000904 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000905 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000906def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000907 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000908 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000909 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000910 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000911 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000912def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000913 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000914 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000915 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000916 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000917 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000918def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000919 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000920 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000921 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000922 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000923 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000924def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000925 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000926 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000927 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000928 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000929 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000930def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000931 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000932 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000933 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000934 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000935 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000936def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000937 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000938 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000939 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000940 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000941 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000942def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000943 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000944 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000945 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000946 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000947 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000948def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000949 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000950 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000951 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000952 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000953 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000954def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000955 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000956 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000957 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000958 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000959 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000960def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000961 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000962 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000963 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000964 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000965 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000966def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000967 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000968 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000969 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000970 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000971 TB;
Evan Cheng7ad42d92007-10-05 23:13:21 +0000972} // isCommutable = 1
973
Evan Cheng069287d2006-05-16 07:21:53 +0000974def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Cheng64d80e32007-07-19 01:14:50 +0000975 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000976 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000977 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +0000978 X86_COND_NP, EFLAGS))]>,
979 TB;
Evan Cheng7ad42d92007-10-05 23:13:21 +0000980
981def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
982 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
983 "cmovb\t{$src2, $dst|$dst, $src2}",
984 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
985 X86_COND_B, EFLAGS))]>,
986 TB, OpSize;
987def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
988 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
989 "cmovb\t{$src2, $dst|$dst, $src2}",
990 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
991 X86_COND_B, EFLAGS))]>,
992 TB;
993def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
994 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
995 "cmovae\t{$src2, $dst|$dst, $src2}",
996 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
997 X86_COND_AE, EFLAGS))]>,
998 TB, OpSize;
999def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1000 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1001 "cmovae\t{$src2, $dst|$dst, $src2}",
1002 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1003 X86_COND_AE, EFLAGS))]>,
1004 TB;
1005def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1006 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1007 "cmove\t{$src2, $dst|$dst, $src2}",
1008 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1009 X86_COND_E, EFLAGS))]>,
1010 TB, OpSize;
1011def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1012 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1013 "cmove\t{$src2, $dst|$dst, $src2}",
1014 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1015 X86_COND_E, EFLAGS))]>,
1016 TB;
1017def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1018 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1019 "cmovne\t{$src2, $dst|$dst, $src2}",
1020 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1021 X86_COND_NE, EFLAGS))]>,
1022 TB, OpSize;
1023def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1024 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1025 "cmovne\t{$src2, $dst|$dst, $src2}",
1026 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1027 X86_COND_NE, EFLAGS))]>,
1028 TB;
1029def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1030 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1031 "cmovbe\t{$src2, $dst|$dst, $src2}",
1032 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1033 X86_COND_BE, EFLAGS))]>,
1034 TB, OpSize;
1035def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1036 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1037 "cmovbe\t{$src2, $dst|$dst, $src2}",
1038 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1039 X86_COND_BE, EFLAGS))]>,
1040 TB;
1041def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1042 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1043 "cmova\t{$src2, $dst|$dst, $src2}",
1044 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1045 X86_COND_A, EFLAGS))]>,
1046 TB, OpSize;
1047def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1048 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1049 "cmova\t{$src2, $dst|$dst, $src2}",
1050 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1051 X86_COND_A, EFLAGS))]>,
1052 TB;
1053def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1054 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1055 "cmovl\t{$src2, $dst|$dst, $src2}",
1056 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1057 X86_COND_L, EFLAGS))]>,
1058 TB, OpSize;
1059def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1060 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1061 "cmovl\t{$src2, $dst|$dst, $src2}",
1062 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1063 X86_COND_L, EFLAGS))]>,
1064 TB;
1065def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1066 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1067 "cmovge\t{$src2, $dst|$dst, $src2}",
1068 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1069 X86_COND_GE, EFLAGS))]>,
1070 TB, OpSize;
1071def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1072 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1073 "cmovge\t{$src2, $dst|$dst, $src2}",
1074 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1075 X86_COND_GE, EFLAGS))]>,
1076 TB;
1077def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1078 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1079 "cmovle\t{$src2, $dst|$dst, $src2}",
1080 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1081 X86_COND_LE, EFLAGS))]>,
1082 TB, OpSize;
1083def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1084 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1085 "cmovle\t{$src2, $dst|$dst, $src2}",
1086 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1087 X86_COND_LE, EFLAGS))]>,
1088 TB;
1089def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1090 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1091 "cmovg\t{$src2, $dst|$dst, $src2}",
1092 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1093 X86_COND_G, EFLAGS))]>,
1094 TB, OpSize;
1095def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1096 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1097 "cmovg\t{$src2, $dst|$dst, $src2}",
1098 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1099 X86_COND_G, EFLAGS))]>,
1100 TB;
1101def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1102 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1103 "cmovs\t{$src2, $dst|$dst, $src2}",
1104 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1105 X86_COND_S, EFLAGS))]>,
1106 TB, OpSize;
1107def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1108 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1109 "cmovs\t{$src2, $dst|$dst, $src2}",
1110 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1111 X86_COND_S, EFLAGS))]>,
1112 TB;
1113def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1114 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1115 "cmovns\t{$src2, $dst|$dst, $src2}",
1116 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1117 X86_COND_NS, EFLAGS))]>,
1118 TB, OpSize;
1119def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1120 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1121 "cmovns\t{$src2, $dst|$dst, $src2}",
1122 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1123 X86_COND_NS, EFLAGS))]>,
1124 TB;
1125def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1126 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1127 "cmovp\t{$src2, $dst|$dst, $src2}",
1128 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1129 X86_COND_P, EFLAGS))]>,
1130 TB, OpSize;
1131def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1132 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1133 "cmovp\t{$src2, $dst|$dst, $src2}",
1134 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1135 X86_COND_P, EFLAGS))]>,
1136 TB;
1137def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1138 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1139 "cmovnp\t{$src2, $dst|$dst, $src2}",
1140 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1141 X86_COND_NP, EFLAGS))]>,
1142 TB, OpSize;
Evan Cheng0488db92007-09-25 01:57:46 +00001143} // Uses = [EFLAGS]
1144
1145
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001146// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001147let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001148let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001149def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001150 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001151def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001152 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001153def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001154 [(set GR32:$dst, (ineg GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001155let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001156 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001157 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001158 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001159 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001160 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001161 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1162
Chris Lattner57a02302004-08-11 04:31:00 +00001163}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001164} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001165
Dan Gohmanb1576f52007-07-31 20:11:57 +00001166def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001167 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001168def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001169 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001170def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001171 [(set GR32:$dst, (not GR32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001172let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001173 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001174 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001175 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001176 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001177 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001178 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001179}
Evan Cheng1693e482006-07-19 00:27:29 +00001180} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001181
Evan Chengb51a0592005-12-10 00:48:20 +00001182// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001183let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001184let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001185def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001186 [(set GR8:$dst, (add GR8:$src, 1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001187let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001188def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001189 [(set GR16:$dst, (add GR16:$src, 1))]>,
1190 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001191def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001192 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001193}
Evan Cheng1693e482006-07-19 00:27:29 +00001194let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001195 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001196 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001197 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001198 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1199 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001200 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001201 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1202 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001203}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001204
Evan Cheng1693e482006-07-19 00:27:29 +00001205let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001206def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001207 [(set GR8:$dst, (add GR8:$src, -1))]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001208let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001209def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001210 [(set GR16:$dst, (add GR16:$src, -1))]>,
1211 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001212def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +00001213 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001214}
Chris Lattner57a02302004-08-11 04:31:00 +00001215
Evan Cheng1693e482006-07-19 00:27:29 +00001216let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001217 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001218 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001219 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001220 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1221 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001222 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng66f71632007-10-19 21:23:22 +00001223 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1224 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001225}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001226} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001227
1228// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001229let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001230let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001231def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001232 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001233 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001234 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001235def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001236 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001237 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001238 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001239def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001240 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001241 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001242 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001243}
Chris Lattner57a02302004-08-11 04:31:00 +00001244
Chris Lattner3a173df2004-10-03 20:35:00 +00001245def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001246 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001247 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001248 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001249def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001250 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001251 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001252 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001253def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001254 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001255 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001256 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001257
Chris Lattner3a173df2004-10-03 20:35:00 +00001258def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001259 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001260 "and{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001261 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001262def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001263 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001264 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001265 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001266def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001267 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001268 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001269 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001270def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001271 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001272 "and{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001273 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001274 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001275def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001276 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001277 "and{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001278 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001279
1280let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001281 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001282 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001283 "and{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001284 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001285 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001286 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001287 "and{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001288 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001289 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001290 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001291 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001292 "and{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001293 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001294 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001295 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001296 "and{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001297 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001298 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001299 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001300 "and{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001301 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001302 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001303 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001304 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001305 "and{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001306 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001307 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001308 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001309 "and{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001310 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1311 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001312 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001313 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001314 "and{l}\t{$src, $dst|$dst, $src}",
Evan Chenge3703d42006-01-14 01:18:49 +00001315 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001316}
1317
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001318
Chris Lattnercc65bee2005-01-02 02:35:46 +00001319let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001320def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001321 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001322 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001323def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001324 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001325 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001326def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001327 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001328 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001329}
Evan Cheng64d80e32007-07-19 01:14:50 +00001330def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001331 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001332 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001333def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001334 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001335 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001336def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001337 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001338 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001339
Evan Cheng64d80e32007-07-19 01:14:50 +00001340def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001341 "or{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001342 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001343def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001344 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001345 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001346def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001347 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001348 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001349
Evan Cheng64d80e32007-07-19 01:14:50 +00001350def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001351 "or{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001352 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001353def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001354 "or{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001355 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001356let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001357 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001358 "or{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001359 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001360 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001361 "or{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001362 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001363 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001364 "or{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001365 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001366 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001367 "or{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001368 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001369 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001370 "or{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001371 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001372 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001373 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001374 "or{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001375 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001376 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001377 "or{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001378 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1379 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001380 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001381 "or{l}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001382 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001383} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001384
1385
Evan Cheng359e9372008-06-18 08:13:07 +00001386let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001387 def XOR8rr : I<0x30, MRMDestReg,
1388 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1389 "xor{b}\t{$src2, $dst|$dst, $src2}",
1390 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1391 def XOR16rr : I<0x31, MRMDestReg,
1392 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1393 "xor{w}\t{$src2, $dst|$dst, $src2}",
1394 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1395 def XOR32rr : I<0x31, MRMDestReg,
1396 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1397 "xor{l}\t{$src2, $dst|$dst, $src2}",
1398 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng359e9372008-06-18 08:13:07 +00001399} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00001400
Chris Lattner3a173df2004-10-03 20:35:00 +00001401def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001402 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001403 "xor{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001404 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001405def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001406 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001407 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001408 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1409 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001410def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001411 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001412 "xor{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001413 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001414
Bill Wendling75cf88f2008-05-29 03:46:36 +00001415def XOR8ri : Ii8<0x80, MRM6r,
1416 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1417 "xor{b}\t{$src2, $dst|$dst, $src2}",
1418 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1419def XOR16ri : Ii16<0x81, MRM6r,
1420 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1421 "xor{w}\t{$src2, $dst|$dst, $src2}",
1422 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1423def XOR32ri : Ii32<0x81, MRM6r,
1424 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1425 "xor{l}\t{$src2, $dst|$dst, $src2}",
1426 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1427def XOR16ri8 : Ii8<0x83, MRM6r,
1428 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1429 "xor{w}\t{$src2, $dst|$dst, $src2}",
1430 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1431 OpSize;
1432def XOR32ri8 : Ii8<0x83, MRM6r,
1433 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1434 "xor{l}\t{$src2, $dst|$dst, $src2}",
1435 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001436
Chris Lattner57a02302004-08-11 04:31:00 +00001437let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001438 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001439 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001440 "xor{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001441 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001442 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001443 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001444 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001445 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001446 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001447 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001448 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001449 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00001450 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001451 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001452 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001453 "xor{b}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001454 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001455 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001456 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001457 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001458 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001459 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001460 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001461 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001462 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001463 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001464 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001465 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001466 "xor{w}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001467 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1468 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001469 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001470 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001471 "xor{l}\t{$src, $dst|$dst, $src}",
Evan Cheng0ef3a772005-12-13 01:41:36 +00001472 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001473} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00001474} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001475
1476// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00001477let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00001478let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001479def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001480 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001481 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001482def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001483 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001484 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001485def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001486 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001487 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001488} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00001489
Evan Cheng64d80e32007-07-19 01:14:50 +00001490def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001491 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001492 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001493let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001494def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001495 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001496 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001497def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001498 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001499 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf9b3f372008-01-11 18:00:50 +00001500// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1501// cheaper.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001502} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00001503
Chris Lattnerf29ed092004-08-11 05:07:25 +00001504let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001505 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001506 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001507 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001508 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001509 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001510 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001511 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001512 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001513 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001514 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1515 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001516 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001517 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001518 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001519 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001520 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001521 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1522 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001523 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001524 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001525 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001526
1527 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001528 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001529 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001530 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001531 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001532 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001533 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1534 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001535 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001536 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001537 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001538}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001539
Evan Cheng071a2792007-09-11 19:55:27 +00001540let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001541def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001542 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001543 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001544def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001545 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001546 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001547def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001548 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001549 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1550}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001551
Evan Cheng64d80e32007-07-19 01:14:50 +00001552def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001553 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001554 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001555def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001556 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001557 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001558def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001559 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001560 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001561
Evan Cheng09c54572006-06-29 00:36:51 +00001562// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001563def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001564 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001565 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001566def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001567 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001568 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001569def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001570 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001571 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1572
Chris Lattner57a02302004-08-11 04:31:00 +00001573let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001574 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001575 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001576 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001577 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001578 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001579 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001580 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001581 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001582 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001583 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001584 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1585 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001586 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001587 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001588 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001589 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001590 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001591 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1592 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001593 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001594 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001595 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001596
1597 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001598 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001599 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001600 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001601 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001602 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001603 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001604 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001605 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001606 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001607}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001608
Evan Cheng071a2792007-09-11 19:55:27 +00001609let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001610def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001611 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001612 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001613def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001614 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001615 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001616def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001617 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001618 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1619}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001620
Evan Cheng64d80e32007-07-19 01:14:50 +00001621def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001622 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001623 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001624def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001625 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001626 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001627 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001628def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001629 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001630 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001631
1632// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001633def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001634 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001635 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001636def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001637 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001638 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001639def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001640 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001641 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1642
Chris Lattnerf29ed092004-08-11 05:07:25 +00001643let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001644 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001645 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001646 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001647 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001648 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001649 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001650 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001651 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001652 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001653 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1654 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001655 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001656 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001657 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001658 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001659 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001660 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1661 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001662 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001663 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001664 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001665
1666 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001667 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001668 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001669 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001670 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001671 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001672 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1673 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001674 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001675 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001676 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001677}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001678
Chris Lattner40ff6332005-01-19 07:50:03 +00001679// Rotate instructions
1680// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00001681let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001682def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001683 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001684 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001685def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001686 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001687 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001688def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001689 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001690 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1691}
Chris Lattner40ff6332005-01-19 07:50:03 +00001692
Evan Cheng64d80e32007-07-19 01:14:50 +00001693def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001694 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001695 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001696def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001697 "rol{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001698 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001699def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001700 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001701 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001702
Evan Cheng09c54572006-06-29 00:36:51 +00001703// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001704def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001705 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001706 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001707def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001708 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001709 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001710def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001711 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001712 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1713
Chris Lattner40ff6332005-01-19 07:50:03 +00001714let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001715 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001716 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001717 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001718 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001719 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001720 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001721 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001722 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001723 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001724 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1725 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001726 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001727 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001728 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001729 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001730 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001731 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1732 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001733 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001734 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001735 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001736
1737 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001738 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001739 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001740 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001741 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001742 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001743 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1744 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001745 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001746 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001747 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001748}
1749
Evan Cheng071a2792007-09-11 19:55:27 +00001750let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001751def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001752 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001753 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001754def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001755 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001756 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001757def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001758 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001759 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1760}
Chris Lattner40ff6332005-01-19 07:50:03 +00001761
Evan Cheng64d80e32007-07-19 01:14:50 +00001762def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001763 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001764 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001765def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001766 "ror{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001767 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001768def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001769 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001770 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001771
1772// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001773def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001774 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001775 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001776def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001777 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001778 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001779def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001780 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001781 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1782
Chris Lattner40ff6332005-01-19 07:50:03 +00001783let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001784 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001785 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001786 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001787 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001788 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001789 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001790 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001791 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001792 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001793 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1794 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001795 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001796 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001797 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001798 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001799 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001800 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1801 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001802 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001803 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001804 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001805
1806 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001807 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001808 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001809 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001810 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001811 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001812 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1813 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001814 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001815 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001816 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001817}
1818
1819
1820
1821// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00001822let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001823def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001824 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001825 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001826def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001827 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001828 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001829def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001830 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001831 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001832 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001833def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001834 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001835 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001836 TB, OpSize;
1837}
Chris Lattner41e431b2005-01-19 07:11:01 +00001838
1839let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001840def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001841 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001842 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001843 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001844 (i8 imm:$src3)))]>,
1845 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001846def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001847 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001848 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001849 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001850 (i8 imm:$src3)))]>,
1851 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001852def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001853 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001854 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001855 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001856 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001857 TB, OpSize;
1858def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001859 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001860 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001861 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001862 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001863 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001864}
Chris Lattner0e967d42004-08-01 08:13:11 +00001865
Chris Lattner57a02302004-08-11 04:31:00 +00001866let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001867 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001868 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001869 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001870 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001871 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00001872 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001873 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001874 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001875 addr:$dst)]>, TB;
1876 }
Chris Lattner3a173df2004-10-03 20:35:00 +00001877 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001878 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001879 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001880 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001881 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001882 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001883 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001884 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001885 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001886 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001887 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001888 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001889
Evan Cheng071a2792007-09-11 19:55:27 +00001890 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001891 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001892 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001893 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001894 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001895 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001896 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00001897 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00001898 addr:$dst)]>, TB, OpSize;
1899 }
Chris Lattner0df53d22005-01-19 07:31:24 +00001900 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001901 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001902 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001903 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001904 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001905 TB, OpSize;
1906 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001907 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001908 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00001909 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00001910 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001911 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001912}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001913} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001914
1915
Chris Lattnercc65bee2005-01-02 02:35:46 +00001916// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001917let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001918let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng071a2792007-09-11 19:55:27 +00001919def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1920 (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001921 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001922 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001923let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng071a2792007-09-11 19:55:27 +00001924def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1925 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001926 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001927 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00001928def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1929 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001930 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001931 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001932} // end isConvertibleToThreeAddress
1933} // end isCommutable
Evan Cheng071a2792007-09-11 19:55:27 +00001934def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1935 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001936 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001937 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00001938def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1939 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001940 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng071a2792007-09-11 19:55:27 +00001941 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1942def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1943 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001944 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001945 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001946
Evan Cheng64d80e32007-07-19 01:14:50 +00001947def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001948 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001949 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001950
1951let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng071a2792007-09-11 19:55:27 +00001952def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1953 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001954 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001955 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00001956def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1957 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001958 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001959 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng071a2792007-09-11 19:55:27 +00001960def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1961 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001962 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng071a2792007-09-11 19:55:27 +00001963 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1964def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1965 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001966 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng071a2792007-09-11 19:55:27 +00001967 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00001968}
Chris Lattner57a02302004-08-11 04:31:00 +00001969
1970let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001971 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001972 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001973 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001974 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001975 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001976 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00001977 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001978 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001979 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001980 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001981 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001982 "add{b}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001983 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001984 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001985 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001986 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00001987 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001988 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001989 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001990 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001991 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001992 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001993 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00001994 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001995 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001996 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001997 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001998}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001999
Evan Cheng3154cb62007-10-05 17:59:57 +00002000let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002001let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00002002def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002003 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002004 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002005}
Evan Cheng64d80e32007-07-19 01:14:50 +00002006def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002007 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002008 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002009def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002010 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002011 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002012def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002013 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002014 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002015
2016let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002017 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002018 "adc{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002019 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002020 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002021 "adc{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002022 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002023 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002024 "adc{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002025 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002026}
Evan Cheng3154cb62007-10-05 17:59:57 +00002027} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002028
Evan Cheng64d80e32007-07-19 01:14:50 +00002029def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002030 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002031 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002032def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002033 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002034 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002035def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002036 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002037 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002038def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002039 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002040 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002041def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002042 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002043 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002044def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002045 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002046 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002047
Evan Cheng64d80e32007-07-19 01:14:50 +00002048def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002049 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002050 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002051def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002052 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002053 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002054def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002055 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002056 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002057def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002058 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002059 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00002060 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002061def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002062 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002063 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002064let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002065 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002066 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002067 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002068 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002069 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002070 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00002071 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002072 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002073 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002074 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002075 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002076 "sub{b}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00002077 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002078 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002079 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00002080 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00002081 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002082 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002083 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00002084 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002085 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002086 "sub{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00002087 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng24f2ea32007-09-14 21:48:26 +00002088 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002089 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002090 "sub{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00002091 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002092}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002093
Evan Cheng3154cb62007-10-05 17:59:57 +00002094let Uses = [EFLAGS] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002095def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002096 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng24f2ea32007-09-14 21:48:26 +00002097 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00002098
Chris Lattner57a02302004-08-11 04:31:00 +00002099let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002100 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002101 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002102 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002103 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002104 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002105 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002106 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002107 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Nate Begeman551bf3f2006-02-17 05:43:56 +00002108 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002109 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002110 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng24f2ea32007-09-14 21:48:26 +00002111 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002112}
Evan Cheng64d80e32007-07-19 01:14:50 +00002113def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002114 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002115 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002116def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002117 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002118 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002119def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002120 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002121 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00002122} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00002123} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002124
Evan Cheng24f2ea32007-09-14 21:48:26 +00002125let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002126let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00002127def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002128 "imul{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002129 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002130def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002131 "imul{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002132 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002133}
Evan Cheng64d80e32007-07-19 01:14:50 +00002134def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002135 "imul{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002136 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002137 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002138def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002139 "imul{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002140 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002141} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002142} // end Two Address instructions
2143
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002144// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00002145let Defs = [EFLAGS] in {
Evan Cheng069287d2006-05-16 07:21:53 +00002146def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002147 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002148 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002149 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2150def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002151 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002152 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002153 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2154def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002155 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002156 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002157 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002158 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002159def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002160 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002161 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002162 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002163
Evan Cheng069287d2006-05-16 07:21:53 +00002164def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002165 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002166 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002167 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
Evan Chengf281e022005-12-12 23:47:46 +00002168 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002169def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002170 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002171 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002172 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2173def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002174 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002175 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002176 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00002177 OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002178def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002179 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002180 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002181 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002182} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002183
2184//===----------------------------------------------------------------------===//
2185// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002186//
Evan Cheng0488db92007-09-25 01:57:46 +00002187let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002188let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng64d80e32007-07-19 01:14:50 +00002189def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002190 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002191 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002192 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002193def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002194 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002195 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002196 (implicit EFLAGS)]>,
2197 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002198def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002199 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002200 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002201 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002202}
Evan Cheng734503b2006-09-11 02:19:56 +00002203
Evan Cheng64d80e32007-07-19 01:14:50 +00002204def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002205 "test{b}\t{$src2, $src1|$src1, $src2}",
2206 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2207 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002208def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002209 "test{w}\t{$src2, $src1|$src1, $src2}",
2210 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2211 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002212def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002213 "test{l}\t{$src2, $src1|$src1, $src2}",
2214 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2215 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002216
Evan Cheng069287d2006-05-16 07:21:53 +00002217def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002218 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002219 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002220 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002221 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002222def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002223 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002224 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002225 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002226 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002227def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002228 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002229 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002230 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002231 (implicit EFLAGS)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002232
Evan Chenge5f62042007-09-29 00:00:36 +00002233def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002234 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002235 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002236 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2237 (implicit EFLAGS)]>;
2238def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002239 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002240 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002241 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2242 (implicit EFLAGS)]>, OpSize;
2243def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002244 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002245 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002246 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng0488db92007-09-25 01:57:46 +00002247 (implicit EFLAGS)]>;
2248} // Defs = [EFLAGS]
2249
2250
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002251// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00002252let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002253def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00002254let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002255def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002256
Evan Cheng0488db92007-09-25 01:57:46 +00002257let Uses = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002258def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002259 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002260 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002261 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002262 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002263def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002264 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002265 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002266 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002267 TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002268def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002269 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002270 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002271 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002272 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002273def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002274 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002275 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002276 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002277 TB; // [mem8] = !=
2278def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002279 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002280 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002281 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002282 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002283def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002284 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002285 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002286 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002287 TB; // [mem8] = < signed
2288def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002289 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002290 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002291 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002292 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002293def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002294 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002295 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002296 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002297 TB; // [mem8] = >= signed
2298def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002299 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002300 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002301 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002302 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002303def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002304 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002305 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002306 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002307 TB; // [mem8] = <= signed
2308def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002309 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002310 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002311 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002312 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002313def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002314 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002315 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002316 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002317 TB; // [mem8] = > signed
2318
2319def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002320 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002321 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002322 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002323 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002324def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002325 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002326 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002327 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002328 TB; // [mem8] = < unsign
2329def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002330 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002331 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002332 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002333 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002334def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002335 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002336 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002337 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002338 TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002339def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002340 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002341 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002342 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002343 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002344def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002345 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002346 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002347 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002348 TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002349def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002350 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002351 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002352 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002353 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002354def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002355 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002356 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002357 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002358 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002359
Chris Lattner3a173df2004-10-03 20:35:00 +00002360def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002361 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002362 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002363 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002364 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002365def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002366 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002367 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002368 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002369 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002370def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002371 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002372 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002373 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002374 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002375def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002376 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002377 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002378 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002379 TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002380def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002381 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002382 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002383 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002384 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002385def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002386 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002387 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002388 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002389 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002390def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002391 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002392 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002393 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002394 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002395def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002396 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002397 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002398 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002399 TB; // [mem8] = not parity
Evan Cheng0488db92007-09-25 01:57:46 +00002400} // Uses = [EFLAGS]
2401
Chris Lattner1cca5e32003-08-03 21:54:21 +00002402
2403// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00002404let Defs = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002405def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002406 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002407 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002408 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002409def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002410 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002411 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002412 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002413def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002414 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002415 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002416 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002417def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002418 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002419 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002420 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2421 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002422def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002423 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002424 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002425 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2426 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002427def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002428 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002429 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002430 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2431 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002432def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002433 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002434 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002435 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2436 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002437def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002438 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002439 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002440 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2441 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002442def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002443 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002444 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002445 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2446 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002447def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002448 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002449 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002450 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002451def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002452 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002453 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002454 [(X86cmp GR16:$src1, imm:$src2),
2455 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002456def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002457 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002458 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002459 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002460def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002461 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002462 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002463 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2464 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002465def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002466 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002467 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002468 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2469 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002470def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002471 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002472 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002473 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2474 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002475def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002476 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002477 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002478 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2479 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002480def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002481 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002482 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002483 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2484 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002485def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002486 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002487 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002488 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2489 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002490def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002491 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002492 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002493 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00002494 (implicit EFLAGS)]>;
2495} // Defs = [EFLAGS]
2496
Chris Lattner1cca5e32003-08-03 21:54:21 +00002497// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00002498// Use movsbl intead of movsbw; we don't care about the high 16 bits
2499// of the register here. This has a smaller encoding and avoids a
2500// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002501def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002502 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2503 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002504def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002505 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2506 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002507def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002508 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002509 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002510def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002511 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002512 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002513def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002514 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002515 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002516def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002517 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002518 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00002519
Dan Gohman11ba3b12008-07-30 18:09:17 +00002520// Use movzbl intead of movzbw; we don't care about the high 16 bits
2521// of the register here. This has a smaller encoding and avoids a
2522// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002523def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002524 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2525 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002526def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002527 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2528 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002529def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002530 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002531 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002532def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002533 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002534 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002535def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002536 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002537 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002538def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002539 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00002540 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00002541
Chris Lattnerba7e7562008-01-10 07:59:24 +00002542let neverHasSideEffects = 1 in {
2543 let Defs = [AX], Uses = [AL] in
2544 def CBW : I<0x98, RawFrm, (outs), (ins),
2545 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2546 let Defs = [EAX], Uses = [AX] in
2547 def CWDE : I<0x98, RawFrm, (outs), (ins),
2548 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00002549
Chris Lattnerba7e7562008-01-10 07:59:24 +00002550 let Defs = [AX,DX], Uses = [AX] in
2551 def CWD : I<0x99, RawFrm, (outs), (ins),
2552 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2553 let Defs = [EAX,EDX], Uses = [EAX] in
2554 def CDQ : I<0x99, RawFrm, (outs), (ins),
2555 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2556}
Evan Cheng747a90d2006-02-21 02:24:38 +00002557
Evan Cheng747a90d2006-02-21 02:24:38 +00002558//===----------------------------------------------------------------------===//
2559// Alias Instructions
2560//===----------------------------------------------------------------------===//
2561
2562// Alias instructions that map movr0 to xor.
2563// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00002564let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002565def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002566 "xor{b}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002567 [(set GR8:$dst, 0)]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00002568// Use xorl instead of xorw since we don't care about the high 16 bits,
2569// it's smaller, and it avoids a partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00002570def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman11ba3b12008-07-30 18:09:17 +00002571 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2572 [(set GR16:$dst, 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002573def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002574 "xor{l}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00002575 [(set GR32:$dst, 0)]>;
Dan Gohman1ab79892007-09-07 21:32:51 +00002576}
Evan Cheng747a90d2006-02-21 02:24:38 +00002577
Evan Cheng069287d2006-05-16 07:21:53 +00002578// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2579// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerba7e7562008-01-10 07:59:24 +00002580let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002581def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002582 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002583def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002584 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002585
Evan Cheng64d80e32007-07-19 01:14:50 +00002586def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002587 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002588def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002589 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002590} // neverHasSideEffects
2591
2592let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002593def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002594 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002595def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002596 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng2f394262007-08-30 05:49:43 +00002597}
Chris Lattnerba7e7562008-01-10 07:59:24 +00002598let mayStore = 1, neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002599def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002600 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002601def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002602 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +00002603}
Evan Cheng403be7e2006-05-08 08:01:26 +00002604
Evan Cheng510e4782006-01-09 23:10:28 +00002605//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002606// Thread Local Storage Instructions
2607//
2608
Evan Cheng071a2792007-09-11 19:55:27 +00002609let Uses = [EBX] in
Anton Korobeynikov6625eff2008-05-04 21:36:32 +00002610def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2611 "leal\t${sym:mem}(,%ebx,1), $dst",
2612 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002613
Lauro Ramos Venancio7d2cc2b2007-04-22 22:50:52 +00002614let AddedComplexity = 10 in
Anton Korobeynikov6625eff2008-05-04 21:36:32 +00002615def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002616 "movl\t%gs:($src), $dst",
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002617 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2618
2619let AddedComplexity = 15 in
Evan Cheng64d80e32007-07-19 01:14:50 +00002620def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002621 "movl\t%gs:${src:mem}, $dst",
Lauro Ramos Venancioede1d782007-04-23 01:28:10 +00002622 [(set GR32:$dst,
2623 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
Lauro Ramos Venancio7d2cc2b2007-04-22 22:50:52 +00002624
Evan Cheng64d80e32007-07-19 01:14:50 +00002625def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002626 "movl\t%gs:0, $dst",
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00002627 [(set GR32:$dst, X86TLStp)]>;
2628
2629//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00002630// DWARF Pseudo Instructions
2631//
2632
Evan Cheng64d80e32007-07-19 01:14:50 +00002633def DWARF_LOC : I<0, Pseudo, (outs),
2634 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman6b5766e2007-09-24 19:25:06 +00002635 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Evan Cheng3c992d22006-03-07 02:02:57 +00002636 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2637 (i32 imm:$file))]>;
2638
Evan Cheng3c992d22006-03-07 02:02:57 +00002639//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00002640// EH Pseudo Instructions
2641//
2642let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Chengffbacca2007-07-21 00:34:19 +00002643 hasCtrlDep = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002644def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002645 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00002646 [(X86ehret GR32:$addr)]>;
2647
2648}
2649
2650//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00002651// Atomic support
2652//
Andrew Lenharthea7da502008-03-01 13:37:02 +00002653
Evan Chengbb6939d2008-04-19 01:20:30 +00002654// Atomic swap. These are just normal xchg instructions. But since a memory
2655// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00002656let Constraints = "$val = $dst" in {
Evan Chengbb6939d2008-04-19 01:20:30 +00002657def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2658 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2659 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2660def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2661 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2662 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2663 OpSize;
2664def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2665 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2666 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2667}
2668
Evan Cheng7e032802008-04-18 20:55:36 +00002669// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002670let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002671def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002672 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002673 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002674}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002675let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovf88a6fa2008-07-22 16:22:48 +00002676def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002677 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00002678 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2679}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002680
2681let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002682def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002683 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002684 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002685}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00002686let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00002687def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002688 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00002689 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002690}
2691
Evan Cheng7e032802008-04-18 20:55:36 +00002692// Atomic exchange and add
2693let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2694def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002695 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00002696 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00002697 TB, LOCK;
2698def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002699 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00002700 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00002701 TB, OpSize, LOCK;
2702def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesen140be2d2008-08-19 18:47:28 +00002703 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00002704 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00002705 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00002706}
2707
Mon P Wang28873102008-06-25 08:15:39 +00002708// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00002709let Constraints = "$val = $dst", Defs = [EFLAGS],
2710 usesCustomDAGSchedInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00002711def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002712 "#ATOMAND32 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002713 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002714def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002715 "#ATOMOR32 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002716 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002717def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002718 "#ATOMXOR32 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002719 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00002720def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang28873102008-06-25 08:15:39 +00002721 "#ATOMNAND32 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002722 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002723def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002724 "#ATOMMIN32 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002725 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002726def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002727 "#ATOMMAX32 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002728 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002729def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002730 "#ATOMUMIN32 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002731 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00002732def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang63307c32008-05-05 19:05:59 +00002733 "#ATOMUMAX32 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002734 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002735
2736def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2737 "#ATOMAND16 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002738 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002739def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2740 "#ATOMOR16 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002741 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002742def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2743 "#ATOMXOR16 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002744 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002745def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2746 "#ATOMNAND16 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002747 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002748def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2749 "#ATOMMIN16 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002750 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002751def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2752 "#ATOMMAX16 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002753 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002754def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2755 "#ATOMUMIN16 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002756 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002757def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2758 "#ATOMUMAX16 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002759 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002760
2761def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2762 "#ATOMAND8 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002763 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002764def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2765 "#ATOMOR8 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002766 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002767def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2768 "#ATOMXOR8 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002769 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00002770def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2771 "#ATOMNAND8 PSUEDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00002772 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00002773}
2774
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002775let Constraints = "$val1 = $dst1, $val2 = $dst2",
2776 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
2777 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00002778 mayLoad = 1, mayStore = 1,
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002779 usesCustomDAGSchedInserter = 1 in {
2780def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2781 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2782 "#ATOMAND6432 PSUEDO!", []>;
2783def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2784 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2785 "#ATOMOR6432 PSUEDO!", []>;
2786def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2787 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2788 "#ATOMXOR6432 PSUEDO!", []>;
2789def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2790 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2791 "#ATOMNAND6432 PSUEDO!", []>;
2792def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2793 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2794 "#ATOMADD6432 PSUEDO!", []>;
2795def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2796 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2797 "#ATOMSUB6432 PSUEDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00002798def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2799 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2800 "#ATOMSWAP6432 PSUEDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00002801}
2802
Andrew Lenharthab0b9492008-02-21 06:45:13 +00002803//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00002804// Non-Instruction Patterns
2805//===----------------------------------------------------------------------===//
2806
Bill Wendling056292f2008-09-16 21:48:12 +00002807// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00002808def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00002809def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00002810def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002811def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2812def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2813
Evan Cheng069287d2006-05-16 07:21:53 +00002814def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2815 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2816def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2817 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2818def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2819 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2820def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2821 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00002822
Evan Chengfc8feb12006-05-19 07:30:36 +00002823def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002824 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00002825def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00002826 (MOV32mi addr:$dst, texternalsym:$src)>;
2827
Evan Cheng510e4782006-01-09 23:10:28 +00002828// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002829// tailcall stuff
Evan Cheng069287d2006-05-16 07:21:53 +00002830def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002831 (TAILCALL)>;
Evan Chengfea89c12006-04-27 08:40:39 +00002832
Evan Cheng25ab6902006-09-08 06:48:29 +00002833def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002834 (TAILCALL)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002835def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00002836 (TAILCALL)>;
2837
2838def : Pat<(X86tcret GR32:$dst, imm:$off),
2839 (TCRETURNri GR32:$dst, imm:$off)>;
2840
2841def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2842 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2843
2844def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2845 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Evan Chengfea89c12006-04-27 08:40:39 +00002846
Evan Cheng25ab6902006-09-08 06:48:29 +00002847def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00002848 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00002849def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00002850 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002851
2852// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00002853def : Pat<(addc GR32:$src1, GR32:$src2),
2854 (ADD32rr GR32:$src1, GR32:$src2)>;
2855def : Pat<(addc GR32:$src1, (load addr:$src2)),
2856 (ADD32rm GR32:$src1, addr:$src2)>;
2857def : Pat<(addc GR32:$src1, imm:$src2),
2858 (ADD32ri GR32:$src1, imm:$src2)>;
2859def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2860 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002861
Evan Cheng069287d2006-05-16 07:21:53 +00002862def : Pat<(subc GR32:$src1, GR32:$src2),
2863 (SUB32rr GR32:$src1, GR32:$src2)>;
2864def : Pat<(subc GR32:$src1, (load addr:$src2)),
2865 (SUB32rm GR32:$src1, addr:$src2)>;
2866def : Pat<(subc GR32:$src1, imm:$src2),
2867 (SUB32ri GR32:$src1, imm:$src2)>;
2868def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2869 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002870
Chris Lattnerffc0b262006-09-07 20:33:45 +00002871// Comparisons.
2872
2873// TEST R,R is smaller than CMP R,0
Evan Chenge5f62042007-09-29 00:00:36 +00002874def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00002875 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00002876def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00002877 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00002878def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00002879 (TEST32rr GR32:$src1, GR32:$src1)>;
2880
Duncan Sandsf9c98e62008-01-23 20:39:46 +00002881// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00002882def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002883def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2884def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2885
2886// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00002887def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00002888def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
2889 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00002890def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00002891def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
2892 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00002893def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2894def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002895
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00002896// anyext
Bill Wendling449416d2008-08-22 20:51:05 +00002897def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
2898 Requires<[In32BitMode]>;
2899def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
2900 Requires<[In32BitMode]>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00002901def : Pat<(i32 (anyext GR16:$src)),
2902 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Evan Cheng510e4782006-01-09 23:10:28 +00002903
Evan Cheng1314b002007-12-13 00:43:27 +00002904// (and (i32 load), 255) -> (zextload i8)
Evan Chengd47e0b62008-09-29 17:26:18 +00002905def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
2906 (MOVZX32rm8 addr:$src)>;
2907def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
2908 (MOVZX32rm16 addr:$src)>;
Evan Cheng1314b002007-12-13 00:43:27 +00002909
Evan Chengcfa260b2006-01-06 02:31:59 +00002910//===----------------------------------------------------------------------===//
2911// Some peepholes
2912//===----------------------------------------------------------------------===//
2913
Dan Gohman11ba3b12008-07-30 18:09:17 +00002914// r & (2^16-1) ==> movz
2915def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00002916 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00002917// r & (2^8-1) ==> movz
2918def : Pat<(and GR32:$src1, 0xff),
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00002919 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
2920 x86_subreg_8bit)))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00002921 Requires<[In32BitMode]>;
2922// r & (2^8-1) ==> movz
2923def : Pat<(and GR16:$src1, 0xff),
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00002924 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
2925 x86_subreg_8bit)))>,
2926 Requires<[In32BitMode]>;
2927
2928// sext_inreg patterns
2929def : Pat<(sext_inreg GR32:$src, i16),
2930 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
2931def : Pat<(sext_inreg GR32:$src, i8),
2932 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
2933 x86_subreg_8bit)))>,
2934 Requires<[In32BitMode]>;
2935def : Pat<(sext_inreg GR16:$src, i8),
2936 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
2937 x86_subreg_8bit)))>,
2938 Requires<[In32BitMode]>;
2939
2940// trunc patterns
2941def : Pat<(i16 (trunc GR32:$src)),
2942 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
2943def : Pat<(i8 (trunc GR32:$src)),
2944 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
2945 Requires<[In32BitMode]>;
2946def : Pat<(i8 (trunc GR16:$src)),
2947 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00002948 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00002949
Evan Chengcfa260b2006-01-06 02:31:59 +00002950// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00002951def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2952def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2953def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002954
Evan Chengeb9f8922008-08-30 02:03:58 +00002955// (shl x (and y, 31)) ==> (shl x, y)
2956def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
2957 (SHL8rCL GR8:$src1)>;
2958def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
2959 (SHL16rCL GR16:$src1)>;
2960def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
2961 (SHL32rCL GR32:$src1)>;
2962def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2963 (SHL8mCL addr:$dst)>;
2964def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2965 (SHL16mCL addr:$dst)>;
2966def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2967 (SHL32mCL addr:$dst)>;
2968
2969def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
2970 (SHR8rCL GR8:$src1)>;
2971def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
2972 (SHR16rCL GR16:$src1)>;
2973def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
2974 (SHR32rCL GR32:$src1)>;
2975def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2976 (SHR8mCL addr:$dst)>;
2977def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2978 (SHR16mCL addr:$dst)>;
2979def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2980 (SHR32mCL addr:$dst)>;
2981
2982def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
2983 (SAR8rCL GR8:$src1)>;
2984def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
2985 (SAR16rCL GR16:$src1)>;
2986def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
2987 (SAR32rCL GR32:$src1)>;
2988def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2989 (SAR8mCL addr:$dst)>;
2990def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2991 (SAR16mCL addr:$dst)>;
2992def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2993 (SAR32mCL addr:$dst)>;
2994
Evan Cheng956044c2006-01-19 23:26:24 +00002995// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00002996def : Pat<(or (srl GR32:$src1, CL:$amt),
2997 (shl GR32:$src2, (sub 32, CL:$amt))),
2998 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00002999
Evan Cheng21d54432006-01-20 01:13:30 +00003000def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003001 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3002 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003003
Dan Gohman74feef22008-10-17 01:23:35 +00003004def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3005 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3006 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3007
3008def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3009 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3010 addr:$dst),
3011 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3012
3013def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3014 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3015
3016def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3017 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3018 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3019
Evan Cheng956044c2006-01-19 23:26:24 +00003020// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003021def : Pat<(or (shl GR32:$src1, CL:$amt),
3022 (srl GR32:$src2, (sub 32, CL:$amt))),
3023 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003024
Evan Cheng21d54432006-01-20 01:13:30 +00003025def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003026 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3027 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003028
Dan Gohman74feef22008-10-17 01:23:35 +00003029def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3030 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3031 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3032
3033def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3034 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3035 addr:$dst),
3036 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3037
3038def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3039 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3040
3041def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3042 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3043 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3044
Evan Cheng956044c2006-01-19 23:26:24 +00003045// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003046def : Pat<(or (srl GR16:$src1, CL:$amt),
3047 (shl GR16:$src2, (sub 16, CL:$amt))),
3048 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003049
Evan Cheng21d54432006-01-20 01:13:30 +00003050def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003051 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3052 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003053
Dan Gohman74feef22008-10-17 01:23:35 +00003054def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3055 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3056 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3057
3058def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3059 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3060 addr:$dst),
3061 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3062
3063def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3064 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3065
3066def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3067 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3068 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3069
Evan Cheng956044c2006-01-19 23:26:24 +00003070// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003071def : Pat<(or (shl GR16:$src1, CL:$amt),
3072 (srl GR16:$src2, (sub 16, CL:$amt))),
3073 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003074
3075def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003076 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3077 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003078
Dan Gohman74feef22008-10-17 01:23:35 +00003079def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3080 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3081 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3082
3083def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3084 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3085 addr:$dst),
3086 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3087
3088def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3089 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3090
3091def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3092 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3093 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3094
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003095//===----------------------------------------------------------------------===//
3096// Floating Point Stack Support
3097//===----------------------------------------------------------------------===//
3098
3099include "X86InstrFPStack.td"
3100
3101//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00003102// X86-64 Support
3103//===----------------------------------------------------------------------===//
3104
Chris Lattner36fe6d22008-01-10 05:50:42 +00003105include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00003106
3107//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003108// XMM Floating point support (requires SSE / SSE2)
3109//===----------------------------------------------------------------------===//
3110
3111include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00003112
3113//===----------------------------------------------------------------------===//
3114// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3115//===----------------------------------------------------------------------===//
3116
3117include "X86InstrMMX.td"