blob: 64d002171a407f638a07127c2a7b56827dcfcf96 [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
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
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
Evan Cheng621216e2007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng950aac02007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029
Dan Gohman99a12192009-03-04 19:44:21 +000030// Unary and binary operator instructions that set EFLAGS as a side-effect.
31def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
32 [SDTCisInt<0>]>;
33def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34 [SDTCisSameAs<0, 1>,
35 SDTCisSameAs<0, 2>,
36 SDTCisInt<0>]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +000037
Evan Cheng621216e2007-09-29 00:00:36 +000038def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000039 [SDTCisVT<0, OtherVT>,
40 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041
Evan Cheng621216e2007-09-29 00:00:36 +000042def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000043 [SDTCisVT<0, i8>,
44 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000046def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
47 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000048def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000049
Dale Johannesenf160d802008-10-02 18:53:47 +000050def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
51 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000052def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000053
Bill Wendling7173da52007-11-13 09:19:02 +000054def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
55def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
56 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057
Dan Gohman3329ffe2008-05-29 19:57:41 +000058def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000059
60def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
61
62def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
63
64def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
65
66def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
67
68def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
69
70def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
71
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000072def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
73
Evan Cheng48679f42007-12-14 02:13:44 +000074def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
75def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
77def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
78
Evan Cheng621216e2007-09-29 00:00:36 +000079def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000080
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000081def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
82
Evan Cheng621216e2007-09-29 00:00:36 +000083def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000084def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000085 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000086def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000087
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000088def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
90 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000091def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
92 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
93 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000094def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
95 [SDNPHasChain, SDNPMayStore,
96 SDNPMayLoad, SDNPMemOperand]>;
97def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
98 [SDNPHasChain, SDNPMayStore,
99 SDNPMayLoad, SDNPMemOperand]>;
100def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
101 [SDNPHasChain, SDNPMayStore,
102 SDNPMayLoad, SDNPMemOperand]>;
103def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
104 [SDNPHasChain, SDNPMayStore,
105 SDNPMayLoad, SDNPMemOperand]>;
106def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
107 [SDNPHasChain, SDNPMayStore,
108 SDNPMayLoad, SDNPMemOperand]>;
109def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
110 [SDNPHasChain, SDNPMayStore,
111 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000112def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
113 [SDNPHasChain, SDNPMayStore,
114 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000115def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
116 [SDNPHasChain, SDNPOptInFlag]>;
117
118def X86callseq_start :
119 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
120 [SDNPHasChain, SDNPOutFlag]>;
121def X86callseq_end :
122 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000123 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000124
125def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
126 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
127
128def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
129 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
130
131def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000133def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000134 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
135 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000136
137def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000138 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139
140def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
141def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
142
143def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000144 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000145def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
146
147def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
148 [SDNPHasChain]>;
149
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000150def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
151 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152
Dan Gohman99a12192009-03-04 19:44:21 +0000153def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
154def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
155def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
156def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
157def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
158def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000159
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000160//===----------------------------------------------------------------------===//
161// X86 Operand Definitions.
162//
163
164// *mem - Operand definitions for the funky X86 addressing mode operands.
165//
166class X86MemOperand<string printMethod> : Operand<iPTR> {
167 let PrintMethod = printMethod;
168 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
169}
170
171def i8mem : X86MemOperand<"printi8mem">;
172def i16mem : X86MemOperand<"printi16mem">;
173def i32mem : X86MemOperand<"printi32mem">;
174def i64mem : X86MemOperand<"printi64mem">;
175def i128mem : X86MemOperand<"printi128mem">;
176def f32mem : X86MemOperand<"printf32mem">;
177def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000178def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179def f128mem : X86MemOperand<"printf128mem">;
180
181def lea32mem : Operand<i32> {
182 let PrintMethod = "printi32mem";
183 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
184}
185
186def SSECC : Operand<i8> {
187 let PrintMethod = "printSSECC";
188}
189
190def piclabel: Operand<i32> {
191 let PrintMethod = "printPICLabel";
192}
193
194// A couple of more descriptive operand definitions.
195// 16-bits but only 8 bits are significant.
196def i16i8imm : Operand<i16>;
197// 32-bits but only 8 bits are significant.
198def i32i8imm : Operand<i32>;
199
200// Branch targets have OtherVT type.
201def brtarget : Operand<OtherVT>;
202
203//===----------------------------------------------------------------------===//
204// X86 Complex Pattern Definitions.
205//
206
207// Define X86 specific addressing mode.
208def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
209def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
210 [add, mul, shl, or, frameindex], []>;
211
212//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000213// X86 Instruction Predicate Definitions.
214def HasMMX : Predicate<"Subtarget->hasMMX()">;
215def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
216def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
217def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
218def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000219def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
220def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000221def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
222def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
224def In64BitMode : Predicate<"Subtarget->is64Bit()">;
225def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
226def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
227def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000228def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000229def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000230
231//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000232// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233//
234
Evan Cheng86ab7d32007-07-31 08:04:03 +0000235include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236
237//===----------------------------------------------------------------------===//
238// Pattern fragments...
239//
240
241// X86 specific condition code. These correspond to CondCode in
242// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000243def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
244def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
245def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
246def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
247def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
248def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
249def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
250def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
251def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
252def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000253def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000254def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000256def X86_COND_O : PatLeaf<(i8 13)>;
257def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
258def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259
260def i16immSExt8 : PatLeaf<(i16 imm), [{
261 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
262 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000263 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264}]>;
265
266def i32immSExt8 : PatLeaf<(i32 imm), [{
267 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
268 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000269 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000270}]>;
271
272// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000273// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
274// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000275def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000276 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-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() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000282 return false;
283}]>;
284
Dan Gohman2a174122008-10-15 06:50:19 +0000285def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000286 LoadSDNode *LD = cast<LoadSDNode>(N);
Evan Cheng56ec77b2008-09-24 23:27:55 +0000287 ISD::LoadExtType ExtType = LD->getExtensionType();
288 if (ExtType == ISD::EXTLOAD)
289 return LD->getAlignment() >= 2 && !LD->isVolatile();
290 return false;
291}]>;
292
Dan Gohman2a174122008-10-15 06:50:19 +0000293def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000294 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000295 ISD::LoadExtType ExtType = LD->getExtensionType();
296 if (ExtType == ISD::NON_EXTLOAD)
297 return true;
298 if (ExtType == ISD::EXTLOAD)
299 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000300 return false;
301}]>;
302
Dan Gohman2a174122008-10-15 06:50:19 +0000303def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000304 LoadSDNode *LD = cast<LoadSDNode>(N);
305 if (LD->isVolatile())
306 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000307 ISD::LoadExtType ExtType = LD->getExtensionType();
308 if (ExtType == ISD::NON_EXTLOAD)
309 return true;
310 if (ExtType == ISD::EXTLOAD)
311 return LD->getAlignment() >= 4;
312 return false;
313}]>;
314
sampo9cc09a32009-01-26 01:24:32 +0000315def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
316 LoadSDNode *LD = cast<LoadSDNode>(N);
317 const Value *Src = LD->getSrcValue();
318 if (!Src)
319 return false;
320 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
321 return PT->getAddressSpace() == 256;
322 return false;
323}]>;
324
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000326def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
327
328def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
329def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000330def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
333def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
334def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
335
336def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
337def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
338def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
339def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
340def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
341def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
342
343def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
344def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
345def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
346def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
347def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
348def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
349
Chris Lattner21da6382008-02-19 17:37:35 +0000350
351// An 'and' node with a single use.
352def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000353 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000354}]>;
355
Dan Gohman921581d2008-10-17 01:23:35 +0000356// 'shld' and 'shrd' instruction patterns. Note that even though these have
357// the srl and shl in their patterns, the C++ code must still check for them,
358// because predicates are tested before children nodes are explored.
359
360def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
361 (or (srl node:$src1, node:$amt1),
362 (shl node:$src2, node:$amt2)), [{
363 assert(N->getOpcode() == ISD::OR);
364 return N->getOperand(0).getOpcode() == ISD::SRL &&
365 N->getOperand(1).getOpcode() == ISD::SHL &&
366 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
367 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
368 N->getOperand(0).getConstantOperandVal(1) ==
369 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
370}]>;
371
372def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
373 (or (shl node:$src1, node:$amt1),
374 (srl node:$src2, node:$amt2)), [{
375 assert(N->getOpcode() == ISD::OR);
376 return N->getOperand(0).getOpcode() == ISD::SHL &&
377 N->getOperand(1).getOpcode() == ISD::SRL &&
378 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
379 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
380 N->getOperand(0).getConstantOperandVal(1) ==
381 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
382}]>;
383
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385// Instruction list...
386//
387
388// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
389// a stack adjustment and the codegen must know that they may modify the stack
390// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000391// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
392// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000393let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000394def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
395 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000396 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000397 Requires<[In32BitMode]>;
398def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
399 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000400 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000401 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000402}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403
404// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000405let neverHasSideEffects = 1 in
406 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407
Evan Cheng0729ccf2008-01-05 00:41:47 +0000408// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000409let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000410 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
411 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412
413//===----------------------------------------------------------------------===//
414// Control Flow Instructions...
415//
416
417// Return instructions.
418let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000419 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000420 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000421 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000422 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000423 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
424 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000425 [(X86retflag imm:$amt)]>;
426}
427
428// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000429let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000430 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
431 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000432
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000434 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435
Owen Andersonf8053082007-11-12 07:39:39 +0000436// Indirect branches
437let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000438 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000440 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441 [(brind (loadi32 addr:$dst))]>;
442}
443
444// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000445let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000446def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000447 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000448def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000449 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000450def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000451 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000452def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000453 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000454def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000455 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000456def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000457 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458
Dan Gohman91888f02007-07-31 20:11:57 +0000459def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000460 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000461def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000462 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000463def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000464 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000465def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000466 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467
Dan Gohman91888f02007-07-31 20:11:57 +0000468def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000469 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000470def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000471 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000472def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000473 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000474def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000475 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000476def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000477 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000478def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000479 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000480} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481
482//===----------------------------------------------------------------------===//
483// Call Instructions...
484//
Evan Cheng37e7c752007-07-21 00:34:19 +0000485let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000486 // All calls clobber the non-callee saved registers. ESP is marked as
487 // a use to prevent stack-pointer assignments that appear immediately
488 // before calls from potentially appearing dead. Uses for argument
489 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
491 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000492 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
493 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000494 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000495 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
Evan Cheng0af5a042009-03-12 18:15:39 +0000496 "call\t${dst:call}", [(X86call imm:$dst)]>,
497 Requires<[In32BitMode]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000498 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000499 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000500 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000501 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502 }
503
504// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000505
Chris Lattnerb56cc342008-03-11 03:23:40 +0000506def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000507 "#TAILCALL",
508 []>;
509
Evan Cheng37e7c752007-07-21 00:34:19 +0000510let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000511def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000512 "#TC_RETURN $dst $offset",
513 []>;
514
515let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000516def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000517 "#TC_RETURN $dst $offset",
518 []>;
519
520let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000521
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000522 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000524let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000525 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
526 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000527let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000528 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000529 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530
531//===----------------------------------------------------------------------===//
532// Miscellaneous Instructions...
533//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000534let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000536 (outs), (ins), "leave", []>;
537
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000538let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
539let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000540def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000542let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000543def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000544}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000546let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000547def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000548let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000549def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000550
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551let isTwoAddress = 1 in // GR32 = bswap GR32
552 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000553 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000554 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
556
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557
Evan Cheng48679f42007-12-14 02:13:44 +0000558// Bit scan instructions.
559let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000560def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000561 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000562 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000563def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000564 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000565 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
566 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000567def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000568 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000569 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000570def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000571 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000572 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
573 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000574
Evan Cheng4e33de92007-12-14 18:49:43 +0000575def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000576 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000577 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000578def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000579 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000580 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
581 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000582def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000583 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000584 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000585def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000586 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000587 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
588 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000589} // Defs = [EFLAGS]
590
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000591let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000593 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000594 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000595let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000596def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000597 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000598 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000599 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
600
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000601let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000602def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000603 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000604def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000605 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000606def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000607 [(X86rep_movs i32)]>, REP;
608}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000610let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000611def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000612 [(X86rep_stos i8)]>, REP;
613let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000614def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000615 [(X86rep_stos i16)]>, REP, OpSize;
616let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000617def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000618 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000620let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000621def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000622 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000624let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000625def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000626}
627
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628//===----------------------------------------------------------------------===//
629// Input/Output Instructions...
630//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000631let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000632def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000633 "in{b}\t{%dx, %al|%AL, %DX}", []>;
634let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000635def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000636 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
637let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000638def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000639 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000641let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000642def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000643 "in{b}\t{$port, %al|%AL, $port}", []>;
644let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000645def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000646 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
647let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000648def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000649 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000650
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000651let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000652def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000653 "out{b}\t{%al, %dx|%DX, %AL}", []>;
654let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000655def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000656 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
657let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000658def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000659 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000660
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000661let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000662def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000663 "out{b}\t{%al, $port|$port, %AL}", []>;
664let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000665def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000666 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
667let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000668def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000669 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670
671//===----------------------------------------------------------------------===//
672// Move Instructions...
673//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000674let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000675def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000676 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000677def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000678 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000679def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000680 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000681}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000682let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000683def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000684 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000686def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000687 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000689def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(set GR32:$dst, imm:$src)]>;
692}
Evan Chengb783fa32007-07-19 01:14:50 +0000693def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000694 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000696def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000697 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000699def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000700 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000701 [(store (i32 imm:$src), addr:$dst)]>;
702
Dan Gohman5574cc72008-12-03 18:15:48 +0000703let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000704def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000705 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000707def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000710def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000711 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000713}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714
Evan Chengb783fa32007-07-19 01:14:50 +0000715def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000716 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000718def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000719 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000721def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000722 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 [(store GR32:$src, addr:$dst)]>;
724
725//===----------------------------------------------------------------------===//
726// Fixed-Register Multiplication and Division Instructions...
727//
728
729// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000730let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000731def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000732 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
733 // This probably ought to be moved to a def : Pat<> if the
734 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000735 [(set AL, (mul AL, GR8:$src)),
736 (implicit EFLAGS)]>; // AL,AH = AL*GR8
737
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000738let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000739def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
740 "mul{w}\t$src",
741 []>, OpSize; // AX,DX = AX*GR16
742
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000743let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000744def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
745 "mul{l}\t$src",
746 []>; // EAX,EDX = EAX*GR32
747
Evan Cheng55687072007-09-14 21:48:26 +0000748let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000749def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000750 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
752 // This probably ought to be moved to a def : Pat<> if the
753 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000754 [(set AL, (mul AL, (loadi8 addr:$src))),
755 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
756
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000757let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000758let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000759def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000760 "mul{w}\t$src",
761 []>, OpSize; // AX,DX = AX*[mem16]
762
Evan Cheng55687072007-09-14 21:48:26 +0000763let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000764def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000765 "mul{l}\t$src",
766 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000767}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000769let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000770let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000771def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
772 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000773let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000774def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000775 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000776let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000777def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
778 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000779let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000780let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000781def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000782 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000783let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000784def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000785 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
786let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000787def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000788 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000789}
Dan Gohmand44572d2008-11-18 21:29:14 +0000790} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791
792// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000793let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000794def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000795 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000796let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000797def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000798 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000799let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000800def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000801 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000802let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000803let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000804def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000805 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000806let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000807def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000808 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000809let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000810def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000811 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000812}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813
814// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000815let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000816def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000817 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000818let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000819def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000820 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000821let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000822def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000823 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000824let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000825let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000826def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000827 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000828let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000829def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000830 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000831let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000832def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000833 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000834}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835
836//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000837// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838//
839let isTwoAddress = 1 in {
840
841// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000842let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000843let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000845 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000846 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000848 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000851 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000852 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000854 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000857 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000858 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000860 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000863 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000864 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000866 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000869 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000870 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000872 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000875 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000876 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000878 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000881 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000882 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000884 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000887 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000888 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000890 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000893 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000894 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000896 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000899 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000900 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000902 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000903 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000905 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000906 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000908 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000911 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000912 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000914 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000917 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000918 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000920 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000923 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000924 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000926 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000929 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000930 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000932 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000935 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000938 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000941 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000942 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000944 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000947 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000948 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000950 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000953 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000954 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000956 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000959 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000962 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000965 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000968 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000971 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000972 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000974 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000977 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000978 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000980 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000983 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000984 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000986 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000989 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000990 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000992 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000995 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000996 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000998 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001001 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001002 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001004 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001007 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001008 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001010 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001012def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1013 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1014 "cmovo\t{$src2, $dst|$dst, $src2}",
1015 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1016 X86_COND_O, EFLAGS))]>,
1017 TB, OpSize;
1018def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1019 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1020 "cmovo\t{$src2, $dst|$dst, $src2}",
1021 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1022 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001023 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001024def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1025 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1026 "cmovno\t{$src2, $dst|$dst, $src2}",
1027 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1028 X86_COND_NO, EFLAGS))]>,
1029 TB, OpSize;
1030def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1031 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1032 "cmovno\t{$src2, $dst|$dst, $src2}",
1033 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1034 X86_COND_NO, EFLAGS))]>,
1035 TB;
1036} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001037
1038def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1039 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1040 "cmovb\t{$src2, $dst|$dst, $src2}",
1041 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1042 X86_COND_B, EFLAGS))]>,
1043 TB, OpSize;
1044def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1045 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1046 "cmovb\t{$src2, $dst|$dst, $src2}",
1047 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1048 X86_COND_B, EFLAGS))]>,
1049 TB;
1050def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1051 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1052 "cmovae\t{$src2, $dst|$dst, $src2}",
1053 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1054 X86_COND_AE, EFLAGS))]>,
1055 TB, OpSize;
1056def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1057 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1058 "cmovae\t{$src2, $dst|$dst, $src2}",
1059 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1060 X86_COND_AE, EFLAGS))]>,
1061 TB;
1062def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1063 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1064 "cmove\t{$src2, $dst|$dst, $src2}",
1065 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1066 X86_COND_E, EFLAGS))]>,
1067 TB, OpSize;
1068def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1069 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1070 "cmove\t{$src2, $dst|$dst, $src2}",
1071 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1072 X86_COND_E, EFLAGS))]>,
1073 TB;
1074def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1075 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1076 "cmovne\t{$src2, $dst|$dst, $src2}",
1077 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1078 X86_COND_NE, EFLAGS))]>,
1079 TB, OpSize;
1080def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1081 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1082 "cmovne\t{$src2, $dst|$dst, $src2}",
1083 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1084 X86_COND_NE, EFLAGS))]>,
1085 TB;
1086def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1087 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1088 "cmovbe\t{$src2, $dst|$dst, $src2}",
1089 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1090 X86_COND_BE, EFLAGS))]>,
1091 TB, OpSize;
1092def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1093 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1094 "cmovbe\t{$src2, $dst|$dst, $src2}",
1095 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1096 X86_COND_BE, EFLAGS))]>,
1097 TB;
1098def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1099 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1100 "cmova\t{$src2, $dst|$dst, $src2}",
1101 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1102 X86_COND_A, EFLAGS))]>,
1103 TB, OpSize;
1104def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1105 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1106 "cmova\t{$src2, $dst|$dst, $src2}",
1107 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1108 X86_COND_A, EFLAGS))]>,
1109 TB;
1110def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1111 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1112 "cmovl\t{$src2, $dst|$dst, $src2}",
1113 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1114 X86_COND_L, EFLAGS))]>,
1115 TB, OpSize;
1116def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1117 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1118 "cmovl\t{$src2, $dst|$dst, $src2}",
1119 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1120 X86_COND_L, EFLAGS))]>,
1121 TB;
1122def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1123 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1124 "cmovge\t{$src2, $dst|$dst, $src2}",
1125 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1126 X86_COND_GE, EFLAGS))]>,
1127 TB, OpSize;
1128def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1129 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1130 "cmovge\t{$src2, $dst|$dst, $src2}",
1131 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1132 X86_COND_GE, EFLAGS))]>,
1133 TB;
1134def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1135 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1136 "cmovle\t{$src2, $dst|$dst, $src2}",
1137 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1138 X86_COND_LE, EFLAGS))]>,
1139 TB, OpSize;
1140def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1141 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1142 "cmovle\t{$src2, $dst|$dst, $src2}",
1143 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1144 X86_COND_LE, EFLAGS))]>,
1145 TB;
1146def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1147 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1148 "cmovg\t{$src2, $dst|$dst, $src2}",
1149 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1150 X86_COND_G, EFLAGS))]>,
1151 TB, OpSize;
1152def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1153 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1154 "cmovg\t{$src2, $dst|$dst, $src2}",
1155 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1156 X86_COND_G, EFLAGS))]>,
1157 TB;
1158def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1159 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1160 "cmovs\t{$src2, $dst|$dst, $src2}",
1161 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1162 X86_COND_S, EFLAGS))]>,
1163 TB, OpSize;
1164def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1165 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1166 "cmovs\t{$src2, $dst|$dst, $src2}",
1167 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1168 X86_COND_S, EFLAGS))]>,
1169 TB;
1170def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1171 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1172 "cmovns\t{$src2, $dst|$dst, $src2}",
1173 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1174 X86_COND_NS, EFLAGS))]>,
1175 TB, OpSize;
1176def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1177 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1178 "cmovns\t{$src2, $dst|$dst, $src2}",
1179 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1180 X86_COND_NS, EFLAGS))]>,
1181 TB;
1182def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1183 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1184 "cmovp\t{$src2, $dst|$dst, $src2}",
1185 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1186 X86_COND_P, EFLAGS))]>,
1187 TB, OpSize;
1188def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1189 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1190 "cmovp\t{$src2, $dst|$dst, $src2}",
1191 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1192 X86_COND_P, EFLAGS))]>,
1193 TB;
1194def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1195 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1196 "cmovnp\t{$src2, $dst|$dst, $src2}",
1197 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1198 X86_COND_NP, EFLAGS))]>,
1199 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001200def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1201 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1202 "cmovnp\t{$src2, $dst|$dst, $src2}",
1203 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1204 X86_COND_NP, EFLAGS))]>,
1205 TB;
1206def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1207 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1208 "cmovo\t{$src2, $dst|$dst, $src2}",
1209 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1210 X86_COND_O, EFLAGS))]>,
1211 TB, OpSize;
1212def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1213 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1214 "cmovo\t{$src2, $dst|$dst, $src2}",
1215 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1216 X86_COND_O, EFLAGS))]>,
1217 TB;
1218def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1219 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1220 "cmovno\t{$src2, $dst|$dst, $src2}",
1221 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1222 X86_COND_NO, EFLAGS))]>,
1223 TB, OpSize;
1224def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1225 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1226 "cmovno\t{$src2, $dst|$dst, $src2}",
1227 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1228 X86_COND_NO, EFLAGS))]>,
1229 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001230} // Uses = [EFLAGS]
1231
1232
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233// unary instructions
1234let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001235let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001236def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001237 [(set GR8:$dst, (ineg GR8:$src)),
1238 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001239def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001240 [(set GR16:$dst, (ineg GR16:$src)),
1241 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001242def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001243 [(set GR32:$dst, (ineg GR32:$src)),
1244 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001246 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001247 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1248 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001249 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001250 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1251 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001252 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001253 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1254 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255}
Evan Cheng55687072007-09-14 21:48:26 +00001256} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257
Evan Chengc6cee682009-01-21 02:09:05 +00001258// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1259let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001260def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001262def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001264def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001266}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001268 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001270 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001272 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1274}
1275} // CodeSize
1276
1277// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001278let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001280def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001281 [(set GR8:$dst, (add GR8:$src, 1)),
1282 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001284def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001285 [(set GR16:$dst, (add GR16:$src, 1)),
1286 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001288def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001289 [(set GR32:$dst, (add GR32:$src, 1)),
1290 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291}
1292let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001293 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001294 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1295 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001296 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001297 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1298 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001299 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001300 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001301 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1302 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001303 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304}
1305
1306let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001307def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001308 [(set GR8:$dst, (add GR8:$src, -1)),
1309 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001311def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001312 [(set GR16:$dst, (add GR16:$src, -1)),
1313 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001315def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001316 [(set GR32:$dst, (add GR32:$src, -1)),
1317 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318}
1319
1320let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001321 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001322 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1323 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001324 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001325 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1326 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001327 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001328 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001329 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1330 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001331 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332}
Evan Cheng55687072007-09-14 21:48:26 +00001333} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334
1335// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001336let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1338def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001339 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001340 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001341 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1342 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001344 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001345 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001346 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1347 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001349 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001350 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001351 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1352 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353}
1354
1355def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001356 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001357 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001358 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2))),
1359 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001360def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001361 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001362 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001363 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2))),
1364 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001366 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001367 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001368 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2))),
1369 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001370
1371def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001372 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001373 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001374 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1375 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001377 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001378 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001379 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1380 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001382 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001383 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001384 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1385 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001387 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001388 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001389 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1390 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391 OpSize;
1392def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001393 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001394 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001395 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1396 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397
1398let isTwoAddress = 0 in {
1399 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001400 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001401 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001402 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1403 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001405 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001406 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001407 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1408 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409 OpSize;
1410 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001411 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001412 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001413 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1414 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001416 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001418 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1419 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001420 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001421 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001422 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001423 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1424 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001425 OpSize;
1426 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001427 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001428 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001429 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1430 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001431 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001432 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001433 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001434 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1435 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436 OpSize;
1437 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001438 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001440 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1441 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442}
1443
1444
1445let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001446def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001448 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1449 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001450def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001451 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001452 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1453 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001454def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001455 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001456 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1457 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001458}
Evan Chengb783fa32007-07-19 01:14:50 +00001459def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001461 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1462 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001463def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001465 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1466 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001467def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001469 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1470 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471
Evan Chengb783fa32007-07-19 01:14:50 +00001472def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001473 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001474 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1475 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001476def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001477 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001478 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1479 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001480def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001482 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1483 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001484
Evan Chengb783fa32007-07-19 01:14:50 +00001485def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001487 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1488 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001489def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001491 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1492 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001493let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001494 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001495 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001496 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1497 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001498 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001499 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001500 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1501 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001502 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001504 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1505 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001506 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001507 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001508 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1509 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001510 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001512 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1513 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001515 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001517 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1518 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001519 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001520 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001521 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1522 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001523 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001524 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001525 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001526 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1527 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001528} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529
1530
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001531let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001532 def XOR8rr : I<0x30, MRMDestReg,
1533 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1534 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001535 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1536 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001537 def XOR16rr : I<0x31, MRMDestReg,
1538 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1539 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001540 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1541 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001542 def XOR32rr : I<0x31, MRMDestReg,
1543 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1544 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001545 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1546 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001547} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548
1549def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001550 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001552 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1553 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001555 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001557 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1558 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001559 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001561 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001563 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1564 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001566def XOR8ri : Ii8<0x80, MRM6r,
1567 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1568 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001569 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1570 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001571def XOR16ri : Ii16<0x81, MRM6r,
1572 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1573 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001574 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1575 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001576def XOR32ri : Ii32<0x81, MRM6r,
1577 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1578 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001579 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1580 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001581def XOR16ri8 : Ii8<0x83, MRM6r,
1582 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1583 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001584 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1585 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001586 OpSize;
1587def XOR32ri8 : Ii8<0x83, MRM6r,
1588 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1589 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001590 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1591 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001592
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593let isTwoAddress = 0 in {
1594 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001595 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001597 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1598 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001600 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001602 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1603 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001604 OpSize;
1605 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001606 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001607 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001608 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1609 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001610 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001611 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001613 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1614 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001616 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001617 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001618 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1619 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620 OpSize;
1621 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001622 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001624 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1625 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001627 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001629 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1630 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631 OpSize;
1632 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001633 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001634 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001635 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1636 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001637} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001638} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639
1640// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001641let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001642let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001643def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001644 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001645 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001646def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001648 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001649def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001650 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001651 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001652} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653
Evan Chengb783fa32007-07-19 01:14:50 +00001654def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1657let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001658def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001660 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001661def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001662 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001663 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001664// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1665// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001666} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667
1668let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001669 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001670 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001672 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001673 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001675 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001676 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001678 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1679 }
Evan Chengb783fa32007-07-19 01:14:50 +00001680 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001681 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001682 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001683 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1686 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001687 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001688 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1690
1691 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001692 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001693 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001694 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001695 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1698 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001699 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1702}
1703
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001704let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001705def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001707 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001708def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001710 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001711def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001712 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001713 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1714}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001715
Evan Chengb783fa32007-07-19 01:14:50 +00001716def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001717 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001718 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001719def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001722def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1725
1726// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001727def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001728 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001729 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001730def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001733def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1736
1737let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001738 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001739 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001741 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001742 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001743 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001745 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001746 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001747 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001748 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1749 }
Evan Chengb783fa32007-07-19 01:14:50 +00001750 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001751 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001753 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1756 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001757 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1760
1761 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001762 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001764 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001765 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001766 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001768 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1771}
1772
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001773let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001774def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001776 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001777def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001779 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001780def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001782 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1783}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001784
Evan Chengb783fa32007-07-19 01:14:50 +00001785def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001788def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1791 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001792def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001794 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1795
1796// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001797def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001798 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001800def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001803def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1806
1807let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001808 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001809 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001811 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001812 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001814 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001815 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001817 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1818 }
Evan Chengb783fa32007-07-19 01:14:50 +00001819 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001822 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1825 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001826 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001828 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1829
1830 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001831 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001834 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1837 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001838 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1841}
1842
1843// Rotate instructions
1844// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001845let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001846def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001847 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001848 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001849def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001850 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001851 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001852def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001854 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1855}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001856
Evan Chengb783fa32007-07-19 01:14:50 +00001857def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001858 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001859 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001860def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001863def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1866
1867// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001868def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001871def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001872 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001873 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001874def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1877
1878let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001879 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001880 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001881 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001882 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001883 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001884 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001885 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001886 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001888 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1889 }
Evan Chengb783fa32007-07-19 01:14:50 +00001890 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001893 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1896 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001897 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1900
1901 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001902 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001904 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001905 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1908 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001909 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001910 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001911 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1912}
1913
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001914let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001915def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001916 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001917 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001918def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001920 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001921def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001923 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1924}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001925
Evan Chengb783fa32007-07-19 01:14:50 +00001926def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001927 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001928 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001929def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001930 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001932def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001934 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1935
1936// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001937def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001940def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001943def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1946
1947let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001948 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001949 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001950 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001951 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001952 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001953 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001954 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001955 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001956 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001957 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1958 }
Evan Chengb783fa32007-07-19 01:14:50 +00001959 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001960 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001962 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1965 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001966 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001967 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1969
1970 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001971 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001974 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1977 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001978 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1981}
1982
1983
1984
1985// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001986let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001987def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001988 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001989 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001990def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001992 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001993def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001994 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001996 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001997def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001998 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001999 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002000 TB, OpSize;
2001}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002
2003let isCommutable = 1 in { // These instructions commute to each other.
2004def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002005 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2008 (i8 imm:$src3)))]>,
2009 TB;
2010def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002011 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002013 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2014 (i8 imm:$src3)))]>,
2015 TB;
2016def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002017 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2020 (i8 imm:$src3)))]>,
2021 TB, OpSize;
2022def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002023 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2026 (i8 imm:$src3)))]>,
2027 TB, OpSize;
2028}
2029
2030let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002031 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002032 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002035 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002036 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002039 addr:$dst)]>, TB;
2040 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002042 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2045 (i8 imm:$src3)), addr:$dst)]>,
2046 TB;
2047 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002048 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2051 (i8 imm:$src3)), addr:$dst)]>,
2052 TB;
2053
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002054 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002055 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002058 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002059 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002062 addr:$dst)]>, TB, OpSize;
2063 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002064 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002065 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2068 (i8 imm:$src3)), addr:$dst)]>,
2069 TB, OpSize;
2070 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002071 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002072 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002073 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2074 (i8 imm:$src3)), addr:$dst)]>,
2075 TB, OpSize;
2076}
Evan Cheng55687072007-09-14 21:48:26 +00002077} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078
2079
2080// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002081let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002083// Register-Register Addition
2084def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2085 (ins GR8 :$src1, GR8 :$src2),
2086 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002087 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002088 (implicit EFLAGS)]>;
2089
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002091// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002092def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2093 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002094 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002095 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2096 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002097def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2098 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002099 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002100 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2101 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002102} // end isConvertibleToThreeAddress
2103} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002104
2105// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002106def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2107 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002109 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2110 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002111def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2112 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002113 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002114 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2115 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002116def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2117 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002119 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2120 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121
Bill Wendlingae034ed2008-12-12 00:56:36 +00002122// Register-Integer Addition
2123def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2124 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002125 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2126 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002127
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002129// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002130def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2131 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002132 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002133 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2134 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002135def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2136 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002137 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002138 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2139 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002140def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2141 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002143 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2144 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002145def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2146 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002148 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2149 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002150}
2151
2152let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002153 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002154 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002155 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002156 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2157 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002158 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002160 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2161 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002162 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002164 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2165 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002166 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002168 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2169 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002170 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002172 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2173 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002174 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002175 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002176 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2177 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002178 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002179 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002180 [(store (add (load addr:$dst), i16immSExt8:$src2),
2181 addr:$dst),
2182 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002183 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002184 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002185 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002186 addr:$dst),
2187 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188}
2189
Evan Cheng259471d2007-10-05 17:59:57 +00002190let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002192def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002194 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195}
Evan Chengb783fa32007-07-19 01:14:50 +00002196def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002198 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002199def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002201 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002202def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002204 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205
2206let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002207 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002208 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002209 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002210 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002211 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002212 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002213 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002215 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002216}
Evan Cheng259471d2007-10-05 17:59:57 +00002217} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002218
Bill Wendlingae034ed2008-12-12 00:56:36 +00002219// Register-Register Subtraction
2220def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2221 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002222 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2223 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002224def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2225 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002226 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2227 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002228def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2229 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002230 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2231 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002232
2233// Register-Memory Subtraction
2234def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2235 (ins GR8 :$src1, i8mem :$src2),
2236 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002237 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2238 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002239def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2240 (ins GR16:$src1, i16mem:$src2),
2241 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002242 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2243 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002244def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2245 (ins GR32:$src1, i32mem:$src2),
2246 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002247 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2248 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002249
2250// Register-Integer Subtraction
2251def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2252 (ins GR8:$src1, i8imm:$src2),
2253 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002254 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2255 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002256def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2257 (ins GR16:$src1, i16imm:$src2),
2258 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002259 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2260 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002261def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2262 (ins GR32:$src1, i32imm:$src2),
2263 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002264 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2265 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002266def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2267 (ins GR16:$src1, i16i8imm:$src2),
2268 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002269 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2270 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002271def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2272 (ins GR32:$src1, i32i8imm:$src2),
2273 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002274 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2275 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002276
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002277let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002278 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002279 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002281 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2282 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002283 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002284 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002285 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2286 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002287 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002289 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2290 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002291
2292 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002293 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002295 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2296 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002297 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002299 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2300 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002301 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002302 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002303 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2304 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002305 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002306 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002307 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002308 addr:$dst),
2309 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002310 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002312 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002313 addr:$dst),
2314 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315}
2316
Evan Cheng259471d2007-10-05 17:59:57 +00002317let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002318def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002319 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002320 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002321
2322let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002323 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002324 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002325 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002326 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002327 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002329 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002330 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002332 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002334 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002335}
Evan Chengb783fa32007-07-19 01:14:50 +00002336def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002337 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002338 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002339def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002341 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002342def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002343 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002344 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002345} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002346} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002347
Evan Cheng55687072007-09-14 21:48:26 +00002348let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002350// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002351def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002353 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2354 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002355def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002356 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002357 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2358 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002359}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002360
Bill Wendlingf5399032008-12-12 21:15:41 +00002361// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002362def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2363 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002364 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002365 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2366 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002367def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002368 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002369 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2370 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002371} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002372} // end Two Address instructions
2373
2374// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002375let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002376// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002377def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002378 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002379 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002380 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2381 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002382def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002383 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002384 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002385 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2386 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002387def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002388 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002389 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002390 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2391 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002392def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002393 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002394 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002395 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2396 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002397
Bill Wendlingf5399032008-12-12 21:15:41 +00002398// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002399def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002400 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002401 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002402 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2403 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002405 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002406 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002407 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2408 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002409def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002410 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002411 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002412 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002413 i16immSExt8:$src2)),
2414 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002415def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002416 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002417 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002418 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002419 i32immSExt8:$src2)),
2420 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002421} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002422
2423//===----------------------------------------------------------------------===//
2424// Test instructions are just like AND, except they don't generate a result.
2425//
Evan Cheng950aac02007-09-25 01:57:46 +00002426let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002427let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002428def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002429 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002430 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002431 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002432def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002433 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002434 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002435 (implicit EFLAGS)]>,
2436 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002437def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002438 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002439 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002440 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002441}
2442
Evan Chengb783fa32007-07-19 01:14:50 +00002443def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002444 "test{b}\t{$src2, $src1|$src1, $src2}",
2445 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2446 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002447def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002448 "test{w}\t{$src2, $src1|$src1, $src2}",
2449 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2450 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002451def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002452 "test{l}\t{$src2, $src1|$src1, $src2}",
2453 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2454 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002455
2456def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002457 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002458 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002459 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002460 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002461def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002462 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002464 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002465 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002466def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002467 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002469 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002470 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002471
Evan Cheng621216e2007-09-29 00:00:36 +00002472def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002473 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002474 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002475 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2476 (implicit EFLAGS)]>;
2477def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002478 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002479 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002480 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2481 (implicit EFLAGS)]>, OpSize;
2482def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002483 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002484 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002485 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002486 (implicit EFLAGS)]>;
2487} // Defs = [EFLAGS]
2488
2489
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002490// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002491let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002492def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002493let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002494def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002495
Evan Cheng950aac02007-09-25 01:57:46 +00002496let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002497def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002498 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002499 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002500 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002501 TB; // GR8 = ==
2502def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002503 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002504 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002505 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002506 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002507
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002509 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002510 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002511 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512 TB; // GR8 = !=
2513def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002514 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002515 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002516 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002517 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002518
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002519def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002520 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002521 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002522 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002523 TB; // GR8 = < signed
2524def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002525 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002526 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002527 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002528 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002529
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002530def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002531 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002532 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002533 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002534 TB; // GR8 = >= signed
2535def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002536 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002537 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002538 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002539 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002540
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002541def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002542 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002543 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002544 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002545 TB; // GR8 = <= signed
2546def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002547 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002548 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002549 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002550 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002551
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002552def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002553 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002554 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002555 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002556 TB; // GR8 = > signed
2557def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002558 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002559 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002560 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002561 TB; // [mem8] = > signed
2562
2563def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002564 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002565 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002566 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002567 TB; // GR8 = < unsign
2568def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002569 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002570 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002571 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002572 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002573
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002575 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002576 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002577 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002578 TB; // GR8 = >= unsign
2579def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002580 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002581 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002582 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002584
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002585def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002586 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002587 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002588 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589 TB; // GR8 = <= unsign
2590def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002591 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002592 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002593 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002594 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002595
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002596def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002597 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002598 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002599 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002600 TB; // GR8 = > signed
2601def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002602 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002603 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002604 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605 TB; // [mem8] = > signed
2606
2607def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002608 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002609 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002610 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002611 TB; // GR8 = <sign bit>
2612def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002613 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002614 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002615 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616 TB; // [mem8] = <sign bit>
2617def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002618 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002619 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002620 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002621 TB; // GR8 = !<sign bit>
2622def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002623 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002624 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002625 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002626 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002627
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002629 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002630 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002631 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632 TB; // GR8 = parity
2633def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002634 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002635 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002636 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002637 TB; // [mem8] = parity
2638def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002639 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002640 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002641 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002642 TB; // GR8 = not parity
2643def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002644 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002645 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002646 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002647 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002648
2649def SETOr : I<0x90, MRM0r,
2650 (outs GR8 :$dst), (ins),
2651 "seto\t$dst",
2652 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2653 TB; // GR8 = overflow
2654def SETOm : I<0x90, MRM0m,
2655 (outs), (ins i8mem:$dst),
2656 "seto\t$dst",
2657 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2658 TB; // [mem8] = overflow
2659def SETNOr : I<0x91, MRM0r,
2660 (outs GR8 :$dst), (ins),
2661 "setno\t$dst",
2662 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2663 TB; // GR8 = not overflow
2664def SETNOm : I<0x91, MRM0m,
2665 (outs), (ins i8mem:$dst),
2666 "setno\t$dst",
2667 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2668 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002669} // Uses = [EFLAGS]
2670
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002671
2672// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002673let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002674def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002675 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002676 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002677 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002678def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002679 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002680 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002681 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002682def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002683 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002684 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002685 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002686def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002687 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002688 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002689 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2690 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002691def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002692 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002693 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002694 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2695 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002696def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002697 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002698 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002699 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2700 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002701def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002702 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002703 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002704 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2705 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002706def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002707 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002708 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002709 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2710 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002711def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002712 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002713 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002714 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2715 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002716def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002717 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002718 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002719 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002720def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002721 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002722 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002723 [(X86cmp GR16:$src1, imm:$src2),
2724 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002725def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002726 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002727 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002728 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002729def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002730 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002731 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002732 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2733 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002734def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002735 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002736 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002737 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2738 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002739def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002740 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002741 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002742 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2743 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002744def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002745 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002746 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002747 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2748 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002749def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002750 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002751 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002752 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2753 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002754def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002755 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002756 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002757 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2758 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002759def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002760 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002761 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002762 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002763 (implicit EFLAGS)]>;
2764} // Defs = [EFLAGS]
2765
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002766// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002767// TODO: BTC, BTR, and BTS
2768let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002769def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002770 "bt{w}\t{$src2, $src1|$src1, $src2}",
2771 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002772 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002773def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002774 "bt{l}\t{$src2, $src1|$src1, $src2}",
2775 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002776 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002777
2778// Unlike with the register+register form, the memory+register form of the
2779// bt instruction does not ignore the high bits of the index. From ISel's
2780// perspective, this is pretty bizarre. Disable these instructions for now.
2781//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2782// "bt{w}\t{$src2, $src1|$src1, $src2}",
2783// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2784// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2785//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2786// "bt{l}\t{$src2, $src1|$src1, $src2}",
2787// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2788// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002789
2790def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2791 "bt{w}\t{$src2, $src1|$src1, $src2}",
2792 [(X86bt GR16:$src1, i16immSExt8:$src2),
2793 (implicit EFLAGS)]>, OpSize, TB;
2794def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2795 "bt{l}\t{$src2, $src1|$src1, $src2}",
2796 [(X86bt GR32:$src1, i32immSExt8:$src2),
2797 (implicit EFLAGS)]>, TB;
2798// Note that these instructions don't need FastBTMem because that
2799// only applies when the other operand is in a register. When it's
2800// an immediate, bt is still fast.
2801def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
2802 "bt{w}\t{$src2, $src1|$src1, $src2}",
2803 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
2804 (implicit EFLAGS)]>, OpSize, TB;
2805def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
2806 "bt{l}\t{$src2, $src1|$src1, $src2}",
2807 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
2808 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002809} // Defs = [EFLAGS]
2810
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002811// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002812// Use movsbl intead of movsbw; we don't care about the high 16 bits
2813// of the register here. This has a smaller encoding and avoids a
2814// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002815def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002816 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2817 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002818def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002819 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2820 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002821def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002822 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002823 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002824def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002825 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002826 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002827def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002828 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002829 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002830def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002831 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002832 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2833
Dan Gohman9203ab42008-07-30 18:09:17 +00002834// Use movzbl intead of movzbw; we don't care about the high 16 bits
2835// of the register here. This has a smaller encoding and avoids a
2836// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002837def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002838 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2839 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002840def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002841 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2842 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002843def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002844 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002845 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002846def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002847 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002848 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002849def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002850 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002851 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002852def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002853 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2855
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002856let neverHasSideEffects = 1 in {
2857 let Defs = [AX], Uses = [AL] in
2858 def CBW : I<0x98, RawFrm, (outs), (ins),
2859 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2860 let Defs = [EAX], Uses = [AX] in
2861 def CWDE : I<0x98, RawFrm, (outs), (ins),
2862 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002863
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002864 let Defs = [AX,DX], Uses = [AX] in
2865 def CWD : I<0x99, RawFrm, (outs), (ins),
2866 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2867 let Defs = [EAX,EDX], Uses = [EAX] in
2868 def CDQ : I<0x99, RawFrm, (outs), (ins),
2869 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2870}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002871
2872//===----------------------------------------------------------------------===//
2873// Alias Instructions
2874//===----------------------------------------------------------------------===//
2875
2876// Alias instructions that map movr0 to xor.
2877// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002878let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002879def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002880 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002881 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002882// Use xorl instead of xorw since we don't care about the high 16 bits,
2883// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002884def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002885 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2886 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002887def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002888 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002889 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002890}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002891
2892// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2893// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengbd0ca9c2009-02-05 08:42:55 +00002894let neverHasSideEffects = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002895def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002896 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002897def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002898 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002899
Evan Chengb783fa32007-07-19 01:14:50 +00002900def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002901 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002902def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002903 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002904} // neverHasSideEffects
2905
Dan Gohman5574cc72008-12-03 18:15:48 +00002906let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002907def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002908 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002909def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002910 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002911}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002912let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002913def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002914 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002915def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002916 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002917}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002918
2919//===----------------------------------------------------------------------===//
2920// Thread Local Storage Instructions
2921//
2922
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002923let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002924def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2925 "leal\t${sym:mem}(,%ebx,1), $dst",
2926 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002927
2928let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002929def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002930 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002931 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2932
2933let AddedComplexity = 15 in
Nicolas Geoffray81580792008-10-25 15:22:06 +00002934def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002935 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002936 [(set GR32:$dst,
Nicolas Geoffray81580792008-10-25 15:22:06 +00002937 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
2938 SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002939
Rafael Espindola53ec6be2009-03-11 22:40:04 +00002940let AddedComplexity = 15 in
2941def TLS_ext16_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2942 "movzwl\t%gs:${src:mem}, $dst",
2943 [(set GR32:$dst,
2944 (extloadi32i16
2945 (add X86TLStp,
2946 (X86Wrapper tglobaltlsaddr:$src))))]>,
2947 SegGS;
2948
2949let AddedComplexity = 15 in
2950def TLS_ext8_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
2951 "movzbl\t%gs:${src:mem}, $dst",
2952 [(set GR32:$dst,
2953 (extloadi32i8
2954 (add X86TLStp,
2955 (X86Wrapper tglobaltlsaddr:$src))))]>,
2956 SegGS;
2957
Nicolas Geoffray81580792008-10-25 15:22:06 +00002958def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002959 "movl\t%gs:0, $dst",
Nicolas Geoffray81580792008-10-25 15:22:06 +00002960 [(set GR32:$dst, X86TLStp)]>, SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002961
sampo9cc09a32009-01-26 01:24:32 +00002962let AddedComplexity = 5 in
2963def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
2964 "movl\t%gs:$src, $dst",
2965 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
2966
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002967//===----------------------------------------------------------------------===//
2968// DWARF Pseudo Instructions
2969//
2970
Evan Chengb783fa32007-07-19 01:14:50 +00002971def DWARF_LOC : I<0, Pseudo, (outs),
2972 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002973 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002974 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2975 (i32 imm:$file))]>;
2976
2977//===----------------------------------------------------------------------===//
2978// EH Pseudo Instructions
2979//
2980let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002981 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002982def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002983 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002984 [(X86ehret GR32:$addr)]>;
2985
2986}
2987
2988//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002989// Atomic support
2990//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002991
Evan Cheng3e171562008-04-19 01:20:30 +00002992// Atomic swap. These are just normal xchg instructions. But since a memory
2993// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00002994let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00002995def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2996 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2997 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2998def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2999 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3000 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3001 OpSize;
3002def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3003 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3004 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3005}
3006
Evan Chengd49dbb82008-04-18 20:55:36 +00003007// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003008let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003009def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003010 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003011 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003012}
Dale Johannesenf160d802008-10-02 18:53:47 +00003013let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003014def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00003015 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003016 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3017}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003018
3019let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003020def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003021 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003022 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003023}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003024let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003025def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00003026 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003027 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003028}
3029
Evan Chengd49dbb82008-04-18 20:55:36 +00003030// Atomic exchange and add
3031let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3032def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003033 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003034 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003035 TB, LOCK;
3036def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003037 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003038 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003039 TB, OpSize, LOCK;
3040def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00003041 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003042 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003043 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003044}
3045
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003046// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003047let Constraints = "$val = $dst", Defs = [EFLAGS],
3048 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003049def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003050 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003051 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003052def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003053 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003054 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003055def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003056 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003057 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003058def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003059 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003060 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003061def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003062 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003063 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003064def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003065 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003066 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003067def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003068 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003069 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003070def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003071 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003072 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003073
3074def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003075 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003076 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003077def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003078 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003079 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003080def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003081 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003082 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003083def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003084 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003085 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003086def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003087 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003088 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003089def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003090 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003091 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003092def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003093 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003094 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003095def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003096 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003097 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003098
3099def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003100 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003101 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003102def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003103 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003104 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003105def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003106 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003107 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003108def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003109 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003110 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003111}
3112
Dale Johannesenf160d802008-10-02 18:53:47 +00003113let Constraints = "$val1 = $dst1, $val2 = $dst2",
3114 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3115 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003116 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003117 usesCustomDAGSchedInserter = 1 in {
3118def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3119 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003120 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003121def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3122 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003123 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003124def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3125 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003126 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003127def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3128 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003129 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003130def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3131 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003132 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003133def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3134 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003135 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003136def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3137 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003138 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003139}
3140
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003141//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003142// Non-Instruction Patterns
3143//===----------------------------------------------------------------------===//
3144
Bill Wendlingfef06052008-09-16 21:48:12 +00003145// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003146def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3147def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003148def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003149def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3150def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3151
3152def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3153 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3154def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3155 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3156def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3157 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3158def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3159 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3160
3161def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3162 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3163def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3164 (MOV32mi addr:$dst, texternalsym:$src)>;
3165
3166// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003167// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003168def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003169 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003170
3171def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003172 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003173def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003174 (TAILCALL)>;
3175
3176def : Pat<(X86tcret GR32:$dst, imm:$off),
3177 (TCRETURNri GR32:$dst, imm:$off)>;
3178
3179def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3180 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3181
3182def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3183 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003184
3185def : Pat<(X86call (i32 tglobaladdr:$dst)),
3186 (CALLpcrel32 tglobaladdr:$dst)>;
3187def : Pat<(X86call (i32 texternalsym:$dst)),
3188 (CALLpcrel32 texternalsym:$dst)>;
3189
3190// X86 specific add which produces a flag.
3191def : Pat<(addc GR32:$src1, GR32:$src2),
3192 (ADD32rr GR32:$src1, GR32:$src2)>;
3193def : Pat<(addc GR32:$src1, (load addr:$src2)),
3194 (ADD32rm GR32:$src1, addr:$src2)>;
3195def : Pat<(addc GR32:$src1, imm:$src2),
3196 (ADD32ri GR32:$src1, imm:$src2)>;
3197def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3198 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3199
3200def : Pat<(subc GR32:$src1, GR32:$src2),
3201 (SUB32rr GR32:$src1, GR32:$src2)>;
3202def : Pat<(subc GR32:$src1, (load addr:$src2)),
3203 (SUB32rm GR32:$src1, addr:$src2)>;
3204def : Pat<(subc GR32:$src1, imm:$src2),
3205 (SUB32ri GR32:$src1, imm:$src2)>;
3206def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3207 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3208
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003209// Comparisons.
3210
3211// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003212def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003213 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003214def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003215 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003216def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003217 (TEST32rr GR32:$src1, GR32:$src1)>;
3218
Dan Gohman0a3c5222009-01-07 01:00:24 +00003219// Conditional moves with folded loads with operands swapped and conditions
3220// inverted.
3221def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3222 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3223def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3224 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3225def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3226 (CMOVB16rm GR16:$src2, addr:$src1)>;
3227def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3228 (CMOVB32rm GR32:$src2, addr:$src1)>;
3229def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3230 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3231def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3232 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3233def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3234 (CMOVE16rm GR16:$src2, addr:$src1)>;
3235def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3236 (CMOVE32rm GR32:$src2, addr:$src1)>;
3237def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3238 (CMOVA16rm GR16:$src2, addr:$src1)>;
3239def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3240 (CMOVA32rm GR32:$src2, addr:$src1)>;
3241def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3242 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3243def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3244 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3245def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3246 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3247def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3248 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3249def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3250 (CMOVL16rm GR16:$src2, addr:$src1)>;
3251def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3252 (CMOVL32rm GR32:$src2, addr:$src1)>;
3253def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3254 (CMOVG16rm GR16:$src2, addr:$src1)>;
3255def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3256 (CMOVG32rm GR32:$src2, addr:$src1)>;
3257def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3258 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3259def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3260 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3261def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3262 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3263def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3264 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3265def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3266 (CMOVP16rm GR16:$src2, addr:$src1)>;
3267def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3268 (CMOVP32rm GR32:$src2, addr:$src1)>;
3269def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3270 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3271def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3272 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3273def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3274 (CMOVS16rm GR16:$src2, addr:$src1)>;
3275def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3276 (CMOVS32rm GR32:$src2, addr:$src1)>;
3277def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3278 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3279def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3280 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3281def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3282 (CMOVO16rm GR16:$src2, addr:$src1)>;
3283def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3284 (CMOVO32rm GR32:$src2, addr:$src1)>;
3285
Duncan Sands082524c2008-01-23 20:39:46 +00003286// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003287def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3288def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3289def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3290
3291// extload bool -> extload byte
3292def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003293def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3294 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003295def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003296def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3297 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003298def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3299def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3300
Dan Gohmandd612bb2008-08-20 21:27:32 +00003301// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003302def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3303 Requires<[In32BitMode]>;
3304def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3305 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003306def : Pat<(i32 (anyext GR16:$src)),
3307 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003308
Evan Chengf2abee72007-12-13 00:43:27 +00003309// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003310def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3311 (MOVZX32rm8 addr:$src)>;
3312def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3313 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003314
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003315//===----------------------------------------------------------------------===//
3316// Some peepholes
3317//===----------------------------------------------------------------------===//
3318
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003319// Odd encoding trick: -128 fits into an 8-bit immediate field while
3320// +128 doesn't, so in this special case use a sub instead of an add.
3321def : Pat<(add GR16:$src1, 128),
3322 (SUB16ri8 GR16:$src1, -128)>;
3323def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3324 (SUB16mi8 addr:$dst, -128)>;
3325def : Pat<(add GR32:$src1, 128),
3326 (SUB32ri8 GR32:$src1, -128)>;
3327def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3328 (SUB32mi8 addr:$dst, -128)>;
3329
Dan Gohman9203ab42008-07-30 18:09:17 +00003330// r & (2^16-1) ==> movz
3331def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003332 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003333// r & (2^8-1) ==> movz
3334def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003335 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3336 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003337 Requires<[In32BitMode]>;
3338// r & (2^8-1) ==> movz
3339def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003340 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3341 x86_subreg_8bit)))>,
3342 Requires<[In32BitMode]>;
3343
3344// sext_inreg patterns
3345def : Pat<(sext_inreg GR32:$src, i16),
3346 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3347def : Pat<(sext_inreg GR32:$src, i8),
3348 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3349 x86_subreg_8bit)))>,
3350 Requires<[In32BitMode]>;
3351def : Pat<(sext_inreg GR16:$src, i8),
3352 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3353 x86_subreg_8bit)))>,
3354 Requires<[In32BitMode]>;
3355
3356// trunc patterns
3357def : Pat<(i16 (trunc GR32:$src)),
3358 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3359def : Pat<(i8 (trunc GR32:$src)),
3360 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3361 Requires<[In32BitMode]>;
3362def : Pat<(i8 (trunc GR16:$src)),
3363 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003364 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003365
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003366// (shl x, 1) ==> (add x, x)
3367def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3368def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3369def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3370
Evan Cheng76a64c72008-08-30 02:03:58 +00003371// (shl x (and y, 31)) ==> (shl x, y)
3372def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3373 (SHL8rCL GR8:$src1)>;
3374def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3375 (SHL16rCL GR16:$src1)>;
3376def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3377 (SHL32rCL GR32:$src1)>;
3378def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3379 (SHL8mCL addr:$dst)>;
3380def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3381 (SHL16mCL addr:$dst)>;
3382def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3383 (SHL32mCL addr:$dst)>;
3384
3385def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3386 (SHR8rCL GR8:$src1)>;
3387def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3388 (SHR16rCL GR16:$src1)>;
3389def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3390 (SHR32rCL GR32:$src1)>;
3391def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3392 (SHR8mCL addr:$dst)>;
3393def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3394 (SHR16mCL addr:$dst)>;
3395def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3396 (SHR32mCL addr:$dst)>;
3397
3398def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3399 (SAR8rCL GR8:$src1)>;
3400def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3401 (SAR16rCL GR16:$src1)>;
3402def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3403 (SAR32rCL GR32:$src1)>;
3404def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3405 (SAR8mCL addr:$dst)>;
3406def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3407 (SAR16mCL addr:$dst)>;
3408def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3409 (SAR32mCL addr:$dst)>;
3410
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003411// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3412def : Pat<(or (srl GR32:$src1, CL:$amt),
3413 (shl GR32:$src2, (sub 32, CL:$amt))),
3414 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3415
3416def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3417 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3418 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3419
Dan Gohman921581d2008-10-17 01:23:35 +00003420def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3421 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3422 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3423
3424def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3425 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3426 addr:$dst),
3427 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3428
3429def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3430 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3431
3432def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3433 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3434 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3435
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003436// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3437def : Pat<(or (shl GR32:$src1, CL:$amt),
3438 (srl GR32:$src2, (sub 32, CL:$amt))),
3439 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3440
3441def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3442 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3443 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3444
Dan Gohman921581d2008-10-17 01:23:35 +00003445def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3446 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3447 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3448
3449def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3450 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3451 addr:$dst),
3452 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3453
3454def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3455 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3456
3457def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3458 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3459 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3460
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003461// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3462def : Pat<(or (srl GR16:$src1, CL:$amt),
3463 (shl GR16:$src2, (sub 16, CL:$amt))),
3464 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3465
3466def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3467 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3468 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3469
Dan Gohman921581d2008-10-17 01:23:35 +00003470def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3471 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3472 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3473
3474def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3475 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3476 addr:$dst),
3477 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3478
3479def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3480 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3481
3482def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3483 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3484 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3485
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003486// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3487def : Pat<(or (shl GR16:$src1, CL:$amt),
3488 (srl GR16:$src2, (sub 16, CL:$amt))),
3489 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3490
3491def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3492 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3493 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3494
Dan Gohman921581d2008-10-17 01:23:35 +00003495def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3496 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3497 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3498
3499def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3500 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3501 addr:$dst),
3502 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3503
3504def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3505 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3506
3507def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3508 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3509 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3510
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003511//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003512// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003513//===----------------------------------------------------------------------===//
3514
Dan Gohman99a12192009-03-04 19:44:21 +00003515// Register-Register Addition with EFLAGS result
3516def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003517 (implicit EFLAGS)),
3518 (ADD8rr GR8:$src1, GR8:$src2)>;
3519
Dan Gohman99a12192009-03-04 19:44:21 +00003520// Register-Register Addition with EFLAGS result
3521def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003522 (implicit EFLAGS)),
3523 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003524def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003525 (implicit EFLAGS)),
3526 (ADD32rr GR32:$src1, GR32:$src2)>;
3527
Dan Gohman99a12192009-03-04 19:44:21 +00003528// Register-Memory Addition with EFLAGS result
3529def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003530 (implicit EFLAGS)),
3531 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003532def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003533 (implicit EFLAGS)),
3534 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003535def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003536 (implicit EFLAGS)),
3537 (ADD32rm GR32:$src1, addr:$src2)>;
3538
Dan Gohman99a12192009-03-04 19:44:21 +00003539// Register-Integer Addition with EFLAGS result
3540def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003541 (implicit EFLAGS)),
3542 (ADD8ri GR8:$src1, imm:$src2)>;
3543
Dan Gohman99a12192009-03-04 19:44:21 +00003544// Register-Integer Addition with EFLAGS result
3545def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003546 (implicit EFLAGS)),
3547 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003548def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003549 (implicit EFLAGS)),
3550 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003551def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003552 (implicit EFLAGS)),
3553 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003554def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003555 (implicit EFLAGS)),
3556 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3557
Dan Gohman99a12192009-03-04 19:44:21 +00003558// Memory-Register Addition with EFLAGS result
3559def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003560 addr:$dst),
3561 (implicit EFLAGS)),
3562 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003563def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003564 addr:$dst),
3565 (implicit EFLAGS)),
3566 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003567def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003568 addr:$dst),
3569 (implicit EFLAGS)),
3570 (ADD32mr addr:$dst, GR32:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003571def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003572 addr:$dst),
3573 (implicit EFLAGS)),
3574 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003575def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003576 addr:$dst),
3577 (implicit EFLAGS)),
3578 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003579def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003580 addr:$dst),
3581 (implicit EFLAGS)),
3582 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003583def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003584 addr:$dst),
3585 (implicit EFLAGS)),
3586 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003587def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003588 addr:$dst),
3589 (implicit EFLAGS)),
3590 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3591
Dan Gohman99a12192009-03-04 19:44:21 +00003592// Register-Register Subtraction with EFLAGS result
3593def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003594 (implicit EFLAGS)),
3595 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003596def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003597 (implicit EFLAGS)),
3598 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003599def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003600 (implicit EFLAGS)),
3601 (SUB32rr GR32:$src1, GR32:$src2)>;
3602
Dan Gohman99a12192009-03-04 19:44:21 +00003603// Register-Memory Subtraction with EFLAGS result
3604def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003605 (implicit EFLAGS)),
3606 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003607def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003608 (implicit EFLAGS)),
3609 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003610def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003611 (implicit EFLAGS)),
3612 (SUB32rm GR32:$src1, addr:$src2)>;
3613
Dan Gohman99a12192009-03-04 19:44:21 +00003614// Register-Integer Subtraction with EFLAGS result
3615def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003616 (implicit EFLAGS)),
3617 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003618def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003619 (implicit EFLAGS)),
3620 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003621def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003622 (implicit EFLAGS)),
3623 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003624def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003625 (implicit EFLAGS)),
3626 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003627def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003628 (implicit EFLAGS)),
3629 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3630
Dan Gohman99a12192009-03-04 19:44:21 +00003631// Memory-Register Subtraction with EFLAGS result
3632def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003633 addr:$dst),
3634 (implicit EFLAGS)),
3635 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003636def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003637 addr:$dst),
3638 (implicit EFLAGS)),
3639 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003640def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003641 addr:$dst),
3642 (implicit EFLAGS)),
3643 (SUB32mr addr:$dst, GR32:$src2)>;
3644
Dan Gohman99a12192009-03-04 19:44:21 +00003645// Memory-Integer Subtraction with EFLAGS result
3646def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003647 addr:$dst),
3648 (implicit EFLAGS)),
3649 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003650def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003651 addr:$dst),
3652 (implicit EFLAGS)),
3653 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003654def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003655 addr:$dst),
3656 (implicit EFLAGS)),
3657 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003658def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003659 addr:$dst),
3660 (implicit EFLAGS)),
3661 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003662def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003663 addr:$dst),
3664 (implicit EFLAGS)),
3665 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3666
3667
Dan Gohman99a12192009-03-04 19:44:21 +00003668// Register-Register Signed Integer Multiply with EFLAGS result
3669def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003670 (implicit EFLAGS)),
3671 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003672def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003673 (implicit EFLAGS)),
3674 (IMUL32rr GR32:$src1, GR32:$src2)>;
3675
Dan Gohman99a12192009-03-04 19:44:21 +00003676// Register-Memory Signed Integer Multiply with EFLAGS result
3677def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003678 (implicit EFLAGS)),
3679 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003680def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003681 (implicit EFLAGS)),
3682 (IMUL32rm GR32:$src1, addr:$src2)>;
3683
Dan Gohman99a12192009-03-04 19:44:21 +00003684// Register-Integer Signed Integer Multiply with EFLAGS result
3685def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003686 (implicit EFLAGS)),
3687 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003688def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003689 (implicit EFLAGS)),
3690 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003691def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003692 (implicit EFLAGS)),
3693 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003694def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003695 (implicit EFLAGS)),
3696 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3697
Dan Gohman99a12192009-03-04 19:44:21 +00003698// Memory-Integer Signed Integer Multiply with EFLAGS result
3699def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003700 (implicit EFLAGS)),
3701 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003702def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003703 (implicit EFLAGS)),
3704 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003705def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003706 (implicit EFLAGS)),
3707 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003708def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003709 (implicit EFLAGS)),
3710 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3711
Dan Gohman99a12192009-03-04 19:44:21 +00003712// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003713let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003714def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003715 (implicit EFLAGS)),
3716 (ADD16rr GR16:$src1, GR16:$src1)>;
3717
Dan Gohman99a12192009-03-04 19:44:21 +00003718def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003719 (implicit EFLAGS)),
3720 (ADD32rr GR32:$src1, GR32:$src1)>;
3721}
3722
Dan Gohman99a12192009-03-04 19:44:21 +00003723// INC and DEC with EFLAGS result. Note that these do not set CF.
3724def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3725 (INC8r GR8:$src)>;
3726def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3727 (implicit EFLAGS)),
3728 (INC8m addr:$dst)>;
3729def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3730 (DEC8r GR8:$src)>;
3731def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3732 (implicit EFLAGS)),
3733 (DEC8m addr:$dst)>;
3734
3735def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003736 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003737def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3738 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003739 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003740def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003741 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003742def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3743 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003744 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003745
3746def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003747 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003748def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3749 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003750 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003751def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003752 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003753def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3754 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003755 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003756
Bill Wendlingf5399032008-12-12 21:15:41 +00003757//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003758// Floating Point Stack Support
3759//===----------------------------------------------------------------------===//
3760
3761include "X86InstrFPStack.td"
3762
3763//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003764// X86-64 Support
3765//===----------------------------------------------------------------------===//
3766
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003767include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003768
3769//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003770// XMM Floating point support (requires SSE / SSE2)
3771//===----------------------------------------------------------------------===//
3772
3773include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003774
3775//===----------------------------------------------------------------------===//
3776// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3777//===----------------------------------------------------------------------===//
3778
3779include "X86InstrMMX.td"