blob: 4d22c3cfc291573efa75d1a0e5e8f7fc7fc7059b [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
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000079def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
80
Evan Cheng621216e2007-09-29 00:00:36 +000081def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000082def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000083 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000084def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000085
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000086def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
87 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
88 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000089def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
90 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
91 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000092def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
93 [SDNPHasChain, SDNPMayStore,
94 SDNPMayLoad, SDNPMemOperand]>;
95def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
96 [SDNPHasChain, SDNPMayStore,
97 SDNPMayLoad, SDNPMemOperand]>;
98def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
99 [SDNPHasChain, SDNPMayStore,
100 SDNPMayLoad, SDNPMemOperand]>;
101def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
102 [SDNPHasChain, SDNPMayStore,
103 SDNPMayLoad, SDNPMemOperand]>;
104def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
105 [SDNPHasChain, SDNPMayStore,
106 SDNPMayLoad, SDNPMemOperand]>;
107def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
108 [SDNPHasChain, SDNPMayStore,
109 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000110def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
111 [SDNPHasChain, SDNPMayStore,
112 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000113def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
114 [SDNPHasChain, SDNPOptInFlag]>;
115
116def X86callseq_start :
117 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
118 [SDNPHasChain, SDNPOutFlag]>;
119def X86callseq_end :
120 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000121 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122
123def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
124 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
125
126def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
127 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
128
129def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000130 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000131def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000132 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
133 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000134
135def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000136 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000137
138def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
139def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
140
141def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000142 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000143def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
144
145def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
146 [SDNPHasChain]>;
147
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000148def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
149 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000150
Bill Wendlingf5399032008-12-12 21:15:41 +0000151def X86add_ovf : SDNode<"X86ISD::ADD", SDTBinaryArithOvf>;
152def X86sub_ovf : SDNode<"X86ISD::SUB", SDTBinaryArithOvf>;
153def X86smul_ovf : SDNode<"X86ISD::SMUL", SDTBinaryArithOvf>;
154def X86umul_ovf : SDNode<"X86ISD::UMUL", SDTUnaryArithOvf>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000155
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000156//===----------------------------------------------------------------------===//
157// X86 Operand Definitions.
158//
159
160// *mem - Operand definitions for the funky X86 addressing mode operands.
161//
162class X86MemOperand<string printMethod> : Operand<iPTR> {
163 let PrintMethod = printMethod;
164 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
165}
166
167def i8mem : X86MemOperand<"printi8mem">;
168def i16mem : X86MemOperand<"printi16mem">;
169def i32mem : X86MemOperand<"printi32mem">;
170def i64mem : X86MemOperand<"printi64mem">;
171def i128mem : X86MemOperand<"printi128mem">;
172def f32mem : X86MemOperand<"printf32mem">;
173def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000174def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175def f128mem : X86MemOperand<"printf128mem">;
176
177def lea32mem : Operand<i32> {
178 let PrintMethod = "printi32mem";
179 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
180}
181
182def SSECC : Operand<i8> {
183 let PrintMethod = "printSSECC";
184}
185
186def piclabel: Operand<i32> {
187 let PrintMethod = "printPICLabel";
188}
189
190// A couple of more descriptive operand definitions.
191// 16-bits but only 8 bits are significant.
192def i16i8imm : Operand<i16>;
193// 32-bits but only 8 bits are significant.
194def i32i8imm : Operand<i32>;
195
196// Branch targets have OtherVT type.
197def brtarget : Operand<OtherVT>;
198
199//===----------------------------------------------------------------------===//
200// X86 Complex Pattern Definitions.
201//
202
203// Define X86 specific addressing mode.
204def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
205def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
206 [add, mul, shl, or, frameindex], []>;
207
208//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209// X86 Instruction Predicate Definitions.
210def HasMMX : Predicate<"Subtarget->hasMMX()">;
211def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
212def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
213def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
214def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000215def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
216def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000217def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
218def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
220def In64BitMode : Predicate<"Subtarget->is64Bit()">;
221def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
222def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
223def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000224def OptForSpeed : Predicate<"!OptForSize">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225
226//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000227// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000228//
229
Evan Cheng86ab7d32007-07-31 08:04:03 +0000230include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231
232//===----------------------------------------------------------------------===//
233// Pattern fragments...
234//
235
236// X86 specific condition code. These correspond to CondCode in
237// X86InstrInfo.h. They must be kept in synch.
238def X86_COND_A : PatLeaf<(i8 0)>;
239def X86_COND_AE : PatLeaf<(i8 1)>;
240def X86_COND_B : PatLeaf<(i8 2)>;
241def X86_COND_BE : PatLeaf<(i8 3)>;
242def X86_COND_E : PatLeaf<(i8 4)>;
243def X86_COND_G : PatLeaf<(i8 5)>;
244def X86_COND_GE : PatLeaf<(i8 6)>;
245def X86_COND_L : PatLeaf<(i8 7)>;
246def X86_COND_LE : PatLeaf<(i8 8)>;
247def X86_COND_NE : PatLeaf<(i8 9)>;
248def X86_COND_NO : PatLeaf<(i8 10)>;
249def X86_COND_NP : PatLeaf<(i8 11)>;
250def X86_COND_NS : PatLeaf<(i8 12)>;
Bill Wendlingd06b4202008-11-26 22:37:40 +0000251def X86_COND_NC : PatLeaf<(i8 13)>;
252def X86_COND_O : PatLeaf<(i8 14)>;
253def X86_COND_P : PatLeaf<(i8 15)>;
254def X86_COND_S : PatLeaf<(i8 16)>;
255def X86_COND_C : PatLeaf<(i8 17)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000256
257def i16immSExt8 : PatLeaf<(i16 imm), [{
258 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
259 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000260 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261}]>;
262
263def i32immSExt8 : PatLeaf<(i32 imm), [{
264 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
265 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000266 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000267}]>;
268
269// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000270// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
271// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000272def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000273 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000274 ISD::LoadExtType ExtType = LD->getExtensionType();
275 if (ExtType == ISD::NON_EXTLOAD)
276 return true;
277 if (ExtType == ISD::EXTLOAD)
278 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000279 return false;
280}]>;
281
Dan Gohman2a174122008-10-15 06:50:19 +0000282def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000283 LoadSDNode *LD = cast<LoadSDNode>(N);
Evan Cheng56ec77b2008-09-24 23:27:55 +0000284 ISD::LoadExtType ExtType = LD->getExtensionType();
285 if (ExtType == ISD::EXTLOAD)
286 return LD->getAlignment() >= 2 && !LD->isVolatile();
287 return false;
288}]>;
289
Dan Gohman2a174122008-10-15 06:50:19 +0000290def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000291 LoadSDNode *LD = cast<LoadSDNode>(N);
Dan Gohman8335c412008-08-20 15:24:22 +0000292 ISD::LoadExtType ExtType = LD->getExtensionType();
293 if (ExtType == ISD::NON_EXTLOAD)
294 return true;
295 if (ExtType == ISD::EXTLOAD)
296 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000297 return false;
298}]>;
299
Dan Gohman2a174122008-10-15 06:50:19 +0000300def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000301 LoadSDNode *LD = cast<LoadSDNode>(N);
302 if (LD->isVolatile())
303 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000304 ISD::LoadExtType ExtType = LD->getExtensionType();
305 if (ExtType == ISD::NON_EXTLOAD)
306 return true;
307 if (ExtType == ISD::EXTLOAD)
308 return LD->getAlignment() >= 4;
309 return false;
310}]>;
311
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
314
315def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
316def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000317def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
320def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
321def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
322
323def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
324def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
325def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
326def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
327def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
328def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
329
330def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
331def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
332def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
333def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
334def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
335def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
336
Chris Lattner21da6382008-02-19 17:37:35 +0000337
338// An 'and' node with a single use.
339def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000340 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000341}]>;
342
Dan Gohman921581d2008-10-17 01:23:35 +0000343// 'shld' and 'shrd' instruction patterns. Note that even though these have
344// the srl and shl in their patterns, the C++ code must still check for them,
345// because predicates are tested before children nodes are explored.
346
347def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
348 (or (srl node:$src1, node:$amt1),
349 (shl node:$src2, node:$amt2)), [{
350 assert(N->getOpcode() == ISD::OR);
351 return N->getOperand(0).getOpcode() == ISD::SRL &&
352 N->getOperand(1).getOpcode() == ISD::SHL &&
353 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
354 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
355 N->getOperand(0).getConstantOperandVal(1) ==
356 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
357}]>;
358
359def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
360 (or (shl node:$src1, node:$amt1),
361 (srl node:$src2, node:$amt2)), [{
362 assert(N->getOpcode() == ISD::OR);
363 return N->getOperand(0).getOpcode() == ISD::SHL &&
364 N->getOperand(1).getOpcode() == ISD::SRL &&
365 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
366 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
367 N->getOperand(0).getConstantOperandVal(1) ==
368 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
369}]>;
370
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000372// Instruction list...
373//
374
375// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
376// a stack adjustment and the codegen must know that they may modify the stack
377// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000378// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
379// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000380let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000381def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
382 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000383 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000384 Requires<[In32BitMode]>;
385def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
386 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000387 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000388 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000389}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390
391// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000392let neverHasSideEffects = 1 in
393 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394
Evan Cheng0729ccf2008-01-05 00:41:47 +0000395// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000396let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000397 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
398 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399
400//===----------------------------------------------------------------------===//
401// Control Flow Instructions...
402//
403
404// Return instructions.
405let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000406 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000407 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000408 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000409 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000410 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
411 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412 [(X86retflag imm:$amt)]>;
413}
414
415// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000416let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000417 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
418 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000421 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422
Owen Andersonf8053082007-11-12 07:39:39 +0000423// Indirect branches
424let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000425 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000427 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000428 [(brind (loadi32 addr:$dst))]>;
429}
430
431// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000432let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000433def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000434 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000435def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000436 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000437def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000438 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000439def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000440 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000441def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000442 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000443def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000444 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445
Dan Gohman91888f02007-07-31 20:11:57 +0000446def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000447 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000448def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000449 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000450def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000451 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000452def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000453 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000454
Dan Gohman91888f02007-07-31 20:11:57 +0000455def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000456 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000457def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000458 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000459def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000460 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000461def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000462 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000463def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000464 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000465def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000466 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Bill Wendlingd06b4202008-11-26 22:37:40 +0000467def JC : IBr<0x82, (ins brtarget:$dst), "jc\t$dst",
468 [(X86brcond bb:$dst, X86_COND_C, EFLAGS)]>, TB;
469def JNC : IBr<0x83, (ins brtarget:$dst), "jnc\t$dst",
470 [(X86brcond bb:$dst, X86_COND_NC, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000471} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000472
473//===----------------------------------------------------------------------===//
474// Call Instructions...
475//
Evan Cheng37e7c752007-07-21 00:34:19 +0000476let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000477 // All calls clobber the non-callee saved registers. ESP is marked as
478 // a use to prevent stack-pointer assignments that appear immediately
479 // before calls from potentially appearing dead. Uses for argument
480 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
482 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000483 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
484 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000485 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000486 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
487 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000488 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000489 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000490 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000491 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492 }
493
494// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000495
Chris Lattnerb56cc342008-03-11 03:23:40 +0000496def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000497 "#TAILCALL",
498 []>;
499
Evan Cheng37e7c752007-07-21 00:34:19 +0000500let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000501def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000502 "#TC_RETURN $dst $offset",
503 []>;
504
505let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000506def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000507 "#TC_RETURN $dst $offset",
508 []>;
509
510let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000511
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000512 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000513 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000514let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000515 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
516 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000517let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000518 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000519 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520
521//===----------------------------------------------------------------------===//
522// Miscellaneous Instructions...
523//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000524let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000526 (outs), (ins), "leave", []>;
527
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000528let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
529let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000530def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000532let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000533def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000534}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000536let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000537def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000538let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000539def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000540
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541let isTwoAddress = 1 in // GR32 = bswap GR32
542 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000543 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000544 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
546
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547
Evan Cheng48679f42007-12-14 02:13:44 +0000548// Bit scan instructions.
549let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000550def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000551 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000552 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000553def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000554 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000555 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
556 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000557def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000558 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000559 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000560def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000561 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000562 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
563 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000564
Evan Cheng4e33de92007-12-14 18:49:43 +0000565def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000566 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000567 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000568def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000569 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000570 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
571 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000572def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000573 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000574 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000575def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000576 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000577 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
578 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000579} // Defs = [EFLAGS]
580
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000581let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000583 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000584 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000585let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000587 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000588 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
590
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000591let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000592def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000593 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000594def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000595 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000596def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000597 [(X86rep_movs i32)]>, REP;
598}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000599
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000600let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000601def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000602 [(X86rep_stos i8)]>, REP;
603let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000604def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000605 [(X86rep_stos i16)]>, REP, OpSize;
606let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000607def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000608 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000609
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000610let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000611def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000612 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000614let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000615def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000616}
617
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618//===----------------------------------------------------------------------===//
619// Input/Output Instructions...
620//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000621let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000622def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000623 "in{b}\t{%dx, %al|%AL, %DX}", []>;
624let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000625def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000626 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
627let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000628def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000629 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000631let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000632def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000633 "in{b}\t{$port, %al|%AL, $port}", []>;
634let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000635def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000636 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
637let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000638def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000639 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000641let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000642def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000643 "out{b}\t{%al, %dx|%DX, %AL}", []>;
644let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000645def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000646 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
647let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000648def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000649 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000650
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000651let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000652def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000653 "out{b}\t{%al, $port|$port, %AL}", []>;
654let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000655def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000656 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
657let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000658def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000659 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000660
661//===----------------------------------------------------------------------===//
662// Move Instructions...
663//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000664let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000665def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000666 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000667def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000668 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000669def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000670 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000671}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000672let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000673def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000674 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000675 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000676def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000677 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000678 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000679def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000680 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000681 [(set GR32:$dst, imm:$src)]>;
682}
Evan Chengb783fa32007-07-19 01:14:50 +0000683def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000684 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000686def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000687 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000689def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(store (i32 imm:$src), addr:$dst)]>;
692
Dan Gohman5574cc72008-12-03 18:15:48 +0000693let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000694def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000695 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000697def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000698 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000699 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000700def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000703}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704
Evan Chengb783fa32007-07-19 01:14:50 +0000705def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000706 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000707 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000708def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000709 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000711def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000712 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713 [(store GR32:$src, addr:$dst)]>;
714
715//===----------------------------------------------------------------------===//
716// Fixed-Register Multiplication and Division Instructions...
717//
718
719// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000720let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000721def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
723 // This probably ought to be moved to a def : Pat<> if the
724 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000725 [(set AL, (mul AL, GR8:$src)),
726 (implicit EFLAGS)]>; // AL,AH = AL*GR8
727
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000728let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000729def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
730 "mul{w}\t$src",
731 []>, OpSize; // AX,DX = AX*GR16
732
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000733let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000734def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
735 "mul{l}\t$src",
736 []>; // EAX,EDX = EAX*GR32
737
Evan Cheng55687072007-09-14 21:48:26 +0000738let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000739def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000740 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
742 // This probably ought to be moved to a def : Pat<> if the
743 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000744 [(set AL, (mul AL, (loadi8 addr:$src))),
745 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
746
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000747let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000748let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000749def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000750 "mul{w}\t$src",
751 []>, OpSize; // AX,DX = AX*[mem16]
752
Evan Cheng55687072007-09-14 21:48:26 +0000753let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000754def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000755 "mul{l}\t$src",
756 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000757}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000759let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000760let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000761def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
762 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000763let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000764def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000765 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000766let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000767def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
768 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000769let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000770let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000771def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000772 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000773let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000774def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000775 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
776let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000777def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000778 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000779}
Dan Gohmand44572d2008-11-18 21:29:14 +0000780} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781
782// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000783let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000784def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000785 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000786let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000787def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000788 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000789let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000790def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000791 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000792let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000793let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000794def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000795 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000796let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000797def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000798 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000799let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000800def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000801 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000802}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803
804// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000805let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000806def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000807 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000808let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000809def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000810 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000811let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000812def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000813 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000814let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000815let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000816def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000817 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000818let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000819def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000820 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000821let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000822def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000823 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000824}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825
826//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000827// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828//
829let isTwoAddress = 1 in {
830
831// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000832let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000833let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000835 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000836 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000838 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000841 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000842 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000844 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846
847def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000848 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000849 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000851 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000854 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000857 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000863 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000866 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000867 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000869 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000872 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000873 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000875 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000878 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000879 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000881 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000884 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000885 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000887 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000890 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000891 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000893 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000896 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000897 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000899 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000902 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000903 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000905 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000908 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000909 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000911 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000914 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000915 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000917 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000920 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000921 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000923 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000926 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000927 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000929 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000932 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000933 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000935 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000938 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000939 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000941 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000944 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000945 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000947 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000950 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000953 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000956 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000957 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000959 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000962 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000963 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000965 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000968 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000969 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000971 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000974 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000975 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000977 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000980 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000983 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000986 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000989 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000992 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000993 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000995 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000998 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000999 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001001 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002 TB;
Evan Cheng926658c2007-10-05 23:13:21 +00001003} // isCommutable = 1
1004
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +00001006 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001007 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00001009 X86_COND_NP, EFLAGS))]>,
1010 TB;
Evan Cheng926658c2007-10-05 23:13:21 +00001011
1012def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1013 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1014 "cmovb\t{$src2, $dst|$dst, $src2}",
1015 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1016 X86_COND_B, EFLAGS))]>,
1017 TB, OpSize;
1018def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1019 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1020 "cmovb\t{$src2, $dst|$dst, $src2}",
1021 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1022 X86_COND_B, EFLAGS))]>,
1023 TB;
1024def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1025 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1026 "cmovae\t{$src2, $dst|$dst, $src2}",
1027 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1028 X86_COND_AE, EFLAGS))]>,
1029 TB, OpSize;
1030def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1031 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1032 "cmovae\t{$src2, $dst|$dst, $src2}",
1033 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1034 X86_COND_AE, EFLAGS))]>,
1035 TB;
1036def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1037 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1038 "cmove\t{$src2, $dst|$dst, $src2}",
1039 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1040 X86_COND_E, EFLAGS))]>,
1041 TB, OpSize;
1042def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1043 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1044 "cmove\t{$src2, $dst|$dst, $src2}",
1045 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1046 X86_COND_E, EFLAGS))]>,
1047 TB;
1048def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1049 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1050 "cmovne\t{$src2, $dst|$dst, $src2}",
1051 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1052 X86_COND_NE, EFLAGS))]>,
1053 TB, OpSize;
1054def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1055 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1056 "cmovne\t{$src2, $dst|$dst, $src2}",
1057 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1058 X86_COND_NE, EFLAGS))]>,
1059 TB;
1060def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1061 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1062 "cmovbe\t{$src2, $dst|$dst, $src2}",
1063 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1064 X86_COND_BE, EFLAGS))]>,
1065 TB, OpSize;
1066def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1067 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1068 "cmovbe\t{$src2, $dst|$dst, $src2}",
1069 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1070 X86_COND_BE, EFLAGS))]>,
1071 TB;
1072def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1073 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1074 "cmova\t{$src2, $dst|$dst, $src2}",
1075 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1076 X86_COND_A, EFLAGS))]>,
1077 TB, OpSize;
1078def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1079 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1080 "cmova\t{$src2, $dst|$dst, $src2}",
1081 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1082 X86_COND_A, EFLAGS))]>,
1083 TB;
1084def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1085 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1086 "cmovl\t{$src2, $dst|$dst, $src2}",
1087 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1088 X86_COND_L, EFLAGS))]>,
1089 TB, OpSize;
1090def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1091 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1092 "cmovl\t{$src2, $dst|$dst, $src2}",
1093 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1094 X86_COND_L, EFLAGS))]>,
1095 TB;
1096def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1097 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1098 "cmovge\t{$src2, $dst|$dst, $src2}",
1099 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1100 X86_COND_GE, EFLAGS))]>,
1101 TB, OpSize;
1102def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1103 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1104 "cmovge\t{$src2, $dst|$dst, $src2}",
1105 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1106 X86_COND_GE, EFLAGS))]>,
1107 TB;
1108def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1109 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1110 "cmovle\t{$src2, $dst|$dst, $src2}",
1111 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1112 X86_COND_LE, EFLAGS))]>,
1113 TB, OpSize;
1114def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1115 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1116 "cmovle\t{$src2, $dst|$dst, $src2}",
1117 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1118 X86_COND_LE, EFLAGS))]>,
1119 TB;
1120def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1121 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1122 "cmovg\t{$src2, $dst|$dst, $src2}",
1123 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1124 X86_COND_G, EFLAGS))]>,
1125 TB, OpSize;
1126def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1127 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1128 "cmovg\t{$src2, $dst|$dst, $src2}",
1129 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1130 X86_COND_G, EFLAGS))]>,
1131 TB;
1132def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1133 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1134 "cmovs\t{$src2, $dst|$dst, $src2}",
1135 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1136 X86_COND_S, EFLAGS))]>,
1137 TB, OpSize;
1138def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1139 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1140 "cmovs\t{$src2, $dst|$dst, $src2}",
1141 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1142 X86_COND_S, EFLAGS))]>,
1143 TB;
1144def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1145 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1146 "cmovns\t{$src2, $dst|$dst, $src2}",
1147 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1148 X86_COND_NS, EFLAGS))]>,
1149 TB, OpSize;
1150def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1151 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1152 "cmovns\t{$src2, $dst|$dst, $src2}",
1153 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1154 X86_COND_NS, EFLAGS))]>,
1155 TB;
1156def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1157 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1158 "cmovp\t{$src2, $dst|$dst, $src2}",
1159 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1160 X86_COND_P, EFLAGS))]>,
1161 TB, OpSize;
1162def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1163 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1164 "cmovp\t{$src2, $dst|$dst, $src2}",
1165 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1166 X86_COND_P, EFLAGS))]>,
1167 TB;
1168def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1169 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1170 "cmovnp\t{$src2, $dst|$dst, $src2}",
1171 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1172 X86_COND_NP, EFLAGS))]>,
1173 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001174} // Uses = [EFLAGS]
1175
1176
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177// unary instructions
1178let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001179let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001180def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001182def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001183 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001184def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 [(set GR32:$dst, (ineg GR32:$src))]>;
1186let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001187 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001189 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001191 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001192 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1193
1194}
Evan Cheng55687072007-09-14 21:48:26 +00001195} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001196
Dan Gohman91888f02007-07-31 20:11:57 +00001197def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001199def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001201def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202 [(set GR32:$dst, (not GR32:$src))]>;
1203let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001204 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001206 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001208 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1210}
1211} // CodeSize
1212
1213// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001214let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001216def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217 [(set GR8:$dst, (add GR8:$src, 1))]>;
1218let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001219def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001220 [(set GR16:$dst, (add GR16:$src, 1))]>,
1221 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001222def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1224}
1225let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001226 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001227 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001228 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001229 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1230 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001231 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001232 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1233 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234}
1235
1236let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001237def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001238 [(set GR8:$dst, (add GR8:$src, -1))]>;
1239let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001240def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 [(set GR16:$dst, (add GR16:$src, -1))]>,
1242 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001243def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001244 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1245}
1246
1247let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001248 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001250 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001251 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1252 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001253 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001254 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1255 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256}
Evan Cheng55687072007-09-14 21:48:26 +00001257} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258
1259// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001260let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1262def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001263 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001264 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1266def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001267 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001268 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1270def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001271 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001272 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1274}
1275
1276def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001277 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001278 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1280def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001281 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001282 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1284def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001285 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001286 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1288
1289def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001290 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001291 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001292 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1293def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001294 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001295 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1297def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001298 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001299 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1301def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001302 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001303 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1305 OpSize;
1306def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001307 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001308 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1310
1311let isTwoAddress = 0 in {
1312 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001313 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001314 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001315 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1316 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001317 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001318 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1320 OpSize;
1321 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001322 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001323 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1325 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001326 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001327 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001328 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1329 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001330 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001331 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1333 OpSize;
1334 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001335 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001336 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1338 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001339 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001340 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1342 OpSize;
1343 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001344 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001345 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1347}
1348
1349
1350let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001351def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001352 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001354def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001355 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001357def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001358 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1360}
Evan Chengb783fa32007-07-19 01:14:50 +00001361def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001362 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001364def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001365 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001367def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001368 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1370
Evan Chengb783fa32007-07-19 01:14:50 +00001371def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001372 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001374def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001377def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001378 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1380
Evan Chengb783fa32007-07-19 01:14:50 +00001381def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001382 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001384def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001385 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1387let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001388 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001389 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001391 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001392 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001394 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001395 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001396 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001397 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001398 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001400 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001401 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001402 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1403 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001404 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001405 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001407 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001408 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1410 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001411 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001412 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001414} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415
1416
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001417let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001418 def XOR8rr : I<0x30, MRMDestReg,
1419 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1420 "xor{b}\t{$src2, $dst|$dst, $src2}",
1421 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1422 def XOR16rr : I<0x31, MRMDestReg,
1423 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1424 "xor{w}\t{$src2, $dst|$dst, $src2}",
1425 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1426 def XOR32rr : I<0x31, MRMDestReg,
1427 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1428 "xor{l}\t{$src2, $dst|$dst, $src2}",
1429 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001430} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001431
1432def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001433 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001435 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1436def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001437 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001438 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001439 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1440 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001441def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001442 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001443 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001444 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1445
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001446def XOR8ri : Ii8<0x80, MRM6r,
1447 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1448 "xor{b}\t{$src2, $dst|$dst, $src2}",
1449 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1450def XOR16ri : Ii16<0x81, MRM6r,
1451 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1452 "xor{w}\t{$src2, $dst|$dst, $src2}",
1453 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1454def XOR32ri : Ii32<0x81, MRM6r,
1455 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1456 "xor{l}\t{$src2, $dst|$dst, $src2}",
1457 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1458def XOR16ri8 : Ii8<0x83, MRM6r,
1459 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1460 "xor{w}\t{$src2, $dst|$dst, $src2}",
1461 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1462 OpSize;
1463def XOR32ri8 : Ii8<0x83, MRM6r,
1464 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1465 "xor{l}\t{$src2, $dst|$dst, $src2}",
1466 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001467
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001468let isTwoAddress = 0 in {
1469 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001470 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001471 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001472 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1473 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001474 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1477 OpSize;
1478 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001479 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001480 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001481 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1482 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001483 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001485 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1486 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001487 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1490 OpSize;
1491 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001492 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1495 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001496 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1499 OpSize;
1500 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001501 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001503 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001504} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001505} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001506
1507// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001508let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001509let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001510def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001512 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001513def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001515 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001516def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001517 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001518 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001519} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001520
Evan Chengb783fa32007-07-19 01:14:50 +00001521def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001523 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1524let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001525def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001526 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001527 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001528def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001529 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001531// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1532// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001533} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001534
1535let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001536 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001537 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001538 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001539 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001540 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001542 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001543 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001544 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001545 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1546 }
Evan Chengb783fa32007-07-19 01:14:50 +00001547 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001550 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1553 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001554 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001555 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1557
1558 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001559 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001560 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001562 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001563 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1565 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001566 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1569}
1570
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001571let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001572def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001573 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001574 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001575def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001577 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001578def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001580 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1581}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001582
Evan Chengb783fa32007-07-19 01:14:50 +00001583def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001584 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001585 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001586def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001587 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001589def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1592
1593// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001594def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001595 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001596 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001597def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001600def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001602 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1603
1604let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001605 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001606 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001607 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001608 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001609 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001610 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001612 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001613 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001615 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1616 }
Evan Chengb783fa32007-07-19 01:14:50 +00001617 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001618 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001620 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001621 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001622 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1623 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001624 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1627
1628 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001629 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001632 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001633 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001635 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1638}
1639
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001640let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001641def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001642 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001643 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001644def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001646 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001647def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001648 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001649 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1650}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001651
Evan Chengb783fa32007-07-19 01:14:50 +00001652def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001654 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001655def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001656 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001657 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1658 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001659def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001660 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1662
1663// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001664def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001665 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001667def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001668 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001669 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001670def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1673
1674let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001675 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001676 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001678 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001679 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001681 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001682 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001684 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1685 }
Evan Chengb783fa32007-07-19 01:14:50 +00001686 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001687 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001688 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001689 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001691 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1692 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001693 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001694 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001695 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1696
1697 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001698 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001699 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001700 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001701 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1704 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001705 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1708}
1709
1710// Rotate instructions
1711// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001712let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001713def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001715 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001716def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001717 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001718 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001719def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001721 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1722}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723
Evan Chengb783fa32007-07-19 01:14:50 +00001724def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001725 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001726 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001727def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001728 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001729 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001730def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1733
1734// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001735def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001738def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001739 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001741def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001743 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1744
1745let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001746 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001747 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001749 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001750 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001751 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001752 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001753 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001755 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1756 }
Evan Chengb783fa32007-07-19 01:14:50 +00001757 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001760 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1763 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001764 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1767
1768 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001769 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001771 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001772 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1775 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001776 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1779}
1780
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001781let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001782def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001784 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001785def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001787 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001788def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001790 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1791}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792
Evan Chengb783fa32007-07-19 01:14:50 +00001793def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001796def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001799def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1802
1803// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001804def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001805 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001807def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001808 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001809 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001810def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1813
1814let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001815 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001816 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001817 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001818 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001819 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001821 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001822 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001824 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1825 }
Evan Chengb783fa32007-07-19 01:14:50 +00001826 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001828 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001829 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1832 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001833 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001835 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1836
1837 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001838 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001841 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001842 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1844 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001845 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001846 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001847 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1848}
1849
1850
1851
1852// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001853let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001854def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001855 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001856 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001857def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001858 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001859 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001860def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001863 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001864def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001867 TB, OpSize;
1868}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869
1870let isCommutable = 1 in { // These instructions commute to each other.
1871def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001872 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001874 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1875 (i8 imm:$src3)))]>,
1876 TB;
1877def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001878 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001879 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1881 (i8 imm:$src3)))]>,
1882 TB;
1883def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001884 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1887 (i8 imm:$src3)))]>,
1888 TB, OpSize;
1889def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001890 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1893 (i8 imm:$src3)))]>,
1894 TB, OpSize;
1895}
1896
1897let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001898 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001899 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001900 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001901 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001902 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001903 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001906 addr:$dst)]>, TB;
1907 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001909 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001910 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001911 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1912 (i8 imm:$src3)), addr:$dst)]>,
1913 TB;
1914 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001915 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001916 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001917 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1918 (i8 imm:$src3)), addr:$dst)]>,
1919 TB;
1920
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001921 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001922 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001924 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001925 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001926 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001927 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001928 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001929 addr:$dst)]>, TB, OpSize;
1930 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001932 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001934 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1935 (i8 imm:$src3)), addr:$dst)]>,
1936 TB, OpSize;
1937 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001938 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001940 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1941 (i8 imm:$src3)), addr:$dst)]>,
1942 TB, OpSize;
1943}
Evan Cheng55687072007-09-14 21:48:26 +00001944} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945
1946
1947// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001948let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001949let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00001950// Register-Register Addition
1951def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1952 (ins GR8 :$src1, GR8 :$src2),
1953 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001954 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00001955 (implicit EFLAGS)]>;
1956
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001957let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00001958// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001959def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1960 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001961 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001962 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
1963 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001964def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1965 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001967 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
1968 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969} // end isConvertibleToThreeAddress
1970} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00001971
1972// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001973def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1974 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001976 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
1977 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001978def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1979 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001980 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001981 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
1982 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001983def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1984 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001985 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001986 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
1987 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988
Bill Wendlingae034ed2008-12-12 00:56:36 +00001989// Register-Integer Addition
1990def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1991 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00001992 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
1993 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00001994
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00001996// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001997def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1998 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001999 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002000 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2001 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002002def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2003 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002005 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2006 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002007def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2008 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002010 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2011 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002012def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2013 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002015 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2016 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017}
2018
2019let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002020 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002021 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002023 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2024 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002025 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002027 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2028 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002029 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002030 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002031 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2032 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002033 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002034 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002035 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2036 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002037 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002039 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2040 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002041 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002042 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002043 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2044 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002045 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002047 [(store (add (load addr:$dst), i16immSExt8:$src2),
2048 addr:$dst),
2049 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002050 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002052 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002053 addr:$dst),
2054 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055}
2056
Evan Cheng259471d2007-10-05 17:59:57 +00002057let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002059def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002061 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062}
Evan Chengb783fa32007-07-19 01:14:50 +00002063def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002065 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002066def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002067 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002068 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002069def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002070 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002071 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072
2073let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002074 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002075 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002076 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002077 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingc0ca7f32008-12-01 23:44:08 +00002079 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002080 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002081 "adc{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002082 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002083}
Evan Cheng259471d2007-10-05 17:59:57 +00002084} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085
Bill Wendlingae034ed2008-12-12 00:56:36 +00002086// Register-Register Subtraction
2087def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2088 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002089 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2090 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002091def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2092 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002093 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2094 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002095def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2096 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002097 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2098 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002099
2100// Register-Memory Subtraction
2101def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2102 (ins GR8 :$src1, i8mem :$src2),
2103 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002104 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2105 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002106def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2107 (ins GR16:$src1, i16mem:$src2),
2108 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002109 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2110 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002111def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2112 (ins GR32:$src1, i32mem:$src2),
2113 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002114 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2115 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002116
2117// Register-Integer Subtraction
2118def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2119 (ins GR8:$src1, i8imm:$src2),
2120 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002121 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2122 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002123def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2124 (ins GR16:$src1, i16imm:$src2),
2125 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002126 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2127 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002128def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2129 (ins GR32:$src1, i32imm:$src2),
2130 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002131 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2132 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002133def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2134 (ins GR16:$src1, i16i8imm:$src2),
2135 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002136 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2137 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002138def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2139 (ins GR32:$src1, i32i8imm:$src2),
2140 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002141 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2142 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002143
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002145 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002146 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002148 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2149 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002150 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002152 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2153 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002154 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002155 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002156 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2157 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002158
2159 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002160 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002162 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2163 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002164 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002165 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002166 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2167 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002168 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002169 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002170 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2171 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002172 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002173 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002174 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002175 addr:$dst),
2176 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002177 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002179 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002180 addr:$dst),
2181 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182}
2183
Evan Cheng259471d2007-10-05 17:59:57 +00002184let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002185def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002186 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002187 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188
2189let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002190 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002193 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002194 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002196 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002199 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002201 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202}
Evan Chengb783fa32007-07-19 01:14:50 +00002203def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002206def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002208 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002209def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002212} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002213} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214
Evan Cheng55687072007-09-14 21:48:26 +00002215let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002216let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002217// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002218def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002219 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002220 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2221 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002222def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002224 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2225 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002227
Bill Wendlingf5399032008-12-12 21:15:41 +00002228// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002229def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2230 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002231 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002232 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2233 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002234def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002236 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2237 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002238} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002239} // end Two Address instructions
2240
2241// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002242let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002243// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002245 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002247 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2248 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002249def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002250 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002251 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002252 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2253 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002255 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002257 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2258 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002260 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002262 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2263 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264
Bill Wendlingf5399032008-12-12 21:15:41 +00002265// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002267 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002268 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002269 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2270 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002272 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002274 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2275 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002276def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002277 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002278 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002279 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002280 i16immSExt8:$src2)),
2281 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002283 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002284 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002285 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002286 i32immSExt8:$src2)),
2287 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002288} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289
2290//===----------------------------------------------------------------------===//
2291// Test instructions are just like AND, except they don't generate a result.
2292//
Evan Cheng950aac02007-09-25 01:57:46 +00002293let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002295def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002296 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002297 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002298 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002299def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002300 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002301 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002302 (implicit EFLAGS)]>,
2303 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002304def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002305 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002306 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002307 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002308}
2309
Evan Chengb783fa32007-07-19 01:14:50 +00002310def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002311 "test{b}\t{$src2, $src1|$src1, $src2}",
2312 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2313 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002314def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002315 "test{w}\t{$src2, $src1|$src1, $src2}",
2316 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2317 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002318def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002319 "test{l}\t{$src2, $src1|$src1, $src2}",
2320 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2321 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322
2323def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002324 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002325 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002326 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002327 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002329 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002330 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002331 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002332 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002333def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002334 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002335 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002336 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002337 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002338
Evan Cheng621216e2007-09-29 00:00:36 +00002339def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002340 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002341 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002342 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2343 (implicit EFLAGS)]>;
2344def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002345 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002346 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002347 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2348 (implicit EFLAGS)]>, OpSize;
2349def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002350 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002351 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002352 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002353 (implicit EFLAGS)]>;
2354} // Defs = [EFLAGS]
2355
2356
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002357// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002358let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002359def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002360let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002361def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362
Evan Cheng950aac02007-09-25 01:57:46 +00002363let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002364def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002365 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002366 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002367 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002368 TB; // GR8 = ==
2369def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002370 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002372 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002373 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002374
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002375def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002376 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002377 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002378 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379 TB; // GR8 = !=
2380def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002381 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002382 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002383 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002385
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002386def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002387 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002388 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002389 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390 TB; // GR8 = < signed
2391def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002392 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002393 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002394 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002396
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002397def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002398 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002399 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002400 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401 TB; // GR8 = >= signed
2402def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002403 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002404 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002405 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002406 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002407
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002408def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002409 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002410 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002411 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002412 TB; // GR8 = <= signed
2413def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002414 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002415 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002416 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002418
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002419def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002420 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002421 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002422 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423 TB; // GR8 = > signed
2424def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002425 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002426 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002427 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002428 TB; // [mem8] = > signed
2429
2430def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002431 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002432 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002433 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002434 TB; // GR8 = < unsign
2435def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002436 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002437 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002438 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002439 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002440
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002441def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002442 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002443 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002444 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002445 TB; // GR8 = >= unsign
2446def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002447 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002448 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002449 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002450 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002451
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002452def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002453 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002455 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002456 TB; // GR8 = <= unsign
2457def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002458 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002459 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002460 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002461 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002462
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002463def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002464 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002465 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002466 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002467 TB; // GR8 = > signed
2468def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002469 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002470 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002471 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002472 TB; // [mem8] = > signed
2473
2474def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002475 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002476 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002477 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002478 TB; // GR8 = <sign bit>
2479def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002480 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002481 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002482 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002483 TB; // [mem8] = <sign bit>
2484def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002485 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002486 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002487 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002488 TB; // GR8 = !<sign bit>
2489def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002490 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002491 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002492 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002493 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002494
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002495def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002496 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002497 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002498 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002499 TB; // GR8 = parity
2500def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002501 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002502 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002503 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504 TB; // [mem8] = parity
2505def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002506 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002507 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002508 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002509 TB; // GR8 = not parity
2510def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002511 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002512 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002513 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002514 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002515
2516def SETOr : I<0x90, MRM0r,
2517 (outs GR8 :$dst), (ins),
2518 "seto\t$dst",
2519 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2520 TB; // GR8 = overflow
2521def SETOm : I<0x90, MRM0m,
2522 (outs), (ins i8mem:$dst),
2523 "seto\t$dst",
2524 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2525 TB; // [mem8] = overflow
2526def SETNOr : I<0x91, MRM0r,
2527 (outs GR8 :$dst), (ins),
2528 "setno\t$dst",
2529 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2530 TB; // GR8 = not overflow
2531def SETNOm : I<0x91, MRM0m,
2532 (outs), (ins i8mem:$dst),
2533 "setno\t$dst",
2534 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2535 TB; // [mem8] = not overflow
2536
2537def SETCr : I<0x92, MRM0r,
2538 (outs GR8 :$dst), (ins),
2539 "setc\t$dst",
2540 [(set GR8:$dst, (X86setcc X86_COND_C, EFLAGS))]>,
2541 TB; // GR8 = carry
2542def SETCm : I<0x92, MRM0m,
2543 (outs), (ins i8mem:$dst),
2544 "setc\t$dst",
2545 [(store (X86setcc X86_COND_C, EFLAGS), addr:$dst)]>,
2546 TB; // [mem8] = carry
2547def SETNCr : I<0x93, MRM0r,
2548 (outs GR8 :$dst), (ins),
2549 "setnc\t$dst",
2550 [(set GR8:$dst, (X86setcc X86_COND_NC, EFLAGS))]>,
2551 TB; // GR8 = not carry
2552def SETNCm : I<0x93, MRM0m,
2553 (outs), (ins i8mem:$dst),
2554 "setnc\t$dst",
2555 [(store (X86setcc X86_COND_NC, EFLAGS), addr:$dst)]>,
2556 TB; // [mem8] = not carry
Evan Cheng950aac02007-09-25 01:57:46 +00002557} // Uses = [EFLAGS]
2558
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002559
2560// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002561let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002562def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002563 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002564 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002565 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002566def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002567 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002568 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002569 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002571 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002572 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002573 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002575 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002576 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002577 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2578 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002579def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002580 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002581 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002582 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2583 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002584def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002585 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002586 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002587 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2588 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002590 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002591 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002592 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2593 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002594def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002595 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002596 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002597 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2598 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002599def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002600 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002601 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002602 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2603 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002604def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002605 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002606 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002607 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002608def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002609 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002610 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002611 [(X86cmp GR16:$src1, imm:$src2),
2612 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002614 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002615 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002616 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002617def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002618 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002619 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002620 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2621 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002623 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002624 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002625 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2626 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002627def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002628 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002629 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002630 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2631 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002633 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002634 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002635 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2636 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002637def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002638 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002639 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002640 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2641 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002642def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002643 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002644 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002645 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2646 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002647def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002648 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002649 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002650 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002651 (implicit EFLAGS)]>;
2652} // Defs = [EFLAGS]
2653
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002654// Bit tests.
2655// TODO: BT with immediate operands
2656// TODO: BTC, BTR, and BTS
2657let Defs = [EFLAGS] in {
2658def BT16rr : I<0xA3, MRMSrcReg, (outs), (ins GR16:$src1, GR16:$src2),
2659 "bt{w}\t{$src2, $src1|$src1, $src2}",
2660 [(X86bt GR16:$src1, GR16:$src2),
2661 (implicit EFLAGS)]>, OpSize;
2662def BT32rr : I<0xA3, MRMSrcReg, (outs), (ins GR32:$src1, GR32:$src2),
2663 "bt{l}\t{$src2, $src1|$src1, $src2}",
2664 [(X86bt GR32:$src1, GR32:$src2),
2665 (implicit EFLAGS)]>;
2666def BT16mr : I<0xA3, MRMSrcMem, (outs), (ins i16mem:$src1, GR16:$src2),
2667 "bt{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerf8048c32008-12-25 01:27:10 +00002668 [(X86bt (loadi16 addr:$src1), GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002669 (implicit EFLAGS)]>, OpSize;
2670def BT32mr : I<0xA3, MRMSrcMem, (outs), (ins i32mem:$src1, GR32:$src2),
2671 "bt{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerf8048c32008-12-25 01:27:10 +00002672 [(X86bt (loadi32 addr:$src1), GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002673 (implicit EFLAGS)]>;
2674} // Defs = [EFLAGS]
2675
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002676// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002677// Use movsbl intead of movsbw; we don't care about the high 16 bits
2678// of the register here. This has a smaller encoding and avoids a
2679// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002680def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002681 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2682 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002683def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002684 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2685 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002686def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002687 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002689def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002690 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002691 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002692def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002693 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002694 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002695def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002696 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002697 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2698
Dan Gohman9203ab42008-07-30 18:09:17 +00002699// Use movzbl intead of movzbw; we don't care about the high 16 bits
2700// of the register here. This has a smaller encoding and avoids a
2701// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002702def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002703 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2704 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002705def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002706 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2707 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002708def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002709 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002710 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002711def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002712 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002713 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002714def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002715 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002716 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002717def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002718 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002719 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2720
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002721let neverHasSideEffects = 1 in {
2722 let Defs = [AX], Uses = [AL] in
2723 def CBW : I<0x98, RawFrm, (outs), (ins),
2724 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2725 let Defs = [EAX], Uses = [AX] in
2726 def CWDE : I<0x98, RawFrm, (outs), (ins),
2727 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002728
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002729 let Defs = [AX,DX], Uses = [AX] in
2730 def CWD : I<0x99, RawFrm, (outs), (ins),
2731 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2732 let Defs = [EAX,EDX], Uses = [EAX] in
2733 def CDQ : I<0x99, RawFrm, (outs), (ins),
2734 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2735}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002736
2737//===----------------------------------------------------------------------===//
2738// Alias Instructions
2739//===----------------------------------------------------------------------===//
2740
2741// Alias instructions that map movr0 to xor.
2742// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002743let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002744def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002745 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002746 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002747// Use xorl instead of xorw since we don't care about the high 16 bits,
2748// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002749def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002750 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2751 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002752def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002753 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002754 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002755}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002756
2757// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2758// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002759let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002760def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002761 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002762def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002763 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002764
Evan Chengb783fa32007-07-19 01:14:50 +00002765def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002766 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002767def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002768 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002769} // neverHasSideEffects
2770
Dan Gohman5574cc72008-12-03 18:15:48 +00002771let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002772def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002773 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002774def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002775 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002776}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002777let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002778def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002779 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002780def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002781 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002782}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002783
2784//===----------------------------------------------------------------------===//
2785// Thread Local Storage Instructions
2786//
2787
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002788let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002789def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2790 "leal\t${sym:mem}(,%ebx,1), $dst",
2791 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002792
2793let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002794def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002795 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002796 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2797
2798let AddedComplexity = 15 in
Nicolas Geoffray81580792008-10-25 15:22:06 +00002799def TLS_gs_ri : I<0x8B, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002800 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002801 [(set GR32:$dst,
Nicolas Geoffray81580792008-10-25 15:22:06 +00002802 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>,
2803 SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002804
Nicolas Geoffray81580792008-10-25 15:22:06 +00002805def TLS_tp : I<0x8B, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002806 "movl\t%gs:0, $dst",
Nicolas Geoffray81580792008-10-25 15:22:06 +00002807 [(set GR32:$dst, X86TLStp)]>, SegGS;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808
2809//===----------------------------------------------------------------------===//
2810// DWARF Pseudo Instructions
2811//
2812
Evan Chengb783fa32007-07-19 01:14:50 +00002813def DWARF_LOC : I<0, Pseudo, (outs),
2814 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002815 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002816 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2817 (i32 imm:$file))]>;
2818
2819//===----------------------------------------------------------------------===//
2820// EH Pseudo Instructions
2821//
2822let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002823 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002824def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002825 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002826 [(X86ehret GR32:$addr)]>;
2827
2828}
2829
2830//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002831// Atomic support
2832//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002833
Evan Cheng3e171562008-04-19 01:20:30 +00002834// Atomic swap. These are just normal xchg instructions. But since a memory
2835// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00002836let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00002837def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2838 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2839 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2840def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2841 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2842 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2843 OpSize;
2844def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2845 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2846 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2847}
2848
Evan Chengd49dbb82008-04-18 20:55:36 +00002849// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002850let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002851def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002852 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002853 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002854}
Dale Johannesenf160d802008-10-02 18:53:47 +00002855let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00002856def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00002857 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00002858 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2859}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002860
2861let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002862def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002863 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002864 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002865}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002866let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002867def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002868 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002869 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002870}
2871
Evan Chengd49dbb82008-04-18 20:55:36 +00002872// Atomic exchange and add
2873let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2874def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002875 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002876 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002877 TB, LOCK;
2878def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002879 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002880 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002881 TB, OpSize, LOCK;
2882def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002883 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002884 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002885 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002886}
2887
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002888// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00002889let Constraints = "$val = $dst", Defs = [EFLAGS],
2890 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002891def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002892 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002893 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002894def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002895 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002896 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002897def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002898 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002899 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00002900def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002901 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002902 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002903def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002904 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002905 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002906def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002907 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002908 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002909def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002910 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002911 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002912def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002913 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002914 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002915
2916def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002917 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002918 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002919def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002920 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002921 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002922def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002923 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002924 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002925def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002926 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002927 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002928def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002929 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002930 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002931def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002932 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002933 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002934def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002935 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002936 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002937def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002938 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002939 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002940
2941def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002942 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002943 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002944def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002945 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002946 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002947def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002948 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002949 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002950def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002951 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002952 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00002953}
2954
Dale Johannesenf160d802008-10-02 18:53:47 +00002955let Constraints = "$val1 = $dst1, $val2 = $dst2",
2956 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
2957 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00002958 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00002959 usesCustomDAGSchedInserter = 1 in {
2960def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2961 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002962 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002963def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2964 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002965 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002966def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2967 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002968 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002969def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2970 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002971 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002972def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2973 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002974 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002975def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2976 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002977 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00002978def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2979 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00002980 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00002981}
2982
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002983//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002984// Non-Instruction Patterns
2985//===----------------------------------------------------------------------===//
2986
Bill Wendlingfef06052008-09-16 21:48:12 +00002987// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002988def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2989def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00002990def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002991def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2992def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2993
2994def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2995 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2996def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2997 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2998def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2999 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3000def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3001 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3002
3003def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3004 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3005def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3006 (MOV32mi addr:$dst, texternalsym:$src)>;
3007
3008// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003009// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003010def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003011 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003012
3013def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003014 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003015def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003016 (TAILCALL)>;
3017
3018def : Pat<(X86tcret GR32:$dst, imm:$off),
3019 (TCRETURNri GR32:$dst, imm:$off)>;
3020
3021def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3022 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3023
3024def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3025 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003026
3027def : Pat<(X86call (i32 tglobaladdr:$dst)),
3028 (CALLpcrel32 tglobaladdr:$dst)>;
3029def : Pat<(X86call (i32 texternalsym:$dst)),
3030 (CALLpcrel32 texternalsym:$dst)>;
3031
3032// X86 specific add which produces a flag.
3033def : Pat<(addc GR32:$src1, GR32:$src2),
3034 (ADD32rr GR32:$src1, GR32:$src2)>;
3035def : Pat<(addc GR32:$src1, (load addr:$src2)),
3036 (ADD32rm GR32:$src1, addr:$src2)>;
3037def : Pat<(addc GR32:$src1, imm:$src2),
3038 (ADD32ri GR32:$src1, imm:$src2)>;
3039def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3040 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3041
3042def : Pat<(subc GR32:$src1, GR32:$src2),
3043 (SUB32rr GR32:$src1, GR32:$src2)>;
3044def : Pat<(subc GR32:$src1, (load addr:$src2)),
3045 (SUB32rm GR32:$src1, addr:$src2)>;
3046def : Pat<(subc GR32:$src1, imm:$src2),
3047 (SUB32ri GR32:$src1, imm:$src2)>;
3048def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3049 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3050
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003051// Comparisons.
3052
3053// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003054def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003055 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003056def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003057 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003058def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003059 (TEST32rr GR32:$src1, GR32:$src1)>;
3060
Duncan Sands082524c2008-01-23 20:39:46 +00003061// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003062def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3063def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3064def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3065
3066// extload bool -> extload byte
3067def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003068def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3069 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003070def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003071def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3072 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003073def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3074def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3075
Dan Gohmandd612bb2008-08-20 21:27:32 +00003076// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003077def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3078 Requires<[In32BitMode]>;
3079def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3080 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003081def : Pat<(i32 (anyext GR16:$src)),
3082 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003083
Evan Chengf2abee72007-12-13 00:43:27 +00003084// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003085def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3086 (MOVZX32rm8 addr:$src)>;
3087def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3088 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003089
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003090//===----------------------------------------------------------------------===//
3091// Some peepholes
3092//===----------------------------------------------------------------------===//
3093
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003094// Odd encoding trick: -128 fits into an 8-bit immediate field while
3095// +128 doesn't, so in this special case use a sub instead of an add.
3096def : Pat<(add GR16:$src1, 128),
3097 (SUB16ri8 GR16:$src1, -128)>;
3098def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3099 (SUB16mi8 addr:$dst, -128)>;
3100def : Pat<(add GR32:$src1, 128),
3101 (SUB32ri8 GR32:$src1, -128)>;
3102def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3103 (SUB32mi8 addr:$dst, -128)>;
3104
Dan Gohman9203ab42008-07-30 18:09:17 +00003105// r & (2^16-1) ==> movz
3106def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003107 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003108// r & (2^8-1) ==> movz
3109def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003110 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
3111 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003112 Requires<[In32BitMode]>;
3113// r & (2^8-1) ==> movz
3114def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00003115 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
3116 x86_subreg_8bit)))>,
3117 Requires<[In32BitMode]>;
3118
3119// sext_inreg patterns
3120def : Pat<(sext_inreg GR32:$src, i16),
3121 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
3122def : Pat<(sext_inreg GR32:$src, i8),
3123 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
3124 x86_subreg_8bit)))>,
3125 Requires<[In32BitMode]>;
3126def : Pat<(sext_inreg GR16:$src, i8),
3127 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
3128 x86_subreg_8bit)))>,
3129 Requires<[In32BitMode]>;
3130
3131// trunc patterns
3132def : Pat<(i16 (trunc GR32:$src)),
3133 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
3134def : Pat<(i8 (trunc GR32:$src)),
3135 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
3136 Requires<[In32BitMode]>;
3137def : Pat<(i8 (trunc GR16:$src)),
3138 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003139 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003140
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003141// (shl x, 1) ==> (add x, x)
3142def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3143def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3144def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3145
Evan Cheng76a64c72008-08-30 02:03:58 +00003146// (shl x (and y, 31)) ==> (shl x, y)
3147def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3148 (SHL8rCL GR8:$src1)>;
3149def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3150 (SHL16rCL GR16:$src1)>;
3151def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3152 (SHL32rCL GR32:$src1)>;
3153def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3154 (SHL8mCL addr:$dst)>;
3155def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3156 (SHL16mCL addr:$dst)>;
3157def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3158 (SHL32mCL addr:$dst)>;
3159
3160def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3161 (SHR8rCL GR8:$src1)>;
3162def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3163 (SHR16rCL GR16:$src1)>;
3164def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3165 (SHR32rCL GR32:$src1)>;
3166def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3167 (SHR8mCL addr:$dst)>;
3168def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3169 (SHR16mCL addr:$dst)>;
3170def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3171 (SHR32mCL addr:$dst)>;
3172
3173def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3174 (SAR8rCL GR8:$src1)>;
3175def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3176 (SAR16rCL GR16:$src1)>;
3177def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3178 (SAR32rCL GR32:$src1)>;
3179def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3180 (SAR8mCL addr:$dst)>;
3181def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3182 (SAR16mCL addr:$dst)>;
3183def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3184 (SAR32mCL addr:$dst)>;
3185
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003186// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3187def : Pat<(or (srl GR32:$src1, CL:$amt),
3188 (shl GR32:$src2, (sub 32, CL:$amt))),
3189 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3190
3191def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3192 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3193 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3194
Dan Gohman921581d2008-10-17 01:23:35 +00003195def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3196 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3197 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3198
3199def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3200 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3201 addr:$dst),
3202 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3203
3204def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3205 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3206
3207def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3208 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3209 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3210
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003211// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3212def : Pat<(or (shl GR32:$src1, CL:$amt),
3213 (srl GR32:$src2, (sub 32, CL:$amt))),
3214 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3215
3216def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3217 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3218 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3219
Dan Gohman921581d2008-10-17 01:23:35 +00003220def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3221 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3222 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3223
3224def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3225 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3226 addr:$dst),
3227 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3228
3229def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3230 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3231
3232def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3233 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3234 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3235
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003236// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3237def : Pat<(or (srl GR16:$src1, CL:$amt),
3238 (shl GR16:$src2, (sub 16, CL:$amt))),
3239 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3240
3241def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3242 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3243 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3244
Dan Gohman921581d2008-10-17 01:23:35 +00003245def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3246 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3247 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3248
3249def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3250 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3251 addr:$dst),
3252 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3253
3254def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3255 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3256
3257def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3258 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3259 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3260
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003261// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3262def : Pat<(or (shl GR16:$src1, CL:$amt),
3263 (srl GR16:$src2, (sub 16, CL:$amt))),
3264 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3265
3266def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3267 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3268 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3269
Dan Gohman921581d2008-10-17 01:23:35 +00003270def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3271 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3272 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3273
3274def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3275 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3276 addr:$dst),
3277 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3278
3279def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3280 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3281
3282def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3283 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3284 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3285
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003286//===----------------------------------------------------------------------===//
Bill Wendlingf5399032008-12-12 21:15:41 +00003287// Overflow Patterns
3288//===----------------------------------------------------------------------===//
3289
3290// Register-Register Addition with Overflow
3291def : Pat<(parallel (X86add_ovf GR8:$src1, GR8:$src2),
3292 (implicit EFLAGS)),
3293 (ADD8rr GR8:$src1, GR8:$src2)>;
3294
3295// Register-Register Addition with Overflow
3296def : Pat<(parallel (X86add_ovf GR16:$src1, GR16:$src2),
3297 (implicit EFLAGS)),
3298 (ADD16rr GR16:$src1, GR16:$src2)>;
3299def : Pat<(parallel (X86add_ovf GR32:$src1, GR32:$src2),
3300 (implicit EFLAGS)),
3301 (ADD32rr GR32:$src1, GR32:$src2)>;
3302
3303// Register-Memory Addition with Overflow
3304def : Pat<(parallel (X86add_ovf GR8:$src1, (load addr:$src2)),
3305 (implicit EFLAGS)),
3306 (ADD8rm GR8:$src1, addr:$src2)>;
3307def : Pat<(parallel (X86add_ovf GR16:$src1, (load addr:$src2)),
3308 (implicit EFLAGS)),
3309 (ADD16rm GR16:$src1, addr:$src2)>;
3310def : Pat<(parallel (X86add_ovf GR32:$src1, (load addr:$src2)),
3311 (implicit EFLAGS)),
3312 (ADD32rm GR32:$src1, addr:$src2)>;
3313
3314// Register-Integer Addition with Overflow
3315def : Pat<(parallel (X86add_ovf GR8:$src1, imm:$src2),
3316 (implicit EFLAGS)),
3317 (ADD8ri GR8:$src1, imm:$src2)>;
3318
3319// Register-Integer Addition with Overflow
3320def : Pat<(parallel (X86add_ovf GR16:$src1, imm:$src2),
3321 (implicit EFLAGS)),
3322 (ADD16ri GR16:$src1, imm:$src2)>;
3323def : Pat<(parallel (X86add_ovf GR32:$src1, imm:$src2),
3324 (implicit EFLAGS)),
3325 (ADD32ri GR32:$src1, imm:$src2)>;
3326def : Pat<(parallel (X86add_ovf GR16:$src1, i16immSExt8:$src2),
3327 (implicit EFLAGS)),
3328 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
3329def : Pat<(parallel (X86add_ovf GR32:$src1, i32immSExt8:$src2),
3330 (implicit EFLAGS)),
3331 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3332
3333// Memory-Register Addition with Overflow
3334def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR8:$src2),
3335 addr:$dst),
3336 (implicit EFLAGS)),
3337 (ADD8mr addr:$dst, GR8:$src2)>;
3338def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR16:$src2),
3339 addr:$dst),
3340 (implicit EFLAGS)),
3341 (ADD16mr addr:$dst, GR16:$src2)>;
3342def : Pat<(parallel (store (X86add_ovf (load addr:$dst), GR32:$src2),
3343 addr:$dst),
3344 (implicit EFLAGS)),
3345 (ADD32mr addr:$dst, GR32:$src2)>;
3346def : Pat<(parallel (store (X86add_ovf (loadi8 addr:$dst), imm:$src2),
3347 addr:$dst),
3348 (implicit EFLAGS)),
3349 (ADD8mi addr:$dst, imm:$src2)>;
3350def : Pat<(parallel (store (X86add_ovf (loadi16 addr:$dst), imm:$src2),
3351 addr:$dst),
3352 (implicit EFLAGS)),
3353 (ADD16mi addr:$dst, imm:$src2)>;
3354def : Pat<(parallel (store (X86add_ovf (loadi32 addr:$dst), imm:$src2),
3355 addr:$dst),
3356 (implicit EFLAGS)),
3357 (ADD32mi addr:$dst, imm:$src2)>;
3358def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i16immSExt8:$src2),
3359 addr:$dst),
3360 (implicit EFLAGS)),
3361 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
3362def : Pat<(parallel (store (X86add_ovf (load addr:$dst), i32immSExt8:$src2),
3363 addr:$dst),
3364 (implicit EFLAGS)),
3365 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3366
3367// Register-Register Subtraction with Overflow
3368def : Pat<(parallel (X86sub_ovf GR8:$src1, GR8:$src2),
3369 (implicit EFLAGS)),
3370 (SUB8rr GR8:$src1, GR8:$src2)>;
3371def : Pat<(parallel (X86sub_ovf GR16:$src1, GR16:$src2),
3372 (implicit EFLAGS)),
3373 (SUB16rr GR16:$src1, GR16:$src2)>;
3374def : Pat<(parallel (X86sub_ovf GR32:$src1, GR32:$src2),
3375 (implicit EFLAGS)),
3376 (SUB32rr GR32:$src1, GR32:$src2)>;
3377
3378// Register-Memory Subtraction with Overflow
3379def : Pat<(parallel (X86sub_ovf GR8:$src1, (load addr:$src2)),
3380 (implicit EFLAGS)),
3381 (SUB8rm GR8:$src1, addr:$src2)>;
3382def : Pat<(parallel (X86sub_ovf GR16:$src1, (load addr:$src2)),
3383 (implicit EFLAGS)),
3384 (SUB16rm GR16:$src1, addr:$src2)>;
3385def : Pat<(parallel (X86sub_ovf GR32:$src1, (load addr:$src2)),
3386 (implicit EFLAGS)),
3387 (SUB32rm GR32:$src1, addr:$src2)>;
3388
3389// Register-Integer Subtraction with Overflow
3390def : Pat<(parallel (X86sub_ovf GR8:$src1, imm:$src2),
3391 (implicit EFLAGS)),
3392 (SUB8ri GR8:$src1, imm:$src2)>;
3393def : Pat<(parallel (X86sub_ovf GR16:$src1, imm:$src2),
3394 (implicit EFLAGS)),
3395 (SUB16ri GR16:$src1, imm:$src2)>;
3396def : Pat<(parallel (X86sub_ovf GR32:$src1, imm:$src2),
3397 (implicit EFLAGS)),
3398 (SUB32ri GR32:$src1, imm:$src2)>;
3399def : Pat<(parallel (X86sub_ovf GR16:$src1, i16immSExt8:$src2),
3400 (implicit EFLAGS)),
3401 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
3402def : Pat<(parallel (X86sub_ovf GR32:$src1, i32immSExt8:$src2),
3403 (implicit EFLAGS)),
3404 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3405
3406// Memory-Register Subtraction with Overflow
3407def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR8:$src2),
3408 addr:$dst),
3409 (implicit EFLAGS)),
3410 (SUB8mr addr:$dst, GR8:$src2)>;
3411def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR16:$src2),
3412 addr:$dst),
3413 (implicit EFLAGS)),
3414 (SUB16mr addr:$dst, GR16:$src2)>;
3415def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), GR32:$src2),
3416 addr:$dst),
3417 (implicit EFLAGS)),
3418 (SUB32mr addr:$dst, GR32:$src2)>;
3419
3420// Memory-Integer Subtraction with Overflow
3421def : Pat<(parallel (store (X86sub_ovf (loadi8 addr:$dst), imm:$src2),
3422 addr:$dst),
3423 (implicit EFLAGS)),
3424 (SUB8mi addr:$dst, imm:$src2)>;
3425def : Pat<(parallel (store (X86sub_ovf (loadi16 addr:$dst), imm:$src2),
3426 addr:$dst),
3427 (implicit EFLAGS)),
3428 (SUB16mi addr:$dst, imm:$src2)>;
3429def : Pat<(parallel (store (X86sub_ovf (loadi32 addr:$dst), imm:$src2),
3430 addr:$dst),
3431 (implicit EFLAGS)),
3432 (SUB32mi addr:$dst, imm:$src2)>;
3433def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i16immSExt8:$src2),
3434 addr:$dst),
3435 (implicit EFLAGS)),
3436 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
3437def : Pat<(parallel (store (X86sub_ovf (load addr:$dst), i32immSExt8:$src2),
3438 addr:$dst),
3439 (implicit EFLAGS)),
3440 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3441
3442
3443// Register-Register Signed Integer Multiply with Overflow
3444def : Pat<(parallel (X86smul_ovf GR16:$src1, GR16:$src2),
3445 (implicit EFLAGS)),
3446 (IMUL16rr GR16:$src1, GR16:$src2)>;
3447def : Pat<(parallel (X86smul_ovf GR32:$src1, GR32:$src2),
3448 (implicit EFLAGS)),
3449 (IMUL32rr GR32:$src1, GR32:$src2)>;
3450
3451// Register-Memory Signed Integer Multiply with Overflow
3452def : Pat<(parallel (X86smul_ovf GR16:$src1, (load addr:$src2)),
3453 (implicit EFLAGS)),
3454 (IMUL16rm GR16:$src1, addr:$src2)>;
3455def : Pat<(parallel (X86smul_ovf GR32:$src1, (load addr:$src2)),
3456 (implicit EFLAGS)),
3457 (IMUL32rm GR32:$src1, addr:$src2)>;
3458
3459// Register-Integer Signed Integer Multiply with Overflow
3460def : Pat<(parallel (X86smul_ovf GR16:$src1, imm:$src2),
3461 (implicit EFLAGS)),
3462 (IMUL16rri GR16:$src1, imm:$src2)>;
3463def : Pat<(parallel (X86smul_ovf GR32:$src1, imm:$src2),
3464 (implicit EFLAGS)),
3465 (IMUL32rri GR32:$src1, imm:$src2)>;
3466def : Pat<(parallel (X86smul_ovf GR16:$src1, i16immSExt8:$src2),
3467 (implicit EFLAGS)),
3468 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
3469def : Pat<(parallel (X86smul_ovf GR32:$src1, i32immSExt8:$src2),
3470 (implicit EFLAGS)),
3471 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3472
3473// Memory-Integer Signed Integer Multiply with Overflow
3474def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
3475 (implicit EFLAGS)),
3476 (IMUL16rmi addr:$src1, imm:$src2)>;
3477def : Pat<(parallel (X86smul_ovf (load addr:$src1), imm:$src2),
3478 (implicit EFLAGS)),
3479 (IMUL32rmi addr:$src1, imm:$src2)>;
3480def : Pat<(parallel (X86smul_ovf (load addr:$src1), i16immSExt8:$src2),
3481 (implicit EFLAGS)),
3482 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
3483def : Pat<(parallel (X86smul_ovf (load addr:$src1), i32immSExt8:$src2),
3484 (implicit EFLAGS)),
3485 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3486
3487//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003488// Floating Point Stack Support
3489//===----------------------------------------------------------------------===//
3490
3491include "X86InstrFPStack.td"
3492
3493//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003494// X86-64 Support
3495//===----------------------------------------------------------------------===//
3496
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003497include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003498
3499//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003500// XMM Floating point support (requires SSE / SSE2)
3501//===----------------------------------------------------------------------===//
3502
3503include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003504
3505//===----------------------------------------------------------------------===//
3506// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3507//===----------------------------------------------------------------------===//
3508
3509include "X86InstrMMX.td"