blob: de80bb2d45b8695ec2740a40d4876cafb1191216 [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
Evan Cheng621216e2007-09-29 00:00:36 +000030def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000031 [SDTCisVT<0, OtherVT>,
32 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000033
Evan Cheng621216e2007-09-29 00:00:36 +000034def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000035 [SDTCisVT<0, i8>,
36 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000038def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
39 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000040def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000041
Dale Johannesenf160d802008-10-02 18:53:47 +000042def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
43 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000044def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045
Bill Wendling7173da52007-11-13 09:19:02 +000046def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
47def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
48 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000049
Dan Gohman3329ffe2008-05-29 19:57:41 +000050def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000051
52def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
53
54def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
55
56def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
57
58def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
59
60def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
61
62def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
63
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000064def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
65
Evan Cheng48679f42007-12-14 02:13:44 +000066def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
67def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
69def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
70
Evan Cheng621216e2007-09-29 00:00:36 +000071def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072
Evan Cheng621216e2007-09-29 00:00:36 +000073def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000074def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000075 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000076def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000077
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000078def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
79 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
80 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000081def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
82 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
83 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000084def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
85 [SDNPHasChain, SDNPMayStore,
86 SDNPMayLoad, SDNPMemOperand]>;
87def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
88 [SDNPHasChain, SDNPMayStore,
89 SDNPMayLoad, SDNPMemOperand]>;
90def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
91 [SDNPHasChain, SDNPMayStore,
92 SDNPMayLoad, SDNPMemOperand]>;
93def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000102def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
103 [SDNPHasChain, SDNPOptInFlag]>;
104
105def X86callseq_start :
106 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
107 [SDNPHasChain, SDNPOutFlag]>;
108def X86callseq_end :
109 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000110 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000111
112def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
113 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
114
115def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
116 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
117
118def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000119 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000121 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
122 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123
124def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000125 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126
127def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
128def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
129
130def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000131 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
133
134def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
135 [SDNPHasChain]>;
136
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000137def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
138 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139
140//===----------------------------------------------------------------------===//
141// X86 Operand Definitions.
142//
143
144// *mem - Operand definitions for the funky X86 addressing mode operands.
145//
146class X86MemOperand<string printMethod> : Operand<iPTR> {
147 let PrintMethod = printMethod;
148 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
149}
150
151def i8mem : X86MemOperand<"printi8mem">;
152def i16mem : X86MemOperand<"printi16mem">;
153def i32mem : X86MemOperand<"printi32mem">;
154def i64mem : X86MemOperand<"printi64mem">;
155def i128mem : X86MemOperand<"printi128mem">;
156def f32mem : X86MemOperand<"printf32mem">;
157def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000158def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159def f128mem : X86MemOperand<"printf128mem">;
160
161def lea32mem : Operand<i32> {
162 let PrintMethod = "printi32mem";
163 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
164}
165
166def SSECC : Operand<i8> {
167 let PrintMethod = "printSSECC";
168}
169
170def piclabel: Operand<i32> {
171 let PrintMethod = "printPICLabel";
172}
173
174// A couple of more descriptive operand definitions.
175// 16-bits but only 8 bits are significant.
176def i16i8imm : Operand<i16>;
177// 32-bits but only 8 bits are significant.
178def i32i8imm : Operand<i32>;
179
180// Branch targets have OtherVT type.
181def brtarget : Operand<OtherVT>;
182
183//===----------------------------------------------------------------------===//
184// X86 Complex Pattern Definitions.
185//
186
187// Define X86 specific addressing mode.
188def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
189def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
190 [add, mul, shl, or, frameindex], []>;
191
192//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000193// X86 Instruction Predicate Definitions.
194def HasMMX : Predicate<"Subtarget->hasMMX()">;
195def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
196def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
197def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
198def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000199def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
200def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000201def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
202def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
204def In64BitMode : Predicate<"Subtarget->is64Bit()">;
205def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
206def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
207def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000208def OptForSpeed : Predicate<"!OptForSize">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000209
210//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000211// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212//
213
Evan Cheng86ab7d32007-07-31 08:04:03 +0000214include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000215
216//===----------------------------------------------------------------------===//
217// Pattern fragments...
218//
219
220// X86 specific condition code. These correspond to CondCode in
221// X86InstrInfo.h. They must be kept in synch.
222def X86_COND_A : PatLeaf<(i8 0)>;
223def X86_COND_AE : PatLeaf<(i8 1)>;
224def X86_COND_B : PatLeaf<(i8 2)>;
225def X86_COND_BE : PatLeaf<(i8 3)>;
226def X86_COND_E : PatLeaf<(i8 4)>;
227def X86_COND_G : PatLeaf<(i8 5)>;
228def X86_COND_GE : PatLeaf<(i8 6)>;
229def X86_COND_L : PatLeaf<(i8 7)>;
230def X86_COND_LE : PatLeaf<(i8 8)>;
231def X86_COND_NE : PatLeaf<(i8 9)>;
232def X86_COND_NO : PatLeaf<(i8 10)>;
233def X86_COND_NP : PatLeaf<(i8 11)>;
234def X86_COND_NS : PatLeaf<(i8 12)>;
235def X86_COND_O : PatLeaf<(i8 13)>;
236def X86_COND_P : PatLeaf<(i8 14)>;
237def X86_COND_S : PatLeaf<(i8 15)>;
238
239def i16immSExt8 : PatLeaf<(i16 imm), [{
240 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
241 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000242 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243}]>;
244
245def i32immSExt8 : PatLeaf<(i32 imm), [{
246 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
247 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000248 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249}]>;
250
251// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000252// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
253// known to be 32-bit aligned or better. Ditto for i8 to i16.
Evan Cheng8b765e92008-05-13 00:54:02 +0000254def loadi16 : PatFrag<(ops node:$ptr), (i16 (ld node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000255 LoadSDNode *LD = cast<LoadSDNode>(N);
256 if (LD->getAddressingMode() != ISD::UNINDEXED)
257 return false;
258 ISD::LoadExtType ExtType = LD->getExtensionType();
259 if (ExtType == ISD::NON_EXTLOAD)
260 return true;
261 if (ExtType == ISD::EXTLOAD)
262 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000263 return false;
264}]>;
265
Evan Cheng56ec77b2008-09-24 23:27:55 +0000266def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
267 LoadSDNode *LD = cast<LoadSDNode>(N);
268 if (LD->getAddressingMode() != ISD::UNINDEXED)
269 return false;
270 ISD::LoadExtType ExtType = LD->getExtensionType();
271 if (ExtType == ISD::EXTLOAD)
272 return LD->getAlignment() >= 2 && !LD->isVolatile();
273 return false;
274}]>;
275
Evan Cheng8b765e92008-05-13 00:54:02 +0000276def loadi32 : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000277 LoadSDNode *LD = cast<LoadSDNode>(N);
278 if (LD->getAddressingMode() != ISD::UNINDEXED)
279 return false;
280 ISD::LoadExtType ExtType = LD->getExtensionType();
281 if (ExtType == ISD::NON_EXTLOAD)
282 return true;
283 if (ExtType == ISD::EXTLOAD)
284 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000285 return false;
286}]>;
287
Evan Cheng1e5e5452008-09-29 17:26:18 +0000288def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
289 LoadSDNode *LD = cast<LoadSDNode>(N);
290 if (LD->isVolatile())
291 return false;
292 if (LD->getAddressingMode() != ISD::UNINDEXED)
293 return false;
294 ISD::LoadExtType ExtType = LD->getExtensionType();
295 if (ExtType == ISD::NON_EXTLOAD)
296 return true;
297 if (ExtType == ISD::EXTLOAD)
298 return LD->getAlignment() >= 4;
299 return false;
300}]>;
301
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000303def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
304
305def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
306def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000307def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
310def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
311def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
312
313def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
314def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
315def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
316def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
317def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
318def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
319
320def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
321def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
322def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
323def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
324def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
325def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
326
Chris Lattner21da6382008-02-19 17:37:35 +0000327
328// An 'and' node with a single use.
329def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000330 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000331}]>;
332
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334// Instruction list...
335//
336
337// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
338// a stack adjustment and the codegen must know that they may modify the stack
339// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000340// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
341// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000342let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000343def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
344 "#ADJCALLSTACKDOWN",
345 [(X86callseq_start imm:$amt)]>,
346 Requires<[In32BitMode]>;
347def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
348 "#ADJCALLSTACKUP",
349 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
350 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000351}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000352
353// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000354let neverHasSideEffects = 1 in
355 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356
Evan Cheng0729ccf2008-01-05 00:41:47 +0000357// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000358let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000359 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
360 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361
362//===----------------------------------------------------------------------===//
363// Control Flow Instructions...
364//
365
366// Return instructions.
367let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000368 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000369 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000370 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000371 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000372 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
373 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000374 [(X86retflag imm:$amt)]>;
375}
376
377// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000378let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000379 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
380 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000381
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000383 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384
Owen Andersonf8053082007-11-12 07:39:39 +0000385// Indirect branches
386let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000387 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000389 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390 [(brind (loadi32 addr:$dst))]>;
391}
392
393// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000394let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000395def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000396 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000397def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000398 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000399def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000400 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000401def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000402 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000403def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000404 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000405def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000406 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407
Dan Gohman91888f02007-07-31 20:11:57 +0000408def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000409 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000410def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000411 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000412def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000413 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000414def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000415 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416
Dan Gohman91888f02007-07-31 20:11:57 +0000417def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000418 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000419def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000420 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000421def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000422 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000423def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000424 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000425def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000426 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000427def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000428 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000429} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430
431//===----------------------------------------------------------------------===//
432// Call Instructions...
433//
Evan Cheng37e7c752007-07-21 00:34:19 +0000434let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000435 // All calls clobber the non-callee saved registers. ESP is marked as
436 // a use to prevent stack-pointer assignments that appear immediately
437 // before calls from potentially appearing dead. Uses for argument
438 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
440 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Dan Gohman9499cfe2008-10-01 04:14:30 +0000441 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS],
442 Uses = [ESP] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000443 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
444 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000445 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000446 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000447 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000448 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449 }
450
451// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000452
Chris Lattnerb56cc342008-03-11 03:23:40 +0000453def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000454 "#TAILCALL",
455 []>;
456
Evan Cheng37e7c752007-07-21 00:34:19 +0000457let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000458def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000459 "#TC_RETURN $dst $offset",
460 []>;
461
462let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000463def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000464 "#TC_RETURN $dst $offset",
465 []>;
466
467let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000468
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000469 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000471let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000472 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
473 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000474let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000475 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000476 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000477
478//===----------------------------------------------------------------------===//
479// Miscellaneous Instructions...
480//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000481let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000482def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000483 (outs), (ins), "leave", []>;
484
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000485let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
486let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000487def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000488
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000489let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000490def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000491}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000493let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000494def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000495let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000496def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000497
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000498let isTwoAddress = 1 in // GR32 = bswap GR32
499 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000500 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000501 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
503
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504
Evan Cheng48679f42007-12-14 02:13:44 +0000505// Bit scan instructions.
506let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000507def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000508 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000509 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000510def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000511 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000512 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
513 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000514def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000515 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000516 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000517def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000518 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000519 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
520 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000521
Evan Cheng4e33de92007-12-14 18:49:43 +0000522def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000523 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000524 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000525def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000526 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000527 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
528 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000529def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000530 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000531 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000532def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000533 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000534 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
535 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000536} // Defs = [EFLAGS]
537
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000538let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000540 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000541 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000542let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000544 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000545 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000546 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
547
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000548let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000549def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000550 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000551def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000552 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000553def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000554 [(X86rep_movs i32)]>, REP;
555}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000557let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000558def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000559 [(X86rep_stos i8)]>, REP;
560let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000561def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000562 [(X86rep_stos i16)]>, REP, OpSize;
563let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000564def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000565 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000567let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000568def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000569 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000571let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000572def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000573}
574
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575//===----------------------------------------------------------------------===//
576// Input/Output Instructions...
577//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000578let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000579def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000580 "in{b}\t{%dx, %al|%AL, %DX}", []>;
581let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000582def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000583 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
584let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000585def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000586 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000587
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000588let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000589def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000590 "in{b}\t{$port, %al|%AL, $port}", []>;
591let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000592def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000593 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
594let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000595def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000596 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000598let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000599def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000600 "out{b}\t{%al, %dx|%DX, %AL}", []>;
601let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000602def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000603 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
604let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000605def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000606 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000608let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000609def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000610 "out{b}\t{%al, $port|$port, %AL}", []>;
611let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000612def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000613 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
614let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000615def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000616 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000617
618//===----------------------------------------------------------------------===//
619// Move Instructions...
620//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000621let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000622def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000623 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000624def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000625 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000626def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000627 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000628}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000629let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000630def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000631 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000632 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000633def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000634 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000636def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000637 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000638 [(set GR32:$dst, imm:$src)]>;
639}
Evan Chengb783fa32007-07-19 01:14:50 +0000640def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000641 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000643def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000644 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000646def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648 [(store (i32 imm:$src), addr:$dst)]>;
649
Chris Lattner1a1932c2008-01-06 23:38:27 +0000650let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000651def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000652 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000654def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000655 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000657def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000658 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000660}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661
Evan Chengb783fa32007-07-19 01:14:50 +0000662def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000663 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000665def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000666 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000667 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000668def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000669 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670 [(store GR32:$src, addr:$dst)]>;
671
672//===----------------------------------------------------------------------===//
673// Fixed-Register Multiplication and Division Instructions...
674//
675
676// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000677let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000678def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
680 // This probably ought to be moved to a def : Pat<> if the
681 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000682 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000683let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000684def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000685 OpSize; // AX,DX = AX*GR16
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000686let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000687def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
688 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000689let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000690def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000691 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
693 // This probably ought to be moved to a def : Pat<> if the
694 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000695 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000696let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000697let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000698def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000699 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000700let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000701def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000702 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000703}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000705let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000706let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000707def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
708 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000709let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000710def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000711 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000712let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000713def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
714 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000715let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000716let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000717def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000718 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000719let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000720def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000721 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
722let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000723def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000724 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000725}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726
727// unsigned division/remainder
Evan Cheng55687072007-09-14 21:48:26 +0000728let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000729def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000730 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000731let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000732def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000733 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000734let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000735def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000736 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000737let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000738let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000739def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000740 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000741let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000742def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000743 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000744let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000745def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000746 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000747}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748
749// Signed division/remainder.
Evan Cheng55687072007-09-14 21:48:26 +0000750let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000751def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000752 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000753let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000754def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000755 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000756let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000757def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000758 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000759let mayLoad = 1, mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000760let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000761def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000762 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000763let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000764def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000765 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000766let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000767def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000768 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000769}
770} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771
772//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000773// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774//
775let isTwoAddress = 1 in {
776
777// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000778let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000779let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000781 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000782 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000784 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000787 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000788 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000790 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792
793def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000794 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000795 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000797 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000799def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000800 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000801 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000803 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000806 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000807 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000809 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000812 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000813 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000815 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000818 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000819 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000821 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000824 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000825 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000827 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000830 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000831 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000833 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000836 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000837 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000839 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000842 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000843 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000845 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000848 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000849 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000851 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000854 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000857 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000863 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000866 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000867 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000869 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000872 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000873 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000874 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000875 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000878 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000879 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000881 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000884 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000885 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000887 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000890 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000891 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000893 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000896 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000897 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000899 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000902 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000903 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000905 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000908 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000909 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000911 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000914 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000915 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000917 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000920 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000921 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000922 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000923 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000926 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000927 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000929 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000932 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000933 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000935 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000938 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000939 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000941 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000944 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000945 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000947 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000949} // isCommutable = 1
950
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000952 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000953 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000955 X86_COND_NP, EFLAGS))]>,
956 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000957
958def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
959 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
960 "cmovb\t{$src2, $dst|$dst, $src2}",
961 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
962 X86_COND_B, EFLAGS))]>,
963 TB, OpSize;
964def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
965 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
966 "cmovb\t{$src2, $dst|$dst, $src2}",
967 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
968 X86_COND_B, EFLAGS))]>,
969 TB;
970def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
971 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
972 "cmovae\t{$src2, $dst|$dst, $src2}",
973 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
974 X86_COND_AE, EFLAGS))]>,
975 TB, OpSize;
976def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
977 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
978 "cmovae\t{$src2, $dst|$dst, $src2}",
979 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
980 X86_COND_AE, EFLAGS))]>,
981 TB;
982def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
983 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
984 "cmove\t{$src2, $dst|$dst, $src2}",
985 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
986 X86_COND_E, EFLAGS))]>,
987 TB, OpSize;
988def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
989 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
990 "cmove\t{$src2, $dst|$dst, $src2}",
991 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
992 X86_COND_E, EFLAGS))]>,
993 TB;
994def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
995 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
996 "cmovne\t{$src2, $dst|$dst, $src2}",
997 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
998 X86_COND_NE, EFLAGS))]>,
999 TB, OpSize;
1000def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1001 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1002 "cmovne\t{$src2, $dst|$dst, $src2}",
1003 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1004 X86_COND_NE, EFLAGS))]>,
1005 TB;
1006def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1007 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1008 "cmovbe\t{$src2, $dst|$dst, $src2}",
1009 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1010 X86_COND_BE, EFLAGS))]>,
1011 TB, OpSize;
1012def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1013 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1014 "cmovbe\t{$src2, $dst|$dst, $src2}",
1015 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1016 X86_COND_BE, EFLAGS))]>,
1017 TB;
1018def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1019 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1020 "cmova\t{$src2, $dst|$dst, $src2}",
1021 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1022 X86_COND_A, EFLAGS))]>,
1023 TB, OpSize;
1024def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1025 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1026 "cmova\t{$src2, $dst|$dst, $src2}",
1027 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1028 X86_COND_A, EFLAGS))]>,
1029 TB;
1030def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1031 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1032 "cmovl\t{$src2, $dst|$dst, $src2}",
1033 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1034 X86_COND_L, EFLAGS))]>,
1035 TB, OpSize;
1036def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1037 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1038 "cmovl\t{$src2, $dst|$dst, $src2}",
1039 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1040 X86_COND_L, EFLAGS))]>,
1041 TB;
1042def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1043 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1044 "cmovge\t{$src2, $dst|$dst, $src2}",
1045 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1046 X86_COND_GE, EFLAGS))]>,
1047 TB, OpSize;
1048def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1049 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1050 "cmovge\t{$src2, $dst|$dst, $src2}",
1051 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1052 X86_COND_GE, EFLAGS))]>,
1053 TB;
1054def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1055 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1056 "cmovle\t{$src2, $dst|$dst, $src2}",
1057 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1058 X86_COND_LE, EFLAGS))]>,
1059 TB, OpSize;
1060def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1061 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1062 "cmovle\t{$src2, $dst|$dst, $src2}",
1063 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1064 X86_COND_LE, EFLAGS))]>,
1065 TB;
1066def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1067 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1068 "cmovg\t{$src2, $dst|$dst, $src2}",
1069 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1070 X86_COND_G, EFLAGS))]>,
1071 TB, OpSize;
1072def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1073 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1074 "cmovg\t{$src2, $dst|$dst, $src2}",
1075 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1076 X86_COND_G, EFLAGS))]>,
1077 TB;
1078def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1079 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1080 "cmovs\t{$src2, $dst|$dst, $src2}",
1081 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1082 X86_COND_S, EFLAGS))]>,
1083 TB, OpSize;
1084def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1085 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1086 "cmovs\t{$src2, $dst|$dst, $src2}",
1087 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1088 X86_COND_S, EFLAGS))]>,
1089 TB;
1090def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1091 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1092 "cmovns\t{$src2, $dst|$dst, $src2}",
1093 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1094 X86_COND_NS, EFLAGS))]>,
1095 TB, OpSize;
1096def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1097 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1098 "cmovns\t{$src2, $dst|$dst, $src2}",
1099 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1100 X86_COND_NS, EFLAGS))]>,
1101 TB;
1102def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1103 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1104 "cmovp\t{$src2, $dst|$dst, $src2}",
1105 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1106 X86_COND_P, EFLAGS))]>,
1107 TB, OpSize;
1108def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1109 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1110 "cmovp\t{$src2, $dst|$dst, $src2}",
1111 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1112 X86_COND_P, EFLAGS))]>,
1113 TB;
1114def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1115 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1116 "cmovnp\t{$src2, $dst|$dst, $src2}",
1117 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1118 X86_COND_NP, EFLAGS))]>,
1119 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001120} // Uses = [EFLAGS]
1121
1122
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001123// unary instructions
1124let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001125let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001126def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001128def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001130def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131 [(set GR32:$dst, (ineg GR32:$src))]>;
1132let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001133 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001135 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001137 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001138 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1139
1140}
Evan Cheng55687072007-09-14 21:48:26 +00001141} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142
Dan Gohman91888f02007-07-31 20:11:57 +00001143def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001144 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001145def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001147def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148 [(set GR32:$dst, (not GR32:$src))]>;
1149let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001150 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001152 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001154 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1156}
1157} // CodeSize
1158
1159// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001160let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001162def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163 [(set GR8:$dst, (add GR8:$src, 1))]>;
1164let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001165def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166 [(set GR16:$dst, (add GR16:$src, 1))]>,
1167 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001168def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1170}
1171let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001172 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001173 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001174 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001175 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1176 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001177 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001178 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1179 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180}
1181
1182let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001183def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 [(set GR8:$dst, (add GR8:$src, -1))]>;
1185let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001186def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187 [(set GR16:$dst, (add GR16:$src, -1))]>,
1188 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001189def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1191}
1192
1193let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001194 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001195 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001196 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001197 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1198 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001199 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001200 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1201 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202}
Evan Cheng55687072007-09-14 21:48:26 +00001203} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204
1205// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001206let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1208def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001209 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001210 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1212def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001213 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001214 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1216def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001217 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001218 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1220}
1221
1222def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001223 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001224 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1226def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001227 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001228 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1230def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001231 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001232 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1234
1235def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001236 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001237 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001238 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1239def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001240 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001241 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1243def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001244 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001245 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1247def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001248 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001249 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1251 OpSize;
1252def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001253 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001254 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1256
1257let isTwoAddress = 0 in {
1258 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001259 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001260 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1262 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001263 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001264 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1266 OpSize;
1267 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001268 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001269 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1271 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001272 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001273 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001274 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1275 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001276 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001277 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1279 OpSize;
1280 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001281 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001282 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1284 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001285 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001286 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1288 OpSize;
1289 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001290 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001291 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001292 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1293}
1294
1295
1296let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001297def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001300def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001303def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001304 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1306}
Evan Chengb783fa32007-07-19 01:14:50 +00001307def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001308 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001310def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001311 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001313def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001314 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001315 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1316
Evan Chengb783fa32007-07-19 01:14:50 +00001317def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001318 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001320def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001321 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001323def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001324 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1326
Evan Chengb783fa32007-07-19 01:14:50 +00001327def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001328 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001330def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001331 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001332 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1333let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001334 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001335 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001336 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001337 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001338 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001340 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001341 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001343 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001344 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001345 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001346 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001347 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001348 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1349 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001350 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001351 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001353 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001354 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1356 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001357 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001358 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001360} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361
1362
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001363let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001364 def XOR8rr : I<0x30, MRMDestReg,
1365 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1366 "xor{b}\t{$src2, $dst|$dst, $src2}",
1367 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1368 def XOR16rr : I<0x31, MRMDestReg,
1369 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1370 "xor{w}\t{$src2, $dst|$dst, $src2}",
1371 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1372 def XOR32rr : I<0x31, MRMDestReg,
1373 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1374 "xor{l}\t{$src2, $dst|$dst, $src2}",
1375 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001376} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377
1378def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001379 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001380 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1382def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001383 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001384 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001385 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1386 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001388 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001389 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1391
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001392def XOR8ri : Ii8<0x80, MRM6r,
1393 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1394 "xor{b}\t{$src2, $dst|$dst, $src2}",
1395 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1396def XOR16ri : Ii16<0x81, MRM6r,
1397 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1398 "xor{w}\t{$src2, $dst|$dst, $src2}",
1399 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1400def XOR32ri : Ii32<0x81, MRM6r,
1401 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1402 "xor{l}\t{$src2, $dst|$dst, $src2}",
1403 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1404def XOR16ri8 : Ii8<0x83, MRM6r,
1405 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1406 "xor{w}\t{$src2, $dst|$dst, $src2}",
1407 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1408 OpSize;
1409def XOR32ri8 : Ii8<0x83, MRM6r,
1410 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1411 "xor{l}\t{$src2, $dst|$dst, $src2}",
1412 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001413
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001414let isTwoAddress = 0 in {
1415 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001416 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1419 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001420 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001421 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1423 OpSize;
1424 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001425 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001426 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1428 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001429 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001430 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001431 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1432 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001433 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001435 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1436 OpSize;
1437 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001438 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1441 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001442 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001443 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001444 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1445 OpSize;
1446 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001447 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001448 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001449 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001450} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001451} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001452
1453// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001454let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001455let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001456def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001457 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001458 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001459def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001461 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001462def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001463 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001464 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001465} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001466
Evan Chengb783fa32007-07-19 01:14:50 +00001467def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001469 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1470let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001471def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001474def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001477// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1478// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001479} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480
1481let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001482 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001483 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001485 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001486 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001487 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001488 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001489 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001491 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1492 }
Evan Chengb783fa32007-07-19 01:14:50 +00001493 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001494 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001495 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001496 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1499 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001500 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001501 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001502 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1503
1504 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001505 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001508 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001509 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1511 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001512 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001513 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1515}
1516
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001517let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001518def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001520 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001521def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001523 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001524def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001525 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001526 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1527}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528
Evan Chengb783fa32007-07-19 01:14:50 +00001529def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001532def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001533 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001534 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001535def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1538
1539// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001540def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001542 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001543def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001544 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001545 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001546def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1549
1550let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001551 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001552 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001554 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001555 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001558 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001559 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001560 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001561 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1562 }
Evan Chengb783fa32007-07-19 01:14:50 +00001563 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001566 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1569 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001570 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1573
1574 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001575 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001577 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001578 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001581 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001582 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1584}
1585
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001586let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001587def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001589 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001590def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001591 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001592 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001593def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001595 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1596}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597
Evan Chengb783fa32007-07-19 01:14:50 +00001598def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001599 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001601def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1604 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001605def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001607 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1608
1609// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001610def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001613def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001616def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001617 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001618 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1619
1620let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001621 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001622 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001624 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001625 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001626 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001627 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001628 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001629 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001630 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1631 }
Evan Chengb783fa32007-07-19 01:14:50 +00001632 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001633 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001635 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1638 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001639 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001640 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001641 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1642
1643 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001644 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001646 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001647 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001648 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001649 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1650 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001651 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1654}
1655
1656// Rotate instructions
1657// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001658let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001659def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001660 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001661 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001662def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001664 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001665def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001667 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1668}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001669
Evan Chengb783fa32007-07-19 01:14:50 +00001670def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001673def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001676def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1679
1680// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001681def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001682 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001683 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001684def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001685 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001686 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001687def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001688 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1690
1691let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001692 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001693 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001694 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001695 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001696 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001698 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001699 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001701 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1702 }
Evan Chengb783fa32007-07-19 01:14:50 +00001703 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001704 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001706 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001707 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001708 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1709 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001710 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1713
1714 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001715 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001718 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1721 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001722 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1725}
1726
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001727let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001728def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001730 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001731def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001733 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001734def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001736 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1737}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738
Evan Chengb783fa32007-07-19 01:14:50 +00001739def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001742def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001743 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001745def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1748
1749// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001750def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001751 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001753def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001756def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1759
1760let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001761 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001762 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001764 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001765 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001766 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001767 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001768 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001770 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1771 }
Evan Chengb783fa32007-07-19 01:14:50 +00001772 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001775 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001776 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001777 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1778 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001779 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1782
1783 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001784 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001787 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001788 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1790 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001791 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1794}
1795
1796
1797
1798// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001799let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001800def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001802 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001803def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001805 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001806def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001808 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001809 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001810def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001813 TB, OpSize;
1814}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815
1816let isCommutable = 1 in { // These instructions commute to each other.
1817def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001818 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001820 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1821 (i8 imm:$src3)))]>,
1822 TB;
1823def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001824 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1827 (i8 imm:$src3)))]>,
1828 TB;
1829def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001830 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1833 (i8 imm:$src3)))]>,
1834 TB, OpSize;
1835def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001836 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001837 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1839 (i8 imm:$src3)))]>,
1840 TB, OpSize;
1841}
1842
1843let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001844 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001845 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001846 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001847 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001848 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001849 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001850 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001851 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001852 addr:$dst)]>, TB;
1853 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001855 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1858 (i8 imm:$src3)), addr:$dst)]>,
1859 TB;
1860 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001861 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001862 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001863 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1864 (i8 imm:$src3)), addr:$dst)]>,
1865 TB;
1866
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001867 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001868 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001871 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001872 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001874 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001875 addr:$dst)]>, TB, OpSize;
1876 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001877 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001878 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001879 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1881 (i8 imm:$src3)), addr:$dst)]>,
1882 TB, OpSize;
1883 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001884 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1887 (i8 imm:$src3)), addr:$dst)]>,
1888 TB, OpSize;
1889}
Evan Cheng55687072007-09-14 21:48:26 +00001890} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891
1892
1893// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001894let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001896def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1897 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1900let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001901def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1902 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001904 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001905def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1906 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1909} // end isConvertibleToThreeAddress
1910} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001911def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1912 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001914 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001915def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1916 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001918 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1919def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1920 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001921 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1923
Evan Chengb783fa32007-07-19 01:14:50 +00001924def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1927
1928let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001929def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1930 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001933def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1934 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001936 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001937def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1938 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001940 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1941def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1942 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001943 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001944 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945}
1946
1947let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001948 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001951 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001953 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001954 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001955 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001956 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001957 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001958 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001961 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001964 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001965 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001968 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001971 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001972 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001973 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1975}
1976
Evan Cheng259471d2007-10-05 17:59:57 +00001977let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001979def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001980 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1982}
Evan Chengb783fa32007-07-19 01:14:50 +00001983def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001984 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001986def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001987 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001989def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001990 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1992
1993let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001994 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001997 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001998 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001999 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002000 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2003}
Evan Cheng259471d2007-10-05 17:59:57 +00002004} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005
Evan Chengb783fa32007-07-19 01:14:50 +00002006def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002009def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002010 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002012def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002015def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002016 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002018def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002019 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002021def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
2024
Evan Chengb783fa32007-07-19 01:14:50 +00002025def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002028def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002031def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002034def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00002037 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002038def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002040 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
2041let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002042 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002045 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002048 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002049 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002050 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002051 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002052 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002053 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002054 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002055 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002058 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002059 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002062 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002063 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002064 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002065 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002066 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002067 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002068 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2069}
2070
Evan Cheng259471d2007-10-05 17:59:57 +00002071let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002072def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002074 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002075
2076let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002077 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002080 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002081 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002083 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002086 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002087 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002088 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089}
Evan Chengb783fa32007-07-19 01:14:50 +00002090def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002093def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002094 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002095 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002096def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002099} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002100} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101
Evan Cheng55687072007-09-14 21:48:26 +00002102let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002104def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002105 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002107def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2110}
Evan Chengb783fa32007-07-19 01:14:50 +00002111def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2114 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002115def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002118} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119} // end Two Address instructions
2120
2121// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002122let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002124 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002125 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2127def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002128 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002129 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2131def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002132 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2135 OpSize;
2136def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002137 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2140
2141def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002142 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002143 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2145 OpSize;
2146def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002147 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002148 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2150def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002151 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2154 OpSize;
2155def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002156 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002159} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160
2161//===----------------------------------------------------------------------===//
2162// Test instructions are just like AND, except they don't generate a result.
2163//
Evan Cheng950aac02007-09-25 01:57:46 +00002164let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002165let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002166def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002167 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002168 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002169 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002170def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002171 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002172 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002173 (implicit EFLAGS)]>,
2174 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002175def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002176 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002177 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002178 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179}
2180
Evan Chengb783fa32007-07-19 01:14:50 +00002181def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002182 "test{b}\t{$src2, $src1|$src1, $src2}",
2183 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2184 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002185def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002186 "test{w}\t{$src2, $src1|$src1, $src2}",
2187 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2188 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002189def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002190 "test{l}\t{$src2, $src1|$src1, $src2}",
2191 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2192 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193
2194def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002195 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002197 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002198 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002200 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002202 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002203 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002205 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002206 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002207 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002208 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002209
Evan Cheng621216e2007-09-29 00:00:36 +00002210def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002211 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002213 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2214 (implicit EFLAGS)]>;
2215def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002216 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002218 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2219 (implicit EFLAGS)]>, OpSize;
2220def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002221 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002222 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002223 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002224 (implicit EFLAGS)]>;
2225} // Defs = [EFLAGS]
2226
2227
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002228// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002229let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002230def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002231let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002232def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002233
Evan Cheng950aac02007-09-25 01:57:46 +00002234let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002235def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002236 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002237 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002238 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002239 TB; // GR8 = ==
2240def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002241 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002242 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002243 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244 TB; // [mem8] = ==
2245def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002246 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002247 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002248 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002249 TB; // GR8 = !=
2250def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002251 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002253 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254 TB; // [mem8] = !=
2255def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002256 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002258 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259 TB; // GR8 = < signed
2260def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002261 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002262 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002263 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264 TB; // [mem8] = < signed
2265def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002266 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002268 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 TB; // GR8 = >= signed
2270def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002271 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002273 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274 TB; // [mem8] = >= signed
2275def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002276 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002278 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002279 TB; // GR8 = <= signed
2280def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002281 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002283 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002284 TB; // [mem8] = <= signed
2285def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002286 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002288 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289 TB; // GR8 = > signed
2290def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002291 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002292 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002293 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294 TB; // [mem8] = > signed
2295
2296def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002297 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002299 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 TB; // GR8 = < unsign
2301def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002302 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002303 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002304 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002305 TB; // [mem8] = < unsign
2306def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002307 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002308 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002309 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002310 TB; // GR8 = >= unsign
2311def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002312 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002313 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002314 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315 TB; // [mem8] = >= unsign
2316def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002317 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002319 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002320 TB; // GR8 = <= unsign
2321def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002322 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002323 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002324 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002325 TB; // [mem8] = <= unsign
2326def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002327 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002328 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002329 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002330 TB; // GR8 = > signed
2331def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002332 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002334 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002335 TB; // [mem8] = > signed
2336
2337def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002338 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002340 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002341 TB; // GR8 = <sign bit>
2342def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002343 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002344 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002345 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002346 TB; // [mem8] = <sign bit>
2347def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002348 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002350 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002351 TB; // GR8 = !<sign bit>
2352def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002353 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002354 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002355 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 TB; // [mem8] = !<sign bit>
2357def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002358 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002359 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002360 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002361 TB; // GR8 = parity
2362def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002363 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002364 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002365 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002366 TB; // [mem8] = parity
2367def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002368 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002369 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002370 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002371 TB; // GR8 = not parity
2372def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002373 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002374 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002375 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002376 TB; // [mem8] = not parity
Evan Cheng950aac02007-09-25 01:57:46 +00002377} // Uses = [EFLAGS]
2378
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379
2380// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002381let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002382def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002383 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002384 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002385 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002386def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002387 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002388 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002389 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002391 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002392 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002393 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002394def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002395 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002396 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002397 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2398 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002399def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002400 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002401 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002402 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2403 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002405 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002406 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002407 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2408 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002409def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002410 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002411 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002412 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2413 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002414def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002415 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002416 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002417 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2418 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002419def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002420 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002421 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002422 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2423 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002424def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002425 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002426 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002427 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002428def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002429 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002431 [(X86cmp GR16:$src1, imm:$src2),
2432 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002433def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002434 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002435 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002436 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002437def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002438 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002439 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002440 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2441 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002442def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002443 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002444 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002445 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2446 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002448 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002449 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002450 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2451 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002452def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002453 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002455 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2456 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002457def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002458 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002459 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002460 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2461 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002462def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002463 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002464 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002465 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2466 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002467def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002468 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002469 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002470 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002471 (implicit EFLAGS)]>;
2472} // Defs = [EFLAGS]
2473
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002474// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002475// Use movsbl intead of movsbw; we don't care about the high 16 bits
2476// of the register here. This has a smaller encoding and avoids a
2477// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002478def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002479 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2480 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002481def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002482 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2483 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002484def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002485 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002487def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002488 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002489 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002490def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002491 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002492 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002493def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002494 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002495 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2496
Dan Gohman9203ab42008-07-30 18:09:17 +00002497// Use movzbl intead of movzbw; we don't care about the high 16 bits
2498// of the register here. This has a smaller encoding and avoids a
2499// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002500def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002501 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2502 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002503def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002504 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2505 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002506def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002507 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002509def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002510 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002511 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002512def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002513 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002514 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002515def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002516 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002517 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2518
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002519let neverHasSideEffects = 1 in {
2520 let Defs = [AX], Uses = [AL] in
2521 def CBW : I<0x98, RawFrm, (outs), (ins),
2522 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2523 let Defs = [EAX], Uses = [AX] in
2524 def CWDE : I<0x98, RawFrm, (outs), (ins),
2525 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002526
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002527 let Defs = [AX,DX], Uses = [AX] in
2528 def CWD : I<0x99, RawFrm, (outs), (ins),
2529 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2530 let Defs = [EAX,EDX], Uses = [EAX] in
2531 def CDQ : I<0x99, RawFrm, (outs), (ins),
2532 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2533}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002534
2535//===----------------------------------------------------------------------===//
2536// Alias Instructions
2537//===----------------------------------------------------------------------===//
2538
2539// Alias instructions that map movr0 to xor.
2540// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002541let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002542def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002543 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002544 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002545// Use xorl instead of xorw since we don't care about the high 16 bits,
2546// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002547def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002548 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2549 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002550def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002551 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002552 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002553}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554
2555// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2556// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002557let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002558def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002559 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002560def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002561 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002562
Evan Chengb783fa32007-07-19 01:14:50 +00002563def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002564 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002565def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002566 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002567} // neverHasSideEffects
2568
2569let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002570def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002571 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002572def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002573 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002574}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002575let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002576def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002577 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002578def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002579 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002580}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581
2582//===----------------------------------------------------------------------===//
2583// Thread Local Storage Instructions
2584//
2585
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002586let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002587def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2588 "leal\t${sym:mem}(,%ebx,1), $dst",
2589 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002590
2591let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002592def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002593 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002594 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2595
2596let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002597def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002598 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002599 [(set GR32:$dst,
2600 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2601
Evan Chengb783fa32007-07-19 01:14:50 +00002602def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002603 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002604 [(set GR32:$dst, X86TLStp)]>;
2605
2606//===----------------------------------------------------------------------===//
2607// DWARF Pseudo Instructions
2608//
2609
Evan Chengb783fa32007-07-19 01:14:50 +00002610def DWARF_LOC : I<0, Pseudo, (outs),
2611 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002612 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2614 (i32 imm:$file))]>;
2615
2616//===----------------------------------------------------------------------===//
2617// EH Pseudo Instructions
2618//
2619let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002620 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002621def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002622 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002623 [(X86ehret GR32:$addr)]>;
2624
2625}
2626
2627//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002628// Atomic support
2629//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002630
Evan Cheng3e171562008-04-19 01:20:30 +00002631// Atomic swap. These are just normal xchg instructions. But since a memory
2632// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00002633let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00002634def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2635 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2636 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2637def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2638 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2639 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2640 OpSize;
2641def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2642 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2643 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2644}
2645
Evan Chengd49dbb82008-04-18 20:55:36 +00002646// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002647let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002648def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002649 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002650 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002651}
Dale Johannesenf160d802008-10-02 18:53:47 +00002652let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00002653def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00002654 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00002655 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2656}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002657
2658let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002659def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002660 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002661 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002662}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002663let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002664def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002665 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002666 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002667}
2668
Evan Chengd49dbb82008-04-18 20:55:36 +00002669// Atomic exchange and add
2670let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2671def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002672 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002673 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002674 TB, LOCK;
2675def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002676 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002677 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002678 TB, OpSize, LOCK;
2679def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002680 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002681 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002682 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002683}
2684
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002685// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00002686let Constraints = "$val = $dst", Defs = [EFLAGS],
2687 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002688def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002689 "#ATOMAND32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002690 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002691def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002692 "#ATOMOR32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002693 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002694def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002695 "#ATOMXOR32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002696 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00002697def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002698 "#ATOMNAND32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002699 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002700def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002701 "#ATOMMIN32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002702 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002703def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002704 "#ATOMMAX32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002705 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002706def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002707 "#ATOMUMIN32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002708 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002709def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002710 "#ATOMUMAX32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002711 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002712
2713def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2714 "#ATOMAND16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002715 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002716def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2717 "#ATOMOR16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002718 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002719def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2720 "#ATOMXOR16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002721 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002722def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2723 "#ATOMNAND16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002724 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002725def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2726 "#ATOMMIN16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002727 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002728def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2729 "#ATOMMAX16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002730 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002731def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2732 "#ATOMUMIN16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002733 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002734def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2735 "#ATOMUMAX16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002736 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002737
2738def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2739 "#ATOMAND8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002740 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002741def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2742 "#ATOMOR8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002743 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002744def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2745 "#ATOMXOR8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002746 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002747def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2748 "#ATOMNAND8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002749 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00002750}
2751
Dale Johannesenf160d802008-10-02 18:53:47 +00002752let Constraints = "$val1 = $dst1, $val2 = $dst2",
2753 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
2754 Uses = [EAX, EBX, ECX, EDX],
2755 usesCustomDAGSchedInserter = 1 in {
2756def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2757 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2758 "#ATOMAND6432 PSUEDO!", []>;
2759def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2760 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2761 "#ATOMOR6432 PSUEDO!", []>;
2762def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2763 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2764 "#ATOMXOR6432 PSUEDO!", []>;
2765def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2766 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2767 "#ATOMNAND6432 PSUEDO!", []>;
2768def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2769 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2770 "#ATOMADD6432 PSUEDO!", []>;
2771def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
2772 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
2773 "#ATOMSUB6432 PSUEDO!", []>;
2774}
2775
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002776//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002777// Non-Instruction Patterns
2778//===----------------------------------------------------------------------===//
2779
Bill Wendlingfef06052008-09-16 21:48:12 +00002780// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002781def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2782def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00002783def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002784def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2785def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2786
2787def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2788 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2789def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2790 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2791def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2792 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2793def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2794 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2795
2796def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2797 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2798def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2799 (MOV32mi addr:$dst, texternalsym:$src)>;
2800
2801// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002802// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002803def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002804 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002805
2806def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002807 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002809 (TAILCALL)>;
2810
2811def : Pat<(X86tcret GR32:$dst, imm:$off),
2812 (TCRETURNri GR32:$dst, imm:$off)>;
2813
2814def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2815 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2816
2817def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2818 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002819
2820def : Pat<(X86call (i32 tglobaladdr:$dst)),
2821 (CALLpcrel32 tglobaladdr:$dst)>;
2822def : Pat<(X86call (i32 texternalsym:$dst)),
2823 (CALLpcrel32 texternalsym:$dst)>;
2824
2825// X86 specific add which produces a flag.
2826def : Pat<(addc GR32:$src1, GR32:$src2),
2827 (ADD32rr GR32:$src1, GR32:$src2)>;
2828def : Pat<(addc GR32:$src1, (load addr:$src2)),
2829 (ADD32rm GR32:$src1, addr:$src2)>;
2830def : Pat<(addc GR32:$src1, imm:$src2),
2831 (ADD32ri GR32:$src1, imm:$src2)>;
2832def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2833 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2834
2835def : Pat<(subc GR32:$src1, GR32:$src2),
2836 (SUB32rr GR32:$src1, GR32:$src2)>;
2837def : Pat<(subc GR32:$src1, (load addr:$src2)),
2838 (SUB32rm GR32:$src1, addr:$src2)>;
2839def : Pat<(subc GR32:$src1, imm:$src2),
2840 (SUB32ri GR32:$src1, imm:$src2)>;
2841def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2842 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2843
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002844// Comparisons.
2845
2846// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00002847def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002848 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002849def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002850 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002851def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002852 (TEST32rr GR32:$src1, GR32:$src1)>;
2853
Duncan Sands082524c2008-01-23 20:39:46 +00002854// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002855def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2856def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2857def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2858
2859// extload bool -> extload byte
2860def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002861def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
2862 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002863def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002864def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
2865 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002866def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2867def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2868
Dan Gohmandd612bb2008-08-20 21:27:32 +00002869// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002870def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
2871 Requires<[In32BitMode]>;
2872def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
2873 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00002874def : Pat<(i32 (anyext GR16:$src)),
2875 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002876
Evan Chengf2abee72007-12-13 00:43:27 +00002877// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00002878def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
2879 (MOVZX32rm8 addr:$src)>;
2880def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
2881 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00002882
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883//===----------------------------------------------------------------------===//
2884// Some peepholes
2885//===----------------------------------------------------------------------===//
2886
Dan Gohman9203ab42008-07-30 18:09:17 +00002887// r & (2^16-1) ==> movz
2888def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002889 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002890// r & (2^8-1) ==> movz
2891def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002892 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
2893 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002894 Requires<[In32BitMode]>;
2895// r & (2^8-1) ==> movz
2896def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002897 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
2898 x86_subreg_8bit)))>,
2899 Requires<[In32BitMode]>;
2900
2901// sext_inreg patterns
2902def : Pat<(sext_inreg GR32:$src, i16),
2903 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
2904def : Pat<(sext_inreg GR32:$src, i8),
2905 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
2906 x86_subreg_8bit)))>,
2907 Requires<[In32BitMode]>;
2908def : Pat<(sext_inreg GR16:$src, i8),
2909 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
2910 x86_subreg_8bit)))>,
2911 Requires<[In32BitMode]>;
2912
2913// trunc patterns
2914def : Pat<(i16 (trunc GR32:$src)),
2915 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
2916def : Pat<(i8 (trunc GR32:$src)),
2917 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
2918 Requires<[In32BitMode]>;
2919def : Pat<(i8 (trunc GR16:$src)),
2920 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002921 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002922
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002923// (shl x, 1) ==> (add x, x)
2924def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2925def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2926def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2927
Evan Cheng76a64c72008-08-30 02:03:58 +00002928// (shl x (and y, 31)) ==> (shl x, y)
2929def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
2930 (SHL8rCL GR8:$src1)>;
2931def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
2932 (SHL16rCL GR16:$src1)>;
2933def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
2934 (SHL32rCL GR32:$src1)>;
2935def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2936 (SHL8mCL addr:$dst)>;
2937def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2938 (SHL16mCL addr:$dst)>;
2939def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2940 (SHL32mCL addr:$dst)>;
2941
2942def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
2943 (SHR8rCL GR8:$src1)>;
2944def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
2945 (SHR16rCL GR16:$src1)>;
2946def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
2947 (SHR32rCL GR32:$src1)>;
2948def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2949 (SHR8mCL addr:$dst)>;
2950def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2951 (SHR16mCL addr:$dst)>;
2952def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2953 (SHR32mCL addr:$dst)>;
2954
2955def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
2956 (SAR8rCL GR8:$src1)>;
2957def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
2958 (SAR16rCL GR16:$src1)>;
2959def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
2960 (SAR32rCL GR32:$src1)>;
2961def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2962 (SAR8mCL addr:$dst)>;
2963def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2964 (SAR16mCL addr:$dst)>;
2965def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2966 (SAR32mCL addr:$dst)>;
2967
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002968// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2969def : Pat<(or (srl GR32:$src1, CL:$amt),
2970 (shl GR32:$src2, (sub 32, CL:$amt))),
2971 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2972
2973def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2974 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2975 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2976
2977// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2978def : Pat<(or (shl GR32:$src1, CL:$amt),
2979 (srl GR32:$src2, (sub 32, CL:$amt))),
2980 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2981
2982def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2983 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2984 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2985
2986// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2987def : Pat<(or (srl GR16:$src1, CL:$amt),
2988 (shl GR16:$src2, (sub 16, CL:$amt))),
2989 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2990
2991def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2992 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2993 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2994
2995// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2996def : Pat<(or (shl GR16:$src1, CL:$amt),
2997 (srl GR16:$src2, (sub 16, CL:$amt))),
2998 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2999
3000def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3001 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3002 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3003
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003004//===----------------------------------------------------------------------===//
3005// Floating Point Stack Support
3006//===----------------------------------------------------------------------===//
3007
3008include "X86InstrFPStack.td"
3009
3010//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003011// X86-64 Support
3012//===----------------------------------------------------------------------===//
3013
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003014include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003015
3016//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003017// XMM Floating point support (requires SSE / SSE2)
3018//===----------------------------------------------------------------------===//
3019
3020include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003021
3022//===----------------------------------------------------------------------===//
3023// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3024//===----------------------------------------------------------------------===//
3025
3026include "X86InstrMMX.td"