blob: 5638182f7c25cfd20399b5eee2f9f3819d847be6 [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
Bill Wendlingf5399032008-12-12 21:15:41 +000030def SDTUnaryArithOvf : SDTypeProfile<1, 1,
31 [SDTCisInt<0>]>;
32def SDTBinaryArithOvf : SDTypeProfile<1, 2,
33 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
34 SDTCisInt<0>]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +000035
Evan Cheng621216e2007-09-29 00:00:36 +000036def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000037 [SDTCisVT<0, OtherVT>,
38 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000039
Evan Cheng621216e2007-09-29 00:00:36 +000040def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000041 [SDTCisVT<0, i8>,
42 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000044def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
45 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000046def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000047
Dale Johannesenf160d802008-10-02 18:53:47 +000048def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
49 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000050def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000051
Bill Wendling7173da52007-11-13 09:19:02 +000052def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
53def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
54 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000055
Dan Gohman3329ffe2008-05-29 19:57:41 +000056def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057
58def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
59
60def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
61
62def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
63
64def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
65
66def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
67
68def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
69
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000070def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
71
Evan Cheng48679f42007-12-14 02:13:44 +000072def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
73def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000074def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
75def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
76
Evan Cheng621216e2007-09-29 00:00:36 +000077def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000078
Evan Cheng621216e2007-09-29 00:00:36 +000079def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000080def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000081 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000082def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000084def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
85 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
86 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000087def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
89 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000090def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
91 [SDNPHasChain, SDNPMayStore,
92 SDNPMayLoad, SDNPMemOperand]>;
93def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
102def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
105def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
106 [SDNPHasChain, SDNPMayStore,
107 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000108def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
109 [SDNPHasChain, SDNPMayStore,
110 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000111def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
112 [SDNPHasChain, SDNPOptInFlag]>;
113
114def X86callseq_start :
115 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
116 [SDNPHasChain, SDNPOutFlag]>;
117def X86callseq_end :
118 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000119 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120
121def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
122 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
123
124def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
125 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
126
127def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000128 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000129def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000130 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
131 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132
133def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000134 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135
136def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
137def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
138
139def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000140 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000141def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
142
143def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
144 [SDNPHasChain]>;
145
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000146def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
147 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000148
Bill Wendlingf5399032008-12-12 21:15:41 +0000149def X86add_ovf : SDNode<"X86ISD::ADD", SDTBinaryArithOvf>;
150def X86sub_ovf : SDNode<"X86ISD::SUB", SDTBinaryArithOvf>;
151def X86smul_ovf : SDNode<"X86ISD::SMUL", SDTBinaryArithOvf>;
152def X86umul_ovf : SDNode<"X86ISD::UMUL", SDTUnaryArithOvf>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000153
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000154//===----------------------------------------------------------------------===//
155// X86 Operand Definitions.
156//
157
158// *mem - Operand definitions for the funky X86 addressing mode operands.
159//
160class X86MemOperand<string printMethod> : Operand<iPTR> {
161 let PrintMethod = printMethod;
162 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
163}
164
165def i8mem : X86MemOperand<"printi8mem">;
166def i16mem : X86MemOperand<"printi16mem">;
167def i32mem : X86MemOperand<"printi32mem">;
168def i64mem : X86MemOperand<"printi64mem">;
169def i128mem : X86MemOperand<"printi128mem">;
170def f32mem : X86MemOperand<"printf32mem">;
171def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000172def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173def f128mem : X86MemOperand<"printf128mem">;
174
175def lea32mem : Operand<i32> {
176 let PrintMethod = "printi32mem";
177 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
178}
179
180def SSECC : Operand<i8> {
181 let PrintMethod = "printSSECC";
182}
183
184def piclabel: Operand<i32> {
185 let PrintMethod = "printPICLabel";
186}
187
188// A couple of more descriptive operand definitions.
189// 16-bits but only 8 bits are significant.
190def i16i8imm : Operand<i16>;
191// 32-bits but only 8 bits are significant.
192def i32i8imm : Operand<i32>;
193
194// Branch targets have OtherVT type.
195def brtarget : Operand<OtherVT>;
196
197//===----------------------------------------------------------------------===//
198// X86 Complex Pattern Definitions.
199//
200
201// Define X86 specific addressing mode.
202def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
203def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
204 [add, mul, shl, or, frameindex], []>;
205
206//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207// X86 Instruction Predicate Definitions.
208def HasMMX : Predicate<"Subtarget->hasMMX()">;
209def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
210def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
211def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
212def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000213def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
214def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000215def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
216def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000217def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
218def In64BitMode : Predicate<"Subtarget->is64Bit()">;
219def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
220def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
221def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000222def OptForSpeed : Predicate<"!OptForSize">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223
224//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000225// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000226//
227
Evan Cheng86ab7d32007-07-31 08:04:03 +0000228include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229
230//===----------------------------------------------------------------------===//
231// Pattern fragments...
232//
233
234// X86 specific condition code. These correspond to CondCode in
235// X86InstrInfo.h. They must be kept in synch.
236def X86_COND_A : PatLeaf<(i8 0)>;
237def X86_COND_AE : PatLeaf<(i8 1)>;
238def X86_COND_B : PatLeaf<(i8 2)>;
239def X86_COND_BE : PatLeaf<(i8 3)>;
240def X86_COND_E : PatLeaf<(i8 4)>;
241def X86_COND_G : PatLeaf<(i8 5)>;
242def X86_COND_GE : PatLeaf<(i8 6)>;
243def X86_COND_L : PatLeaf<(i8 7)>;
244def X86_COND_LE : PatLeaf<(i8 8)>;
245def X86_COND_NE : PatLeaf<(i8 9)>;
246def X86_COND_NO : PatLeaf<(i8 10)>;
247def X86_COND_NP : PatLeaf<(i8 11)>;
248def X86_COND_NS : PatLeaf<(i8 12)>;
Bill Wendlingd06b4202008-11-26 22:37:40 +0000249def X86_COND_NC : PatLeaf<(i8 13)>;
250def X86_COND_O : PatLeaf<(i8 14)>;
251def X86_COND_P : PatLeaf<(i8 15)>;
252def X86_COND_S : PatLeaf<(i8 16)>;
253def X86_COND_C : PatLeaf<(i8 17)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000254
255def i16immSExt8 : PatLeaf<(i16 imm), [{
256 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
257 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000258 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259}]>;
260
261def i32immSExt8 : PatLeaf<(i32 imm), [{
262 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
263 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000264 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265}]>;
266
267// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000268// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
269// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000270def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000271 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000272 ISD::LoadExtType ExtType = LD->getExtensionType();
273 if (ExtType == ISD::NON_EXTLOAD)
274 return true;
275 if (ExtType == ISD::EXTLOAD)
276 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000277 return false;
278}]>;
279
Dan Gohman2a174122008-10-15 06:50:19 +0000280def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000281 LoadSDNode *LD = cast<LoadSDNode>(N);
Evan Cheng56ec77b2008-09-24 23:27:55 +0000282 ISD::LoadExtType ExtType = LD->getExtensionType();
283 if (ExtType == ISD::EXTLOAD)
284 return LD->getAlignment() >= 2 && !LD->isVolatile();
285 return false;
286}]>;
287
Dan Gohman2a174122008-10-15 06:50:19 +0000288def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000289 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000290 ISD::LoadExtType ExtType = LD->getExtensionType();
291 if (ExtType == ISD::NON_EXTLOAD)
292 return true;
293 if (ExtType == ISD::EXTLOAD)
294 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000295 return false;
296}]>;
297
Dan Gohman2a174122008-10-15 06:50:19 +0000298def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000299 LoadSDNode *LD = cast<LoadSDNode>(N);
300 if (LD->isVolatile())
301 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000302 ISD::LoadExtType ExtType = LD->getExtensionType();
303 if (ExtType == ISD::NON_EXTLOAD)
304 return true;
305 if (ExtType == ISD::EXTLOAD)
306 return LD->getAlignment() >= 4;
307 return false;
308}]>;
309
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
312
313def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
314def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000315def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
318def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
319def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
320
321def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
322def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
323def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
324def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
325def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
326def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
327
328def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
329def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
330def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
331def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
332def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
333def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
334
Chris Lattner21da6382008-02-19 17:37:35 +0000335
336// An 'and' node with a single use.
337def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000338 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000339}]>;
340
Dan Gohman921581d2008-10-17 01:23:35 +0000341// 'shld' and 'shrd' instruction patterns. Note that even though these have
342// the srl and shl in their patterns, the C++ code must still check for them,
343// because predicates are tested before children nodes are explored.
344
345def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
346 (or (srl node:$src1, node:$amt1),
347 (shl node:$src2, node:$amt2)), [{
348 assert(N->getOpcode() == ISD::OR);
349 return N->getOperand(0).getOpcode() == ISD::SRL &&
350 N->getOperand(1).getOpcode() == ISD::SHL &&
351 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
352 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
353 N->getOperand(0).getConstantOperandVal(1) ==
354 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
355}]>;
356
357def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
358 (or (shl node:$src1, node:$amt1),
359 (srl node:$src2, node:$amt2)), [{
360 assert(N->getOpcode() == ISD::OR);
361 return N->getOperand(0).getOpcode() == ISD::SHL &&
362 N->getOperand(1).getOpcode() == ISD::SRL &&
363 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
364 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
365 N->getOperand(0).getConstantOperandVal(1) ==
366 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
367}]>;
368
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000370// Instruction list...
371//
372
373// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
374// a stack adjustment and the codegen must know that they may modify the stack
375// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000376// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
377// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000378let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000379def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
380 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000381 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000382 Requires<[In32BitMode]>;
383def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
384 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000385 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000386 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000387}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388
389// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000390let neverHasSideEffects = 1 in
391 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392
Evan Cheng0729ccf2008-01-05 00:41:47 +0000393// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000394let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000395 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
396 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000397
398//===----------------------------------------------------------------------===//
399// Control Flow Instructions...
400//
401
402// Return instructions.
403let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000404 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000405 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000406 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000407 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000408 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
409 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410 [(X86retflag imm:$amt)]>;
411}
412
413// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000414let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000415 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
416 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000418let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000419 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420
Owen Andersonf8053082007-11-12 07:39:39 +0000421// Indirect branches
422let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000423 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000425 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426 [(brind (loadi32 addr:$dst))]>;
427}
428
429// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000430let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000431def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000432 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000433def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000434 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000435def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000436 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000437def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000438 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000439def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000440 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000441def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000442 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443
Dan Gohman91888f02007-07-31 20:11:57 +0000444def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000445 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000446def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000447 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000448def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000449 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000450def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000451 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452
Dan Gohman91888f02007-07-31 20:11:57 +0000453def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000454 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000455def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000456 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000457def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000458 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000459def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000460 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000461def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000462 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000463def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000464 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Bill Wendlingd06b4202008-11-26 22:37:40 +0000465def JC : IBr<0x82, (ins brtarget:$dst), "jc\t$dst",
466 [(X86brcond bb:$dst, X86_COND_C, EFLAGS)]>, TB;
467def JNC : IBr<0x83, (ins brtarget:$dst), "jnc\t$dst",
468 [(X86brcond bb:$dst, X86_COND_NC, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000469} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470
471//===----------------------------------------------------------------------===//
472// Call Instructions...
473//
Evan Cheng37e7c752007-07-21 00:34:19 +0000474let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000475 // All calls clobber the non-callee saved registers. ESP is marked as
476 // a use to prevent stack-pointer assignments that appear immediately
477 // before calls from potentially appearing dead. Uses for argument
478 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000479 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
480 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000481 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
482 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000483 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000484 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
485 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000486 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000487 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000488 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000489 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490 }
491
492// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000493
Chris Lattnerb56cc342008-03-11 03:23:40 +0000494def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000495 "#TAILCALL",
496 []>;
497
Evan Cheng37e7c752007-07-21 00:34:19 +0000498let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000499def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000500 "#TC_RETURN $dst $offset",
501 []>;
502
503let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000504def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000505 "#TC_RETURN $dst $offset",
506 []>;
507
508let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000509
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000510 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000511 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000512let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000513 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
514 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000515let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000516 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000517 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000518
519//===----------------------------------------------------------------------===//
520// Miscellaneous Instructions...
521//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000522let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000524 (outs), (ins), "leave", []>;
525
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000526let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
527let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000528def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000530let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000531def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000532}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000533
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000534let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000535def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000536let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000537def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000538
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539let isTwoAddress = 1 in // GR32 = bswap GR32
540 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000541 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000542 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
544
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545
Evan Cheng48679f42007-12-14 02:13:44 +0000546// Bit scan instructions.
547let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000548def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000549 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000550 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000551def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000552 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000553 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
554 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000555def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000556 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000557 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000558def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000559 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000560 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
561 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000562
Evan Cheng4e33de92007-12-14 18:49:43 +0000563def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000564 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000565 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000566def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000567 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000568 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
569 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000570def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000571 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000572 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000573def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000574 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000575 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
576 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000577} // Defs = [EFLAGS]
578
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000579let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000581 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000582 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000583let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000585 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000586 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000587 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
588
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000589let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000590def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000591 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000592def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000593 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000594def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000595 [(X86rep_movs i32)]>, REP;
596}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000598let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000599def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000600 [(X86rep_stos i8)]>, REP;
601let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000602def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000603 [(X86rep_stos i16)]>, REP, OpSize;
604let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000605def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000606 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000608let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000609def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000610 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000612let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000613def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000614}
615
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616//===----------------------------------------------------------------------===//
617// Input/Output Instructions...
618//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000619let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000620def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000621 "in{b}\t{%dx, %al|%AL, %DX}", []>;
622let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000623def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000624 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
625let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000626def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000627 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000629let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000630def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000631 "in{b}\t{$port, %al|%AL, $port}", []>;
632let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000633def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000634 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
635let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000636def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000637 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000639let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000640def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000641 "out{b}\t{%al, %dx|%DX, %AL}", []>;
642let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000643def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000644 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
645let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000646def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000647 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000649let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000650def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000651 "out{b}\t{%al, $port|$port, %AL}", []>;
652let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000653def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000654 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
655let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000656def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000657 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658
659//===----------------------------------------------------------------------===//
660// Move Instructions...
661//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000662let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000663def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000664 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000665def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000666 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000667def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000668 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000669}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000670let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000671def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000672 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000674def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000677def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000678 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679 [(set GR32:$dst, imm:$src)]>;
680}
Evan Chengb783fa32007-07-19 01:14:50 +0000681def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000682 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000684def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000685 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000687def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000688 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689 [(store (i32 imm:$src), addr:$dst)]>;
690
Dan Gohman5574cc72008-12-03 18:15:48 +0000691let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000692def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000693 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000695def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000696 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000698def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000699 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000701}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702
Evan Chengb783fa32007-07-19 01:14:50 +0000703def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000704 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000706def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000707 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000709def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000710 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711 [(store GR32:$src, addr:$dst)]>;
712
713//===----------------------------------------------------------------------===//
714// Fixed-Register Multiplication and Division Instructions...
715//
716
717// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000718let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000719def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
721 // This probably ought to be moved to a def : Pat<> if the
722 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000723 [(set AL, (mul AL, GR8:$src)),
724 (implicit EFLAGS)]>; // AL,AH = AL*GR8
725
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000726let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000727def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
728 "mul{w}\t$src",
729 []>, OpSize; // AX,DX = AX*GR16
730
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000731let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000732def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
733 "mul{l}\t$src",
734 []>; // EAX,EDX = EAX*GR32
735
Evan Cheng55687072007-09-14 21:48:26 +0000736let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000737def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000738 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
740 // This probably ought to be moved to a def : Pat<> if the
741 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000742 [(set AL, (mul AL, (loadi8 addr:$src))),
743 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
744
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000745let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000746let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000747def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000748 "mul{w}\t$src",
749 []>, OpSize; // AX,DX = AX*[mem16]
750
Evan Cheng55687072007-09-14 21:48:26 +0000751let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000752def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000753 "mul{l}\t$src",
754 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000755}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000757let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000758let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000759def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
760 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000761let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000762def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000763 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000764let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000765def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
766 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000767let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000768let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000769def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000770 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000771let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000772def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000773 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
774let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000775def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000776 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000777}
Dan Gohmand44572d2008-11-18 21:29:14 +0000778} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779
780// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000781let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000782def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000783 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000784let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000785def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000786 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000787let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000788def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000789 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000790let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000791let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000792def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000793 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000794let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000795def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000796 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000797let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000798def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000799 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000800}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801
802// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000803let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000804def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000805 "idiv{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 IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000808 "idiv{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 IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000811 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000812let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000813let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000814def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000815 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000816let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000817def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000818 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000819let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000820def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000821 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000822}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823
824//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000825// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826//
827let isTwoAddress = 1 in {
828
829// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000830let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000831let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000833 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000834 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000836 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000839 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000840 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000842 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844
845def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000846 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000847 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000849 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000852 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000853 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000855 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000858 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000859 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000861 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000864 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000865 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000867 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000869def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000870 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000871 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000873 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000876 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000877 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000879 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000882 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000883 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000885 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000888 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000889 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000891 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000894 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000895 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000897 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000900 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000901 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000903 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000906 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000907 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000909 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000912 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000913 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000915 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000918 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000919 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000921 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000924 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000925 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000927 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000930 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000931 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000933 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000936 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000937 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000939 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000942 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000943 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000945 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000948 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000949 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000951 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000954 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000955 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000957 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000960 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000961 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000963 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000966 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000967 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000969 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000972 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000973 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000975 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000978 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000979 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000981 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000984 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000985 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000987 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000990 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000993 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000996 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000999 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000 TB;
Evan Cheng926658c2007-10-05 23:13:21 +00001001} // isCommutable = 1
1002
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +00001004 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001005 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00001007 X86_COND_NP, EFLAGS))]>,
1008 TB;
Evan Cheng926658c2007-10-05 23:13:21 +00001009
1010def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1011 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1012 "cmovb\t{$src2, $dst|$dst, $src2}",
1013 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1014 X86_COND_B, EFLAGS))]>,
1015 TB, OpSize;
1016def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1017 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1018 "cmovb\t{$src2, $dst|$dst, $src2}",
1019 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1020 X86_COND_B, EFLAGS))]>,
1021 TB;
1022def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1023 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1024 "cmovae\t{$src2, $dst|$dst, $src2}",
1025 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1026 X86_COND_AE, EFLAGS))]>,
1027 TB, OpSize;
1028def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1029 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1030 "cmovae\t{$src2, $dst|$dst, $src2}",
1031 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1032 X86_COND_AE, EFLAGS))]>,
1033 TB;
1034def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1035 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1036 "cmove\t{$src2, $dst|$dst, $src2}",
1037 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1038 X86_COND_E, EFLAGS))]>,
1039 TB, OpSize;
1040def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1041 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1042 "cmove\t{$src2, $dst|$dst, $src2}",
1043 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1044 X86_COND_E, EFLAGS))]>,
1045 TB;
1046def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1047 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1048 "cmovne\t{$src2, $dst|$dst, $src2}",
1049 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1050 X86_COND_NE, EFLAGS))]>,
1051 TB, OpSize;
1052def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1053 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1054 "cmovne\t{$src2, $dst|$dst, $src2}",
1055 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1056 X86_COND_NE, EFLAGS))]>,
1057 TB;
1058def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1059 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1060 "cmovbe\t{$src2, $dst|$dst, $src2}",
1061 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1062 X86_COND_BE, EFLAGS))]>,
1063 TB, OpSize;
1064def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1065 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1066 "cmovbe\t{$src2, $dst|$dst, $src2}",
1067 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1068 X86_COND_BE, EFLAGS))]>,
1069 TB;
1070def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1071 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1072 "cmova\t{$src2, $dst|$dst, $src2}",
1073 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1074 X86_COND_A, EFLAGS))]>,
1075 TB, OpSize;
1076def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1077 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1078 "cmova\t{$src2, $dst|$dst, $src2}",
1079 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1080 X86_COND_A, EFLAGS))]>,
1081 TB;
1082def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1083 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1084 "cmovl\t{$src2, $dst|$dst, $src2}",
1085 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1086 X86_COND_L, EFLAGS))]>,
1087 TB, OpSize;
1088def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1089 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1090 "cmovl\t{$src2, $dst|$dst, $src2}",
1091 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1092 X86_COND_L, EFLAGS))]>,
1093 TB;
1094def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1095 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1096 "cmovge\t{$src2, $dst|$dst, $src2}",
1097 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1098 X86_COND_GE, EFLAGS))]>,
1099 TB, OpSize;
1100def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1101 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1102 "cmovge\t{$src2, $dst|$dst, $src2}",
1103 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1104 X86_COND_GE, EFLAGS))]>,
1105 TB;
1106def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1107 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1108 "cmovle\t{$src2, $dst|$dst, $src2}",
1109 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1110 X86_COND_LE, EFLAGS))]>,
1111 TB, OpSize;
1112def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1113 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1114 "cmovle\t{$src2, $dst|$dst, $src2}",
1115 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1116 X86_COND_LE, EFLAGS))]>,
1117 TB;
1118def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1119 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1120 "cmovg\t{$src2, $dst|$dst, $src2}",
1121 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1122 X86_COND_G, EFLAGS))]>,
1123 TB, OpSize;
1124def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1125 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1126 "cmovg\t{$src2, $dst|$dst, $src2}",
1127 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1128 X86_COND_G, EFLAGS))]>,
1129 TB;
1130def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1131 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1132 "cmovs\t{$src2, $dst|$dst, $src2}",
1133 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1134 X86_COND_S, EFLAGS))]>,
1135 TB, OpSize;
1136def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1137 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1138 "cmovs\t{$src2, $dst|$dst, $src2}",
1139 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1140 X86_COND_S, EFLAGS))]>,
1141 TB;
1142def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1143 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1144 "cmovns\t{$src2, $dst|$dst, $src2}",
1145 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1146 X86_COND_NS, EFLAGS))]>,
1147 TB, OpSize;
1148def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1149 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1150 "cmovns\t{$src2, $dst|$dst, $src2}",
1151 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1152 X86_COND_NS, EFLAGS))]>,
1153 TB;
1154def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1155 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1156 "cmovp\t{$src2, $dst|$dst, $src2}",
1157 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1158 X86_COND_P, EFLAGS))]>,
1159 TB, OpSize;
1160def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1161 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1162 "cmovp\t{$src2, $dst|$dst, $src2}",
1163 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1164 X86_COND_P, EFLAGS))]>,
1165 TB;
1166def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1167 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1168 "cmovnp\t{$src2, $dst|$dst, $src2}",
1169 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1170 X86_COND_NP, EFLAGS))]>,
1171 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001172} // Uses = [EFLAGS]
1173
1174
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175// unary instructions
1176let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001177let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001178def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001180def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001182def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001183 [(set GR32:$dst, (ineg GR32:$src))]>;
1184let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001185 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001186 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001187 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001189 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1191
1192}
Evan Cheng55687072007-09-14 21:48:26 +00001193} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194
Dan Gohman91888f02007-07-31 20:11:57 +00001195def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001196 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001197def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001199def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200 [(set GR32:$dst, (not GR32:$src))]>;
1201let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001202 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001203 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001204 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001206 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1208}
1209} // CodeSize
1210
1211// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001212let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001214def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 [(set GR8:$dst, (add GR8:$src, 1))]>;
1216let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001217def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218 [(set GR16:$dst, (add GR16:$src, 1))]>,
1219 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001220def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001221 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1222}
1223let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001224 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001226 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001227 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1228 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001229 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001230 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1231 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001232}
1233
1234let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001235def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 [(set GR8:$dst, (add GR8:$src, -1))]>;
1237let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001238def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 [(set GR16:$dst, (add GR16:$src, -1))]>,
1240 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001241def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1243}
1244
1245let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001246 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001248 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001249 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1250 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001251 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001252 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1253 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254}
Evan Cheng55687072007-09-14 21:48:26 +00001255} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256
1257// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001258let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1260def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001261 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1264def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001265 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001266 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1268def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001269 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001270 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001271 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1272}
1273
1274def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001275 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001276 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1278def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1282def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001283 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1286
1287def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001288 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001289 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1291def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001292 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001293 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1295def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001296 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001297 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001298 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1299def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001300 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1303 OpSize;
1304def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001305 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001306 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1308
1309let isTwoAddress = 0 in {
1310 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001311 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001312 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1314 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001315 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001316 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1318 OpSize;
1319 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001320 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001321 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1323 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001324 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001325 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1327 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001328 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001329 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1331 OpSize;
1332 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001333 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001334 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1336 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001337 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001338 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1340 OpSize;
1341 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001342 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001343 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001344 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1345}
1346
1347
1348let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001349def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001350 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001352def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001353 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001355def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001356 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001357 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1358}
Evan Chengb783fa32007-07-19 01:14:50 +00001359def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001360 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001362def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001363 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001365def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001366 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1368
Evan Chengb783fa32007-07-19 01:14:50 +00001369def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001370 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001372def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001373 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001375def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001376 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1378
Evan Chengb783fa32007-07-19 01:14:50 +00001379def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001380 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001382def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001383 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1385let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001386 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001387 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001388 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001389 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001390 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001392 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001393 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001394 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001395 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001396 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001398 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001399 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1401 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001402 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001403 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001405 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001406 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001407 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1408 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001409 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001410 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001411 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001412} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413
1414
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001415let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001416 def XOR8rr : I<0x30, MRMDestReg,
1417 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1418 "xor{b}\t{$src2, $dst|$dst, $src2}",
1419 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1420 def XOR16rr : I<0x31, MRMDestReg,
1421 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1422 "xor{w}\t{$src2, $dst|$dst, $src2}",
1423 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1424 def XOR32rr : I<0x31, MRMDestReg,
1425 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1426 "xor{l}\t{$src2, $dst|$dst, $src2}",
1427 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001428} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001429
1430def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001431 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001432 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001433 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1434def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001435 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001436 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001437 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1438 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001440 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001441 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1443
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001444def XOR8ri : Ii8<0x80, MRM6r,
1445 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1446 "xor{b}\t{$src2, $dst|$dst, $src2}",
1447 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1448def XOR16ri : Ii16<0x81, MRM6r,
1449 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1450 "xor{w}\t{$src2, $dst|$dst, $src2}",
1451 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1452def XOR32ri : Ii32<0x81, MRM6r,
1453 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1454 "xor{l}\t{$src2, $dst|$dst, $src2}",
1455 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1456def XOR16ri8 : Ii8<0x83, MRM6r,
1457 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1458 "xor{w}\t{$src2, $dst|$dst, $src2}",
1459 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1460 OpSize;
1461def XOR32ri8 : Ii8<0x83, MRM6r,
1462 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1463 "xor{l}\t{$src2, $dst|$dst, $src2}",
1464 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001465
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466let isTwoAddress = 0 in {
1467 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001468 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001470 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1471 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001472 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001473 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001474 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1475 OpSize;
1476 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001477 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001478 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001479 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1480 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001481 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001482 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001483 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1484 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001485 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1488 OpSize;
1489 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001490 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001491 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001492 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1493 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001494 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001495 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001496 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1497 OpSize;
1498 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001499 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001500 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001502} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001503} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504
1505// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001506let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001507let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001508def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001509 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001510 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001511def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001512 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001513 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001514def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001515 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001516 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001517} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001518
Evan Chengb783fa32007-07-19 01:14:50 +00001519def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001520 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001521 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1522let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001523def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001526def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001529// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1530// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001531} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001532
1533let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001534 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001535 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001537 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001538 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001539 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001540 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001541 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001543 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1544 }
Evan Chengb783fa32007-07-19 01:14:50 +00001545 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001546 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001547 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001548 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001549 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001550 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1551 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001552 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1555
1556 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001557 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001560 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1563 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001564 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001565 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1567}
1568
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001569let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001570def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001572 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001573def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001575 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001576def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001577 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001578 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1579}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580
Evan Chengb783fa32007-07-19 01:14:50 +00001581def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001582 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001584def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001585 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001587def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001589 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1590
1591// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001592def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001593 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001595def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001598def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001599 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1601
1602let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001603 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001604 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001606 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001607 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001608 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001610 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001611 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001613 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1614 }
Evan Chengb783fa32007-07-19 01:14:50 +00001615 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001616 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001618 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1621 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001622 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001624 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1625
1626 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001627 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001630 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001631 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001633 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001634 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001635 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1636}
1637
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001638let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001639def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001640 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001641 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001642def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001644 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001645def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001646 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001647 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1648}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001649
Evan Chengb783fa32007-07-19 01:14:50 +00001650def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001651 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001653def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001654 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001655 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1656 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001657def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1660
1661// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001662def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001664 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001665def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001668def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1671
1672let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001673 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001674 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001675 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001676 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001677 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001678 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001679 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001680 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001681 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001682 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1683 }
Evan Chengb783fa32007-07-19 01:14:50 +00001684 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001685 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001686 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001687 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001688 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1690 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001691 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1694
1695 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001696 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001699 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1702 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001703 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001704 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1706}
1707
1708// Rotate instructions
1709// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001710let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001711def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001712 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001713 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001714def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001715 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001716 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001717def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001718 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001719 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1720}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721
Evan Chengb783fa32007-07-19 01:14:50 +00001722def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001725def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001726 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001728def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001730 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1731
1732// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001733def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001736def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001737 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001739def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1742
1743let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001744 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001745 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001747 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001748 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001750 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001751 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001752 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001753 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1754 }
Evan Chengb783fa32007-07-19 01:14:50 +00001755 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001758 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001760 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1761 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001762 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001764 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1765
1766 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001767 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001769 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001770 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001771 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1773 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001774 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1777}
1778
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001779let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001780def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001782 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001783def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001784 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001785 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001786def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001788 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1789}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790
Evan Chengb783fa32007-07-19 01:14:50 +00001791def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001794def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001797def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001798 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1800
1801// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001802def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001805def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001808def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1811
1812let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001813 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001814 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001816 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001817 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001818 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001819 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001820 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001821 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001822 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1823 }
Evan Chengb783fa32007-07-19 01:14:50 +00001824 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001827 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1830 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001831 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1834
1835 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001836 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001837 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001839 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001841 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1842 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001843 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001844 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1846}
1847
1848
1849
1850// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001851let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001852def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001854 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001855def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001857 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001858def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001861 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001862def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001865 TB, OpSize;
1866}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001867
1868let isCommutable = 1 in { // These instructions commute to each other.
1869def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001870 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1873 (i8 imm:$src3)))]>,
1874 TB;
1875def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001876 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001878 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1879 (i8 imm:$src3)))]>,
1880 TB;
1881def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001882 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001883 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001884 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1885 (i8 imm:$src3)))]>,
1886 TB, OpSize;
1887def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001888 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001889 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1891 (i8 imm:$src3)))]>,
1892 TB, OpSize;
1893}
1894
1895let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001896 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001897 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001900 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001901 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001904 addr:$dst)]>, TB;
1905 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001907 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1910 (i8 imm:$src3)), addr:$dst)]>,
1911 TB;
1912 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001913 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001914 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1916 (i8 imm:$src3)), addr:$dst)]>,
1917 TB;
1918
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001919 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001920 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001921 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001923 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001924 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001927 addr:$dst)]>, TB, OpSize;
1928 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001930 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1933 (i8 imm:$src3)), addr:$dst)]>,
1934 TB, OpSize;
1935 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001936 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001937 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1939 (i8 imm:$src3)), addr:$dst)]>,
1940 TB, OpSize;
1941}
Evan Cheng55687072007-09-14 21:48:26 +00001942} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943
1944
1945// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001946let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00001948// Register-Register Addition
1949def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1950 (ins GR8 :$src1, GR8 :$src2),
1951 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001952 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00001953 (implicit EFLAGS)]>;
1954
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001955let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00001956// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001957def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1958 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001960 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
1961 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001962def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1963 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001964 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001965 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
1966 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967} // end isConvertibleToThreeAddress
1968} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00001969
1970// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001971def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1972 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001973 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001974 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
1975 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001976def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1977 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001979 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
1980 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001981def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1982 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001984 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
1985 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986
Bill Wendlingae034ed2008-12-12 00:56:36 +00001987// Register-Integer Addition
1988def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1989 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001990 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
1991 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00001992
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00001994// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001995def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1996 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001997 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001998 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
1999 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002000def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2001 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002003 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2004 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002005def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2006 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002008 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2009 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002010def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2011 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002013 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2014 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015}
2016
2017let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002018 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002019 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002021 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2022 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002023 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002025 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2026 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002027 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002028 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002029 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2030 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002031 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002033 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2034 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002035 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002036 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002037 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2038 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002039 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002041 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2042 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002043 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002045 [(store (add (load addr:$dst), i16immSExt8:$src2),
2046 addr:$dst),
2047 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002048 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002050 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002051 addr:$dst),
2052 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053}
2054
Evan Cheng259471d2007-10-05 17:59:57 +00002055let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002056let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002057def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002058 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002059 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002060}
Evan Chengb783fa32007-07-19 01:14:50 +00002061def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002062 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002063 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002064def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002065 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002066 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002067def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002068 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002069 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070
2071let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002072 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002074 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002075 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002077 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002078 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002080 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081}
Evan Cheng259471d2007-10-05 17:59:57 +00002082} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002083
Bill Wendlingae034ed2008-12-12 00:56:36 +00002084// Register-Register Subtraction
2085def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2086 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002087 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2088 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002089def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2090 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002091 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2092 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002093def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2094 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002095 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2096 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002097
2098// Register-Memory Subtraction
2099def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2100 (ins GR8 :$src1, i8mem :$src2),
2101 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002102 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2103 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002104def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2105 (ins GR16:$src1, i16mem:$src2),
2106 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002107 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2108 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002109def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2110 (ins GR32:$src1, i32mem:$src2),
2111 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002112 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2113 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002114
2115// Register-Integer Subtraction
2116def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2117 (ins GR8:$src1, i8imm:$src2),
2118 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002119 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2120 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002121def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2122 (ins GR16:$src1, i16imm:$src2),
2123 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002124 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2125 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002126def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2127 (ins GR32:$src1, i32imm:$src2),
2128 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002129 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2130 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002131def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2132 (ins GR16:$src1, i16i8imm:$src2),
2133 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002134 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2135 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002136def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2137 (ins GR32:$src1, i32i8imm:$src2),
2138 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002139 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2140 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002141
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002143 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002144 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002146 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2147 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002148 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002149 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002150 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2151 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002152 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002153 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002154 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2155 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002156
2157 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002158 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002160 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2161 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002162 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002164 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2165 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002166 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002168 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2169 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002170 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002172 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002173 addr:$dst),
2174 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002175 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002176 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002177 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002178 addr:$dst),
2179 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002180}
2181
Evan Cheng259471d2007-10-05 17:59:57 +00002182let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002183def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002184 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002185 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186
2187let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002188 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002191 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002192 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002194 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002195 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002197 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002198 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002199 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200}
Evan Chengb783fa32007-07-19 01:14:50 +00002201def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002202 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002203 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002204def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002207def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002208 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002209 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002210} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002211} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212
Evan Cheng55687072007-09-14 21:48:26 +00002213let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002215// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002216def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002218 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2219 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002220def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002221 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002222 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2223 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002224}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002225
Bill Wendlingf5399032008-12-12 21:15:41 +00002226// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002227def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2228 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002229 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002230 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2231 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002232def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002234 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2235 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002236} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237} // end Two Address instructions
2238
2239// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002240let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002241// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002243 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002245 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2246 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002248 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002250 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2251 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002253 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002254 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002255 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2256 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002258 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002259 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002260 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2261 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002262
Bill Wendlingf5399032008-12-12 21:15:41 +00002263// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002265 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002266 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002267 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2268 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002270 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002271 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002272 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2273 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002275 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002276 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002277 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002278 i16immSExt8:$src2)),
2279 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002281 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002283 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002284 i32immSExt8:$src2)),
2285 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002286} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002287
2288//===----------------------------------------------------------------------===//
2289// Test instructions are just like AND, except they don't generate a result.
2290//
Evan Cheng950aac02007-09-25 01:57:46 +00002291let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002292let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002293def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002294 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002295 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002296 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002297def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002298 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002299 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002300 (implicit EFLAGS)]>,
2301 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002302def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002303 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002304 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002305 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306}
2307
Evan Chengb783fa32007-07-19 01:14:50 +00002308def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002309 "test{b}\t{$src2, $src1|$src1, $src2}",
2310 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2311 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002312def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002313 "test{w}\t{$src2, $src1|$src1, $src2}",
2314 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2315 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002316def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002317 "test{l}\t{$src2, $src1|$src1, $src2}",
2318 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2319 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002320
2321def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002322 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002323 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002324 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002325 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002326def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002327 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002328 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002329 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002330 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002332 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002334 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002335 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002336
Evan Cheng621216e2007-09-29 00:00:36 +00002337def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002338 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002340 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2341 (implicit EFLAGS)]>;
2342def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002343 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002344 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002345 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2346 (implicit EFLAGS)]>, OpSize;
2347def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002348 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002350 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002351 (implicit EFLAGS)]>;
2352} // Defs = [EFLAGS]
2353
2354
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002355// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002356let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002357def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002358let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002359def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002360
Evan Cheng950aac02007-09-25 01:57:46 +00002361let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002363 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002364 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002365 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002366 TB; // GR8 = ==
2367def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002368 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002369 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002370 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002371 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002372
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002373def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002374 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002375 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002376 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002377 TB; // GR8 = !=
2378def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002379 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002380 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002381 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002382 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002383
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002385 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002387 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002388 TB; // GR8 = < signed
2389def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002390 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002391 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002392 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002393 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002394
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002396 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002397 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002398 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002399 TB; // GR8 = >= signed
2400def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002401 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002402 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002403 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002405
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002406def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002407 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002408 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002409 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002410 TB; // GR8 = <= signed
2411def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002412 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002413 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002414 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002415 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002416
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002418 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002419 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002420 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002421 TB; // GR8 = > signed
2422def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002423 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002424 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002425 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002426 TB; // [mem8] = > signed
2427
2428def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002429 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002431 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002432 TB; // GR8 = < unsign
2433def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002434 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002435 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002436 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002437 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002438
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002439def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002440 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002441 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002442 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002443 TB; // GR8 = >= unsign
2444def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002445 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002447 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002448 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002449
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002450def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002451 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002452 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002453 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002454 TB; // GR8 = <= unsign
2455def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002456 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002457 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002458 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002460
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002461def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002462 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002464 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002465 TB; // GR8 = > signed
2466def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002467 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002469 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002470 TB; // [mem8] = > signed
2471
2472def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002473 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002474 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002475 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002476 TB; // GR8 = <sign bit>
2477def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002478 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002479 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002480 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002481 TB; // [mem8] = <sign bit>
2482def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002483 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002484 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002485 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486 TB; // GR8 = !<sign bit>
2487def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002488 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002489 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002490 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002491 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002492
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002493def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002494 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002495 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002496 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002497 TB; // GR8 = parity
2498def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002499 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002500 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002501 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002502 TB; // [mem8] = parity
2503def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002504 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002505 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002506 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002507 TB; // GR8 = not parity
2508def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002509 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002510 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002511 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002513
2514def SETOr : I<0x90, MRM0r,
2515 (outs GR8 :$dst), (ins),
2516 "seto\t$dst",
2517 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2518 TB; // GR8 = overflow
2519def SETOm : I<0x90, MRM0m,
2520 (outs), (ins i8mem:$dst),
2521 "seto\t$dst",
2522 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2523 TB; // [mem8] = overflow
2524def SETNOr : I<0x91, MRM0r,
2525 (outs GR8 :$dst), (ins),
2526 "setno\t$dst",
2527 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2528 TB; // GR8 = not overflow
2529def SETNOm : I<0x91, MRM0m,
2530 (outs), (ins i8mem:$dst),
2531 "setno\t$dst",
2532 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2533 TB; // [mem8] = not overflow
2534
2535def SETCr : I<0x92, MRM0r,
2536 (outs GR8 :$dst), (ins),
2537 "setc\t$dst",
2538 [(set GR8:$dst, (X86setcc X86_COND_C, EFLAGS))]>,
2539 TB; // GR8 = carry
2540def SETCm : I<0x92, MRM0m,
2541 (outs), (ins i8mem:$dst),
2542 "setc\t$dst",
2543 [(store (X86setcc X86_COND_C, EFLAGS), addr:$dst)]>,
2544 TB; // [mem8] = carry
2545def SETNCr : I<0x93, MRM0r,
2546 (outs GR8 :$dst), (ins),
2547 "setnc\t$dst",
2548 [(set GR8:$dst, (X86setcc X86_COND_NC, EFLAGS))]>,
2549 TB; // GR8 = not carry
2550def SETNCm : I<0x93, MRM0m,
2551 (outs), (ins i8mem:$dst),
2552 "setnc\t$dst",
2553 [(store (X86setcc X86_COND_NC, EFLAGS), addr:$dst)]>,
2554 TB; // [mem8] = not carry
Evan Cheng950aac02007-09-25 01:57:46 +00002555} // Uses = [EFLAGS]
2556
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002557
2558// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002559let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002560def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002561 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002562 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002563 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002564def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002565 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002566 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002567 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002568def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002569 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002570 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002571 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002572def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002573 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002574 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002575 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2576 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002577def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002578 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002579 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002580 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2581 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002582def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002583 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002584 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002585 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2586 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002588 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002589 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002590 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2591 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002592def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002593 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002594 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002595 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2596 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002597def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002598 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002599 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002600 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2601 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002603 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002604 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002605 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002606def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002607 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002608 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002609 [(X86cmp GR16:$src1, imm:$src2),
2610 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002611def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002612 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002613 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002614 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002615def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002616 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002617 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002618 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2619 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002620def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002621 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002622 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002623 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2624 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002625def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002626 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002627 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002628 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2629 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002630def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002631 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002632 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002633 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2634 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002635def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002636 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002637 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002638 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2639 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002640def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002641 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002642 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002643 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2644 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002645def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002646 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002647 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002648 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002649 (implicit EFLAGS)]>;
2650} // Defs = [EFLAGS]
2651
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002652// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002653// Use movsbl intead of movsbw; we don't care about the high 16 bits
2654// of the register here. This has a smaller encoding and avoids a
2655// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002656def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002657 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2658 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002659def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002660 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2661 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002662def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002663 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002664 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002665def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002666 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002667 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002668def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002669 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002670 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002671def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002672 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2674
Dan Gohman9203ab42008-07-30 18:09:17 +00002675// Use movzbl intead of movzbw; we don't care about the high 16 bits
2676// of the register here. This has a smaller encoding and avoids a
2677// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002678def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002679 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2680 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002681def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002682 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2683 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002684def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002685 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002686 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002687def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002688 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002689 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002690def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002691 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002692 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002693def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002694 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002695 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2696
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002697let neverHasSideEffects = 1 in {
2698 let Defs = [AX], Uses = [AL] in
2699 def CBW : I<0x98, RawFrm, (outs), (ins),
2700 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2701 let Defs = [EAX], Uses = [AX] in
2702 def CWDE : I<0x98, RawFrm, (outs), (ins),
2703 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002704
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002705 let Defs = [AX,DX], Uses = [AX] in
2706 def CWD : I<0x99, RawFrm, (outs), (ins),
2707 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2708 let Defs = [EAX,EDX], Uses = [EAX] in
2709 def CDQ : I<0x99, RawFrm, (outs), (ins),
2710 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2711}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002712
2713//===----------------------------------------------------------------------===//
2714// Alias Instructions
2715//===----------------------------------------------------------------------===//
2716
2717// Alias instructions that map movr0 to xor.
2718// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002719let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002720def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002721 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002722 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002723// Use xorl instead of xorw since we don't care about the high 16 bits,
2724// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002725def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002726 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2727 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002728def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002729 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002730 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002731}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002732
2733// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2734// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002735let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002736def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002737 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002738def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002739 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002740
Evan Chengb783fa32007-07-19 01:14:50 +00002741def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002742 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002743def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002744 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002745} // neverHasSideEffects
2746
Dan Gohman5574cc72008-12-03 18:15:48 +00002747let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002748def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002749 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002750def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002751 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002752}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002753let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002754def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002755 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002756def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002757 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002758}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002759
2760//===----------------------------------------------------------------------===//
2761// Thread Local Storage Instructions
2762//
2763
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002764let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002765def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2766 "leal\t${sym:mem}(,%ebx,1), $dst",
2767 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002768
2769let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002770def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002771 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002772 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2773
2774let AddedComplexity = 15 in
Nicolas Geoffray81580792008-10-25 15:22:06 +00002775def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002776 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002777 [(set GR32:$dst,
Nicolas Geoffray81580792008-10-25 15:22:06 +00002778 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
2779 SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002780
Nicolas Geoffray81580792008-10-25 15:22:06 +00002781def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002782 "movl\t%gs:0, $dst",
Nicolas Geoffray81580792008-10-25 15:22:06 +00002783 [(set GR32:$dst, X86TLStp)]>, SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002784
2785//===----------------------------------------------------------------------===//
2786// DWARF Pseudo Instructions
2787//
2788
Evan Chengb783fa32007-07-19 01:14:50 +00002789def DWARF_LOC : I<0, Pseudo, (outs),
2790 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002791 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002792 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2793 (i32 imm:$file))]>;
2794
2795//===----------------------------------------------------------------------===//
2796// EH Pseudo Instructions
2797//
2798let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002799 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002800def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002801 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002802 [(X86ehret GR32:$addr)]>;
2803
2804}
2805
2806//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002807// Atomic support
2808//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002809
Evan Cheng3e171562008-04-19 01:20:30 +00002810// Atomic swap. These are just normal xchg instructions. But since a memory
2811// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00002812let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00002813def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2814 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2815 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2816def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2817 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2818 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2819 OpSize;
2820def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2821 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2822 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2823}
2824
Evan Chengd49dbb82008-04-18 20:55:36 +00002825// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002826let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002827def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002828 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002829 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002830}
Dale Johannesenf160d802008-10-02 18:53:47 +00002831let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00002832def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00002833 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00002834 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2835}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002836
2837let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002838def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002839 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002840 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002841}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002842let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002843def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002844 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002845 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002846}
2847
Evan Chengd49dbb82008-04-18 20:55:36 +00002848// Atomic exchange and add
2849let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2850def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002851 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002852 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002853 TB, LOCK;
2854def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002855 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002856 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002857 TB, OpSize, LOCK;
2858def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002859 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002860 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002861 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002862}
2863
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002864// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00002865let Constraints = "$val = $dst", Defs = [EFLAGS],
2866 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002867def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002868 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002869 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002870def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002871 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002872 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002873def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002874 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002875 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00002876def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002877 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002878 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002879def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002880 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002881 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002882def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002883 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002884 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002885def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002886 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002887 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002888def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002889 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002890 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002891
2892def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002893 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002894 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002895def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002896 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002897 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002898def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002899 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002900 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002901def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002902 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002903 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002904def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002905 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002906 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002907def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002908 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002909 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002910def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002911 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002912 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002913def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002914 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002915 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002916
2917def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002918 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002919 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002920def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002921 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002922 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002923def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002924 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002925 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002926def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002927 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002928 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00002929}
2930
Dale Johannesenf160d802008-10-02 18:53:47 +00002931let Constraints = "$val1 = $dst1, $val2 = $dst2",
2932 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
2933 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00002934 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00002935 usesCustomDAGSchedInserter = 1 in {
2936def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2937 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002938 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002939def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2940 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002941 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002942def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2943 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002944 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002945def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2946 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002947 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002948def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2949 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002950 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002951def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2952 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002953 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00002954def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2955 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002956 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002957}
2958
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002959//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002960// Non-Instruction Patterns
2961//===----------------------------------------------------------------------===//
2962
Bill Wendlingfef06052008-09-16 21:48:12 +00002963// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002964def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2965def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00002966def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002967def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2968def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2969
2970def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2971 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2972def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2973 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2974def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2975 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2976def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2977 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2978
2979def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2980 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2981def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2982 (MOV32mi addr:$dst, texternalsym:$src)>;
2983
2984// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002985// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002986def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002987 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002988
2989def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002990 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002991def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002992 (TAILCALL)>;
2993
2994def : Pat<(X86tcret GR32:$dst, imm:$off),
2995 (TCRETURNri GR32:$dst, imm:$off)>;
2996
2997def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2998 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2999
3000def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3001 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003002
3003def : Pat<(X86call (i32 tglobaladdr:$dst)),
3004 (CALLpcrel32 tglobaladdr:$dst)>;
3005def : Pat<(X86call (i32 texternalsym:$dst)),
3006 (CALLpcrel32 texternalsym:$dst)>;
3007
3008// X86 specific add which produces a flag.
3009def : Pat<(addc GR32:$src1, GR32:$src2),
3010 (ADD32rr GR32:$src1, GR32:$src2)>;
3011def : Pat<(addc GR32:$src1, (load addr:$src2)),
3012 (ADD32rm GR32:$src1, addr:$src2)>;
3013def : Pat<(addc GR32:$src1, imm:$src2),
3014 (ADD32ri GR32:$src1, imm:$src2)>;
3015def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3016 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3017
3018def : Pat<(subc GR32:$src1, GR32:$src2),
3019 (SUB32rr GR32:$src1, GR32:$src2)>;
3020def : Pat<(subc GR32:$src1, (load addr:$src2)),
3021 (SUB32rm GR32:$src1, addr:$src2)>;
3022def : Pat<(subc GR32:$src1, imm:$src2),
3023 (SUB32ri GR32:$src1, imm:$src2)>;
3024def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3025 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3026
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003027// Comparisons.
3028
3029// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003030def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003031 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003032def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003033 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003034def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003035 (TEST32rr GR32:$src1, GR32:$src1)>;
3036
Duncan Sands082524c2008-01-23 20:39:46 +00003037// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003038def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3039def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3040def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3041
3042// extload bool -> extload byte
3043def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003044def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3045 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003046def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003047def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3048 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003049def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3050def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3051
Dan Gohmandd612bb2008-08-20 21:27:32 +00003052// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003053def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3054 Requires<[In32BitMode]>;
3055def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3056 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003057def : Pat<(i32 (anyext GR16:$src)),
3058 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003059
Evan Chengf2abee72007-12-13 00:43:27 +00003060// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003061def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3062 (MOVZX32rm8 addr:$src)>;
3063def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3064 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003065
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003066//===----------------------------------------------------------------------===//
3067// Some peepholes
3068//===----------------------------------------------------------------------===//
3069
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003070// Odd encoding trick: -128 fits into an 8-bit immediate field while
3071// +128 doesn't, so in this special case use a sub instead of an add.
3072def : Pat<(add GR16:$src1, 128),
3073 (SUB16ri8 GR16:$src1, -128)>;
3074def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3075 (SUB16mi8 addr:$dst, -128)>;
3076def : Pat<(add GR32:$src1, 128),
3077 (SUB32ri8 GR32:$src1, -128)>;
3078def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3079 (SUB32mi8 addr:$dst, -128)>;
3080
Dan Gohman9203ab42008-07-30 18:09:17 +00003081// r & (2^16-1) ==> movz
3082def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003083 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003084// r & (2^8-1) ==> movz
3085def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003086 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3087 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003088 Requires<[In32BitMode]>;
3089// r & (2^8-1) ==> movz
3090def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003091 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3092 x86_subreg_8bit)))>,
3093 Requires<[In32BitMode]>;
3094
3095// sext_inreg patterns
3096def : Pat<(sext_inreg GR32:$src, i16),
3097 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3098def : Pat<(sext_inreg GR32:$src, i8),
3099 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3100 x86_subreg_8bit)))>,
3101 Requires<[In32BitMode]>;
3102def : Pat<(sext_inreg GR16:$src, i8),
3103 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3104 x86_subreg_8bit)))>,
3105 Requires<[In32BitMode]>;
3106
3107// trunc patterns
3108def : Pat<(i16 (trunc GR32:$src)),
3109 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3110def : Pat<(i8 (trunc GR32:$src)),
3111 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3112 Requires<[In32BitMode]>;
3113def : Pat<(i8 (trunc GR16:$src)),
3114 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003115 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003116
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003117// (shl x, 1) ==> (add x, x)
3118def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3119def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3120def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3121
Evan Cheng76a64c72008-08-30 02:03:58 +00003122// (shl x (and y, 31)) ==> (shl x, y)
3123def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3124 (SHL8rCL GR8:$src1)>;
3125def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3126 (SHL16rCL GR16:$src1)>;
3127def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3128 (SHL32rCL GR32:$src1)>;
3129def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3130 (SHL8mCL addr:$dst)>;
3131def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3132 (SHL16mCL addr:$dst)>;
3133def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3134 (SHL32mCL addr:$dst)>;
3135
3136def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3137 (SHR8rCL GR8:$src1)>;
3138def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3139 (SHR16rCL GR16:$src1)>;
3140def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3141 (SHR32rCL GR32:$src1)>;
3142def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3143 (SHR8mCL addr:$dst)>;
3144def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3145 (SHR16mCL addr:$dst)>;
3146def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3147 (SHR32mCL addr:$dst)>;
3148
3149def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3150 (SAR8rCL GR8:$src1)>;
3151def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3152 (SAR16rCL GR16:$src1)>;
3153def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3154 (SAR32rCL GR32:$src1)>;
3155def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3156 (SAR8mCL addr:$dst)>;
3157def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3158 (SAR16mCL addr:$dst)>;
3159def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3160 (SAR32mCL addr:$dst)>;
3161
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003162// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3163def : Pat<(or (srl GR32:$src1, CL:$amt),
3164 (shl GR32:$src2, (sub 32, CL:$amt))),
3165 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3166
3167def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3168 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3169 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3170
Dan Gohman921581d2008-10-17 01:23:35 +00003171def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3172 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3173 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3174
3175def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3176 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3177 addr:$dst),
3178 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3179
3180def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3181 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3182
3183def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3184 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3185 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3186
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003187// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3188def : Pat<(or (shl GR32:$src1, CL:$amt),
3189 (srl GR32:$src2, (sub 32, CL:$amt))),
3190 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3191
3192def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3193 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3194 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3195
Dan Gohman921581d2008-10-17 01:23:35 +00003196def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3197 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3198 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3199
3200def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3201 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3202 addr:$dst),
3203 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3204
3205def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3206 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3207
3208def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3209 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3210 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3211
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003212// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3213def : Pat<(or (srl GR16:$src1, CL:$amt),
3214 (shl GR16:$src2, (sub 16, CL:$amt))),
3215 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3216
3217def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3218 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3219 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3220
Dan Gohman921581d2008-10-17 01:23:35 +00003221def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3222 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3223 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3224
3225def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3226 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3227 addr:$dst),
3228 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3229
3230def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3231 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3232
3233def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3234 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3235 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3236
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003237// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3238def : Pat<(or (shl GR16:$src1, CL:$amt),
3239 (srl GR16:$src2, (sub 16, CL:$amt))),
3240 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3241
3242def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3243 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3244 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3245
Dan Gohman921581d2008-10-17 01:23:35 +00003246def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3247 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3248 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3249
3250def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3251 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3252 addr:$dst),
3253 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3254
3255def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3256 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3257
3258def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3259 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3260 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3261
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003262//===----------------------------------------------------------------------===//
Bill Wendlingf5399032008-12-12 21:15:41 +00003263// Overflow Patterns
3264//===----------------------------------------------------------------------===//
3265
3266// Register-Register Addition with Overflow
3267def : Pat<(parallel (X86add_ovf GR8:$src1, GR8:$src2),
3268 (implicit EFLAGS)),
3269 (ADD8rr GR8:$src1, GR8:$src2)>;
3270
3271// Register-Register Addition with Overflow
3272def : Pat<(parallel (X86add_ovf GR16:$src1, GR16:$src2),
3273 (implicit EFLAGS)),
3274 (ADD16rr GR16:$src1, GR16:$src2)>;
3275def : Pat<(parallel (X86add_ovf GR32:$src1, GR32:$src2),
3276 (implicit EFLAGS)),
3277 (ADD32rr GR32:$src1, GR32:$src2)>;
3278
3279// Register-Memory Addition with Overflow
3280def : Pat<(parallel (X86add_ovf GR8:$src1, (load addr:$src2)),
3281 (implicit EFLAGS)),
3282 (ADD8rm GR8:$src1, addr:$src2)>;
3283def : Pat<(parallel (X86add_ovf GR16:$src1, (load addr:$src2)),
3284 (implicit EFLAGS)),
3285 (ADD16rm GR16:$src1, addr:$src2)>;
3286def : Pat<(parallel (X86add_ovf GR32:$src1, (load addr:$src2)),
3287 (implicit EFLAGS)),
3288 (ADD32rm GR32:$src1, addr:$src2)>;
3289
3290// Register-Integer Addition with Overflow
3291def : Pat<(parallel (X86add_ovf GR8:$src1, imm:$src2),
3292 (implicit EFLAGS)),
3293 (ADD8ri GR8:$src1, imm:$src2)>;
3294
3295// Register-Integer Addition with Overflow
3296def : Pat<(parallel (X86add_ovf GR16:$src1, imm:$src2),
3297 (implicit EFLAGS)),
3298 (ADD16ri GR16:$src1, imm:$src2)>;
3299def : Pat<(parallel (X86add_ovf GR32:$src1, imm:$src2),
3300 (implicit EFLAGS)),
3301 (ADD32ri GR32:$src1, imm:$src2)>;
3302def : Pat<(parallel (X86add_ovf GR16:$src1, i16immSExt8:$src2),
3303 (implicit EFLAGS)),
3304 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3305def : Pat<(parallel (X86add_ovf GR32:$src1, i32immSExt8:$src2),
3306 (implicit EFLAGS)),
3307 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3308
3309// Memory-Register Addition with Overflow
3310def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR8:$src2),
3311 addr:$dst),
3312 (implicit EFLAGS)),
3313 (ADD8mr addr:$dst, GR8:$src2)>;
3314def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR16:$src2),
3315 addr:$dst),
3316 (implicit EFLAGS)),
3317 (ADD16mr addr:$dst, GR16:$src2)>;
3318def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR32:$src2),
3319 addr:$dst),
3320 (implicit EFLAGS)),
3321 (ADD32mr addr:$dst, GR32:$src2)>;
3322def : Pat<(parallel (store (X86add_ovf (loadi8 addr:$dst), imm:$src2),
3323 addr:$dst),
3324 (implicit EFLAGS)),
3325 (ADD8mi addr:$dst, imm:$src2)>;
3326def : Pat<(parallel (store (X86add_ovf (loadi16 addr:$dst), imm:$src2),
3327 addr:$dst),
3328 (implicit EFLAGS)),
3329 (ADD16mi addr:$dst, imm:$src2)>;
3330def : Pat<(parallel (store (X86add_ovf (loadi32 addr:$dst), imm:$src2),
3331 addr:$dst),
3332 (implicit EFLAGS)),
3333 (ADD32mi addr:$dst, imm:$src2)>;
3334def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i16immSExt8:$src2),
3335 addr:$dst),
3336 (implicit EFLAGS)),
3337 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3338def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i32immSExt8:$src2),
3339 addr:$dst),
3340 (implicit EFLAGS)),
3341 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3342
3343// Register-Register Subtraction with Overflow
3344def : Pat<(parallel (X86sub_ovf GR8:$src1, GR8:$src2),
3345 (implicit EFLAGS)),
3346 (SUB8rr GR8:$src1, GR8:$src2)>;
3347def : Pat<(parallel (X86sub_ovf GR16:$src1, GR16:$src2),
3348 (implicit EFLAGS)),
3349 (SUB16rr GR16:$src1, GR16:$src2)>;
3350def : Pat<(parallel (X86sub_ovf GR32:$src1, GR32:$src2),
3351 (implicit EFLAGS)),
3352 (SUB32rr GR32:$src1, GR32:$src2)>;
3353
3354// Register-Memory Subtraction with Overflow
3355def : Pat<(parallel (X86sub_ovf GR8:$src1, (load addr:$src2)),
3356 (implicit EFLAGS)),
3357 (SUB8rm GR8:$src1, addr:$src2)>;
3358def : Pat<(parallel (X86sub_ovf GR16:$src1, (load addr:$src2)),
3359 (implicit EFLAGS)),
3360 (SUB16rm GR16:$src1, addr:$src2)>;
3361def : Pat<(parallel (X86sub_ovf GR32:$src1, (load addr:$src2)),
3362 (implicit EFLAGS)),
3363 (SUB32rm GR32:$src1, addr:$src2)>;
3364
3365// Register-Integer Subtraction with Overflow
3366def : Pat<(parallel (X86sub_ovf GR8:$src1, imm:$src2),
3367 (implicit EFLAGS)),
3368 (SUB8ri GR8:$src1, imm:$src2)>;
3369def : Pat<(parallel (X86sub_ovf GR16:$src1, imm:$src2),
3370 (implicit EFLAGS)),
3371 (SUB16ri GR16:$src1, imm:$src2)>;
3372def : Pat<(parallel (X86sub_ovf GR32:$src1, imm:$src2),
3373 (implicit EFLAGS)),
3374 (SUB32ri GR32:$src1, imm:$src2)>;
3375def : Pat<(parallel (X86sub_ovf GR16:$src1, i16immSExt8:$src2),
3376 (implicit EFLAGS)),
3377 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3378def : Pat<(parallel (X86sub_ovf GR32:$src1, i32immSExt8:$src2),
3379 (implicit EFLAGS)),
3380 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3381
3382// Memory-Register Subtraction with Overflow
3383def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR8:$src2),
3384 addr:$dst),
3385 (implicit EFLAGS)),
3386 (SUB8mr addr:$dst, GR8:$src2)>;
3387def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR16:$src2),
3388 addr:$dst),
3389 (implicit EFLAGS)),
3390 (SUB16mr addr:$dst, GR16:$src2)>;
3391def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR32:$src2),
3392 addr:$dst),
3393 (implicit EFLAGS)),
3394 (SUB32mr addr:$dst, GR32:$src2)>;
3395
3396// Memory-Integer Subtraction with Overflow
3397def : Pat<(parallel (store (X86sub_ovf (loadi8 addr:$dst), imm:$src2),
3398 addr:$dst),
3399 (implicit EFLAGS)),
3400 (SUB8mi addr:$dst, imm:$src2)>;
3401def : Pat<(parallel (store (X86sub_ovf (loadi16 addr:$dst), imm:$src2),
3402 addr:$dst),
3403 (implicit EFLAGS)),
3404 (SUB16mi addr:$dst, imm:$src2)>;
3405def : Pat<(parallel (store (X86sub_ovf (loadi32 addr:$dst), imm:$src2),
3406 addr:$dst),
3407 (implicit EFLAGS)),
3408 (SUB32mi addr:$dst, imm:$src2)>;
3409def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i16immSExt8:$src2),
3410 addr:$dst),
3411 (implicit EFLAGS)),
3412 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3413def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i32immSExt8:$src2),
3414 addr:$dst),
3415 (implicit EFLAGS)),
3416 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3417
3418
3419// Register-Register Signed Integer Multiply with Overflow
3420def : Pat<(parallel (X86smul_ovf GR16:$src1, GR16:$src2),
3421 (implicit EFLAGS)),
3422 (IMUL16rr GR16:$src1, GR16:$src2)>;
3423def : Pat<(parallel (X86smul_ovf GR32:$src1, GR32:$src2),
3424 (implicit EFLAGS)),
3425 (IMUL32rr GR32:$src1, GR32:$src2)>;
3426
3427// Register-Memory Signed Integer Multiply with Overflow
3428def : Pat<(parallel (X86smul_ovf GR16:$src1, (load addr:$src2)),
3429 (implicit EFLAGS)),
3430 (IMUL16rm GR16:$src1, addr:$src2)>;
3431def : Pat<(parallel (X86smul_ovf GR32:$src1, (load addr:$src2)),
3432 (implicit EFLAGS)),
3433 (IMUL32rm GR32:$src1, addr:$src2)>;
3434
3435// Register-Integer Signed Integer Multiply with Overflow
3436def : Pat<(parallel (X86smul_ovf GR16:$src1, imm:$src2),
3437 (implicit EFLAGS)),
3438 (IMUL16rri GR16:$src1, imm:$src2)>;
3439def : Pat<(parallel (X86smul_ovf GR32:$src1, imm:$src2),
3440 (implicit EFLAGS)),
3441 (IMUL32rri GR32:$src1, imm:$src2)>;
3442def : Pat<(parallel (X86smul_ovf GR16:$src1, i16immSExt8:$src2),
3443 (implicit EFLAGS)),
3444 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
3445def : Pat<(parallel (X86smul_ovf GR32:$src1, i32immSExt8:$src2),
3446 (implicit EFLAGS)),
3447 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3448
3449// Memory-Integer Signed Integer Multiply with Overflow
3450def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
3451 (implicit EFLAGS)),
3452 (IMUL16rmi addr:$src1, imm:$src2)>;
3453def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
3454 (implicit EFLAGS)),
3455 (IMUL32rmi addr:$src1, imm:$src2)>;
3456def : Pat<(parallel (X86smul_ovf (load addr:$src1), i16immSExt8:$src2),
3457 (implicit EFLAGS)),
3458 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
3459def : Pat<(parallel (X86smul_ovf (load addr:$src1), i32immSExt8:$src2),
3460 (implicit EFLAGS)),
3461 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3462
3463//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003464// Floating Point Stack Support
3465//===----------------------------------------------------------------------===//
3466
3467include "X86InstrFPStack.td"
3468
3469//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003470// X86-64 Support
3471//===----------------------------------------------------------------------===//
3472
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003473include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003474
3475//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003476// XMM Floating point support (requires SSE / SSE2)
3477//===----------------------------------------------------------------------===//
3478
3479include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003480
3481//===----------------------------------------------------------------------===//
3482// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3483//===----------------------------------------------------------------------===//
3484
3485include "X86InstrMMX.td"